Skip to content

Commit

Permalink
🐛 Fix, improve E3V2 Enhanced UI (MarlinFirmware#22733)
Browse files Browse the repository at this point in the history
  • Loading branch information
mriscoc authored and mh-dm committed May 15, 2022
1 parent caadbdc commit acdede6
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 103 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
158 changes: 88 additions & 70 deletions Marlin/src/lcd/e3v2/enhanced/dwin.cpp

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions Marlin/src/lcd/e3v2/enhanced/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 9 additions & 3 deletions Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
********************************************************************************/

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ----------------------------------------*/

Expand Down
9 changes: 6 additions & 3 deletions Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
********************************************************************************/

Expand Down Expand Up @@ -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
Expand All @@ -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 ----------------------------------------*/

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/e3v2/enhanced/dwinui.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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("-"));
Expand Down
35 changes: 18 additions & 17 deletions Marlin/src/lcd/e3v2/enhanced/dwinui.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit acdede6

Please sign in to comment.