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

🐛 Fix, improve E3V2 Enhanced UI (#22733)

This commit is contained in:
Miguel Risco-Castillo 2021-09-09 16:40:10 -05:00 committed by GitHub
parent 754b31918a
commit 392a4a6f85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 126 additions and 103 deletions

View File

@ -421,7 +421,7 @@
#endif
#endif
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#if EITHER(DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI)
#define HAS_LCD_BRIGHTNESS 1
#endif

View File

@ -163,10 +163,10 @@ static bool sdprint = false;
#if ENABLED(PAUSE_HEAT)
#if HAS_HOTEND
uint16_t resume_hotend_temp = 0;
celsius_t resume_hotend_temp = 0;
#endif
#if HAS_HEATED_BED
uint16_t resume_bed_temp = 0;
celsius_t resume_bed_temp = 0;
#endif
#if HAS_FAN
uint16_t resume_fan = 0;
@ -708,7 +708,7 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y,
else if (blink && draw_empty)
DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" "));
else
DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 1, x, y, p * 10);
DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 1, x, y, p);
}
}
@ -805,7 +805,7 @@ void update_variable() {
static float _offset = 0;
if (BABY_Z_VAR != _offset) {
_offset = BABY_Z_VAR;
DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, _offset * 100);
DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, _offset);
}
_draw_xyz_position(false);
@ -1030,14 +1030,7 @@ void Draw_Status_Area(const bool with_update) {
DWINUI::Draw_Icon(ICON_Zoffset, 187, 416);
#endif
if (BABY_Z_VAR < 0) {
DWINUI::Draw_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 207, 417, -BABY_Z_VAR * 100);
DWINUI::Draw_String(HMI_data.Indicator_Color, 205, 419, F("-"));
}
else {
DWINUI::Draw_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 207, 417, BABY_Z_VAR * 100);
DWINUI::Draw_String(HMI_data.Indicator_Color, 205, 419, F(" "));
}
DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, BABY_Z_VAR);
DWIN_Draw_Rectangle(1, HMI_data.SplitLine_Color, 0, 449, DWIN_WIDTH, 451);
@ -1690,7 +1683,7 @@ void DWIN_CompletedLeveling() { HMI_ReturnScreen(); }
void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
char msg[33] = "";
char str_1[6] = "";
sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_MESH), xpos, ypos,
sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), xpos, ypos,
dtostrf(zval, 1, 2, str_1));
ui.set_status(msg);
}
@ -1791,6 +1784,7 @@ void DWIN_Print_Started(const bool sd) {
sdprint = card.isPrinting() || sd;
_percent_done = 0;
_remain_time = 0;
HMI_flag.print_finish = false;
Goto_PrintProcess();
}
@ -1846,18 +1840,20 @@ void DWIN_SetDataDefaults() {
TERN_(HAS_HOTEND, HMI_data.HotendPidT = PREHEAT_1_TEMP_HOTEND);
TERN_(HAS_HEATED_BED, HMI_data.BedPidT = PREHEAT_1_TEMP_BED);
TERN_(HAS_HOTEND, HMI_data.PidCycles = 5);
TERN_(PREVENT_COLD_EXTRUSION, HMI_data.ExtMinT = EXTRUDE_MINTEMP);
}
void DWIN_StoreSettings(char *buff) {
memcpy(buff, &HMI_data, min(sizeof(HMI_data), eeprom_data_size));
memcpy(buff, &HMI_data, _MIN(sizeof(HMI_data), eeprom_data_size));
}
void DWIN_LoadSettings(const char *buff) {
memcpy(&HMI_data, buff, min(sizeof(HMI_data), eeprom_data_size));
memcpy(&HMI_data, buff, _MIN(sizeof(HMI_data), eeprom_data_size));
dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z);
if (HMI_data.Text_Color == HMI_data.Background_Color) DWIN_SetColorDefaults();
DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color);
TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT());
feedrate_percentage = 100;
}
void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) {
@ -1970,11 +1966,11 @@ void DWIN_LockScreen(const bool flag) {
// lo: low limit
// hi: high limit
// dp: decimal places, 0 for integers
// val: value
// val: value / scaled value
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
last_checkkey = checkkey;
last_checkkey = Menu;
checkkey = process;
HMI_value.MinValue = lo;
HMI_value.MaxValue = hi;
@ -1985,18 +1981,29 @@ void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp,
EncoderRate.enabled = true;
}
// Generic onclick event for set values (dp = 0: integer, dp > 0: float)
// Generic onclick event for integer values
// process: process id HMI destiny
// lo: scaled low limit
// hi: scaled high limit
// dp: decimal places, 0 for integers
// val: scaled value
// val: value
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
SetOnClick(process, lo, hi, dp, val, Apply, LiveUpdate);
dp ? DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value)
: Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, HMI_value.Value);
void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate);
Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, HMI_value.Value);
}
// Generic onclick event for float values
// process: process id HMI destiny
// lo: scaled low limit
// hi: scaled high limit
// val: value
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
const int32_t value = round(val * POW(10, dp));
SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate);
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val);
}
// Generic onclick event for integer values
@ -2005,8 +2012,8 @@ void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_
// val: value
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
SetValueOnClick(SetInt, lo, hi, 0, val, Apply, LiveUpdate);
inline void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
SetValueOnClick(SetInt, lo, hi, val, Apply, LiveUpdate);
}
// Generic onclick event for set pointer to 16 bit uinteger values
@ -2017,7 +2024,7 @@ void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (
void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
HMI_value.P_Int = (int16_t*)static_cast<MenuItemPtrClass*>(CurrentMenu->SelectedItem())->value;
const int32_t value = *HMI_value.P_Int;
SetValueOnClick(SetPInt, lo, hi, 0, value, Apply, LiveUpdate);
SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate);
}
// Generic onclick event for float values
@ -2026,8 +2033,8 @@ void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() = nullpt
// hi: high limit
// dp: decimal places
// val: value
void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
SetValueOnClick(SetFloat, lo * POW(10, dp), hi * POW(10, dp), dp, val * POW(10, dp), Apply, LiveUpdate);
inline void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
SetValueOnClick(SetFloat, lo, hi, dp, val, Apply, LiveUpdate);
}
// Generic onclick event for set pointer to float values
@ -2037,8 +2044,7 @@ void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val
// Apply: update function when the encoder is pressed
void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
HMI_value.P_Float = (float*)static_cast<MenuItemPtrClass*>(CurrentMenu->SelectedItem())->value;
const int32_t value = *HMI_value.P_Float * POW(10, dp);
SetValueOnClick(SetPFloat, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate);
SetValueOnClick(SetPFloat, lo, hi, dp, *HMI_value.P_Float, Apply, LiveUpdate);
}
#if ENABLED(EEPROM_SETTINGS)
@ -2148,7 +2154,7 @@ void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS
#if HAS_HOTEND
void SetMoveE() {
#ifdef PREVENT_COLD_EXTRUSION
#if ENABLED(PREVENT_COLD_EXTRUSION)
if (thermalManager.tooColdToExtrude(0)) {
Popup_Window_ETempTooLow();
return;
@ -2162,8 +2168,14 @@ void SetMoveZto0() {
char cmd[48] = "";
char str_1[5] = "", str_2[5] = "";
sprintf_P(cmd, PSTR("G28OXY\nG28Z\nG0X%sY%sF5000\nG0Z0F300"),
dtostrf(X_CENTER, 1, 1, str_1),
dtostrf(Y_CENTER, 1, 1, str_2));
#if ENABLED(MESH_BED_LEVELING)
dtostrf(0, 1, 1, str_1),
dtostrf(0, 1, 1, str_2)
#else
dtostrf(X_CENTER, 1, 1, str_1),
dtostrf(Y_CENTER, 1, 1, str_2)
#endif
);
gcode.process_subcommands_now_P(cmd);
planner.synchronize();
ui.set_status_P(PSTR("Now adjust Z Offset"));
@ -2175,7 +2187,8 @@ void SetPID(celsius_t t, heater_id_t h) {
char str_1[5] = "", str_2[5] = "";
sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84"),
dtostrf(X_CENTER, 1, 1, str_1),
dtostrf(Y_CENTER, 1, 1, str_2));
dtostrf(Y_CENTER, 1, 1, str_2)
);
gcode.process_subcommands_now_P(cmd);
planner.synchronize();
thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true);
@ -2217,6 +2230,7 @@ void Goto_LockScreen() {
#if HAS_BED_PROBE
void SetProbeOffsetX() { SetPFloatOnClick(-50, 50, UNITFDIGITS); }
void SetProbeOffsetY() { SetPFloatOnClick(-50, 50, UNITFDIGITS); }
void SetProbeOffsetZ() { SetPFloatOnClick(-10, 10, 2); }
void ProbeTest() {
ui.set_status_P(GET_TEXT(MSG_M48_TEST));
queue.inject_P(PSTR("G28O\nM48 P10"));
@ -2250,24 +2264,24 @@ void RestoreDefaultsColors() {
void SelColor() {
HMI_value.P_Int = (int16_t*)static_cast<MenuItemPtrClass*>(CurrentMenu->SelectedItem())->value;
HMI_value.Color[2] = GetRColor(*HMI_value.P_Int); // Red
HMI_value.Color[0] = GetRColor(*HMI_value.P_Int); // Red
HMI_value.Color[1] = GetGColor(*HMI_value.P_Int); // Green
HMI_value.Color[0] = GetBColor(*HMI_value.P_Int); // Blue
HMI_value.Color[2] = GetBColor(*HMI_value.P_Int); // Blue
Draw_GetColor_Menu();
}
void LiveRGBColor() {
HMI_value.Color[CurrentMenu->line() - 2] = HMI_value.Value;
uint16_t color = RGB(HMI_value.Color[2], HMI_value.Color[1], HMI_value.Color[0]);
uint16_t color = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]);
DWIN_Draw_Rectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335);
}
void SetRGBColor() {
const uint8_t line = CurrentMenu->line() - 2;
SetIntOnClick(0, (line == 1) ? 63 : 31, HMI_value.Color[CurrentMenu->SelectedItem()->icon], nullptr, LiveRGBColor);
const uint8_t color = CurrentMenu->SelectedItem()->icon;
SetIntOnClick(0, (color == 1) ? 63 : 31, HMI_value.Color[color], nullptr, LiveRGBColor);
}
void DWIN_ApplyColor() {
*HMI_value.P_Int = RGB(HMI_value.Color[2], HMI_value.Color[1], HMI_value.Color[0]);
*HMI_value.P_Int = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]);
DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color);
Draw_Status_Area(false);
Draw_SelectColors_Menu();
@ -2278,7 +2292,7 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); }
#if HAS_HOTEND
void ApplyHotendTemp() { thermalManager.setTargetHotend(HMI_value.Value, 0); }
void SetHotendTemp() { SetIntOnClick(HEATER_0_MINTEMP, HEATER_0_MAXTEMP, thermalManager.degTargetHotend(0), ApplyHotendTemp); }
void SetHotendTemp() { SetIntOnClick(MIN_ETEMP, MAX_ETEMP, thermalManager.degTargetHotend(0), ApplyHotendTemp); }
#endif
#if HAS_HEATED_BED
@ -2384,11 +2398,19 @@ void LevBedC () { LevBed(4); }
gcode.process_subcommands_now_P(PSTR("G28 XYO\nG28 Z\nM211 S0\nG29S1"));
planner.synchronize();
#ifdef MANUAL_PROBE_START_Z
MMeshMoveZItem->Draw(CurrentMenu->line(MMeshMoveZItem->pos));
const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos);
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, 2, VALX - 2 * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(line), MANUAL_PROBE_START_Z);
#endif
}
void SetMMeshMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(-1, 1, 2, planner.synchronize, LiveMove);}
void LiveMeshMoveZ() {
*HMI_value.P_Float = HMI_value.Value / POW(10, 2);
if (!planner.is_full()) {
planner.synchronize();
planner.buffer_line(current_position, homing_feedrate(Z_AXIS));
}
}
void SetMMeshMoveZ() { SetPFloatOnClick(-1, 1, 2, planner.synchronize, LiveMeshMoveZ);}
void ManualMeshContinue(){
gcode.process_subcommands_now_P(PSTR("G29S2"));
@ -2496,7 +2518,7 @@ void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) {
void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) {
onDrawMenuItem(menuitem, line);
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(line), value * POW(10, dp));
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(line), value);
}
void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) {
@ -2507,8 +2529,7 @@ void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) {
void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) {
const float value = *(float*)static_cast<MenuItemPtrClass*>(menuitem)->value;
const int8_t dp = 2;
onDrawFloatMenu(menuitem, line, dp, value);
onDrawFloatMenu(menuitem, line, 2, value);
}
void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) {
@ -2643,9 +2664,9 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) {
const uint8_t i = menuitem->icon;
uint16_t color;
switch (i) {
case 0: color = RGB(0, 0, 31); break;
case 1: color = RGB(0, 63, 0); break;
case 2: color = RGB(31, 0, 0); break;
case 0: color = RGB(31, 0, 0); break; // Red
case 1: color = RGB(0, 63, 0); break; // Green
case 2: color = RGB(0, 0, 31); break; // Blue
default: color = 0; break;
}
DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, ICOX + 1, MBASE(line) - 1 + 1, ICOX + 18, MBASE(line) - 1 + 18);
@ -3002,12 +3023,12 @@ int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) {
if (encoder_diffState != ENCODER_DIFF_NO) {
if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
EncoderRate.enabled = false;
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value);
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
checkkey = last_checkkey;
return 2;
}
LIMIT(HMI_value.Value, lo, hi);
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value);
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
return 1;
}
return 0;
@ -3182,10 +3203,11 @@ void Draw_Move_Menu() {
if (CurrentMenu != ProbeSetMenu) {
CurrentMenu = ProbeSetMenu;
SetMenuTitle({0}, {0}, GET_TEXT_F(MSG_ZPROBE_SETTINGS)); // TODO: Chinese, English "Probe Settings" JPG
DWINUI::MenuItemsPrepare(4);
DWINUI::MenuItemsPrepare(5);
ADDMENUITEM(ICON_Back, GET_TEXT(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu);
ADDMENUITEM_P(ICON_ProbeOffsetX, GET_TEXT(MSG_ZPROBE_XOFFSET), onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x);
ADDMENUITEM_P(ICON_ProbeOffsetY, GET_TEXT(MSG_ZPROBE_YOFFSET), onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y);
ADDMENUITEM_P(ICON_ProbeOffsetZ, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z);
ADDMENUITEM(ICON_ProbeTest, GET_TEXT(MSG_M48_TEST), onDrawMenuItem, ProbeTest);
}
CurrentMenu->Draw();
@ -3203,7 +3225,7 @@ void Draw_Move_Menu() {
ADDMENUITEM(ICON_Back, GET_TEXT(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu);
TERN_(HAS_FILAMENT_SENSOR, ADDMENUITEM(ICON_Runout, GET_TEXT(MSG_RUNOUT_ENABLE), onDrawRunoutEnable, SetRunoutEnable));
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, ADDMENUITEM_P(ICON_Runout, F("Runout Distance"), onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()));
TERN_(PREVENT_COLD_EXTRUSION, ADDMENUITEM_P(ICON_ExtrudeMinT, F("Extrude Min Temp."), onDrawPIntMenu, SetExtMinT, &thermalManager.extrude_min_temp));
TERN_(PREVENT_COLD_EXTRUSION, ADDMENUITEM_P(ICON_ExtrudeMinT, F("Extrude Min Temp."), onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT));
TERN_(ADVANCED_PAUSE_FEATURE, ADDMENUITEM_P(ICON_FilLoad, GET_TEXT(MSG_FILAMENT_LOAD), onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length));
TERN_(ADVANCED_PAUSE_FEATURE, ADDMENUITEM_P(ICON_FilUnload, GET_TEXT(MSG_FILAMENT_UNLOAD), onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length));
}
@ -3250,9 +3272,9 @@ void Draw_GetColor_Menu() {
DWINUI::MenuItemsPrepare(5);
ADDMENUITEM(ICON_Back, GET_TEXT(MSG_BUTTON_BACK), onDrawBack, DWIN_ApplyColor);
ADDMENUITEM(ICON_Cancel, GET_TEXT(MSG_BUTTON_CANCEL), onDrawMenuItem, Draw_SelectColors_Menu);
ADDMENUITEM(0, "Blue", onDrawGetColorItem, SetRGBColor);
ADDMENUITEM(0, "Red", onDrawGetColorItem, SetRGBColor);
ADDMENUITEM(1, "Green", onDrawGetColorItem, SetRGBColor);
ADDMENUITEM(2, "Red", onDrawGetColorItem, SetRGBColor);
ADDMENUITEM(2, "Blue", onDrawGetColorItem, SetRGBColor);
}
CurrentMenu->Draw();
DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335);
@ -3270,16 +3292,12 @@ void Draw_Tune_Menu() {
TERN_(HAS_HOTEND, HotendTargetItem = ADDMENUITEM_P(ICON_HotendTemp, GET_TEXT(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target));
TERN_(HAS_HEATED_BED, BedTargetItem = ADDMENUITEM_P(ICON_BedTemp, GET_TEXT(MSG_UBL_SET_TEMP_BED), onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target));
TERN_(HAS_FAN, FanSpeedItem = ADDMENUITEM_P(ICON_FanSpeed, GET_TEXT(MSG_FAN_SPEED), onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]));
#if HAS_ZOFFSET_ITEM
#if EITHER(HAS_BED_PROBE, BABYSTEPPING)
ADDMENUITEM_P(ICON_Zoffset, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawZOffset, SetZOffset, &BABY_Z_VAR);
#else
ADDMENUITEM(ICON_SetHome, GET_TEXT(MSG_SET_HOME_OFFSETS), onDrawHomeOffset, SetHome);
#endif
#if HAS_ZOFFSET_ITEM && EITHER(HAS_BED_PROBE, BABYSTEPPING)
ADDMENUITEM_P(ICON_Zoffset, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawZOffset, SetZOffset, &BABY_Z_VAR);
#endif
ADDMENUITEM_P(ICON_Flow, GET_TEXT(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]);
TERN_(ADVANCED_PAUSE_FEATURE, ADDMENUITEM(ICON_FilMan, GET_TEXT(MSG_FILAMENTCHANGE), onDrawMenuItem, ChangeFilament));
ADDMENUITEM(ICON_Lock, PSTR("Lock Screen"), onDrawMenuItem, Goto_LockScreen);
ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen);
TERN_(HAS_LCD_BRIGHTNESS, ADDMENUITEM_P(ICON_Brightness, F("LCD Brightness"), onDrawPInt8Menu, SetBrightness, &ui.brightness));
}
CurrentMenu->Draw();
@ -3300,7 +3318,6 @@ void Draw_Motion_Menu() {
ADDMENUITEM_P(ICON_Flow, GET_TEXT(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]);
}
CurrentMenu->Draw();
DWIN_StatusChanged(nullptr);
}
#if ENABLED(ADVANCED_PAUSE_FEATURE)
@ -3476,9 +3493,9 @@ void Draw_Steps_Menu() {
DWINUI::MenuItemsPrepare(8);
ADDMENUITEM(ICON_Back, GET_TEXT(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu);
ADDMENUITEM(ICON_PIDNozzle, F("Hotend PID"), onDrawMenuItem, HotendPID);
ADDMENUITEM_P(ICON_PIDValue, F(STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp);
ADDMENUITEM_P(ICON_PIDValue, F(STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki);
ADDMENUITEM_P(ICON_PIDValue, F(STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd);
ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp);
ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki);
ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd);
ADDMENUITEM_P(ICON_Temperature, GET_TEXT(MSG_TEMPERATURE), onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT);
ADDMENUITEM_P(ICON_PIDcycles, GET_TEXT(MSG_PID_CYCLE), onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles);
TERN_(EEPROM_SETTINGS, ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom));
@ -3497,9 +3514,9 @@ void Draw_Steps_Menu() {
DWINUI::MenuItemsPrepare(8);
ADDMENUITEM(ICON_Back, GET_TEXT(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu);
ADDMENUITEM(ICON_PIDNozzle, F("Bed PID"), onDrawMenuItem,BedPID);
ADDMENUITEM_P(ICON_PIDValue, F(STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp);
ADDMENUITEM_P(ICON_PIDValue, F(STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki);
ADDMENUITEM_P(ICON_PIDValue, F(STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd);
ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp);
ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki);
ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd);
ADDMENUITEM_P(ICON_Temperature, GET_TEXT(MSG_TEMPERATURE), onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT);
ADDMENUITEM_P(ICON_PIDcycles, GET_TEXT(MSG_PID_CYCLE), onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles);
TERN_(EEPROM_SETTINGS, ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom));
@ -3522,6 +3539,7 @@ void Draw_Steps_Menu() {
ADDMENUITEM_P(ICON_Zoffset, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR);
}
CurrentMenu->Draw();
if (!axis_is_trusted(Z_AXIS)) ui.set_status_P(PSTR("WARNING: Z position is unknow, move Z to home"));
}
#endif

View File

@ -20,11 +20,6 @@
*/
#pragma once
/**
* DWIN by Creality3D
* Enhanced implementation by Miguel A. Risco-Castillo
*/
#include "../../../inc/MarlinConfigPre.h"
#include "dwinui.h"
#include "rotary_encoder.h"
@ -130,7 +125,7 @@ typedef struct {
#ifdef PREHEAT_1_TEMP_BED
int16_t BedPidT = PREHEAT_1_TEMP_BED;
#endif
TERN_(PREVENT_COLD_EXTRUSION, uint16_t ExtMinT = EXTRUDE_MINTEMP);
TERN_(PREVENT_COLD_EXTRUSION, int16_t ExtMinT = EXTRUDE_MINTEMP);
} HMI_data_t;
typedef struct {

View File

@ -22,8 +22,8 @@
/********************************************************************************
* @file lcd/e3v2/enhanced/dwin_lcd.cpp
* @author LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
* @date 2021/08/29
* @version 2.1.1
* @date 2021/09/08
* @version 2.2.1
* @brief DWIN screen control functions
********************************************************************************/
@ -260,7 +260,7 @@ void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color
// x/y: Upper-left coordinate
// value: Integer value
void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
size_t i = 0;
DWIN_Byte(i, 0x14);
// Bit 7: bshow
@ -319,6 +319,12 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
DWIN_Long(i, value);
DWIN_Send(i);
}
// value: positive float value
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
const long val = round(value * POW(10, fNum));
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val);
}
/*---------------------------------------- Picture related functions ----------------------------------------*/

