Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» DWIN icon updates, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 24, 2023
1 parent 18b0dbb commit 0f09554
Show file tree
Hide file tree
Showing 122 changed files with 282 additions and 317 deletions.
6 changes: 3 additions & 3 deletions Marlin/src/feature/pause.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ enum PauseMessage : char {
PAUSE_MESSAGE_PARKING,
PAUSE_MESSAGE_CHANGING,
PAUSE_MESSAGE_WAITING,
PAUSE_MESSAGE_UNLOAD,
PAUSE_MESSAGE_INSERT,
PAUSE_MESSAGE_LOAD,
PAUSE_MESSAGE_UNLOAD,
PAUSE_MESSAGE_PURGE,
PAUSE_MESSAGE_OPTION,
PAUSE_MESSAGE_RESUME,
PAUSE_MESSAGE_STATUS,
PAUSE_MESSAGE_HEAT,
PAUSE_MESSAGE_HEATING
PAUSE_MESSAGE_HEATING,
PAUSE_MESSAGE_STATUS
};

#if M600_PURGE_MORE_RESUMABLE
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/e3v2/common/dwin_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define GetGColor(color) ((color >> 5) & 0x3F)
#define GetBColor(color) ((color >> 0) & 0x1F)

// RGB565 colors: https://rgbcolorpicker.com/565
#define COLOR_WHITE 0xFFFF
#define COLOR_YELLOW RGB(0x1F,0x3F,0x00)
#define COLOR_RED RGB(0x1F,0x00,0x00)
Expand Down
11 changes: 3 additions & 8 deletions Marlin/src/lcd/e3v2/common/dwin_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
#define Language_English 1
#define Language_Chinese 2

//#define USE_STOCK_DWIN_SET // Use the Creality stock DWIN_SET instead of Marlin's unified DWIN_SET by The-EG & thinkyhead
#ifdef USE_STOCK_DWIN_SET
#define ICON 9 // 9.ICO
#else
#define ICON 7 // 7.ICO
#endif
#define ICON 7 // 7.ICO

#ifndef CORP_WEBSITE
#define CORP_WEBSITE WEBSITE_URL
Expand Down Expand Up @@ -82,7 +77,7 @@
#define ICON_Motion 41
#define ICON_WriteEEPROM 42
#define ICON_ReadEEPROM 43
#define ICON_ResumeEEPROM 44
#define ICON_ResetEEPROM 44
#define ICON_Info 45

#define ICON_SetEndTemp 46
Expand Down Expand Up @@ -144,7 +139,7 @@
#define ICON_ProbeOffsetY ICON_StepY
#define ICON_ProbeOffsetZ ICON_StepZ
#define ICON_PIDNozzle ICON_SetEndTemp
#define ICON_PIDbed ICON_SetBedTemp
#define ICON_PIDBed ICON_SetBedTemp
#define ICON_FWRetract ICON_StepE
#define ICON_FWRetLength ICON_StepE
#define ICON_FWRetSpeed ICON_Setspeed
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/creality/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ void drawControlMenu() {
#if ENABLED(EEPROM_SETTINGS)
_TEMP_ICON(CONTROL_CASE_SAVE, ICON_WriteEEPROM, false);
_TEMP_ICON(CONTROL_CASE_LOAD, ICON_ReadEEPROM, false);
_TEMP_ICON(CONTROL_CASE_RESET, ICON_ResumeEEPROM, false);
_TEMP_ICON(CONTROL_CASE_RESET, ICON_ResetEEPROM, false);
#endif
}

Expand Down Expand Up @@ -2468,7 +2468,7 @@ void itemAdvBedPID(const uint8_t row) {
itemAreaCopy(145, 104, 167, 114, row, 27); // "PID"
#endif
}
drawMenuLine(row, ICON_PIDbed);
drawMenuLine(row, ICON_PIDBed);
}

