🐛 Fix MarlinUI on Ender 3 S1 (#23949)
This commit is contained in:
committed by
Scott Lahteine
parent
bb0e0cf7f3
commit
5c5b380fda
@ -25,6 +25,7 @@
|
||||
|
||||
#include "dwin_api.h"
|
||||
#include "dwin_set.h"
|
||||
#include "dwin_font.h"
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
@ -89,6 +90,40 @@ bool DWIN_Handshake() {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get font character width
|
||||
uint8_t fontWidth(uint8_t cfont) {
|
||||
switch (cfont) {
|
||||
case font6x12 : return 6;
|
||||
case font8x16 : return 8;
|
||||
case font10x20: return 10;
|
||||
case font12x24: return 12;
|
||||
case font14x28: return 14;
|
||||
case font16x32: return 16;
|
||||
case font20x40: return 20;
|
||||
case font24x48: return 24;
|
||||
case font28x56: return 28;
|
||||
case font32x64: return 32;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Get font character height
|
||||
uint8_t fontHeight(uint8_t cfont) {
|
||||
switch (cfont) {
|
||||
case font6x12 : return 12;
|
||||
case font8x16 : return 16;
|
||||
case font10x20: return 20;
|
||||
case font12x24: return 24;
|
||||
case font14x28: return 28;
|
||||
case font16x32: return 32;
|
||||
case font20x40: return 40;
|
||||
case font24x48: return 48;
|
||||
case font28x56: return 56;
|
||||
case font32x64: return 64;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Set screen display direction
|
||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
||||
void DWIN_Frame_SetDir(uint8_t dir) {
|
||||
@ -199,6 +234,8 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
||||
// *string: The string
|
||||
// rlimit: To limit the drawn string length
|
||||
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) {
|
||||
DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size));
|
||||
DWIN_UpdateLCD();
|
||||
constexpr uint8_t widthAdjust = 0;
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x11);
|
||||
@ -213,6 +250,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor,
|
||||
DWIN_Word(i, y);
|
||||
DWIN_Text(i, string, rlimit);
|
||||
DWIN_Send(i);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
// Draw a positive integer
|
||||
@ -228,6 +266,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor,
|
||||
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, uint32_t value) {
|
||||
size_t i = 0;
|
||||
DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size));
|
||||
DWIN_Byte(i, 0x14);
|
||||
// Bit 7: bshow
|
||||
// Bit 6: 1 = signed; 0 = unsigned number;
|
||||
@ -258,6 +297,7 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t
|
||||
#endif
|
||||
|
||||
DWIN_Send(i);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
// Draw a floating point number
|
||||
@ -275,6 +315,7 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
|
||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
|
||||
//uint8_t *fvalue = (uint8_t*)&value;
|
||||
size_t i = 0;
|
||||
DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size));
|
||||
DWIN_Byte(i, 0x14);
|
||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
||||
DWIN_Word(i, color);
|
||||
@ -291,6 +332,7 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
|
||||
DWIN_Byte(i, fvalue[0]);
|
||||
*/
|
||||
DWIN_Send(i);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
// Draw a floating point number
|
||||
|
Reference in New Issue
Block a user