Browse Source

Merge Clean up code_seen (PR#2395)

Richard Wackerbarth 10 years ago
parent
commit
a91263f79e
1 changed files with 16 additions and 16 deletions
  1. 16
    16
      Marlin/Marlin_main.cpp

+ 16
- 16
Marlin/Marlin_main.cpp View File

966
 int16_t code_value_short() { return (int16_t)strtol(seen_pointer + 1, NULL, 10); }
966
 int16_t code_value_short() { return (int16_t)strtol(seen_pointer + 1, NULL, 10); }
967
 
967
 
968
 bool code_seen(char code) {
968
 bool code_seen(char code) {
969
-  seen_pointer = strchr(current_command_args, code); // +3 since "G0 " is the shortest prefix
970
-  return (seen_pointer != NULL);  //Return True if a character was found
969
+  seen_pointer = strchr(current_command_args, code);
970
+  return (seen_pointer != NULL); // Return TRUE if the code-letter was found
971
 }
971
 }
972
 
972
 
973
 #define DEFINE_PGM_READ_ANY(type, reader)       \
973
 #define DEFINE_PGM_READ_ANY(type, reader)       \
2388
   inline void gcode_G29() {
2388
   inline void gcode_G29() {
2389
 
2389
 
2390
     static int probe_point = -1;
2390
     static int probe_point = -1;
2391
-    MeshLevelingState state = code_seen('S') || code_seen('s') ? (MeshLevelingState)code_value_short() : MeshReport;
2391
+    MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_short() : MeshReport;
2392
     if (state < 0 || state > 3) {
2392
     if (state < 0 || state > 3) {
2393
       SERIAL_PROTOCOLLNPGM("S out of range (0-3).");
2393
       SERIAL_PROTOCOLLNPGM("S out of range (0-3).");
2394
       return;
2394
       return;
2466
         break;
2466
         break;
2467
 
2467
 
2468
       case MeshSet:
2468
       case MeshSet:
2469
-        if (code_seen('X') || code_seen('x')) {
2469
+        if (code_seen('X')) {
2470
           ix = code_value_long()-1;
2470
           ix = code_value_long()-1;
2471
           if (ix < 0 || ix >= MESH_NUM_X_POINTS) {
2471
           if (ix < 0 || ix >= MESH_NUM_X_POINTS) {
2472
             SERIAL_PROTOCOLPGM("X out of range (1-" STRINGIFY(MESH_NUM_X_POINTS) ").\n");
2472
             SERIAL_PROTOCOLPGM("X out of range (1-" STRINGIFY(MESH_NUM_X_POINTS) ").\n");
2476
             SERIAL_PROTOCOLPGM("X not entered.\n");
2476
             SERIAL_PROTOCOLPGM("X not entered.\n");
2477
             return;
2477
             return;
2478
         }
2478
         }
2479
-        if (code_seen('Y') || code_seen('y')) {
2479
+        if (code_seen('Y')) {
2480
           iy = code_value_long()-1;
2480
           iy = code_value_long()-1;
2481
           if (iy < 0 || iy >= MESH_NUM_Y_POINTS) {
2481
           if (iy < 0 || iy >= MESH_NUM_Y_POINTS) {
2482
             SERIAL_PROTOCOLPGM("Y out of range (1-" STRINGIFY(MESH_NUM_Y_POINTS) ").\n");
2482
             SERIAL_PROTOCOLPGM("Y out of range (1-" STRINGIFY(MESH_NUM_Y_POINTS) ").\n");
2486
             SERIAL_PROTOCOLPGM("Y not entered.\n");
2486
             SERIAL_PROTOCOLPGM("Y not entered.\n");
2487
             return;
2487
             return;
2488
         }
2488
         }
2489
-        if (code_seen('Z') || code_seen('z')) {
2489
+        if (code_seen('Z')) {
2490
           z = code_value();
2490
           z = code_value();
2491
         } else {
2491
         } else {
2492
           SERIAL_PROTOCOLPGM("Z not entered.\n");
2492
           SERIAL_PROTOCOLPGM("Z not entered.\n");
2553
       return;
2553
       return;
2554
     }
2554
     }
2555
 
2555
 
2556
-    int verbose_level = code_seen('V') || code_seen('v') ? code_value_short() : 1;
2556
+    int verbose_level = code_seen('V') ? code_value_short() : 1;
2557
     if (verbose_level < 0 || verbose_level > 4) {
2557
     if (verbose_level < 0 || verbose_level > 4) {
2558
       SERIAL_ECHOLNPGM("?(V)erbose Level is implausible (0-4).");
2558
       SERIAL_ECHOLNPGM("?(V)erbose Level is implausible (0-4).");
2559
       return;
2559
       return;
2560
     }
2560
     }
2561
 
2561
 
2562
-    bool dryrun = code_seen('D') || code_seen('d'),
2563
-         deploy_probe_for_each_reading = code_seen('E') || code_seen('e');
2562
+    bool dryrun = code_seen('D'),
2563
+         deploy_probe_for_each_reading = code_seen('E');
2564
 
2564
 
2565
     #ifdef AUTO_BED_LEVELING_GRID
2565
     #ifdef AUTO_BED_LEVELING_GRID
2566
 
2566
 
2567
       #ifndef DELTA
2567
       #ifndef DELTA
2568
-        bool do_topography_map = verbose_level > 2 || code_seen('T') || code_seen('t');
2568
+        bool do_topography_map = verbose_level > 2 || code_seen('T');
2569
       #endif
2569
       #endif
2570
 
2570
 
2571
       if (verbose_level > 0) {
2571
       if (verbose_level > 0) {
3223
     double sum = 0.0, mean = 0.0, sigma = 0.0, sample_set[50];
3223
     double sum = 0.0, mean = 0.0, sigma = 0.0, sample_set[50];
3224
     uint8_t verbose_level = 1, n_samples = 10, n_legs = 0;
3224
     uint8_t verbose_level = 1, n_samples = 10, n_legs = 0;
3225
 
3225
 
3226
-    if (code_seen('V') || code_seen('v')) {
3226
+    if (code_seen('V')) {
3227
       verbose_level = code_value_short();
3227
       verbose_level = code_value_short();
3228
       if (verbose_level < 0 || verbose_level > 4 ) {
3228
       if (verbose_level < 0 || verbose_level > 4 ) {
3229
         SERIAL_PROTOCOLPGM("?Verbose Level not plausible (0-4).\n");
3229
         SERIAL_PROTOCOLPGM("?Verbose Level not plausible (0-4).\n");
3234
     if (verbose_level > 0)
3234
     if (verbose_level > 0)
3235
       SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n");
3235
       SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n");
3236
 
3236
 
3237
-    if (code_seen('P') || code_seen('p')) {
3237
+    if (code_seen('P')) {
3238
       n_samples = code_value_short();
3238
       n_samples = code_value_short();
3239
       if (n_samples < 4 || n_samples > 50) {
3239
       if (n_samples < 4 || n_samples > 50) {
3240
         SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n");
3240
         SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n");
3249
            X_probe_location = X_current, Y_probe_location = Y_current,
3249
            X_probe_location = X_current, Y_probe_location = Y_current,
3250
            Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING;
3250
            Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING;
3251
 
3251
 
3252
-    bool deploy_probe_for_each_reading = code_seen('E') || code_seen('e');
3252
+    bool deploy_probe_for_each_reading = code_seen('E');
3253
 
3253
 
3254
-    if (code_seen('X') || code_seen('x')) {
3254
+    if (code_seen('X')) {
3255
       X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
3255
       X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
3256
       if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) {
3256
       if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) {
3257
         out_of_range_error(PSTR("X"));
3257
         out_of_range_error(PSTR("X"));
3259
       }
3259
       }
3260
     }
3260
     }
3261
 
3261
 
3262
-    if (code_seen('Y') || code_seen('y')) {
3262
+    if (code_seen('Y')) {
3263
       Y_probe_location = code_value() -  Y_PROBE_OFFSET_FROM_EXTRUDER;
3263
       Y_probe_location = code_value() -  Y_PROBE_OFFSET_FROM_EXTRUDER;
3264
       if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) {
3264
       if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) {
3265
         out_of_range_error(PSTR("Y"));
3265
         out_of_range_error(PSTR("Y"));
3267
       }
3267
       }
3268
     }
3268
     }
3269
 
3269
 
3270
-    if (code_seen('L') || code_seen('l')) {
3270
+    if (code_seen('L')) {
3271
       n_legs = code_value_short();
3271
       n_legs = code_value_short();
3272
       if (n_legs == 1) n_legs = 2;
3272
       if (n_legs == 1) n_legs = 2;
3273
       if (n_legs < 0 || n_legs > 15) {
3273
       if (n_legs < 0 || n_legs > 15) {

Loading…
Cancel
Save