🎨 Consolidate Ender-3 V2 DWIN common code (#22778)

This commit is contained in:
Scott Lahteine
2021-09-15 19:48:29 -05:00
committed by Scott Lahteine
parent 5b593da04d
commit e705a7724e
39 changed files with 1512 additions and 4078 deletions

View File

@ -37,89 +37,9 @@
//#define DEBUG_OUT 1
#include "../../../core/debug_out.h"
// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
uint8_t databuf[26] = { 0 };
uint8_t receivedType;
int recnum = 0;
inline void DWIN_Byte(size_t &i, const uint16_t bval) {
DWIN_SendBuf[++i] = bval;
}
inline void DWIN_Word(size_t &i, const uint16_t wval) {
DWIN_SendBuf[++i] = wval >> 8;
DWIN_SendBuf[++i] = wval & 0xFF;
}
inline void DWIN_Long(size_t &i, const uint32_t lval) {
DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
DWIN_SendBuf[++i] = (lval >> 8) & 0xFF;
DWIN_SendBuf[++i] = lval & 0xFF;
}
inline void DWIN_String(size_t &i, char * const string) {
const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string));
memcpy(&DWIN_SendBuf[i+1], string, len);
i += len;
}
inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
if (!string) return;
const size_t len = strlen_P((PGM_P)string); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
if (len == 0) return;
memcpy(&DWIN_SendBuf[i+1], string, len);
i += len;
}
// Send the data in the buffer and the packet end
inline void DWIN_Send(size_t &i) {
++i;
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
}
/*-------------------------------------- System variable function --------------------------------------*/
// Handshake (1: Success, 0: Fail)
bool DWIN_Handshake(void) {
#ifndef LCD_BAUDRATE
#define LCD_BAUDRATE 115200
#endif
LCD_SERIAL.begin(LCD_BAUDRATE);
const millis_t serial_connect_timeout = millis() + 1000UL;
while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
size_t i = 0;
DWIN_Byte(i, 0x00);
DWIN_Send(i);
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
databuf[recnum] = LCD_SERIAL.read();
// ignore the invalid data
if (databuf[0] != FHONE) { // prevent the program from running.
if (recnum > 0) {
recnum = 0;
ZERO(databuf);
}
continue;
}
delay(10);
recnum++;
}
return ( recnum >= 3
&& databuf[0] == FHONE
&& databuf[1] == '\0'
&& databuf[2] == 'O'
&& databuf[3] == 'K' );
}
void DWIN_Startup(void) {
void DWIN_Startup() {
DEBUG_ECHOPGM("\r\nDWIN handshake ");
delay(750); // Delay here or init later in the boot process
const bool success = DWIN_Handshake();
@ -129,342 +49,14 @@ void DWIN_Startup(void) {
DWIN_UpdateLCD();
}
// Set the backlight luminance
// luminance: (0x00-0xFF)
void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
size_t i = 0;
DWIN_Byte(i, 0x30);
DWIN_Byte(i, _MAX(luminance, 0x1F));
DWIN_Send(i);
}
// Set screen display direction
// dir: 0=0°, 1=90°, 2=180°, 3=270°
void DWIN_Frame_SetDir(uint8_t dir) {
size_t i = 0;
DWIN_Byte(i, 0x34);
DWIN_Byte(i, 0x5A);
DWIN_Byte(i, 0xA5);
DWIN_Byte(i, dir);
DWIN_Send(i);
}
// Update display
void DWIN_UpdateLCD(void) {
size_t i = 0;
DWIN_Byte(i, 0x3D);
DWIN_Send(i);
}
/*---------------------------------------- Drawing functions ----------------------------------------*/
// Clear screen
// color: Clear screen color
void DWIN_Frame_Clear(const uint16_t color) {
size_t i = 0;
DWIN_Byte(i, 0x01);
DWIN_Word(i, color);
DWIN_Send(i);
}
// Draw a point
// width: point width 0x01-0x0F
// height: point height 0x01-0x0F
// x,y: upper left point
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
size_t i = 0;
DWIN_Byte(i, 0x02);
DWIN_Word(i, color);
DWIN_Byte(i, width);
DWIN_Byte(i, height);
DWIN_Word(i, x);
DWIN_Word(i, y);
DWIN_Send(i);
}
// Draw a line
// color: Line segment color
// xStart/yStart: Start point
// xEnd/yEnd: End point
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
size_t i = 0;
DWIN_Byte(i, 0x03);
DWIN_Word(i, color);
DWIN_Word(i, xStart);
DWIN_Word(i, yStart);
DWIN_Word(i, xEnd);
DWIN_Word(i, yEnd);
DWIN_Send(i);
}
// Draw a rectangle
// mode: 0=frame, 1=fill, 2=XOR fill
// color: Rectangle color
// xStart/yStart: upper left point
// xEnd/yEnd: lower right point
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
size_t i = 0;
DWIN_Byte(i, 0x05);
DWIN_Byte(i, mode);
DWIN_Word(i, color);
DWIN_Word(i, xStart);
DWIN_Word(i, yStart);
DWIN_Word(i, xEnd);
DWIN_Word(i, yEnd);
DWIN_Send(i);
}
// Move a screen area
// mode: 0, circle shift; 1, translation
// dir: 0=left, 1=right, 2=up, 3=down
// dis: Distance
// color: Fill color
// xStart/yStart: upper left point
// xEnd/yEnd: bottom right point
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
size_t i = 0;
DWIN_Byte(i, 0x09);
DWIN_Byte(i, (mode << 7) | dir);
DWIN_Word(i, dis);
DWIN_Word(i, color);
DWIN_Word(i, xStart);
DWIN_Word(i, yStart);
DWIN_Word(i, xEnd);
DWIN_Word(i, yEnd);
DWIN_Send(i);
}
/*---------------------------------------- Text related functions ----------------------------------------*/
// Draw a string
// bShow: true=display background color; false=don't display background color
// size: Font size
// color: Character color
// bColor: Background color
// x/y: Upper-left coordinate of the string
// *string: The string
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) {
uint8_t widthAdjust = 0;
size_t i = 0;
DWIN_Byte(i, 0x11);
// Bit 7: widthAdjust
// Bit 6: bShow
// Bit 5-4: Unused (0)
// Bit 3-0: size
DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
DWIN_Word(i, color);
DWIN_Word(i, bColor);
DWIN_Word(i, x);
DWIN_Word(i, y);
DWIN_String(i, string);
DWIN_Send(i);
}
// Draw a positive integer
// bShow: true=display background color; false=don't display background color
// zeroFill: true=zero fill; false=no zero fill
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
// size: Font size
// color: Character color
// bColor: Background color
// iNum: Number of digits
// 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) {
size_t i = 0;
DWIN_Byte(i, 0x14);
// Bit 7: bshow
// Bit 6: 1 = signed; 0 = unsigned number;
// Bit 5: zeroFill
// Bit 4: zeroMode
// Bit 3-0: size
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
DWIN_Word(i, color);
DWIN_Word(i, bColor);
DWIN_Byte(i, iNum);
DWIN_Byte(i, 0); // fNum
DWIN_Word(i, x);
DWIN_Word(i, y);
#if 0
for (char count = 0; count < 8; count++) {
DWIN_Byte(i, value);
value >>= 8;
if (!(value & 0xFF)) break;
}
#else
// Write a big-endian 64 bit integer
const size_t p = i + 1;
for (char count = 8; count--;) { // 7..0
++i;
DWIN_SendBuf[p + count] = value;
value >>= 8;
}
#endif
DWIN_Send(i);
}
// Draw a floating point number
// bShow: true=display background color; false=don't display background color
// zeroFill: true=zero fill; false=no zero fill
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
// size: Font size
// color: Character color
// bColor: Background color
// iNum: Number of whole digits
// fNum: Number of decimal digits
// x/y: Upper-left point
// value: 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) {
//uint8_t *fvalue = (uint8_t*)&value;
size_t i = 0;
DWIN_Byte(i, 0x14);
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
DWIN_Word(i, color);
DWIN_Word(i, bColor);
DWIN_Byte(i, iNum);
DWIN_Byte(i, fNum);
DWIN_Word(i, x);
DWIN_Word(i, y);
DWIN_Long(i, value);
/*
DWIN_Byte(i, fvalue[3]);
DWIN_Byte(i, fvalue[2]);
DWIN_Byte(i, fvalue[1]);
DWIN_Byte(i, fvalue[0]);
*/
DWIN_Send(i);
}
/*---------------------------------------- Picture related functions ----------------------------------------*/
// Draw JPG and cached in #0 virtual display area
// id: Picture ID
void DWIN_JPG_ShowAndCache(const uint8_t id) {
size_t i = 0;
DWIN_Word(i, 0x2200);
DWIN_Byte(i, id);
DWIN_Send(i); // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
}
// Draw an Icon
// libID: Icon library ID
// picID: Icon ID
// x/y: Upper-left point
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
NOMORE(x, DWIN_WIDTH - 1);
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
size_t i = 0;
DWIN_Byte(i, 0x23);
DWIN_Word(i, x);
DWIN_Word(i, y);
DWIN_Byte(i, 0x80 | libID);
//DWIN_Byte(i, libID);
DWIN_Byte(i, picID);
DWIN_Send(i);
DWIN_ICON_Show(true, false, false, libID, picID, x, y);
}
// Unzip the JPG picture to a virtual display area
// n: Cache index
// id: Picture ID
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
size_t i = 0;
DWIN_Byte(i, 0x25);
DWIN_Byte(i, n);
DWIN_Byte(i, id);
DWIN_Send(i);
}
// 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) {
size_t i = 0;
DWIN_Byte(i, 0x27);
DWIN_Byte(i, 0x80 | cacheID);
DWIN_Word(i, xStart);
DWIN_Word(i, yStart);
DWIN_Word(i, xEnd);
DWIN_Word(i, yEnd);
DWIN_Word(i, x);
DWIN_Word(i, y);
DWIN_Send(i);
}
// Animate a series of icons
// animID: Animation ID; 0x00-0x0F
// animate: true on; false off;
// libID: Icon library ID
// picIDs: Icon starting ID
// picIDe: Icon ending ID
// x/y: Upper-left point
// interval: Display time interval, unit 10mS
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
NOMORE(x, DWIN_WIDTH - 1);
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
size_t i = 0;
DWIN_Byte(i, 0x28);
DWIN_Word(i, x);
DWIN_Word(i, y);
// Bit 7: animation on or off
// Bit 6: start from begin or end
// Bit 5-4: unused (0)
// Bit 3-0: animID
DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
DWIN_Byte(i, libID);
DWIN_Byte(i, picIDs);
DWIN_Byte(i, picIDe);
DWIN_Byte(i, interval);
DWIN_Send(i);
}
// Animation Control
// state: 16 bits, each bit is the state of an animation id
void DWIN_ICON_AnimationControl(uint16_t state) {
size_t i = 0;
DWIN_Byte(i, 0x29);
DWIN_Word(i, state);
DWIN_Send(i);
}
/*---------------------------------------- Memory functions ----------------------------------------*/
// The LCD has an additional 32KB SRAM and 16KB Flash
// Data can be written to the sram and save to one of the jpeg page files
// Write Data Memory
// command 0x31
// Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
// Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
// Data: data
//
// Flash writing returns 0xA5 0x4F 0x4B
// Read Data Memory
// command 0x32
// Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
// Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
// Length: leangth of data to read; 0x01-0xF0
//
// Response:
// Type, Address, Length, Data
// Write Picture Memory
// Write the contents of the 32KB SRAM data memory into the designated image memory space
// Issued: 0x5A, 0xA5, PIC_ID
// Response: 0xA5 0x4F 0x4B
//
// command 0x33
// 0x5A, 0xA5
// PicId: Picture Memory location, 0x00-0x0F
//
// Flash writing returns 0xA5 0x4F 0x4B
#endif // IS_DWIN_MARLINUI

