<commit_before>#include "Arduino.h"

#define MAX_PARSE_VALUES 9
// 9 is the max number of values I need to store for one single command. for example:
// b x1,y1, ax1,ay1, ax2,ay2, x2,y2, targetspeed  = 9 values

float fVals[MAX_PARSE_VALUES];	// float values
float lVals[MAX_PARSE_VALUES];	// long values

/****
 *
 * PARSED LETTERS
 *
 * a	Arc
 * b	Bezier
 * c	Callibrate (find home)
 * d	Debug       : set debug level
 * e	Ellipse
 * f	Files       : display a list of files
 * g
 * h	Home        : go to home position (0,0)
 * i	bezierResolution
 * j
 * k    Kill        : delete a file
 * l	Lineto      : put the pen down and go to position (x,y)
 * m	Moveto      : move the pen to position (x,y,z)
 * n	tool selection: 1 = Pen, 2 = Brush
 * o	Origin      : set as origin
 * p	Print       : draw a file
 * q
 * r	Radius		: knife radius
 * s	Speeds (delays)
 * t	Testrun
 * u	Microsteps
 * v    v : rotation (0,1,2,3 times 90 degrees)
 * w	Write to file
 * x	X times : scale the drawing from file
 * y
 * z    Enable/disable z axis
 *
 ****/


