Przeglądaj źródła

Merge pull request #5089 from thinkyhead/rc_break_m1_fix

Centralize click-handling in the LCD loop
Scott Lahteine 8 lat temu
rodzic
commit
3c3fe1a1ba

+ 1
- 1
Marlin/Marlin.h Wyświetl plik

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

+ 1
- 4
Marlin/MarlinSerial.cpp Wyświetl plik

508
         if (c == '\n') {
508
         if (c == '\n') {
509
           switch (state) {
509
           switch (state) {
510
             case state_M108:
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
               break;
512
               break;
516
             case state_M112:
513
             case state_M112:
517
               kill(PSTR(MSG_KILLED));
514
               kill(PSTR(MSG_KILLED));

+ 42
- 87
Marlin/Marlin_main.cpp Wyświetl plik

1046
 
1046
 
1047
       #if DISABLED(EMERGENCY_PARSER)
1047
       #if DISABLED(EMERGENCY_PARSER)
1048
         // If command was e-stop process now
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
         if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
1055
         if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
1051
         if (strcmp(command, "M410") == 0) { quickstop_stepper(); }
1056
         if (strcmp(command, "M410") == 0) { quickstop_stepper(); }
1052
       #endif
1057
       #endif
4414
           dontExpireStatus();
4419
           dontExpireStatus();
4415
         #endif
4420
         #endif
4416
       }
4421
       }
4417
-      lcd_ignore_click();
4418
 
4422
 
4419
     #else
4423
     #else
4420
 
4424
 
4425
 
4429
 
4426
     #endif
4430
     #endif
4427
 
4431
 
4428
-    #if ENABLED(EMERGENCY_PARSER)
4429
-      wait_for_user = true;
4430
-    #endif
4431
-
4432
+    wait_for_user = true;
4432
     KEEPALIVE_STATE(PAUSED_FOR_USER);
4433
     KEEPALIVE_STATE(PAUSED_FOR_USER);
4433
 
4434
 
4434
     stepper.synchronize();
4435
     stepper.synchronize();
4435
     refresh_cmd_timeout();
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
       #else
4448
       #else
4442
-        #define M1_WAIT_CONDITION !lcd_clicked()
4449
+        while (wait_for_user) idle();
4443
       #endif
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
     KEEPALIVE_STATE(IN_HANDLER);
4454
     KEEPALIVE_STATE(IN_HANDLER);
4476
   }
4455
   }
4477
 
4456
 
5539
    *   F<fan speed>
5518
    *   F<fan speed>
5540
    */
5519
    */
5541
   inline void gcode_M145() {
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
       SERIAL_ERROR_START;
5523
       SERIAL_ERROR_START;
5545
       SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
5524
       SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
5546
     }
5525
     }
