Bladeren bron

Clear lcd_clicked immediately on use

Scott Lahteine 7 jaren geleden
bovenliggende
commit
a1ce6e8ff4
1 gewijzigde bestanden met toevoegingen van 37 en 26 verwijderingen
  1. 37
    26
      Marlin/src/lcd/ultralcd.cpp

+ 37
- 26
Marlin/src/lcd/ultralcd.cpp Bestand weergeven

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

Laden…
Annuleren
Opslaan