Browse Source

Centralize click-handling in the LCD loop

Scott Lahteine 7 years ago
parent
commit
50ee749082
5 changed files with 72 additions and 115 deletions
  1. 1
    1
      Marlin/Marlin.h
  2. 1
    4
      Marlin/MarlinSerial.cpp
  3. 24
    45
      Marlin/Marlin_main.cpp
  4. 38
    57
      Marlin/ultralcd.cpp
  5. 8
    8
      Marlin/ultralcd.h

+ 1
- 1
Marlin/Marlin.h View File

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 View File

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));

+ 24
- 45
Marlin/Marlin_main.cpp View File

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
 
6874
     // Wait for filament insert by user and press button
6853
     // Wait for filament insert by user and press button
6875
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
6854
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
6876
 
6855
 
6877
-    while (!lcd_clicked()) {
6856
+    // LCD click or M108 will clear this
6857
+    wait_for_user = true;
6858
+
6859
+    while (wait_for_user) {
6878
       #if HAS_BUZZER
6860
       #if HAS_BUZZER
6879
         millis_t ms = millis();
6861
         millis_t ms = millis();
6880
         if (ms >= next_buzz) {
6862
         if (ms >= next_buzz) {
6884
       #endif
6866
       #endif
6885
       idle(true);
6867
       idle(true);
6886
     }
6868
     }
6887
-    delay(100);
6888
-    while (lcd_clicked()) idle(true);
6889
-    delay(100);
6890
 
6869
 
6891
     // Show load message
6870
     // Show load message
6892
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD);
6871
     lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_LOAD);

+ 38
- 57
Marlin/ultralcd.cpp View File

243
    *
243
    *
244
    * START_MENU    Opening code for a screen with menu items.
244
    * START_MENU    Opening code for a screen with menu items.
245
    *               Scroll as-needed to keep the selected line in view.
245
    *               Scroll as-needed to keep the selected line in view.
246
-   *               'wasClicked' indicates the controller was clicked.
247
    */
246
    */
248
   #define START_SCREEN() \
247
   #define START_SCREEN() \
249
     START_SCREEN_OR_MENU(LCD_HEIGHT); \
248
     START_SCREEN_OR_MENU(LCD_HEIGHT); \
257
     if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
256
     if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
258
       encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
257
       encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
259
     } \
258
     } \
260
-    bool wasClicked = LCD_CLICKED; \
261
     bool _skipStatic = true; \
259
     bool _skipStatic = true; \
262
     SCREEN_OR_MENU_LOOP()
260
     SCREEN_OR_MENU_LOOP()
263
 
261
 