5547
     else {
5526
     else {
5548
       int v;
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
    * M149: Set temperature units
5549
    * M149: Set temperature units
5591
    */
5550
    */
5592
   inline void gcode_M149() {
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
 #endif
5556
 #endif
5602
 
5557
 
6874
     // Wait for filament insert by user and press button
6829
     // Wait for filament insert by user and press button
6875
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
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
       #if HAS_BUZZER
6836
       #if HAS_BUZZER
6879
         millis_t ms = millis();
6837
         millis_t ms = millis();
6880
         if (ms >= next_buzz) {
6838
         if (ms >= next_buzz) {
6884
       #endif
6842
       #endif
6885
       idle(true);
6843
       idle(true);
6886
     }
6844
     }
6887
-    delay(100);
6888
-    while (lcd_clicked()) idle(true);
6889
-    delay(100);
6890
 
6845
 
6891
     // Show load message
6846
     // Show load message
6892
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD);
6847
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD);

+ 26
- 37
Marlin/configuration_store.cpp Wyświetl plik

86
  *  301  M666 Z    z_endstop_adj (float)
86
  *  301  M666 Z    z_endstop_adj (float)
87
  *
87
  *
88
  * ULTIPANEL:
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
  * PIDTEMP:
93
  * PIDTEMP:
97
  *  317  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
94
  *  317  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
277
     #endif
274
     #endif
278
 
275
 
279
     #if DISABLED(ULTIPANEL)
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
     #endif // !ULTIPANEL
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
     for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
286
     for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
292
 
287
 
465
       #endif
460
       #endif
466
 
461
 
467
       #if DISABLED(ULTIPANEL)
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
       #endif
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
       #if ENABLED(PIDTEMP)
470
       #if ENABLED(PIDTEMP)
480
         for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
471
         for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
639
   #endif
630
   #endif
640
 
631
 
641
   #if ENABLED(ULTIPANEL)
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
   #endif
639
   #endif
649
 
640
 
650
   #if HAS_LCD_CONTRAST
641
   #if HAS_LCD_CONTRAST
863
         SERIAL_ECHOLNPGM("Material heatup parameters:");
854
         SERIAL_ECHOLNPGM("Material heatup parameters:");
864
         CONFIG_ECHO_START;
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
     #endif // ULTIPANEL
864
     #endif // ULTIPANEL
876
 
865
 
877
     #if HAS_PID_HEATING
866
     #if HAS_PID_HEATING

+ 8
- 8
Marlin/planner.h Wyświetl plik

264
      *  fr_mm_s      - (target) speed of the move (mm/s)
264
      *  fr_mm_s      - (target) speed of the move (mm/s)
265
      *  extruder     - target extruder
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
       #if PLANNER_LEVELING && IS_CARTESIAN
268
       #if PLANNER_LEVELING && IS_CARTESIAN
269
         apply_leveling(lx, ly, lz);
269
         apply_leveling(lx, ly, lz);
270
       #endif
270
       #endif
280
      *  fr_mm_s  - (target) speed of the move (mm/s)
280
      *  fr_mm_s  - (target) speed of the move (mm/s)
281
      *  extruder - target extruder
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
       #if PLANNER_LEVELING
284
       #if PLANNER_LEVELING
285
         float pos[XYZ] = { target[X_AXIS], target[Y_AXIS], target[Z_AXIS] };
285
         float pos[XYZ] = { target[X_AXIS], target[Y_AXIS], target[Z_AXIS] };
286
         apply_leveling(pos);
286
         apply_leveling(pos);
311
       _set_position_mm(lx, ly, lz, e);
311
       _set_position_mm(lx, ly, lz, e);
312
     }
312
     }
313
     static void set_position_mm_kinematic(const float position[NUM_AXIS]);
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
      * Sync from the stepper positions. (e.g., after an interrupted move)
319
      * Sync from the stepper positions. (e.g., after an interrupted move)
369
      * Calculate the distance (not time) it takes to accelerate
369
      * Calculate the distance (not time) it takes to accelerate
370
      * from initial_rate to target_rate using the given acceleration:
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
       if (accel == 0) return 0; // accel was 0, set acceleration distance to 0
373
       if (accel == 0) return 0; // accel was 0, set acceleration distance to 0
374
       return (sq(target_rate) - sq(initial_rate)) / (accel * 2);
374
       return (sq(target_rate) - sq(initial_rate)) / (accel * 2);
375
     }
375
     }
382
      * This is used to compute the intersection point between acceleration and deceleration
382
      * This is used to compute the intersection point between acceleration and deceleration
383
      * in cases where the "trapezoid" has no plateau (i.e., never reaches maximum speed)
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
       if (accel == 0) return 0; // accel was 0, set intersection distance to 0
386
       if (accel == 0) return 0; // accel was 0, set intersection distance to 0
387
       return (accel * 2 * distance - sq(initial_rate) + sq(final_rate)) / (accel * 4);
387
       return (accel * 2 * distance - sq(initial_rate) + sq(final_rate)) / (accel * 4);
388
     }
388
     }
392
      * to reach 'target_velocity' using 'acceleration' within a given
392
      * to reach 'target_velocity' using 'acceleration' within a given
393
      * 'distance'.
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
       return sqrt(sq(target_velocity) - 2 * accel * distance);
396
       return sqrt(sq(target_velocity) - 2 * accel * distance);
397
     }
397
     }
398
 
398
 

+ 67
- 99
Marlin/ultralcd.cpp Wyświetl plik

43
   #include "duration_t.h"
43
   #include "duration_t.h"
44
 #endif
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
 #if ENABLED(FILAMENT_LCD_DISPLAY)
48
 #if ENABLED(FILAMENT_LCD_DISPLAY)
50
   millis_t previous_lcd_status_ms = 0;
49
   millis_t previous_lcd_status_ms = 0;
