♻️ Adjust LCD init, contrast default, settings load

This commit is contained in:
Scott Lahteine
2022-01-22 10:14:47 -06:00
parent 37ee9a47ab
commit d5f2334140
19 changed files with 137 additions and 154 deletions

View File

@@ -43,7 +43,6 @@ MarlinUI ui;
#if HAS_DISPLAY
#include "../gcode/queue.h"
#include "fontutils.h"
#include "../sd/cardreader.h"
#endif
#if ENABLED(DWIN_CREALITY_LCD)
@@ -176,6 +175,77 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
#endif
// Encoder Handling
#if HAS_ENCODER_ACTION
uint32_t MarlinUI::encoderPosition;
volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
#endif
void MarlinUI::init() {
init_lcd();
#if HAS_DIGITAL_BUTTONS
#if BUTTON_EXISTS(EN1)
SET_INPUT_PULLUP(BTN_EN1);
#endif
#if BUTTON_EXISTS(EN2)
SET_INPUT_PULLUP(BTN_EN2);
#endif
#if BUTTON_EXISTS(ENC)
SET_INPUT_PULLUP(BTN_ENC);
#endif
#if BUTTON_EXISTS(ENC_EN)
SET_INPUT_PULLUP(BTN_ENC_EN);
#endif
#if BUTTON_EXISTS(BACK)
SET_INPUT_PULLUP(BTN_BACK);
#endif
#if BUTTON_EXISTS(UP)
SET_INPUT(BTN_UP);
#endif
#if BUTTON_EXISTS(DWN)
SET_INPUT(BTN_DWN);
#endif
#if BUTTON_EXISTS(LFT)
SET_INPUT(BTN_LFT);
#endif
#if BUTTON_EXISTS(RT)
SET_INPUT(BTN_RT);
#endif
#endif
#if HAS_SHIFT_ENCODER
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
SET_OUTPUT(SR_DATA_PIN);
SET_OUTPUT(SR_CLK_PIN);
#elif PIN_EXISTS(SHIFT_CLK)
SET_OUTPUT(SHIFT_CLK_PIN);
OUT_WRITE(SHIFT_LD_PIN, HIGH);
#if PIN_EXISTS(SHIFT_EN)
OUT_WRITE(SHIFT_EN_PIN, LOW);
#endif
SET_INPUT_PULLUP(SHIFT_OUT_PIN);
#endif
#endif // HAS_SHIFT_ENCODER
#if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS)
slow_buttons = 0;
#endif
update_buttons();
TERN_(HAS_ENCODER_ACTION, encoderDiff = 0);
reset_status(); // Set welcome message
}
#if HAS_WIRED_LCD
#if HAS_MARLINUI_U8GLIB
@@ -184,8 +254,6 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
#include "lcdprint.h"
#include "../sd/cardreader.h"
#include "../module/temperature.h"
#include "../module/planner.h"
#include "../module/motion.h"
@@ -247,16 +315,8 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
bool MarlinUI::old_is_printing;
#endif
// Encoder Handling
#if HAS_ENCODER_ACTION
uint32_t MarlinUI::encoderPosition;
volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
#endif
#if ENABLED(SDSUPPORT)
#include "../sd/cardreader.h"
#if MARLINUI_SCROLL_NAME
uint8_t MarlinUI::filename_scroll_pos, MarlinUI::filename_scroll_max;
#endif
@@ -393,69 +453,6 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
#endif // HAS_LCD_MENU
void MarlinUI::init() {
init_lcd();
#if HAS_DIGITAL_BUTTONS
#if BUTTON_EXISTS(EN1)
SET_INPUT_PULLUP(BTN_EN1);
#endif
#if BUTTON_EXISTS(EN2)
SET_INPUT_PULLUP(BTN_EN2);
#endif
#if BUTTON_EXISTS(ENC)
SET_INPUT_PULLUP(BTN_ENC);
#endif
#if BUTTON_EXISTS(ENC_EN)
SET_INPUT_PULLUP(BTN_ENC_EN);
#endif
#if BUTTON_EXISTS(BACK)
SET_INPUT_PULLUP(BTN_BACK);
#endif
#if BUTTON_EXISTS(UP)
SET_INPUT(BTN_UP);
#endif
#if BUTTON_EXISTS(DWN)
SET_INPUT(BTN_DWN);
#endif
#if BUTTON_EXISTS(LFT)
SET_INPUT(BTN_LFT);
#endif
#if BUTTON_EXISTS(RT)
SET_INPUT(BTN_RT);
#endif
#endif
#if HAS_SHIFT_ENCODER
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
SET_OUTPUT(SR_DATA_PIN);
SET_OUTPUT(SR_CLK_PIN);
#elif PIN_EXISTS(SHIFT_CLK)
SET_OUTPUT(SHIFT_CLK_PIN);
OUT_WRITE(SHIFT_LD_PIN, HIGH);
#if PIN_EXISTS(SHIFT_EN)
OUT_WRITE(SHIFT_EN_PIN, LOW);
#endif
SET_INPUT_PULLUP(SHIFT_OUT_PIN);
#endif
#endif // HAS_SHIFT_ENCODER
#if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS)
slow_buttons = 0;
#endif
update_buttons();
TERN_(HAS_ENCODER_ACTION, encoderDiff = 0);
}
////////////////////////////////////////////
///////////// Keypad Handling //////////////
////////////////////////////////////////////
@@ -629,9 +626,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
next_filament_display = millis() + 5000UL; // Show status message for 5s
#endif
goto_screen(menu_main);
#if DISABLED(NO_LCD_REINIT)
init_lcd(); // May revive the LCD if static electricity killed it
#endif
IF_DISABLED(NO_LCD_REINIT, init_lcd()); // May revive the LCD if static electricity killed it
return;
}