288
     if (_menuLineNr == _thisItemNr) { \
286
     if (_menuLineNr == _thisItemNr) { \
289
       if (lcdDrawUpdate) \
287
       if (lcdDrawUpdate) \
290
         lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
288
         lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## __VA_ARGS__); \
291
-      if (wasClicked && encoderLine == _thisItemNr) { \
292
-        lcd_quick_feedback()
289
+      if (lcd_clicked && encoderLine == _thisItemNr) {
293
 
290
 
294
   #define _MENU_ITEM_PART_2(TYPE, ...) \
291
   #define _MENU_ITEM_PART_2(TYPE, ...) \
295
         menu_action_ ## TYPE(__VA_ARGS__); \
292
         menu_action_ ## TYPE(__VA_ARGS__); \
381
   menuPosition screen_history[10];
378
   menuPosition screen_history[10];
382
   uint8_t screen_history_depth = 0;
379
   uint8_t screen_history_depth = 0;
383
 
380
 
384
-  bool ignore_click = false;
385
-  bool wait_for_unclick;
386
-  bool defer_return_to_status = false;
381
+  // LCD and menu clicks
382
+  bool lcd_clicked, wait_for_unclick, defer_return_to_status;
387
 
383
 
388
   // Variables used when editing values.
384
   // Variables used when editing values.
389
   const char* editLabel;
385
   const char* editLabel;
392
   screenFunc_t callbackFunc;              // call this after editing
388
   screenFunc_t callbackFunc;              // call this after editing
393
 
389
 
394
   /**
390
   /**
395
-   * General function to go directly to a menu
391
+   * General function to go directly to a screen
396
    */
392
    */
397
-  static void lcd_goto_screen(screenFunc_t screen, const bool feedback = false, const uint32_t encoder = 0) {
393
+  static void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0) {
398
     if (currentScreen != screen) {
394
     if (currentScreen != screen) {
399
       currentScreen = screen;
395
       currentScreen = screen;
400
       encoderPosition = encoder;
396
       encoderPosition = encoder;
402
         defer_return_to_status = false;
398
         defer_return_to_status = false;
403
         screen_history_depth = 0;
399
         screen_history_depth = 0;
404
       }
400
       }
405
-      if (feedback) lcd_quick_feedback();
406
       lcd_implementation_clear();
401
       lcd_implementation_clear();
407
       #if ENABLED(LCD_PROGRESS_BAR)
402
       #if ENABLED(LCD_PROGRESS_BAR)
408
         // For LCD_PROGRESS_BAR re-initialize custom characters
403
         // For LCD_PROGRESS_BAR re-initialize custom characters
427
       --screen_history_depth;
422
       --screen_history_depth;
428
       lcd_goto_screen(
423
       lcd_goto_screen(
429
         screen_history[screen_history_depth].menu_function,
424
         screen_history[screen_history_depth].menu_function,
430
-        feedback,
431
         screen_history[screen_history_depth].encoder_position
425
         screen_history[screen_history_depth].encoder_position
432
       );
426
       );
433
     }
427
     }
435
       lcd_return_to_status();
429
       lcd_return_to_status();
436
   }
430
   }
437
 
431
 
438
-  void lcd_ignore_click(bool b) {
439
-    ignore_click = b;
440
-    wait_for_unclick = false;
441
-  }
442
-
443
 #endif // ULTIPANEL
432
 #endif // ULTIPANEL
444
 
433
 
445
 /**
434
 /**
493
 
482
 
494
   #if ENABLED(ULTIPANEL)
483
   #if ENABLED(ULTIPANEL)
495
 
484
 
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) {
485
+    if (lcd_clicked) {
513
       #if ENABLED(FILAMENT_LCD_DISPLAY)
486
       #if ENABLED(FILAMENT_LCD_DISPLAY)
514
         previous_lcd_status_ms = millis();  // get status message to show up for a while
487
         previous_lcd_status_ms = millis();  // get status message to show up for a while
515
       #endif
488
       #endif
518
           false
491
           false
519
         #endif
492
         #endif
520
       );
493
       );
521
-      lcd_goto_screen(lcd_main_menu, true);
494
+      lcd_goto_screen(lcd_main_menu);
522
     }
495
     }
523
 
496
 
524
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
497
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
676
     long babysteps_done = 0;
649
     long babysteps_done = 0;
677
 
650
 
678
     static void _lcd_babystep(const AxisEnum axis, const char* msg) {
651
     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; }
652
+      if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(true); }
680
       ENCODER_DIRECTION_NORMAL();
653
       ENCODER_DIRECTION_NORMAL();
681
       if (encoderPosition) {
654
       if (encoderPosition) {
682
         int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
655
         int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
1092
       }
1065
       }
1093
 
1066
 
1094
       static bool debounce_click = false;
1067
       static bool debounce_click = false;
1095
-      if (LCD_CLICKED) {
1068
+      if (lcd_clicked) {
1096
         if (!debounce_click) {
1069
         if (!debounce_click) {
1097
           debounce_click = true; // ignore multiple "clicks" in a row
1070
           debounce_click = true; // ignore multiple "clicks" in a row
1098
           mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
1071
           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)) {
1072
           if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
1100
-            lcd_goto_screen(_lcd_level_bed_done, true);
1073
+            lcd_goto_screen(_lcd_level_bed_done);
1101
 
1074
 
1102
             current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT;
1075
             current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT;
1103
             line_to_current(Z_AXIS);
1076
             line_to_current(Z_AXIS);
1113
             #endif
1086
             #endif
1114
           }
1087
           }
1115
           else {
1088
           else {
1116
-            lcd_goto_screen(_lcd_level_goto_next_point, true);
1089
+            lcd_goto_screen(_lcd_level_goto_next_point);
1117
           }
1090
           }
1118
         }
1091
         }
1119
       }
1092
       }
1171
      */
1144
      */
1172
     static void _lcd_level_bed_homing_done() {
1145
     static void _lcd_level_bed_homing_done() {
1173
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
1146
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
1174
-      if (LCD_CLICKED) {
1147
+      if (lcd_clicked) {
1175
         _lcd_level_bed_position = 0;
1148
         _lcd_level_bed_position = 0;
1176
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
1149
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
1177
           #if Z_HOME_DIR > 0
1150
           #if Z_HOME_DIR > 0
1179
           #endif
1152
           #endif
1180
         ;
1153
         ;
1181
         planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1154
         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);
1155
+        lcd_goto_screen(_lcd_level_goto_next_point);
1183
       }
1156
       }
1184
     }
1157
     }
