Ver código fonte

Clear lcd_clicked immediately on use

Scott Lahteine 7 anos atrás
pai
commit
a1ce6e8ff4
1 arquivos alterados com 37 adições e 26 exclusões
  1. 37
    26
      Marlin/src/lcd/ultralcd.cpp

+ 37
- 26
Marlin/src/lcd/ultralcd.cpp Ver arquivo

@@ -295,7 +295,8 @@ uint16_t max_display_update_time = 0;
295 295
    */
296 296
   #define _MENU_ITEM_PART_1(TYPE, ...) \
297 297
     if (_menuLineNr == _thisItemNr) { \
298
-      if (lcd_clicked && encoderLine == _thisItemNr) {
298
+      if (encoderLine == _thisItemNr && lcd_clicked) { \
299
+        lcd_clicked = false
299 300
 
300 301
   #define _MENU_ITEM_PART_2(TYPE, LABEL, ...) \
301 302
         menu_action_ ## TYPE(__VA_ARGS__); \
@@ -499,6 +500,12 @@ uint16_t max_display_update_time = 0;
499 500
     float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits
500 501
   #endif
501 502
 
503
+  inline bool use_click() {
504
+    const bool click = lcd_clicked;
505
+    lcd_clicked = false;
506
+    return click;
507
+  }
508
+
502 509
   /**
503 510
    * General function to go directly to a screen
504 511
    */
@@ -678,7 +685,7 @@ void lcd_status_screen() {
678 685
 
679 686
   #if ENABLED(ULTIPANEL)
680 687
 
681
-    if (lcd_clicked) {
688
+    if (use_click()) {
682 689
       #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
683 690
         previous_lcd_status_ms = millis();  // get status message to show up for a while
684 691
       #endif
@@ -861,7 +868,7 @@ void kill_screen(const char* lcd_msg) {
861 868
 
862 869
     static void progress_bar_test() {
863 870
       static int8_t bar_percent = 0;
864
-      if (lcd_clicked) {
871
+      if (use_click()) {
865 872
         lcd_goto_previous_menu();
866 873
         lcd_set_custom_characters(CHARSET_MENU);
867 874
         return;
@@ -1088,7 +1095,7 @@ void kill_screen(const char* lcd_msg) {
1088 1095
   #if ENABLED(BABYSTEPPING)
1089 1096
 
1090 1097
     void _lcd_babystep(const AxisEnum axis, const char* msg) {
1091
-      if (lcd_clicked) { return lcd_goto_previous_menu_no_defer(); }
1098
+      if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
1092 1099
       ENCODER_DIRECTION_NORMAL();
1093 1100
       if (encoderPosition) {
1094 1101
         const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
@@ -1111,7 +1118,7 @@ void kill_screen(const char* lcd_msg) {
1111 1118
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
1112 1119
 
1113 1120
       void lcd_babystep_zoffset() {
1114
-        if (lcd_clicked) { return lcd_goto_previous_menu_no_defer(); }
1121
+        if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
1115 1122
         defer_return_to_status = true;
1116 1123
         ENCODER_DIRECTION_NORMAL();
1117 1124
         if (encoderPosition) {
@@ -1793,7 +1800,7 @@ void kill_screen(const char* lcd_msg) {
1793 1800
     void _lcd_level_bed_get_z() {
1794 1801
       ENCODER_DIRECTION_NORMAL();
1795 1802
 
1796
-      if (lcd_clicked) {
1803
+      if (use_click()) {
1797 1804
 
1798 1805
         //
1799 1806
         // Save the current Z position and move
@@ -1873,7 +1880,7 @@ void kill_screen(const char* lcd_msg) {
1873 1880
      */
1874 1881
     void _lcd_level_bed_homing_done() {
1875 1882
       if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
1876
-      if (lcd_clicked) {
1883
+      if (use_click()) {
1877 1884
         manual_probe_index = 0;
1878 1885
         _lcd_level_goto_next_point();
1879 1886
       }
@@ -2364,7 +2371,7 @@ void kill_screen(const char* lcd_msg) {
2364 2371
       if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
2365 2372
         return lcd_goto_screen(_lcd_ubl_map_homing);
2366 2373
 
2367
-      if (lcd_clicked) return _lcd_ubl_map_lcd_edit_cmd();
2374
+      if (use_click()) return _lcd_ubl_map_lcd_edit_cmd();
2368 2375
       ENCODER_DIRECTION_NORMAL();
2369 2376
 
2370 2377
       if (encoderPosition) {
@@ -2833,7 +2840,7 @@ void kill_screen(const char* lcd_msg) {
2833 2840
    */
2834 2841
 
2835 2842
   void _lcd_move_xyz(const char* name, AxisEnum axis) {
2836
-    if (lcd_clicked) { return lcd_goto_previous_menu(); }
2843
+    if (use_click()) { return lcd_goto_previous_menu(); }
2837 2844
     ENCODER_DIRECTION_NORMAL();
2838 2845
     if (encoderPosition && !processing_manual_move) {
2839 2846
       gcode.refresh_cmd_timeout();
@@ -2917,7 +2924,7 @@ void kill_screen(const char* lcd_msg) {
2917 2924
       int8_t eindex=-1
2918 2925
     #endif
2919 2926
   ) {
2920
-    if (lcd_clicked) { return lcd_goto_previous_menu(); }
2927
+    if (use_click()) { return lcd_goto_previous_menu(); }
2921 2928
     ENCODER_DIRECTION_NORMAL();
2922 2929
     if (encoderPosition) {
2923 2930
       if (!processing_manual_move) {
@@ -2999,7 +3006,7 @@ void kill_screen(const char* lcd_msg) {
2999 3006
     _manual_move_func_ptr = func;
3000 3007
     START_MENU();
3001 3008
     if (LCD_HEIGHT >= 4) {
3002
-      switch(axis) {
3009
+      switch (axis) {
3003 3010
         case X_AXIS:
3004 3011
           STATIC_ITEM(MSG_MOVE_X, true, true); break;
3005 3012
         case Y_AXIS:
@@ -3802,7 +3809,7 @@ void kill_screen(const char* lcd_msg) {
3802 3809
        *
3803 3810
        */
3804 3811
       void lcd_info_stats_menu() {
3805
-        if (lcd_clicked) { return lcd_goto_previous_menu(); }
3812
+        if (use_click()) { return lcd_goto_previous_menu(); }
3806 3813
 
3807 3814
         char buffer[21];
3808 3815
         printStatistics stats = print_job_timer.getStats();
@@ -3836,7 +3843,7 @@ void kill_screen(const char* lcd_msg) {
3836 3843
      *
3837 3844
      */
3838 3845
     void lcd_info_thermistors_menu() {
3839
-      if (lcd_clicked) { return lcd_goto_previous_menu(); }
3846
+      if (use_click()) { return lcd_goto_previous_menu(); }
3840 3847
       START_SCREEN();
3841 3848
       #define THERMISTOR_ID TEMP_SENSOR_0
3842 3849
       #include "thermistornames.h"
@@ -3897,7 +3904,7 @@ void kill_screen(const char* lcd_msg) {
3897 3904
      *
3898 3905
      */
3899 3906
     void lcd_info_board_menu() {
3900
-      if (lcd_clicked) { return lcd_goto_previous_menu(); }
3907
+      if (use_click()) { return lcd_goto_previous_menu(); }
3901 3908
       START_SCREEN();
3902 3909
       STATIC_ITEM(BOARD_NAME, true, true);                           // MyPrinterController
3903 3910
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
@@ -3918,7 +3925,7 @@ void kill_screen(const char* lcd_msg) {
3918 3925
      *
3919 3926
      */
3920 3927
     void lcd_info_printer_menu() {
3921
-      if (lcd_clicked) { return lcd_goto_previous_menu(); }
3928
+      if (use_click()) { return lcd_goto_previous_menu(); }
3922 3929
       START_SCREEN();
3923 3930
       STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
3924 3931
       STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch
@@ -4317,7 +4324,7 @@ void kill_screen(const char* lcd_msg) {
4317 4324
         if (liveEdit) (*callbackFunc)(); \
4318 4325
         if (lcd_clicked) lcd_goto_previous_menu(); \
4319 4326
       } \
4320
-      return lcd_clicked; \
4327
+      return use_click(); \
4321 4328
     } \
4322 4329
     void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \
4323 4330
     void menu_edit_callback_ ## _name() { if (_menu_edit_ ## _name()) (*callbackFunc)(); } \
@@ -4674,7 +4681,7 @@ void lcd_update() {
4674 4681
     #if ENABLED(DOGLCD)
4675 4682
       || drawing_screen
4676 4683
     #endif
4677
-    ) {
4684
+  ) {
4678 4685
 
4679 4686
     next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
4680 4687
 
@@ -4778,12 +4785,13 @@ void lcd_update() {
4778 4785
 
4779 4786
     if ((lcdDrawUpdate || IS_DRAWING) && (!bbr2 || bbr2 > max_display_update_time)) {
4780 4787
 
4788
+      // Change state of drawing flag between screen updates
4781 4789
       if (!IS_DRAWING) switch (lcdDrawUpdate) {
4782 4790
         case LCDVIEW_CALL_NO_REDRAW:
4783 4791
           lcdDrawUpdate = LCDVIEW_NONE;
4784 4792
           break;
4785
-        case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here)
4786
-        case LCDVIEW_CALL_REDRAW_NEXT:  // set by handlers, then altered after (never occurs here?)
4793
+        case LCDVIEW_CLEAR_CALL_REDRAW:
4794
+        case LCDVIEW_CALL_REDRAW_NEXT:
4787 4795
           lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
4788 4796
         case LCDVIEW_REDRAW_NOW:        // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
4789 4797
         case LCDVIEW_NONE:
@@ -4795,7 +4803,7 @@ void lcd_update() {
4795 4803
       #endif
4796 4804
 
4797 4805
       #if ENABLED(ULTIPANEL)
4798
-        #define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false
4806
+        #define CURRENTSCREEN() (*currentScreen)()
4799 4807
       #else
4800 4808
         #define CURRENTSCREEN() lcd_status_screen()
4801 4809
       #endif
@@ -4820,6 +4828,10 @@ void lcd_update() {
4820 4828
         CURRENTSCREEN();
4821 4829
       #endif
4822 4830
 
4831
+      #if ENABLED(ULTIPANEL)
4832
+        lcd_clicked = false;
4833
+      #endif
4834
+
4823 4835
       // Keeping track of the longest time for an individual LCD update.
4824 4836
       // Used to do screen throttling when the planner starts to fill up.
4825 4837
       NOLESS(max_display_update_time, millis() - ms);
@@ -4835,17 +4847,16 @@ void lcd_update() {
4835 4847
 
4836 4848
     #endif // ULTIPANEL
4837 4849
 
4850
+    // Change state of drawing flag between screen updates
4838 4851
     if (!IS_DRAWING) switch (lcdDrawUpdate) {
4839 4852
       case LCDVIEW_CLEAR_CALL_REDRAW:
4840
-        lcd_implementation_clear();
4841
-      case LCDVIEW_CALL_REDRAW_NEXT:
4842
-        lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
4843
-        break;
4853
+        lcd_implementation_clear(); break;
4844 4854
       case LCDVIEW_REDRAW_NOW:
4845 4855
         lcdDrawUpdate = LCDVIEW_NONE;
4846
-        break;
4847 4856
       case LCDVIEW_NONE:
4848
-        break;
4857
+      case LCDVIEW_CALL_REDRAW_NEXT:
4858
+      case LCDVIEW_CALL_NO_REDRAW:
4859
+      default: break;
4849 4860
     } // switch
4850 4861
 
4851 4862
   } // ELAPSED(ms, next_lcd_update_ms)

Carregando…
Cancelar
Salvar