Browse Source

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

Marcio Teixeira 5 years ago
parent
commit
e6cf7860e8

+ 2
- 2
Marlin/Makefile View File

666
 CSTANDARD = -std=gnu99
666
 CSTANDARD = -std=gnu99
667
 CXXSTANDARD = -std=gnu++11
667
 CXXSTANDARD = -std=gnu++11
668
 CDEBUG = -g$(DEBUG)
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
 CTUNING = -fsigned-char -funsigned-bitfields -fpack-struct -fno-exceptions \
671
 CTUNING = -fsigned-char -funsigned-bitfields -fpack-struct -fno-exceptions \
672
           -fshort-enums -ffunction-sections -fdata-sections
672
           -fshort-enums -ffunction-sections -fdata-sections
673
 ifneq ($(HARDWARE_MOTHERBOARD),)
673
 ifneq ($(HARDWARE_MOTHERBOARD),)

+ 6
- 0
Marlin/src/feature/backlash.h View File

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

+ 1
- 1
Marlin/src/feature/tmc_util.cpp View File

985
     st.TCOOLTHRS(0xFFFFF);
985
     st.TCOOLTHRS(0xFFFFF);
986
     return true;
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
     st.TCOOLTHRS(0);
989
     st.TCOOLTHRS(0);
990
   }
990
   }
991
 
991
 

+ 6
- 0
Marlin/src/gcode/calibrate/G425.cpp View File

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

+ 2
- 2
Marlin/src/gcode/config/M92.cpp View File

40
       SERIAL_ECHOPAIR(" M92 T", (int)i);
40
       SERIAL_ECHOPAIR(" M92 T", (int)i);
41
       SERIAL_ECHOLNPAIR(" E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
41
       SERIAL_ECHOLNPAIR(" E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
42
     }
42
     }
43
-  #else
44
-    UNUSED(e);
45
   #endif
43
   #endif
44
+
45
+  UNUSED_E(e);
46
 }
46
 }
47
 
47
 
48
 /**
48
 /**

+ 19
- 17
Marlin/src/gcode/queue.cpp View File

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
  * Clear the Marlin command queue
100
  * Clear the Marlin command queue
94
  */
101
  */
95
 void GCodeQueue::clear() {
102
 void GCodeQueue::clear() {
154
 
161
 
155
 /**
162
 /**
156
  * Process the next "immediate" command.
163
  * Process the next "immediate" command.
164
+ * Return 'true' if any commands were processed,
165
+ * or remain to process.
157
  */
166
  */
158
 bool GCodeQueue::process_injected_command() {
167
 bool GCodeQueue::process_injected_command() {
159
   if (injected_commands_P == nullptr) return false;
168
   if (injected_commands_P == nullptr) return false;
161
   char c;
170
   char c;
162
   size_t i = 0;
171
   size_t i = 0;
163
   while ((c = pgm_read_byte(&injected_commands_P[i])) && c != '\n') i++;
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
   injected_commands_P = c ? injected_commands_P + i + 1 : nullptr;
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
   return true;
183
   return true;
178
 }
184
 }
179
 
185
 
183
  * Aborts the current queue, if any.
189
  * Aborts the current queue, if any.
184
  * Note: process_injected_command() will be called to drain any commands afterwards
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
  * Enqueue and return only when commands are actually enqueued.
195
  * Enqueue and return only when commands are actually enqueued.
192
  * Never call this from a G-code handler!
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
  * Enqueue from program memory and return only when commands are actually enqueued
201
  * Enqueue from program memory and return only when commands are actually enqueued

+ 5
- 0
Marlin/src/gcode/queue.h View File

85
   static void enqueue_now_P(PGM_P const cmd);
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
    * Get the next command in the queue, optionally log it to SD, then dispatch it
93
    * Get the next command in the queue, optionally log it to SD, then dispatch it
89
    */
94
    */
90
   static void advance();
95
   static void advance();

+ 2
- 0
Marlin/src/inc/Conditionals_LCD.h View File

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

+ 36
- 8
Marlin/src/lcd/extensible_ui/ui_api.cpp View File

242
   }
242
   }
243
 
243
 
