1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

🧑‍💻 JyersUI code cleanup

This commit is contained in:
Scott Lahteine 2023-04-14 18:00:25 -05:00
parent 6d819eb8d4
commit 48b712fdc0
2 changed files with 102 additions and 103 deletions

View File

@ -377,7 +377,7 @@ private:
return min;
}
void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7) {
void Draw_Bed_Mesh(const int16_t selected=-1, const uint8_t gridline_width=1, const uint16_t padding_x=8, const uint16_t padding_y_top=40 + 53 - 7) {
drawing_mesh = true;
const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x,
cell_width_px = total_width_px / (GRID_MAX_POINTS_X),
@ -470,15 +470,15 @@ constexpr const char * const CrealityDWINClass::preheat_modes[3];
// 3=Title bar and Menu area (default)
// 2=Menu area
// 1=Title bar
void CrealityDWINClass::Clear_Screen(uint8_t e/*=3*/) {
void CrealityDWINClass::Clear_Screen(const uint8_t e/*=3*/) {
if (e == 1 || e == 3 || e == 4) DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.menu_top_bg, Color_Bg_Blue, false), 0, 0, DWIN_WIDTH, TITLE_HEIGHT); // Clear Title Bar
if (e == 2 || e == 3) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y); // Clear Menu Area
if (e == 4) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); // Clear Popup Area
}
void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=false*/, uint8_t minunit/*=10*/) {
void CrealityDWINClass::Draw_Float(const_float_t value, const uint8_t row, const bool selected/*=false*/, const uint8_t minunit/*=10*/) {
const uint8_t digits = (uint8_t)floor(log10(abs(value))) + log10(minunit) + (minunit > 1);
const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
const uint16_t bColor = selected ? Select_Color : Color_Bg_Black;
const uint16_t xpos = 240 - (digits * 8);
DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16);
if (isnan(value))
@ -489,44 +489,44 @@ void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=fal
}
}
void CrealityDWINClass::Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected/*=false*/, bool color/*=false*/) {
uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black,
tColor = (color) ? GetColor(value, Color_White, false) : Color_White;
void CrealityDWINClass::Draw_Option(const uint8_t value, const char * const * options, const uint8_t row, const bool selected/*=false*/, const bool color/*=false*/) {
const uint16_t bColor = selected ? Select_Color : Color_Bg_Black,
tColor = color ? GetColor(value, Color_White, false) : Color_White;
DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2);
DWIN_Draw_String(false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]);
}
uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) {
uint16_t CrealityDWINClass::GetColor(const uint8_t color, const uint16_t original, const bool light/*=false*/) {
switch (color) {
case Default:
return original;
break;
case White:
return (light) ? Color_Light_White : Color_White;
return light ? Color_Light_White : Color_White;
break;
case Green:
return (light) ? Color_Light_Green : Color_Green;
return light ? Color_Light_Green : Color_Green;
break;
case Cyan:
return (light) ? Color_Light_Cyan : Color_Cyan;
return light ? Color_Light_Cyan : Color_Cyan;
break;
case Blue:
return (light) ? Color_Light_Blue : Color_Blue;
return light ? Color_Light_Blue : Color_Blue;
break;
case Magenta:
return (light) ? Color_Light_Magenta : Color_Magenta;
return light ? Color_Light_Magenta : Color_Magenta;
break;
case Red:
return (light) ? Color_Light_Red : Color_Red;
return light ? Color_Light_Red : Color_Red;
break;
case Orange:
return (light) ? Color_Light_Orange : Color_Orange;
return light ? Color_Light_Orange : Color_Orange;
break;
case Yellow:
return (light) ? Color_Light_Yellow : Color_Yellow;
return light ? Color_Light_Yellow : Color_Yellow;
break;
case Brown:
return (light) ? Color_Light_Brown : Color_Brown;
return light ? Color_Light_Brown : Color_Brown;
break;
case Black:
return Color_Black;
@ -535,7 +535,7 @@ uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool ligh
return Color_White;
}
void CrealityDWINClass::Draw_Title(const char * ctitle) {
void CrealityDWINClass::Draw_Title(const char * const ctitle) {
DWIN_Draw_String(false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(ctitle) * STAT_CHR_W) / 2, 5, ctitle);
}
void CrealityDWINClass::Draw_Title(FSTR_P const ftitle) {
@ -548,7 +548,7 @@ void _Decorate_Menu_Item(uint8_t row, uint8_t icon, bool more) {
DWIN_Draw_Line(CrealityDWIN.GetColor(CrealityDWIN.eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line
}
void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) {
void CrealityDWINClass::Draw_Menu_Item(const uint8_t row, const uint8_t icon/*=0*/, const char * const label1, const char * const label2, const bool more/*=false*/, const bool centered/*=false*/) {
const uint8_t label_offset_y = (label1 || label2) ? MENU_CHR_H * 3 / 5 : 0,
label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2),
label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2);
@ -557,7 +557,7 @@ void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const ch
_Decorate_Menu_Item(row, icon, more);
}
void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, FSTR_P const flabel1, FSTR_P const flabel2, bool more/*=false*/, bool centered/*=false*/) {
void CrealityDWINClass::Draw_Menu_Item(const uint8_t row, const uint8_t icon/*=0*/, FSTR_P const flabel1, FSTR_P const flabel2, const bool more/*=false*/, const bool centered/*=false*/) {
const uint8_t label_offset_y = (flabel1 || flabel2) ? MENU_CHR_H * 3 / 5 : 0,
label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (flabel1 ? strlen_P(FTOP(flabel1)) : 0) * MENU_CHR_W) / 2),
label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (flabel2 ? strlen_P(FTOP(flabel2)) : 0) * MENU_CHR_W) / 2);
@ -566,7 +566,7 @@ void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, FSTR_P c
_Decorate_Menu_Item(row, icon, more);
}
void CrealityDWINClass::Draw_Checkbox(uint8_t row, bool value) {
void CrealityDWINClass::Draw_Checkbox(const uint8_t row, const bool value) {
#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) // Draw appropriate checkbox icon
DWIN_ICON_Show(ICON, (value ? ICON_Checkbox_T : ICON_Checkbox_F), 226, MBASE(row) - 3);
#else // Draw a basic checkbox using rectangles and lines
@ -583,7 +583,7 @@ void CrealityDWINClass::Draw_Checkbox(uint8_t row, bool value) {
#endif
}
void CrealityDWINClass::Draw_Menu(uint8_t menu, uint8_t select/*=0*/, uint8_t scroll/*=0*/) {
void CrealityDWINClass::Draw_Menu(const uint8_t menu, const uint8_t select/*=0*/, const uint8_t scroll/*=0*/) {
if (active_menu != menu) {
last_menu = active_menu;
if (process == Menu) last_selection = selection;
@ -600,12 +600,12 @@ void CrealityDWINClass::Draw_Menu(uint8_t menu, uint8_t select/*=0*/, uint8_t sc
DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
}
void CrealityDWINClass::Redraw_Menu(bool lastprocess/*=true*/, bool lastselection/*=false*/, bool lastmenu/*=false*/) {
switch ((lastprocess) ? last_process : process) {
void CrealityDWINClass::Redraw_Menu(const bool lastproc/*=true*/, const bool lastsel/*=false*/, const bool lastmenu/*=false*/) {
switch (lastproc ? last_process : process) {
case Menu:
Draw_Menu((lastmenu) ? last_menu : active_menu, (lastselection) ? last_selection : selection, (lastmenu) ? 0 : scrollpos);
Draw_Menu(lastmenu ? last_menu : active_menu, lastsel ? last_selection : selection, lastmenu ? 0 : scrollpos);
break;
case Main: Draw_Main_Menu((lastselection) ? last_selection : selection); break;
case Main: Draw_Main_Menu(lastsel ? last_selection : selection); break;
case Print: Draw_Print_Screen(); break;
case File: Draw_SD_List(); break;
default: break;
@ -671,7 +671,7 @@ void CrealityDWINClass::Main_Menu_Icons() {
#endif
}
void CrealityDWINClass::Draw_Main_Menu(uint8_t select/*=0*/) {
void CrealityDWINClass::Draw_Main_Menu(const uint8_t select/*=0*/) {
process = Main;
active_menu = MainMenu;
selection = select;
@ -803,7 +803,7 @@ void CrealityDWINClass::Draw_Print_confirm() {
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 85, 281, 188, 322);
}
void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) {
void CrealityDWINClass::Draw_SD_Item(const uint8_t item, const uint8_t row) {
if (item == 0)
Draw_Menu_Item(0, ICON_Back, card.flag.workDirIsRoot ? F("Back") : F(".."));
else {
@ -824,7 +824,7 @@ void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) {
}
}
void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) {
void CrealityDWINClass::Draw_SD_List(const bool removed/*=false*/) {
Clear_Screen();
Draw_Title("Select File");
selection = 0;
@ -842,7 +842,7 @@ void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) {
DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33);
}
void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
void CrealityDWINClass::Draw_Status_Area(const bool icons/*=false*/) {
if (icons) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1);
@ -965,7 +965,7 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink()))
DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, F(" -?- "));
else
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z : 0);
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, current_position.z >= 0 ? current_position.z : 0);
}
DWIN_UpdateLCD();
}
@ -1001,15 +1001,15 @@ void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const) {
}
void CrealityDWINClass::Popup_Select() {
const uint16_t c1 = (selection == 0) ? GetColor(eeprom_settings.highlight_box, Color_White) : Color_Bg_Window,
c2 = (selection == 0) ? Color_Bg_Window : GetColor(eeprom_settings.highlight_box, Color_White);
const uint16_t c1 = selection ? Color_Bg_Window : GetColor(eeprom_settings.highlight_box, Color_White),
c2 = selection ? GetColor(eeprom_settings.highlight_box, Color_White) : Color_Bg_Window;
DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318);
DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319);
DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318);
DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319);
}
void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) {
void CrealityDWINClass::Update_Status_Bar(const bool refresh/*=false*/) {
typedef TextScroller<30> Scroller;
static bool new_msg;
static Scroller scroller;
@ -1039,7 +1039,7 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) {
/* Menu Item Config */
void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) {
void CrealityDWINClass::Menu_Item_Handler(const uint8_t menu, const uint8_t item, bool draw/*=true*/) {
const uint8_t row = item - scrollpos;
#if HAS_LEVELING
static bool level_state;
@ -1199,7 +1199,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
#if ENABLED(ADVANCED_PAUSE_FEATURE)
case PREPARE_CHANGEFIL:
if (draw) {
Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament")
Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
, nullptr, true
#endif
@ -1737,7 +1737,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
break;
case CHANGEFIL_LOAD:
if (draw)
Draw_Menu_Item(row, ICON_WriteEEPROM, F("Load Filament"));
Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENTLOAD));
else {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
Popup_Handler(ETemp);
@ -1755,7 +1755,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
break;
case CHANGEFIL_UNLOAD:
if (draw)
Draw_Menu_Item(row, ICON_ReadEEPROM, F("Unload Filament"));
Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENTUNLOAD));
else {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) {
Popup_Handler(ETemp);
@ -1774,7 +1774,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
break;
case CHANGEFIL_CHANGE:
if (draw)
Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament"));
Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE));
else {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
Popup_Handler(ETemp);
@ -3805,7 +3805,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
case TUNE_CHANGEFIL:
if (draw)
Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament"));
Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE));
else
Popup_Handler(ConfFilChange);
break;
@ -3931,32 +3931,32 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
}
}
FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
FSTR_P CrealityDWINClass::Get_Menu_Title(const uint8_t menu) {
switch (menu) {
case MainMenu: return F("Main Menu");
case Prepare: return F("Prepare");
case MainMenu: return GET_TEXT_F(MSG_MAIN_MENU);
case Prepare: return GET_TEXT_F(MSG_PREPARE);
case HomeMenu: return F("Homing Menu");
case Move: return F("Move");
case ManualLevel: return F("Manual Leveling");
case Move: return GET_TEXT_F(MSG_MOVE_AXIS);
case ManualLevel: return GET_TEXT_F(MSG_BED_TRAMMING_MANUAL);
#if HAS_ZOFFSET_ITEM
case ZOffset: return F("Z Offset");
case ZOffset: return GET_TEXT_F(MSG_ZPROBE_ZOFFSET);
#endif
#if HAS_PREHEAT
case Preheat: return F("Preheat");
#endif
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
case ChangeFilament: return F("Change Filament");
case ChangeFilament: return GET_TEXT_F(MSG_FILAMENTCHANGE);
#endif
#if HAS_CUSTOM_MENU
case MenuCustom:
#ifdef CUSTOM_MENU_CONFIG_TITLE
return F(CUSTOM_MENU_CONFIG_TITLE);
#else
return F("Custom Commands");
return GET_TEXT_F(MSG_CUSTOM_COMMANDS);
#endif
#endif
case Control: return F("Control");
case TempMenu: return F("Temperature");
case Control: return GET_TEXT_F(MSG_CONTROL);
case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE);
#if HAS_HOTEND || HAS_HEATED_BED
case PID: return F("PID Menu");
#endif
@ -3977,14 +3977,14 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
#if HAS_CLASSIC_JERK
case MaxJerk: return F("Max Jerk");
#endif
case Steps: return F("Steps/mm");
case Steps: return GET_TEXT_F(MSG_STEPS_PER_MM);
case Visual: return F("Visual Settings");
case Advanced: return F("Advanced Settings");
case Advanced: return GET_TEXT_F(MSG_ADVANCED_SETTINGS);
#if HAS_BED_PROBE
case ProbeMenu: return F("Bed Probe");
#endif
#if HAS_TRINAMIC_CONFIG
case TMCMenu: return F("TMC Drivers");
case TMCMenu: return GET_TEXT_F(MSG_TMC_DRIVERS);
#endif
case ColorSettings: return F("UI Color Settings");
case Info: return F("Info");
@ -4000,15 +4000,15 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
case UBLMesh: return F("UBL Bed Leveling");
#endif
#if ENABLED(PROBE_MANUALLY)
case ManualMesh: return F("Mesh Bed Leveling");
case ManualMesh: return GET_TEXT_F(MSG_MANUAL_LEVELING);
#endif
case Tune: return F("Tune");
case PreheatHotend: return F("Preheat Hotend");
case Tune: return GET_TEXT_F(MSG_TUNE);
case PreheatHotend: return GET_TEXT_F(MSG_PREHEAT_HOTEND);
}
return F("");
}
uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
uint8_t CrealityDWINClass::Get_Menu_Size(const uint8_t menu) {
switch (menu) {
case Prepare: return PREPARE_TOTAL;
case HomeMenu: return HOME_TOTAL;
@ -4085,7 +4085,7 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
/* Popup Config */
void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) {
void CrealityDWINClass::Popup_Handler(const PopupID popupid, const bool option/*=false*/) {
popup = last_popup = popupid;
switch (popupid) {
case Pause: Draw_Popup(F("Pause Print"), F(""), F(""), Popup); break;
@ -4522,7 +4522,7 @@ void CrealityDWINClass::Popup_Control() {
else {
pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
if (printing) Popup_Handler(Resuming);
else Redraw_Menu(true, true, (active_menu==PreheatHotend));
else Redraw_Menu(true, true, active_menu == PreheatHotend);
}
break;
#endif // ADVANCED_PAUSE_FEATURE
@ -4581,7 +4581,7 @@ void CrealityDWINClass::Confirm_Control() {
/* In-Menu Value Modification */
void CrealityDWINClass::Setup_Value(float value, float min, float max, float unit, uint8_t type) {
void CrealityDWINClass::Setup_Value(const_float_t value, const_float_t min, const_float_t max, const_float_t unit, const uint8_t type) {
if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki))
tempvalue = unscalePID_i(value) * unit;
else if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Kd) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Kd))
@ -4597,38 +4597,38 @@ void CrealityDWINClass::Setup_Value(float value, float min, float max, float uni
Draw_Float(tempvalue / unit, selection - scrollpos, true, valueunit);
}
void CrealityDWINClass::Modify_Value(float &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
void CrealityDWINClass::Modify_Value(float &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) {
valuepointer = &value;
funcpointer = f;
Setup_Value((float)value, min, max, unit, 0);
}
void CrealityDWINClass::Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
void CrealityDWINClass::Modify_Value(uint8_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) {
valuepointer = &value;
funcpointer = f;
Setup_Value((float)value, min, max, unit, 1);
}
void CrealityDWINClass::Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
void CrealityDWINClass::Modify_Value(uint16_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) {
valuepointer = &value;
funcpointer = f;
Setup_Value((float)value, min, max, unit, 2);
}
void CrealityDWINClass::Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
void CrealityDWINClass::Modify_Value(int16_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) {
valuepointer = &value;
funcpointer = f;
Setup_Value((float)value, min, max, unit, 3);
}
void CrealityDWINClass::Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
void CrealityDWINClass::Modify_Value(uint32_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) {
valuepointer = &value;
funcpointer = f;
Setup_Value((float)value, min, max, unit, 4);
}
void CrealityDWINClass::Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) {
void CrealityDWINClass::Modify_Value(int8_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) {
valuepointer = &value;
funcpointer = f;
Setup_Value((float)value, min, max, unit, 5);
}
void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * options, uint8_t max) {
void CrealityDWINClass::Modify_Option(const uint8_t value, const char * const * options, const uint8_t max) {
tempvalue = value;
valuepointer = const_cast<const char * *>(options);
valuemin = 0;
@ -4652,7 +4652,7 @@ void CrealityDWINClass::Update_Status(const char * const text) {
}
}
void CrealityDWINClass::Start_Print(bool sd) {
void CrealityDWINClass::Start_Print(const bool sd) {
sdprint = sd;
if (!printing) {
printing = true;
@ -4723,7 +4723,7 @@ void CrealityDWINClass::State_Update() {
Popup_Handler(FilChange);
else if (pause_menu_response == PAUSE_RESPONSE_RESUME_PRINT) {
if (printing) Popup_Handler(Resuming);
else Redraw_Menu(true, true, (active_menu==PreheatHotend));
else Redraw_Menu(true, true, active_menu == PreheatHotend);
}
}
#endif
@ -4869,13 +4869,13 @@ void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
Update_Status(success ? "Success" : "Failed");
}
void CrealityDWINClass::Save_Settings(char *buff) {
void CrealityDWINClass::Save_Settings(char * const buff) {
TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = mesh_conf.tilt_grid - 1);
eeprom_settings.corner_pos = corner_pos * 10;
memcpy(buff, &eeprom_settings, _MIN(sizeof(eeprom_settings), eeprom_data_size));
}
void CrealityDWINClass::Load_Settings(const char *buff) {
void CrealityDWINClass::Load_Settings(const char * const buff) {
memcpy(&eeprom_settings, buff, _MIN(sizeof(eeprom_settings), eeprom_data_size));
TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
if (eeprom_settings.corner_pos == 0) eeprom_settings.corner_pos = 325;

View File

@ -172,17 +172,17 @@ public:
static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" };
static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" };
static void Clear_Screen(uint8_t e=3);
static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10);
static void Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected=false, bool color=false);
static uint16_t GetColor(uint8_t color, uint16_t original, bool light=false);
static void Draw_Checkbox(uint8_t row, bool value);
static void Draw_Title(const char * title);
static void Clear_Screen(const uint8_t e=3);
static void Draw_Float(const_float_t value, const uint8_t row, const bool selected=false, const uint8_t minunit=10);
static void Draw_Option(const uint8_t value, const char * const * options, const uint8_t row, const bool selected=false, const bool color=false);
static uint16_t GetColor(const uint8_t color, const uint16_t original, const bool light=false);
static void Draw_Checkbox(const uint8_t row, const bool value);
static void Draw_Title(const char * const title);
static void Draw_Title(FSTR_P const title);
static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, const char * const label1=nullptr, const char * const label2=nullptr, bool more=false, bool centered=false);
static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, FSTR_P const flabel1=nullptr, FSTR_P const flabel2=nullptr, bool more=false, bool centered=false);
static void Draw_Menu(uint8_t menu, uint8_t select=0, uint8_t scroll=0);
static void Redraw_Menu(bool lastprocess=true, bool lastselection=false, bool lastmenu=false);
static void Draw_Menu_Item(const uint8_t row, uint8_t icon=0, const char * const label1=nullptr, const char * const label2=nullptr, const bool more=false, const bool centered=false);
static void Draw_Menu_Item(const uint8_t row, uint8_t icon=0, FSTR_P const flabel1=nullptr, FSTR_P const flabel2=nullptr, const bool more=false, const bool centered=false);
static void Draw_Menu(const uint8_t menu, const uint8_t select=0, const uint8_t scroll=0);
static void Redraw_Menu(const bool lastproc=true, const bool lastsel=false, const bool lastmenu=false);
static void Redraw_Screen();
static void Main_Menu_Icons();
@ -196,24 +196,23 @@ public:
#endif
static void Draw_Print_ProgressElapsed();
static void Draw_Print_confirm();
static void Draw_SD_Item(uint8_t item, uint8_t row);
static void Draw_SD_List(bool removed=false);
static void Draw_Status_Area(bool icons=false);
static void Draw_SD_Item(const uint8_t item, const uint8_t row);
static void Draw_SD_List(const bool removed=false);
static void Draw_Status_Area(const bool icons=false);
static void Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon=0);
static void Popup_Select();
static void Update_Status_Bar(bool refresh=false);
static void Update_Status_Bar(const bool refresh=false);
#if ENABLED(AUTO_BED_LEVELING_UBL)
static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7);
#if HAS_MESH
static void Set_Mesh_Viewer_Status();
#endif
static FSTR_P Get_Menu_Title(uint8_t menu);
static uint8_t Get_Menu_Size(uint8_t menu);
static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true);
static FSTR_P Get_Menu_Title(const uint8_t menu);
static uint8_t Get_Menu_Size(const uint8_t menu);
static void Menu_Item_Handler(const uint8_t menu, const uint8_t item, bool draw=true);
static void Popup_Handler(PopupID popupid, bool option = false);
static void Confirm_Handler(PopupID popupid);
static void Popup_Handler(const PopupID popupid, bool option=false);
static void Confirm_Handler(const PopupID popupid);
static void Main_Menu_Control();
static void Menu_Control();
@ -224,24 +223,24 @@ public:
static void Popup_Control();
static void Confirm_Control();
static void Setup_Value(float value, float min, float max, float unit, uint8_t type);
static void Modify_Value(float &value, float min, float max, float unit, void (*f)()=nullptr);
static void Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()=nullptr);
static void Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()=nullptr);
static void Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()=nullptr);
static void Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()=nullptr);
static void Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()=nullptr);
static void Modify_Option(uint8_t value, const char * const * options, uint8_t max);
static void Setup_Value(const_float_t value, const_float_t min, const_float_t max, const_float_t unit, const uint8_t type);
static void Modify_Value(float &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr);
static void Modify_Value(uint8_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr);
static void Modify_Value(uint16_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr);
static void Modify_Value(int16_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr);
static void Modify_Value(uint32_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr);
static void Modify_Value(int8_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr);
static void Modify_Option(const uint8_t value, const char * const * options, const uint8_t max);
static void Update_Status(const char * const text);
static void Start_Print(bool sd);
static void Start_Print(const bool sd);
static void Stop_Print();
static void Update();
static void State_Update();
static void Screen_Update();
static void AudioFeedback(const bool success=true);
static void Save_Settings(char *buff);
static void Load_Settings(const char *buff);
static void Save_Settings(char * const buff);
static void Load_Settings(const char * const buff);
static void Reset_Settings();
};