Browse Source

♻️ Adjust LCD init, contrast default, settings load

FB4S_WIFI
Scott Lahteine 2 years ago
parent
commit
99f3b8b4a8
  1. 2
      Marlin/src/HAL/LPC1768/inc/SanityCheck.h
  2. 24
      Marlin/src/MarlinCore.cpp
  3. 2
      Marlin/src/gcode/lcd/M250.cpp
  4. 2
      Marlin/src/inc/Conditionals_LCD.h
  5. 11
      Marlin/src/inc/Conditionals_post.h
  6. 4
      Marlin/src/inc/Warnings.cpp
  7. 3
      Marlin/src/lcd/e3v2/creality/dwin.cpp
  8. 3
      Marlin/src/lcd/e3v2/enhanced/dwin.cpp
  9. 2
      Marlin/src/lcd/e3v2/jyersui/dwin.cpp
  10. 4
      Marlin/src/lcd/e3v2/marlinui/ui_common.cpp
  11. 2
      Marlin/src/lcd/extui/ui_api.cpp
  12. 149
      Marlin/src/lcd/marlinui.cpp
  13. 29
      Marlin/src/lcd/marlinui.h
  14. 2
      Marlin/src/lcd/menu/menu_configuration.cpp
  15. 44
      Marlin/src/module/settings.cpp
  16. 2
      Marlin/src/pins/mega/pins_GT2560_REV_A.h
  17. 2
      Marlin/src/pins/mega/pins_HJC2560C_REV2.h
  18. 2
      Marlin/src/pins/ramps/pins_K8800.h
  19. 2
      Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h

2
Marlin/src/HAL/LPC1768/inc/SanityCheck.h

@ -113,7 +113,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#define _IS_RX1_1 IS_RX1
#if IS_TX1(TMC_SW_SCK)
#error "Serial port pins (1) conflict with other pins!"
#elif HAS_WIRED_LCD
#elif HAS_ROTARY_ENCODER
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
#error "Serial port pins (1) conflict with Encoder Buttons!"
#elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK_PIN) \

24
Marlin/src/MarlinCore.cpp