243
    *
242
    *
244
    * START_MENU    Opening code for a screen with menu items.
243
    * START_MENU    Opening code for a screen with menu items.
245
    *               Scroll as-needed to keep the selected line in view.
244
    *               Scroll as-needed to keep the selected line in view.
246
-   *               'wasClicked' indicates the controller was clicked.
247
    */
245
    */
248
   #define START_SCREEN() \
246
   #define START_SCREEN() \
249
     START_SCREEN_OR_MENU(LCD_HEIGHT); \
247
     START_SCREEN_OR_MENU(LCD_HEIGHT); \
257
     if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
255
     if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
258
       encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
256
       encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
259
     } \
257
     } \
260
-    bool wasClicked = LCD_CLICKED; \
261
     bool _skipStatic = true; \
258
     bool _skipStatic = true; \
262
     SCREEN_OR_MENU_LOOP()
259
     SCREEN_OR_MENU_LOOP()
263
 
260
 
288
     if (_menuLineNr == _thisItemNr) { \
285
     if (_menuLineNr == _thisItemNr) { \
289
       if (lcdDrawUpdate) \
286
       if (lcdDrawUpdate) \
290
         lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
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
   #define _MENU_ITEM_PART_2(TYPE, ...) \
290
   #define _MENU_ITEM_PART_2(TYPE, ...) \
295
         menu_action_ ## TYPE(__VA_ARGS__); \
291
         menu_action_ ## TYPE(__VA_ARGS__); \
381
   menuPosition screen_history[10];
377
   menuPosition screen_history[10];
382
   uint8_t screen_history_depth = 0;
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
   // Variables used when editing values.
383
   // Variables used when editing values.
389
   const char* editLabel;
384
   const char* editLabel;
392
   screenFunc_t callbackFunc;              // call this after editing
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
     if (currentScreen != screen) {
393
     if (currentScreen != screen) {
399
       currentScreen = screen;
394
       currentScreen = screen;
400
       encoderPosition = encoder;
395
       encoderPosition = encoder;
402
         defer_return_to_status = false;
397
         defer_return_to_status = false;
403
         screen_history_depth = 0;
398
         screen_history_depth = 0;
404
       }
399
       }
405
-      if (feedback) lcd_quick_feedback();
406
       lcd_implementation_clear();
400
       lcd_implementation_clear();
407
       #if ENABLED(LCD_PROGRESS_BAR)
401
       #if ENABLED(LCD_PROGRESS_BAR)
408
         // For LCD_PROGRESS_BAR re-initialize custom characters
402
         // For LCD_PROGRESS_BAR re-initialize custom characters
427
       --screen_history_depth;
421
       --screen_history_depth;
428
       lcd_goto_screen(
422
       lcd_goto_screen(
429
         screen_history[screen_history_depth].menu_function,
423
         screen_history[screen_history_depth].menu_function,
430
-        feedback,
431
         screen_history[screen_history_depth].encoder_position
424
         screen_history[screen_history_depth].encoder_position
432
       );
425
       );
433
     }
426
     }
435
       lcd_return_to_status();
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
 #endif // ULTIPANEL
431
 #endif // ULTIPANEL
444
 
432
 