View File

@ -22,8 +22,8 @@
/********************************************************************************
* @file lcd/e3v2/enhanced/dwin_lcd.h
* @author LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
* @date 2021/08/29
* @version 2.1.1
* @date 2021/08/09
* @version 2.2.1
* @brief DWIN screen control functions
********************************************************************************/
@ -157,7 +157,7 @@ inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t
// x/y: Upper-left coordinate
// value: Integer value
void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value);
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value);
// Draw a positive floating point number
// bShow: true=display background color; false=don't display background color
@ -172,6 +172,9 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t
// value: Scaled positive float value
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
// value: positive float value
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
/*---------------------------------------- Picture related functions ----------------------------------------*/

View File

@ -1,8 +1,8 @@
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.6.1
* Date: 2021/08/29
* Version: 3.6.3
* Date: 2021/08/09
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@ -185,7 +185,7 @@ void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rli
// fNum: Number of decimal digits
// x/y: Upper-left point
// value: Float value
void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
if (value < 0) {
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, -value);
DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, F("-"));

View File

@ -1,8 +1,8 @@
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.6.1
* Date: 2021/08/29
* Version: 3.6.3
* Date: 2021/08/09
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@ -152,6 +152,7 @@
#define ICON_PIDValue ICON_Contact
#define ICON_ProbeOffsetX ICON_StepX
#define ICON_ProbeOffsetY ICON_StepY
#define ICON_ProbeOffsetZ ICON_StepZ
#define ICON_ProbeSet ICON_SetEndTemp
#define ICON_ProbeTest ICON_SetEndTemp
#define ICON_Pwrlossr ICON_Motion
@ -392,14 +393,14 @@ namespace DWINUI {
// iNum: Number of digits
// x/y: Upper-left coordinate
// value: Integer value
inline void Draw_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
inline void Draw_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
DWIN_Draw_IntValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, x, y, value);
}
inline void Draw_Int(uint8_t iNum, uint16_t value) {
inline void Draw_Int(uint8_t iNum, long value) {
DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
MoveBy(iNum * Get_font_width(font), 0);
}
inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value);
}
inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
@ -423,23 +424,23 @@ namespace DWINUI {
// fNum: Number of decimal digits
// x/y: Upper-left point
// value: Float value
inline void Draw_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Float(uint8_t iNum, uint8_t fNum, long value) {
inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
MoveBy((iNum + fNum + 1) * Get_font_width(font), 0);
}
inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
}
inline void Draw_Float(uint16_t color, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Float(uint16_t color, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
DWIN_Draw_FloatValue(false, true, 0, font, color, backcolor, iNum, fNum, x, y, value);
}
inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
DWIN_Draw_FloatValue(true, true, 0, font, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
DWIN_Draw_FloatValue(true, true, 0, size, color, bColor, iNum, fNum, x, y, value);
}
@ -453,21 +454,21 @@ namespace DWINUI {
// fNum: Number of decimal digits
// x/y: Upper-left point
// value: Float value
void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, long value) {
void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
MoveBy((iNum + fNum + 1) * Get_font_width(font), 0);
}
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
}
inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Signed_Float(false, true, 0, size, textcolor, backcolor, iNum, fNum, x, y, value);
}
inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Signed_Float(true, true, 0, font, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Signed_Float(true, true, 0, size, color, bColor, iNum, fNum, x, y, value);
}