Browse Source

Add heater timeouts to ExtUI (#13970)

- Add local UI methods to get heater timeout state.
- Add methods to resume timed-out heaters.
- Re-enable heaters on UI temperature request.
- Make `ExtUI` show a dialog box if pause needs a button press after reheat.
Marcio Teixeira 6 years ago
parent
commit
227f29090d

+ 10
- 0
Marlin/src/feature/pause.cpp View File

49
   #include "host_actions.h"
49
   #include "host_actions.h"
50
 #endif
50
 #endif
51
 
51
 
52
+#if ENABLED(EXTENSIBLE_UI)
53
+  #include "../lcd/extensible_ui/ui_api.h"
54
+#endif
55
+
52
 #include "../lcd/ultralcd.h"
56
 #include "../lcd/ultralcd.h"
53
 #include "../libs/buzzer.h"
57
 #include "../libs/buzzer.h"
54
 #include "../libs/nozzle.h"
58
 #include "../libs/nozzle.h"
538
       #if ENABLED(HOST_PROMPT_SUPPORT)
542
       #if ENABLED(HOST_PROMPT_SUPPORT)
539
         host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheating"));
543
         host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheating"));
540
       #endif
544
       #endif
545
+      #if ENABLED(EXTENSIBLE_UI)
546
+        ExtUI::onStatusChanged(PSTR("Reheating..."));
547
+      #endif
541
 
548
 
542
       // Re-enable the heaters if they timed out
549
       // Re-enable the heaters if they timed out
543
       HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e);
550
       HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e);
555
       #if ENABLED(HOST_PROMPT_SUPPORT)
562
       #if ENABLED(HOST_PROMPT_SUPPORT)
556
         host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), PSTR("Continue"));
563
         host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), PSTR("Continue"));
557
       #endif
564
       #endif
565
+      #if ENABLED(EXTENSIBLE_UI)
566
+        ExtUI::onUserConfirmRequired("Reheat finished.");
567
+      #endif
558
       wait_for_user = true;
568
       wait_for_user = true;
559
       nozzle_timed_out = false;
569
       nozzle_timed_out = false;
560
 
570
 

+ 53
- 33
Marlin/src/lcd/extensible_ui/ui_api.cpp View File

148
     }
148
     }
149
   #endif // __SAM3X8E__
149
   #endif // __SAM3X8E__
150
 
150
 
151
-  void delay_us(unsigned long us) {
152
-    DELAY_US(us);
153
-  }
151
+  void delay_us(unsigned long us) { DELAY_US(us); }
154
 
152
 
155
   void delay_ms(unsigned long ms) {
153
   void delay_ms(unsigned long ms) {
156
     if (flags.printer_killed)
154
     if (flags.printer_killed)
164
       thermalManager.manage_heater();
162
       thermalManager.manage_heater();
165
   }
163
   }
166
 
164
 
165
+  void enableHeater(const extruder_t extruder) {
166
+    #if HEATER_IDLE_HANDLER
167
+      thermalManager.reset_heater_idle_timer(extruder - E0);
168
+    #endif
169
+  }
170
+
171
+  void enableHeater(const heater_t heater) {
172
+    #if HEATER_IDLE_HANDLER
173
+      #if HAS_HEATED_BED
174
+        if (heater == BED)
175
+          thermalManager.reset_bed_idle_timer();
176
+        else
177
+      #endif
178
+          thermalManager.reset_heater_idle_timer(heater - H0);
179
+    #endif
180
+  }
181
+
182
+  bool isHeaterIdle(const extruder_t extruder) {
183
+    return false
184
+      #if HEATER_IDLE_HANDLER
185
+        || thermalManager.hotend_idle[extruder - E0].timed_out
186
+      #endif
187
+    ;
188
+  }
189
+
190
+  bool isHeaterIdle(const heater_t heater) {
191
+    return (false
192
+      #if HEATER_IDLE_HANDLER
193
+        || (heater == BED ? (false
194
+          #if HAS_HEATED_BED
195
+            || thermalManager.bed_idle.timed_out
196
+          #endif
197
+        ) : thermalManager.hotend_idle[heater - H0].timed_out)
198
+      #endif
199
+    );
200
+  }
201
+
167
   float getActualTemp_celsius(const heater_t heater) {
202
   float getActualTemp_celsius(const heater_t heater) {
168
-    return heater == BED ?
203
+    return heater == BED ? (0
169
       #if HAS_HEATED_BED
204
       #if HAS_HEATED_BED
170
-        thermalManager.degBed()
171
-      #else
172
-        0
205
+        + thermalManager.degBed()
173
       #endif
206
       #endif
174
-      : thermalManager.degHotend(heater - H0);
207
+    ) : thermalManager.degHotend(heater - H0);
175
   }
208
   }
176
 
209
 
177
   float getActualTemp_celsius(const extruder_t extruder) {
210
   float getActualTemp_celsius(const extruder_t extruder) {
179
   }
212
   }
180
 
213
 
181
   float getTargetTemp_celsius(const heater_t heater) {
214
   float getTargetTemp_celsius(const heater_t heater) {
182
-    return heater == BED ?
215
+    return heater == BED ? (0
183
       #if HAS_HEATED_BED
216
       #if HAS_HEATED_BED
184
-        thermalManager.degTargetBed()
185
-      #else
186
-        0
217
+        + thermalManager.degTargetBed()
187
       #endif
218
       #endif
188
-      : thermalManager.degTargetHotend(heater - H0);
219
+    ) : thermalManager.degTargetHotend(heater - H0);
189
   }
220
   }