#if ENABLED(POWER_LOSS_RECOVERY)
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
#if ENABLED(ADVANCED_PAUSE_FEATURE)
case PREPARE_CHANGEFIL:
if (draw) {
drawMenuItem(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)
drawMenuItem(row, ICON_ResetEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
, nullptr, true
#endif
Expand Down Expand Up @@ -1766,7 +1766,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
break;
case CHANGEFIL_CHANGE:
if (draw)
drawMenuItem(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE));
drawMenuItem(row, ICON_ResetEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE));
else {
if (thermalManager.targetTooColdToExtrude(0))
popupHandler(Popup_ETemp);
Expand Down Expand Up @@ -3449,7 +3449,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
break;
case LEVELING_SETTINGS_PLANE:
if (draw)
drawMenuItem(row, ICON_ResumeEEPROM, F("Convert Mesh to Plane"));
drawMenuItem(row, ICON_ResetEEPROM, F("Convert Mesh to Plane"));
else {
if (mesh_conf.createPlaneFromMesh()) break;
gcode.process_subcommands_now(F("M420 S1"));
Expand Down Expand Up @@ -3594,7 +3594,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
#if ENABLED(AUTO_BED_LEVELING_UBL)
case LEVELING_M_UNDEF:
if (draw)
drawMenuItem(row, ICON_ResumeEEPROM, F("Clear Point Value"));
drawMenuItem(row, ICON_ResetEEPROM, F("Clear Point Value"));
else {
mesh_conf.manualValueUpdate(true);
redrawMenu(false);
Expand Down Expand Up @@ -3924,7 +3924,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
case TUNE_CHANGEFIL:
if (draw)
drawMenuItem(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE));
drawMenuItem(row, ICON_ResetEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE));
else
popupHandler(Popup_ConfFilChange);
break;
Expand Down
68 changes: 36 additions & 32 deletions Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ bool drawing_mesh = false;
struct linear_fit_data lsf_results;
incremental_LSF_reset(&lsf_results);
GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y])) {
const float z = bedlevel.z_values[x][y];
if (!isnan(z)) {
xy_pos_t rpos = { bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) };
incremental_LSF(&lsf_results, rpos, bedlevel.z_values[x][y]);
incremental_LSF(&lsf_results, rpos, z);
}
}

Expand Down Expand Up @@ -199,8 +200,8 @@ float BedLevelTools::getMinValue() {
// Return 'true' if mesh is good and within LCD limits
bool BedLevelTools::meshValidate() {
GRID_LOOP(x, y) {
const float v = bedlevel.z_values[x][y];
if (isnan(v) || !WITHIN(v, Z_OFFSET_MIN, Z_OFFSET_MAX)) return false;
const float z = bedlevel.z_values[x][y];
if (isnan(z) || !WITHIN(z, Z_OFFSET_MIN, Z_OFFSET_MAX)) return false;
}
return true;
}
Expand Down Expand Up @@ -232,46 +233,49 @@ bool BedLevelTools::meshValidate() {
const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width;
const auto start_y_px = padding_y_top + ((GRID_MAX_POINTS_Y) - y - 1) * cell_height_px;
const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width;
dwinDrawRectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
isnan(bedlevel.z_values[x][y]) ? COLOR_GREY : ( // gray if undefined
(bedlevel.z_values[x][y] < 0 ?
(uint16_t)round(0x1F * -bedlevel.z_values[x][y] / rmax) << 11 : // red if mesh point value is negative
(uint16_t)round(0x3F * bedlevel.z_values[x][y] / rmax) << 5) | // green if mesh point value is positive
_MIN(0x1F, (((uint8_t)abs(bedlevel.z_values[x][y]) / 10) * 4))), // + blue stepping for every mm
start_x_px, start_y_px, end_x_px, end_y_px
const float z = bedlevel.z_values[x][y];
const uint16_t color = isnan(z) ? COLOR_GREY : ( // Gray if undefined
(z < 0 ? uint16_t(round(0x1F * -z / rmax)) << 11 // Red for negative mesh point
: uint16_t(round(0x3F * z / rmax)) << 5) // Green for positive mesh point
| _MIN(0x1F, (uint8_t(abs(z) * 0.4))) // + Blue stepping for every mm
);

dwinDrawRectangle(1, color, start_x_px, start_y_px, end_x_px, end_y_px);

safe_delay(10);
LCD_SERIAL.flushTX();

// Draw value text on
if (!viewer_print_value) continue;

const uint8_t fs = DWINUI::fontWidth(meshfont);
if (viewer_print_value) {
const int8_t offset_y = cell_height_px / 2 - fs;
if (isnan(bedlevel.z_values[x][y])) { // undefined
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
}
else { // has value
MString<12> msg;
if ((GRID_MAX_POINTS_X) < TERN(TJC_DISPLAY, 8, 10))
msg.set(p_float_t(abs(bedlevel.z_values[x][y]), 2));
else
msg.setf(F("%02i"), uint16_t(abs(bedlevel.z_values[x][y] - int16_t(bedlevel.z_values[x][y])) * 100));
const int8_t offset_x = cell_width_px / 2 - (fs / 2) * msg.length() - 2;
if ((GRID_MAX_POINTS_X) >= TERN(TJC_DISPLAY, 8, 10))
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px - 2 + offset_x, start_y_px + offset_y, F("."));
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + 1 + offset_x, start_y_px + offset_y, msg);
}
safe_delay(10);
LCD_SERIAL.flushTX();
const int8_t offset_y = cell_height_px / 2 - fs;
if (isnan(z)) { // undefined
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
}
}
else { // has value
MString<12> msg;
constexpr bool is_wide = (GRID_MAX_POINTS_X) >= TERN(TJC_DISPLAY, 8, 10);
if (is_wide)
msg.setf(F("%02i"), uint16_t(z * 100) % 100);
else
msg.set(p_float_t(abs(z), 2));
const int8_t offset_x = cell_width_px / 2 - (fs / 2) * msg.length() - 2;
if (is_wide)
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px - 2 + offset_x, start_y_px + offset_y, F("."));
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + 1 + offset_x, start_y_px + offset_y, msg);
}

