Skip to content

Commit

Permalink
🩹 Fix, clean up ProUI, JyersUI (#26078)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
classicrocker883 and thinkyhead authored Jul 16, 2023
1 parent 45f7ebb commit fc2272c
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 103 deletions.
117 changes: 58 additions & 59 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class TextScroller {

#if HAS_MESH

struct Mesh_Settings {
struct {
bool viewer_asymmetric_range = false;
bool viewer_print_value = false;
bool goto_mesh_value = false;
Expand Down Expand Up @@ -436,8 +436,7 @@ class TextScroller {
drawing_mesh = false;
}

};
Mesh_Settings mesh_conf;
} mesh_conf;

#endif // HAS_MESH

Expand Down Expand Up @@ -817,14 +816,14 @@ void JyersDWIN::drawStatusArea(const bool icons/*=false*/) {
dwinIconShow(ICON, ICON_HotendTemp, 10, 383);
dwinDrawString(false, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
}
if (thermalManager.temp_hotend[0].celsius != hotend) {
hotend = thermalManager.temp_hotend[0].celsius;
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 28, 384, thermalManager.temp_hotend[0].celsius);
if (thermalManager.degHotend(0) != hotend) {
hotend = thermalManager.degHotend(0);
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 28, 384, hotend);
dwinDrawDegreeSymbol(getColor(eeprom_settings.status_area_text, COLOR_WHITE), 25 + 3 * STAT_CHR_W + 5, 386);
}
if (thermalManager.temp_hotend[0].target != hotendtarget) {
hotendtarget = thermalManager.temp_hotend[0].target;
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target);
if (thermalManager.wholeDegHotend(0) != hotendtarget) {
hotendtarget = thermalManager.degTargetHotend(0);
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 25 + 4 * STAT_CHR_W + 6, 384, hotendtarget);
dwinDrawDegreeSymbol(getColor(eeprom_settings.status_area_text, COLOR_WHITE), 25 + 4 * STAT_CHR_W + 39, 386);
}
if (icons) {
Expand All @@ -847,14 +846,14 @@ void JyersDWIN::drawStatusArea(const bool icons/*=false*/) {
dwinIconShow(ICON, ICON_BedTemp, 10, 416);
dwinDrawString(false, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
}
if (thermalManager.temp_bed.celsius != bed) {
bed = thermalManager.temp_bed.celsius;
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 28, 417, thermalManager.temp_bed.celsius);
if (thermalManager.degBed() != bed) {
bed = thermalManager.degBed();
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 28, 417, bed);
dwinDrawDegreeSymbol(getColor(eeprom_settings.status_area_text, COLOR_WHITE), 25 + 3 * STAT_CHR_W + 5, 419);
}
if (thermalManager.temp_bed.target != bedtarget) {
bedtarget = thermalManager.temp_bed.target;
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target);
if (thermalManager.degTargetBed() != bedtarget) {
bedtarget = thermalManager.degTargetBed();
dwinDrawIntValue(true, true, 0, DWIN_FONT_STAT, getColor(eeprom_settings.status_area_text, COLOR_WHITE), COLOR_BG_BLACK, 3, 25 + 4 * STAT_CHR_W + 6, 417, bedtarget);
dwinDrawDegreeSymbol(getColor(eeprom_settings.status_area_text, COLOR_WHITE), 25 + 4 * STAT_CHR_W + 39, 419);
}
#endif
Expand Down Expand Up @@ -1173,15 +1172,15 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
drawMenu(ID_ChangeFilament);
#else
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
if (thermalManager.targetTooColdToExtrude(0))
popupHandler(Popup_ETemp);
else {
if (thermalManager.temp_hotend[0].is_below_target(2)) {
popupHandler(Popup_Heating);
thermalManager.wait_for_hotend(0);
}
popupHandler(Popup_FilChange);
gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.temp_hotend[0].target));
gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0)));
}
#endif
}
Expand Down Expand Up @@ -1314,7 +1313,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawFloat(current_position.e, row);
}
else {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) {
if (thermalManager.targetTooColdToExtrude(0)) {
popupHandler(Popup_ETemp);
}
else {
Expand All @@ -1338,7 +1337,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, probe_deployed);
}
else {
probe_deployed = !probe_deployed;
probe_deployed ^= true;
probe.set_deployed(probe_deployed);
drawCheckbox(row, probe_deployed);
}
Expand All @@ -1351,7 +1350,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, livemove);
}
else {
livemove = !livemove;
livemove ^= true;
drawCheckbox(row, livemove);
}
break;
Expand Down Expand Up @@ -1612,7 +1611,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
planner.synchronize();
redrawMenu();
}
liveadjust = !liveadjust;
liveadjust ^= true;
drawCheckbox(row, liveadjust);
}
break;
Expand Down Expand Up @@ -1728,7 +1727,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
if (draw)
drawMenuItem(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENTLOAD));
else {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
if (thermalManager.targetTooColdToExtrude(0))
popupHandler(Popup_ETemp);
else {
if (thermalManager.temp_hotend[0].is_below_target(2)) {
Expand All @@ -1746,7 +1745,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
if (draw)
drawMenuItem(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENTUNLOAD));
else {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) {
if (thermalManager.targetTooColdToExtrude(0)) {
popupHandler(Popup_ETemp);
}
else {
Expand All @@ -1765,15 +1764,15 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
if (draw)
drawMenuItem(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE));
else {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
if (thermalManager.targetTooColdToExtrude(0))
popupHandler(Popup_ETemp);
else {
if (thermalManager.temp_hotend[0].is_below_target(2)) {
popupHandler(Popup_Heating);
thermalManager.wait_for_hotend(0);
}
popupHandler(Popup_FilChange);
gcode.process_subcommands_now(TS(F("M600B1R"), thermalManager.temp_hotend[0].target));
gcode.process_subcommands_now(TS(F("M600B1R"), thermalManager.degTargetHotend(0)));
}
}
break;
Expand Down Expand Up @@ -2002,7 +2001,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
case TEMP_HOTEND:
if (draw) {
drawMenuItem(row, ICON_SetEndTemp, F("Hotend"));
drawFloat(thermalManager.temp_hotend[0].target, row, false, 1);
drawFloat(thermalManager.degTargetHotend(0), row, false, 1);
}
else
modifyValue(thermalManager.temp_hotend[0].target, MIN_E_TEMP, MAX_E_TEMP, 1);
Expand All @@ -2012,7 +2011,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
case TEMP_BED:
if (draw) {
drawMenuItem(row, ICON_SetBedTemp, F("Bed"));
drawFloat(thermalManager.temp_bed.target, row, false, 1);
drawFloat(thermalManager.degTargetBed(), row, false, 1);
}
else
modifyValue(thermalManager.temp_bed.target, MIN_BED_TEMP, MAX_BED_TEMP, 1);
Expand Down Expand Up @@ -2690,7 +2689,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, eeprom_settings.time_format_textual);
}
else {
eeprom_settings.time_format_textual = !eeprom_settings.time_format_textual;
eeprom_settings.time_format_textual ^= true;
drawCheckbox(row, eeprom_settings.time_format_textual);
}
break;
Expand Down Expand Up @@ -2848,7 +2847,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, ui.sound_on);
}
else {
ui.sound_on = !ui.sound_on;
ui.sound_on ^= true;
drawCheckbox(row, ui.sound_on);
}
break;
Expand Down Expand Up @@ -2931,7 +2930,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, runout.enabled);
}
else {
runout.enabled = !runout.enabled;
runout.enabled ^= true;
drawCheckbox(row, runout.enabled);
}
break;
Expand Down Expand Up @@ -3378,7 +3377,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, mesh_conf.viewer_print_value);
}
else {
mesh_conf.viewer_print_value = !mesh_conf.viewer_print_value;
mesh_conf.viewer_print_value ^= true;
drawCheckbox(row, mesh_conf.viewer_print_value);
}
break;
Expand All @@ -3388,7 +3387,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, mesh_conf.viewer_asymmetric_range);
}
else {
mesh_conf.viewer_asymmetric_range = !mesh_conf.viewer_asymmetric_range;
mesh_conf.viewer_asymmetric_range ^= true;
drawCheckbox(row, mesh_conf.viewer_asymmetric_range);
}
break;
Expand Down Expand Up @@ -3571,7 +3570,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, mesh_conf.goto_mesh_value);
}
else {
mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value;
mesh_conf.goto_mesh_value ^= true;
current_position.z = 0;
mesh_conf.manual_mesh_move(true);
drawCheckbox(row, mesh_conf.goto_mesh_value);
Expand Down Expand Up @@ -3836,7 +3835,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
case TUNE_HOTEND:
if (draw) {
drawMenuItem(row, ICON_SetEndTemp, F("Hotend"));
drawFloat(thermalManager.temp_hotend[0].target, row, false, 1);
drawFloat(thermalManager.degTargetHotend(0), row, false, 1);
}
else
modifyValue(thermalManager.temp_hotend[0].target, MIN_E_TEMP, MAX_E_TEMP, 1);
Expand All @@ -3847,7 +3846,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
case TUNE_BED:
if (draw) {
drawMenuItem(row, ICON_SetBedTemp, F("Bed"));
drawFloat(thermalManager.temp_bed.target, row, false, 1);
drawFloat(thermalManager.degTargetBed(), row, false, 1);
}
else
modifyValue(thermalManager.temp_bed.target, MIN_BED_TEMP, MAX_BED_TEMP, 1);
Expand Down Expand Up @@ -3910,7 +3909,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
drawCheckbox(row, runout.enabled);
}
else {
runout.enabled = !runout.enabled;
runout.enabled ^= true;
drawCheckbox(row, runout.enabled);
}
break;
Expand Down Expand Up @@ -3966,7 +3965,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
switch (last_menu) {
case ID_Prepare:
popupHandler(Popup_FilChange);
gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.temp_hotend[0].target));
gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0)));
break;
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
case ID_ChangeFilament:
Expand All @@ -3985,7 +3984,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
break;
case CHANGEFIL_CHANGE:
popupHandler(Popup_FilChange);
gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.temp_hotend[0].target));
gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0)));
break;
}
break;
Expand All @@ -4009,7 +4008,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
case PREHEATHOTEND_CUSTOM:
if (draw) {
drawMenuItem(row, ICON_Temperature, F("Custom"));
drawFloat(thermalManager.temp_hotend[0].target, row, false, 1);
drawFloat(thermalManager.degTargetHotend(0), row, false, 1);
}
else
modifyValue(thermalManager.temp_hotend[0].target, EXTRUDE_MINTEMP, MAX_E_TEMP, 1);
Expand Down Expand Up @@ -4532,8 +4531,8 @@ void JyersDWIN::popupControl() {
planner.synchronize();
#else
queue.inject(F("M25"));
TERN_(HAS_HOTEND, pausetemp = thermalManager.temp_hotend[0].target);
TERN_(HAS_HEATED_BED, pausebed = thermalManager.temp_bed.target);
TERN_(HAS_HOTEND, pausetemp = thermalManager.degTargetHotend(0));
TERN_(HAS_HEATED_BED, pausebed = thermalManager.degTargetBed());
TERN_(HAS_FAN, pausefan = thermalManager.fan_speed[0]);
thermalManager.cooldown();
#endif
Expand Down Expand Up @@ -4594,15 +4593,15 @@ void JyersDWIN::popupControl() {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
case Popup_ConfFilChange:
if (selection == 0) {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
if (thermalManager.targetTooColdToExtrude(0))
popupHandler(Popup_ETemp);
else {
if (thermalManager.temp_hotend[0].is_below_target(2)) {
popupHandler(Popup_Heating);
thermalManager.wait_for_hotend(0);
}
popupHandler(Popup_FilChange);
gcode.process_subcommands_now(TS(F("M600B1R"), thermalManager.temp_hotend[0].target));
gcode.process_subcommands_now(TS(F("M600B1R"), thermalManager.degTargetHotend(0)));
}
}
else
Expand Down Expand Up @@ -4786,12 +4785,12 @@ void JyersDWIN::update() {
stateUpdate();
screenUpdate();
switch (process) {
case Proc_Main: mainMenuControl(); break;
case Proc_Main: mainMenuControl(); break;
case Proc_Menu: menuControl(); break;
case Proc_Value: valueControl(); break;
case Proc_Option: optionControl(); break;
case Proc_File: fileControl(); break;
case Proc_Print: printScreenControl(); break;
case Proc_Print: printScreenControl(); break;
case Proc_Popup: popupControl(); break;
case Proc_Confirm: confirmControl(); break;
}
Expand Down Expand Up @@ -4900,20 +4899,20 @@ void JyersDWIN::screenUpdate() {
switch (active_menu) {
case ID_TempMenu:
#if HAS_HOTEND
if (thermalManager.temp_hotend[0].target != hotendtarget) {
hotendtarget = thermalManager.temp_hotend[0].target;
if (thermalManager.degTargetHotend(0) != hotendtarget) {
hotendtarget = thermalManager.degTargetHotend(0);
if (scrollpos <= TEMP_HOTEND && TEMP_HOTEND <= scrollpos + MROWS) {
if (process != Proc_Value || selection != TEMP_HOTEND - scrollpos)
drawFloat(thermalManager.temp_hotend[0].target, TEMP_HOTEND - scrollpos, false, 1);
drawFloat(hotendtarget, TEMP_HOTEND - scrollpos, false, 1);
}
}
#endif
#if HAS_HEATED_BED
if (thermalManager.temp_bed.target != bedtarget) {
bedtarget = thermalManager.temp_bed.target;
if (thermalManager.degTargetBed() != bedtarget) {
bedtarget = thermalManager.degTargetBed();
if (scrollpos <= TEMP_BED && TEMP_BED <= scrollpos + MROWS) {
if (process != Proc_Value || selection != TEMP_HOTEND - scrollpos)
drawFloat(thermalManager.temp_bed.target, TEMP_BED - scrollpos, false, 1);
drawFloat(bedtarget, TEMP_BED - scrollpos, false, 1);
}
}
#endif
Expand All @@ -4922,27 +4921,27 @@ void JyersDWIN::screenUpdate() {
fanspeed = thermalManager.fan_speed[0];
if (scrollpos <= TEMP_FAN && TEMP_FAN <= scrollpos + MROWS) {
if (process != Proc_Value || selection != TEMP_HOTEND - scrollpos)
drawFloat(thermalManager.fan_speed[0], TEMP_FAN - scrollpos, false, 1);
drawFloat(fanspeed, TEMP_FAN - scrollpos, false, 1);
}
}
#endif
break;
case ID_Tune:
#if HAS_HOTEND
if (thermalManager.temp_hotend[0].target != hotendtarget) {
hotendtarget = thermalManager.temp_hotend[0].target;
if (thermalManager.degTargetHotend(0) != hotendtarget) {
hotendtarget = thermalManager.degTargetHotend(0);
if (scrollpos <= TUNE_HOTEND && TUNE_HOTEND <= scrollpos + MROWS) {
if (process != Proc_Value || selection != TEMP_HOTEND - scrollpos)
drawFloat(thermalManager.temp_hotend[0].target, TUNE_HOTEND - scrollpos, false, 1);
drawFloat(hotendtarget, TUNE_HOTEND - scrollpos, false, 1);
}
}
#endif
#if HAS_HEATED_BED
if (thermalManager.temp_bed.target != bedtarget) {
bedtarget = thermalManager.temp_bed.target;
if (thermalManager.degTargetBed() != bedtarget) {
bedtarget = thermalManager.degTargetBed();
if (scrollpos <= TUNE_BED && TUNE_BED <= scrollpos + MROWS) {
if (process != Proc_Value || selection != TEMP_HOTEND - scrollpos)
drawFloat(thermalManager.temp_bed.target, TUNE_BED - scrollpos, false, 1);
drawFloat(bedtarget, TUNE_BED - scrollpos, false, 1);
}
}
#endif
Expand All @@ -4951,7 +4950,7 @@ void JyersDWIN::screenUpdate() {
fanspeed = thermalManager.fan_speed[0];
if (scrollpos <= TUNE_FAN && TUNE_FAN <= scrollpos + MROWS) {
if (process != Proc_Value || selection != TEMP_HOTEND - scrollpos)
drawFloat(thermalManager.fan_speed[0], TUNE_FAN - scrollpos, false, 1);
drawFloat(fanspeed, TUNE_FAN - scrollpos, false, 1);
}
}
#endif
Expand Down
Loading

0 comments on commit fc2272c

Please sign in to comment.