Kaynağa Gözat

Improve ExtUI, fix compiler errors, warnings (#14441)

Marcio Teixeira 4 yıl önce
ebeveyn
işleme
e6cf7860e8

+ 2
- 2
Marlin/Makefile Dosyayı Görüntüle

@@ -666,8 +666,8 @@ LIBWARN = -w -Wno-packed-bitfield-compat
666 666
 CSTANDARD = -std=gnu99
667 667
 CXXSTANDARD = -std=gnu++11
668 668
 CDEBUG = -g$(DEBUG)
669
-CWARN   = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas
670
-CXXWARN = -Wall                     -Wno-packed-bitfield-compat -Wno-pragmas
669
+CWARN   = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
670
+CXXWARN = -Wall                     -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
671 671
 CTUNING = -fsigned-char -funsigned-bitfields -fpack-struct -fno-exceptions \
672 672
           -fshort-enums -ffunction-sections -fdata-sections
673 673
 ifneq ($(HARDWARE_MOTHERBOARD),)

+ 6
- 0
Marlin/src/feature/backlash.h Dosyayı Görüntüle

@@ -68,6 +68,9 @@ public:
68 68
       #endif
69 69
       0
70 70
     );
71
+    #if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
72
+      UNUSED(e);
73
+    #endif
71 74
   }
72 75
 
73 76
   static inline bool has_measurement(const uint8_t e) {
@@ -76,6 +79,9 @@ public:
76 79
         || (measured_count[e] > 0)
77 80
       #endif
78 81
     );
82
+    #if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
83
+      UNUSED(e);
84
+    #endif
79 85
   }
80 86
 
81 87
   static inline bool has_any_measurement() {

+ 1
- 1
Marlin/src/feature/tmc_util.cpp Dosyayı Görüntüle

@@ -985,7 +985,7 @@
985 985
     st.TCOOLTHRS(0xFFFFF);
986 986
     return true;
987 987
   }
988
-  void tmc_disable_stallguard(TMC2209Stepper &st, const bool restore_stealth) {
988
+  void tmc_disable_stallguard(TMC2209Stepper &st, const bool restore_stealth _UNUSED) {
989 989
     st.TCOOLTHRS(0);
990 990
   }
991 991
 

+ 6
- 0
Marlin/src/gcode/calibrate/G425.cpp Dosyayı Görüntüle

@@ -411,9 +411,13 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
411 411
     SERIAL_ECHOLNPGM("Nozzle Tip Outer Dimensions:");
412 412
     #if HAS_X_CENTER
413 413
       SERIAL_ECHOLNPAIR(" X", m.nozzle_outer_dimension[X_AXIS]);
414
+    #else
415
+      UNUSED(m);
414 416
     #endif
415 417
     #if HAS_Y_CENTER
416 418
       SERIAL_ECHOLNPAIR(" Y", m.nozzle_outer_dimension[Y_AXIS]);
419
+    #else
420
+      UNUSED(m);
417 421
     #endif
418 422
     SERIAL_EOL();
419 423
   }
@@ -518,6 +522,8 @@ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const
518 522
 
519 523
   #if HOTENDS > 1
520 524
     set_nozzle(m, extruder);
525
+  #else
526
+    UNUSED(extruder);
521 527
   #endif
522 528
 
523 529
   probe_sides(m, uncertainty);

+ 2
- 2
Marlin/src/gcode/config/M92.cpp Dosyayı Görüntüle

@@ -40,9 +40,9 @@ void report_M92(const bool echo=true, const int8_t e=-1) {
40 40
       SERIAL_ECHOPAIR(" M92 T", (int)i);
41 41
       SERIAL_ECHOLNPAIR(" E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
42 42
     }
43
-  #else
44
-    UNUSED(e);
45 43
   #endif
44
+
45
+  UNUSED_E(e);
46 46
 }
47 47
 
48 48
 /**

+ 19
- 17
Marlin/src/gcode/queue.cpp Dosyayı Görüntüle

@@ -90,6 +90,13 @@ GCodeQueue::GCodeQueue() {
90 90
 }
91 91
 
92 92
 /**
93
+ * Check whether there are any commands yet to be executed
94
+ */
95
+bool GCodeQueue::has_commands_queued() {
96
+  return queue.length || injected_commands_P;
97
+}
98
+
99
+/**
93 100
  * Clear the Marlin command queue
94 101
  */