//------------------------------------------------------------
void parseMessage(char* input, int length) {
	if (length  < 1) { // BAD MESSAGE!
		print("BAD message: too short '");
		print(input);
		println("'");
		return;
	}
	float value = 0; // calculate number following the command
	if (length > 1) {
		value = atof(&input[1]); //<< length needs to be at least 2 to make this fail safe!
	}
	switch (input[0]) {
			// MOVES
		case 'A':
		case 'a':	// draw an arc
			parseArc(&input[1], length - 1);
			break;
			
		case 'B':
		case 'b':	// draw a bezier path
			parseBezier(&input[1], length - 1);
			break;
			
		case 'C':
		case 'c':	// find home
			findHome();
			break;
			
		case 'E':
		case 'e':	// draw an ellipse
			parseEllipse(&input[1], length - 1);
			break;
			
		case 'h':
		case 'H':	// go back home!
			goHome();
			break;
			
			
		case 'l':
		case 'L':	// Line to
			parseLineTo(&input[1], length - 1);
			break;
			
		case 'm':	// Move to
			parseMoveTo(&input[1], length - 1);
			break;
		case 'M':	// Relative move to
			parseRelativeMoveTo(&input[1], length - 1);
			break;
			
		case 'o':
		case 'O':	// set origin
			setHome();
			break;
			
			// SETTINGS
			
		case 'd':
		case 'D':	// toggle debug statements off / on / A LOT
			debug = (bool)value;
			switch (debug) {
				case 0:
					println("Debug is OFF");
					break;
				case 1:
					println("Debug is ON");
					break;
				case 2:
					println("Debug is ON HIGH ALERT");
					break;
			}
			break;
		case 'n':
		case 'N':
			tool = (int)value;
			switch (tool) {
				default:
					println("tool set to UNKNOWN");
					break;
				case 1:
					println("tool set to PEN");
					break;
				case 2:
					println("tool set to BRUSH");
					break;
				case 3:
					println("tool set to KNIFE");
					break;
			}
			break;
		case 'i':
		case 'I':	// set bezier resolution
			bezierResolution = (int)value;
			if (bezierResolution == 0.0f) bezierResolution = 1.0f;
			if (debug) {
				print("Bezier Resolution: ");
				println((int)bezierResolution);
			}
			break;
			
		case 'r':
		case 'R':	//set resolution for circles
			knifeRadius = value;
			if (knifeRadius < 0) knifeRadius = 1;<commit_msg>fixed feedback for tool light<commit_after>#include "Arduino.h"

#define MAX_PARSE_VALUES 9
// 9 is the max number of values I need to store for one single command. for example:
// b x1,y1, ax1,ay1, ax2,ay2, x2,y2, targetspeed  = 9 values

float fVals[MAX_PARSE_VALUES];	// float values
float lVals[MAX_PARSE_VALUES];	// long values

/****
 *
 * PARSED LETTERS
 *
 * a	Arc
 * b	Bezier
 * c	Callibrate (find home)
 * d	Debug       : set debug level
 * e	Ellipse
 * f	Files       : display a list of files
 * g
 * h	Home        : go to home position (0,0)
 * i	bezierResolution
 * j
 * k    Kill        : delete a file
 * l	Lineto      : put the pen down and go to position (x,y)
 * m	Moveto      : move the pen to position (x,y,z)
 * n	tool selection: 1 = Pen, 2 = Brush
 * o	Origin      : set as origin
 * p	Print       : draw a file
 * q
 * r	Radius		: knife radius
 * s	Speeds (delays)
 * t	Testrun
 * u	Microsteps
 * v    v : rotation (0,1,2,3 times 90 degrees)
 * w	Write to file
 * x	X times : scale the drawing from file
 * y
 * z    Enable/disable z axis
 *
 ****/


//------------------------------------------------------------
void parseMessage(char* input, int length) {
	if (length  < 1) { // BAD MESSAGE!
		print("BAD message: too short '");
		print(input);
		println("'");
		return;
	}
	float value = 0; // calculate number following the command
	if (length > 1) {
		value = atof(&input[1]); //<< length needs to be at least 2 to make this fail safe!
	}
	switch (input[0]) {
			// MOVES
		case 'A':
		case 'a':	// draw an arc
			parseArc(&input[1], length - 1);
			break;
			
		case 'B':
		case 'b':	// draw a bezier path
			parseBezier(&input[1], length - 1);
			break;
			
		case 'C':
		case 'c':	// find home
			findHome();
			break;
			
		case 'E':
		case 'e':	// draw an ellipse
			parseEllipse(&input[1], length - 1);
			break;
			
		case 'h':
		case 'H':	// go back home!
			goHome();
			break;
			
			
		case 'l':
		case 'L':	// Line to
			parseLineTo(&input[1], length - 1);
			break;
			
		case 'm':	// Move to
			parseMoveTo(&input[1], length - 1);
			break;
		case 'M':	// Relative move to
			parseRelativeMoveTo(&input[1], length - 1);
			break;
			
		case 'o':
		case 'O':	// set origin
			setHome();
			break;
			
			// SETTINGS
			
		case 'd':
		case 'D':	// toggle debug statements off / on / A LOT
			debug = (bool)value;
			switch (debug) {
				case 0:
					println("Debug is OFF");
					break;
				case 1:
					println("Debug is ON");
					break;
				case 2:
					println("Debug is ON HIGH ALERT");
					break;
			}
			break;
		case 'n':
		case 'N':
			tool = (int)value;
			switch (tool) {
				default:
					println("tool set to UNKNOWN");
					break;
				case 1:
					println("tool set to PEN");
					break;
				case 2:
					println("tool set to BRUSH");
					break;
				case 3:
					println("tool set to KNIFE");
					break;
				case 4:
					println("tool set to LIGHT");
					break;
			}
			break;
		case 'i':
		case 'I':	// set bezier resolution
			bezierResolution = (int)value;
			if (bezierResolution == 0.0f) bezierResolution = 1.0f;
			if (debug) {
				print("Bezier Resolution: ");
				println((int)bezierResolution);
			}
			break;
			
		case 'r':
		case 'R':	//set resolution for circles
			knifeRadius = value;
			if (knifeRadius < 0) knifeRadius = 1;
{'fraction_non_alphanumeric': 0.15345699831365936, 'fraction_numerical': 0.015790280545761152, 'mean_word_length': 2.1516908212560386, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5694602', 'n_tokens_mistral': 2866, 'n_tokens_neox': 2338, 'n_words': 788}