445
 /**
433
 /**
493
 
481
 
494
   #if ENABLED(ULTIPANEL)
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
       #if ENABLED(FILAMENT_LCD_DISPLAY)
485
       #if ENABLED(FILAMENT_LCD_DISPLAY)
514
         previous_lcd_status_ms = millis();  // get status message to show up for a while
486
         previous_lcd_status_ms = millis();  // get status message to show up for a while
515
       #endif
487
       #endif
518
           false
490
           false
519
         #endif
491
         #endif
520
       );
492
       );
521
-      lcd_goto_screen(lcd_main_menu, true);
493
+      lcd_goto_screen(lcd_main_menu);
522
     }
494
     }
523
 
495
 
524
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
496
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
676
     long babysteps_done = 0;
648
     long babysteps_done = 0;
677
 
649
 
678
     static void _lcd_babystep(const AxisEnum axis, const char* msg) {
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
       ENCODER_DIRECTION_NORMAL();
652
       ENCODER_DIRECTION_NORMAL();
681
       if (encoderPosition) {
653
       if (encoderPosition) {
682
         int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
654
         int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
914
   }
886
   }
915
 
887
 
916
   #if TEMP_SENSOR_0 != 0
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
   #endif
891
   #endif
920
 
892
 
921
   #if HOTENDS > 1
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
     #if HOTENDS > 2
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
       #if HOTENDS > 3
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
       #endif
902
       #endif
931
     #endif
903
     #endif
932
 
904
 
933
     void lcd_preheat_pla0123() {
905
     void lcd_preheat_pla0123() {
934
       #if HOTENDS > 1
906
       #if HOTENDS > 1
935
-        thermalManager.setTargetHotend(preheatHotendTemp1, 1);
907
+        thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 1);
936
         #if HOTENDS > 2
908
         #if HOTENDS > 2
937
-          thermalManager.setTargetHotend(preheatHotendTemp1, 2);
909
+          thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 2);
938
           #if HOTENDS > 3
910
           #if HOTENDS > 3
939
-            thermalManager.setTargetHotend(preheatHotendTemp1, 3);
911
+            thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 3);
940
           #endif
912
           #endif
941
         #endif
913
         #endif
942
       #endif
914
       #endif
944
     }
916
     }
945
     void lcd_preheat_abs0123() {
917
     void lcd_preheat_abs0123() {
946
       #if HOTENDS > 1
918
       #if HOTENDS > 1
947
-        thermalManager.setTargetHotend(preheatHotendTemp2, 1);
919
+        thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 1);
948
         #if HOTENDS > 2
920
         #if HOTENDS > 2
949
-          thermalManager.setTargetHotend(preheatHotendTemp2, 2);
921
+          thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 2);
950
           #if HOTENDS > 3
922
           #if HOTENDS > 3
951
-            thermalManager.setTargetHotend(preheatHotendTemp2, 3);
923
+            thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 3);
952
           #endif
924
           #endif
953
         #endif
925
         #endif
954
       #endif
926
       #endif
958
   #endif // HOTENDS > 1
930
   #endif // HOTENDS > 1
959
 
931
 
960
   #if TEMP_SENSOR_BED != 0
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
   #endif
935
   #endif
964
 
936
 
965
   #if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0)
937
   #if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0)
1092
       }
1064
       }
1093
 
1065
 
1094
       static bool debounce_click = false;
1066
       static bool debounce_click = false;
1095
-      if (LCD_CLICKED) {
1067
+      if (lcd_clicked) {
1096
         if (!debounce_click) {
1068
         if (!debounce_click) {
1097
           debounce_click = true; // ignore multiple "clicks" in a row
1069
           debounce_click = true; // ignore multiple "clicks" in a row
1098
           mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
1070
           mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
1099
           if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
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
             current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT;
1074
             current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT;
1103
             line_to_current(Z_AXIS);
1075
             line_to_current(Z_AXIS);
1113
             #endif
1085
             #endif
1114
           }
1086
           }
1115
           else {
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
      */
1143
      */
