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:
Scott Lahteine
2018-11-11 12:16:24 -06:00
committed by GitHub
parent 9da6809ac3
commit a0c795b097
65 changed files with 1881 additions and 1997 deletions

View File

@ -163,12 +163,12 @@ int8_t g26_prime_flag;
* If the LCD is clicked, cancel, wait for release, return true
*/
bool user_canceled() {
if (!is_lcd_clicked()) return false; // Return if the button isn't pressed
lcd_setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
if (!ui.button_pressed()) return false; // Return if the button isn't pressed
ui.setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
#if HAS_LCD_MENU
lcd_quick_feedback();
ui.quick_feedback();
#endif
wait_for_release();
ui.wait_for_release();
return true;
}
@ -414,10 +414,10 @@ inline bool turn_on_heaters() {
if (g26_bed_temp > 25) {
#if ENABLED(ULTRA_LCD)
lcd_setstatusPGM(PSTR("G26 Heating Bed."), 99);
lcd_quick_feedback();
ui.setstatusPGM(PSTR("G26 Heating Bed."), 99);
ui.quick_feedback();
#if HAS_LCD_MENU
lcd_external_control = true;
ui.capture();
#endif
#endif
thermalManager.setTargetBed(g26_bed_temp);
@ -435,8 +435,8 @@ inline bool turn_on_heaters() {
// Start heating the active nozzle
#if ENABLED(ULTRA_LCD)
lcd_setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
lcd_quick_feedback();
ui.setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
ui.quick_feedback();
#endif
thermalManager.setTargetHotend(g26_hotend_temp, active_extruder);
@ -449,8 +449,8 @@ inline bool turn_on_heaters() {
) return G26_ERR;
#if ENABLED(ULTRA_LCD)
lcd_reset_status();
lcd_quick_feedback();
ui.reset_status();
ui.quick_feedback();
#endif
return G26_OK;
@ -468,16 +468,16 @@ inline bool prime_nozzle() {
if (g26_prime_flag == -1) { // The user wants to control how much filament gets purged
lcd_external_control = true;
lcd_setstatusPGM(PSTR("User-Controlled Prime"), 99);
lcd_chirp();
ui.capture();
ui.setstatusPGM(PSTR("User-Controlled Prime"), 99);
ui.chirp();
set_destination_from_current();
recover_filament(destination); // Make sure G26 doesn't think the filament is retracted().
while (!is_lcd_clicked()) {
lcd_chirp();
while (!ui.button_pressed()) {
ui.chirp();
destination[E_AXIS] += 0.25;
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
Total_Prime += 0.25;
@ -491,18 +491,18 @@ inline bool prime_nozzle() {
// action to give the user a more responsive 'Stop'.
}
wait_for_release();
ui.wait_for_release();
lcd_setstatusPGM(PSTR("Done Priming"), 99);
lcd_quick_feedback();
lcd_external_control = false;
ui.setstatusPGM(PSTR("Done Priming"), 99);
ui.quick_feedback();
ui.release();
}
else
#endif
{
#if ENABLED(ULTRA_LCD)
lcd_setstatusPGM(PSTR("Fixed Length Prime."), 99);
lcd_quick_feedback();
ui.setstatusPGM(PSTR("Fixed Length Prime."), 99);
ui.quick_feedback();
#endif
set_destination_from_current();
destination[E_AXIS] += g26_prime_length;
@ -715,7 +715,7 @@ void GcodeSuite::G26() {
move_to(destination, g26_ooze_amount);
#if HAS_LCD_MENU
lcd_external_control = true;
ui.capture();
#endif
//debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern."));
@ -881,8 +881,7 @@ void GcodeSuite::G26() {
} while (--g26_repeats && location.x_index >= 0 && location.y_index >= 0);
LEAVE:
lcd_setstatusPGM(PSTR("Leaving G26"), -1);
wait_for_release();
ui.setstatusPGM(PSTR("Leaving G26"), -1);
retract_filament(destination);
destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;
@ -891,15 +890,15 @@ void GcodeSuite::G26() {
move_to(destination, 0); // Raise the nozzle
//debug_current_and_destination(PSTR("done doing Z-Raise."));
destination[X_AXIS] = g26_x_pos; // Move back to the starting position
destination[X_AXIS] = g26_x_pos; // Move back to the starting position
destination[Y_AXIS] = g26_y_pos;
//destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
//destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
move_to(destination, 0); // Move back to the starting position
move_to(destination, 0); // Move back to the starting position
//debug_current_and_destination(PSTR("done doing X/Y move."));
#if HAS_LCD_MENU
lcd_external_control = false; // Give back control of the LCD Panel!
ui.release(); // Give back control of the LCD
#endif
if (!g26_keep_heaters_on) {

View File

@ -498,7 +498,7 @@ G29_TYPE GcodeSuite::G29() {
set_bed_leveling_enabled(abl_should_enable);
g29_in_progress = false;
#if ENABLED(LCD_BED_LEVELING)
lcd_wait_for_move = false;
ui.wait_for_bl_move = false;
#endif
}
@ -790,7 +790,7 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(PROBE_MANUALLY)
g29_in_progress = false;
#if ENABLED(LCD_BED_LEVELING)
lcd_wait_for_move = false;
ui.wait_for_bl_move = false;
#endif
#endif

View File

@ -90,7 +90,7 @@ void GcodeSuite::G29() {
case MeshStart:
mbl.reset();
mbl_probe_index = 0;
if (!lcd_wait_for_move) {
if (!ui.wait_for_bl_move) {
enqueue_and_echo_commands_P(PSTR("G28\nG29 S2"));
return;
}
@ -151,7 +151,7 @@ void GcodeSuite::G29() {
#endif
#if ENABLED(LCD_BED_LEVELING)
lcd_wait_for_move = false;
ui.wait_for_bl_move = false;
#endif
}
break;

View File

@ -425,7 +425,7 @@ void GcodeSuite::G28(const bool always_home_all) {
tool_change(old_tool_index, 0, NO_FETCH);
#endif
lcd_refresh();
ui.refresh();
report_current_position();
#if ENABLED(NANODLP_Z_SYNC)

View File

@ -522,7 +522,7 @@ void GcodeSuite::G33() {
if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
if (set_up) SERIAL_PROTOCOLPGM(" (SET-UP)");
SERIAL_EOL();
lcd_setstatusPGM(checkingac);
ui.setstatusPGM(checkingac);
print_calibration_settings(_endstop_results, _angle_results);
@ -683,7 +683,7 @@ void GcodeSuite::G33() {
sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev_min * 1000.0));
else
sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min));
lcd_setstatus(mess);
ui.setstatus(mess);
print_calibration_settings(_endstop_results, _angle_results);
serialprintPGM(save_message);
SERIAL_EOL();
@ -699,7 +699,7 @@ void GcodeSuite::G33() {
SERIAL_PROTOCOLPGM("std dev:");
SERIAL_PROTOCOL_F(zero_std_dev, 3);
SERIAL_EOL();
lcd_setstatus(mess);
ui.setstatus(mess);
if (verbose_level > 1)
print_calibration_settings(_endstop_results, _angle_results);
}
@ -719,7 +719,7 @@ void GcodeSuite::G33() {
sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0));
else
sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev));
lcd_setstatus(mess);
ui.setstatus(mess);
}
ac_home();
}

View File

@ -63,7 +63,7 @@ void GcodeSuite::M18_M84() {
#if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
if (ubl.lcd_map_control) {
ubl.lcd_map_control = false;
set_defer_return_to_status(false);
ui.defer_status_screen(false);
}
#endif
}

View File

@ -83,7 +83,7 @@
#endif
#if HAS_LCD_MENU
lcd_reset_status();
ui.reset_status();
#endif
}

View File

@ -38,7 +38,7 @@
*/
void GcodeSuite::M999() {
Running = true;
lcd_reset_alert_level();
ui.reset_alert_level();
if (parser.boolval('S')) return;

View File

@ -62,11 +62,11 @@ void GcodeSuite::M0_M1() {
#if HAS_LCD_MENU
if (has_message)
lcd_setstatus(args, true);
ui.setstatus(args, true);
else {
LCD_MESSAGEPGM(MSG_USERWAIT);
#if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
dontExpireStatus();
ui.reset_progress_bar_timeout();
#endif
}
@ -94,7 +94,7 @@ void GcodeSuite::M0_M1() {
#endif
#if HAS_LCD_MENU
lcd_reset_status();
ui.reset_status();
#endif
wait_for_user = false;

View File

@ -28,6 +28,6 @@
*/
void GcodeSuite::M117() {
lcd_setstatus(parser.string_arg);
ui.setstatus(parser.string_arg);
}

View File

@ -37,7 +37,7 @@
*/
void GcodeSuite::M145() {
const uint8_t material = (uint8_t)parser.intval('S');
if (material >= COUNT(lcd_preheat_hotend_temp)) {
if (material >= COUNT(ui.preheat_hotend_temp)) {
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
}
@ -45,16 +45,16 @@ void GcodeSuite::M145() {
int v;
if (parser.seenval('H')) {
v = parser.value_int();
lcd_preheat_hotend_temp[material] = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
ui.preheat_hotend_temp[material] = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
}
if (parser.seenval('F')) {
v = parser.value_int();
lcd_preheat_fan_speed[material] = (uint8_t)constrain(v, 0, 255);
ui.preheat_fan_speed[material] = (uint8_t)constrain(v, 0, 255);
}
#if TEMP_SENSOR_BED != 0
if (parser.seenval('B')) {
v = parser.value_int();
lcd_preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
ui.preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
}
#endif
}

View File

@ -31,10 +31,8 @@
* M250: Read and optionally set the LCD contrast
*/
void GcodeSuite::M250() {
if (parser.seen('C')) set_lcd_contrast(parser.value_int());
SERIAL_PROTOCOLPGM("lcd contrast value: ");
SERIAL_PROTOCOL(lcd_contrast);
SERIAL_EOL();
if (parser.seen('C')) ui.set_contrast(parser.value_int());
SERIAL_PROTOCOLLNPAIR("LCD Contrast: ", ui.contrast);
}
#endif // HAS_LCD_CONTRAST

View File

@ -38,10 +38,8 @@
* This has no effect during an SD print job
*/
void GcodeSuite::M73() {
if (!IS_SD_PRINTING() && parser.seen('P')) {
progress_bar_percent = parser.value_byte();
NOMORE(progress_bar_percent, 100);
}
if (parser.seen('P') && !IS_SD_PRINTING())
ui.set_progress(parser.value_byte());
}
#endif // ULTRA_LCD && LCD_SET_PROGRESS_MANUALLY

View File

@ -38,7 +38,7 @@ void GcodeSuite::G4() {
SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
#endif
if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
if (!ui.hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
dwell(dwell_ms);
}

View File

@ -40,7 +40,7 @@ void GcodeSuite::M31() {
char buffer[21];
duration_t elapsed = print_job_timer.duration();
elapsed.toString(buffer);
lcd_setstatus(buffer);
ui.setstatus(buffer);
SERIAL_ECHO_START_P(port);
SERIAL_ECHOLNPAIR_P(port, "Print time: ", buffer);

View File

@ -66,7 +66,7 @@ void GcodeSuite::M104() {
*/
if (temp <= (EXTRUDE_MINTEMP) / 2) {
print_job_timer.stop();
lcd_reset_status();
ui.reset_status();
}
#endif
}
@ -108,7 +108,7 @@ void GcodeSuite::M109() {
*/
if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
print_job_timer.stop();
lcd_reset_status();
ui.reset_status();
}
else
print_job_timer.start();

View File

@ -64,7 +64,7 @@ void GcodeSuite::M190() {
}
else return;
lcd_setstatusPGM(thermalManager.isHeatingBed() ? PSTR(MSG_BED_HEATING) : PSTR(MSG_BED_COOLING));
ui.setstatusPGM(thermalManager.isHeatingBed() ? PSTR(MSG_BED_HEATING) : PSTR(MSG_BED_COOLING));
thermalManager.wait_for_bed(no_wait_for_cooling);
}