|
@@ -114,12 +114,16 @@ millis_t next_button_update_ms;
|
114
|
114
|
bool drawing_screen, first_page; // = false
|
115
|
115
|
#endif
|
116
|
116
|
|
117
|
|
-#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
118
|
|
- bool encoderRateMultiplierEnabled;
|
119
|
|
-#endif
|
120
|
|
-
|
121
|
|
-#if ENABLED(REVERSE_MENU_DIRECTION)
|
122
|
|
- int8_t encoderDirection = 1;
|
|
117
|
+// Encoder Handling
|
|
118
|
+#if HAS_ENCODER_ACTION
|
|
119
|
+ uint32_t encoderPosition;
|
|
120
|
+ volatile int8_t encoderDiff; // Updated in lcd_buttons_update, added to encoderPosition every LCD update
|
|
121
|
+ #if ENABLED(ENCODER_RATE_MULTIPLIER)
|
|
122
|
+ bool encoderRateMultiplierEnabled;
|
|
123
|
+ #endif
|
|
124
|
+ #if ENABLED(REVERSE_MENU_DIRECTION)
|
|
125
|
+ int8_t encoderDirection = 1;
|
|
126
|
+ #endif
|
123
|
127
|
#endif
|
124
|
128
|
|
125
|
129
|
#if HAS_LCD_MENU
|
|
@@ -127,10 +131,10 @@ millis_t next_button_update_ms;
|
127
|
131
|
|
128
|
132
|
screenFunc_t currentScreen = lcd_status_screen;
|
129
|
133
|
|
130
|
|
- // Encoder Handling
|
131
|
|
- volatile int8_t encoderDiff; // Updated in lcd_buttons_update, added to encoderPosition every LCD update
|
132
|
|
- uint32_t encoderPosition;
|
133
|
|
- millis_t lastEncoderMovementMillis = 0;
|
|
134
|
+ #if ENABLED(ENCODER_RATE_MULTIPLIER)
|
|
135
|
+ millis_t lastEncoderMovementMillis = 0;
|
|
136
|
+ #endif
|
|
137
|
+
|
134
|
138
|
bool lcd_clicked, wait_for_unclick;
|
135
|
139
|
float move_menu_scale;
|
136
|
140
|
|
|
@@ -139,6 +143,11 @@ millis_t next_button_update_ms;
|
139
|
143
|
lcd_clicked = false;
|
140
|
144
|
return click;
|
141
|
145
|
}
|
|
146
|
+
|
|
147
|
+#else
|
|
148
|
+
|
|
149
|
+ constexpr bool lcd_clicked = false;
|
|
150
|
+
|
142
|
151
|
#endif
|
143
|
152
|
|
144
|
153
|
void lcd_init() {
|
|
@@ -200,7 +209,7 @@ void lcd_init() {
|
200
|
209
|
|
201
|
210
|
lcd_buttons_update();
|
202
|
211
|
|
203
|
|
- #if HAS_LCD_MENU
|
|
212
|
+ #if HAS_ENCODER_ACTION
|
204
|
213
|
encoderDiff = 0;
|
205
|
214
|
#endif
|
206
|
215
|
}
|
|
@@ -229,17 +238,20 @@ bool lcd_blink() {
|
229
|
238
|
inline bool handle_adc_keypad() {
|
230
|
239
|
#define ADC_MIN_KEY_DELAY 100
|
231
|
240
|
if (buttons_reprapworld_keypad) {
|
232
|
|
- lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
233
|
|
- if (encoderDirection == -1) { // side effect which signals we are inside a menu
|
234
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
|
235
|
|
- else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
|
236
|
|
- else if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) { menu_action_back(); lcd_quick_feedback(true); }
|
237
|
|
- else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) { lcd_return_to_status(); lcd_quick_feedback(true); }
|
238
|
|
- }
|
239
|
|
- else if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition += ENCODER_PULSES_PER_STEP;
|
240
|
|
- else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition -= ENCODER_PULSES_PER_STEP;
|
241
|
|
- else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) encoderPosition = 0;
|
242
|
|
-
|
|
241
|
+ #if HAS_ENCODER_ACTION
|
|
242
|
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
|
243
|
+ if (encoderDirection == -1) { // side effect which signals we are inside a menu
|
|
244
|
+ #if HAS_LCD_MENU
|
|
245
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
|
|
246
|
+ else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
|
|
247
|
+ else if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) { menu_item_back::action(); lcd_quick_feedback(true); }
|
|
248
|
+ else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) { lcd_return_to_status(); lcd_quick_feedback(true); }
|
|
249
|
+ #endif
|
|
250
|
+ }
|
|
251
|
+ else if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition += ENCODER_PULSES_PER_STEP;
|
|
252
|
+ else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition -= ENCODER_PULSES_PER_STEP;
|
|
253
|
+ else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) encoderPosition = 0;
|
|
254
|
+ #endif
|
243
|
255
|
next_button_update_ms = millis() + ADC_MIN_KEY_DELAY;
|
244
|
256
|
return true;
|
245
|
257
|
}
|
|
@@ -249,20 +261,24 @@ bool lcd_blink() {
|
249
|
261
|
|
250
|
262
|
#elif ENABLED(REPRAPWORLD_KEYPAD)
|
251
|
263
|
|
252
|
|
- void lcd_move_x();
|
253
|
|
- void lcd_move_y();
|
254
|
|
- void lcd_move_z();
|
255
|
|
-
|
256
|
|
- void _reprapworld_keypad_move(const AxisEnum axis, const int16_t dir) {
|
257
|
|
- move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
|
258
|
|
- encoderPosition = dir;
|
259
|
|
- switch (axis) {
|
260
|
|
- case X_AXIS: lcd_move_x(); break;
|
261
|
|
- case Y_AXIS: lcd_move_y(); break;
|
262
|
|
- case Z_AXIS: lcd_move_z();
|
263
|
|
- default: break;
|
|
264
|
+ #if HAS_LCD_MENU
|
|
265
|
+
|
|
266
|
+ void lcd_move_x();
|
|
267
|
+ void lcd_move_y();
|
|
268
|
+ void lcd_move_z();
|
|
269
|
+
|
|
270
|
+ void _reprapworld_keypad_move(const AxisEnum axis, const int16_t dir) {
|
|
271
|
+ move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
|
|
272
|
+ encoderPosition = dir;
|
|
273
|
+ switch (axis) {
|
|
274
|
+ case X_AXIS: lcd_move_x(); break;
|
|
275
|
+ case Y_AXIS: lcd_move_y(); break;
|
|
276
|
+ case Z_AXIS: lcd_move_z();
|
|
277
|
+ default: break;
|
|
278
|
+ }
|
264
|
279
|
}
|
265
|
|
- }
|
|
280
|
+
|
|
281
|
+ #endif
|
266
|
282
|
|
267
|
283
|
inline void handle_reprapworld_keypad() {
|
268
|
284
|
|
|
@@ -278,23 +294,30 @@ bool lcd_blink() {
|
278
|
294
|
else if (!keypad_debounce) {
|
279
|
295
|
keypad_debounce = 2;
|
280
|
296
|
|
281
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE)) lcd_goto_screen(menu_move);
|
|
297
|
+ const bool homed = all_axes_homed();
|
282
|
298
|
|
283
|
|
- #if DISABLED(DELTA) && Z_HOME_DIR == -1
|
284
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1);
|
285
|
|
- #endif
|
|
299
|
+ #if HAS_LCD_MENU
|
286
|
300
|
|
287
|
|
- if (all_axes_homed()) {
|
288
|
|
- #if ENABLED(DELTA) || Z_HOME_DIR != -1
|
289
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1);
|
|
301
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE)) lcd_goto_screen(menu_move);
|
|
302
|
+
|
|
303
|
+ #if DISABLED(DELTA) && Z_HOME_DIR == -1
|
|
304
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1);
|
290
|
305
|
#endif
|
291
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_F3)) _reprapworld_keypad_move(Z_AXIS, -1);
|
292
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) _reprapworld_keypad_move(X_AXIS, -1);
|
293
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) _reprapworld_keypad_move(X_AXIS, 1);
|
294
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) _reprapworld_keypad_move(Y_AXIS, 1);
|
295
|
|
- if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) _reprapworld_keypad_move(Y_AXIS, -1);
|
296
|
|
- }
|
297
|
|
- else if (RRK(EN_REPRAPWORLD_KEYPAD_F1)) enqueue_and_echo_commands_P(PSTR("G28"));
|
|
306
|
+
|
|
307
|
+ if (homed) {
|
|
308
|
+ #if ENABLED(DELTA) || Z_HOME_DIR != -1
|
|
309
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1);
|
|
310
|
+ #endif
|
|
311
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_F3)) _reprapworld_keypad_move(Z_AXIS, -1);
|
|
312
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) _reprapworld_keypad_move(X_AXIS, -1);
|
|
313
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) _reprapworld_keypad_move(X_AXIS, 1);
|
|
314
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) _reprapworld_keypad_move(Y_AXIS, 1);
|
|
315
|
+ if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) _reprapworld_keypad_move(Y_AXIS, -1);
|
|
316
|
+ }
|
|
317
|
+
|
|
318
|
+ #endif // HAS_LCD_MENU
|
|
319
|
+
|
|
320
|
+ if (!homed && RRK(EN_REPRAPWORLD_KEYPAD_F1)) enqueue_and_echo_commands_P(PSTR("G28"));
|
298
|
321
|
}
|
299
|
322
|
}
|
300
|
323
|
|
|
@@ -387,32 +410,34 @@ void lcd_status_screen() {
|
387
|
410
|
return;
|
388
|
411
|
}
|
389
|
412
|
|
390
|
|
- #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
|
391
|
|
- const int16_t new_frm = feedrate_percentage + (int32_t)encoderPosition;
|
392
|
|
- // Dead zone at 100% feedrate
|
393
|
|
- if ((feedrate_percentage < 100 && new_frm > 100) || (feedrate_percentage > 100 && new_frm < 100)) {
|
394
|
|
- feedrate_percentage = 100;
|
|
413
|
+ #endif // HAS_LCD_MENU
|
|
414
|
+
|
|
415
|
+ #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
|
|
416
|
+
|
|
417
|
+ const int16_t new_frm = feedrate_percentage + (int32_t)encoderPosition;
|
|
418
|
+ // Dead zone at 100% feedrate
|
|
419
|
+ if ((feedrate_percentage < 100 && new_frm > 100) || (feedrate_percentage > 100 && new_frm < 100)) {
|
|
420
|
+ feedrate_percentage = 100;
|
|
421
|
+ encoderPosition = 0;
|
|
422
|
+ }
|
|
423
|
+ else if (feedrate_percentage == 100) {
|
|
424
|
+ if ((int32_t)encoderPosition > ENCODER_FEEDRATE_DEADZONE) {
|
|
425
|
+ feedrate_percentage += (int32_t)encoderPosition - (ENCODER_FEEDRATE_DEADZONE);
|
395
|
426
|
encoderPosition = 0;
|
396
|
427
|
}
|
397
|
|
- else if (feedrate_percentage == 100) {
|
398
|
|
- if ((int32_t)encoderPosition > ENCODER_FEEDRATE_DEADZONE) {
|
399
|
|
- feedrate_percentage += (int32_t)encoderPosition - (ENCODER_FEEDRATE_DEADZONE);
|
400
|
|
- encoderPosition = 0;
|
401
|
|
- }
|
402
|
|
- else if ((int32_t)encoderPosition < -(ENCODER_FEEDRATE_DEADZONE)) {
|
403
|
|
- feedrate_percentage += (int32_t)encoderPosition + ENCODER_FEEDRATE_DEADZONE;
|
404
|
|
- encoderPosition = 0;
|
405
|
|
- }
|
406
|
|
- }
|
407
|
|
- else {
|
408
|
|
- feedrate_percentage = new_frm;
|
|
428
|
+ else if ((int32_t)encoderPosition < -(ENCODER_FEEDRATE_DEADZONE)) {
|
|
429
|
+ feedrate_percentage += (int32_t)encoderPosition + ENCODER_FEEDRATE_DEADZONE;
|
409
|
430
|
encoderPosition = 0;
|
410
|
431
|
}
|
411
|
|
- #endif // ULTIPANEL_FEEDMULTIPLY
|
|
432
|
+ }
|
|
433
|
+ else {
|
|
434
|
+ feedrate_percentage = new_frm;
|
|
435
|
+ encoderPosition = 0;
|
|
436
|
+ }
|
412
|
437
|
|
413
|
438
|
feedrate_percentage = constrain(feedrate_percentage, 10, 999);
|
414
|
439
|
|
415
|
|
- #endif // HAS_LCD_MENU
|
|
440
|
+ #endif // ULTIPANEL_FEEDMULTIPLY
|
416
|
441
|
|
417
|
442
|
#if LCD_INFO_SCREEN_STYLE == 0
|
418
|
443
|
lcd_impl_status_screen_0();
|
|
@@ -594,6 +619,16 @@ LCDViewAction lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
|
594
|
619
|
volatile uint8_t slow_buttons;
|
595
|
620
|
#endif
|
596
|
621
|
|
|
622
|
+bool lcd_detected() {
|
|
623
|
+ return
|
|
624
|
+ #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE)
|
|
625
|
+ lcd.LcdDetected() == 1
|
|
626
|
+ #else
|
|
627
|
+ true
|
|
628
|
+ #endif
|
|
629
|
+ ;
|
|
630
|
+}
|
|
631
|
+
|
597
|
632
|
void lcd_update() {
|
598
|
633
|
|
599
|
634
|
static uint16_t max_display_update_time = 0;
|
|
@@ -693,10 +728,14 @@ void lcd_update() {
|
693
|
728
|
slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
|
694
|
729
|
#endif
|
695
|
730
|
|
|
731
|
+ #endif // HAS_LCD_MENU
|
|
732
|
+
|
|
733
|
+ #if HAS_ENCODER_ACTION
|
|
734
|
+
|
696
|
735
|
#if ENABLED(ADC_KEYPAD)
|
697
|
736
|
|
698
|
737
|
if (handle_adc_keypad()) {
|
699
|
|
- #if LCD_TIMEOUT_TO_STATUS
|
|
738
|
+ #if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS
|
700
|
739
|
return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
|
701
|
740
|
#endif
|
702
|
741
|
}
|
|
@@ -710,9 +749,10 @@ void lcd_update() {
|
710
|
749
|
const bool encoderPastThreshold = (ABS(encoderDiff) >= ENCODER_PULSES_PER_STEP);
|
711
|
750
|
if (encoderPastThreshold || lcd_clicked) {
|
712
|
751
|
if (encoderPastThreshold) {
|
713
|
|
- int32_t encoderMultiplier = 1;
|
714
|
752
|
|
715
|
|
- #if ENABLED(ENCODER_RATE_MULTIPLIER)
|
|
753
|
+ #if HAS_LCD_MENU && ENABLED(ENCODER_RATE_MULTIPLIER)
|
|
754
|
+
|
|
755
|
+ int32_t encoderMultiplier = 1;
|
716
|
756
|
|
717
|
757
|
if (encoderRateMultiplierEnabled) {
|
718
|
758
|
int32_t encoderMovementSteps = ABS(encoderDiff) / ENCODER_PULSES_PER_STEP;
|
|
@@ -737,18 +777,23 @@ void lcd_update() {
|
737
|
777
|
|
738
|
778
|
lastEncoderMovementMillis = ms;
|
739
|
779
|
} // encoderRateMultiplierEnabled
|
|
780
|
+
|
|
781
|
+ #else
|
|
782
|
+
|
|
783
|
+ constexpr int32_t encoderMultiplier = 1;
|
|
784
|
+
|
740
|
785
|
#endif // ENCODER_RATE_MULTIPLIER
|
741
|
786
|
|
742
|
787
|
encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
|
743
|
788
|
encoderDiff = 0;
|
744
|
789
|
}
|
745
|
|
- #if LCD_TIMEOUT_TO_STATUS
|
|
790
|
+ #if HAS_LCD_MENU && LCD_TIMEOUT_TO_STATUS
|
746
|
791
|
return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
|
747
|
792
|
#endif
|
748
|
793
|
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
749
|
794
|
}
|
750
|
795
|
|
751
|
|
- #endif // HAS_LCD_MENU
|
|
796
|
+ #endif
|
752
|
797
|
|
753
|
798
|
// This runs every ~100ms when idling often enough.
|
754
|
799
|
// Instead of tracking changes just redraw the Status Screen once per second.
|
|
@@ -1039,12 +1084,6 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
1039
|
1084
|
} \
|
1040
|
1085
|
DST = ~new_##DST; //invert it, because a pressed switch produces a logical 0
|
1041
|
1086
|
|
1042
|
|
- #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
|
1043
|
|
- bool lcd_detected() { return lcd.LcdDetected() == 1; }
|
1044
|
|
- #else
|
1045
|
|
- bool lcd_detected() { return true; }
|
1046
|
|
- #endif
|
1047
|
|
-
|
1048
|
1087
|
#if ENABLED(G26_MESH_VALIDATION)
|
1049
|
1088
|
void lcd_chirp() {
|
1050
|
1089
|
lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
|