Browse Source

Merge pull request #5089 from thinkyhead/rc_break_m1_fix

Centralize click-handling in the LCD loop
Scott Lahteine 8 years ago
parent
commit
3c3fe1a1ba
7 changed files with 174 additions and 269 deletions
  1. 1
    1
      Marlin/Marlin.h
  2. 1
    4
      Marlin/MarlinSerial.cpp
  3. 42
    87
      Marlin/Marlin_main.cpp
  4. 26
    37
      Marlin/configuration_store.cpp
  5. 8
    8
      Marlin/planner.h
  6. 67
    99
      Marlin/ultralcd.cpp
  7. 29
    33
      Marlin/ultralcd.h

+ 1
- 1
Marlin/Marlin.h View File

@@ -270,7 +270,7 @@ extern bool axis_known_position[XYZ]; // axis[n].is_known
270 270
 extern bool axis_homed[XYZ]; // axis[n].is_homed
271 271
 extern volatile bool wait_for_heatup;
272 272
 
273
-#if ENABLED(ULTIPANEL) || ENABLED(EMERGENCY_PARSER)
273
+#if ENABLED(EMERGENCY_PARSER) || ENABLED(ULTIPANEL)
274 274
   extern volatile bool wait_for_user;
275 275
 #endif
276 276
 

+ 1
- 4
Marlin/MarlinSerial.cpp View File