95 102
 void GCodeQueue::clear() {
@@ -154,6 +161,8 @@ bool GCodeQueue::enqueue_one(const char* cmd) {
154 161
 
155 162
 /**
156 163
  * Process the next "immediate" command.
164
+ * Return 'true' if any commands were processed,
165
+ * or remain to process.
157 166
  */
158 167
 bool GCodeQueue::process_injected_command() {
159 168
   if (injected_commands_P == nullptr) return false;
@@ -161,19 +170,16 @@ bool GCodeQueue::process_injected_command() {
161 170
   char c;
162 171
   size_t i = 0;
163 172
   while ((c = pgm_read_byte(&injected_commands_P[i])) && c != '\n') i++;
164
-  if (!i) return false;
165
-
166
-  char cmd[i + 1];
167
-  memcpy_P(cmd, injected_commands_P, i);
168
-  cmd[i] = '\0';
173
+  if (i) {
174
+    char cmd[i + 1];
175
+    memcpy_P(cmd, injected_commands_P, i);
176
+    cmd[i] = '\0';
169 177
 
178
+    parser.parse(cmd);
179
+    PORT_REDIRECT(SERIAL_PORT);
180
+    gcode.process_parsed_command();
181
+  }
170 182
   injected_commands_P = c ? injected_commands_P + i + 1 : nullptr;
171
-
172
-  parser.parse(cmd);
173
-  PORT_REDIRECT(SERIAL_PORT);
174
-  gcode.process_parsed_command();
175
-  PORT_RESTORE();
176
-
177 183
   return true;
178 184
 }
179 185
 
@@ -183,17 +189,13 @@ bool GCodeQueue::process_injected_command() {
183 189
  * Aborts the current queue, if any.
184 190
  * Note: process_injected_command() will be called to drain any commands afterwards
185 191
  */
186
-void GCodeQueue::inject_P(PGM_P const pgcode) {
187
-  injected_commands_P = pgcode;
188
-}
192
+void GCodeQueue::inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; }
189 193
 
190 194
 /**
191 195
  * Enqueue and return only when commands are actually enqueued.
192 196
  * Never call this from a G-code handler!
193 197
  */
194
-void GCodeQueue::enqueue_one_now(const char* cmd) {
195
-  while (!enqueue_one(cmd)) idle();
196
-}
198
+void GCodeQueue::enqueue_one_now(const char* cmd) { while (!enqueue_one(cmd)) idle(); }
197 199
 
198 200
 /**
199 201
  * Enqueue from program memory and return only when commands are actually enqueued

+ 5
- 0
Marlin/src/gcode/queue.h Dosyayı Görüntüle

@@ -85,6 +85,11 @@ public:
85 85
   static void enqueue_now_P(PGM_P const cmd);
86 86
 
87 87
   /**
88
+   * Check whether there are any commands yet to be executed
89
+   */
90
+  static bool has_commands_queued();
91
+
92
+  /**
88 93
    * Get the next command in the queue, optionally log it to SD, then dispatch it
89 94
    */
90 95
   static void advance();

+ 2
- 0
Marlin/src/inc/Conditionals_LCD.h Dosyayı Görüntüle

@@ -451,10 +451,12 @@
451 451
 #if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1
452 452
   #define XYZE_N (XYZ + E_STEPPERS)
453 453
   #define E_AXIS_N(E) AxisEnum(E_AXIS + E)
454
+  #define UNUSED_E(E) NOOP
454 455
 #else
455 456
   #undef DISTINCT_E_FACTORS
456 457
   #define XYZE_N XYZE
457 458
   #define E_AXIS_N(E) E_AXIS
459
+  #define UNUSED_E(E) UNUSED(E)
458 460
 #endif
459 461
 
460 462
 /**

+ 36
- 8
Marlin/src/lcd/extensible_ui/ui_api.cpp Dosyayı Görüntüle

@@ -242,18 +242,28 @@ namespace ExtUI {
242 242
   }
243 243
 
244 244
   float getTargetFan_percent(const fan_t fan) {
245
-    return thermalManager.fanPercent(thermalManager.fan_speed[fan - FAN0]);
245
+    #if FAN_COUNT > 0
246
+      return thermalManager.fanPercent(thermalManager.fan_speed[fan - FAN0]);
247
+    #else
248
+      UNUSED(fan);
249
+      return 0;
250
+    #endif
246 251
   }
247 252
 
248 253
   float getActualFan_percent(const fan_t fan) {
249
-    return thermalManager.fanPercent(thermalManager.scaledFanSpeed(fan - FAN0));
254
+    #if FAN_COUNT > 0
255
+      return thermalManager.fanPercent(thermalManager.scaledFanSpeed(fan - FAN0));
256
+    #else
257
+      UNUSED(fan);
258
+      return 0;
259
+    #endif
250 260
   }
251 261
 
252 262
   float getAxisPosition_mm(const axis_t axis) {
253 263
     return flags.manual_motion ? destination[axis] : current_position[axis];
254 264
   }
255 265
 
256
-  float getAxisPosition_mm(const extruder_t extruder) {
266
+  float getAxisPosition_mm(const extruder_t) {
257 267
     return flags.manual_motion ? destination[E_AXIS] : current_position[E_AXIS];
258 268
   }
259 269
 
@@ -353,6 +363,9 @@ namespace ExtUI {
353 363
         if (e != active_extruder) tool_change(e, no_move);
354 364
       #endif
355 365
       active_extruder = e;
366
+    #else
367
+      UNUSED(extruder);
368
+      UNUSED(no_move);
356 369
     #endif
357 370
   }
358 371
 
@@ -506,6 +519,7 @@ namespace ExtUI {
506 519
   }
507 520
 
508 521
   float getAxisSteps_per_mm(const extruder_t extruder) {
522
+    UNUSED_E(extruder);
509 523
     return planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)];
510 524
   }
511 525
 
@@ -514,6 +528,7 @@ namespace ExtUI {
514 528
   }
515 529
 
516 530
   void setAxisSteps_per_mm(const float value, const extruder_t extruder) {
531
+    UNUSED_E(extruder);
517 532
     planner.settings.axis_steps_per_mm[E_AXIS_N(axis - E0)] = value;
518 533
   }
519 534
 
@@ -522,6 +537,7 @@ namespace ExtUI {
522 537
   }
523 538
 
524 539
   float getAxisMaxFeedrate_mm_s(const extruder_t extruder) {
540
+    UNUSED_E(extruder);
525 541
     return planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)];
526 542
   }
527 543
 
@@ -530,6 +546,7 @@ namespace ExtUI {
530 546
   }
531 547
 
532 548
   void setAxisMaxFeedrate_mm_s(const float value, const extruder_t extruder) {
549
+    UNUSED_E(extruder);
533 550
     planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)] = value;
534 551
   }
535 552
 
@@ -538,6 +555,7 @@ namespace ExtUI {
538 555
   }
539 556
 
540 557
   float getAxisMaxAcceleration_mm_s2(const extruder_t extruder) {
558
+    UNUSED_E(extruder);
541 559
     return planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)];
542 560
   }
543 561
 
@@ -546,6 +564,7 @@ namespace ExtUI {
546 564
   }
547 565
 
548 566
   void setAxisMaxAcceleration_mm_s2(const float value, const extruder_t extruder) {
567
+    UNUSED_E(extruder);
549 568
     planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)] = value;
550 569
   }
551 570
 
@@ -589,7 +608,7 @@ namespace ExtUI {
589 608
       return planner.max_jerk[axis];
590 609
     }
591 610
 
592
-    float getAxisMaxJerk_mm_s(const extruder_t extruder) {
611
+    float getAxisMaxJerk_mm_s(const extruder_t) {
593 612
       return planner.max_jerk[E_AXIS];
594 613
     }
595 614
 
@@ -597,7 +616,7 @@ namespace ExtUI {
597 616
       planner.max_jerk[axis] = value;
598 617
     }
599 618
 
600
-    void setAxisMaxJerk_mm_s(const float value, const extruder_t extruder) {
619
+    void setAxisMaxJerk_mm_s(const float value, const extruder_t) {
601 620
       planner.max_jerk[E_AXIS] = value;
602 621
     }
603 622
   #endif
@@ -780,12 +799,16 @@ namespace ExtUI {
780 799
     queue.inject_P(gcode);
781 800
   }
782 801
 
783
-  bool commandsInQueue() { return (planner.movesplanned() || queue.length); }
802
+  bool commandsInQueue() { return (planner.movesplanned() || queue.has_commands_queued()); }
784 803
 
785 804
   bool isAxisPositionKnown(const axis_t axis) {
786 805
     return TEST(axis_known_position, axis);
787 806
   }
788 807
 
808
+  bool isAxisPositionKnown(const extruder_t) {
809
+    return TEST(axis_known_position, E_AXIS);
810
+  }
811
+
789 812
   bool isPositionKnown() { return all_axes_known(); }
790 813
   bool isMachineHomed() { return all_axes_homed(); }
791 814
 
@@ -814,8 +837,13 @@ namespace ExtUI {
814 837
   }
815 838
 
816 839
   void setTargetFan_percent(const float value, const fan_t fan) {
817
-    if (fan < FAN_COUNT)
818
-      thermalManager.set_fan_speed(fan - FAN0, map(clamp(value, 0, 100), 0, 100, 0, 255));
840
+    #if FAN_COUNT > 0
841
+      if (fan < FAN_COUNT)
842
+        thermalManager.set_fan_speed(fan - FAN0, map(clamp(value, 0, 100), 0, 100, 0, 255));
843
+    #else
844
+      UNUSED(value);
845
+      UNUSED(fan);
846
+    #endif
819 847
   }
820 848
 
821 849
   void setFeedrate_percent(const float value) {

+ 1
- 1
Marlin/src/lcd/menu/menu_sdcard.cpp Dosyayı Görüntüle

@@ -93,7 +93,7 @@ inline void sdcard_start_selected_file() {
93 93
 
94 94
 class MenuItem_sdfile {
95 95
   public:
96
-    static void action(CardReader &theCard) {
96
+    static void action(CardReader &) {
97 97
       #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
98 98
         // Save menu state for the selected file
99 99
         sd_encoder_position = ui.encoderPosition;

Loading…
İptal
Kaydet