Encapsulate common display code in a singleton (#12395)
* Encapsulate common LCD code in a singleton * Depend more UBL code on UBL_DEVEL_DEBUGGING - Since most users don't need the debugging on at all times, this helps reduce the default build size for UBL by over 2K, a little closer to fitting on 128K boards.
This commit is contained in:
@ -201,9 +201,9 @@ typedef struct SettingsDataStruct {
|
||||
//
|
||||
// ULTIPANEL
|
||||
//
|
||||
int16_t lcd_preheat_hotend_temp[2], // M145 S0 H
|
||||
lcd_preheat_bed_temp[2]; // M145 S0 B
|
||||
uint8_t lcd_preheat_fan_speed[2]; // M145 S0 F
|
||||
int16_t ui_preheat_hotend_temp[2], // M145 S0 H
|
||||
ui_preheat_bed_temp[2]; // M145 S0 B
|
||||
uint8_t ui_preheat_fan_speed[2]; // M145 S0 F
|
||||
|
||||
//
|
||||
// PIDTEMP
|
||||
@ -680,15 +680,19 @@ void MarlinSettings::postprocess() {
|
||||
{
|
||||
_FIELD_TEST(lcd_preheat_hotend_temp);
|
||||
|
||||
#if !HAS_LCD_MENU
|
||||
constexpr int16_t lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
|
||||
lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED };
|
||||
constexpr uint8_t lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
|
||||
#if HAS_LCD_MENU
|
||||
const int16_t (&ui_preheat_hotend_temp)[2] = ui.preheat_hotend_temp,
|
||||
(&ui_preheat_bed_temp)[2] = ui.preheat_bed_temp;
|
||||
const uint8_t (&ui_preheat_fan_speed)[2] = ui.preheat_fan_speed;
|
||||
#else
|
||||
constexpr int16_t ui_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
|
||||
ui_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED };
|
||||
constexpr uint8_t ui_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
|
||||
#endif
|
||||
|
||||
EEPROM_WRITE(lcd_preheat_hotend_temp);
|
||||
EEPROM_WRITE(lcd_preheat_bed_temp);
|
||||
EEPROM_WRITE(lcd_preheat_fan_speed);
|
||||
EEPROM_WRITE(ui_preheat_hotend_temp);
|
||||
EEPROM_WRITE(ui_preheat_bed_temp);
|
||||
EEPROM_WRITE(ui_preheat_fan_speed);
|
||||
}
|
||||
|
||||
//
|
||||
@ -717,6 +721,7 @@ void MarlinSettings::postprocess() {
|
||||
//
|
||||
{
|
||||
_FIELD_TEST(bedPID);
|
||||
|
||||
#if DISABLED(PIDTEMPBED)
|
||||
const PID_t bed_pid = { DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE };
|
||||
EEPROM_WRITE(bed_pid);
|
||||
@ -731,9 +736,13 @@ void MarlinSettings::postprocess() {
|
||||
{
|
||||
_FIELD_TEST(lcd_contrast);
|
||||
|
||||
#if !HAS_LCD_CONTRAST
|
||||
const int16_t lcd_contrast = 32;
|
||||
#endif
|
||||
const int16_t lcd_contrast =
|
||||
#if HAS_LCD_CONTRAST
|
||||
ui.contrast
|
||||
#else
|
||||
32
|
||||
#endif
|
||||
;
|
||||
EEPROM_WRITE(lcd_contrast);
|
||||
}
|
||||
|
||||
@ -1304,15 +1313,19 @@ void MarlinSettings::postprocess() {
|
||||
// LCD Preheat settings
|
||||
//
|
||||
{
|
||||
_FIELD_TEST(lcd_preheat_hotend_temp);
|
||||
_FIELD_TEST(ui_preheat_hotend_temp);
|
||||
|
||||
#if !HAS_LCD_MENU
|
||||
int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
|
||||
uint8_t lcd_preheat_fan_speed[2];
|
||||
#if HAS_LCD_MENU
|
||||
int16_t (&ui_preheat_hotend_temp)[2] = ui.preheat_hotend_temp,
|
||||
(&ui_preheat_bed_temp)[2] = ui.preheat_bed_temp;
|
||||
uint8_t (&ui_preheat_fan_speed)[2] = ui.preheat_fan_speed;
|
||||
#else
|
||||
int16_t ui_preheat_hotend_temp[2], ui_preheat_bed_temp[2];
|
||||
uint8_t ui_preheat_fan_speed[2];
|
||||
#endif
|
||||
EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
|
||||
EEPROM_READ(lcd_preheat_bed_temp); // 2 floats
|
||||
EEPROM_READ(lcd_preheat_fan_speed); // 2 floats
|
||||
EEPROM_READ(ui_preheat_hotend_temp); // 2 floats
|
||||
EEPROM_READ(ui_preheat_bed_temp); // 2 floats
|
||||
EEPROM_READ(ui_preheat_fan_speed); // 2 floats
|
||||
}
|
||||
|
||||
//
|
||||
@ -1366,10 +1379,12 @@ void MarlinSettings::postprocess() {
|
||||
//
|
||||
{
|
||||
_FIELD_TEST(lcd_contrast);
|
||||
#if !HAS_LCD_CONTRAST
|
||||
int16_t lcd_contrast;
|
||||
#endif
|
||||
|
||||
int16_t lcd_contrast;
|
||||
EEPROM_READ(lcd_contrast);
|
||||
#if HAS_LCD_CONTRAST
|
||||
ui.set_contrast(lcd_contrast);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
@ -2028,12 +2043,12 @@ void MarlinSettings::reset(PORTARG_SOLO) {
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
lcd_preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
|
||||
lcd_preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
|
||||
lcd_preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
|
||||
lcd_preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
|
||||
lcd_preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
|
||||
lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
|
||||
ui.preheat_hotend_temp[0] = PREHEAT_1_TEMP_HOTEND;
|
||||
ui.preheat_hotend_temp[1] = PREHEAT_2_TEMP_HOTEND;
|
||||
ui.preheat_bed_temp[0] = PREHEAT_1_TEMP_BED;
|
||||
ui.preheat_bed_temp[1] = PREHEAT_2_TEMP_BED;
|
||||
ui.preheat_fan_speed[0] = PREHEAT_1_FAN_SPEED;
|
||||
ui.preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
@ -2057,7 +2072,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_CONTRAST
|
||||
lcd_contrast = DEFAULT_LCD_CONTRAST;
|
||||
ui.set_contrast(DEFAULT_LCD_CONTRAST);
|
||||
#endif
|
||||
|
||||
#if ENABLED(FWRETRACT)
|
||||
@ -2561,12 +2576,12 @@ void MarlinSettings::reset(PORTARG_SOLO) {
|
||||
CONFIG_ECHO_START;
|
||||
SERIAL_ECHOLNPGM_P(port, "Material heatup parameters:");
|
||||
}
|
||||
for (uint8_t i = 0; i < COUNT(lcd_preheat_hotend_temp); i++) {
|
||||
for (uint8_t i = 0; i < COUNT(ui.preheat_hotend_temp); i++) {
|
||||
CONFIG_ECHO_START;
|
||||
SERIAL_ECHOPAIR_P(port, " M145 S", (int)i);
|
||||
SERIAL_ECHOPAIR_P(port, " H", TEMP_UNIT(lcd_preheat_hotend_temp[i]));
|
||||
SERIAL_ECHOPAIR_P(port, " B", TEMP_UNIT(lcd_preheat_bed_temp[i]));
|
||||
SERIAL_ECHOLNPAIR_P(port, " F", int(lcd_preheat_fan_speed[i]));
|
||||
SERIAL_ECHOPAIR_P(port, " H", TEMP_UNIT(ui.preheat_hotend_temp[i]));
|
||||
SERIAL_ECHOPAIR_P(port, " B", TEMP_UNIT(ui.preheat_bed_temp[i]));
|
||||
SERIAL_ECHOLNPAIR_P(port, " F", int(ui.preheat_fan_speed[i]));
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -2625,7 +2640,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
|
||||
SERIAL_ECHOLNPGM_P(port, "LCD Contrast:");
|
||||
}
|
||||
CONFIG_ECHO_START;
|
||||
SERIAL_ECHOLNPAIR_P(port, " M250 C", lcd_contrast);
|
||||
SERIAL_ECHOLNPAIR_P(port, " M250 C", ui.contrast);
|
||||
#endif
|
||||
|
||||
#if ENABLED(FWRETRACT)
|
||||
|
@ -337,7 +337,7 @@ void Endstops::event_handler() {
|
||||
SERIAL_EOL();
|
||||
|
||||
#if ENABLED(ULTRA_LCD)
|
||||
lcd_status_printf_P(0, PSTR(MSG_LCD_ENDSTOPS " %c %c %c %c"), chrX, chrY, chrZ, chrP);
|
||||
ui.status_printf_P(0, PSTR(MSG_LCD_ENDSTOPS " %c %c %c %c"), chrX, chrY, chrZ, chrP);
|
||||
#endif
|
||||
|
||||
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
|
||||
|
@ -1026,7 +1026,7 @@ void prepare_move_to_destination() {
|
||||
SERIAL_ECHOLNPGM(" " MSG_FIRST);
|
||||
|
||||
#if ENABLED(ULTRA_LCD)
|
||||
lcd_status_printf_P(0, PSTR(MSG_HOME " %s%s%s " MSG_FIRST), xx ? MSG_X : "", yy ? MSG_Y : "", zz ? MSG_Z : "");
|
||||
ui.status_printf_P(0, PSTR(MSG_HOME " %s%s%s " MSG_FIRST), xx ? MSG_X : "", yy ? MSG_Y : "", zz ? MSG_Z : "");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@ -1121,7 +1121,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
|
||||
serialprintPGM(msg_wait_for_bed_heating);
|
||||
LCD_MESSAGEPGM(MSG_BED_HEATING);
|
||||
while (thermalManager.isHeatingBed()) safe_delay(200);
|
||||
lcd_reset_status();
|
||||
ui.reset_status();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -370,15 +370,15 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
|
||||
BUZZ(100, 698);
|
||||
|
||||
PGM_P const ds_str = deploy ? PSTR(MSG_MANUAL_DEPLOY) : PSTR(MSG_MANUAL_STOW);
|
||||
lcd_return_to_status(); // To display the new status message
|
||||
lcd_setstatusPGM(ds_str, 99);
|
||||
ui.return_to_status(); // To display the new status message
|
||||
ui.setstatusPGM(ds_str, 99);
|
||||
serialprintPGM(ds_str);
|
||||
SERIAL_EOL();
|
||||
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
wait_for_user = true;
|
||||
while (wait_for_user) idle();
|
||||
lcd_reset_status();
|
||||
ui.reset_status();
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
|
||||
#endif // PAUSE_BEFORE_DEPLOY_STOW
|
||||
@ -527,7 +527,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
|
||||
serialprintPGM(msg_wait_for_bed_heating);
|
||||
LCD_MESSAGEPGM(MSG_BED_HEATING);
|
||||
while (thermalManager.isHeatingBed()) safe_delay(200);
|
||||
lcd_reset_status();
|
||||
ui.reset_status();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -498,7 +498,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
|
||||
|
||||
return;
|
||||
}
|
||||
lcd_update();
|
||||
ui.update();
|
||||
}
|
||||
disable_all_heaters();
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
@ -2123,7 +2123,7 @@ void Temperature::isr() {
|
||||
// Update lcd buttons 488 times per second
|
||||
//
|
||||
static bool do_buttons;
|
||||
if ((do_buttons ^= true)) lcd_buttons_update();
|
||||
if ((do_buttons ^= true)) ui.update_buttons();
|
||||
|
||||
/**
|
||||
* One sensor is sampled on every other call of the ISR.
|
||||
@ -2425,9 +2425,9 @@ void Temperature::isr() {
|
||||
void Temperature::set_heating_message(const uint8_t e) {
|
||||
const bool heating = isHeatingHotend(e);
|
||||
#if HOTENDS > 1
|
||||
lcd_status_printf_P(0, heating ? PSTR("E%i " MSG_HEATING) : PSTR("E%i " MSG_COOLING), int(e + 1));
|
||||
ui.status_printf_P(0, heating ? PSTR("E%i " MSG_HEATING) : PSTR("E%i " MSG_COOLING), int(e + 1));
|
||||
#else
|
||||
lcd_setstatusPGM(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
|
||||
ui.setstatusPGM(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -2530,16 +2530,16 @@ void Temperature::isr() {
|
||||
}
|
||||
|
||||
#if G26_CLICK_CAN_CANCEL
|
||||
if (click_to_cancel && use_click()) {
|
||||
if (click_to_cancel && ui.use_click()) {
|
||||
wait_for_heatup = false;
|
||||
lcd_quick_feedback();
|
||||
ui.quick_feedback();
|
||||
}
|
||||
#endif
|
||||
|
||||
} while (wait_for_heatup && TEMP_CONDITIONS);
|
||||
|
||||
if (wait_for_heatup) {
|
||||
lcd_reset_status();
|
||||
ui.reset_status();
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
printerEventLEDs.onHeatingDone();
|
||||
#endif
|
||||
@ -2655,15 +2655,15 @@ void Temperature::isr() {
|
||||
}
|
||||
|
||||
#if G26_CLICK_CAN_CANCEL
|
||||
if (click_to_cancel && use_click()) {
|
||||
if (click_to_cancel && ui.use_click()) {
|
||||
wait_for_heatup = false;
|
||||
lcd_quick_feedback();
|
||||
ui.quick_feedback();
|
||||
}
|
||||
#endif
|
||||
|
||||
} while (wait_for_heatup && TEMP_BED_CONDITIONS);
|
||||
|
||||
if (wait_for_heatup) lcd_reset_status();
|
||||
if (wait_for_heatup) ui.reset_status();
|
||||
|
||||
#if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE)
|
||||
gcode.busy_state = old_busy_state;
|
||||
|
@ -540,7 +540,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
||||
}
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
lcd_return_to_status();
|
||||
ui.return_to_status();
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
||||
|
Reference in New Issue
Block a user