@@ -508,10 +508,7 @@ MarlinSerial customizedSerial;
508 508
         if (c == '\n') {
509 509
           switch (state) {
510 510
             case state_M108:
511
-              wait_for_heatup = false;
512
-              #if DISABLED(ULTIPANEL)
513
-                wait_for_user = false;
514
-              #endif
511
+              wait_for_user = wait_for_heatup = false;
515 512
               break;
516 513
             case state_M112:
517 514
               kill(PSTR(MSG_KILLED));

+ 42
- 87
Marlin/Marlin_main.cpp View File

@@ -1046,7 +1046,12 @@ inline void get_serial_commands() {
1046 1046
 
1047 1047
       #if DISABLED(EMERGENCY_PARSER)
1048 1048
         // If command was e-stop process now
1049
-        if (strcmp(command, "M108") == 0) wait_for_heatup = false;
1049
+        if (strcmp(command, "M108") == 0) {
1050
+          wait_for_heatup = false;
1051
+          #if ENABLED(ULTIPANEL)
1052
+            wait_for_user = false;
1053
+          #endif
1054
+        }
1050 1055
         if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
1051 1056
         if (strcmp(command, "M410") == 0) { quickstop_stepper(); }
1052 1057
       #endif
@@ -4414,7 +4419,6 @@ inline void gcode_G92() {
4414 4419
           dontExpireStatus();
4415 4420
         #endif
4416 4421
       }
4417
-      lcd_ignore_click();
4418 4422
 
4419 4423
     #else
4420 4424
 
@@ -4425,53 +4429,28 @@ inline void gcode_G92() {
4425 4429
 
4426 4430
     #endif
4427 4431
 
4428
-    #if ENABLED(EMERGENCY_PARSER)
4429
-      wait_for_user = true;
4430
-    #endif
4431
-
4432
+    wait_for_user = true;
4432 4433
     KEEPALIVE_STATE(PAUSED_FOR_USER);
4433 4434
 
4434 4435
     stepper.synchronize();
4435 4436
     refresh_cmd_timeout();
4436 4437
 
4437
-    #if ENABLED(ULTIPANEL)
4438
-
4439
-      #if ENABLED(EMERGENCY_PARSER)
4440
-        #define M1_WAIT_CONDITION (!lcd_clicked() && wait_for_user)
4438
+    if (codenum > 0) {
4439
+      codenum += previous_cmd_ms;  // wait until this time for a click
4440
+      while (PENDING(millis(), codenum) && wait_for_user) idle();
4441
+    }
4442
+    else {
4443
+      #if ENABLED(ULTIPANEL)
4444
+        if (lcd_detected()) {
4445
+          while (wait_for_user) idle();
4446
+          IS_SD_PRINTING ? LCD_MESSAGEPGM(MSG_RESUMING) : LCD_MESSAGEPGM(WELCOME_MSG);
4447
+        }
4441 4448
       #else
4442
-        #define M1_WAIT_CONDITION !lcd_clicked()
4449
+        while (wait_for_user) idle();
4443 4450
       #endif
4451
+    }
4444 4452
 
4445
-      if (codenum > 0) {
4446
-        codenum += previous_cmd_ms;  // wait until this time for a click
4447
-        while (PENDING(millis(), codenum) && M1_WAIT_CONDITION) idle();
4448
-        lcd_ignore_click(false);
4449
-      }
4450
-      else if (lcd_detected()) {
4451
-        while (M1_WAIT_CONDITION) idle();
4452
-      }
4453
-      else goto ExitM1;
4454
-
4455
-      IS_SD_PRINTING ? LCD_MESSAGEPGM(MSG_RESUMING) : LCD_MESSAGEPGM(WELCOME_MSG);
4456
-
4457
-    #else
4458
-
4459
-      if (codenum > 0) {
4460
-        codenum += previous_cmd_ms;  // wait until this time for an M108
4461
-        while (PENDING(millis(), codenum) && wait_for_user) idle();
4462
-      }
4463
-      else while (wait_for_user) idle();
4464
-
4465
-    #endif
4466
-
4467
-#if ENABLED(ULTIPANEL)
4468
-  ExitM1:
4469
-#endif
4470
-
4471
-    #if ENABLED(EMERGENCY_PARSER)
4472
-      wait_for_user = false;
4473
-    #endif
4474
-
4453
+    wait_for_user = false;
4475 4454
     KEEPALIVE_STATE(IN_HANDLER);
4476 4455
   }
4477 4456
 
@@ -5539,47 +5518,27 @@ inline void gcode_M140() {
5539 5518
    *   F<fan speed>
5540 5519
    */
5541 5520
   inline void gcode_M145() {
5542
-    int8_t material = code_seen('S') ? (int8_t)code_value_int() : 0;
5543
-    if (material < 0 || material > 1) {
5521
+    uint8_t material = code_seen('S') ? (uint8_t)code_value_int() : 0;
5522
+    if (material >= COUNT(lcd_preheat_hotend_temp)) {
5544 5523
       SERIAL_ERROR_START;
5545 5524
       SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
5546 5525
     }
5547 5526
     else {
5548 5527
       int v;
5549
-      switch (material) {
5550
-        case 0:
5551
-          if (code_seen('H')) {
5552
-            v = code_value_int();
5553
-            preheatHotendTemp1 = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
5554
-          }
5555
-          if (code_seen('F')) {
5556
-            v = code_value_int();
5557
-            preheatFanSpeed1 = constrain(v, 0, 255);
5558
-          }
5559
-          #if TEMP_SENSOR_BED != 0
5560
-            if (code_seen('B')) {
5561
-              v = code_value_int();
5562
-              preheatBedTemp1 = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
5563
-            }
5564
-          #endif
5565
-          break;
5566
-        case 1:
5567
-          if (code_seen('H')) {
5568
-            v = code_value_int();
5569
-            preheatHotendTemp2 = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
5570
-          }
5571
-          if (code_seen('F')) {
5572
-            v = code_value_int();
5573
-            preheatFanSpeed2 = constrain(v, 0, 255);
5574
-          }
5575
-          #if TEMP_SENSOR_BED != 0
5576
-            if (code_seen('B')) {
5577
-              v = code_value_int();
5578
-              preheatBedTemp2 = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
5579
-            }
5580
-          #endif
5581
-          break;
5528
+      if (code_seen('H')) {
5529
+        v = code_value_int();
5530
+        lcd_preheat_hotend_temp[material] = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
5531
+      }
5532
+      if (code_seen('F')) {
5533
+        v = code_value_int();
5534
+        lcd_preheat_fan_speed[material] = constrain(v, 0, 255);
5582 5535
       }
5536
+      #if TEMP_SENSOR_BED != 0
5537
+        if (code_seen('B')) {
5538
+          v = code_value_int();
5539
+          lcd_preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
5540
+        }
5541
+      #endif
5583 5542
     }
5584 5543
   }
5585 5544
 
@@ -5590,13 +5549,9 @@ inline void gcode_M140() {
5590 5549
    * M149: Set temperature units
5591 5550
    */
5592 5551
   inline void gcode_M149() {
5593
-    if (code_seen('C')) {
5594
-      set_input_temp_units(TEMPUNIT_C);
5595
-    } else if (code_seen('K')) {
5596
-      set_input_temp_units(TEMPUNIT_K);
5597
-    } else if (code_seen('F')) {
5598
-      set_input_temp_units(TEMPUNIT_F);
5599
-    }
5552
+         if (code_seen('C')) set_input_temp_units(TEMPUNIT_C);
5553
+    else if (code_seen('K')) set_input_temp_units(TEMPUNIT_K);
5554
+    else if (code_seen('F')) set_input_temp_units(TEMPUNIT_F);
5600 5555
   }
5601 5556
 #endif
5602 5557
 
@@ -6874,7 +6829,10 @@ inline void gcode_M503() {
6874 6829
     // Wait for filament insert by user and press button
6875 6830
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
6876 6831
 
6877
-    while (!lcd_clicked()) {
6832
+    // LCD click or M108 will clear this
6833
+    wait_for_user = true;
6834
+
6835
+    while (wait_for_user) {
6878 6836
       #if HAS_BUZZER
6879 6837
         millis_t ms = millis();
6880 6838
         if (ms >= next_buzz) {
@@ -6884,9 +6842,6 @@ inline void gcode_M503() {
6884 6842
       #endif
6885 6843
       idle(true);
6886 6844
     }
6887
-    delay(100);
6888
-    while (lcd_clicked()) idle(true);
6889
-    delay(100);
6890 6845
 
6891 6846
     // Show load message
6892 6847
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD);

+ 26
- 37
Marlin/configuration_store.cpp View File

@@ -86,12 +86,9 @@
86 86
  *  301  M666 Z    z_endstop_adj (float)
87 87
  *
88 88
  * ULTIPANEL:
89
- *  305  M145 S0 H preheatHotendTemp1 (int)
90
- *  307  M145 S0 B preheatBedTemp1 (int)
91
- *  309  M145 S0 F preheatFanSpeed1 (int)
92
- *  311  M145 S1 H preheatHotendTemp2 (int)
93
- *  313  M145 S1 B preheatBedTemp2 (int)
94
- *  315  M145 S1 F preheatFanSpeed2 (int)
89
+ *  305  M145 S0 H lcd_preheat_hotend_temp (int x2)
90
+ *  309  M145 S0 B lcd_preheat_bed_temp (int x2)
91
+ *  313  M145 S0 F lcd_preheat_fan_speed (int x2)
95 92
  *
96 93
  * PIDTEMP:
97 94
  *  317  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
@@ -277,16 +274,14 @@ void Config_Postprocess() {
277 274
     #endif
278 275
 
279 276
     #if DISABLED(ULTIPANEL)
280
-      int preheatHotendTemp1 = PREHEAT_1_TEMP_HOTEND, preheatBedTemp1 = PREHEAT_1_TEMP_BED, preheatFanSpeed1 = PREHEAT_1_FAN_SPEED,
281
-          preheatHotendTemp2 = PREHEAT_2_TEMP_HOTEND, preheatBedTemp2 = PREHEAT_2_TEMP_BED, preheatFanSpeed2 = PREHEAT_2_FAN_SPEED;
277
+      const int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
278
+                lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
279
+                lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
282 280
     #endif // !ULTIPANEL
283 281
 
284
-    EEPROM_WRITE(preheatHotendTemp1);
285
-    EEPROM_WRITE(preheatBedTemp1);
286
-    EEPROM_WRITE(preheatFanSpeed1);
287
-    EEPROM_WRITE(preheatHotendTemp2);
288
-    EEPROM_WRITE(preheatBedTemp2);
289
-    EEPROM_WRITE(preheatFanSpeed2);
282
+    EEPROM_WRITE(lcd_preheat_hotend_temp);
283
+    EEPROM_WRITE(lcd_preheat_bed_temp);
284
+    EEPROM_WRITE(lcd_preheat_fan_speed);
290 285
 
291 286
     for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
292 287
 
@@ -465,16 +460,12 @@ void Config_Postprocess() {
465 460
       #endif
466 461
 
467 462
       #if DISABLED(ULTIPANEL)
468
-        int preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1,
469
-            preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2;
463
+        int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
470 464
       #endif
471 465
 
472
-      EEPROM_READ(preheatHotendTemp1);
473
-      EEPROM_READ(preheatBedTemp1);
474
-      EEPROM_READ(preheatFanSpeed1);
475
-      EEPROM_READ(preheatHotendTemp2);
476
-      EEPROM_READ(preheatBedTemp2);
477
-      EEPROM_READ(preheatFanSpeed2);
466
+      EEPROM_READ(lcd_preheat_hotend_temp);
467
+      EEPROM_READ(lcd_preheat_bed_temp);
468
+      EEPROM_READ(lcd_preheat_fan_speed);
478 469
 
479 470
       #if ENABLED(PIDTEMP)
480 471
         for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
@@ -639,12 +630,12 @@ void Config_ResetDefault() {
639 630
   #endif
640 631
 
641 632
   #if ENABLED(ULTIPANEL)
642
-    preheatHotendTemp1 = PREHEAT_1_TEMP_HOTEND;
643
-    preheatBedTemp1 = PREHEAT_1_TEMP_BED;
644
-    preheatFanSpeed1 = PREHEAT_1_FAN_SPEED;
645
-    preheatHotendTemp2 = PREHEAT_2_TEMP_HOTEND;
646
-    preheatBedTemp2 = PREHEAT_2_TEMP_BED;
647
-    preheatFanSpeed2 = PREHEAT_2_FAN_SPEED;
633
+    lcd_preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
634
+    lcd_preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
635
+    lcd_preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
636
+    lcd_preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
637
+    lcd_preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
638
+    lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
648 639
   #endif
649 640
 
650 641
   #if HAS_LCD_CONTRAST
@@ -863,15 +854,13 @@ void Config_ResetDefault() {
863 854
         SERIAL_ECHOLNPGM("Material heatup parameters:");
864 855
         CONFIG_ECHO_START;
865 856
       }
866
-      SERIAL_ECHOPAIR("  M145 S0 H", preheatHotendTemp1);
867
-      SERIAL_ECHOPAIR(" B", preheatBedTemp1);
868
-      SERIAL_ECHOPAIR(" F", preheatFanSpeed1);
869
-      SERIAL_EOL;
870
-      CONFIG_ECHO_START;
871
-      SERIAL_ECHOPAIR("  M145 S1 H", preheatHotendTemp2);
872
-      SERIAL_ECHOPAIR(" B", preheatBedTemp2);
873
-      SERIAL_ECHOPAIR(" F", preheatFanSpeed2);
874
-      SERIAL_EOL;
857
+      for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
858
+        SERIAL_ECHOPAIR("  M145 S", (int)i);
859
+        SERIAL_ECHOPAIR(" H", lcd_preheat_hotend_temp[i]);
860
+        SERIAL_ECHOPAIR(" B", lcd_preheat_bed_temp[i]);
861
+        SERIAL_ECHOPAIR(" F", lcd_preheat_fan_speed[i]);
862
+        SERIAL_EOL;
863
+      }
875 864
     #endif // ULTIPANEL
876 865
 
877 866
     #if HAS_PID_HEATING

+ 8
- 8
Marlin/planner.h View File

@@ -264,7 +264,7 @@ class Planner {
264 264
      *  fr_mm_s      - (target) speed of the move (mm/s)
265 265
      *  extruder     - target extruder
266 266
      */
267
-    static FORCE_INLINE void buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, const uint8_t extruder) {
267
+    static FORCE_INLINE void buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, const float &fr_mm_s, const uint8_t extruder) {
268 268
       #if PLANNER_LEVELING && IS_CARTESIAN
269 269
         apply_leveling(lx, ly, lz);
270 270
       #endif
@@ -280,7 +280,7 @@ class Planner {
280 280
      *  fr_mm_s  - (target) speed of the move (mm/s)
281 281
      *  extruder - target extruder
282 282
      */
283
-    static FORCE_INLINE void buffer_line_kinematic(const float target[XYZE], float fr_mm_s, const uint8_t extruder) {
283
+    static FORCE_INLINE void buffer_line_kinematic(const float target[XYZE], const float &fr_mm_s, const uint8_t extruder) {
284 284
       #if PLANNER_LEVELING
285 285
         float pos[XYZ] = { target[X_AXIS], target[Y_AXIS], target[Z_AXIS] };
286 286
         apply_leveling(pos);
@@ -311,9 +311,9 @@ class Planner {
311 311
       _set_position_mm(lx, ly, lz, e);
312 312
     }
313 313
     static void set_position_mm_kinematic(const float position[NUM_AXIS]);
314
-    static void set_position_mm(const AxisEnum axis, const float& v);
315
-    static FORCE_INLINE void set_z_position_mm(const float& z) { set_position_mm(Z_AXIS, z); }
316
-    static FORCE_INLINE void set_e_position_mm(const float& e) { set_position_mm(E_AXIS, e); }
314
+    static void set_position_mm(const AxisEnum axis, const float &v);
315
+    static FORCE_INLINE void set_z_position_mm(const float &z) { set_position_mm(Z_AXIS, z); }
316
+    static FORCE_INLINE void set_e_position_mm(const float &e) { set_position_mm(E_AXIS, e); }
317 317
 
318 318
     /**
319 319
      * Sync from the stepper positions. (e.g., after an interrupted move)
@@ -369,7 +369,7 @@ class Planner {
369 369
      * Calculate the distance (not time) it takes to accelerate
370 370
      * from initial_rate to target_rate using the given acceleration:
371 371
      */
372
-    static float estimate_acceleration_distance(float initial_rate, float target_rate, float accel) {
372
+    static float estimate_acceleration_distance(const float &initial_rate, const float &target_rate, const float &accel) {
373 373
       if (accel == 0) return 0; // accel was 0, set acceleration distance to 0
374 374
       return (sq(target_rate) - sq(initial_rate)) / (accel * 2);
375 375
     }
@@ -382,7 +382,7 @@ class Planner {
382 382
      * This is used to compute the intersection point between acceleration and deceleration
383 383
      * in cases where the "trapezoid" has no plateau (i.e., never reaches maximum speed)
384 384
      */
385
-    static float intersection_distance(float initial_rate, float final_rate, float accel, float distance) {
385
+    static float intersection_distance(const float &initial_rate, const float &final_rate, const float &accel, const float &distance) {
386 386
       if (accel == 0) return 0; // accel was 0, set intersection distance to 0
387 387
       return (accel * 2 * distance - sq(initial_rate) + sq(final_rate)) / (accel * 4);
388 388
     }
@@ -392,7 +392,7 @@ class Planner {
392 392
      * to reach 'target_velocity' using 'acceleration' within a given
393 393
      * 'distance'.
394 394
      */
395
-    static float max_allowable_speed(float accel, float target_velocity, float distance) {
395
+    static float max_allowable_speed(const float &accel, const float &target_velocity, const float &distance) {
396 396
       return sqrt(sq(target_velocity) - 2 * accel * distance);
397 397
     }
398 398
 

+ 67
- 99
Marlin/ultralcd.cpp View File

@@ -43,8 +43,7 @@
43 43
   #include "duration_t.h"
44 44
 #endif
45 45
 
46
-int preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1,
47
-    preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2;
46
+int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
48 47
 
49 48
 #if ENABLED(FILAMENT_LCD_DISPLAY)
50 49
   millis_t previous_lcd_status_ms = 0;
@@ -243,7 +242,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
243 242
    *
244 243
    * START_MENU    Opening code for a screen with menu items.
245 244
    *               Scroll as-needed to keep the selected line in view.
246
-   *               'wasClicked' indicates the controller was clicked.
247 245
    */
248 246
   #define START_SCREEN() \
249 247
     START_SCREEN_OR_MENU(LCD_HEIGHT); \
@@ -257,7 +255,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
257 255
     if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
258 256
       encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
259 257
     } \
260
-    bool wasClicked = LCD_CLICKED; \
261 258
     bool _skipStatic = true; \
262 259
     SCREEN_OR_MENU_LOOP()
263 260
 
@@ -288,8 +285,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
288 285
     if (_menuLineNr == _thisItemNr) { \
289 286
       if (lcdDrawUpdate) \
290 287
         lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
291
-      if (wasClicked && encoderLine == _thisItemNr) { \
292
-        lcd_quick_feedback()
288
+      if (lcd_clicked && encoderLine == _thisItemNr) {
293 289
 
294 290
   #define _MENU_ITEM_PART_2(TYPE, ...) \
295 291
         menu_action_ ## TYPE(__VA_ARGS__); \
@@ -381,9 +377,8 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
381 377
   menuPosition screen_history[10];
382 378
   uint8_t screen_history_depth = 0;
383 379
 
384
-  bool ignore_click = false;
385
-  bool wait_for_unclick;
386
-  bool defer_return_to_status = false;
380
+  // LCD and menu clicks
381
+  bool lcd_clicked, wait_for_unclick, defer_return_to_status;
387 382
 
388 383
   // Variables used when editing values.
389 384
   const char* editLabel;
@@ -392,9 +387,9 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
392 387
   screenFunc_t callbackFunc;              // call this after editing
393 388
 
394 389
   /**
395
-   * General function to go directly to a menu
390
+   * General function to go directly to a screen
396 391
    */
397
-  static void lcd_goto_screen(screenFunc_t screen, const bool feedback = false, const uint32_t encoder = 0) {
392
+  static void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0) {
398 393
     if (currentScreen != screen) {
399 394
       currentScreen = screen;
400 395
       encoderPosition = encoder;
@@ -402,7 +397,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
402 397
         defer_return_to_status = false;
403 398
         screen_history_depth = 0;
404 399
       }
405
-      if (feedback) lcd_quick_feedback();
406 400
       lcd_implementation_clear();
407 401
       #if ENABLED(LCD_PROGRESS_BAR)
408 402
         // For LCD_PROGRESS_BAR re-initialize custom characters
@@ -427,7 +421,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
427 421
       --screen_history_depth;
428 422
       lcd_goto_screen(
429 423
         screen_history[screen_history_depth].menu_function,
430
-        feedback,
431 424
         screen_history[screen_history_depth].encoder_position
432 425
       );
433 426
     }
@@ -435,11 +428,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
435 428
       lcd_return_to_status();
436 429
   }
437 430
 
438
-  void lcd_ignore_click(bool b) {
439
-    ignore_click = b;
440
-    wait_for_unclick = false;
441
-  }
442
-
443 431
 #endif // ULTIPANEL
444 432
 
445 433
 /**
@@ -493,23 +481,7 @@ static void lcd_status_screen() {
493 481
 
494 482
   #if ENABLED(ULTIPANEL)
495 483
 
496
-    bool current_click = LCD_CLICKED;
497
-
498
-    if (ignore_click) {
499
-      if (wait_for_unclick) {
500
-        if (!current_click)
501
-          ignore_click = wait_for_unclick = false;
502
-        else
503
-          current_click = false;
504
-      }
505
-      else if (current_click) {
506
-        lcd_quick_feedback();
507
-        wait_for_unclick = true;
508
-        current_click = false;
509
-      }
510
-    }
511
-
512
-    if (current_click) {
484
+    if (lcd_clicked) {
513 485
       #if ENABLED(FILAMENT_LCD_DISPLAY)
514 486
         previous_lcd_status_ms = millis();  // get status message to show up for a while
515 487
       #endif
@@ -518,7 +490,7 @@ static void lcd_status_screen() {
518 490
           false
519 491
         #endif
520 492
       );
521
-      lcd_goto_screen(lcd_main_menu, true);
493
+      lcd_goto_screen(lcd_main_menu);
522 494
     }
523 495
 
524 496
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
@@ -676,7 +648,7 @@ void kill_screen(const char* lcd_msg) {
676 648
     long babysteps_done = 0;
677 649
 
678 650
     static void _lcd_babystep(const AxisEnum axis, const char* msg) {
679
-      if (LCD_CLICKED) { defer_return_to_status = false; lcd_goto_previous_menu(true); return; }
651
+      if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(true); }
680 652
       ENCODER_DIRECTION_NORMAL();
681 653
       if (encoderPosition) {
682 654
         int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
@@ -914,29 +886,29 @@ void kill_screen(const char* lcd_msg) {
914 886
   }
915 887
 
916 888
   #if TEMP_SENSOR_0 != 0
917
-    void lcd_preheat_pla0() { _lcd_preheat(0, preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1); }
918
-    void lcd_preheat_abs0() { _lcd_preheat(0, preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2); }
889
+    void lcd_preheat_pla0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
890
+    void lcd_preheat_abs0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
919 891
   #endif
920 892
 
921 893
   #if HOTENDS > 1
922
-    void lcd_preheat_pla1() { _lcd_preheat(1, preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1); }
923
-    void lcd_preheat_abs1() { _lcd_preheat(1, preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2); }
894
+    void lcd_preheat_pla1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
895
+    void lcd_preheat_abs1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
924 896
     #if HOTENDS > 2
925
-      void lcd_preheat_pla2() { _lcd_preheat(2, preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1); }
926
-      void lcd_preheat_abs2() { _lcd_preheat(2, preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2); }
897
+      void lcd_preheat_pla2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
898
+      void lcd_preheat_abs2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
927 899
       #if HOTENDS > 3
928
-        void lcd_preheat_pla3() { _lcd_preheat(3, preheatHotendTemp1, preheatBedTemp1, preheatFanSpeed1); }
929
-        void lcd_preheat_abs3() { _lcd_preheat(3, preheatHotendTemp2, preheatBedTemp2, preheatFanSpeed2); }
900
+        void lcd_preheat_pla3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
901
+        void lcd_preheat_abs3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
930 902
       #endif
931 903
     #endif
932 904
 
933 905
     void lcd_preheat_pla0123() {
934 906
       #if HOTENDS > 1
935
-        thermalManager.setTargetHotend(preheatHotendTemp1, 1);
907
+        thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 1);
936 908
         #if HOTENDS > 2
937
-          thermalManager.setTargetHotend(preheatHotendTemp1, 2);
909
+          thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 2);
938 910
           #if HOTENDS > 3
939
-            thermalManager.setTargetHotend(preheatHotendTemp1, 3);
911
+            thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 3);
940 912
           #endif
941 913
         #endif
942 914
       #endif
@@ -944,11 +916,11 @@ void kill_screen(const char* lcd_msg) {
944 916
     }
945 917
     void lcd_preheat_abs0123() {
946 918
       #if HOTENDS > 1
947
-        thermalManager.setTargetHotend(preheatHotendTemp2, 1);
919
+        thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 1);
948 920
         #if HOTENDS > 2
949
-          thermalManager.setTargetHotend(preheatHotendTemp2, 2);
921
+          thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 2);
950 922
           #if HOTENDS > 3
951
-            thermalManager.setTargetHotend(preheatHotendTemp2, 3);
923
+            thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 3);
952 924
           #endif
953 925
         #endif
954 926
       #endif
@@ -958,8 +930,8 @@ void kill_screen(const char* lcd_msg) {
958 930
   #endif // HOTENDS > 1
959 931
 
960 932
   #if TEMP_SENSOR_BED != 0
961
-    void lcd_preheat_pla_bedonly() { _lcd_preheat(0, 0, preheatBedTemp1, preheatFanSpeed1); }
962
-    void lcd_preheat_abs_bedonly() { _lcd_preheat(0, 0, preheatBedTemp2, preheatFanSpeed2); }
933
+    void lcd_preheat_pla_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
934
+    void lcd_preheat_abs_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
963 935
   #endif
964 936
 
965 937
   #if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0)
@@ -1092,12 +1064,12 @@ void kill_screen(const char* lcd_msg) {
1092 1064
       }
1093 1065
 
1094 1066
       static bool debounce_click = false;
1095
-      if (LCD_CLICKED) {
1067
+      if (lcd_clicked) {
1096 1068
         if (!debounce_click) {
1097 1069
           debounce_click = true; // ignore multiple "clicks" in a row
1098 1070
           mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
1099 1071
           if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
1100
-            lcd_goto_screen(_lcd_level_bed_done, true);
1072
+            lcd_goto_screen(_lcd_level_bed_done);
1101 1073
 
1102 1074
             current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT;
1103 1075
             line_to_current(Z_AXIS);
@@ -1113,7 +1085,7 @@ void kill_screen(const char* lcd_msg) {
1113 1085
             #endif
1114 1086
           }
1115 1087
           else {
1116
-            lcd_goto_screen(_lcd_level_goto_next_point, true);
1088
+            lcd_goto_screen(_lcd_level_goto_next_point);
1117 1089
           }
1118 1090
         }
1119 1091
       }
@@ -1171,7 +1143,7 @@ void kill_screen(const char* lcd_msg) {
1171 1143
      */
1172 1144
     static void _lcd_level_bed_homing_done() {
1173 1145
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
1174
-      if (LCD_CLICKED) {
1146
+      if (lcd_clicked) {
1175 1147
         _lcd_level_bed_position = 0;
1176 1148
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
1177 1149
           #if Z_HOME_DIR > 0
@@ -1179,7 +1151,7 @@ void kill_screen(const char* lcd_msg) {
1179 1151
           #endif
1180 1152
         ;
1181 1153
         planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1182
-        lcd_goto_screen(_lcd_level_goto_next_point, true);
1154
+        lcd_goto_screen(_lcd_level_goto_next_point);
1183 1155
       }
1184 1156
     }
1185 1157
 
@@ -1385,7 +1357,7 @@ void kill_screen(const char* lcd_msg) {
1385 1357
    */
1386 1358
 
1387 1359
   static void _lcd_move_xyz(const char* name, AxisEnum axis) {
1388
-    if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1360
+    if (lcd_clicked) { return lcd_goto_previous_menu(true); }
1389 1361
     ENCODER_DIRECTION_NORMAL();
1390 1362
     if (encoderPosition) {
1391 1363
       refresh_cmd_timeout();
@@ -1425,7 +1397,7 @@ void kill_screen(const char* lcd_msg) {
1425 1397
       int8_t eindex=-1
1426 1398
     #endif
1427 1399
   ) {
1428
-    if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1400
+    if (lcd_clicked) { return lcd_goto_previous_menu(true); }
1429 1401
     ENCODER_DIRECTION_NORMAL();
1430 1402
     if (encoderPosition) {
1431 1403
       current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
@@ -1793,20 +1765,15 @@ void kill_screen(const char* lcd_msg) {
1793 1765
     END_MENU();
1794 1766
   }
1795 1767
 
1796
-  /**
1797
-   *
1798
-   * "Temperature" > "Preheat PLA conf" submenu
1799
-   *
1800
-   */
1801
-  static void lcd_control_temperature_preheat_pla_settings_menu() {
1768
+  static void _lcd_control_temperature_preheat_settings_menu(uint8_t material) {
1802 1769
     START_MENU();
1803 1770
     MENU_BACK(MSG_TEMPERATURE);
1804
-    MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &preheatFanSpeed1, 0, 255);
1771
+    MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
1805 1772
     #if TEMP_SENSOR_0 != 0
1806
-      MENU_ITEM_EDIT(int3, MSG_NOZZLE, &preheatHotendTemp1, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
1773
+      MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
1807 1774
     #endif
1808 1775
     #if TEMP_SENSOR_BED != 0
1809
-      MENU_ITEM_EDIT(int3, MSG_BED, &preheatBedTemp1, BED_MINTEMP, BED_MAXTEMP - 15);
1776
+      MENU_ITEM_EDIT(int3, MSG_BED, &lcd_preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
1810 1777
     #endif
1811 1778
     #if ENABLED(EEPROM_SETTINGS)
1812 1779
       MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
@@ -1816,24 +1783,17 @@ void kill_screen(const char* lcd_msg) {
1816 1783
 
1817 1784
   /**
1818 1785
    *
1786
+   * "Temperature" > "Preheat PLA conf" submenu
1787
+   *
1788
+   */
1789
+  static void lcd_control_temperature_preheat_pla_settings_menu() { _lcd_control_temperature_preheat_settings_menu(0); }
1790
+
1791
+  /**
1792
+   *
1819 1793
    * "Temperature" > "Preheat ABS conf" submenu
1820 1794
    *
1821 1795
    */
1822
-  static void lcd_control_temperature_preheat_abs_settings_menu() {
1823
-    START_MENU();
1824
-    MENU_BACK(MSG_TEMPERATURE);
1825
-    MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &preheatFanSpeed2, 0, 255);
1826
-    #if TEMP_SENSOR_0 != 0
1827
-      MENU_ITEM_EDIT(int3, MSG_NOZZLE, &preheatHotendTemp2, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
1828
-    #endif
1829
-    #if TEMP_SENSOR_BED != 0
1830
-      MENU_ITEM_EDIT(int3, MSG_BED, &preheatBedTemp2, BED_MINTEMP, BED_MAXTEMP - 15);
1831
-    #endif
1832
-    #if ENABLED(EEPROM_SETTINGS)
1833
-      MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
1834
-    #endif
1835
-    END_MENU();
1836
-  }
1796
+  static void lcd_control_temperature_preheat_abs_settings_menu() { _lcd_control_temperature_preheat_settings_menu(1); }
1837 1797
 
1838 1798
   static void _reset_acceleration_rates() { planner.reset_acceleration_rates(); }
1839 1799
   static void _planner_refresh_positioning() { planner.refresh_positioning(); }
@@ -1924,7 +1884,7 @@ void kill_screen(const char* lcd_msg) {
1924 1884
    */
1925 1885
   #if HAS_LCD_CONTRAST
1926 1886
     static void lcd_set_contrast() {
1927
-      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1887
+      if (lcd_clicked) { return lcd_goto_previous_menu(true); }
1928 1888
       ENCODER_DIRECTION_NORMAL();
1929 1889
       if (encoderPosition) {
1930 1890
         set_lcd_contrast(lcd_contrast + encoderPosition);
@@ -1991,7 +1951,7 @@ void kill_screen(const char* lcd_msg) {
1991 1951
      */
1992 1952
     void lcd_sdcard_menu() {
1993 1953
       ENCODER_DIRECTION_MENUS();
1994
-      if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card)
1954
+      if (!lcdDrawUpdate && !lcd_clicked) return; // nothing to do (so don't thrash the SD card)
1995 1955
       uint16_t fileCnt = card.getnrfilenames();
1996 1956
       START_MENU();
1997 1957
       MENU_BACK(MSG_MAIN);
@@ -2037,7 +1997,7 @@ void kill_screen(const char* lcd_msg) {
2037 1997
        *
2038 1998
        */
2039 1999
       static void lcd_info_stats_menu() {
2040
-        if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2000
+        if (lcd_clicked) { return lcd_goto_previous_menu(true); }
2041 2001
 
2042 2002
         char buffer[21];
2043 2003
         printStatistics stats = print_job_timer.getStats();
@@ -2071,7 +2031,7 @@ void kill_screen(const char* lcd_msg) {
2071 2031
      *
2072 2032
      */
2073 2033
     static void lcd_info_thermistors_menu() {
2074
-      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2034
+      if (lcd_clicked) { return lcd_goto_previous_menu(true); }
2075 2035
       START_SCREEN();
2076 2036
       #define THERMISTOR_ID TEMP_SENSOR_0
2077 2037
       #include "thermistornames.h"
@@ -2123,7 +2083,7 @@ void kill_screen(const char* lcd_msg) {
2123 2083
      *
2124 2084
      */
2125 2085
     static void lcd_info_board_menu() {
2126
-      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2086
+      if (lcd_clicked) { return lcd_goto_previous_menu(true); }
2127 2087
       START_SCREEN();
2128 2088
       STATIC_ITEM(BOARD_NAME, true, true);                           // MyPrinterController
2129 2089
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
@@ -2144,7 +2104,7 @@ void kill_screen(const char* lcd_msg) {
2144 2104
      *
2145 2105
      */
2146 2106
     static void lcd_info_printer_menu() {
2147
-      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2107
+      if (lcd_clicked) { return lcd_goto_previous_menu(true); }
2148 2108
       START_SCREEN();
2149 2109
       STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
2150 2110
       STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch
@@ -2334,16 +2294,15 @@ void kill_screen(const char* lcd_msg) {
2334 2294
   #define menu_edit_type(_type, _name, _strFunc, scale) \
2335 2295
     bool _menu_edit_ ## _name () { \
2336 2296
       ENCODER_DIRECTION_NORMAL(); \
2337
-      bool isClicked = LCD_CLICKED; \
2338 2297
       if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
2339 2298
       if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
2340 2299
       if (lcdDrawUpdate) \
2341 2300
         lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
2342
-      if (isClicked) { \
2301
+      if (lcd_clicked) { \
2343 2302
         *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
2344 2303
         lcd_goto_previous_menu(true); \
2345 2304
       } \
2346
-      return isClicked; \
2305
+      return lcd_clicked; \
2347 2306
     } \
2348 2307
     void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \
2349 2308
     void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \
@@ -2614,9 +2573,20 @@ void lcd_update() {
2614 2573
   #if ENABLED(ULTIPANEL)
2615 2574
     static millis_t return_to_status_ms = 0;
2616 2575
     manage_manual_move();
2617
-  #endif
2618 2576
 
2619
-  lcd_buttons_update();
2577
+    lcd_buttons_update();
2578
+
2579
+    // If the action button is pressed...
2580
+    if (LCD_CLICKED) {
2581
+      if (!wait_for_unclick) {           // If not waiting for a debounce release:
2582
+        wait_for_unclick = true;         //  Set debounce flag to ignore continous clicks
2583
+        lcd_clicked = !wait_for_user;    //  Keep the click if not waiting for a user-click
2584
+        wait_for_user = false;           //  Any click clears wait for user
2585
+        lcd_quick_feedback();            //  Always make a click sound
2586
+      }
2587
+    }
2588
+    else wait_for_unclick = false;
2589
+  #endif
2620 2590
 
2621 2591
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
2622 2592
 
@@ -2691,7 +2661,7 @@ void lcd_update() {
2691 2661
       #endif // REPRAPWORLD_KEYPAD
2692 2662
 
2693 2663
       bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
2694
-      if (encoderPastThreshold || LCD_CLICKED) {
2664
+      if (encoderPastThreshold || lcd_clicked) {
2695 2665
         if (encoderPastThreshold) {
2696 2666
           int32_t encoderMultiplier = 1;
2697 2667
 
@@ -2757,7 +2727,7 @@ void lcd_update() {
2757 2727
       }
2758 2728
 
2759 2729
       #if ENABLED(ULTIPANEL)
2760
-        #define CURRENTSCREEN() (*currentScreen)()
2730
+        #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
2761 2731
       #else
2762 2732
         #define CURRENTSCREEN() lcd_status_screen()
2763 2733
       #endif
@@ -3020,8 +2990,6 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
3020 2990
     #endif
3021 2991
   }
3022 2992
 
3023
-  bool lcd_clicked() { return LCD_CLICKED; }
3024
-
3025 2993
 #endif // ULTIPANEL
3026 2994
 
3027 2995
 #endif // ULTRA_LCD

+ 29
- 33
Marlin/ultralcd.h View File

@@ -30,6 +30,8 @@
30 30
   #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
31 31
   #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
32 32
 
33
+  extern int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
34
+
33 35
   int lcd_strlen(const char* s);
34 36
   int lcd_strlen_P(const char* s);
35 37
   void lcd_update();
@@ -65,26 +67,31 @@
65 67
   #define LCD_TIMEOUT_TO_STATUS 15000
66 68
 
67 69
   #if ENABLED(ULTIPANEL)
70
+
71
+    #define BLEN_A 0
72
+    #define BLEN_B 1
73
+    // Encoder click is directly connected
74
+    #if BUTTON_EXISTS(ENC)
75
+      #define BLEN_C 2
76
+      #define EN_C (_BV(BLEN_C))
77
+    #endif
78
+    #define EN_A (_BV(BLEN_A))
79
+    #define EN_B (_BV(BLEN_B))
80
+    #define EN_C (_BV(BLEN_C))
81
+
68 82
     extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
69 83
     void lcd_buttons_update();
70 84
     void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual
71
-    bool lcd_clicked();
72
-    void lcd_ignore_click(bool b=true);
73 85
 
74 86
     #if ENABLED(FILAMENT_CHANGE_FEATURE)
75 87
       void lcd_filament_change_show_message(FilamentChangeMessage message);
76 88
     #endif // FILAMENT_CHANGE_FEATURE
77 89
 
78 90
   #else
79
-    FORCE_INLINE void lcd_buttons_update() {}
80
-  #endif
81 91
 
82
-  extern int preheatHotendTemp1;
83
-  extern int preheatBedTemp1;
84
-  extern int preheatFanSpeed1;
85
-  extern int preheatHotendTemp2;
86
-  extern int preheatBedTemp2;
87
-  extern int preheatFanSpeed2;
92
+    inline void lcd_buttons_update() {}
93
+
94
+  #endif
88 95
 
89 96
   #if ENABLED(FILAMENT_LCD_DISPLAY)
90 97
     extern millis_t previous_lcd_status_ms;
@@ -92,19 +99,6 @@
92 99
 
93 100
   bool lcd_blink();
94 101
 
95
-  #if ENABLED(ULTIPANEL)
96
-    #define BLEN_A 0
97
-    #define BLEN_B 1
98
-    // Encoder click is directly connected
99
-    #if BUTTON_EXISTS(ENC)
100
-      #define BLEN_C 2
101
-      #define EN_C (_BV(BLEN_C))
102
-    #endif
103
-    #define EN_A (_BV(BLEN_A))
104
-    #define EN_B (_BV(BLEN_B))
105
-    #define EN_C (_BV(BLEN_C))
106
-  #endif
107
-
108 102
   #if ENABLED(REPRAPWORLD_KEYPAD) // is also ULTIPANEL and NEWPANEL
109 103
 
110 104
     #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
@@ -150,21 +144,23 @@
150 144
     #define LCD_CLICKED ((buttons & EN_C) || (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F1))
151 145
   #elif ENABLED(NEWPANEL)
152 146
     #define LCD_CLICKED (buttons & EN_C)
147
+  #else
148
+    #define LCD_CLICKED false
153 149
   #endif
154 150
 
155 151
 #else //no LCD
156
-  FORCE_INLINE void lcd_update() {}
157
-  FORCE_INLINE void lcd_init() {}
158
-  FORCE_INLINE bool lcd_hasstatus() { return false; }
159
-  FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {UNUSED(message); UNUSED(persist);}
160
-  FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {UNUSED(message); UNUSED(level);}
161
-  FORCE_INLINE void lcd_buttons_update() {}
162
-  FORCE_INLINE void lcd_reset_alert_level() {}
163
-  FORCE_INLINE bool lcd_detected(void) { return true; }
152
+  inline void lcd_update() {}
153
+  inline void lcd_init() {}
154
+  inline bool lcd_hasstatus() { return false; }
155
+  inline void lcd_setstatus(const char* message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
156
+  inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); }
157
+  inline void lcd_buttons_update() {}
158
+  inline void lcd_reset_alert_level() {}
159
+  inline bool lcd_detected(void) { return true; }
164 160
 
165 161
   #define LCD_MESSAGEPGM(x) NOOP
166 162
   #define LCD_ALERTMESSAGEPGM(x) NOOP
167 163
 
168
-#endif //ULTRA_LCD
164
+#endif // ULTRA_LCD
169 165
 
170
-#endif //ULTRALCD_H
166
+#endif // ULTRALCD_H

Loading…
Cancel
Save