@@ -340,8 +340,9 @@ void teleport(float *pos) {
340340
341341
342342/* *
343- Print a helpful message to serial. The first line must never be changed to play nice with the JAVA software.
344- */
343+ * M100
344+ * Print a helpful message to serial. The first line must never be changed to play nice with the JAVA software.
345+ */
345346void help () {
346347 Serial.print (F (" \n\n HELLO WORLD! " ));
347348 sayModelAndUID ();
@@ -363,6 +364,10 @@ void sayModelAndUID() {
363364}
364365
365366
367+ /* *
368+ * D5
369+ * report current firmware version
370+ */
366371void sayFirmwareVersionNumber () {
367372 char versionNumber = loadVersion ();
368373
@@ -372,9 +377,9 @@ void sayFirmwareVersionNumber() {
372377
373378
374379/* *
375- Print the X,Y,Z, feedrate, and acceleration to serial.
376- Equivalent to gcode M114
377- */
380+ * M114
381+ * Print the X,Y,Z, feedrate, acceleration, and home position
382+ */
378383void where () {
379384 wait_for_empty_segment_buffer ();
380385
@@ -401,8 +406,9 @@ void where() {
401406
402407
403408/* *
404- Print the machine limits to serial.
405- */
409+ * M102
410+ * Print the machine limits to serial.
411+ */
406412void printConfig () {
407413 int i;
408414
@@ -439,8 +445,8 @@ void set_tool_offset(int toolID, float *pos) {
439445
440446
441447/* *
442- @return the position + active tool offset
443- */
448+ * @return the position + active tool offset
449+ */
444450void get_end_plus_offset (float *results) {
445451 int i;
446452 for (i=0 ;i<NUM_AXIES;++i) {
@@ -450,9 +456,10 @@ void get_end_plus_offset(float *results) {
450456
451457
452458/* *
453- Change the currently active tool
454- */
455- void tool_change (int tool_id) {
459+ * M6 [Tnnn]
460+ * Change the currently active tool
461+ */
462+ void toolChange (int tool_id) {
456463 if (tool_id < 0 ) tool_id = 0 ;
457464 if (tool_id >= NUM_TOOLS) tool_id = NUM_TOOLS - 1 ;
458465 current_tool = tool_id;
@@ -465,11 +472,11 @@ void tool_change(int tool_id) {
465472
466473
467474/* *
468- Look for character /code/ in the buffer and read the float that immediately follows it.
469- @return the value found. If nothing is found, /val/ is returned.
470- @input code the character to look for.
471- @input val the return value if /code/ is not found.
472- ** /
475+ * Look for character /code/ in the buffer and read the float that immediately follows it.
476+ * @return the value found. If nothing is found, /val/ is returned.
477+ * @input code the character to look for.
478+ * @input val the return value if /code/ is not found.
479+ */
473480float parseNumber (char code, float val) {
474481 char *ptr = serialBuffer; // start at the beginning of buffer
475482 while ((long )ptr > 1 && (*ptr) && (long )ptr < (long )serialBuffer + sofar) { // walk to the end
@@ -481,13 +488,22 @@ float parseNumber(char code, float val) {
481488 return val; // end reached, nothing found, return default val.
482489}
483490
491+
492+ /* *
493+ * G4 [Snn] [Pnn]
494+ * Wait S milliseconds and P seconds.
495+ */
484496void parseDwell () {
485497 wait_for_empty_segment_buffer ();
486498 float delayTime = parseNumber (' S' , 0 ) + parseNumber (' P' , 0 ) * 1000 .0f ;
487499 pause (delayTime);
488500}
489501
490502
503+ /* *
504+ * G0-G1 [Xnnn] [Ynnn] [Znnn] [Unnn] [Vnnn] [Wnnn] [Ann] [Fnn]
505+ * straight lines
506+ */
491507void parseLine () {
492508 float offset[NUM_AXIES];
493509 get_end_plus_offset (offset);
@@ -505,8 +521,9 @@ void parseLine() {
505521
506522
507523/* *
524+ * G2-G3 [Xnnn] [Ynnn] [Ann] [Fnn] [Inn] [Jnn]
508525 * arcs in the XY plane
509- * @param clockwise 1 for cw, 0 for ccw
526+ * @param clockwise (G2) 1 for cw, (G3) 0 for ccw
510527 */
511528void parseArc (int clockwise) {
512529 float offset[NUM_AXIES];
@@ -528,6 +545,10 @@ void parseArc(int clockwise) {
528545}
529546
530547
548+ /* *
549+ * G92 [Xnnn] [Ynnn] [Znnn] [Unnn] [Vnnn] [Wnnn]
550+ * Teleport mental position
551+ */
531552void parseTeleport () {
532553 float offset[NUM_AXIES];
533554 get_end_plus_offset (offset);
@@ -541,6 +562,10 @@ void parseTeleport() {
541562}
542563
543564
565+ /* *
566+ * G54-G59 [Xnnn] [Ynnn] [Znnn] [Unnn] [Vnnn] [Wnnn]
567+ * Adjust tool offset
568+ */
544569void parseToolOffset (int toolID) {
545570 int i;
546571 float offset[NUM_AXIES];
@@ -650,7 +675,7 @@ void processCommand() {
650675 // M codes
651676 cmd = parseNumber (' M' , -1 );
652677 switch (cmd) {
653- case 6 : tool_change (parseNumber (' T' , current_tool)); break ;
678+ case 6 : toolChange (parseNumber (' T' , current_tool)); break ;
654679 case 17 : motor_engage (); break ;
655680 case 18 : motor_disengage (); break ;
656681 case 100 : help (); break ;
@@ -695,10 +720,7 @@ void processCommand() {
695720 case 4 : SD_StartPrintingFile (strchr (serialBuffer, ' ' ) + 1 ); break ; // read file
696721 case 5 : sayFirmwareVersionNumber (); break ;
697722 case 6 : parseSetHome (); break ;
698- case 7 : // set calibration length
699- calibrateLeft = parseNumber (' L' , calibrateLeft);
700- calibrateRight = parseNumber (' R' , calibrateRight);
701- // fall through to case 8, report calibration.
723+ case 7 : setCalibration (); break ;
702724 case 8 : reportCalibration (); break ;
703725 case 9 : saveCalibration (); break ;
704726 case 10 : // get hardware version
@@ -718,6 +740,9 @@ void processCommand() {
718740
719741
720742#if MACHINE_STYLE == POLARGRAPH
743+ /* *
744+ * D11 makelangelo 5 specific setup call
745+ */
721746void makelangelo5Setup () {
722747 // if you accidentally upload m3 firmware to an m5 then upload it ONCE with this line uncommented.
723748 float limits[NUM_AXIES*2 ];
@@ -743,6 +768,10 @@ void makelangelo5Setup() {
743768#endif
744769
745770
771+ /* *
772+ * D6 [Xnnn] [Ynnn] [Znnn] [Unnn] [Vnnn] [Wnnn]
773+ * Set home position for each axis.
774+ */
746775void parseSetHome () {
747776 int i;
748777 float offset[NUM_AXIES];
@@ -753,6 +782,11 @@ void parseSetHome() {
753782}
754783
755784
785+ /* *
786+ * D0 [Lnn] [Rnn] [Unn] [Vnn] [Wnn] [Tnn]
787+ * Jog each motor nn steps.
788+ * I don't know why the latter motor names are UVWT.
789+ */
756790void jogMotors () {
757791 int i, j, amount;
758792
@@ -788,6 +822,21 @@ void jogMotors() {
788822}
789823
790824
825+ /* *
826+ * D7 [Lnnn] [Rnnn]
827+ * Set calibration length of each belt
828+ */
829+ void setCalibration () {
830+ calibrateLeft = parseNumber (' L' , calibrateLeft);
831+ calibrateRight = parseNumber (' R' , calibrateRight);
832+ reportCalibration ();
833+ }
834+
835+
836+ /* *
837+ * D8
838+ * Report calibration values for left and right belts
839+ */
791840void reportCalibration () {
792841 Serial.print (F (" D8 L" ));
793842 Serial.print (calibrateLeft);
@@ -797,7 +846,7 @@ void reportCalibration() {
797846
798847
799848/* *
800- * equal to some decimal places?
849+ * Compare two floats to the first decimal place.
801850 * return true when abs(a-b)<0.1
802851 */
803852boolean equalEpsilon (float a, float b) {
0 commit comments