Browse Source

Encoder direction: Wrangle, Revert select screen change (#14628)

Robby Candra 5 years ago
parent
commit
c9aa68ef7a

+ 0
- 1
Marlin/src/lcd/menu/game/game.cpp View File

@@ -56,7 +56,6 @@ void MarlinGame::draw_game_over() {
56 56
 void MarlinGame::init_game(const uint8_t init_state, const screenFunc_t screen) {
57 57
   score = 0;
58 58
   game_state = init_state;
59
-  ui.encoder_direction_normal();
60 59
   ui.goto_screen(screen);
61 60
   ui.defer_status_screen();
62 61
 }

+ 14
- 10
Marlin/src/lcd/menu/menu.cpp View File

@@ -130,7 +130,6 @@ void MenuItem_gcode::action(PGM_P const pgcode) { queue.inject_P(pgcode); }
130 130
  *       MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
131 131
  */
132 132
 void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
133
-  ui.encoder_direction_normal();
134 133
   if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
135 134
   if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
136 135
   if (ui.should_draw())
@@ -276,7 +275,11 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
276 275
       drawing_screen = false;
277 276
     #endif
278 277
 
279
-    set_ui_selection(false);
278
+    #if HAS_LCD_MENU
279
+      encoder_direction_normal();
280
+    #endif
281
+
282
+    set_selection(false);
280 283
   }
281 284
 }
282 285
 