1185
 
1158
 
1385
    */
1358
    */
1386
 
1359
 
1387
   static void _lcd_move_xyz(const char* name, AxisEnum axis) {
1360
   static void _lcd_move_xyz(const char* name, AxisEnum axis) {
1388
-    if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1361
+    if (lcd_clicked) { return lcd_goto_previous_menu(true); }
1389
     ENCODER_DIRECTION_NORMAL();
1362
     ENCODER_DIRECTION_NORMAL();
1390
     if (encoderPosition) {
1363
     if (encoderPosition) {
1391
       refresh_cmd_timeout();
1364
       refresh_cmd_timeout();
1425
       int8_t eindex=-1
1398
       int8_t eindex=-1
1426
     #endif
1399
     #endif
1427
   ) {
1400
   ) {
1428
-    if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1401
+    if (lcd_clicked) { return lcd_goto_previous_menu(true); }
1429
     ENCODER_DIRECTION_NORMAL();
1402
     ENCODER_DIRECTION_NORMAL();
1430
     if (encoderPosition) {
1403
     if (encoderPosition) {
1431
       current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1404
       current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1924
    */
1897
    */
1925
   #if HAS_LCD_CONTRAST
1898
   #if HAS_LCD_CONTRAST
1926
     static void lcd_set_contrast() {
1899
     static void lcd_set_contrast() {
1927
-      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1900
+      if (lcd_clicked) { return lcd_goto_previous_menu(true); }
1928
       ENCODER_DIRECTION_NORMAL();
1901
       ENCODER_DIRECTION_NORMAL();
1929
       if (encoderPosition) {
1902
       if (encoderPosition) {
1930
         set_lcd_contrast(lcd_contrast + encoderPosition);
1903
         set_lcd_contrast(lcd_contrast + encoderPosition);
1991
      */
1964
      */
1992
     void lcd_sdcard_menu() {
1965
     void lcd_sdcard_menu() {
1993
       ENCODER_DIRECTION_MENUS();
1966
       ENCODER_DIRECTION_MENUS();
1994
-      if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card)
1967
+      if (!lcdDrawUpdate && !lcd_clicked) return; // nothing to do (so don't thrash the SD card)
1995
       uint16_t fileCnt = card.getnrfilenames();
1968
       uint16_t fileCnt = card.getnrfilenames();
1996
       START_MENU();
1969
       START_MENU();
1997
       MENU_BACK(MSG_MAIN);
1970
       MENU_BACK(MSG_MAIN);
2037
        *
2010
        *
2038
        */
2011
        */
2039
       static void lcd_info_stats_menu() {
2012
       static void lcd_info_stats_menu() {
2040
-        if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2013
+        if (lcd_clicked) { return lcd_goto_previous_menu(true); }
2041
 
2014
 
2042
         char buffer[21];
2015
         char buffer[21];
2043
         printStatistics stats = print_job_timer.getStats();
2016
         printStatistics stats = print_job_timer.getStats();
2071
      *
2044
      *
2072
      */
2045
      */
2073
     static void lcd_info_thermistors_menu() {
2046
     static void lcd_info_thermistors_menu() {
2074
-      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2047
+      if (lcd_clicked) { return lcd_goto_previous_menu(true); }
2075
       START_SCREEN();
2048
       START_SCREEN();
2076
       #define THERMISTOR_ID TEMP_SENSOR_0
2049
       #define THERMISTOR_ID TEMP_SENSOR_0
2077
       #include "thermistornames.h"
2050
       #include "thermistornames.h"
2123
      *
2096
      *
2124
      */
2097
      */
2125
     static void lcd_info_board_menu() {
2098
     static void lcd_info_board_menu() {
2126
-      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2099
+      if (lcd_clicked) { return lcd_goto_previous_menu(true); }
2127
       START_SCREEN();
2100
       START_SCREEN();
2128
       STATIC_ITEM(BOARD_NAME, true, true);                           // MyPrinterController
2101
       STATIC_ITEM(BOARD_NAME, true, true);                           // MyPrinterController
2129
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
2102
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
2144
      *
2117
      *
2145
      */
2118
      */
2146
     static void lcd_info_printer_menu() {
2119
     static void lcd_info_printer_menu() {
2147
-      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2120
+      if (lcd_clicked) { return lcd_goto_previous_menu(true); }
2148
       START_SCREEN();
2121
       START_SCREEN();
2149
       STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
2122
       STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
2150
       STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch
2123
       STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch
2334
   #define menu_edit_type(_type, _name, _strFunc, scale) \
2307
   #define menu_edit_type(_type, _name, _strFunc, scale) \
2335
     bool _menu_edit_ ## _name () { \
2308
     bool _menu_edit_ ## _name () { \
2336
       ENCODER_DIRECTION_NORMAL(); \
2309
       ENCODER_DIRECTION_NORMAL(); \
2337
-      bool isClicked = LCD_CLICKED; \
2338
       if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
2310
       if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
2339
       if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
2311
       if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
2340
       if (lcdDrawUpdate) \
2312
       if (lcdDrawUpdate) \
2341
         lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
2313
         lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
2342
-      if (isClicked) { \
2314
+      if (lcd_clicked) { \
2343
         *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
2315
         *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
2344
         lcd_goto_previous_menu(true); \
2316
         lcd_goto_previous_menu(true); \
2345
       } \
2317
       } \
2346
-      return isClicked; \
2318
+      return lcd_clicked; \
2347
     } \
2319
     } \
2348
     void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \
2320
     void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \
2349
     void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \
2321
     void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \
2614
   #if ENABLED(ULTIPANEL)
2586
   #if ENABLED(ULTIPANEL)
2615
     static millis_t return_to_status_ms = 0;
2587
     static millis_t return_to_status_ms = 0;
2616
     manage_manual_move();
2588
     manage_manual_move();
2617
-  #endif
2618
 
2589
 
2619
-  lcd_buttons_update();
2590
+    lcd_buttons_update();
2591
+
2592
+    // If the action button is pressed...
2593
+    if (LCD_CLICKED) {
2594
+      if (!wait_for_unclick) {           // If not waiting for a debounce release:
2595
+        wait_for_unclick = true;         //  Set debounce flag to ignore continous clicks
2596
+        lcd_clicked = !wait_for_user;    //  Keep the click if not waiting for a user-click
2597
+        wait_for_user = false;           //  Any click clears wait for user
2598
+        lcd_quick_feedback();            //  Always make a click sound
2599
+      }
2600
+    }
2601
+    else wait_for_unclick = false;
2602
+  #endif
2620
 
2603
 
2621
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
2604
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
2622
 
2605
 
2691
       #endif // REPRAPWORLD_KEYPAD
2674
       #endif // REPRAPWORLD_KEYPAD
2692
 
2675
 
2693
       bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
2676
       bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
2694
-      if (encoderPastThreshold || LCD_CLICKED) {
2677
+      if (encoderPastThreshold || lcd_clicked) {
2695
         if (encoderPastThreshold) {
2678
         if (encoderPastThreshold) {
2696
           int32_t encoderMultiplier = 1;
2679
           int32_t encoderMultiplier = 1;
2697
 
2680
 
2757
       }
2740
       }
2758
 
2741
 
2759
       #if ENABLED(ULTIPANEL)
2742
       #if ENABLED(ULTIPANEL)
2760
-        #define CURRENTSCREEN() (*currentScreen)()
2743
+        #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
2761
       #else
2744
       #else
2762
         #define CURRENTSCREEN() lcd_status_screen()
2745
         #define CURRENTSCREEN() lcd_status_screen()
2763
       #endif
2746
       #endif
3020
     #endif
3003
     #endif
3021
   }
3004
   }
3022
 
3005
 
3023
-  bool lcd_clicked() { return LCD_CLICKED; }
3024
-
3025
 #endif // ULTIPANEL
3006
 #endif // ULTIPANEL
3026
 
3007
 
3027
 #endif // ULTRA_LCD
3008
 #endif // ULTRA_LCD

+ 8
- 8
Marlin/ultralcd.h View File

68
     extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
68
     extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
69
     void lcd_buttons_update();
69
     void lcd_buttons_update();
70
     void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual
70
     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
 
71
 
74
     #if ENABLED(FILAMENT_CHANGE_FEATURE)
72
     #if ENABLED(FILAMENT_CHANGE_FEATURE)
75
       void lcd_filament_change_show_message(FilamentChangeMessage message);
73
       void lcd_filament_change_show_message(FilamentChangeMessage message);
79
     FORCE_INLINE void lcd_buttons_update() {}
77
     FORCE_INLINE void lcd_buttons_update() {}
80
   #endif
78
   #endif
81
 
79
 
82
-  extern int preheatHotendTemp1;
83
-  extern int preheatBedTemp1;
84
-  extern int preheatFanSpeed1;
85
-  extern int preheatHotendTemp2;
86
-  extern int preheatBedTemp2;
87
-  extern int preheatFanSpeed2;
80
+  extern int preheatHotendTemp1,
81
+             preheatBedTemp1,
82
+             preheatFanSpeed1,
83
+             preheatHotendTemp2,
84
+             preheatBedTemp2,
85
+             preheatFanSpeed2;
88
 
86
 
89
   #if ENABLED(FILAMENT_LCD_DISPLAY)
87
   #if ENABLED(FILAMENT_LCD_DISPLAY)
90
     extern millis_t previous_lcd_status_ms;
88
     extern millis_t previous_lcd_status_ms;
150
     #define LCD_CLICKED ((buttons & EN_C) || (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F1))
148
     #define LCD_CLICKED ((buttons & EN_C) || (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F1))
151
   #elif ENABLED(NEWPANEL)
149
   #elif ENABLED(NEWPANEL)
152
     #define LCD_CLICKED (buttons & EN_C)
150
     #define LCD_CLICKED (buttons & EN_C)
151
+  #else
152
+    #define LCD_CLICKED false
153
   #endif
153
   #endif
154
 
154
 
155
 #else //no LCD
155
 #else //no LCD

Loading…
Cancel
Save