diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 3b669fbba2..4b2d21bc81 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -78,7 +78,7 @@ static void pre_g29_return(const bool retry, const bool did) { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false)); } if (did) { - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone()); + TERN_(HAS_DWIN_E3V2_BASIC, dwinLevelingDone()); TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index ab7b03961c..cb4f80618d 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -236,7 +236,7 @@ void GcodeSuite::G28() { set_and_report_grblstate(M_HOMING); #endif - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingStart()); + TERN_(HAS_DWIN_E3V2_BASIC, dwinHomingStart()); TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart()); planner.synchronize(); // Wait for planner moves to finish! @@ -649,7 +649,7 @@ void GcodeSuite::G28() { ui.refresh(); - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingDone()); + TERN_(HAS_DWIN_E3V2_BASIC, dwinHomingDone()); TERN_(EXTENSIBLE_UI, ExtUI::onHomingDone()); report_current_position(); diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index e874c19d5e..d56f09f71c 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -71,7 +71,7 @@ void GcodeSuite::M1000() { #elif HAS_DWIN_E3V2_BASIC recovery.dwin_flag = true; #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) // Temporary fix until it can be better implemented - CrealityDWIN.Popup_Handler(Resume); + crealityDWIN.popupHandler(Resume); #elif ENABLED(EXTENSIBLE_UI) ExtUI::onPowerLossResume(); #else diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index 319c861ea4..af28cfe62b 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -31,21 +31,21 @@ #include // for memset -uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA }; -uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C }; +uint8_t dwinSendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA }; +uint8_t dwinBufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C }; uint8_t databuf[26] = { 0 }; // Send the data in the buffer plus the packet tail -void DWIN_Send(size_t &i) { +void dwinSend(size_t &i) { ++i; - for (uint8_t n = 0; n < i; ++n) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); } - for (uint8_t n = 0; n < 4; ++n) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); } + for (uint8_t n = 0; n < i; ++n) { LCD_SERIAL.write(dwinSendBuf[n]); delayMicroseconds(1); } + for (uint8_t n = 0; n < 4; ++n) { LCD_SERIAL.write(dwinBufTail[n]); delayMicroseconds(1); } } /*-------------------------------------- System variable function --------------------------------------*/ // Handshake (1: Success, 0: Fail) -bool DWIN_Handshake() { +bool dwinHandshake() { static int recnum = 0; #ifndef LCD_BAUDRATE #define LCD_BAUDRATE 115200 @@ -55,8 +55,8 @@ bool DWIN_Handshake() { while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } size_t i = 0; - DWIN_Byte(i, 0x00); - DWIN_Send(i); + dwinByte(i, 0x00); + dwinSend(i); while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) { databuf[recnum] = LCD_SERIAL.read(); @@ -82,11 +82,11 @@ bool DWIN_Handshake() { #if HAS_LCD_BRIGHTNESS // Set LCD backlight (from DWIN Enhanced) // brightness: 0x00-0xFF - void DWIN_LCD_Brightness(const uint8_t brightness) { + void dwinLCDBrightness(const uint8_t brightness) { size_t i = 0; - DWIN_Byte(i, 0x30); - DWIN_Byte(i, brightness); - DWIN_Send(i); + dwinByte(i, 0x30); + dwinByte(i, brightness); + dwinSend(i); } #endif @@ -126,31 +126,31 @@ uint8_t fontHeight(uint8_t cfont) { // Set screen display direction // dir: 0=0°, 1=90°, 2=180°, 3=270° -void DWIN_Frame_SetDir(uint8_t dir) { +void dwinFrameSetDir(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); + dwinByte(i, 0x34); + dwinByte(i, 0x5A); + dwinByte(i, 0xA5); + dwinByte(i, dir); + dwinSend(i); } // Update display -void DWIN_UpdateLCD() { +void dwinUpdateLCD() { size_t i = 0; - DWIN_Byte(i, 0x3D); - DWIN_Send(i); + dwinByte(i, 0x3D); + dwinSend(i); } /*---------------------------------------- Drawing functions ----------------------------------------*/ // Clear screen // color: Clear screen color -void DWIN_Frame_Clear(const uint16_t color) { +void dwinFrameClear(const uint16_t color) { size_t i = 0; - DWIN_Byte(i, 0x01); - DWIN_Word(i, color); - DWIN_Send(i); + dwinByte(i, 0x01); + dwinWord(i, color); + dwinSend(i); } // Draw a point @@ -158,30 +158,30 @@ void DWIN_Frame_Clear(const uint16_t 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) { +void dwinDrawPoint(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); + dwinByte(i, 0x02); + dwinWord(i, color); + dwinByte(i, width); + dwinByte(i, height); + dwinWord(i, x); + dwinWord(i, y); + dwinSend(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) { +void dwinDrawLine(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); + dwinByte(i, 0x03); + dwinWord(i, color); + dwinWord(i, xStart); + dwinWord(i, yStart); + dwinWord(i, xEnd); + dwinWord(i, yEnd); + dwinSend(i); } // Draw a rectangle @@ -189,16 +189,16 @@ void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t x // 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) { +void dwinDrawRectangle(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); + dwinByte(i, 0x05); + dwinByte(i, mode); + dwinWord(i, color); + dwinWord(i, xStart); + dwinWord(i, yStart); + dwinWord(i, xEnd); + dwinWord(i, yEnd); + dwinSend(i); } // Move a screen area @@ -208,18 +208,18 @@ void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t // 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, +void dwinFrameAreaMove(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); + dwinByte(i, 0x09); + dwinByte(i, (mode << 7) | dir); + dwinWord(i, dis); + dwinWord(i, color); + dwinWord(i, xStart); + dwinWord(i, yStart); + dwinWord(i, xEnd); + dwinWord(i, yEnd); + dwinSend(i); } /*---------------------------------------- Text related functions ----------------------------------------*/ @@ -233,24 +233,24 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // x/y: Upper-left coordinate of the string // *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*/) { +void dwinDrawString(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*/) { #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, IS_DWIN_MARLINUI) - DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); + dwinDrawRectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); #endif constexpr uint8_t widthAdjust = 0; size_t i = 0; - DWIN_Byte(i, 0x11); + dwinByte(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_Text(i, string, rlimit); - DWIN_Send(i); + dwinByte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size); + dwinWord(i, color); + dwinWord(i, bColor); + dwinWord(i, x); + dwinWord(i, y); + dwinText(i, string, rlimit); + dwinSend(i); } // Draw a positive integer @@ -263,28 +263,28 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, // 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, +void dwinDrawIntValue(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; #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + dwinDrawRectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); #endif - DWIN_Byte(i, 0x14); + dwinByte(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); + dwinByte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); + dwinWord(i, color); + dwinWord(i, bColor); + dwinByte(i, iNum); + dwinByte(i, 0); // fNum + dwinWord(i, x); + dwinWord(i, y); #if 0 for (char count = 0; count < 8; count++) { - DWIN_Byte(i, value); + dwinByte(i, value); value >>= 8; if (!(value & 0xFF)) break; } @@ -293,12 +293,12 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t const size_t p = i + 1; for (char count = 8; count--;) { // 7..0 ++i; - DWIN_SendBuf[p + count] = value; + dwinSendBuf[p + count] = value; value >>= 8; } #endif - DWIN_Send(i); + dwinSend(i); } // Draw a floating point number @@ -312,48 +312,48 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t // 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, +void dwinDrawFloatValue(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, int32_t value) { //uint8_t *fvalue = (uint8_t*)&value; size_t i = 0; #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + dwinDrawRectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); #endif - 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); + dwinByte(i, 0x14); + dwinByte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); + dwinWord(i, color); + dwinWord(i, bColor); + dwinByte(i, iNum); + dwinByte(i, fNum); + dwinWord(i, x); + dwinWord(i, y); + dwinLong(i, value); /* - DWIN_Byte(i, fvalue[3]); - DWIN_Byte(i, fvalue[2]); - DWIN_Byte(i, fvalue[1]); - DWIN_Byte(i, fvalue[0]); + dwinByte(i, fvalue[3]); + dwinByte(i, fvalue[2]); + dwinByte(i, fvalue[1]); + dwinByte(i, fvalue[0]); */ - DWIN_Send(i); + dwinSend(i); } // Draw a floating point number // value: positive unscaled float value -void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, +void dwinDrawFloatValue(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 int32_t val = round(value * POW(10, fNum)); - DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val); + dwinDrawFloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val); } /*---------------------------------------- Picture related functions ----------------------------------------*/ // Draw JPG and cached in #0 virtual display area // id: Picture ID -void DWIN_JPG_ShowAndCache(const uint8_t id) { +void dwinJPGShowAndCache(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 + dwinWord(i, 0x2200); + dwinByte(i, id); + dwinSend(i); // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C } // Draw an Icon @@ -363,16 +363,16 @@ void DWIN_JPG_ShowAndCache(const uint8_t id) { // libID: Icon library ID // picID: Icon ID // x/y: Upper-left point -void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) { +void dwinIconShow(bool IBD, bool BIR, bool BFI, 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, (IBD << 7) | (BIR << 6) | (BFI << 5) | libID); - DWIN_Byte(i, picID); - DWIN_Send(i); + dwinByte(i, 0x23); + dwinWord(i, x); + dwinWord(i, y); + dwinByte(i, (IBD << 7) | (BIR << 6) | (BFI << 5) | libID); + dwinByte(i, picID); + dwinSend(i); } // Draw an Icon from SRAM @@ -381,27 +381,27 @@ void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, // BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0) // x/y: Upper-left point // addr: SRAM address -void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint16_t x, uint16_t y, uint16_t addr) { +void dwinIconShow(bool IBD, bool BIR, bool BFI, uint16_t x, uint16_t y, uint16_t addr) { NOMORE(x, DWIN_WIDTH - 1); NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl size_t i = 0; - DWIN_Byte(i, 0x24); - DWIN_Word(i, x); - DWIN_Word(i, y); - DWIN_Byte(i, (IBD << 7) | (BIR << 6) | (BFI << 5) | 0x00); - DWIN_Word(i, addr); - DWIN_Send(i); + dwinByte(i, 0x24); + dwinWord(i, x); + dwinWord(i, y); + dwinByte(i, (IBD << 7) | (BIR << 6) | (BFI << 5) | 0x00); + dwinWord(i, addr); + dwinSend(i); } // 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) { +void dwinJPGCacheToN(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); + dwinByte(i, 0x25); + dwinByte(i, n); + dwinByte(i, id); + dwinSend(i); } // Animate a series of icons @@ -412,32 +412,32 @@ void DWIN_JPG_CacheToN(uint8_t n, uint8_t 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) { +void dwinIconAnimation(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); + dwinByte(i, 0x28); + dwinWord(i, x); + dwinWord(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); + dwinByte(i, (animate * 0x80) | 0x40 | animID); + dwinByte(i, libID); + dwinByte(i, picIDs); + dwinByte(i, picIDe); + dwinByte(i, interval); + dwinSend(i); } // Animation Control // state: 16 bits, each bit is the state of an animation id -void DWIN_ICON_AnimationControl(uint16_t state) { +void dwinIconAnimationControl(uint16_t state) { size_t i = 0; - DWIN_Byte(i, 0x29); - DWIN_Word(i, state); - DWIN_Send(i); + dwinByte(i, 0x29); + dwinWord(i, state); + dwinSend(i); } /*---------------------------------------- Memory functions ----------------------------------------*/ diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.h b/Marlin/src/lcd/e3v2/common/dwin_api.h index dc97ef2723..f2392af55c 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.h +++ b/Marlin/src/lcd/e3v2/common/dwin_api.h @@ -39,101 +39,101 @@ #define DWIN_SCROLL_UP 2 #define DWIN_SCROLL_DOWN 3 -// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail. +// Make sure dwinSendBuf 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. -extern uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2]; -extern uint8_t DWIN_BufTail[4]; +extern uint8_t dwinSendBuf[11 + DWIN_WIDTH / 6 * 2]; +extern uint8_t dwinBufTail[4]; extern uint8_t databuf[26]; -inline void DWIN_Byte(size_t &i, const uint16_t bval) { - DWIN_SendBuf[++i] = bval; +inline void dwinByte(size_t &i, const uint16_t bval) { + dwinSendBuf[++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 dwinWord(size_t &i, const uint16_t wval) { + dwinSendBuf[++i] = wval >> 8; + dwinSendBuf[++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 dwinLong(size_t &i, const uint32_t lval) { + dwinSendBuf[++i] = (lval >> 24) & 0xFF; + dwinSendBuf[++i] = (lval >> 16) & 0xFF; + dwinSendBuf[++i] = (lval >> 8) & 0xFF; + dwinSendBuf[++i] = lval & 0xFF; } // Send the data in the buffer plus the packet tail -void DWIN_Send(size_t &i); +void dwinSend(size_t &i); -inline void DWIN_Text(size_t &i, const char * const string, uint16_t rlimit=0xFFFF) { +inline void dwinText(size_t &i, const char * const string, uint16_t rlimit=0xFFFF) { if (!string) return; - const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(strlen(string), rlimit)); + const size_t len = _MIN(sizeof(dwinSendBuf) - i, _MIN(strlen(string), rlimit)); if (len == 0) return; - memcpy(&DWIN_SendBuf[i+1], string, len); + memcpy(&dwinSendBuf[i+1], string, len); i += len; } -inline void DWIN_Text(size_t &i, FSTR_P string, uint16_t rlimit=0xFFFF) { +inline void dwinText(size_t &i, FSTR_P string, uint16_t rlimit=0xFFFF) { if (!string) return; - const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(rlimit, strlen_P(FTOP(string)))); + const size_t len = _MIN(sizeof(dwinSendBuf) - i, _MIN(rlimit, strlen_P(FTOP(string)))); if (len == 0) return; - memcpy_P(&DWIN_SendBuf[i+1], string, len); + memcpy_P(&dwinSendBuf[i+1], string, len); i += len; } /*-------------------------------------- System variable function --------------------------------------*/ // Handshake (1: Success, 0: Fail) -bool DWIN_Handshake(); +bool dwinHandshake(); // DWIN startup -void DWIN_Startup(); +void dwinStartup(); #if HAS_LCD_BRIGHTNESS // Set the backlight brightness // brightness: (0x00-0xFF) - void DWIN_LCD_Brightness(const uint8_t brightness); + void dwinLCDBrightness(const uint8_t brightness); #endif // Set screen display direction // dir: 0=0°, 1=90°, 2=180°, 3=270° -void DWIN_Frame_SetDir(uint8_t dir); +void dwinFrameSetDir(uint8_t dir); // Update display -void DWIN_UpdateLCD(); +void dwinUpdateLCD(); /*---------------------------------------- Drawing functions ----------------------------------------*/ // Clear screen // color: Clear screen color -void DWIN_Frame_Clear(const uint16_t color); +void dwinFrameClear(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); +void dwinDrawPoint(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); +void dwinDrawLine(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); +inline void dwinDrawHLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) { + dwinDrawLine(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); +inline void dwinDrawVLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) { + dwinDrawLine(color, xStart, yStart, xStart, yStart + yLength - 1); } // Draw a rectangle @@ -141,15 +141,15 @@ inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, ui // 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); +void dwinDrawRectangle(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); +inline void dwinDrawBox(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) { + dwinDrawRectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1); } // Move a screen area @@ -159,7 +159,7 @@ inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_ // 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, +void dwinFrameAreaMove(uint8_t mode, uint8_t dir, uint16_t dis, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd); @@ -173,15 +173,15 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // x/y: Upper-left coordinate of the string // *string: The string // rlimit: For draw less chars than string length use rlimit -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); +void dwinDrawString(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); -inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, FSTR_P const ftitle) { +inline void dwinDrawString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, FSTR_P const ftitle) { #ifdef __AVR__ char ctitle[strlen_P(FTOP(ftitle)) + 1]; strcpy_P(ctitle, FTOP(ftitle)); - DWIN_Draw_String(bShow, size, color, bColor, x, y, ctitle); + dwinDrawString(bShow, size, color, bColor, x, y, ctitle); #else - DWIN_Draw_String(bShow, size, color, bColor, x, y, FTOP(ftitle)); + dwinDrawString(bShow, size, color, bColor, x, y, FTOP(ftitle)); #endif } @@ -195,7 +195,7 @@ inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t // 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, +void dwinDrawIntValue(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); // Draw a floating point number @@ -209,25 +209,25 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t // 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, +void dwinDrawFloatValue(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, int32_t value); // Draw a floating point number // value: positive unscaled float value -void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, +void dwinDrawFloatValue(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 ----------------------------------------*/ // Draw JPG and cached in #0 virtual display area // id: Picture ID -void DWIN_JPG_ShowAndCache(const uint8_t id); +void dwinJPGShowAndCache(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); +void dwinIconShow(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y); // Draw an Icon // IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black @@ -236,7 +236,7 @@ void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y); // libID: Icon library ID // picID: Icon ID // x/y: Upper-left point -void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y); +void dwinIconShow(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y); // Draw an Icon from SRAM // IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black @@ -244,16 +244,16 @@ void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, // BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0) // x/y: Upper-left point // addr: SRAM address -void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint16_t x, uint16_t y, uint16_t addr); +void dwinIconShow(bool IBD, bool BIR, bool BFI, uint16_t x, uint16_t y, uint16_t addr); // 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); +void dwinJPGCacheToN(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); } +inline void dwinJPGCacheTo1(uint8_t id) { dwinJPGCacheToN(1, id); } // Animate a series of icons // animID: Animation ID up to 16 @@ -263,8 +263,8 @@ inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, 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); +void dwinIconAnimation(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); +void dwinIconAnimationControl(uint16_t state); diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index 5081e27690..2ff67059e9 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -46,7 +46,7 @@ #define ENCODER_PULSES_PER_STEP 4 #endif -ENCODER_Rate EncoderRate; +EncoderRate encoderRate; // TODO: Replace with ui.quick_feedback void Encoder_tick() { @@ -54,7 +54,7 @@ void Encoder_tick() { } // Encoder initialization -void Encoder_Configuration() { +void encoderConfiguration() { #if BUTTON_EXISTS(EN1) SET_INPUT_PULLUP(BTN_EN1); #endif @@ -70,7 +70,7 @@ void Encoder_Configuration() { } // Analyze encoder value and return state -EncoderState Encoder_ReceiveAnalyze() { +EncoderState encoderReceiveAnalyze() { const millis_t now = millis(); static uint8_t lastEncoderBits; uint8_t newbutton = 0; @@ -126,20 +126,20 @@ EncoderState Encoder_ReceiveAnalyze() { int32_t encoderMultiplier = 1; // if must encoder rati multiplier - if (EncoderRate.enabled) { + if (encoderRate.enabled) { const float abs_diff = ABS(temp_diff), encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP); - if (EncoderRate.lastEncoderTime) { + if (encoderRate.lastEncoderTime) { // Note that the rate is always calculated between two passes through the // loop and that the abs of the temp_diff value is tracked. - const float encoderStepRate = encoderMovementSteps / float(ms - EncoderRate.lastEncoderTime) * 1000; + const float encoderStepRate = encoderMovementSteps / float(ms - encoderRate.lastEncoderTime) * 1000; if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100; else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10; #if ENCODER_5X_STEPS_PER_SEC else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) encoderMultiplier = 5; #endif } - EncoderRate.lastEncoderTime = ms; + encoderRate.lastEncoderTime = ms; } #else @@ -148,9 +148,9 @@ EncoderState Encoder_ReceiveAnalyze() { #endif - // EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP); - EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP); - if (EncoderRate.encoderMoveValue < 0) EncoderRate.encoderMoveValue = -EncoderRate.encoderMoveValue; + // encoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP); + encoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP); + if (encoderRate.encoderMoveValue < 0) encoderRate.encoderMoveValue = -encoderRate.encoderMoveValue; temp_diff = 0; } diff --git a/Marlin/src/lcd/e3v2/common/encoder.h b/Marlin/src/lcd/e3v2/common/encoder.h index 3ab8c3bf42..72d37108dc 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.h +++ b/Marlin/src/lcd/e3v2/common/encoder.h @@ -34,9 +34,9 @@ typedef struct { bool enabled = false; int encoderMoveValue = 0; millis_t lastEncoderTime = 0; -} ENCODER_Rate; +} EncoderRate; -extern ENCODER_Rate EncoderRate; +extern EncoderRate encoderRate; typedef enum { ENCODER_DIFF_NO = 0, // no state @@ -48,26 +48,26 @@ typedef enum { #define ENCODER_WAIT_MS 20 // Encoder initialization -void Encoder_Configuration(); +void encoderConfiguration(); // Analyze encoder value and return state -EncoderState Encoder_ReceiveAnalyze(); +EncoderState encoderReceiveAnalyze(); inline EncoderState get_encoder_state() { static millis_t Encoder_ms = 0; const millis_t ms = millis(); if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; - const EncoderState state = Encoder_ReceiveAnalyze(); + const EncoderState state = encoderReceiveAnalyze(); if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; return state; } template -inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { +inline bool applyEncoder(const EncoderState &encoder_diffState, T &valref) { if (encoder_diffState == ENCODER_DIFF_CW) - valref += EncoderRate.encoderMoveValue; + valref += encoderRate.encoderMoveValue; else if (encoder_diffState == ENCODER_DIFF_CCW) - valref -= EncoderRate.encoderMoveValue; + valref -= encoderRate.encoderMoveValue; return encoder_diffState == ENCODER_DIFF_ENTER; } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 1ee3932c2d..16e0d10a09 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -535,7 +535,7 @@ typedef struct SettingsDataStruct { #if ENABLED(DWIN_LCD_PROUI) uint8_t dwin_data[eeprom_data_size]; #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) - uint8_t dwin_settings[CrealityDWIN.eeprom_data_size]; + uint8_t dwin_settings[crealityDWIN.eeprom_data_size]; #endif // diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1f0e1a9755..a1bebca4a0 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1231,7 +1231,7 @@ volatile bool Temperature::raw_temps_ready = false; // Heat to 200 degrees SERIAL_ECHOLNPGM(STR_MPC_HEATING_PAST_200); - TERN(DWIN_LCD_PROUI, LCD_ALERTMESSAGE(MSG_MPC_HEATING_PAST_200), LCD_MESSAGE(MSG_HEATING)); + LCD_ALERTMESSAGE(MSG_MPC_HEATING_PAST_200); if (tuner.measure_heatup() != MPC_autotuner::MeasurementState::SUCCESS) return; @@ -1531,14 +1531,14 @@ void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_m void Temperature::maxtemp_error(const heater_id_t heater_id) { #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED) - DWIN_Popup_Temperature(1); + dwinPopupTemperature(1); #endif _temp_error(heater_id, F(STR_T_MAXTEMP), GET_TEXT_F(MSG_ERR_MAXTEMP)); } void Temperature::mintemp_error(const heater_id_t heater_id) { #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED) - DWIN_Popup_Temperature(0); + dwinPopupTemperature(0); #endif _temp_error(heater_id, F(STR_T_MINTEMP), GET_TEXT_F(MSG_ERR_MINTEMP)); } @@ -1758,7 +1758,7 @@ void Temperature::mintemp_error(const heater_id_t heater_id) { if (watch_hotend[e].check(degHotend(e))) // Increased enough? start_watching_hotend(e); // If temp reached, turn off elapsed check else { - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); + TERN_(HAS_DWIN_E3V2_BASIC, dwinPopupTemperature(0)); _temp_error((heater_id_t)e, FPSTR(str_t_heating_failed), GET_TEXT_F(MSG_HEATING_FAILED_LCD)); } } @@ -1783,7 +1783,7 @@ void Temperature::mintemp_error(const heater_id_t heater_id) { if (watch_bed.check(degBed())) // Increased enough? start_watching_bed(); // If temp reached, turn off elapsed check else { - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); + TERN_(HAS_DWIN_E3V2_BASIC, dwinPopupTemperature(0)); _temp_error(H_BED, FPSTR(str_t_heating_failed), GET_TEXT_F(MSG_HEATING_FAILED_LCD)); } } @@ -3179,12 +3179,12 @@ void Temperature::init() { } // fall through case TRRunaway: - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); + TERN_(HAS_DWIN_E3V2_BASIC, dwinPopupTemperature(0)); _temp_error(heater_id, FPSTR(str_t_thermal_runaway), GET_TEXT_F(MSG_THERMAL_RUNAWAY)); #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) case TRMalfunction: - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); + TERN_(HAS_DWIN_E3V2_BASIC, dwinPopupTemperature(0)); _temp_error(heater_id, FPSTR(str_t_temp_malfunction), GET_TEXT_F(MSG_TEMP_MALFUNCTION)); #endif } @@ -4392,7 +4392,7 @@ void Temperature::isr() { if (wait_for_heatup) { wait_for_heatup = false; #if HAS_DWIN_E3V2_BASIC - HMI_flag.heat_flag = 0; + hmiFlag.heat_flag = 0; duration_t elapsed = print_job_timer.duration(); // Print timer dwin_heat_time = elapsed.value; #else