safe_delay(10);
LCD_SERIAL.flushTX();

} // GRID_LOOP
}

void BedLevelTools::setMeshViewerStatus() { // TODO: draw gradient with values as a legend instead
float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), rmax = _MAX(v_min, v_max), rmin = _MIN(v_min, v_max);
if (rmax > 3e+10f) rmax = 0.0000001;
if (rmin > 3e+10f) rmin = 0.0000001;
if (rmax > 3e+10f) rmax = 0.0000001f;
if (rmin > 3e+10f) rmin = 0.0000001f;
ui.set_status(&MString<47>(F("Red "), p_float_t(-rmax, 3), F("..0.."), p_float_t(rmin, 3), F(" Green")));
drawing_mesh = false;
}
Expand Down
33 changes: 13 additions & 20 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void ICON_Button(const bool selected, const int iconid, const frame_rect_t &ico,
//
void ICON_Print() {
constexpr frame_rect_t ico = { 17, 110, 110, 100 };
constexpr text_info_t txt = { 1, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 };
constexpr text_info_t txt = { 1, { 405, 447 }, 27, 15 };
ICON_Button(select_page.now == PAGE_PRINT, ICON_Print_0, ico, txt, GET_TEXT_F(MSG_BUTTON_PRINT));
}

Expand All @@ -345,7 +345,7 @@ void ICON_Print() {
//
void ICON_Prepare() {
constexpr frame_rect_t ico = { 145, 110, 110, 100 };
constexpr text_info_t txt = { 31, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 };
constexpr text_info_t txt = { 31, { 405, 447 }, 27, 15 };
ICON_Button(select_page.now == PAGE_PREPARE, ICON_Prepare_0, ico, txt, GET_TEXT_F(MSG_PREPARE));
}

Expand All @@ -354,7 +354,7 @@ void ICON_Prepare() {
//
void ICON_Control() {
constexpr frame_rect_t ico = { 17, 226, 110, 100 };
constexpr text_info_t txt = { 61, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 };
constexpr text_info_t txt = { 61, { 405, 447 }, 27, 15 };
ICON_Button(select_page.now == PAGE_CONTROL, ICON_Control_0, ico, txt, GET_TEXT_F(MSG_CONTROL));
}

Expand All @@ -363,7 +363,7 @@ void ICON_Control() {
//
void ICON_AdvSettings() {
constexpr frame_rect_t ico = { 145, 226, 110, 100 };
constexpr text_info_t txt = { 91, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 };
constexpr text_info_t txt = { 91, { 405, 447 }, 27, 15 };
ICON_Button(select_page.now == PAGE_ADVANCE, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_ADVANCED));
}

Expand All @@ -372,7 +372,7 @@ void ICON_AdvSettings() {
//
void ICON_Tune() {
constexpr frame_rect_t ico = { 8, 232, 80, 100 };
constexpr text_info_t txt = { 121, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 };
constexpr text_info_t txt = { 121, { 405, 447 }, 27, 15 };
ICON_Button(select_print.now == PRINT_SETUP, ICON_Setup_0, ico, txt, GET_TEXT_F(MSG_TUNE));
}

Expand All @@ -381,7 +381,7 @@ void ICON_Tune() {
//
void ICON_Pause() {
constexpr frame_rect_t ico = { 96, 232, 80, 100 };
constexpr text_info_t txt = { 181, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 };
constexpr text_info_t txt = { 181, { 405, 447 }, 27, 15 };
ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Pause_0, ico, txt, GET_TEXT_F(MSG_BUTTON_PAUSE));
}

Expand All @@ -390,7 +390,7 @@ void ICON_Pause() {
//
void ICON_Resume() {
constexpr frame_rect_t ico = { 96, 232, 80, 100 };
constexpr text_info_t txt = { 1, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 };
constexpr text_info_t txt = { 1, { 405, 447 }, 27, 15 };
ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Continue_0, ico, txt, GET_TEXT_F(MSG_BUTTON_RESUME));
}

Expand All @@ -399,7 +399,7 @@ void ICON_Resume() {
//
void ICON_Stop() {
constexpr frame_rect_t ico = { 184, 232, 80, 100 };
constexpr text_info_t txt = { 151, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 12 };
constexpr text_info_t txt = { 151, { 405, 447 }, 27, 12 };
ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt, GET_TEXT_F(MSG_BUTTON_STOP));
}

Expand Down Expand Up @@ -482,8 +482,7 @@ void dwinResetStatusLine() {
// Djb2 hash algorithm
uint32_t getHash(char * str) {
uint32_t hash = 5381;
char c;
while ((c = *str++)) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
for (char c; (c = *str++);) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}

Expand Down Expand Up @@ -1943,13 +1942,7 @@ void dwinRedrawScreen() {
case PAUSE_MESSAGE_INSERT: dwinPopupPause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT), BTN_Continue); break;
case PAUSE_MESSAGE_LOAD: dwinPopupPause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break;
case PAUSE_MESSAGE_UNLOAD: dwinPopupPause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702
case PAUSE_MESSAGE_PURGE:
#if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
dwinPopupPause(GET_TEXT_F(MSG_FILAMENT_CHANGE_CONT_PURGE));
#else
dwinPopupPause(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE));
#endif
break;
case PAUSE_MESSAGE_PURGE: dwinPopupPause(GET_TEXT_F(TERN(ADVANCED_PAUSE_CONTINUOUS_PURGE, MSG_FILAMENT_CHANGE_CONT_PURGE, MSG_FILAMENT_CHANGE_PURGE))); break;
case PAUSE_MESSAGE_OPTION: gotoFilamentPurge(); break;
case PAUSE_MESSAGE_RESUME: dwinPopupPause(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break;
case PAUSE_MESSAGE_HEAT: dwinPopupPause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), BTN_Continue); break;
Expand Down Expand Up @@ -3141,7 +3134,7 @@ void drawControlMenu() {
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, writeEEPROM);
MENU_ITEM(ICON_ReadEEPROM, MSG_LOAD_EEPROM, onDrawReadEeprom, readEEPROM);
MENU_ITEM(ICON_ResumeEEPROM, MSG_RESTORE_DEFAULTS, onDrawResetEeprom, resetEEPROM);
MENU_ITEM(ICON_ResetEEPROM, MSG_RESTORE_DEFAULTS, onDrawResetEeprom, resetEEPROM);
#endif
MENU_ITEM(ICON_Reboot, MSG_RESET_PRINTER, onDrawMenuItem, rebootPrinter);
MENU_ITEM(ICON_Info, MSG_INFO_SCREEN, onDrawInfoSubMenu, gotoInfoMenu);
Expand Down Expand Up @@ -3957,8 +3950,8 @@ void drawStepsMenu() {
if (SET_MENU(zOffsetWizMenu, MSG_PROBE_WIZARD, 4)) {
BACK_ITEM(drawPrepareMenu);
MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, autoHome);
MENU_ITEM_F(ICON_MoveZ0, "Move Z to Home", onDrawMenuItem, setMoveZto0);
EDIT_ITEM(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, setZOffset, &BABY_Z_VAR);
MENU_ITEM(ICON_MoveZ0, MSG_MOVE_NOZZLE_TO_BED, onDrawMenuItem, setMoveZto0);
EDIT_ITEM(ICON_Zoffset, MSG_XATC_UPDATE_Z_OFFSET, onDrawPFloat2Menu, setZOffset, &BABY_Z_VAR);
}
updateMenu(zOffsetWizMenu);
if (!axis_is_trusted(Z_AXIS)) LCD_MESSAGE_F("WARNING: Z position unknown, move Z to home");
Expand Down
Loading

0 comments on commit 0f09554

Please sign in to comment.