@@ -371,7 +374,6 @@ void MarlinUI::completion_feedback(const bool good/*=true*/) {
371 374
     #else
372 375
       constexpr bool do_probe = true;
373 376
     #endif
374
-    ui.encoder_direction_normal();
375 377
     if (ui.encoderPosition) {
376 378
       const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
377 379
       ui.encoderPosition = 0;
@@ -448,14 +450,16 @@ void _lcd_draw_homing() {
448 450
 //
449 451
 // Selection screen presents a prompt and two options
450 452
 //
451
-bool ui_selection; // = false
452
-void set_ui_selection(const bool sel) { ui_selection = sel; }
453
-void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
454
-  if (ui.encoderPosition) {
455
-    ui_selection = ((ENCODERBASE) > 0) == (int16_t(ui.encoderPosition) > 0);
456
-    ui.encoderPosition = 0;
453
+bool MarlinUI::selection; // = false
454
+bool MarlinUI::update_selection() {
455
+  if (encoderPosition) {
456
+    selection = int16_t(encoderPosition) > 0;
457
+    encoderPosition = 0;
457 458
   }
458
-  const bool got_click = ui.use_click();
459
+  return selection;
460
+}
461
+void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
462
+  const bool ui_selection = ui.update_selection(), got_click = ui.use_click();
459 463
   if (got_click || ui.should_draw()) {
460 464
     draw_select_screen(yes, no, ui_selection, pref, string, suff);
461 465
     if (got_click) { ui_selection ? yesFunc() : noFunc(); }

+ 0
- 1
Marlin/src/lcd/menu/menu.h View File

@@ -71,7 +71,6 @@ DECLARE_MENU_EDIT_TYPE(uint32_t, long5_25,    ftostr5rj,       0.04f );   // 123
71 71
 
72 72
 typedef void (*selectFunc_t)();
73 73
 void draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff);
74
-void set_ui_selection(const bool sel);
75 74
 void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
76 75
 inline void do_select_screen_yn(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
77 76
   do_select_screen(PSTR(MSG_YES), PSTR(MSG_NO), yesFunc, noFunc, pref, string, suff);

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_corners.cpp View File

@@ -111,7 +111,7 @@ static inline void _lcd_level_bed_corners_homing() {
111 111
   if (all_axes_homed()) {
112 112
     bed_corner = 0;
113 113
     ui.goto_screen(menu_level_bed_corners);
114
-    set_ui_selection(true);
114
+    ui.set_selection(true);
115 115
     _lcd_goto_next_corner();
116 116
   }
117 117
 }

+ 0
- 1
Marlin/src/lcd/menu/menu_bed_leveling.cpp View File

@@ -89,7 +89,6 @@
89 89
   // Step 7: Get the Z coordinate, click goes to the next point or exits
90 90
   //
91 91
   void _lcd_level_bed_get_z() {
92
-    ui.encoder_direction_normal();
93 92
 
94 93
     if (ui.use_click()) {
95 94
 

+ 0
- 1
Marlin/src/lcd/menu/menu_configuration.cpp View File

@@ -62,7 +62,6 @@ static void lcd_factory_settings() {
62 62
   #include "../lcdprint.h"
63 63
 
64 64
   static void progress_bar_test() {
65
-    ui.encoder_direction_normal();
66 65
     static int8_t bar_percent = 0;
67 66
     if (ui.use_click()) {
68 67
       ui.goto_previous_screen();

+ 0
- 2
Marlin/src/lcd/menu/menu_mixer.cpp View File

@@ -41,7 +41,6 @@
41 41
 
42 42
   void lcd_mixer_gradient_z_start_edit() {
43 43
     ui.defer_status_screen();
44
-    ui.encoder_direction_normal();
45 44
     ENCODER_RATE_MULTIPLY(true);
46 45
     if (ui.encoderPosition != 0) {
47 46
       mixer.gradient.start_z += float(int16_t(ui.encoderPosition)) * 0.1;
@@ -66,7 +65,6 @@
66 65
 
67 66
   void lcd_mixer_gradient_z_end_edit() {
68 67
     ui.defer_status_screen();
69
-    ui.encoder_direction_normal();
70 68
     ENCODER_RATE_MULTIPLY(true);
71 69
     if (ui.encoderPosition != 0) {
72 70
       mixer.gradient.end_z += float(int16_t(ui.encoderPosition)) * 0.1;

+ 0
- 2
Marlin/src/lcd/menu/menu_motion.cpp View File

@@ -74,7 +74,6 @@ inline void manual_move_to_current(AxisEnum axis
74 74
 
75 75
 static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
76 76
   if (ui.use_click()) return ui.goto_previous_screen_no_defer();
77
-  ui.encoder_direction_normal();
78 77
   if (ui.encoderPosition && !ui.processing_manual_move) {
79 78
 
80 79
     // Start with no limits to movement
@@ -158,7 +157,6 @@ static void _lcd_move_e(
158 157
   #endif
159 158
 ) {
160 159
   if (ui.use_click()) return ui.goto_previous_screen_no_defer();
161
-  ui.encoder_direction_normal();
162 160
   if (ui.encoderPosition) {
163 161
     if (!ui.processing_manual_move) {
164 162
       const float diff = float(int16_t(ui.encoderPosition)) * move_menu_scale;

+ 0
- 1
Marlin/src/lcd/menu/menu_tune.cpp View File

@@ -73,7 +73,6 @@
73 73
 
74 74
   void _lcd_babystep(const AxisEnum axis, PGM_P const msg) {
75 75
     if (ui.use_click()) return ui.goto_previous_screen_no_defer();
76
-    ui.encoder_direction_normal();
77 76
     if (ui.encoderPosition) {
78 77
       const int16_t steps = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
79 78
       ui.encoderPosition = 0;

+ 0
- 1
Marlin/src/lcd/menu/menu_ubl.cpp View File

@@ -468,7 +468,6 @@ void _lcd_ubl_output_map_lcd() {
468 468
   static int16_t step_scaler = 0;
469 469
 
470 470
   if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
471
-  ui.encoder_direction_normal();
472 471
 
473 472
   if (ui.encoderPosition) {
474 473
     step_scaler += int16_t(ui.encoderPosition);

+ 1
- 2
Marlin/src/lcd/ultralcd.cpp View File

@@ -392,7 +392,7 @@ bool MarlinUI::get_blink() {
392 392
         #if HAS_ENCODER_ACTION
393 393
           refresh(LCDVIEW_REDRAW_NOW);
394 394
           #if HAS_LCD_MENU
395
-            if (encoderDirection == -1) {     // ADC_KEYPAD forces REVERSE_MENU_DIRECTION, so this indicates menu navigation
395
+            if (encoderDirection == -(ENCODERBASE)) { // ADC_KEYPAD forces REVERSE_MENU_DIRECTION, so this indicates menu navigation
396 396
                    if (RRK(EN_KEYPAD_UP))     encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
397 397
               else if (RRK(EN_KEYPAD_DOWN))   encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
398 398
               else if (RRK(EN_KEYPAD_LEFT))   { MenuItem_back::action(); quick_feedback(); }
@@ -480,7 +480,6 @@ bool MarlinUI::get_blink() {
480 480
 void MarlinUI::status_screen() {
481 481
 
482 482
   #if HAS_LCD_MENU
483
-    encoder_direction_normal();
484 483
     ENCODER_RATE_MULTIPLY(false);
485 484
   #endif
486 485
 

+ 5
- 0
Marlin/src/lcd/ultralcd.h View File

@@ -424,6 +424,11 @@ public:
424 424
     static int16_t preheat_hotend_temp[2], preheat_bed_temp[2];
425 425
     static uint8_t preheat_fan_speed[2];
426 426
 
427
+    // Select Screen (modal NO/YES style dialog)
428
+    static bool selection;
429
+    static void set_selection(const bool sel) { selection = sel; }
430
+    static bool update_selection();
431
+
427 432
     static void manage_manual_move();
428 433
 
429 434
     static bool lcd_clicked;

Loading…
Cancel
Save