Skip to content

Commit

Permalink
🚸 Fix up E3V2 Enhanced (#23100)
Browse files Browse the repository at this point in the history
  • Loading branch information
mriscoc authored and thinkyhead committed Dec 25, 2021
1 parent 7f4a49c commit 3cccb21
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 104 deletions.
1 change: 0 additions & 1 deletion Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)));
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR)));
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR)));
wait_for_user = true; // A click or M108 breaks the purge_length loop
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
Expand Down
106 changes: 53 additions & 53 deletions Marlin/src/lcd/e3v2/enhanced/dwin.cpp

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Marlin/src/lcd/e3v2/enhanced/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.6.3
* Date: 2021/09/08
* Version: 3.7.1
* Date: 2021/11/09
*/

#include "../../../inc/MarlinConfigPre.h"
Expand Down Expand Up @@ -154,6 +154,7 @@ void HMI_SDCardUpdate();
// Other
void Goto_PrintProcess();
void Goto_Main_Menu();
void Goto_InfoMenu();
void Draw_Select_Highlight(const bool sel);
void Draw_Status_Area(const bool with_update); // Status Area
void Draw_Main_Area(); // Redraw main area;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.6.3
* Date: 2021/09/08
* Version: 3.7.1
* Date: 2021/11/09
*/

#include "../../../inc/MarlinConfigPre.h"
Expand Down
11 changes: 2 additions & 9 deletions Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.6.3
* Date: 2021/09/08
* Version: 3.7.1
* Date: 2021/11/09
*/

#include "../common/dwin_api.h"
Expand All @@ -48,13 +48,6 @@ inline void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, FSTR_P title)
// x/y: Screen paste point
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);

// Copy area from virtual display area to current screen
// cacheID: virtual area number
// xStart/yStart: Upper-left of virtual area
// xEnd/yEnd: Lower-right of virtual area
// x/y: Screen paste point
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);

// Copy area from current virtual display area to current screen
// xStart/yStart: Upper-left of virtual area
// xEnd/yEnd: Lower-right of virtual area
Expand Down
18 changes: 9 additions & 9 deletions Marlin/src/lcd/e3v2/enhanced/dwinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.6.3
* Date: 2021/09/08
* Version: 3.7.1
* Date: 2021/11/09
*/

#include "../../../inc/MarlinConfigPre.h"
Expand All @@ -38,8 +38,8 @@
//#define DEBUG_OUT 1
#include "../../../core/debug_out.h"

uint8_t MenuItemTotal = 0;
uint8_t MenuItemCount = 0;
int8_t MenuItemTotal = 0;
int8_t MenuItemCount = 0;
MenuItemClass** MenuItems = nullptr;
MenuClass *CurrentMenu = nullptr;
MenuClass *PreviousMenu = nullptr;
Expand All @@ -50,8 +50,8 @@ uint16_t DWINUI::textcolor = Def_Text_Color;
uint16_t DWINUI::backcolor = Def_Background_Color;
uint8_t DWINUI::font = font8x16;

void (*DWINUI::onCursorErase)(uint8_t line)=nullptr;
void (*DWINUI::onCursorDraw)(uint8_t line)=nullptr;
void (*DWINUI::onCursorErase)(const int8_t line)=nullptr;
void (*DWINUI::onCursorDraw)(const int8_t line)=nullptr;
void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr;
void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr;