@ -1294,16 +1294,7 @@ void setup() {
// UI must be initialized before EEPROM
// (because EEPROM code calls the UI).
#if HAS_DWIN_E3V2_BASIC
SETUP_RUN(DWIN_Startup());
#else
SETUP_RUN(ui.init());
#if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN)
SETUP_RUN(ui.show_bootscreen());
const millis_t bootscreen_ms = millis();
#endif
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
#endif
SETUP_RUN(ui.init());
#if PIN_EXISTS(SAFE_POWER)
#if HAS_DRIVER_SAFE_POWER_PROTECT
@ -1314,10 +1305,6 @@ void setup() {
#endif
#endif
#if ENABLED(PROBE_TARE)
SETUP_RUN(probe.tare_init());
#endif
#if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION)
SETUP_RUN(card.mount()); // Mount media with settings before first_load
#endif
@ -1325,6 +1312,15 @@ void setup() {
SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults)
// This also updates variables in the planner, elsewhere
#if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN)
SETUP_RUN(ui.show_bootscreen());
const millis_t bootscreen_ms = millis();
#endif
#if ENABLED(PROBE_TARE)
SETUP_RUN(probe.tare_init());
#endif
#if HAS_ETHERNET
SETUP_RUN(ethernet.init());
#endif

2
Marlin/src/gcode/lcd/M250.cpp

@ -31,7 +31,7 @@
* M250: Read and optionally set the LCD contrast
*/
void GcodeSuite::M250() {
if (parser.seenval('C'))
if (LCD_CONTRAST_MIN < LCD_CONTRAST_MAX && parser.seenval('C'))
ui.set_contrast(parser.value_byte());
else
M250_report();

2
Marlin/src/inc/Conditionals_LCD.h

@ -237,7 +237,7 @@
#define LCD_HEIGHT 10 // Character lines
#define LCD_CONTRAST_MIN 127
#define LCD_CONTRAST_MAX 255
#define DEFAULT_LCD_CONTRAST 250
#define LCD_CONTRAST_DEFAULT 250
#define CONVERT_TO_EXT_ASCII // Use extended 128-255 symbols from ASCII table.
// At this time present conversion only for cyrillic - bg, ru and uk languages.
// First 7 ASCII symbols in panel font must be replaced with Marlin's special symbols.

11
Marlin/src/inc/Conditionals_post.h

@ -376,7 +376,6 @@
#elif EITHER(MKS_MINI_12864_V3, BTT_MINI_12864_V1)
#define _LCD_CONTRAST_MIN 255
#define _LCD_CONTRAST_INIT 255
#define _LCD_CONTRAST_MAX 255
#elif ENABLED(FYSETC_MINI_12864)
#define _LCD_CONTRAST_INIT 220
#elif ENABLED(ULTI_CONTROLLER)
@ -389,18 +388,12 @@
#elif ENABLED(ZONESTAR_12864OLED)
#define _LCD_CONTRAST_MIN 64
#define _LCD_CONTRAST_INIT 128
#define _LCD_CONTRAST_MAX 255
#elif IS_TFTGLCD_PANEL
#define _LCD_CONTRAST_MIN 0
#define _LCD_CONTRAST_INIT 250
#define _LCD_CONTRAST_MAX 255
#endif
#ifdef _LCD_CONTRAST_INIT
#define HAS_LCD_CONTRAST 1
#endif
#if HAS_LCD_CONTRAST
#ifndef LCD_CONTRAST_MIN
#ifdef _LCD_CONTRAST_MIN
#define LCD_CONTRAST_MIN _LCD_CONTRAST_MIN
@ -420,8 +413,8 @@
#define LCD_CONTRAST_MAX 63 // ST7567 6-bits contrast
#endif
#endif
#ifndef DEFAULT_LCD_CONTRAST
#define DEFAULT_LCD_CONTRAST LCD_CONTRAST_INIT
#ifndef LCD_CONTRAST_DEFAULT
#define LCD_CONTRAST_DEFAULT LCD_CONTRAST_INIT
#endif
#endif

4
Marlin/src/inc/Warnings.cpp

@ -559,3 +559,7 @@
#if CANNOT_EMBED_CONFIGURATION
#warning "Disabled CONFIGURATION_EMBEDDING because the target usually has less flash storage. Define FORCE_CONFIG_EMBED to override."
#endif
#if HAS_LCD_CONTRAST && LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX
#warning "Contrast cannot be changed when LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX."
#endif

3
Marlin/src/lcd/e3v2/creality/dwin.cpp

@ -1834,6 +1834,9 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT)
void HMI_SDCardInit() { card.cdroot(); }
// Initialize or re-initialize the LCD
void MarlinUI::init_lcd() { DWIN_Startup(); }
void MarlinUI::refresh() { /* Nothing to see here */ }
#if HAS_LCD_BRIGHTNESS

3
Marlin/src/lcd/e3v2/enhanced/dwin.cpp

@ -888,6 +888,9 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT)
void HMI_SDCardInit() { card.cdroot(); }
// Initialize or re-initialize the LCD
void MarlinUI::init_lcd() { DWIN_Startup(); }
void MarlinUI::refresh() { /* Nothing to see here */ }
#if HAS_LCD_BRIGHTNESS

2
Marlin/src/lcd/e3v2/jyersui/dwin.cpp

@ -4980,7 +4980,7 @@ void CrealityDWINClass::Reset_Settings() {
Redraw_Screen();
}
void MarlinUI::init() {
void MarlinUI::init_lcd() {
delay(800);
SERIAL_ECHOPGM("\nDWIN handshake ");
if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error.");

4
Marlin/src/lcd/e3v2/marlinui/ui_common.cpp

@ -79,9 +79,7 @@ void MarlinUI::set_font(const uint8_t font_nr) {
bool MarlinUI::detected() { return true; }
// Initialize or re-initialize the LCD
void MarlinUI::init_lcd() {
DWIN_Startup();
}
void MarlinUI::init_lcd() { DWIN_Startup(); }
// This LCD should clear where it will draw anew
void MarlinUI::clear_lcd() {

2
Marlin/src/lcd/extui/ui_api.cpp

@ -1144,7 +1144,7 @@ namespace ExtUI {
// At the moment we hook into MarlinUI methods, but this could be cleaned up in the future
void MarlinUI::init() { ExtUI::onStartup(); }
void MarlinUI::init_lcd() { ExtUI::onStartup(); }
void MarlinUI::update() { ExtUI::onIdle(); }

149
Marlin/src/lcd/marlinui.cpp

@ -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;
}

29
Marlin/src/lcd/marlinui.h

@ -21,6 +21,7 @@
*/
#pragma once
#include "../sd/cardreader.h"
#include "../module/motion.h"
#include "buttons.h"
@ -30,10 +31,6 @@
#include "../libs/buzzer.h"
#endif
#if ENABLED(SDSUPPORT)
#include "../sd/cardreader.h"
#endif
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
#include "tft_io/touch_calibration.h"
#endif
@ -204,6 +201,20 @@ public:
TERN_(HAS_LCD_MENU, currentScreen = status_screen);
}
static void init();
#if HAS_DISPLAY || HAS_DWIN_E3V2
static void init_lcd();
#else
static void init_lcd() {}
#endif
#if HAS_WIRED_LCD
static bool detected();
#else
static bool detected() { return true; }
#endif
#if HAS_MULTI_LANGUAGE
static uint8_t language;
static void set_language(const uint8_t lang);
@ -270,14 +281,6 @@ public:
}
#endif
#if HAS_WIRED_LCD
static bool detected();
static void init_lcd();
#else
static bool detected() { return true; }
static void init_lcd() {}
#endif
#if HAS_PRINT_PROGRESS
#if HAS_PRINT_PROGRESS_PERMYRIAD
typedef uint16_t progress_t;
@ -365,7 +368,6 @@ public:
#if HAS_DISPLAY
static void init();
static void update();
static void abort_print();
@ -480,7 +482,6 @@ public:
#else // No LCD
static void init() {}
static void update() {}
static void return_to_status() {}

2
Marlin/src/lcd/menu/menu_configuration.cpp

@ -538,7 +538,7 @@ void menu_configuration() {
#if HAS_LCD_BRIGHTNESS
EDIT_ITEM_FAST(uint8, MSG_BRIGHTNESS, &ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.refresh_brightness, true);
#endif
#if HAS_LCD_CONTRAST
#if HAS_LCD_CONTRAST && LCD_CONTRAST_MIN < LCD_CONTRAST_MAX
EDIT_ITEM_FAST(uint8, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
#endif
#if ENABLED(FWRETRACT)

44
Marlin/src/module/settings.cpp

@ -1965,8 +1965,10 @@ void MarlinSettings::postprocess() {
//
#if HAS_USER_THERMISTORS
{
user_thermistor_t user_thermistor[USER_THERMISTORS];
_FIELD_TEST(user_thermistor);
EEPROM_READ(thermalManager.user_thermistor);
EEPROM_READ(user_thermistor);
if (!validating) COPY(thermalManager.user_thermistor, user_thermistor);
}
#endif
@ -1974,13 +1976,10 @@ void MarlinSettings::postprocess() {
// Power monitor
//
{
#if HAS_POWER_MONITOR
uint8_t &power_monitor_flags = power_monitor.flags;
#else
uint8_t power_monitor_flags;
#endif
uint8_t power_monitor_flags;
_FIELD_TEST(power_monitor_flags);
EEPROM_READ(power_monitor_flags);
TERN_(HAS_POWER_MONITOR, if (!validating) power_monitor.flags = power_monitor_flags);
}
//
@ -1997,7 +1996,6 @@ void MarlinSettings::postprocess() {
// LCD Brightness
//
{
_FIELD_TEST(lcd_brightness);
uint8_t lcd_brightness;
EEPROM_READ(lcd_brightness);
TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.set_brightness(lcd_brightness));
@ -2007,45 +2005,37 @@ void MarlinSettings::postprocess() {
// Controller Fan
//
{
controllerFan_settings_t cfs = { 0 };
_FIELD_TEST(controllerFan_settings);
#if ENABLED(CONTROLLER_FAN_EDITABLE)
const controllerFan_settings_t &cfs = controllerFan.settings;
#else
controllerFan_settings_t cfs = { 0 };
#endif
EEPROM_READ(cfs);
TERN_(CONTROLLER_FAN_EDITABLE, if (!validating) controllerFan.settings = cfs);
}
//
// Power-Loss Recovery
//
{
bool recovery_enabled;
_FIELD_TEST(recovery_enabled);
#if ENABLED(POWER_LOSS_RECOVERY)
const bool &recovery_enabled = recovery.enabled;
#else
bool recovery_enabled;
#endif
EEPROM_READ(recovery_enabled);
TERN_(POWER_LOSS_RECOVERY, if (!validating) recovery.enabled = recovery_enabled);
}
//
// Firmware Retraction
//
{
fwretract_settings_t fwretract_settings;
bool autoretract_enabled;
_FIELD_TEST(fwretract_settings);
EEPROM_READ(fwretract_settings);
EEPROM_READ(autoretract_enabled);
#if ENABLED(FWRETRACT)
EEPROM_READ(fwretract.settings);
#else
fwretract_settings_t fwretract_settings;
EEPROM_READ(fwretract_settings);
#endif
#if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT)
EEPROM_READ(fwretract.autoretract_enabled);
#else
bool autoretract_enabled;
EEPROM_READ(autoretract_enabled);
if (!validating) {
fwretract.settings = fwretract_settings;
TERN_(FWRETRACT_AUTORETRACT, fwretract.autoretract_enabled = autoretract_enabled);
}
#endif
}

2
Marlin/src/pins/mega/pins_GT2560_REV_A.h

@ -127,7 +127,7 @@
#define LCD_RESET_PIN 16
#define DEFAULT_LCD_CONTRAST 220
#define LCD_CONTRAST_DEFAULT 220
#define LCD_BACKLIGHT_PIN -1
#else

2
Marlin/src/pins/mega/pins_HJC2560C_REV2.h

@ -134,7 +134,7 @@
#if ENABLED(HJC_LCD_SMART_CONTROLLER)
#define LCD_BACKLIGHT_PIN 5 // LCD_Backlight
//#ifndef LCD_CONTRAST_PIN
// #define LCD_CONTRAST_PIN 5 // LCD_Contrast
// #define LCD_CONTRAST_PIN 5 // LCD_Contrast
//#endif
#ifndef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN 24 // Filament runout

2
Marlin/src/pins/ramps/pins_K8800.h

@ -107,7 +107,7 @@
#define LCD_CONTRAST_MIN 0
#define LCD_CONTRAST_MAX 100
#define DEFAULT_LCD_CONTRAST 30
#define LCD_CONTRAST_DEFAULT 30
//#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270
#if IS_NEWPANEL

2
Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h

@ -157,7 +157,7 @@
#define NEOPIXEL_PIN PB9
#endif
#define DEFAULT_LCD_CONTRAST 255
#define LCD_CONTRAST_DEFAULT 255
#else
#define LCD_PINS_RS PC15
#define LCD_PINS_ENABLE PB6

Loading…
Cancel
Save