View File

@ -26,82 +26,30 @@
* @brief DWIN screen control functions
********************************************************************************/
#include <stdint.h>
#define RECEIVED_NO_DATA 0x00
#define RECEIVED_SHAKE_HAND_ACK 0x01
#define FHONE 0xAA
#define DWIN_SCROLL_UP 2
#define DWIN_SCROLL_DOWN 3
#if DISABLED(DWIN_MARLINUI_LANDSCAPE)
#define DWIN_WIDTH 272
#define DWIN_HEIGHT 480
#else
#if ENABLED(DWIN_MARLINUI_LANDSCAPE)
#define DWIN_WIDTH 480
#define DWIN_HEIGHT 272
#endif
#include "../common/dwin_api.h"
// Picture ID
#define DWIN_Boot_Horiz 0
#define DWIN_Boot_Vert 1
#define DWIN_MarlinUI_Assets 2
/**
* 3-.0The font size, 0x00-0x09, corresponds to the font size below:
* 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28
* 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
*/
#define font6x12 0x00
#define font8x16 0x01
#define font10x20 0x02
#define font12x24 0x03
#define font14x28 0x04
#define font16x32 0x05
#define font20x40 0x06
#define font24x48 0x07
#define font28x56 0x08
#define font32x64 0x09
#define DWIN_FONT_MENU font10x20
#define DWIN_FONT_STAT font14x28
#define DWIN_FONT_ALERT font14x28
// Color
#define Color_White 0xFFFF
#define Color_Yellow 0xFF0F
#define Color_Error_Red 0xB000 // Error!
#define Color_Bg_Red 0xF00F // Red background color
#define Color_Bg_Window 0x31E8 // Popup background color
#define Color_Bg_Heading 0x3344 // Static Heading
#define Color_Bg_Blue 0x1125 // Dark blue background color
#define Color_Bg_Black 0x0841 // Black background color
#define Color_IconBlue 0x45FA // Lighter blue that matches icons/accents
#define Popup_Text_Color 0xD6BA // Popup font background color
#define Line_Color 0x3A6A // Split line color
#define Rectangle_Color 0xEE2F // Blue square cursor color
#define Percent_Color 0xFE29 // Percentage color
#define BarFill_Color 0x10E4 // Fill color of progress bar
#define Select_Color 0x33BB // Selected color
// Character matrix width x height
//#define LCD_WIDTH ((DWIN_WIDTH) / 8)
//#define LCD_HEIGHT ((DWIN_HEIGHT) / 12)
// ICON ID
#define BOOT_ICON 3 // Icon set file 3.ICO
#define ICON 4 // Icon set file 4.ICO
// MarlinUI Boot Icons
// MarlinUI Boot Icons from Set 3
#define ICON_MarlinBoot 0
#define ICON_OpenSource 1
#define ICON_GitHubURL 2
#define ICON_MarlinURL 3
#define ICON_Copyright 4
// MarlinUI Icons
// MarlinUI Icons from Set 4
#define ICON_LOGO_Marlin 0
#define ICON_HotendOff 1
#define ICON_HotendOn 2
@ -120,182 +68,16 @@
#define ICON_DownArrow 15
#define ICON_BedLine 16
#define ICON_AdvSet ICON_Language
#define ICON_HomeOff ICON_AdvSet
#define ICON_HomeOffX ICON_StepX
#define ICON_HomeOffY ICON_StepY
#define ICON_HomeOffZ ICON_StepZ
#define ICON_ProbeOff ICON_AdvSet
#define ICON_ProbeOffX ICON_StepX
#define ICON_ProbeOffY ICON_StepY
#define ICON_PIDNozzle ICON_SetEndTemp
#define ICON_PIDbed ICON_SetBedTemp
#include "../common/dwin_font.h"
/*-------------------------------------- System variable function --------------------------------------*/
#define DWIN_FONT_MENU font10x20
#define DWIN_FONT_STAT font14x28
#define DWIN_FONT_ALERT font14x28
// Handshake (1: Success, 0: Fail)
bool DWIN_Handshake(void);
#include "../common/dwin_color.h"
// Common DWIN startup
void DWIN_Startup(void);
#define Color_Bg_Heading 0x3344 // Static Heading
// Set the backlight luminance
// luminance: (0x00-0xFF)
void DWIN_Backlight_SetLuminance(const uint8_t luminance);
// Set screen display direction
// dir: 0=0°, 1=90°, 2=180°, 3=270°
void DWIN_Frame_SetDir(uint8_t dir);
// Update display
void DWIN_UpdateLCD(void);
/*---------------------------------------- Drawing functions ----------------------------------------*/
// Clear screen
// color: Clear screen color
void DWIN_Frame_Clear(const uint16_t color);
// Draw a point
// color: point color
// width: point width 0x01-0x0F
// height: point height 0x01-0x0F
// x,y: upper left point
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
// Draw a line
// color: Line segment color
// xStart/yStart: Start point
// xEnd/yEnd: End point
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
// Draw a Horizontal line
// color: Line segment color
// xStart/yStart: Start point
// xLength: Line Length
inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
}
// Draw a Vertical line
// color: Line segment color
// xStart/yStart: Start point
// yLength: Line Length
inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
}
// Draw a rectangle
// mode: 0=frame, 1=fill, 2=XOR fill
// color: Rectangle color
// xStart/yStart: upper left point
// xEnd/yEnd: lower right point
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
// Draw a box
// mode: 0=frame, 1=fill, 2=XOR fill
// color: Rectangle color
// xStart/yStart: upper left point
// xSize/ySize: box size
inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
}
// Move a screen area
// mode: 0, circle shift; 1, translation
// dir: 0=left, 1=right, 2=up, 3=down
// dis: Distance
// color: Fill color
// xStart/yStart: upper left point
// xEnd/yEnd: bottom right point
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
/*---------------------------------------- Text related functions ----------------------------------------*/
// Draw a string
// bShow: true=display background color; false=don't display background color
// size: Font size
// color: Character color
// bColor: Background color
// x/y: Upper-left coordinate of the string
// *string: The string
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string);
class __FlashStringHelper;
inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
DWIN_Draw_String(bShow, size, color, bColor, x, y, (char *)title);
}
// Draw a positive integer
// bShow: true=display background color; false=don't display background color
// zeroFill: true=zero fill; false=no zero fill
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
// size: Font size
// color: Character color
// bColor: Background color
// iNum: Number of digits
// 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);
// Draw a floating point number
// bShow: true=display background color; false=don't display background color
// zeroFill: true=zero fill; false=no zero fill
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
// size: Font size
// color: Character color
// bColor: Background color
// iNum: Number of whole digits
// fNum: Number of decimal digits
// x/y: Upper-left point
// value: 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);
/*---------------------------------------- Picture related functions ----------------------------------------*/
// Draw JPG and cached in #0 virtual display area
// id: Picture ID
void DWIN_JPG_ShowAndCache(const uint8_t id);
// Draw an Icon
// libID: Icon library ID
// picID: Icon ID
// x/y: Upper-left point
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
// Unzip the JPG picture to a virtual display area
// n: Cache index
// id: Picture ID
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
// Unzip the JPG picture to virtual display area #1
// id: Picture ID
inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
// 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);
// Animate a series of icons
// animID: Animation ID up to 16
// animate: animation on or off
// libID: Icon library ID
// picIDs: Icon starting ID
// picIDe: Icon ending ID
// x/y: Upper-left point
// interval: Display time interval, unit 10mS
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
// Animation Control
// state: 16 bits, each bit is the state of an animation id
void DWIN_ICON_AnimationControl(uint16_t state);
// Character matrix width x height
//#define LCD_WIDTH ((DWIN_WIDTH) / 8)
//#define LCD_HEIGHT ((DWIN_HEIGHT) / 12)

View File

@ -21,12 +21,11 @@
*/
#pragma once
#include <stdint.h>
#include "../../fontutils.h"
#include "../../marlinui.h"
#include <stdint.h>
typedef struct _dwin_charmap_t {
wchar_t uchar; // the unicode char
uint8_t idx; // the glyph of the char in the ROM

View File

@ -83,7 +83,7 @@ void MarlinUI::init_lcd() {
DWIN_Startup();
// Load the assets JPG (currently just the status screen 'icon')
DWIN_JPG_CacheToN(1, DWIN_MarlinUI_Assets);
DWIN_JPG_CacheTo1(DWIN_MarlinUI_Assets);
}
// This LCD should clear where it will draw anew
@ -545,8 +545,8 @@ void MarlinUI::draw_status_message(const bool blink) {
// Show the location value
dwin_string.set(Z_LBL);
if (!isnan(ubl.z_values[x_plot][y_plot]))
dwin_string.add(ftostr43sign(ubl.z_values[x_plot][y_plot]));
if (!isnan(Z_VALUES_ARR[x_plot][y_plot]))
dwin_string.add(ftostr43sign(Z_VALUES_ARR[x_plot][y_plot]));
else
dwin_string.add(PSTR(" -----"));
lcd_moveto(