1172
     static void _lcd_level_bed_homing_done() {
1144
     static void _lcd_level_bed_homing_done() {
1173
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
1145
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
1174
-      if (LCD_CLICKED) {
1146
+      if (lcd_clicked) {
1175
         _lcd_level_bed_position = 0;
1147
         _lcd_level_bed_position = 0;
1176
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
1148
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
1177
           #if Z_HOME_DIR > 0
1149
           #if Z_HOME_DIR > 0
1179
           #endif
1151
           #endif
1180
         ;
1152
         ;
1181
         planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
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
    */
1357
    */
1386
 
1358
 
1387
   static void _lcd_move_xyz(const char* name, AxisEnum axis) {
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
     ENCODER_DIRECTION_NORMAL();
1361
     ENCODER_DIRECTION_NORMAL();
1390
     if (encoderPosition) {
1362
     if (encoderPosition) {
1391
       refresh_cmd_timeout();
1363
       refresh_cmd_timeout();
1425
       int8_t eindex=-1
1397
       int8_t eindex=-1
1426
     #endif
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
     ENCODER_DIRECTION_NORMAL();
1401
     ENCODER_DIRECTION_NORMAL();
1430
     if (encoderPosition) {
1402
     if (encoderPosition) {
1431
       current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1403
       current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1793
     END_MENU();
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
     START_MENU();
1769
     START_MENU();
1803
     MENU_BACK(MSG_TEMPERATURE);
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
     #if TEMP_SENSOR_0 != 0
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
     #endif
1774
     #endif
1808
     #if TEMP_SENSOR_BED != 0
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
     #endif
1777
     #endif
1811
     #if ENABLED(EEPROM_SETTINGS)
1778
     #if ENABLED(EEPROM_SETTINGS)
1812
       MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
1779
       MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
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
    * "Temperature" > "Preheat ABS conf" submenu
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
   static void _reset_acceleration_rates() { planner.reset_acceleration_rates(); }
1798
   static void _reset_acceleration_rates() { planner.reset_acceleration_rates(); }
1839
   static void _planner_refresh_positioning() { planner.refresh_positioning(); }
1799
   static void _planner_refresh_positioning() { planner.refresh_positioning(); }
1924
    */
1884
    */
1925
   #if HAS_LCD_CONTRAST
1885
   #if HAS_LCD_CONTRAST
1926
     static void lcd_set_contrast() {
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
       ENCODER_DIRECTION_NORMAL();
1888
       ENCODER_DIRECTION_NORMAL();
1929
       if (encoderPosition) {
1889
       if (encoderPosition) {
1930
         set_lcd_contrast(lcd_contrast + encoderPosition);
1890
         set_lcd_contrast(lcd_contrast + encoderPosition);
1991
      */
1951
      */
1992
     void lcd_sdcard_menu() {
1952
     void lcd_sdcard_menu() {
1993
       ENCODER_DIRECTION_MENUS();
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
       uint16_t fileCnt = card.getnrfilenames();
1955
       uint16_t fileCnt = card.getnrfilenames();
1996
       START_MENU();
1956
       START_MENU();
1997
       MENU_BACK(MSG_MAIN);
1957
       MENU_BACK(MSG_MAIN);
2037
        *
1997
        *
2038
        */
1998
        */
2039
       static void lcd_info_stats_menu() {
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
         char buffer[21];
2002
         char buffer[21];
2043
         printStatistics stats = print_job_timer.getStats();
2003
         printStatistics stats = print_job_timer.getStats();
2071
      *
2031
      *
2072
      */
2032
      */
2073
     static void lcd_info_thermistors_menu() {
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
       START_SCREEN();
2035
       START_SCREEN();
2076
       #define THERMISTOR_ID TEMP_SENSOR_0
2036
       #define THERMISTOR_ID TEMP_SENSOR_0
2077
       #include "thermistornames.h"
2037
       #include "thermistornames.h"
2123
      *
2083
      *
2124
      */
2084
      */
2125
     static void lcd_info_board_menu() {
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
       START_SCREEN();
2087
       START_SCREEN();
2128
       STATIC_ITEM(BOARD_NAME, true, true);                           // MyPrinterController
2088
       STATIC_ITEM(BOARD_NAME, true, true);                           // MyPrinterController
2129
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
2089
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
2144
      *
2104
      *
2145
      */
2105
      */
2146
     static void lcd_info_printer_menu() {
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
       START_SCREEN();
2108
       START_SCREEN();
2149
       STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
2109
       STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
2150
       STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch
2110
       STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch
2334
   #define menu_edit_type(_type, _name, _strFunc, scale) \
2294
   #define menu_edit_type(_type, _name, _strFunc, scale) \
2335
     bool _menu_edit_ ## _name () { \
2295
     bool _menu_edit_ ## _name () { \
2336
       ENCODER_DIRECTION_NORMAL(); \
2296
       ENCODER_DIRECTION_NORMAL(); \
2337
-      bool isClicked = LCD_CLICKED; \
2338
       if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
2297
       if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
2339
       if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
2298
       if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
2340
       if (lcdDrawUpdate) \
2299
       if (lcdDrawUpdate) \
2341
         lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
2300
         lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
2342
-      if (isClicked) { \
2301
+      if (lcd_clicked) { \
2343
         *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
2302
         *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
2344
         lcd_goto_previous_menu(true); \
2303
         lcd_goto_previous_menu(true); \
2345
       } \
2304
       } \
2346
-      return isClicked; \
2305
+      return lcd_clicked; \
2347
     } \
2306
     } \
2348
     void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \
2307
     void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \
2349
     void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \
2308
     void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \
2614
   #if ENABLED(ULTIPANEL)
2573
   #if ENABLED(ULTIPANEL)
2615
     static millis_t return_to_status_ms = 0;
2574
     static millis_t return_to_status_ms = 0;
2616
     manage_manual_move();
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
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
2591
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
2622
 
2592
 
2691
       #endif // REPRAPWORLD_KEYPAD
2661
       #endif // REPRAPWORLD_KEYPAD
2692
 
2662
 
2693
       bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
2663
       bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
2694
-      if (encoderPastThreshold || LCD_CLICKED) {
2664
+      if (encoderPastThreshold || lcd_clicked) {
2695
         if (encoderPastThreshold) {
2665
         if (encoderPastThreshold) {
2696
           int32_t encoderMultiplier = 1;
2666
           int32_t encoderMultiplier = 1;
2697
 
2667
 
2757
       }
2727
       }
2758
 
2728
 
2759
       #if ENABLED(ULTIPANEL)
2729
       #if ENABLED(ULTIPANEL)
2760
-        #define CURRENTSCREEN() (*currentScreen)()
2730
+        #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
2761
       #else
2731
       #else
2762
         #define CURRENTSCREEN() lcd_status_screen()
2732
         #define CURRENTSCREEN() lcd_status_screen()
2763
       #endif
2733
       #endif
3020
     #endif
2990
     #endif
3021
   }
2991
   }
3022
 
2992
 
3023
-  bool lcd_clicked() { return LCD_CLICKED; }
3024
-
3025
 #endif // ULTIPANEL
2993
 #endif // ULTIPANEL
3026
 
2994
 
3027
 #endif // ULTRA_LCD
2995
 #endif // ULTRA_LCD

+ 29
- 33
Marlin/ultralcd.h Wyświetl plik

30
   #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
30
   #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
31
   #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
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
   int lcd_strlen(const char* s);
35
   int lcd_strlen(const char* s);
34
   int lcd_strlen_P(const char* s);
36
   int lcd_strlen_P(const char* s);
35
   void lcd_update();
37
   void lcd_update();
65
   #define LCD_TIMEOUT_TO_STATUS 15000
67
   #define LCD_TIMEOUT_TO_STATUS 15000
66
 
68
 
67
   #if ENABLED(ULTIPANEL)
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
     extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
82
     extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
69
     void lcd_buttons_update();
83
     void lcd_buttons_update();
70
     void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual
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
     #if ENABLED(FILAMENT_CHANGE_FEATURE)
86
     #if ENABLED(FILAMENT_CHANGE_FEATURE)
75
       void lcd_filament_change_show_message(FilamentChangeMessage message);
87
       void lcd_filament_change_show_message(FilamentChangeMessage message);
76
     #endif // FILAMENT_CHANGE_FEATURE
88
     #endif // FILAMENT_CHANGE_FEATURE
77
 
89
 
78
   #else
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
   #if ENABLED(FILAMENT_LCD_DISPLAY)
96
   #if ENABLED(FILAMENT_LCD_DISPLAY)
90
     extern millis_t previous_lcd_status_ms;
97
     extern millis_t previous_lcd_status_ms;
92
 
99
 
93
   bool lcd_blink();
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
   #if ENABLED(REPRAPWORLD_KEYPAD) // is also ULTIPANEL and NEWPANEL
102
   #if ENABLED(REPRAPWORLD_KEYPAD) // is also ULTIPANEL and NEWPANEL
109
 
103
 
110
     #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
104
     #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
150
     #define LCD_CLICKED ((buttons & EN_C) || (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F1))
144
     #define LCD_CLICKED ((buttons & EN_C) || (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F1))
151
   #elif ENABLED(NEWPANEL)
145
   #elif ENABLED(NEWPANEL)
152
     #define LCD_CLICKED (buttons & EN_C)
146
     #define LCD_CLICKED (buttons & EN_C)
147
+  #else
148
+    #define LCD_CLICKED false
153
   #endif
149
   #endif
154
 
150
 
155
 #else //no LCD
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
   #define LCD_MESSAGEPGM(x) NOOP
161
   #define LCD_MESSAGEPGM(x) NOOP
166
   #define LCD_ALERTMESSAGEPGM(x) NOOP
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

Ładowanie…
Anuluj
Zapisz