🎨 Consolidate Ender-3 V2 DWIN common code (#22778)
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.3
|
||||
* Date: 2021/08/09
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
@@ -14,117 +15,26 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.3
|
||||
* Date: 2021/09/08
|
||||
*/
|
||||
|
||||
#include "../../../core/types.h"
|
||||
#include "dwin_lcd.h"
|
||||
|
||||
// ICON ID
|
||||
#define ICON 7 // Icon set file 7.ICO
|
||||
|
||||
#define ICON_LOGO 0
|
||||
#define ICON_Print_0 1
|
||||
#define ICON_Print_1 2
|
||||
#define ICON_Prepare_0 3
|
||||
#define ICON_Prepare_1 4
|
||||
#define ICON_Control_0 5
|
||||
#define ICON_Control_1 6
|
||||
#define ICON_Leveling_0 7
|
||||
#define ICON_Leveling_1 8
|
||||
#define ICON_HotendTemp 9
|
||||
#define ICON_BedTemp 10
|
||||
#define ICON_Speed 11
|
||||
#define ICON_Zoffset 12
|
||||
#define ICON_Back 13
|
||||
#define ICON_File 14
|
||||
#define ICON_PrintTime 15
|
||||
#define ICON_RemainTime 16
|
||||
#define ICON_Setup_0 17
|
||||
#define ICON_Setup_1 18
|
||||
#define ICON_Pause_0 19
|
||||
#define ICON_Pause_1 20
|
||||
#define ICON_Continue_0 21
|
||||
#define ICON_Continue_1 22
|
||||
#define ICON_Stop_0 23
|
||||
#define ICON_Stop_1 24
|
||||
#define ICON_Bar 25
|
||||
#define ICON_More 26
|
||||
|
||||
#define ICON_Axis 27
|
||||
#define ICON_CloseMotor 28
|
||||
#define ICON_Homing 29
|
||||
#define ICON_SetHome 30
|
||||
#define ICON_PLAPreheat 31
|
||||
#define ICON_ABSPreheat 32
|
||||
#define ICON_Cool 33
|
||||
#define ICON_Language 34
|
||||
|
||||
#define ICON_MoveX 35
|
||||
#define ICON_MoveY 36
|
||||
#define ICON_MoveZ 37
|
||||
#define ICON_Extruder 38
|
||||
|
||||
#define ICON_Temperature 40
|
||||
#define ICON_Motion 41
|
||||
#define ICON_WriteEEPROM 42
|
||||
#define ICON_ReadEEPROM 43
|
||||
#define ICON_ResumeEEPROM 44
|
||||
#define ICON_Info 45
|
||||
|
||||
#define ICON_SetEndTemp 46
|
||||
#define ICON_SetBedTemp 47
|
||||
#define ICON_FanSpeed 48
|
||||
#define ICON_SetPLAPreheat 49
|
||||
#define ICON_SetABSPreheat 50
|
||||
|
||||
#define ICON_MaxSpeed 51
|
||||
#define ICON_MaxAccelerated 52
|
||||
#define ICON_MaxJerk 53
|
||||
#define ICON_Step 54
|
||||
#define ICON_PrintSize 55
|
||||
#define ICON_Version 56
|
||||
#define ICON_Contact 57
|
||||
#define ICON_StockConfiguration 58
|
||||
#define ICON_MaxSpeedX 59
|
||||
#define ICON_MaxSpeedY 60
|
||||
#define ICON_MaxSpeedZ 61
|
||||
#define ICON_MaxSpeedE 62
|
||||
#define ICON_MaxAccX 63
|
||||
#define ICON_MaxAccY 64
|
||||
#define ICON_MaxAccZ 65
|
||||
#define ICON_MaxAccE 66
|
||||
#define ICON_MaxSpeedJerkX 67
|
||||
#define ICON_MaxSpeedJerkY 68
|
||||
#define ICON_MaxSpeedJerkZ 69
|
||||
#define ICON_MaxSpeedJerkE 70
|
||||
#define ICON_StepX 71
|
||||
#define ICON_StepY 72
|
||||
#define ICON_StepZ 73
|
||||
#define ICON_StepE 74
|
||||
#define ICON_Setspeed 75
|
||||
#define ICON_SetZOffset 76
|
||||
#define ICON_Rectangle 77
|
||||
#define ICON_BLTouch 78
|
||||
#define ICON_TempTooLow 79
|
||||
#define ICON_AutoLeveling 80
|
||||
#define ICON_TempTooHigh 81
|
||||
#define ICON_NoTips_C 82
|
||||
#define ICON_NoTips_E 83
|
||||
#define ICON_Continue_C 84
|
||||
#define ICON_Continue_E 85
|
||||
#define ICON_Cancel_C 86
|
||||
#define ICON_Cancel_E 87
|
||||
#define ICON_Confirm_C 88
|
||||
#define ICON_Confirm_E 89
|
||||
#define ICON_Info_0 90
|
||||
#define ICON_Info_1 91
|
||||
#include "../common/dwin_set.h"
|
||||
#include "../common/dwin_font.h"
|
||||
#include "../common/dwin_color.h"
|
||||
|
||||
// Extra Icons
|
||||
#define ICON_AdvSet ICON_Language
|
||||
#define ICON_Brightness ICON_Motion
|
||||
#define ICON_Cancel ICON_StockConfiguration
|
||||
#define ICON_CustomPreheat ICON_SetEndTemp
|
||||
@@ -135,10 +45,6 @@
|
||||
#define ICON_FilSet ICON_ResumeEEPROM
|
||||
#define ICON_FilUnload ICON_ReadEEPROM
|
||||
#define ICON_Flow ICON_StepE
|
||||
#define ICON_HomeOffset ICON_AdvSet
|
||||
#define ICON_HomeOffsetX ICON_StepX
|
||||
#define ICON_HomeOffsetY ICON_StepY
|
||||
#define ICON_HomeOffsetZ ICON_StepZ
|
||||
#define ICON_LevBed ICON_SetEndTemp
|
||||
#define ICON_Lock ICON_Cool
|
||||
#define ICON_ManualMesh ICON_HotendTemp
|
||||
@@ -146,13 +52,8 @@
|
||||
#define ICON_MeshSave ICON_WriteEEPROM
|
||||
#define ICON_MoveZ0 ICON_HotendTemp
|
||||
#define ICON_Park ICON_Motion
|
||||
#define ICON_PIDbed ICON_SetBedTemp
|
||||
#define ICON_PIDcycles ICON_ResumeEEPROM
|
||||
#define ICON_PIDNozzle ICON_SetEndTemp
|
||||
#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
|
||||
@@ -162,47 +63,6 @@
|
||||
#define ICON_SetCustomPreheat ICON_SetEndTemp
|
||||
#define ICON_Sound ICON_Cool
|
||||
|
||||
/**
|
||||
* 3-.0:The 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
|
||||
|
||||
// Extended and default UI Colors
|
||||
#define RGB(R,G,B) (R << 11) | (G << 5) | (B) // R,B: 0..31; G: 0..63
|
||||
#define GetRColor(color) ((color >> 11) & 0x1F)
|
||||
#define GetGColor(color) ((color >> 5) & 0x3F)
|
||||
#define GetBColor(color) ((color >> 0) & 0x1F)
|
||||
|
||||
#define Color_White 0xFFFF
|
||||
#define Color_Bg_Window 0x31E8 // Popup background color
|
||||
#define Color_Bg_Blue 0x1125 // Dark blue background color
|
||||
#define Color_Bg_Black 0x0841 // Black background color
|
||||
#define Color_Bg_Red 0xF00F // Red background color
|
||||
#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
|
||||
|
||||
#define Color_Black 0
|
||||
#define Color_Red RGB(31,0,0)
|
||||
#define Color_Yellow RGB(31,63,0)
|
||||
#define Color_Green RGB(0,63,0)
|
||||
#define Color_Aqua RGB(0,63,31)
|
||||
#define Color_Blue RGB(0,0,31)
|
||||
|
||||
// Default UI Colors
|
||||
#define Def_Background_Color Color_Bg_Black
|
||||
#define Def_Cursor_color Rectangle_Color
|
||||
@@ -223,7 +83,7 @@
|
||||
#define Def_Indicator_Color Color_White
|
||||
#define Def_Coordinate_Color Color_White
|
||||
|
||||
//UI elements defines and constants
|
||||
// UI element defines and constants
|
||||
#define DWIN_FONT_MENU font8x16
|
||||
#define DWIN_FONT_STAT font10x20
|
||||
#define DWIN_FONT_HEAD font10x20
|
||||
@@ -262,7 +122,7 @@ public:
|
||||
char caption[32] = "";
|
||||
uint8_t frameid = 0;
|
||||
rect_t frame = {0};
|
||||
void Draw();
|
||||
void draw();
|
||||
void SetCaption(const char * const title);
|
||||
inline void SetCaption(const __FlashStringHelper * title) { SetCaption((char *)title); }
|
||||
void ShowCaption(const char * const title);
|
||||
@@ -290,7 +150,7 @@ public:
|
||||
MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
|
||||
void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||
virtual ~MenuItemClass(){};
|
||||
virtual void Draw(int8_t line);
|
||||
virtual void draw(int8_t line);
|
||||
};
|
||||
|
||||
class MenuItemPtrClass: public MenuItemClass {
|
||||
@@ -310,7 +170,7 @@ public:
|
||||
virtual ~MenuClass(){};
|
||||
inline int8_t line() { return selected - topline; };
|
||||
inline int8_t line(uint8_t pos) {return pos - topline; };
|
||||
void Draw();
|
||||
void draw();
|
||||
void onScroll(bool dir);
|
||||
void onClick();
|
||||
MenuItemClass* SelectedItem();
|
||||
@@ -330,16 +190,16 @@ namespace DWINUI {
|
||||
extern void (*onMenuDraw)(MenuClass* menu);
|
||||
|
||||
// DWIN LCD Initialization
|
||||
void Init(void);
|
||||
void init();
|
||||
|
||||
// Set text/number font
|
||||
void SetFont(uint8_t cfont);
|
||||
void setFont(uint8_t cfont);
|
||||
|
||||
// Get font character width
|
||||
uint8_t Get_font_width(uint8_t cfont);
|
||||
uint8_t fontWidth(uint8_t cfont);
|
||||
|
||||
// Get font character heigh
|
||||
uint8_t Get_font_height(uint8_t cfont);
|
||||
uint8_t fontHeight(uint8_t cfont);
|
||||
|
||||
// Get screen x coodinates from text column
|
||||
uint16_t ColToX(uint8_t col);
|
||||
@@ -398,7 +258,7 @@ namespace DWINUI {
|
||||
}
|
||||
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);
|
||||
MoveBy(iNum * fontWidth(font), 0);
|
||||
}
|
||||
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);
|
||||
@@ -429,7 +289,7 @@ namespace DWINUI {
|
||||
}
|
||||
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);
|
||||
MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
|
||||
}
|
||||
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);
|
||||
@@ -457,7 +317,7 @@ namespace DWINUI {
|
||||
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);
|
||||
MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
|
||||
}
|
||||
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);
|
||||
@@ -548,7 +408,7 @@ namespace DWINUI {
|
||||
|
||||
// Draw a circle
|
||||
// Color: circle color
|
||||
// x: the abscissa of the center of the circle
|
||||
// x: abscissa of the center of the circle
|
||||
// y: ordinate of the center of the circle
|
||||
// r: circle radius
|
||||
void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
|
||||
@@ -569,7 +429,7 @@ namespace DWINUI {
|
||||
// Color Interpolator
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximun value
|
||||
// maxv : Maximum value
|
||||
// color1 : Start color
|
||||
// color2 : End color
|
||||
uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
|
||||
@@ -578,7 +438,7 @@ namespace DWINUI {
|
||||
|
||||
// Draw a circle filled with color
|
||||
// bcolor: fill color
|
||||
// x: the abscissa of the center of the circle
|
||||
// x: abscissa of the center of the circle
|
||||
// y: ordinate of the center of the circle
|
||||
// r: circle radius
|
||||
void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
|
||||
@@ -589,7 +449,7 @@ namespace DWINUI {
|
||||
// Color Interpolator through Red->Yellow->Green->Blue
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximun value
|
||||
// maxv : Maximum value
|
||||
uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
|
||||
|
||||
// Write buffer data to the SRAM
|
||||
|
||||
Reference in New Issue
Block a user