Expand Down Expand Up @@ -304,14 +304,14 @@ void DWINUI::ClearMenuArea() {

void DWINUI::MenuItemsClear() {
if (MenuItems == nullptr) return;
for (uint8_t i = 0; i < MenuItemCount; i++) delete MenuItems[i];
for (int8_t i = 0; i < MenuItemCount; i++) delete MenuItems[i];
delete[] MenuItems;
MenuItems = nullptr;
MenuItemCount = 0;
MenuItemTotal = 0;
}

void DWINUI::MenuItemsPrepare(uint8_t totalitems) {
void DWINUI::MenuItemsPrepare(int8_t totalitems) {
MenuItemsClear();
MenuItemTotal = totalitems;
MenuItems = new MenuItemClass*[totalitems];
Expand Down Expand Up @@ -379,7 +379,7 @@ MenuClass::MenuClass() {
void MenuClass::draw() {
MenuTitle.draw();
if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this);
for (uint8_t i = 0; i < MenuItemCount; i++)
for (int8_t i = 0; i < MenuItemCount; i++)
MenuItems[i]->draw(i - topline);
if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
DWIN_UpdateLCD();
Expand Down
37 changes: 21 additions & 16 deletions Marlin/src/lcd/e3v2/enhanced/dwinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.6.3
* Date: 2021/09/08
* Version: 3.7.1
* Date: 2021/11/09
*/

#include "../../../core/types.h"
#include "dwin_lcd.h"
#include "../common/dwin_set.h"
#include "../common/dwin_font.h"
Expand Down Expand Up @@ -138,7 +137,7 @@ extern TitleClass Title;
class MenuItemClass {
protected:
public:
uint8_t pos = 0;
int8_t pos = 0;
uint8_t icon = 0;
char caption[32] = "";
uint8_t frameid = 0;
Expand Down Expand Up @@ -185,8 +184,8 @@ namespace DWINUI {
extern uint16_t backcolor;
extern uint8_t font;

extern void (*onCursorErase)(uint8_t line);
extern void (*onCursorDraw)(uint8_t line);
extern void (*onCursorErase)(const int8_t line);
extern void (*onCursorDraw)(const int8_t line);
extern void (*onTitleDraw)(TitleClass* title);
extern void (*onMenuDraw)(MenuClass* menu);

Expand Down Expand Up @@ -342,6 +341,12 @@ namespace DWINUI {
// rlimit: For draw less chars than string length use rlimit
void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF);
void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF);
inline void Draw_String(FSTR_P string, uint16_t rlimit = 0xFFFF) {
Draw_String(FTOP(string), rlimit);
}
inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) {
Draw_String(color, FTOP(string), rlimit);
}

// Draw a string
// size: Font size
Expand All @@ -353,25 +358,25 @@ namespace DWINUI {
DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string);
}
inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) {
DWIN_Draw_String(false, font, textcolor, backcolor, x, y, (char *)title);
DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title));
}
inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) {
DWIN_Draw_String(false, font, color, backcolor, x, y, string);
}
inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) {
DWIN_Draw_String(false, font, color, backcolor, x, y, (char *)title);
DWIN_Draw_String(false, font, color, backcolor, x, y, title);
}
inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
DWIN_Draw_String(true, font, color, bgcolor, x, y, string);
}
inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
DWIN_Draw_String(true, font, color, bgcolor, x, y, (char *)title);
DWIN_Draw_String(true, font, color, bgcolor, x, y, title);
}
inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
DWIN_Draw_String(true, size, color, bgcolor, x, y, string);
}
inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
DWIN_Draw_String(true, size, color, bgcolor, x, y, (char *)title);
DWIN_Draw_String(true, size, color, bgcolor, x, y, title);
}

// Draw a centered string using DWIN_WIDTH
Expand All @@ -382,8 +387,8 @@ namespace DWINUI {
// y: Upper coordinate of the string
// *string: The string
void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string);
inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P title) {
Draw_CenteredString(bShow, size, color, bColor, y, (char *)title);
inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) {
Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string));
}
inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) {
Draw_CenteredString(true, font, color, bcolor, y, string);
Expand All @@ -392,19 +397,19 @@ namespace DWINUI {
Draw_CenteredString(false, size, color, backcolor, y, string);
}
inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) {
Draw_CenteredString(false, size, color, backcolor, y, (char *)title);
Draw_CenteredString(false, size, color, backcolor, y, title);
}
inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) {
Draw_CenteredString(false, font, color, backcolor, y, string);
}
inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) {
Draw_CenteredString(false, font, color, backcolor, y, (char *)title);
Draw_CenteredString(false, font, color, backcolor, y, title);
}
inline void Draw_CenteredString(uint16_t y, const char * const string) {
Draw_CenteredString(false, font, textcolor, backcolor, y, string);
}
inline void Draw_CenteredString(uint16_t y, FSTR_P title) {
Draw_CenteredString(false, font, textcolor, backcolor, y, (char *)title);
Draw_CenteredString(false, font, textcolor, backcolor, y, title);
}