244
   float getTargetFan_percent(const fan_t fan) {
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
   float getActualFan_percent(const fan_t fan) {
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
   float getAxisPosition_mm(const axis_t axis) {
262
   float getAxisPosition_mm(const axis_t axis) {
253
     return flags.manual_motion ? destination[axis] : current_position[axis];
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
     return flags.manual_motion ? destination[E_AXIS] : current_position[E_AXIS];
267
     return flags.manual_motion ? destination[E_AXIS] : current_position[E_AXIS];
258
   }
268
   }
259
 
269
 
353
         if (e != active_extruder) tool_change(e, no_move);
363
         if (e != active_extruder) tool_change(e, no_move);
354
       #endif
364
       #endif
355
       active_extruder = e;
365
       active_extruder = e;
366
+    #else
367
+      UNUSED(extruder);
368
+      UNUSED(no_move);
356
     #endif
369
     #endif
357
   }
370
   }
358
 
371
 
506
   }
519
   }
507
 
520
 
508
   float getAxisSteps_per_mm(const extruder_t extruder) {
521
   float getAxisSteps_per_mm(const extruder_t extruder) {
522
+    UNUSED_E(extruder);
509
     return planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)];
523
     return planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)];
510
   }
524
   }
511
 
525
 
514
   }
528
   }
515
 
529
 
516
   void setAxisSteps_per_mm(const float value, const extruder_t extruder) {
530
   void setAxisSteps_per_mm(const float value, const extruder_t extruder) {
531
+    UNUSED_E(extruder);
517
     planner.settings.axis_steps_per_mm[E_AXIS_N(axis - E0)] = value;
532
     planner.settings.axis_steps_per_mm[E_AXIS_N(axis - E0)] = value;
518
   }
533
   }
519
 
534
 
522
   }
537
   }
523
 
538
 
524
   float getAxisMaxFeedrate_mm_s(const extruder_t extruder) {
539
   float getAxisMaxFeedrate_mm_s(const extruder_t extruder) {
540
+    UNUSED_E(extruder);
525
     return planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)];
541
     return planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)];
526
   }
542
   }
527
 
543
 
530
   }
546
   }
531
 
547
 
532
   void setAxisMaxFeedrate_mm_s(const float value, const extruder_t extruder) {
548
   void setAxisMaxFeedrate_mm_s(const float value, const extruder_t extruder) {
549
+    UNUSED_E(extruder);
533
     planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)] = value;
550
     planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)] = value;
534
   }
551
   }
535
 
552
 
538
   }
555
   }
539
 
556
 
540
   float getAxisMaxAcceleration_mm_s2(const extruder_t extruder) {
557
   float getAxisMaxAcceleration_mm_s2(const extruder_t extruder) {
558
+    UNUSED_E(extruder);
541
     return planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)];
559
     return planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)];
542
   }
560
   }
543
 
561
 
546
   }
564
   }
547
 
565
 
548
   void setAxisMaxAcceleration_mm_s2(const float value, const extruder_t extruder) {
566
   void setAxisMaxAcceleration_mm_s2(const float value, const extruder_t extruder) {
567
+    UNUSED_E(extruder);
549
     planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)] = value;
568
     planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)] = value;
550
   }
569
   }
551
 
570
 
589
       return planner.max_jerk[axis];
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
       return planner.max_jerk[E_AXIS];
612
       return planner.max_jerk[E_AXIS];
594
     }
613
     }
595
 
614
 
597
       planner.max_jerk[axis] = value;
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
       planner.max_jerk[E_AXIS] = value;
620
       planner.max_jerk[E_AXIS] = value;
602
     }
621
     }
603
   #endif
622
   #endif
780
     queue.inject_P(gcode);
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
   bool isAxisPositionKnown(const axis_t axis) {
804
   bool isAxisPositionKnown(const axis_t axis) {
786
     return TEST(axis_known_position, axis);
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
   bool isPositionKnown() { return all_axes_known(); }
812
   bool isPositionKnown() { return all_axes_known(); }
790
   bool isMachineHomed() { return all_axes_homed(); }
813
   bool isMachineHomed() { return all_axes_homed(); }
791
 
814
 
814
   }
837
   }
815
 
838
 
816
   void setTargetFan_percent(const float value, const fan_t fan) {
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
   void setFeedrate_percent(const float value) {
849
   void setFeedrate_percent(const float value) {

+ 1
- 1
Marlin/src/lcd/menu/menu_sdcard.cpp View File

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

Loading…
Cancel
Save