@@ -865,7 +865,7 @@ void get_command() {
865865
866866 if (drain_queued_commands_P ()) return ; // priority is given to non-serial commands
867867
868- #ifdef NO_TIMEOUTS
868+ #if ENABLED( NO_TIMEOUTS)
869869 static millis_t last_command_time = 0 ;
870870 millis_t ms = millis ();
871871
@@ -880,7 +880,7 @@ void get_command() {
880880 //
881881 while (MYSERIAL.available () > 0 && commands_in_queue < BUFSIZE) {
882882
883- #ifdef NO_TIMEOUTS
883+ #if ENABLED( NO_TIMEOUTS)
884884 last_command_time = ms;
885885 #endif
886886
@@ -905,15 +905,13 @@ void get_command() {
905905 #endif
906906
907907 char *npos = strchr (command, ' N' );
908- if (npos == NULL ) npos = strchr (command, ' n' );
909908 char *apos = strchr (command, ' *' );
910909 if (npos) {
911910
912- boolean M110 = strstr_P (command, PSTR (" M110" )) != NULL || strstr_P (command, PSTR ( " m110 " )) != NULL ;
911+ boolean M110 = strstr_P (command, PSTR (" M110" )) != NULL ;
913912
914913 if (M110) {
915914 char *n2pos = strchr (command + 4 , ' N' );
916- if (n2pos == NULL ) n2pos = strchr (command + 4 , ' n' );
917915 if (n2pos) npos = n2pos;
918916 }
919917
@@ -924,8 +922,6 @@ void get_command() {
924922 return ;
925923 }
926924
927- gcode_LastN = gcode_N;
928-
929925 if (apos) {
930926 byte checksum = 0 , count = 0 ;
931927 while (command[count] != ' *' ) checksum ^= command[count++];
@@ -940,6 +936,9 @@ void get_command() {
940936 gcode_line_error (PSTR (MSG_ERR_NO_CHECKSUM));
941937 return ;
942938 }
939+
940+ gcode_LastN = gcode_N;
941+ // if no errors, continue parsing
943942 }
944943 else if (apos) { // No '*' without 'N'
945944 gcode_line_error (PSTR (MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM), false );
@@ -949,7 +948,6 @@ void get_command() {
949948 // Movement commands alert when stopped
950949 if (IsStopped ()) {
951950 char *gpos = strchr (command, ' G' );
952- if (gpos == NULL ) gpos = strchr (command, ' g' );
953951 if (gpos) {
954952 int codenum = strtol (gpos + 1 , NULL , 10 );
955953 switch (codenum) {
@@ -965,7 +963,7 @@ void get_command() {
965963 }
966964
967965 // If command was e-stop process now
968- if (strcmp (command, " M112" ) == 0 || strcmp (command, " m112 " ) == 0 ) kill (PSTR (MSG_KILLED));
966+ if (strcmp (command, " M112" ) == 0 ) kill (PSTR (MSG_KILLED));
969967
970968 cmd_queue_index_w = (cmd_queue_index_w + 1 ) % BUFSIZE;
971969 commands_in_queue += 1 ;
@@ -1050,7 +1048,7 @@ bool code_has_value() {
10501048
10511049float code_value () {
10521050 float ret;
1053- char *e = strchr (seen_pointer, ' E' ); if (e == NULL ) e = strchr (seen_pointer, ' e ' );
1051+ char *e = strchr (seen_pointer, ' E' );
10541052 if (e) {
10551053 *e = 0 ;
10561054 ret = strtod (seen_pointer + 1 , NULL );
@@ -1067,7 +1065,6 @@ int16_t code_value_short() { return (int16_t)strtol(seen_pointer + 1, NULL, 10);
10671065
10681066bool code_seen (char code) {
10691067 seen_pointer = strchr (current_command_args, code); // +3 since "G0 " is the shortest prefix
1070- if (seen_pointer == NULL ) seen_pointer = strchr (current_command_args, code + (' a' -' A' ));
10711068 return (seen_pointer != NULL ); // Return True if a character was found
10721069}
10731070
@@ -3554,8 +3551,9 @@ inline void gcode_G28() {
35543551 double eqnAMatrix[abl2 * 3 ], // "A" matrix of the linear system of equations
35553552 eqnBVector[abl2]; // "B" vector of Z points
35563553
3554+ int8_t indexIntoAB[auto_bed_leveling_grid_points][auto_bed_leveling_grid_points];
35573555 int probePointCounter = 0 ;
3558- bool zig = true ;
3556+ bool zig = (auto_bed_leveling_grid_points & 1 ) ? true : false ; // always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
35593557
35603558 for (int yCount = 0 ; yCount < auto_bed_leveling_grid_points; yCount++) {
35613559 double yProbe = front_probe_bed_position + yGridSpacing * yCount;
@@ -3572,9 +3570,8 @@ inline void gcode_G28() {
35723570 xInc = -1 ;
35733571 }
35743572
3575- // If do_topography_map is set then don't zig-zag. Just scan in one direction.
3576- // This gets the probe points in more readable order.
3577- if (!do_topography_map) zig = !zig;
3573+ zig = !zig;
3574+
35783575 for (int xCount = xStart; xCount != xStop; xCount += xInc) {
35793576 double xProbe = left_probe_bed_position + xGridSpacing * xCount;
35803577
@@ -3606,6 +3603,7 @@ inline void gcode_G28() {
36063603 eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
36073604 eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
36083605 eqnAMatrix[probePointCounter + 2 * abl2] = 1 ;
3606+ indexIntoAB[xCount][yCount] = probePointCounter;
36093607
36103608 probePointCounter++;
36113609
@@ -3661,7 +3659,7 @@ inline void gcode_G28() {
36613659 for (int8_t yy = auto_bed_leveling_grid_points - 1 ; yy >= 0 ; yy--) {
36623660 ECHO_S (DB);
36633661 for (int8_t xx = 0 ; xx < auto_bed_leveling_grid_points; xx++) {
3664- int8_t ind = yy * auto_bed_leveling_grid_points + xx ;
3662+ int8_t ind = indexIntoAB[xx][yy] ;
36653663
36663664 float diff = eqnBVector[ind];
36673665
@@ -3679,7 +3677,7 @@ inline void gcode_G28() {
36793677 for (int8_t yy = auto_bed_leveling_grid_points - 1 ; yy >= 0 ; yy--) {
36803678 ECHO_S (DB);
36813679 for (int8_t xx = 0 ; xx < auto_bed_leveling_grid_points; xx++) {
3682- int8_t ind = yy * auto_bed_leveling_grid_points + xx ;
3680+ int8_t ind = indexIntoAB[xx][yy] ;
36833681
36843682 float diff = eqnBVector[ind] - min_diff;
36853683
@@ -3697,7 +3695,7 @@ inline void gcode_G28() {
36973695 for (int8_t yy = auto_bed_leveling_grid_points - 1 ; yy >= 0 ; yy--) {
36983696 ECHO_S (DB);
36993697 for (int8_t xx = 0 ; xx < auto_bed_leveling_grid_points; xx++) {
3700- int8_t ind = yy * auto_bed_leveling_grid_points + xx ;
3698+ int8_t ind = indexIntoAB[xx][yy] ;
37013699
37023700 vector_3 probe_point = vector_3 (eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
37033701 probe_point.apply_rotation (inverse_bed_level_matrix);
@@ -3718,7 +3716,7 @@ inline void gcode_G28() {
37183716 for (int8_t yy = auto_bed_leveling_grid_points - 1 ; yy >= 0 ; yy--) {
37193717 ECHO_S (DB);
37203718 for (int8_t xx = 0 ; xx < auto_bed_leveling_grid_points; xx++) {
3721- int8_t ind = yy * auto_bed_leveling_grid_points + xx ;
3719+ int8_t ind = indexIntoAB[xx][yy] ;
37223720
37233721 vector_3 probe_point = vector_3 (eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
37243722 probe_point.apply_rotation (inverse_bed_level_matrix);
@@ -6321,7 +6319,7 @@ inline void gcode_M999() {
63216319inline void gcode_T (uint8_t tmp_extruder) {
63226320 long csteps;
63236321 if (tmp_extruder >= EXTRUDERS) {
6324- ECHO_SMV (DB, " T" , tmp_extruder);
6322+ ECHO_SMV (DB, " T" , ( int ) tmp_extruder);
63256323 ECHO_EM (" " MSG_INVALID_EXTRUDER);
63266324 }
63276325 else {
@@ -6524,10 +6522,10 @@ inline void gcode_T(uint8_t tmp_extruder) {
65246522 if (csteps > 0 ) colorstep (csteps,true );
65256523 old_color = active_extruder = target_extruder;
65266524 active_driver = 0 ;
6527- ECHO_LMV (DB, MSG_ACTIVE_COLOR, active_extruder);
6525+ ECHO_LMV (DB, MSG_ACTIVE_COLOR, ( int ) active_extruder);
65286526 #else
65296527 active_driver = active_extruder = target_extruder;
6530- ECHO_LMV (DB, MSG_ACTIVE_EXTRUDER, active_extruder);
6528+ ECHO_LMV (DB, MSG_ACTIVE_EXTRUDER, ( int ) active_extruder);
65316529
65326530 #endif // end MKR4 || NPR2
65336531 #endif // end no DUAL_X_CARRIAGE
0 commit comments