190
 
221
 
191
   float getTargetTemp_celsius(const extruder_t extruder) {
222
   float getTargetTemp_celsius(const extruder_t extruder) {
252
       }
283
       }
253
     #endif
284
     #endif
254
 
285
 
255
-    if (!flags.manual_motion)
256
-      set_destination_from_current();
286
+    if (!flags.manual_motion) set_destination_from_current();
257
     destination[axis] = clamp(position, min, max);
287
     destination[axis] = clamp(position, min, max);
258
     flags.manual_motion = true;
288
     flags.manual_motion = true;
259
   }
289
   }
261
   void setAxisPosition_mm(const float position, const extruder_t extruder) {
291
   void setAxisPosition_mm(const float position, const extruder_t extruder) {
262
     setActiveTool(extruder, true);
292
     setActiveTool(extruder, true);
263
 
293
 
264
-    if (!flags.manual_motion)
265
-      set_destination_from_current();
294
+    if (!flags.manual_motion) set_destination_from_current();
266
     destination[E_AXIS] = position;
295
     destination[E_AXIS] = position;
267
     flags.manual_motion = true;
296
     flags.manual_motion = true;
268
   }
297
   }
303
     #if EXTRUDERS > 1
332
     #if EXTRUDERS > 1
304
       const uint8_t e = extruder - E0;
333
       const uint8_t e = extruder - E0;
305
       #if DO_SWITCH_EXTRUDER || EITHER(SWITCHING_NOZZLE, PARKING_EXTRUDER)
334
       #if DO_SWITCH_EXTRUDER || EITHER(SWITCHING_NOZZLE, PARKING_EXTRUDER)
306
-        if (e != active_extruder)
307
-          tool_change(e, 0, no_move);
335
+        if (e != active_extruder) tool_change(e, 0, no_move);
308
       #endif
336
       #endif
309
       active_extruder = e;
337
       active_extruder = e;
310
     #endif
338
     #endif
341
   }
369
   }
342
 
370
 
343
   #if HAS_SOFTWARE_ENDSTOPS
371
   #if HAS_SOFTWARE_ENDSTOPS
344
-    bool getSoftEndstopState() {
345
-      return soft_endstops_enabled;
346
-    }
347
-
348
-    void setSoftEndstopState(const bool value) {
349
-      soft_endstops_enabled = value;
350
-    }
372
+    bool getSoftEndstopState() { return soft_endstops_enabled; }
373
+    void setSoftEndstopState(const bool value) { soft_endstops_enabled = value; }
351
   #endif
374
   #endif
352
 
375
 
353
   #if HAS_TRINAMIC
376
   #if HAS_TRINAMIC
513
     void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; }
536
     void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; }
514
 
537
 
515
     #ifdef FILAMENT_RUNOUT_DISTANCE_MM
538
     #ifdef FILAMENT_RUNOUT_DISTANCE_MM
516
-      float getFilamentRunoutDistance_mm() {
517
-        return runout.runout_distance();
518
-      }
519
-
520
-      void setFilamentRunoutDistance_mm(const float value) {
521
-        runout.set_runout_distance(clamp(value, 0, 999));
522
-      }
539
+      float getFilamentRunoutDistance_mm()                 { return runout.runout_distance(); }
540
+      void setFilamentRunoutDistance_mm(const float value) { runout.set_runout_distance(clamp(value, 0, 999)); }
523
     #endif
541
     #endif
524
   #endif
542
   #endif
525
 
543
 
761
   void setTargetTemp_celsius(float value, const heater_t heater) {
779
   void setTargetTemp_celsius(float value, const heater_t heater) {
762
     constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
780
     constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
763
     const int16_t e = heater - H0;
781
     const int16_t e = heater - H0;
782
+    enableHeater(heater);
764
     #if HAS_HEATED_BED
783
     #if HAS_HEATED_BED
765
       if (heater == BED)
784
       if (heater == BED)
766
         thermalManager.setTargetBed(clamp(value, 0, BED_MAXTEMP - 10));
785
         thermalManager.setTargetBed(clamp(value, 0, BED_MAXTEMP - 10));
772
   void setTargetTemp_celsius(float value, const extruder_t extruder) {
791
   void setTargetTemp_celsius(float value, const extruder_t extruder) {
773
     constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
792
     constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
774
     const int16_t e = extruder - E0;
793
     const int16_t e = extruder - E0;
794
+    enableHeater(extruder);
775
     thermalManager.setTargetHotend(clamp(value, 0, heater_maxtemp[e] - 15), e);
795
     thermalManager.setTargetHotend(clamp(value, 0, heater_maxtemp[e] - 15), e);
776
   }
796
   }
777
 
797
 

+ 5
- 0
Marlin/src/lcd/extensible_ui/ui_api.h View File

70
   void enqueueCommands_P(PGM_P const);
70
   void enqueueCommands_P(PGM_P const);
71
   bool commandsInQueue();
71
   bool commandsInQueue();
72
 
72
 
73
+  bool isHeaterIdle(const heater_t);
74
+  bool isHeaterIdle(const extruder_t);
75
+  void enableHeater(const heater_t);
76
+  void enableHeater(const extruder_t);
77
+
73
   /**
78
   /**
74
    * Getters and setters
79
    * Getters and setters
75
    * Should be used by the EXTENSIBLE_UI to query or change Marlin's state.
80
    * Should be used by the EXTENSIBLE_UI to query or change Marlin's state.

Loading…
Cancel
Save