// Draw a circle
Expand Down Expand Up @@ -477,7 +482,7 @@ namespace DWINUI {
void MenuItemsClear();

// Prepare MenuItems array
void MenuItemsPrepare(uint8_t totalitems);
void MenuItemsPrepare(int8_t totalitems);

// Add elements to the MenuItems array
MenuItemClass* MenuItemsAdd(MenuItemClass* menuitem);
Expand Down
41 changes: 34 additions & 7 deletions Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* DWIN Mesh Viewer
* Author: Miguel A. Risco-Castillo
* version: 2.5
* Date: 2021/09/27
* version: 3.8.1
* Date: 2021/11/06
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand Down Expand Up @@ -35,13 +35,15 @@
MeshViewerClass MeshViewer;

void MeshViewerClass::Draw() {
const int8_t mx = 30, my = 30; // Margins
const int8_t mx = 25, my = 25; // Margins
const int16_t stx = (DWIN_WIDTH - 2 * mx) / (GRID_MAX_POINTS_X - 1), // Steps
sty = (DWIN_WIDTH - 2 * my) / (GRID_MAX_POINTS_Y - 1);
int8_t zmesh[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y], maxz =-127, minz = 127;
const int8_t rmax = _MIN(mx - 2, stx / 2);
const int8_t rmin = 7;
int16_t zmesh[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y], maxz =-32000, minz = 32000;
#define px(xp) (mx + (xp) * stx)
#define py(yp) (30 + DWIN_WIDTH - my - (yp) * sty)
#define rm(z) ((((z) - minz) * 10 / _MAX(1, (maxz - minz))) + 10)
#define rm(z) ((z - minz) * (rmax - rmin) / _MAX(1, (maxz - minz)) + rmin)
#define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 12, py(yp) - 6, zv)
#define DrawMeshHLine(yp) DWIN_Draw_HLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx)
#define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(GRID_MAX_POINTS_Y - 1), DWIN_WIDTH - 2 * my)
Expand All @@ -61,8 +63,33 @@ void MeshViewerClass::Draw() {
watchdog_refresh();
LOOP_L_N(x, GRID_MAX_POINTS_X) {
uint16_t color = DWINUI::RainbowInt(zmesh[x][y], _MIN(-5, minz), _MAX(5, maxz));
DWINUI::Draw_FillCircle(color, px(x), py(y), rm(zmesh[x][y]));
DrawMeshValue(x, y, Z_VALUES(x,y));
uint8_t radius = rm(zmesh[x][y]);
DWINUI::Draw_FillCircle(color, px(x), py(y), radius);
if (GRID_MAX_POINTS_X < 9)
DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 12, py(y) - 6, Z_VALUES(x,y));
else {
char str_1[9];
str_1[0] = 0;
switch (zmesh[x][y]) {
case -999 ... -100:
DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y));
break;
case -99 ... -1:
sprintf_P(str_1, PSTR("-.%02i"), -zmesh[x][y]);
break;
case 0:
DWIN_Draw_String(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, py(y) - 6, "0");;
break;
case 1 ... 99:
sprintf_P(str_1, PSTR(".%02i"), zmesh[x][y]);
break;
case 100 ... 999:
DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y));
break;
}
if (str_1[0])
DWIN_Draw_String(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 12, py(y) - 6, str_1);
}
}
}
char str_1[6], str_2[6] = "";
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/enhanced/meshviewer.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* DWIN Mesh Viewer
* Author: Miguel A. Risco-Castillo
* version: 2.5
* Date: 2021/09/27
* Version: 3.8.1
* Date: 2021/11/06
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3044,8 +3044,6 @@ void MarlinSettings::reset() {
postprocess();

DEBUG_ECHO_MSG("Hardcoded Default Settings Loaded");

TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset());
}

#if DISABLED(DISABLE_M503)
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3750,8 +3750,9 @@ void Temperature::isr() {
HMI_flag.heat_flag = 0;
duration_t elapsed = print_job_timer.duration(); // print timer
dwin_heat_time = elapsed.value;
#else
ui.reset_status();
#endif
ui.reset_status();
TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onHeatingDone());
return true;
}
Expand Down

0 comments on commit 3cccb21

Please sign in to comment.