@@ -43,7 +43,6 @@ MarlinUI ui;
43
43
#if HAS_DISPLAY
44
44
#include " ../gcode/queue.h"
45
45
#include " fontutils.h"
46
- #include " ../sd/cardreader.h"
47
46
#endif
48
47
49
48
#if ENABLED(DWIN_CREALITY_LCD)
@@ -176,6 +175,77 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
176
175
177
176
#endif
178
177
178
+ // Encoder Handling
179
+ #if HAS_ENCODER_ACTION
180
+ uint32_t MarlinUI::encoderPosition;
181
+ volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
182
+ #endif
183
+
184
+ void MarlinUI::init () {
185
+
186
+ init_lcd ();
187
+
188
+ #if HAS_DIGITAL_BUTTONS
189
+ #if BUTTON_EXISTS(EN1)
190
+ SET_INPUT_PULLUP (BTN_EN1);
191
+ #endif
192
+ #if BUTTON_EXISTS(EN2)
193
+ SET_INPUT_PULLUP (BTN_EN2);
194
+ #endif
195
+ #if BUTTON_EXISTS(ENC)
196
+ SET_INPUT_PULLUP (BTN_ENC);
197
+ #endif
198
+ #if BUTTON_EXISTS(ENC_EN)
199
+ SET_INPUT_PULLUP (BTN_ENC_EN);
200
+ #endif
201
+ #if BUTTON_EXISTS(BACK)
202
+ SET_INPUT_PULLUP (BTN_BACK);
203
+ #endif
204
+ #if BUTTON_EXISTS(UP)
205
+ SET_INPUT (BTN_UP);
206
+ #endif
207
+ #if BUTTON_EXISTS(DWN)
208
+ SET_INPUT (BTN_DWN);
209
+ #endif
210
+ #if BUTTON_EXISTS(LFT)
211
+ SET_INPUT (BTN_LFT);
212
+ #endif
213
+ #if BUTTON_EXISTS(RT)
214
+ SET_INPUT (BTN_RT);
215
+ #endif
216
+ #endif
217
+
218
+ #if HAS_SHIFT_ENCODER
219
+
220
+ #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
221
+
222
+ SET_OUTPUT (SR_DATA_PIN);
223
+ SET_OUTPUT (SR_CLK_PIN);
224
+
225
+ #elif PIN_EXISTS(SHIFT_CLK)
226
+
227
+ SET_OUTPUT (SHIFT_CLK_PIN);
228
+ OUT_WRITE (SHIFT_LD_PIN, HIGH);
229
+ #if PIN_EXISTS(SHIFT_EN)
230
+ OUT_WRITE (SHIFT_EN_PIN, LOW);
231
+ #endif
232
+ SET_INPUT_PULLUP (SHIFT_OUT_PIN);
233
+
234
+ #endif
235
+
236
+ #endif // HAS_SHIFT_ENCODER
237
+
238
+ #if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS)
239
+ slow_buttons = 0 ;
240
+ #endif
241
+
242
+ update_buttons ();
243
+
244
+ TERN_ (HAS_ENCODER_ACTION, encoderDiff = 0 );
245
+
246
+ reset_status (); // Set welcome message
247
+ }
248
+
179
249
#if HAS_WIRED_LCD
180
250
181
251
#if HAS_MARLINUI_U8GLIB
@@ -184,8 +254,6 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
184
254
185
255
#include " lcdprint.h"
186
256
187
- #include " ../sd/cardreader.h"
188
-
189
257
#include " ../module/temperature.h"
190
258
#include " ../module/planner.h"
191
259
#include " ../module/motion.h"
@@ -247,16 +315,8 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
247
315
bool MarlinUI::old_is_printing;
248
316
#endif
249
317
250
- // Encoder Handling
251
- #if HAS_ENCODER_ACTION
252
- uint32_t MarlinUI::encoderPosition;
253
- volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
254
- #endif
255
-
256
318
#if ENABLED(SDSUPPORT)
257
319
258
- #include " ../sd/cardreader.h"
259
-
260
320
#if MARLINUI_SCROLL_NAME
261
321
uint8_t MarlinUI::filename_scroll_pos, MarlinUI::filename_scroll_max;
262
322
#endif
@@ -393,69 +453,6 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
393
453
394
454
#endif // HAS_LCD_MENU
395
455
396
- void MarlinUI::init () {
397
-
398
- init_lcd ();
399
-
400
- #if HAS_DIGITAL_BUTTONS
401
- #if BUTTON_EXISTS(EN1)
402
- SET_INPUT_PULLUP (BTN_EN1);
403
- #endif
404
- #if BUTTON_EXISTS(EN2)
405
- SET_INPUT_PULLUP (BTN_EN2);
406
- #endif
407
- #if BUTTON_EXISTS(ENC)
408
- SET_INPUT_PULLUP (BTN_ENC);
409
- #endif
410
- #if BUTTON_EXISTS(ENC_EN)
411
- SET_INPUT_PULLUP (BTN_ENC_EN);
412
- #endif
413
- #if BUTTON_EXISTS(BACK)
414
- SET_INPUT_PULLUP (BTN_BACK);
415
- #endif
416
- #if BUTTON_EXISTS(UP)
417
- SET_INPUT (BTN_UP);
418
- #endif
419
- #if BUTTON_EXISTS(DWN)
420
- SET_INPUT (BTN_DWN);
421
- #endif
422
- #if BUTTON_EXISTS(LFT)
423
- SET_INPUT (BTN_LFT);
424
- #endif
425
- #if BUTTON_EXISTS(RT)
426
- SET_INPUT (BTN_RT);
427
- #endif
428
- #endif
429
-
430
- #if HAS_SHIFT_ENCODER
431
-
432
- #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
433
-
434
- SET_OUTPUT (SR_DATA_PIN);
435
- SET_OUTPUT (SR_CLK_PIN);
436
-
437
- #elif PIN_EXISTS(SHIFT_CLK)
438
-
439
- SET_OUTPUT (SHIFT_CLK_PIN);
440
- OUT_WRITE (SHIFT_LD_PIN, HIGH);
441
- #if PIN_EXISTS(SHIFT_EN)
442
- OUT_WRITE (SHIFT_EN_PIN, LOW);
443
- #endif
444
- SET_INPUT_PULLUP (SHIFT_OUT_PIN);
445
-
446
- #endif
447
-
448
- #endif // HAS_SHIFT_ENCODER
449
-
450
- #if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS)
451
- slow_buttons = 0 ;
452
- #endif
453
-
454
- update_buttons ();
455
-
456
- TERN_ (HAS_ENCODER_ACTION, encoderDiff = 0 );
457
- }
458
-
459
456
// //////////////////////////////////////////
460
457
// /////////// Keypad Handling //////////////
461
458
// //////////////////////////////////////////
@@ -629,9 +626,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
629
626
next_filament_display = millis () + 5000UL ; // Show status message for 5s
630
627
#endif
631
628
goto_screen (menu_main);
632
- #if DISABLED(NO_LCD_REINIT)
633
- init_lcd (); // May revive the LCD if static electricity killed it
634
- #endif
629
+ IF_DISABLED (NO_LCD_REINIT, init_lcd ()); // May revive the LCD if static electricity killed it
635
630
return ;
636
631
}
637
632
0 commit comments