🎨 Standardize naming (ProUI) (#25982)

This commit is contained in:
Scott Lahteine
2023-06-30 19:16:00 -05:00
committed by GitHub
parent 7247acdece
commit f14f1be168
52 changed files with 3629 additions and 3582 deletions

View File

@@ -759,7 +759,7 @@ void unified_bed_leveling::shift_mesh_height() {
TERN_(HAS_MARLINUI_MENU, ui.capture());
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart());
TERN_(DWIN_LCD_PROUI, dwinLevelingStart());
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
grid_count_t count = GRID_MAX_POINTS;
@@ -820,7 +820,7 @@ void unified_bed_leveling::shift_mesh_height() {
);
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
TERN_(DWIN_LCD_PROUI, DWIN_LevelingDone());
TERN_(DWIN_LCD_PROUI, dwinLevelingDone());
}
#endif // HAS_BED_PROBE

View File

@@ -88,7 +88,7 @@ void event_filament_runout(const uint8_t extruder) {
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getTool(extruder)));
TERN_(DWIN_LCD_PROUI, DWIN_FilamentRunout(extruder));
TERN_(DWIN_LCD_PROUI, dwinFilamentRunout(extruder));
#if ANY(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS, MULTI_FILAMENT_SENSOR)
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, extruder);

View File

@@ -429,7 +429,7 @@ G29_TYPE GcodeSuite::G29() {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
points[0].z = points[1].z = points[2].z = 0; // Probe at 3 arbitrary points
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart());
TERN_(DWIN_LCD_PROUI, dwinLevelingStart());
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
@@ -440,7 +440,7 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(PREHEAT_BEFORE_LEVELING)
if (!abl.dryrun) probe.preheat_for_probing(LEVELING_NOZZLE_TEMP,
#if ALL(DWIN_LCD_PROUI, HAS_HEATED_BED)
HMI_data.BedLevT
hmiData.bedLevT
#else
LEVELING_BED_TEMP
#endif

View File

@@ -143,7 +143,7 @@ void GcodeSuite::G29() {
queue.inject(F("G29S2"));
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart());
TERN_(DWIN_LCD_PROUI, dwinLevelingStart());
return;
}
@@ -169,7 +169,7 @@ void GcodeSuite::G29() {
// Save Z for the previous mesh position
bedlevel.set_zigzag_z(mbl_probe_index - 1, current_position.z);
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z));
TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(_MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS), current_position.z));
TERN_(DWIN_LCD_PROUI, dwinMeshUpdate(_MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS), current_position.z));
SET_SOFT_ENDSTOP_LOOSE(false);
}
// If there's another point to sample, move there with optional lift.
@@ -236,7 +236,7 @@ void GcodeSuite::G29() {
if (parser.seenval('Z')) {
bedlevel.z_values[ix][iy] = parser.value_linear_units();
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, bedlevel.z_values[ix][iy]));
TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(ix, iy, bedlevel.z_values[ix][iy]));
TERN_(DWIN_LCD_PROUI, dwinMeshUpdate(ix, iy, bedlevel.z_values[ix][iy]));
}
else
return echo_not_entered('Z');

View File

@@ -69,7 +69,7 @@ void GcodeSuite::M421() {
float &zval = bedlevel.z_values[ij.x][ij.y]; // Altering this Mesh Point
zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); // N=NAN, Z=NEWVAL, or Q=ADDVAL
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval)); // Ping ExtUI in case it's showing the mesh
TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(ij.x, ij.y, zval));
TERN_(DWIN_LCD_PROUI, dwinMeshUpdate(ij.x, ij.y, zval));
}
}

View File

@@ -51,7 +51,7 @@ void GcodeSuite::M302() {
if (seen_S) {
thermalManager.extrude_min_temp = parser.value_celsius();
thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0);
TERN_(DWIN_LCD_PROUI, HMI_data.ExtMinT = thermalManager.extrude_min_temp);
TERN_(DWIN_LCD_PROUI, hmiData.extMinT = thermalManager.extrude_min_temp);
}
if (parser.seen('P'))

View File

@@ -33,7 +33,7 @@
*/
void GcodeSuite::M997() {
TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen());
TERN_(DWIN_LCD_PROUI, dwinRebootScreen());
flashFirmware(parser.intval('S'));

View File

@@ -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
jyersDWIN.popupHandler(Resume);
jyersDWIN.popupHandler(Popup_Resume);
#elif ENABLED(EXTENSIBLE_UI)
ExtUI::onPowerLossResume();
#else

View File

@@ -73,9 +73,9 @@ void GcodeSuite::M0_M1() {
ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_USERWAIT));
#elif ENABLED(DWIN_LCD_PROUI)
if (parser.string_arg)
DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT));
dwinPopupConfirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT));
else
DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT_F(MSG_STOPPED), GET_TEXT_F(MSG_USERWAIT));
dwinPopupConfirm(ICON_BLTouch, GET_TEXT_F(MSG_STOPPED), GET_TEXT_F(MSG_USERWAIT));
#else
if (parser.string_arg) {

View File

@@ -49,8 +49,6 @@
#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin.h"
#endif
#if ENABLED(HOST_ACTION_COMMANDS)

View File

@@ -39,7 +39,7 @@
void GcodeSuite::M75() {
startOrResumeJob();
#if ENABLED(DWIN_LCD_PROUI)
if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
if (!IS_SD_PRINTING()) dwinPrintHeader(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
#endif
}

View File

@@ -31,7 +31,7 @@
#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_LCD_PROUI)
#elif ENABLED(PROUI_PID_TUNE)
#include "../../lcd/e3v2/proui/dwin.h"
#endif
@@ -69,7 +69,7 @@ void GcodeSuite::M303() {
SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_HEATER_ID));
TERN_(DWIN_PID_TUNE, DWIN_PidTuning(PID_BAD_HEATER_ID));
TERN_(PROUI_PID_TUNE, dwinPidTuning(PID_BAD_HEATER_ID));
return;
}
@@ -79,7 +79,7 @@ void GcodeSuite::M303() {
const celsius_t temp = seenS ? parser.value_celsius() : default_temp;
const bool u = parser.boolval('U');
TERN_(DWIN_PID_TUNE, DWIN_StartM303(seenC, c, seenS, hid, temp));
TERN_(PROUI_PID_TUNE, dwinStartM303(seenC, c, seenS, hid, temp));
IF_DISABLED(BUSY_WHILE_HEATING, KEEPALIVE_STATE(NOT_BUSY));

View File

@@ -2386,10 +2386,10 @@
#if ENABLED(DWIN_LCD_PROUI)
#if ANY(PIDTEMP, PIDTEMPBED)
#define DWIN_PID_TUNE 1
#define PROUI_PID_TUNE 1
#endif
#if ANY(DWIN_PID_TUNE, MPC_AUTOTUNE) && DISABLED(DISABLE_TUNING_GRAPH)
#define SHOW_TUNING_GRAPH 1
#if ANY(PROUI_PID_TUNE, MPC_AUTOTUNE) && DISABLED(DISABLE_TUNING_GRAPH)
#define PROUI_TUNING_GRAPH 1
#endif
#endif

View File

@@ -27,18 +27,18 @@
#define GetGColor(color) ((color >> 5) & 0x3F)
#define GetBColor(color) ((color >> 0) & 0x1F)
#define Color_White 0xFFFF
#define Color_Yellow RGB(0x1F,0x3F,0x00)
#define Color_Red RGB(0x1F,0x00,0x00)
#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_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
#define COLOR_WHITE 0xFFFF
#define COLOR_YELLOW RGB(0x1F,0x3F,0x00)
#define COLOR_RED RGB(0x1F,0x00,0x00)
#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_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 COLOR_POPUP_TEXT 0xD6BA // Popup font background color
#define COLOR_LINE 0x3A6A // Split line color
#define COLOR_RECTANGLE 0xEE2F // Blue square cursor color
#define COLOR_PERCENT 0xFE29 // Percentage color
#define COLOR_BARFILL 0x10E4 // Fill color of progress bar
#define COLOR_SELECT 0x33BB // Selected color

File diff suppressed because it is too large Load Diff

View File

@@ -34,69 +34,56 @@
enum processID : uint8_t {
// Process ID
MainMenu,
SelectFile,
Prepare,
Control,
Leveling,
PrintProcess,
AxisMove,
TemperatureID,
Motion,
Info,
Tune,
ID_MainMenu,
ID_SelectFile,
ID_Prepare,
ID_Control,
ID_Leveling,
ID_PrintProcess,
ID_AxisMove,
ID_TemperatureID,
ID_Motion,
ID_Info,
ID_Tune,
#if HAS_PREHEAT
PLAPreheat,
ID_PLAPreheat,
#if PREHEAT_COUNT > 1
ABSPreheat,
ID_ABSPreheat,
#endif
#endif
MaxSpeed,
MaxSpeed_value,
MaxAcceleration,
MaxAcceleration_value,
MaxJerk,
MaxJerk_value,
Step,
Step_value,
HomeOff,
HomeOffX,
HomeOffY,
HomeOffZ,
ID_MaxSpeed, ID_MaxSpeedValue,
ID_MaxAcceleration, ID_MaxAccelerationValue,
ID_MaxJerk, ID_MaxJerkValue,
ID_Step, ID_StepValue,
ID_HomeOff, ID_HomeOffX, ID_HomeOffY, ID_HomeOffZ,
// Last Process ID
Last_Prepare,
ID_LastPrepare,
// Advance Settings
AdvSet,
ProbeOff,
ProbeOffX,
ProbeOffY,
ID_AdvSet,
ID_ProbeOff, ID_ProbeOffX, ID_ProbeOffY,
// Back Process ID
Back_Main,
Back_Print,
ID_BackMain, ID_BackPrint,
// Date variable ID
Move_X,
Move_Y,
Move_Z,
ID_MoveX, ID_MoveY, ID_MoveZ,
#if HAS_HOTEND
Extruder,
ETemp,
ID_Extruder,
ID_ETemp,
#endif
Homeoffset,
ID_HomeOffset,
#if HAS_HEATED_BED
BedTemp,
ID_BedTemp,
#endif
#if HAS_FAN
FanSpeed,
ID_FanSpeed,
#endif
PrintSpeed,
ID_PrintSpeed,
// Window ID
Print_window,
Popup_Window
ID_PrintWindow, ID_PopupWindow
};
extern uint8_t checkkey;
@@ -107,32 +94,54 @@ extern millis_t dwin_heat_time;
typedef struct {
#if HAS_HOTEND
celsius_t E_Temp = 0;
celsius_t tempE = 0;
#endif
#if HAS_HEATED_BED
celsius_t Bed_Temp = 0;
celsius_t tempBed = 0;
#endif
#if HAS_FAN
int16_t Fan_speed = 0;
#endif
int16_t print_speed = 100;
float Max_Feedspeed = 0;
float Max_Acceleration = 0;
float Max_Jerk_scaled = 0;
float Max_Step_scaled = 0;
float Move_X_scaled = 0;
float Move_Y_scaled = 0;
float Move_Z_scaled = 0;
#if HAS_HOTEND
float Move_E_scaled = 0;
int16_t fanSpeed = 0;
#endif
int16_t printSpeed = 100;
float maxFeedSpeed = 0;
float maxAcceleration = 0;
float maxJerkScaled = 0;
float maxStepScaled = 0;
float offset_value = 0;
int8_t show_mode = 0; // -1: Temperature control 0: Printing temperature
float Home_OffX_scaled = 0;
float Home_OffY_scaled = 0;
float Home_OffZ_scaled = 0;
float Probe_OffX_scaled = 0;
float Probe_OffY_scaled = 0;
struct {
#if HAS_X_AXIS
float x = 0;
#endif
#if HAS_Y_AXIS
float y = 0;
#endif
#if HAS_Z_AXIS
float z = 0;
#endif
#if HAS_HOTEND
float e = 0;
#endif
} moveScaled;
struct {
#if HAS_X_AXIS
float x = 0;
#endif
#if HAS_Y_AXIS
float y = 0;
#endif
#if HAS_Z_AXIS
float z = 0;
#endif
} homeOffsScaled;
struct {
#if HAS_X_AXIS
float x = 0;
#endif
#if HAS_Y_AXIS
float y = 0;
#endif
} probeOffsScaled;
} hmi_value_t;
#define DWIN_CHINESE 123
@@ -198,19 +207,13 @@ void hmiMaxJerkXYZE();
void hmiStepXYZE();
void hmiSetLanguageCache();
void update_variable();
void dwinDrawSigned_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
void updateVariable();
void dwinDrawSignedFloat(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
// SD Card
void hmiSDCardInit();
void hmiSDCardUpdate();
// Main Process
void Icon_print(bool value);
void Icon_control(bool value);
void Icon_temperature(bool value);
void Icon_leveling(bool value);
// Other
void drawStatusArea(const bool with_update); // Status Area
void hmiStartFrame(const bool with_update); // Prepare the menu view

View File

@@ -47,7 +47,7 @@ void dwinStartup() {
if (dwinHandshake()) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
dwinFrameSetDir(1);
#if DISABLED(SHOW_BOOTSCREEN)
dwinFrameClear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here
dwinFrameClear(COLOR_BG_BLACK); // MarlinUI handles the bootscreen so just clear here
#endif
dwinJPGShowAndCache(3);
dwinUpdateLCD();

File diff suppressed because it is too large Load Diff

View File

@@ -38,61 +38,87 @@
//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
enum processID : uint8_t {
Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
Proc_Main, Proc_Print, Proc_Menu, Proc_Value, Proc_Option,
Proc_File, Proc_Popup, Proc_Confirm, Proc_Wait
};
enum PopupID : uint8_t {
Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot,
Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, PIDWait, MPCWait, Resuming, ManualProbing,
FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom
Popup_Pause,
Popup_Stop,
Popup_Resume,
Popup_SaveLevel,
Popup_ETemp,
Popup_ConfFilChange,
Popup_PurgeMore,
Popup_MeshSlot,
Popup_Level,
Popup_Home,
Popup_MoveWait,
Popup_Heating,
Popup_FilLoad,
Popup_FilChange,
Popup_TempWarn,
Popup_Runout,
Popup_PIDWait,
Popup_MPCWait,
Popup_Resuming,
Popup_ManualProbing,
Popup_FilInsert,
Popup_HeaterTime,
Popup_UserInput,
Popup_LevelError,
Popup_InvalidMesh,
Popup_UI,
Popup_Complete,
Popup_Custom
};
enum menuID : uint8_t {
MainMenu,
Prepare,
Move,
HomeMenu,
ManualLevel,
ZOffset,
Preheat,
ChangeFilament,
MenuCustom,
Control,
TempMenu,
PID,
HotendPID,
BedPID,
ID_MainMenu,
ID_Prepare,
ID_Move,
ID_HomeMenu,
ID_ManualLevel,
ID_ZOffset,
ID_Preheat,
ID_ChangeFilament,
ID_MenuCustom,
ID_Control,
ID_TempMenu,
ID_PID,
ID_HotendPID,
ID_BedPID,
#if HAS_PREHEAT
#define _PREHEAT_ID(N) Preheat##N,
#define _PREHEAT_ID(N) ID_Preheat##N,
REPEAT_1(PREHEAT_COUNT, _PREHEAT_ID)
#endif
#if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
MPC,
ID_MPC,
#endif
Motion,
HomeOffsets,
MaxSpeed,
MaxAcceleration,
MaxJerk,
Steps,
Visual,
ColorSettings,
Advanced,
ProbeMenu,
ID_Motion,
ID_HomeOffsets,
ID_MaxSpeed,
ID_MaxAcceleration,
ID_MaxJerk,
ID_Steps,
ID_Visual,
ID_ColorSettings,
ID_Advanced,
ID_ProbeMenu,
#if HAS_TRINAMIC_CONFIG
TMCMenu,
ID_TMCMenu,
#endif
Info,
Leveling,
LevelManual,
LevelView,
MeshViewer,
LevelSettings,
ManualMesh,
UBLMesh,
InfoMain,
Tune,
PreheatHotend
ID_Info,
ID_Leveling,
ID_LevelManual,
ID_LevelView,
ID_MeshViewer,
ID_LevelSettings,
ID_ManualMesh,
ID_UBLMesh,
ID_InfoMain,
ID_Tune,
ID_PreheatHotend
};
// Custom icons
@@ -129,27 +155,27 @@ enum colorID : uint8_t {
};
#define Custom_Colors 10
#define Color_Aqua RGB(0x00,0x3F,0x1F)
#define Color_Light_White 0xBDD7
#define Color_Green RGB(0x00,0x3F,0x00)
#define Color_Light_Green 0x3460
#define Color_Cyan 0x07FF
#define Color_Light_Cyan 0x04F3
#define Color_Blue 0x015F
#define Color_Light_Blue 0x3A6A
#define Color_Magenta 0xF81F
#define Color_Light_Magenta 0x9813
#define Color_Light_Red 0x8800
#define Color_Orange 0xFA20
#define Color_Light_Orange 0xFBC0
#define Color_Light_Yellow 0x8BE0
#define Color_Brown 0xCC27
#define Color_Light_Brown 0x6204
#define Color_Black 0x0000
#define Color_Grey 0x18E3
#define Check_Color 0x4E5C // Check-box check color
#define Confirm_Color 0x34B9
#define Cancel_Color 0x3186
#define COLOR_AQUA RGB(0x00,0x3F,0x1F)
#define COLOR_LIGHT_WHITE 0xBDD7
#define COLOR_GREEN RGB(0x00,0x3F,0x00)
#define COLOR_LIGHT_GREEN 0x3460
#define COLOR_CYAN 0x07FF
#define COLOR_LIGHT_CYAN 0x04F3
#define COLOR_BLUE 0x015F
#define COLOR_LIGHT_BLUE 0x3A6A
#define COLOR_MAGENTA 0xF81F
#define COLOR_LIGHT_MAGENTA 0x9813
#define COLOR_LIGHT_RED 0x8800
#define COLOR_ORANGE 0xFA20
#define COLOR_LIGHT_ORANGE 0xFBC0
#define COLOR_LIGHT_YELLOW 0x8BE0
#define COLOR_BROWN 0xCC27
#define COLOR_LIGHT_BROWN 0x6204
#define COLOR_BLACK 0x0000
#define COLOR_GREY 0x18E3
#define COLOR_CHECKBOX 0x4E5C // Check-box check color
#define COLOR_CONFIRM 0x34B9
#define COLOR_CANCEL 0x3186
class JyersDWIN {
public:

View File

@@ -45,7 +45,7 @@ void dwinStartup() {
const bool success = dwinHandshake();
if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
dwinFrameSetDir(TERN(DWIN_MARLINUI_LANDSCAPE, 0, 1));
dwinFrameClear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here
dwinFrameClear(COLOR_BG_BLACK); // MarlinUI handles the bootscreen so just clear here
dwinJPGShowAndCache(3);
dwinUpdateLCD();
}

View File

@@ -48,7 +48,7 @@
// DWIN printing specifies the font on each string operation
// but we'll make the font modal for Marlin
dwin_font_t dwin_font = { font8x16, 8, 16, Color_White, Color_Bg_Black, true };
dwin_font_t dwin_font = { font8x16, 8, 16, COLOR_WHITE, COLOR_BG_BLACK, true };
void MarlinUI::set_font(const uint8_t font_nr) {
if (font_nr != dwin_font.index) {
dwin_font.index = font_nr;
@@ -84,7 +84,7 @@ void MarlinUI::init_lcd() { dwinStartup(); }
void MarlinUI::clear_lcd() {
dwinIconAnimationControl(0x0000); // disable all icon animations
dwinJPGShowAndCache(3);
dwinFrameClear(Color_Bg_Black);
dwinFrameClear(COLOR_BG_BLACK);
dwinUpdateLCD();
did_first_redraw = false;
@@ -109,7 +109,7 @@ void MarlinUI::clear_lcd() {
#define VERSION_Y 84
#endif
dwinDrawString(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string()));
dwinDrawString(false, font10x20, COLOR_YELLOW, COLOR_BG_BLACK, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string()));
TERN_(SHOW_CUSTOM_BOOTSCREEN, safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT));
clear_lcd();
@@ -126,7 +126,7 @@ void MarlinUI::clear_lcd() {
dwinIconShow(BOOT_ICON, ICON_MarlinURL, INFO_CENTER - 100 / 2, 152);
dwinIconShow(BOOT_ICON, ICON_Copyright, INFO_CENTER - 126 / 2, 200);
#endif
dwinDrawString(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string()));
dwinDrawString(false, font10x20, COLOR_YELLOW, COLOR_BG_BLACK, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string()));
dwinUpdateLCD();
}
@@ -140,14 +140,14 @@ void MarlinUI::clear_lcd() {
// The kill screen is displayed for unrecoverable conditions
void MarlinUI::draw_kill_screen() {
set_font(DWIN_FONT_ALERT);
dwinFrameClear(Color_Bg_Black);
dwin_font.fg = Color_Error_Red;
dwinFrameClear(COLOR_BG_BLACK);
dwin_font.fg = COLOR_ERROR_RED;
dwin_font.solid = false;
dwinDrawRectangle(1, Color_Bg_Window, 20, 20, LCD_PIXEL_WIDTH - 20, LCD_PIXEL_HEIGHT - 20);
dwinDrawRectangle(1, COLOR_BG_WINDOW, 20, 20, LCD_PIXEL_WIDTH - 20, LCD_PIXEL_HEIGHT - 20);
// make the frame a few pixels thick
dwinDrawRectangle(0, Color_Yellow, 20, 20, LCD_PIXEL_WIDTH - 20, LCD_PIXEL_HEIGHT - 20);
dwinDrawRectangle(0, Color_Yellow, 21, 21, LCD_PIXEL_WIDTH - 21, LCD_PIXEL_HEIGHT - 21);
dwinDrawRectangle(0, Color_Yellow, 22, 22, LCD_PIXEL_WIDTH - 22, LCD_PIXEL_HEIGHT - 22);
dwinDrawRectangle(0, COLOR_YELLOW, 20, 20, LCD_PIXEL_WIDTH - 20, LCD_PIXEL_HEIGHT - 20);
dwinDrawRectangle(0, COLOR_YELLOW, 21, 21, LCD_PIXEL_WIDTH - 21, LCD_PIXEL_HEIGHT - 21);
dwinDrawRectangle(0, COLOR_YELLOW, 22, 22, LCD_PIXEL_WIDTH - 22, LCD_PIXEL_HEIGHT - 22);
uint8_t cx = (LCD_PIXEL_WIDTH / dwin_font.width / 2),
cy = (LCD_PIXEL_HEIGHT / dwin_font.height / 2);
@@ -178,8 +178,8 @@ void MarlinUI::draw_kill_screen() {
void MarlinUI::draw_status_message(const bool blink) {
set_font(DWIN_FONT_STAT);
dwin_font.solid = true;
dwin_font.fg = Color_White;
dwin_font.bg = Color_Bg_Black;
dwin_font.fg = COLOR_WHITE;
dwin_font.bg = COLOR_BG_BLACK;
lcd_moveto_xy(0, LCD_PIXEL_HEIGHT - (STAT_FONT_HEIGHT) - 1);
constexpr uint8_t max_status_chars = (LCD_PIXEL_WIDTH) / (STAT_FONT_WIDTH);
@@ -267,7 +267,7 @@ void MarlinUI::draw_status_message(const bool blink) {
void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
dwin_font.solid = false;
dwin_font.fg = Color_White;
dwin_font.fg = COLOR_WHITE;
dwin_string.set('E');
dwin_string.add('1' + extruder);
dwin_string.add(' ');
@@ -293,10 +293,10 @@ void MarlinUI::draw_status_message(const bool blink) {
dwinDrawBox(1, Color_Bg_Heading, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
else {
#if ENABLED(MENU_HOLLOW_FRAME)
dwinDrawBox(1, Color_Bg_Black, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
if (sel) dwinDrawBox(0, Select_Color, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
dwinDrawBox(1, COLOR_BG_BLACK, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
if (sel) dwinDrawBox(0, COLOR_SELECT, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
#else
dwinDrawBox(1, sel ? Select_Color : Color_Bg_Black, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
dwinDrawBox(1, sel ? COLOR_SELECT : COLOR_BG_BLACK, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
#endif
}
@@ -311,7 +311,7 @@ void MarlinUI::draw_status_message(const bool blink) {
if (mark_as_selected(row, (bool)(style & SS_INVERT), true)) {
ui.set_font(DWIN_FONT_MENU);
dwin_font.solid = false;
dwin_font.fg = Color_White;
dwin_font.fg = COLOR_WHITE;
dwin_string.set();
@@ -356,7 +356,7 @@ void MarlinUI::draw_status_message(const bool blink) {
if (mark_as_selected(row, sel)) {
ui.set_font(DWIN_FONT_MENU);
dwin_font.solid = false;
dwin_font.fg = Color_White;
dwin_font.fg = COLOR_WHITE;
dwin_string.set(ftpl, itemIndex, itemStringC, itemStringF);
@@ -377,7 +377,7 @@ void MarlinUI::draw_status_message(const bool blink) {
if (mark_as_selected(row, sel)) {
ui.set_font(DWIN_FONT_MENU);
dwin_font.solid = false;
dwin_font.fg = Color_White;
dwin_font.fg = COLOR_WHITE;
const uint8_t vallen = (pgm ? utf8_strlen_P(inStr) : utf8_strlen(S(inStr)));
@@ -388,7 +388,7 @@ void MarlinUI::draw_status_message(const bool blink) {
lcd_put_dwin_string();
if (vallen) {
dwin_font.fg = Color_Yellow;
dwin_font.fg = COLOR_YELLOW;
dwin_string.set(inStr);
lcd_moveto(LCD_WIDTH - vallen - 1, row);
lcd_put_dwin_string();
@@ -410,7 +410,7 @@ void MarlinUI::draw_status_message(const bool blink) {
// Assume the label is alpha-numeric (with a descender)
const uint16_t row = (LCD_HEIGHT / 2) - 1;
dwin_font.fg = Color_White;
dwin_font.fg = COLOR_WHITE;
dwin_font.solid = true;
lcd_moveto((LCD_WIDTH - labellen + !!vallen) / 2, row);
lcd_put_dwin_string();
@@ -420,7 +420,7 @@ void MarlinUI::draw_status_message(const bool blink) {
dwin_string.set(value);
const dwin_coord_t by = (row * MENU_LINE_HEIGHT) + MENU_FONT_HEIGHT + EXTRA_ROW_HEIGHT / 2;
dwinDrawString(true, font16x32, Color_Yellow, Color_Bg_Black, (LCD_PIXEL_WIDTH - vallen * 16) / 2, by, S(dwin_string.string()));
dwinDrawString(true, font16x32, COLOR_YELLOW, COLOR_BG_BLACK, (LCD_PIXEL_WIDTH - vallen * 16) / 2, by, S(dwin_string.string()));
if (ui.can_show_slider()) {
@@ -430,11 +430,11 @@ void MarlinUI::draw_status_message(const bool blink) {
slider_y = by + 32 + 4,
amount = ui.encoderPosition * slider_length / maxEditValue;
dwinDrawRectangle(1, Color_Bg_Window, slider_x - 1, slider_y - 1, slider_x - 1 + slider_length + 2 - 1, slider_y - 1 + slider_height + 2 - 1);
dwinDrawRectangle(1, COLOR_BG_WINDOW, slider_x - 1, slider_y - 1, slider_x - 1 + slider_length + 2 - 1, slider_y - 1 + slider_height + 2 - 1);
if (amount > 0)
dwinDrawBox(1, BarFill_Color, slider_x, slider_y, amount, slider_height);
dwinDrawBox(1, COLOR_BARFILL, slider_x, slider_y, amount, slider_height);
if (amount < slider_length)
dwinDrawBox(1, Color_Bg_Black, slider_x + amount, slider_y, slider_length - amount, slider_height);
dwinDrawBox(1, COLOR_BG_BLACK, slider_x + amount, slider_y, slider_length - amount, slider_height);
}
}
}
@@ -445,7 +445,7 @@ void MarlinUI::draw_status_message(const bool blink) {
col = yesopt ? LCD_WIDTH - mar - len : mar,
row = (LCD_HEIGHT >= 8 ? LCD_HEIGHT / 2 + 3 : LCD_HEIGHT - 1);
lcd_moveto(col, row);
dwinDrawBox(1, inv ? Select_Color : Color_Bg_Black, cursor.x - dwin_font.width, cursor.y + 1, dwin_font.width * (len + 2), dwin_font.height + 2);
dwinDrawBox(1, inv ? COLOR_SELECT : COLOR_BG_BLACK, cursor.x - dwin_font.width, cursor.y + 1, dwin_font.width * (len + 2), dwin_font.height + 2);
lcd_put_u8str(col, row, fstr);
}
@@ -455,7 +455,7 @@ void MarlinUI::draw_status_message(const bool blink) {
) {
ui.set_font(DWIN_FONT_MENU);
dwin_font.solid = false;
dwin_font.fg = Color_White;
dwin_font.fg = COLOR_WHITE;
ui.draw_select_screen_prompt(pref, string, suff);
if (no) draw_boxed_string(false, no, !yesno);
if (yes) draw_boxed_string(true, yes, yesno);
@@ -507,9 +507,9 @@ void MarlinUI::draw_status_message(const bool blink) {
// Clear the Mesh Map
// First draw the bigger box in White so we have a border around the mesh map box
dwinDrawRectangle(1, Color_White, x_offset - 2, y_offset - 2, x_offset + 2 + x_map_pixels, y_offset + 2 + y_map_pixels);
dwinDrawRectangle(1, COLOR_WHITE, x_offset - 2, y_offset - 2, x_offset + 2 + x_map_pixels, y_offset + 2 + y_map_pixels);
// Now actually clear the mesh map box
dwinDrawRectangle(1, Color_Bg_Black, x_offset, y_offset, x_offset + x_map_pixels, y_offset + y_map_pixels);
dwinDrawRectangle(1, COLOR_BG_BLACK, x_offset, y_offset, x_offset + x_map_pixels, y_offset + y_map_pixels);
// Fill in the Specified Mesh Point
@@ -517,7 +517,7 @@ void MarlinUI::draw_status_message(const bool blink) {
// invert the Y to get it to plot in the right location.
const dwin_coord_t by = y_offset + y_plot_inv * pixels_per_y_mesh_pnt;
dwinDrawRectangle(1, Select_Color,
dwinDrawRectangle(1, COLOR_SELECT,
x_offset + (x_plot * pixels_per_x_mesh_pnt), by,
x_offset + (x_plot * pixels_per_x_mesh_pnt) + pixels_per_x_mesh_pnt, by + pixels_per_y_mesh_pnt
);
@@ -527,12 +527,12 @@ void MarlinUI::draw_status_message(const bool blink) {
dwin_coord_t y = y_offset + pixels_per_y_mesh_pnt / 2;
for (uint8_t j = 0; j < (GRID_MAX_POINTS_Y); j++, y += pixels_per_y_mesh_pnt)
for (uint8_t i = 0, x = sx; i < (GRID_MAX_POINTS_X); i++, x += pixels_per_x_mesh_pnt)
dwinDrawPoint(Color_White, 1, 1, x, y);
dwinDrawPoint(COLOR_WHITE, 1, 1, x, y);
// Put Relevant Text on Display
// Show X and Y positions at top of screen
dwin_font.fg = Color_White;
dwin_font.fg = COLOR_WHITE;
dwin_font.solid = true;
const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) },
lpos = pos.asLogical();
@@ -586,7 +586,7 @@ void MarlinUI::draw_status_message(const bool blink) {
const int nozzle = (LCD_PIXEL_WIDTH / 2) - 20;
// Draw a representation of the nozzle
dwinDrawBox(1, Color_Bg_Black, nozzle + 3, 8, 48, 52); // 'clear' the area where the nozzle is drawn in case it was moved up/down
dwinDrawBox(1, COLOR_BG_BLACK, nozzle + 3, 8, 48, 52); // 'clear' the area where the nozzle is drawn in case it was moved up/down
dwinIconShow(ICON, ICON_HotendOff, nozzle + 3, 10 - dir);
dwinIconShow(ICON, ICON_BedLine, nozzle, 10 + 36);

View File

@@ -72,7 +72,7 @@ void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink,
const bool x_redraw = !ui.did_first_redraw || old_is_printing != print_job_timer.isRunning();
if (x_redraw) {
dwin_string.set('X' + axis);
dwinDrawString(true, font16x32, Color_IconBlue, Color_Bg_Black,
dwinDrawString(true, font16x32, COLOR_ICONBLUE, COLOR_BG_BLACK,
#if ENABLED(DWIN_MARLINUI_PORTRAIT)
x + (utf8_strlen(value) * 14 - 14) / 2, y + 2
#else
@@ -96,7 +96,7 @@ void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink,
if (TERN0(LCD_SHOW_E_TOTAL, x_redraw && axis == X_AXIS))
dwin_string.add(F(" "));
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black,
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK,
#if ENABLED(DWIN_MARLINUI_PORTRAIT)
x, y + 32
#else
@@ -117,26 +117,26 @@ void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink,
if (e_redraw) {
// Extra spaces to erase previous value
dwin_string.set(F("E "));
dwinDrawString(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string()));
dwinDrawString(true, font16x32, COLOR_ICONBLUE, COLOR_BG_BLACK, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string()));
}
dwin_string.set(ui16tostr5rj(value / scale));
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, x, y + 32, S(dwin_string.string()));
// Extra spaces to erase previous value
dwinDrawString(true, font14x28, Color_IconBlue, Color_Bg_Black, x + (5 * 14), y + 32, S(scale == 1 ? "mm " : "cm "));
dwinDrawString(true, font14x28, COLOR_ICONBLUE, COLOR_BG_BLACK, x + (5 * 14), y + 32, S(scale == 1 ? "mm " : "cm "));
#else // !DWIN_MARLINUI_PORTRAIT
if (e_redraw) {
dwin_string.set(F("E "));
dwinDrawString(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string()));
dwinDrawString(true, font16x32, COLOR_ICONBLUE, COLOR_BG_BLACK, x, y, S(dwin_string.string()));
}
dwin_string.set(ui16tostr5rj(value / scale));
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, x + 32, y + 4, S(dwin_string.string()));
dwinDrawString(true, font14x28, Color_IconBlue, Color_Bg_Black, x + (32 + 70), y + 4, S(scale == 1 ? "mm " : "cm "));
dwinDrawString(true, font14x28, COLOR_ICONBLUE, COLOR_BG_BLACK, x + (32 + 70), y + 4, S(scale == 1 ? "mm " : "cm "));
#endif // !DWIN_MARLINUI_PORTRAIT
}
@@ -154,13 +154,13 @@ void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink,
dwinIconAnimation(0, fan_on, ICON, ICON_Fan0, ICON_Fan3, x + fanx, y, 25);
dwin_string.set(i8tostr3rj(thermalManager.scaledFanSpeedPercent(0)));
dwin_string.add('%');
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string()));
}
else {
dwinIconAnimationControl(0x0000); // disable all icon animations (this is the only one)
dwinIconShow(ICON, ICON_Fan0, x + fanx, y);
dwin_string.set(F(" "));
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string()));
}
}
#endif
@@ -230,7 +230,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
if (t_draw) {
dwin_string.set(i16tostr3rj(tt + 0.5));
dwin_string.add(LCD_STR_DEGREE);
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, x, y, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, x, y, S(dwin_string.string()));
}
// Draw heater icon with on / off / leveled states
@@ -243,7 +243,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
if (c_draw) {
dwin_string.set(i16tostr3rj(tc + 0.5));
dwin_string.add(LCD_STR_DEGREE);
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, x, y + 70, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, x, y + 70, S(dwin_string.string()));
}
}
@@ -253,12 +253,12 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
FORCE_INLINE void _draw_feedrate_status(const char *value, uint16_t x, uint16_t y) {
if (!ui.did_first_redraw) {
dwin_string.set(LCD_STR_FEEDRATE);
dwinDrawString(true, font14x28, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_ICONBLUE, COLOR_BG_BLACK, x, y, S(dwin_string.string()));
}
dwin_string.set(value);
dwin_string.add('%');
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, x + 14, y, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, x + 14, y, S(dwin_string.string()));
}
/**
@@ -281,7 +281,7 @@ void MarlinUI::draw_status_screen() {
);
// Draw a frame around the x/y/z values
dwinDrawRectangle(0, Select_Color,
dwinDrawRectangle(0, COLOR_SELECT,
#if ENABLED(DWIN_MARLINUI_PORTRAIT)
0, 193, LCD_PIXEL_WIDTH - 1, 260
#else
@@ -358,7 +358,7 @@ void MarlinUI::draw_status_screen() {
time.toDigital(buffer);
dwin_string.add(prefix);
dwin_string.add(buffer);
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, (LCD_PIXEL_WIDTH - ((dwin_string.length + 1) * 14)), 290, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, (LCD_PIXEL_WIDTH - ((dwin_string.length + 1) * 14)), 290, S(dwin_string.string()));
#else
@@ -367,23 +367,23 @@ void MarlinUI::draw_status_screen() {
time.toDigital(buffer);
dwin_string.set(' ');
dwin_string.add(buffer);
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, 230, 170, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, 230, 170, S(dwin_string.string()));
#if ENABLED(SHOW_REMAINING_TIME)
if (print_job_timer.isRunning()) {
time = get_remaining_time();
dwinDrawString(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(" R "));
dwinDrawString(true, font14x28, COLOR_ICONBLUE, COLOR_BG_BLACK, 336, 170, S(" R "));
if (print_job_timer.isPaused() && blink)
dwin_string.set(F(" "));
else {
time.toDigital(buffer);
dwin_string.set(buffer);
}
dwinDrawString(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_WHITE, COLOR_BG_BLACK, 378, 170, S(dwin_string.string()));
}
else if (!ui.did_first_redraw || old_is_printing != print_job_timer.isRunning()) {
dwin_string.set(F(" "));
dwinDrawString(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string()));
dwinDrawString(true, font14x28, COLOR_ICONBLUE, COLOR_BG_BLACK, 336, 170, S(dwin_string.string()));
}
#endif
#endif
@@ -403,7 +403,7 @@ void MarlinUI::draw_status_screen() {
const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
if (!ui.did_first_redraw)
dwinDrawRectangle(0, Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline
dwinDrawRectangle(0, COLOR_SELECT, pb_left, pb_top, pb_right, pb_bottom); // Outline
static uint16_t old_solid = 50;
const uint16_t pb_solid = (pb_width - 2) * (progress / (PROGRESS_SCALE)) * 0.01f;
@@ -411,16 +411,16 @@ void MarlinUI::draw_status_screen() {
if (p_draw) {
//if (pb_solid)
dwinDrawRectangle(1, Select_Color, pb_left + 1, pb_top + 1, pb_left + pb_solid, pb_bottom - 1); // Fill the solid part
dwinDrawRectangle(1, COLOR_SELECT, pb_left + 1, pb_top + 1, pb_left + pb_solid, pb_bottom - 1); // Fill the solid part
//if (pb_solid < old_solid)
dwinDrawRectangle(1, Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1, pb_right - 1, pb_bottom - 1); // Erase the rest
dwinDrawRectangle(1, COLOR_BG_BLACK, pb_left + 1 + pb_solid, pb_top + 1, pb_right - 1, pb_bottom - 1); // Erase the rest
#if ENABLED(SHOW_PROGRESS_PERCENT)
dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
dwin_string.add('%');
dwinDrawString(
false, font16x32, Percent_Color, Color_Bg_Black,
false, font16x32, COLOR_PERCENT, COLOR_BG_BLACK,
pb_left + (pb_width - dwin_string.length * 16) / 2,
pb_top + (pb_height - 32) / 2 - 1,
S(dwin_string.string())

View File

@@ -63,22 +63,22 @@
#include "dwin_popup.h"
#include "bedlevel_tools.h"
BedLevelToolsClass bedLevelTools;
BedLevelTools bedLevelTools;
#if ENABLED(USE_GRID_MESHVIEWER)
bool BedLevelToolsClass::viewer_asymmetric_range = false;
bool BedLevelToolsClass::viewer_print_value = false;
bool BedLevelTools::viewer_asymmetric_range = false;
bool BedLevelTools::viewer_print_value = false;
#endif
bool BedLevelToolsClass::goto_mesh_value = false;
uint8_t BedLevelToolsClass::mesh_x = 0;
uint8_t BedLevelToolsClass::mesh_y = 0;
uint8_t BedLevelToolsClass::tilt_grid = 1;
bool BedLevelTools::goto_mesh_value = false;
uint8_t BedLevelTools::mesh_x = 0;
uint8_t BedLevelTools::mesh_y = 0;
uint8_t BedLevelTools::tilt_grid = 1;
bool drawing_mesh = false;
#if ENABLED(AUTO_BED_LEVELING_UBL)
void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) {
void BedLevelTools::manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) {
MString<MAX_CMD_SIZE> cmd;
cmd.set(F("M421 I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3));
if (undefined) cmd += F(" N");
@@ -86,7 +86,7 @@ bool drawing_mesh = false;
planner.synchronize();
}
bool BedLevelToolsClass::create_plane_from_mesh() {
bool BedLevelTools::createPlaneFromMesh() {
struct linear_fit_data lsf_results;
incremental_LSF_reset(&lsf_results);
GRID_LOOP(x, y) {
@@ -126,7 +126,7 @@ bool drawing_mesh = false;
#else
void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) {
void BedLevelTools::manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y) {
gcode.process_subcommands_now(
TS(F("G29 I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3))
);
@@ -135,7 +135,7 @@ bool drawing_mesh = false;
#endif
void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) {
void BedLevelTools::manualMove(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) {
gcode.process_subcommands_now(F("G28O"));
if (zmove) {
planner.synchronize();
@@ -144,48 +144,48 @@ void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y,
planner.synchronize();
}
else {
DWIN_Show_Popup(ICON_BLTouch, F("Moving to Point"), F("Please wait until done."));
HMI_SaveProcessID(NothingToDo);
dwinShowPopup(ICON_BLTouch, F("Moving to Point"), F("Please wait until done."));
hmiSaveProcessID(ID_NothingToDo);
gcode.process_subcommands_now(TS(F("G0 F300 Z"), p_float_t(Z_CLEARANCE_BETWEEN_PROBES, 3)));
gcode.process_subcommands_now(TS(F("G42 F4000 I"), mesh_x, F(" J"), mesh_y));
planner.synchronize();
current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
planner.synchronize();
HMI_ReturnScreen();
hmiReturnScreen();
}
}
// Move / Probe methods. As examples, not yet used.
void BedLevelToolsClass::MoveToXYZ() {
bedLevelTools.goto_mesh_value = true;
bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, false);
void BedLevelTools::moveToXYZ() {
goto_mesh_value = true;
manualMove(mesh_x, mesh_y, false);
}
void BedLevelToolsClass::MoveToXY() {
bedLevelTools.goto_mesh_value = false;
bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, false);
void BedLevelTools::moveToXY() {
goto_mesh_value = false;
manualMove(mesh_x, mesh_y, false);
}
void BedLevelToolsClass::MoveToZ() {
bedLevelTools.goto_mesh_value = true;
bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, true);
void BedLevelTools::moveToZ() {
goto_mesh_value = true;
manualMove(mesh_x, mesh_y, true);
}
void BedLevelToolsClass::ProbeXY() {
void BedLevelTools::probeXY() {
gcode.process_subcommands_now(
MString<MAX_CMD_SIZE>(
F("G28O\nG0Z"), uint16_t(Z_CLEARANCE_DEPLOY_PROBE),
F("\nG30X"), p_float_t(bedlevel.get_mesh_x(bedLevelTools.mesh_x), 2),
F("Y"), p_float_t(bedlevel.get_mesh_y(bedLevelTools.mesh_y), 2)
F("\nG30X"), p_float_t(bedlevel.get_mesh_x(mesh_x), 2),
F("Y"), p_float_t(bedlevel.get_mesh_y(mesh_y), 2)
)
);
}
void BedLevelToolsClass::mesh_reset() {
void BedLevelTools::meshReset() {
ZERO(bedlevel.z_values);
TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level());
}
// Accessors
float BedLevelToolsClass::get_max_value() {
float BedLevelTools::getMaxValue() {
float max = __FLT_MAX__ * -1;
GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max)
@@ -194,7 +194,7 @@ float BedLevelToolsClass::get_max_value() {
return max;
}
float BedLevelToolsClass::get_min_value() {
float BedLevelTools::getMinValue() {
float min = __FLT_MAX__;
GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min)
@@ -204,7 +204,7 @@ float BedLevelToolsClass::get_min_value() {
}
// Return 'true' if mesh is good and within LCD limits
bool BedLevelToolsClass::meshvalidate() {
bool BedLevelTools::meshValidate() {
GRID_LOOP(x, y) {
const float v = bedlevel.z_values[x][y];
if (isnan(v) || !WITHIN(v, UBL_Z_OFFSET_MIN, UBL_Z_OFFSET_MAX)) return false;
@@ -216,21 +216,21 @@ bool BedLevelToolsClass::meshvalidate() {
constexpr uint8_t meshfont = TERN(TJC_DISPLAY, font8x16, font6x12);
void BedLevelToolsClass::Draw_Bed_Mesh(int16_t selected/*=-1*/, uint8_t gridline_width/*=1*/, uint16_t padding_x/*=8*/, uint16_t padding_y_top/*=(40 + 53 - 7)*/) {
void BedLevelTools::drawBedMesh(int16_t selected/*=-1*/, uint8_t gridline_width/*=1*/, uint16_t padding_x/*=8*/, uint16_t padding_y_top/*=(40 + 53 - 7)*/) {
drawing_mesh = true;
const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x;
const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X);
const uint16_t cell_height_px = total_width_px / (GRID_MAX_POINTS_Y);
const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max);
const float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), range = _MAX(v_min, v_max);
// Clear background from previous selection and select new square
dwinDrawRectangle(1, Color_Bg_Black, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px);
dwinDrawRectangle(1, COLOR_BG_BLACK, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px);
if (selected >= 0) {
const auto selected_y = selected / (GRID_MAX_POINTS_X);
const auto selected_x = selected - (GRID_MAX_POINTS_X) * selected_y;
const auto start_y_px = padding_y_top + selected_y * cell_height_px;
const auto start_x_px = padding_x + selected_x * cell_width_px;
dwinDrawRectangle(1, Color_White, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px);
dwinDrawRectangle(1, COLOR_WHITE, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px);
}
// Draw value square grid
@@ -240,7 +240,7 @@ bool BedLevelToolsClass::meshvalidate() {
const auto start_y_px = padding_y_top + ((GRID_MAX_POINTS_Y) - y - 1) * cell_height_px;
const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width;
dwinDrawRectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
isnan(bedlevel.z_values[x][y]) ? Color_Grey : ( // gray if undefined
isnan(bedlevel.z_values[x][y]) ? COLOR_GREY : ( // gray if undefined
(bedlevel.z_values[x][y] < 0 ?
(uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
(uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
@@ -257,7 +257,7 @@ bool BedLevelToolsClass::meshvalidate() {
if (viewer_print_value) {
int8_t offset_x, offset_y = cell_height_px / 2 - fs;
if (isnan(bedlevel.z_values[x][y])) { // undefined
dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
}
else { // has value
if (GRID_MAX_POINTS_X < (ENABLED(TJC_DISPLAY) ? 8 : 10))
@@ -266,8 +266,8 @@ bool BedLevelToolsClass::meshvalidate() {
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100));
offset_x = cell_width_px / 2 - (fs/2) * (strlen(buf)) - 2;
if (!(GRID_MAX_POINTS_X < (ENABLED(TJC_DISPLAY) ? 8 : 10)))
dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y, F("."));
dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y, buf);
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px - 2 + offset_x, start_y_px + offset_y, F("."));
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + 1 + offset_x, start_y_px + offset_y, buf);
}
safe_delay(10);
LCD_SERIAL.flushTX();
@@ -275,8 +275,8 @@ bool BedLevelToolsClass::meshvalidate() {
}
}
void BedLevelToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead
float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max);
void BedLevelTools::setMeshViewerStatus() { // TODO: draw gradient with values as a legend instead
float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), range = _MAX(v_min, v_max);
if (v_min > 3e+10f) v_min = 0.0000001;
if (v_max > 3e+10f) v_max = 0.0000001;
if (range > 3e+10f) range = 0.0000001;

View File

@@ -50,36 +50,35 @@
#define UBL_Z_OFFSET_MIN -3.0
#define UBL_Z_OFFSET_MAX 3.0
class BedLevelToolsClass {
class BedLevelTools {
public:
#if ENABLED(USE_GRID_MESHVIEWER)
static bool viewer_asymmetric_range;
static bool viewer_print_value;
#endif
static bool goto_mesh_value;
static uint8_t mesh_x;
static uint8_t mesh_y;
static uint8_t mesh_x, mesh_y;
static uint8_t tilt_grid;
#if ENABLED(AUTO_BED_LEVELING_UBL)
static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined=false);
static bool create_plane_from_mesh();
static void manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined=false);
static bool createPlaneFromMesh();
#else
static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y);
static void manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y);
#endif
static void manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false);
static void MoveToXYZ();
static void MoveToXY();
static void MoveToZ();
static void ProbeXY();
static void mesh_reset();
static float get_max_value();
static float get_min_value();
static bool meshvalidate();
static void manualMove(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false);
static void moveToXYZ();
static void moveToXY();
static void moveToZ();
static void probeXY();
static void meshReset();
static float getMaxValue();
static float getMinValue();
static bool meshValidate();
#if ENABLED(USE_GRID_MESHVIEWER)
static void Draw_Bed_Mesh(int16_t selected=-1, uint8_t gridline_width=1, uint16_t padding_x=8, uint16_t padding_y_top=(40 + 53 - 7));
static void Set_Mesh_Viewer_Status();
static void drawBedMesh(int16_t selected=-1, uint8_t gridline_width=1, uint16_t padding_x=8, uint16_t padding_y_top=(40 + 53 - 7));
static void setMeshViewerStatus();
#endif
};
extern BedLevelToolsClass bedLevelTools;
extern BedLevelTools bedLevelTools;

File diff suppressed because it is too large Load Diff

View File

@@ -54,31 +54,31 @@ namespace GET_LANG(LCD_LANGUAGE) {
enum processID : uint8_t {
// Process ID
MainMenu,
Menu,
SetInt,
SetPInt,
SetIntNoDraw,
SetFloat,
SetPFloat,
PrintProcess,
Popup,
Leveling,
Locked,
Reboot,
PrintDone,
ESDiagProcess,
WaitResponse,
Homing,
PidProcess,
MPCProcess,
NothingToDo
ID_MainMenu,
ID_Menu,
ID_SetInt,
ID_SetPInt,
ID_SetIntNoDraw,
ID_SetFloat,
ID_SetPFloat,
ID_PrintProcess,
ID_Popup,
ID_Leveling,
ID_Locked,
ID_Reboot,
ID_PrintDone,
ID_ESDiagProcess,
ID_WaitResponse,
ID_Homing,
ID_PIDProcess,
ID_MPCProcess,
ID_NothingToDo
};
#if ANY(DWIN_PID_TUNE, MPC_AUTOTUNE)
#if ANY(PROUI_PID_TUNE, MPC_AUTOTUNE)
enum tempcontrol_t : uint8_t {
#if DWIN_PID_TUNE
#if PROUI_PID_TUNE
PIDTEMP_START,
PIDTEMPBED_START,
PID_BAD_HEATER_ID,
@@ -100,69 +100,69 @@ enum processID : uint8_t {
typedef struct {
// Color settings
uint16_t Background_Color;
uint16_t Cursor_Color;
uint16_t TitleBg_Color;
uint16_t TitleTxt_Color;
uint16_t Text_Color;
uint16_t Selected_Color;
uint16_t SplitLine_Color;
uint16_t Highlight_Color;
uint16_t StatusBg_Color;
uint16_t StatusTxt_Color;
uint16_t PopupBg_Color;
uint16_t PopupTxt_Color;
uint16_t AlertBg_Color;
uint16_t AlertTxt_Color;
uint16_t PercentTxt_Color;
uint16_t Barfill_Color;
uint16_t Indicator_Color;
uint16_t Coordinate_Color;
uint16_t colorBackground;
uint16_t colorCursor;
uint16_t colorTitleBg;
uint16_t colorTitleTxt;
uint16_t colorText;
uint16_t colorSelected;
uint16_t colorSplitLine;
uint16_t colorHighlight;
uint16_t colorStatusBg;
uint16_t colorStatusTxt;
uint16_t colorPopupBg;
uint16_t colorPopupTxt;
uint16_t colorAlertBg;
uint16_t colorAlertTxt;
uint16_t colorPercentTxt;
uint16_t colorBarfill;
uint16_t colorIndicator;
uint16_t colorCoordinate;
// Temperatures
#if DWIN_PID_TUNE
int16_t PidCycles = DEF_PIDCYCLES;
#if PROUI_PID_TUNE
int16_t pidCycles = DEF_PIDCYCLES;
#if ENABLED(PIDTEMP)
int16_t HotendPidT = DEF_HOTENDPIDT;
int16_t hotendPidT = DEF_HOTENDPIDT;
#endif
#if ENABLED(PIDTEMPBED)
int16_t BedPidT = DEF_BEDPIDT;
int16_t bedPidT = DEF_BEDPIDT;
#endif
#endif
#if ENABLED(PREVENT_COLD_EXTRUSION)
int16_t ExtMinT = EXTRUDE_MINTEMP;
int16_t extMinT = EXTRUDE_MINTEMP;
#endif
#if ENABLED(PREHEAT_BEFORE_LEVELING)
int16_t BedLevT = LEVELING_BED_TEMP;
int16_t bedLevT = LEVELING_BED_TEMP;
#endif
#if ENABLED(BAUD_RATE_GCODE)
bool Baud115K = false;
bool baud115K = false;
#endif
bool FullManualTramming = false;
bool MediaSort = true;
bool MediaAutoMount = ENABLED(HAS_SD_EXTENDER);
bool fullManualTramming = false;
bool mediaSort = true;
bool mediaAutoMount = ENABLED(HAS_SD_EXTENDER);
#if ALL(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING)
uint8_t z_after_homing = DEF_Z_AFTER_HOMING;
uint8_t zAfterHoming = DEF_Z_AFTER_HOMING;
#endif
#if ALL(LED_CONTROL_MENU, HAS_COLOR_LEDS)
LEDColor Led_Color = Def_Leds_Color;
LEDColor ledColor = defColorLeds;
#endif
bool AdaptiveStepSmoothing = true;
bool EnablePreview = true;
} HMI_data_t;
bool adaptiveStepSmoothing = true;
bool enablePreview = true;
} hmi_data_t;
extern HMI_data_t HMI_data;
static constexpr size_t eeprom_data_size = sizeof(HMI_data_t);
extern hmi_data_t hmiData;
static constexpr size_t eeprom_data_size = sizeof(hmi_data_t);
typedef struct {
int8_t Color[3]; // Color components
#if ANY(DWIN_PID_TUNE, MPCTEMP)
tempcontrol_t tempcontrol = AUTOTUNE_DONE;
#if ANY(PROUI_PID_TUNE, MPCTEMP)
tempcontrol_t tempControl = AUTOTUNE_DONE;
#endif
uint8_t Select = 0; // Auxiliary selector variable
uint8_t select = 0; // Auxiliary selector variable
AxisEnum axis = X_AXIS; // Axis Select
} HMI_value_t;
} hmi_value_t;
typedef struct {
uint8_t language;
@@ -171,10 +171,10 @@ typedef struct {
bool pause_flag:1; // printing is paused
bool select_flag:1; // Popup button selected
bool home_flag:1; // homing in course
} HMI_flag_t;
} hmi_flag_t;
extern HMI_value_t HMI_value;
extern HMI_flag_t hmiFlag;
extern hmi_value_t hmiValue;
extern hmi_flag_t hmiFlag;
extern uint8_t checkkey;
// Popups
@@ -182,217 +182,214 @@ extern uint8_t checkkey;
void dwinPopupTemperature(const bool toohigh);
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void Popup_PowerLossRecovery();
void popupPowerLossRecovery();
#endif
// Tool Functions
uint32_t GetHash(char * str);
uint32_t getHash(char * str);
#if ENABLED(EEPROM_SETTINGS)
void WriteEeprom();
void ReadEeprom();
void ResetEeprom();
void writeEEPROM();
void readEEPROM();
void resetEEPROM();
#if HAS_MESH
void SaveMesh();
void saveMesh();
#endif
#endif
void RebootPrinter();
void DisableMotors();
void AutoLev();
void AutoHome();
void rebootPrinter();
void disableMotors();
void autoLevel();
void autoHome();
#if HAS_PREHEAT
#define _DOPREHEAT(N) void DoPreheat##N();
REPEAT_1(PREHEAT_COUNT, _DOPREHEAT)
#endif
void DoCoolDown();
void doCoolDown();
#if ENABLED(BAUD_RATE_GCODE)
void HMI_SetBaudRate();
void SetBaud115K();
void SetBaud250K();
void hmiSetBaudRate();
void setBaud115K();
void setBaud250K();
#endif
#if HAS_LCD_BRIGHTNESS
void TurnOffBacklight();
void turnOffBacklight();
#endif
void ApplyExtMinT();
void ParkHead();
void applyExtMinT();
void parkHead();
#if HAS_ONESTEP_LEVELING
void Trammingwizard();
void trammingwizard();
#endif
#if ALL(LED_CONTROL_MENU, HAS_COLOR_LEDS)
void ApplyLEDColor();
void applyLEDColor();
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
void UBLMeshTilt();
void UBLMeshSave();
void UBLMeshLoad();
void ublMeshTilt();
void ublMeshSave();
void ublMeshLoad();
#endif
#if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION)
void HostShutDown();
void hostShutDown();
#endif
#if DISABLED(HAS_BED_PROBE)
void HomeZandDisable();
void homeZAndDisable();
#endif
// Other
void Goto_PrintProcess();
void Goto_Main_Menu();
void Goto_Info_Menu();
void Goto_PowerLossRecovery();
void Goto_ConfirmToPrint();
void DWIN_Draw_Dashboard(const bool with_update); // Status Area
void Draw_Main_Area(); // Redraw main area
void DWIN_DrawStatusLine(const char *text = ""); // Draw simple status text
void DWIN_RedrawDash(); // Redraw Dash and Status line
void DWIN_RedrawScreen(); // Redraw all screen elements
void HMI_MainMenu(); // Main process screen
void HMI_Printing(); // Print page
void HMI_ReturnScreen(); // Return to previous screen before popups
void HMI_WaitForUser();
void HMI_SaveProcessID(const uint8_t id);
void HMI_SDCardUpdate();
void EachMomentUpdate();
void update_variable();
void gotoPrintProcess();
void gotoMainMenu();
void gotoInfoMenu();
void gotoPowerLossRecovery();
void gotoConfirmToPrint();
void dwinDrawDashboard(const bool with_update); // Status Area
void drawMainArea(); // Redraw main area
void dwinDrawStatusLine(const char *text = ""); // Draw simple status text
void dwinRedrawDash(); // Redraw Dash and Status line
void dwinRedrawScreen(); // Redraw all screen elements
void hmiMainMenu(); // Main process screen
void hmiPrinting(); // Print page
void hmiReturnScreen(); // Return to previous screen before popups
void hmiWaitForUser();
void hmiSaveProcessID(const uint8_t id);
void hmiSDCardUpdate();
void eachMomentUpdate();
void updateVariable();
void dwinInitScreen();
void DWIN_HandleScreen();
void DWIN_CheckStatusMessage();
void dwinHandleScreen();
void dwinCheckStatusMessage();
void dwinHomingStart();
void dwinHomingDone();
#if HAS_MESH
void DWIN_MeshUpdate(const int8_t cpos, const int8_t tpos, const_float_t zval);
void dwinMeshUpdate(const int8_t cpos, const int8_t tpos, const_float_t zval);
#endif
void DWIN_LevelingStart();
void DWIN_LevelingDone();
void DWIN_Print_Started();
void DWIN_Print_Pause();
void DWIN_Print_Resume();
void DWIN_Print_Finished();
void DWIN_Print_Aborted();
void dwinLevelingStart();
void dwinLevelingDone();
void dwinPrintStarted();
void dwinPrintPause();
void dwinPrintResume();
void dwinPrintFinished();
void dwinPrintAborted();
#if HAS_FILAMENT_SENSOR
void DWIN_FilamentRunout(const uint8_t extruder);
void dwinFilamentRunout(const uint8_t extruder);
#endif
void DWIN_Print_Header(const char *text);
void DWIN_SetColorDefaults();
void DWIN_CopySettingsTo(char * const buff);
void DWIN_CopySettingsFrom(const char * const buff);
void DWIN_SetDataDefaults();
void DWIN_RebootScreen();
void dwinPrintHeader(const char *text);
void dwinSetColorDefaults();
void dwinCopySettingsTo(char * const buff);
void dwinCopySettingsFrom(const char * const buff);
void dwinSetDataDefaults();
void dwinRebootScreen();
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button=0);
void Draw_Popup_FilamentPurge();
void Goto_FilamentPurge();
void dwinPopupPause(FSTR_P const fmsg, uint8_t button=0);
void drawPopupFilamentPurge();
void gotoFilamentPurge();
#endif
// Utility and extensions
#if HAS_LOCKSCREEN
void DWIN_LockScreen();
void DWIN_UnLockScreen();
void HMI_LockScreen();
void dwinLockScreen();
void dwinUnLockScreen();
void hmiLockScreen();
#endif
#if HAS_MESH
void DWIN_MeshViewer();
void dwinMeshViewer();
#endif
#if HAS_GCODE_PREVIEW
void HMI_ConfirmToPrint();
void hmiConfirmToPrint();
#endif
#if HAS_ESDIAG
void Draw_EndStopDiag();
void drawEndStopDiag();
#endif
#if ENABLED(PRINTCOUNTER)
void Draw_PrintStats();
void drawPrintStats();
#endif
// Menu drawing functions
void Draw_Print_File_Menu();
void Draw_Control_Menu();
void Draw_AdvancedSettings_Menu();
void Draw_Prepare_Menu();
void Draw_Move_Menu();
void Draw_Tramming_Menu();
void drawPrintFileMenu();
void drawControlMenu();
void drawAdvancedSettingsMenu();
void drawPrepareMenu();
void drawMoveMenu();
void drawTrammingMenu();
#if HAS_HOME_OFFSET
void Draw_HomeOffset_Menu();
void drawHomeOffsetMenu();
#endif
#if HAS_BED_PROBE
void Draw_ProbeSet_Menu();
void drawProbeSetMenu();
#endif
void Draw_FilSet_Menu();
void drawFilSetMenu();
#if ENABLED(NOZZLE_PARK_FEATURE)
void Draw_ParkPos_Menu();
void drawParkPosMenu();
#endif
void Draw_PhySet_Menu();
void drawPhySetMenu();
#if ALL(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
void Draw_CaseLight_Menu();
void drawCaseLightMenu();
#endif
#if ENABLED(LED_CONTROL_MENU)
void Draw_LedControl_Menu();
void drawLedControlMenu();
#endif
void Draw_Tune_Menu();
void Draw_Motion_Menu();
void drawTuneMenu();
void drawMotionMenu();
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void Draw_FilamentMan_Menu();
void drawFilamentManMenu();
#endif
#if ENABLED(MESH_BED_LEVELING)
void Draw_ManualMesh_Menu();
void drawManualMeshMenu();
#endif
void Draw_Temperature_Menu();
void Draw_MaxSpeed_Menu();
void Draw_MaxAccel_Menu();
void drawTemperatureMenu();
void drawMaxSpeedMenu();
void drawMaxAccelMenu();
#if HAS_CLASSIC_JERK
void Draw_MaxJerk_Menu();
void drawMaxJerkMenu();
#endif
void Draw_Steps_Menu();
void drawStepsMenu();
#if ANY(HAS_BED_PROBE, BABYSTEPPING)
void Draw_ZOffsetWiz_Menu();
void drawZOffsetWizMenu();
#endif
#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU)
void Draw_Homing_Menu();
void drawHomingMenu();
#endif
#if ENABLED(FWRETRACT)
void Draw_FWRetract_Menu();
void drawFWRetractMenu();
#endif
#if HAS_MESH
void Draw_MeshSet_Menu();
void drawMeshSetMenu();
#if ENABLED(MESH_EDIT_MENU)
void Draw_EditMesh_Menu();
void drawEditMeshMenu();
#endif
#endif
#if HAS_TRINAMIC_CONFIG
void Draw_TrinamicConfig_menu();
#endif
// Custom colors editing
#if HAS_CUSTOM_COLORS
void DWIN_ApplyColor();
void Draw_SelectColors_Menu();
void Draw_GetColor_Menu();
void dwinApplyColor();
void drawSelectColorsMenu();
void drawGetColorMenu();
#endif
// PID
#if DWIN_PID_TUNE
#if PROUI_PID_TUNE
#include "../../../module/temperature.h"
void DWIN_StartM303(const bool seenC, const int c, const bool seenS, const heater_id_t hid, const celsius_t temp);
void DWIN_PidTuning(tempcontrol_t result);
void dwinStartM303(const bool seenC, const int c, const bool seenS, const heater_id_t hid, const celsius_t temp);
void dwinPidTuning(tempcontrol_t result);
#endif
#if ENABLED(PIDTEMP)
#if ENABLED(PID_AUTOTUNE_MENU)
void HotendPID();
void hotendPID();
#endif
#if ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU)
void Draw_HotendPID_Menu();
void drawHotendPIDMenu();
#endif
#endif
#if ENABLED(PIDTEMPBED)
#if ENABLED(PID_AUTOTUNE_MENU)
void BedPID();
void bedPID();
#endif
#if ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU)
void Draw_BedPID_Menu();
void drawBedPIDMenu();
#endif
#endif
// MPC
#if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
void Draw_HotendMPC_Menu();
void drawHotendMPCMenu();
#endif
#if ENABLED(MPC_AUTOTUNE)
void DWIN_MPCTuning(tempcontrol_t result);
void dwinMPCTuning(tempcontrol_t result);
#endif

View File

@@ -46,30 +46,30 @@
#define HAS_ZOFFSET_ITEM 1
#endif
#define Def_Background_Color RGB( 1, 12, 8)
#define Def_Cursor_Color RGB(20, 49, 31)
#define Def_TitleBg_Color RGB( 0, 23, 16)
#define Def_TitleTxt_Color Color_White
#define Def_Text_Color Color_White
#define Def_Selected_Color Select_Color
#define Def_SplitLine_Color RGB( 0, 23, 16)
#define Def_Highlight_Color Color_White
#define Def_StatusBg_Color RGB( 0, 23, 16)
#define Def_StatusTxt_Color Color_Yellow
#define Def_PopupBg_Color Color_Bg_Window
#define Def_PopupTxt_Color Popup_Text_Color
#define Def_AlertBg_Color Color_Bg_Red
#define Def_AlertTxt_Color Color_Yellow
#define Def_PercentTxt_Color Percent_Color
#define Def_Barfill_Color BarFill_Color
#define Def_Indicator_Color Color_White
#define Def_Coordinate_Color Color_White
#define Def_Button_Color RGB( 0, 23, 16)
#define defColorBackground RGB( 1, 12, 8)
#define defColorCursor RGB(20, 49, 31)
#define defColorTitleBg RGB( 0, 23, 16)
#define defColorTitleTxt COLOR_WHITE
#define defColorText COLOR_WHITE
#define defColorSelected COLOR_SELECT
#define defColorSplitLine RGB( 0, 23, 16)
#define defColorHighlight COLOR_WHITE
#define defColorStatusBg RGB( 0, 23, 16)
#define defColorStatusTxt COLOR_YELLOW
#define defColorPopupBg COLOR_BG_WINDOW
#define defColorPopupTxt COLOR_POPUP_TEXT
#define defColorAlertBg COLOR_BG_RED
#define defColorAlertTxt COLOR_YELLOW
#define defColorPercentTxt COLOR_PERCENT
#define defColorBarfill COLOR_BARFILL
#define defColorIndicator COLOR_WHITE
#define defColorCoordinate COLOR_WHITE
#define defColorButton RGB( 0, 23, 16)
#if ALL(LED_CONTROL_MENU, HAS_COLOR_LEDS)
#define Def_Leds_Color LEDColorWhite()
#define defColorLeds LEDColorWhite()
#endif
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
#define Def_CaseLight_Brightness 255
#define defCaseLightBrightness 255
#endif
#ifdef Z_AFTER_HOMING
#define DEF_Z_AFTER_HOMING Z_AFTER_HOMING

View File

@@ -42,7 +42,7 @@
// QR_Pixel: The pixel size occupied by each point of the QR code: 0x01-0x0F (1-16)
// (Nx, Ny): The coordinates of the upper left corner displayed by the QR code
// str: multi-bit data
void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, char *string) {
void dwinDrawQR(uint8_t QR_Pixel, uint16_t x, uint16_t y, char *string) {
size_t i = 0;
dwinByte(i, 0x21);
dwinWord(i, x);
@@ -64,7 +64,7 @@ void dwinIconShow(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
// xStart/yStart: Upper-left of virtual area
// xEnd/yEnd: Lower-right of virtual area
// x/y: Screen paste point
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
void dwinFrameAreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
size_t i = 0;
dwinByte(i, 0x26);
dwinWord(i, xStart);
@@ -84,7 +84,7 @@ void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16
// xStart/yStart: Upper-left of virtual area
// xEnd/yEnd: Lower-right of virtual area
// x/y: Screen paste point
void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
void dwinFrameAreaCopy(bool IBD, bool BIR, bool BFI, 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;
dwinByte(i, 0x27);
dwinByte(i, (IBD & 1) << 7 | (BIR & 1) << 6 | (BFI & 1) << 5 | cacheID);
@@ -102,8 +102,8 @@ void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t
// 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) {
DWIN_Frame_AreaCopy(false, false, true, cacheID, xStart, yStart, xEnd, yEnd, x, y);
void dwinFrameAreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
dwinFrameAreaCopy(false, false, true, cacheID, xStart, yStart, xEnd, yEnd, x, y);
}
// Write buffer data to the SRAM or Flash
@@ -111,7 +111,7 @@ void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint
// addr: start address
// length: Bytes to write
// data: address of the buffer with data
void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) {
void dwinWriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) {
const uint8_t max_size = 128;
uint16_t pending = length;
uint16_t to_send;
@@ -156,7 +156,7 @@ void dwinIconShow(uint16_t x, uint16_t y, uint16_t addr) {
// Write the contents of the 32KB SRAM data memory into the designated image memory space.
// picID: Picture memory space location, 0x00-0x0F, each space is 32Kbytes
void DWIN_SRAMToPic(uint8_t picID) {
void dwinSRAMToPic(uint8_t picID) {
size_t i = 0;
dwinByte(i, 0x33);
dwinByte(i, 0x5A);
@@ -167,7 +167,7 @@ void DWIN_SRAMToPic(uint8_t picID) {
//--------------------------Test area -------------------------
//void DWIN_ReadSRAM(uint16_t addr, const uint8_t length, const char * const data) {
//void dwinReadSRAM(uint16_t addr, const uint8_t length, const char * const data) {
// size_t i = 0;
// dwinByte(i, 0x32);
// dwinByte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash

View File

@@ -35,10 +35,10 @@
// QR_Pixel: The pixel size occupied by each point of the QR code: 0x01-0x0F (1-16)
// (Nx, Ny): The coordinates of the upper left corner displayed by the QR code
// str: multi-bit data
void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, char *string);
void dwinDrawQR(uint8_t QR_Pixel, uint16_t x, uint16_t y, char *string);
inline void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, FSTR_P title) {
DWIN_Draw_QR(QR_Pixel, x, y, (char *)title);
inline void dwinDrawQR(uint8_t QR_Pixel, uint16_t x, uint16_t y, FSTR_P fTitle) {
dwinDrawQR(QR_Pixel, x, y, (char *)fTitle);
}
// Copy area from virtual display area to current screen
@@ -46,13 +46,13 @@ inline void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, FSTR_P title)
// 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);
void dwinFrameAreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
// Copy area from current virtual display area to current screen
// xStart/yStart: Upper-left of virtual area
// xEnd/yEnd: Lower-right of virtual area
// x/y: Screen paste point
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
void dwinFrameAreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
// Copy area from virtual display area to current screen
// IBD: 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
@@ -62,14 +62,14 @@ void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16
// xStart/yStart: Upper-left of virtual area
// xEnd/yEnd: Lower-right of virtual area
// x/y: Screen paste point
void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
void dwinFrameAreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
// Write buffer data to the SRAM or Flash
// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
// addr: start address
// length: Bytes to write
// data: address of the buffer with data
void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data);
void dwinWriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data);
// Draw an Icon from SRAM
// x/y: Upper-left point
@@ -78,4 +78,4 @@ void dwinIconShow(uint16_t x, uint16_t y, uint16_t addr);
// Write the contents of the 32KB SRAM data memory into the designated image memory space.
// picID: Picture memory space location, 0x00-0x0F, each space is 32Kbytes
void DWIN_SRAMToPic(uint8_t picID);
void dwinSRAMToPic(uint8_t picID);

View File

@@ -43,41 +43,41 @@ popupChangeFunc_t popupChange = nullptr;
uint16_t HighlightYPos = 280;
void Draw_Select_Highlight(const bool sel, const uint16_t ypos) {
void drawSelectHighlight(const bool sel, const uint16_t ypos) {
HighlightYPos = ypos;
hmiFlag.select_flag = sel;
const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_Color,
c2 = sel ? HMI_data.PopupBg_Color : HMI_data.Highlight_Color;
const uint16_t c1 = sel ? hmiData.colorHighlight : hmiData.colorPopupBg,
c2 = sel ? hmiData.colorPopupBg : hmiData.colorHighlight;
dwinDrawRectangle(0, c1, 25, ypos - 1, 126, ypos + 38);
dwinDrawRectangle(0, c1, 24, ypos - 2, 127, ypos + 39);
dwinDrawRectangle(0, c2, 145, ypos - 1, 246, ypos + 38);
dwinDrawRectangle(0, c2, 144, ypos - 2, 247, ypos + 39);
}
void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) {
HMI_SaveProcessID(WaitResponse);
DWIN_Draw_Popup(icon, fmsg1, fmsg2, BTN_Continue); // Button Continue
void dwinPopupContinue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) {
hmiSaveProcessID(ID_WaitResponse);
dwinDrawPopup(icon, fmsg1, fmsg2, BTN_Continue); // Button Continue
dwinUpdateLCD();
}
void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) {
DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), fmsg2);
DWINUI::Draw_Button(BTN_Confirm, 26, 280);
DWINUI::Draw_Button(BTN_Cancel, 146, 280);
Draw_Select_Highlight(hmiFlag.select_flag);
void dwinPopupConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) {
dwinDrawPopup(ICON_BLTouch, F("Please confirm"), fmsg2);
DWINUI::drawButton(BTN_Confirm, 26, 280);
DWINUI::drawButton(BTN_Cancel, 146, 280);
drawSelectHighlight(hmiFlag.select_flag);
dwinUpdateLCD();
}
void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick/*=nullptr*/, const popupChangeFunc_t fnChange/*=nullptr*/) {
void gotoPopup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick/*=nullptr*/, const popupChangeFunc_t fnChange/*=nullptr*/) {
popupDraw = fnDraw;
popupClick = fnClick;
popupChange = fnChange;
HMI_SaveProcessID(Popup);
hmiSaveProcessID(ID_Popup);
hmiFlag.select_flag = false;
popupDraw();
}
void HMI_Popup() {
void hmiPopup() {
if (!wait_for_user) {
if (popupClick) popupClick();
return;
@@ -86,7 +86,7 @@ void HMI_Popup() {
EncoderState encoder_diffState = get_encoder_state();
if (encoder_diffState == ENCODER_DIFF_CW || encoder_diffState == ENCODER_DIFF_CCW) {
const bool change = encoder_diffState != ENCODER_DIFF_CW;
if (popupChange) popupChange(change); else Draw_Select_Highlight(change, HighlightYPos);
if (popupChange) popupChange(change); else drawSelectHighlight(change, HighlightYPos);
dwinUpdateLCD();
}
}

View File

@@ -36,38 +36,38 @@ typedef void (*popupClickFunc_t)();
typedef void (*popupChangeFunc_t)(const bool state);
extern popupDrawFunc_t popupDraw;
void Draw_Select_Highlight(const bool sel, const uint16_t ypos);
inline void Draw_Select_Highlight(const bool sel) { Draw_Select_Highlight(sel, 280); };
void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2);
void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2);
void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick=nullptr, const popupChangeFunc_t fnChange=nullptr);
void HMI_Popup();
void drawSelectHighlight(const bool sel, const uint16_t ypos);
inline void drawSelectHighlight(const bool sel) { drawSelectHighlight(sel, 280); };
void dwinPopupContinue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2);
void dwinPopupConfirmCancel(const uint8_t icon, FSTR_P const fmsg2);
void gotoPopup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick=nullptr, const popupChangeFunc_t fnChange=nullptr);
void hmiPopup();
inline void Draw_Popup_Bkgd() {
dwinDrawRectangle(1, HMI_data.PopupBg_Color, 14, 60, 258, 330);
dwinDrawRectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330);
inline void drawPopupBkgd() {
dwinDrawRectangle(1, hmiData.colorPopupBg, 14, 60, 258, 330);
dwinDrawRectangle(0, hmiData.colorHighlight, 14, 60, 258, 330);
}
template<typename T, typename U>
void DWIN_Draw_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) {
DWINUI::ClearMainArea();
Draw_Popup_Bkgd();
if (icon) DWINUI::Draw_Icon(icon, 101, 105);
if (amsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, amsg1);
if (amsg2) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 240, amsg2);
if (button) DWINUI::Draw_Button(button, 86, 280);
void dwinDrawPopup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) {
DWINUI::clearMainArea();
drawPopupBkgd();
if (icon) DWINUI::drawIcon(icon, 101, 105);
if (amsg1) DWINUI::drawCenteredString(hmiData.colorPopupTxt, 210, amsg1);
if (amsg2) DWINUI::drawCenteredString(hmiData.colorPopupTxt, 240, amsg2);
if (button) DWINUI::drawButton(button, 86, 280);
}
template<typename T, typename U>
void DWIN_Show_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) {
DWIN_Draw_Popup(icon, amsg1, amsg2, button);
void dwinShowPopup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) {
dwinDrawPopup(icon, amsg1, amsg2, button);
dwinUpdateLCD();
}
template<typename T, typename U>
void DWIN_Popup_Confirm(const uint8_t icon, T amsg1, U amsg2) {
HMI_SaveProcessID(WaitResponse);
DWIN_Draw_Popup(icon, amsg1, amsg2, BTN_Confirm); // Button Confirm
void dwinPopupConfirm(const uint8_t icon, T amsg1, U amsg2) {
hmiSaveProcessID(ID_WaitResponse);
dwinDrawPopup(icon, amsg1, amsg2, BTN_Confirm); // Button Confirm
dwinUpdateLCD();
}

View File

@@ -35,26 +35,26 @@
#include "dwinui.h"
xy_int_t DWINUI::cursor = { 0 };
uint16_t DWINUI::pencolor = Color_White;
uint16_t DWINUI::textcolor = Def_Text_Color;
uint16_t DWINUI::backcolor = Def_Background_Color;
uint16_t DWINUI::buttoncolor = Def_Button_Color;
uint8_t DWINUI::fontid = font8x16;
FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR);
uint16_t DWINUI::penColor = COLOR_WHITE;
uint16_t DWINUI::textColor = defColorText;
uint16_t DWINUI::backColor = defColorBackground;
uint16_t DWINUI::buttonColor = defColorButton;
uint8_t DWINUI::fontID = font8x16;
FSTR_P const DWINUI::author = F(STRING_CONFIG_H_AUTHOR);
void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr;
void (*DWINUI::onTitleDraw)(Title* t) = nullptr;
void DWINUI::init() {
cursor.reset();
pencolor = Color_White;
textcolor = Def_Text_Color;
backcolor = Def_Background_Color;
buttoncolor = Def_Button_Color;
fontid = font8x16;
penColor = COLOR_WHITE;
textColor = defColorText;
backColor = defColorBackground;
buttonColor = defColorButton;
fontID = font8x16;
}
// Set text/number font
void DWINUI::setFont(fontid_t fid) { fontid = fid; }
void DWINUI::setFont(fontid_t fid) { fontID = fid; }
// Get font character width
uint8_t DWINUI::fontWidth(fontid_t fid) {
@@ -95,33 +95,33 @@ uint8_t DWINUI::fontHeight(fontid_t fid) {
}
// Get screen x coordinates from text column
uint16_t DWINUI::ColToX(uint8_t col) { return col * fontWidth(fontid); }
uint16_t DWINUI::colToX(uint8_t col) { return col * fontWidth(fontID); }
// Get screen y coordinates from text row
uint16_t DWINUI::RowToY(uint8_t row) { return row * fontHeight(fontid); }
uint16_t DWINUI::rowToY(uint8_t row) { return row * fontHeight(fontID); }
// Set text/number color
void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) {
textcolor = fgcolor;
backcolor = bgcolor;
buttoncolor = alcolor;
void DWINUI::setColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) {
textColor = fgcolor;
backColor = bgcolor;
buttonColor = alcolor;
}
void DWINUI::SetTextColor(uint16_t fgcolor) {
textcolor = fgcolor;
void DWINUI::setTextColor(uint16_t fgcolor) {
textColor = fgcolor;
}
void DWINUI::SetBackgroundColor(uint16_t bgcolor) {
backcolor = bgcolor;
void DWINUI::setBackgroundColor(uint16_t bgcolor) {
backColor = bgcolor;
}
// Moves cursor to point
// x: abscissa of the display
// y: ordinate of the display
// point: xy coordinate
void DWINUI::MoveTo(int16_t x, int16_t y) {
void DWINUI::moveTo(int16_t x, int16_t y) {
cursor.x = x;
cursor.y = y;
}
void DWINUI::MoveTo(xy_int_t point) {
void DWINUI::moveTo(xy_int_t point) {
cursor = point;
}
@@ -129,16 +129,16 @@ void DWINUI::MoveTo(xy_int_t point) {
// x: abscissa of the display
// y: ordinate of the display
// point: xy coordinate
void DWINUI::MoveBy(int16_t x, int16_t y) {
void DWINUI::moveBy(int16_t x, int16_t y) {
cursor.x += x;
cursor.y += y;
}
void DWINUI::MoveBy(xy_int_t point) {
void DWINUI::moveBy(xy_int_t point) {
cursor += point;
}
// Draw a Centered string using arbitrary x1 and x2 margins
void DWINUI::Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) {
void DWINUI::drawCenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) {
const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(fid)) / 2 - 1;
dwinDrawString(bShow, fid, color, bColor, x, y, string);
}
@@ -148,28 +148,28 @@ void DWINUI::Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint1
// x: abscissa of the display
// y: ordinate of the display
// c: ASCII code of char
void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) {
void DWINUI::drawChar(uint16_t color, uint16_t x, uint16_t y, const char c) {
const char string[2] = { c, 0};
dwinDrawString(false, fontid, color, backcolor, x, y, string, 1);
dwinDrawString(false, fontID, color, backColor, x, y, string, 1);
}
// Draw a char at cursor position and increment cursor
void DWINUI::Draw_Char(uint16_t color, const char c) {
Draw_Char(color, cursor.x, cursor.y, c);
MoveBy(fontWidth(fontid), 0);
void DWINUI::drawChar(uint16_t color, const char c) {
drawChar(color, cursor.x, cursor.y, c);
moveBy(fontWidth(fontID), 0);
}
// Draw a string at cursor position
// color: Character color
// *string: The string
// rlimit: For draw less chars than string length use rlimit
void DWINUI::Draw_String(const char * const string, uint16_t rlimit) {
dwinDrawString(false, fontid, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
MoveBy(strlen(string) * fontWidth(fontid), 0);
void DWINUI::drawString(const char * const string, uint16_t rlimit) {
dwinDrawString(false, fontID, textColor, backColor, cursor.x, cursor.y, string, rlimit);
moveBy(strlen(string) * fontWidth(fontID), 0);
}
void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) {
dwinDrawString(false, fontid, color, backcolor, cursor.x, cursor.y, string, rlimit);
MoveBy(strlen(string) * fontWidth(fontid), 0);
void DWINUI::drawString(uint16_t color, const char * const string, uint16_t rlimit) {
dwinDrawString(false, fontID, color, backColor, cursor.x, cursor.y, string, rlimit);
moveBy(strlen(string) * fontWidth(fontID), 0);
}
// Draw a numeric integer value
@@ -181,7 +181,7 @@ void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rli
// iNum: Number of digits
// x/y: Upper-left coordinate
// value: Integer value
void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) {
void DWINUI::drawInt(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) {
char nstr[10];
sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value);
dwinDrawString(bShow, fid, color, bColor, x, y, nstr);
@@ -197,7 +197,7 @@ void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t col
// fNum: Number of decimal digits
// x/y: Upper-left coordinate
// value: float value
void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
void DWINUI::drawFloat(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
char nstr[10];
dwinDrawString(bShow, fid, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr));
}
@@ -217,19 +217,19 @@ void DWINUI::ICON_Show(bool BG, uint8_t icon, uint16_t x, uint16_t y) {
// ------------------------- Buttons ------------------------------//
void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) {
void DWINUI::drawButton(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) {
dwinDrawRectangle(1, bcolor, x1, y1, x2, y2);
Draw_CenteredString(0, fontid, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption);
drawCenteredString(0, fontID, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption);
}
void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) {
void DWINUI::drawButton(uint8_t id, uint16_t x, uint16_t y) {
switch (id) {
case BTN_Cancel : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break;
case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break;
case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break;
case BTN_Print : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break;
case BTN_Save : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break;
case BTN_Purge : Draw_Button(GET_TEXT_F(MSG_BUTTON_PURGE), x, y); break;
case BTN_Cancel : drawButton(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break;
case BTN_Confirm : drawButton(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break;
case BTN_Continue: drawButton(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break;
case BTN_Print : drawButton(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break;
case BTN_Save : drawButton(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break;
case BTN_Purge : drawButton(GET_TEXT_F(MSG_BUTTON_PURGE), x, y); break;
default: break;
}
}
@@ -241,7 +241,7 @@ void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) {
// x: the abscissa of the center of the circle
// y: ordinate of the center of the circle
// r: circle radius
void DWINUI::Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) {
void DWINUI::drawCircle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) {
int a = 0, b = 0;
while (a <= b) {
b = SQRT(sq(r) - sq(a));
@@ -263,7 +263,7 @@ void DWINUI::Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) {
// x: the abscissa of the center of the circle
// y: ordinate of the center of the circle
// r: circle radius
void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) {
void DWINUI::drawFillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) {
dwinDrawLine(bcolor, x - r, y, x + r, y);
uint16_t b = 1;
while (b <= r) {
@@ -322,54 +322,54 @@ uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
// bColor: Background color
// x/y: Upper-left point
// mode : 0 : unchecked, 1 : checked
void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) {
void DWINUI::drawCheckbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) {
dwinDrawRectangle(0, color, x + 2, y + 2, x + 17, y + 17);
dwinDrawRectangle(1, checked ? color : bcolor, x + 6, y + 6, x + 13, y + 13);
}
// Clear Menu by filling the menu area with background color
void DWINUI::ClearMainArea() {
dwinDrawRectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
void DWINUI::clearMainArea() {
dwinDrawRectangle(1, backColor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
}
/* Title Class ==============================================================*/
TitleClass Title;
Title title;
void TitleClass::draw() {
void Title::draw() {
if (DWINUI::onTitleDraw != nullptr) (*DWINUI::onTitleDraw)(this);
}
void TitleClass::SetCaption(const char * const title) {
void Title::setCaption(const char * const titleStr) {
frameid = 0;
if ( caption == title ) return;
const uint8_t len = _MIN(sizeof(caption) - 1, strlen(title));
memcpy(&caption[0], title, len);
if ( caption == titleStr ) return;
const uint8_t len = _MIN(sizeof(caption) - 1, strlen(titleStr));
memcpy(&caption[0], titleStr, len);
caption[len] = '\0';
}
void TitleClass::ShowCaption(const char * const title) {
SetCaption(title);
void Title::showCaption(const char * const titleStr) {
setCaption(titleStr);
draw();
}
void TitleClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
void Title::setFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
caption[0] = '\0';
frameid = id;
frame = { x1, y1, x2, y2 };
}
void TitleClass::SetFrame(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
SetFrame(1, x, y, x + w - 1, y + h - 1);
void Title::setFrame(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
setFrame(1, x, y, x + w - 1, y + h - 1);
}
void TitleClass::FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
SetFrame(id, x1, y1, x2, y2);
void Title::frameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
setFrame(id, x1, y1, x2, y2);
draw();
}
void TitleClass::FrameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
FrameCopy(1, x, y, x + w - 1, y + h - 1);
void Title::frameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
frameCopy(1, x, y, x + w - 1, y + h - 1);
}
#endif // DWIN_LCD_PROUI

View File

@@ -46,7 +46,7 @@
#define ICON_Cancel ICON_StockConfiguration
#define ICON_CustomPreheat ICON_SetEndTemp
#define ICON_Error ICON_TempTooHigh
#define ICON_ESDiag ICON_Info
#define ICON_esDiag ICON_Info
#define ICON_ExtrudeMinT ICON_HotendTemp
#define ICON_FilLoad ICON_WriteEEPROM
#define ICON_FilMan ICON_ResumeEEPROM
@@ -170,24 +170,24 @@
#define BTN_Purge 92
// Extended and default UI Colors
#define Color_Black 0
#define Color_Green RGB(0,63,0)
#define Color_Aqua RGB(0,63,31)
#define Color_Blue RGB(0,0,31)
#define Color_Light_White 0xBDD7
#define Color_Light_Green 0x3460
#define Color_Cyan 0x07FF
#define Color_Light_Cyan 0x04F3
#define Color_Light_Blue 0x3A6A
#define Color_Magenta 0xF81F
#define Color_Light_Magenta 0x9813
#define Color_Light_Red 0x8800
#define Color_Orange 0xFA20
#define Color_Light_Orange 0xFBC0
#define Color_Light_Yellow 0x8BE0
#define Color_Brown 0xCC27
#define Color_Light_Brown 0x6204
#define Color_Grey 0x18E3
#define COLOR_BLACK 0
#define COLOR_GREEN RGB(0,63,0)
#define COLOR_AQUA RGB(0,63,31)
#define COLOR_BLUE RGB(0,0,31)
#define COLOR_LIGHT_WHITE 0xBDD7
#define COLOR_LIGHT_GREEN 0x3460
#define COLOR_CYAN 0x07FF
#define COLOR_LIGHT_CYAN 0x04F3
#define COLOR_LIGHT_BLUE 0x3A6A
#define COLOR_MAGENTA 0xF81F
#define COLOR_LIGHT_MAGENTA 0x9813
#define COLOR_LIGHT_RED 0x8800
#define COLOR_ORANGE 0xFA20
#define COLOR_LIGHT_ORANGE 0xFBC0
#define COLOR_LIGHT_YELLOW 0x8BE0
#define COLOR_BROWN 0xCC27
#define COLOR_LIGHT_BROWN 0x6204
#define COLOR_GREY 0x18E3
// UI element defines and constants
#define DWIN_FONT_MENU font8x16
@@ -195,7 +195,7 @@
#define DWIN_FONT_HEAD font10x20
#define DWIN_FONT_ALERT font10x20
#define STATUS_Y 354
#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default fontid is font8x16
#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default fontID is font8x16
// Minimum unit (0.1) : multiple (10)
#define UNITFDIGITS 1
@@ -223,33 +223,33 @@ constexpr uint8_t TITLE_HEIGHT = 30, // Title bar heig
typedef struct { uint16_t left, top, right, bottom; } rect_t;
typedef struct { uint16_t x, y, w, h; } frame_rect_t;
class TitleClass {
class Title {
public:
char caption[32] = "";
uint8_t frameid = 0;
rect_t frame = {0};
void draw();
void SetCaption(const char * const title);
inline void SetCaption(FSTR_P title) { SetCaption((char *)title); }
void ShowCaption(const char * const title);
inline void ShowCaption(FSTR_P title) { ShowCaption((char *)title); }
void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
void SetFrame(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
void FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
void FrameCopy(uint16_t x, uint16_t y, uint16_t h, uint16_t v);
void setCaption(const char * const titleStr);
inline void setCaption(FSTR_P fTitle) { setCaption((char *)fTitle); }
void showCaption(const char * const titleStr);
inline void showCaption(FSTR_P fTitle) { showCaption((char *)fTitle); }
void setFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
void setFrame(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
void frameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
void frameCopy(uint16_t x, uint16_t y, uint16_t h, uint16_t v);
};
extern TitleClass Title;
extern Title title;
namespace DWINUI {
extern xy_int_t cursor;
extern uint16_t pencolor;
extern uint16_t textcolor;
extern uint16_t backcolor;
extern uint16_t buttoncolor;
extern fontid_t fontid;
extern FSTR_P const Author;
extern uint16_t penColor;
extern uint16_t textColor;
extern uint16_t backColor;
extern uint16_t buttonColor;
extern fontid_t fontID;
extern FSTR_P const author;
extern void (*onTitleDraw)(TitleClass* title);
extern void (*onTitleDraw)(Title* t);
// DWIN LCD Initialization
void init();
@@ -259,50 +259,50 @@ namespace DWINUI {
// Get font character width
uint8_t fontWidth(fontid_t cfont);
inline uint8_t fontWidth() { return fontWidth(fontid); };
inline uint8_t fontWidth() { return fontWidth(fontID); };
// Get font character height
uint8_t fontHeight(fontid_t cfont);
inline uint8_t fontHeight() { return fontHeight(fontid); };
inline uint8_t fontHeight() { return fontHeight(fontID); };
// Get screen x coordinates from text column
uint16_t ColToX(uint8_t col);
uint16_t colToX(uint8_t col);
// Get screen y coordinates from text row
uint16_t RowToY(uint8_t row);
uint16_t rowToY(uint8_t row);
// Set text/number color
void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor);
void SetTextColor(uint16_t fgcolor);
void SetBackgroundColor(uint16_t bgcolor);
void setColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor);
void setTextColor(uint16_t fgcolor);
void setBackgroundColor(uint16_t bgcolor);
// Moves cursor to point
// x: abscissa of the display
// y: ordinate of the display
// point: xy coordinate
void MoveTo(int16_t x, int16_t y);
void MoveTo(xy_int_t point);
void moveTo(int16_t x, int16_t y);
void moveTo(xy_int_t point);
// Moves cursor relative to the actual position
// x: abscissa of the display
// y: ordinate of the display
// point: xy coordinate
void MoveBy(int16_t x, int16_t y);
void MoveBy(xy_int_t point);
void moveBy(int16_t x, int16_t y);
void moveBy(xy_int_t point);
// Draw a line from the cursor to xy position
// color: Line segment color
// x/y: End point
inline void LineTo(uint16_t color, uint16_t x, uint16_t y) {
inline void lineTo(uint16_t color, uint16_t x, uint16_t y) {
dwinDrawLine(color, cursor.x, cursor.y, x, y);
}
inline void LineTo(uint16_t x, uint16_t y) {
dwinDrawLine(pencolor, cursor.x, cursor.y, x, y);
inline void lineTo(uint16_t x, uint16_t y) {
dwinDrawLine(penColor, cursor.x, cursor.y, x, y);
}
// Extend a frame box
// v: value to extend
inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) {
inline frame_rect_t extendFrame(frame_rect_t frame, uint8_t v) {
frame_rect_t t;
t.x = frame.x - v;
t.y = frame.y - v;
@@ -321,14 +321,14 @@ namespace DWINUI {
// Draw an Icon with transparent background from the library ICON
// icon: Icon ID
// x/y: Upper-left point
inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) {
inline void drawIcon(uint8_t icon, uint16_t x, uint16_t y) {
ICON_Show(false, icon, x, y);
}
// Draw an Icon from the library ICON with its background
// icon: Icon ID
// x/y: Upper-left point
inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) {
inline void drawIconWB(uint8_t icon, uint16_t x, uint16_t y) {
ICON_Show(true, icon, x, y);
}
@@ -341,48 +341,48 @@ namespace DWINUI {
// iNum: Number of digits
// x/y: Upper-left coordinate
// value: Integer value
void Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value);
void drawInt(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value);
// Draw a positive integer
inline void Draw_Int(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(bShow, 0, fid, color, bColor, iNum, x, y, value);
inline void drawInt(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(bShow, 0, fid, color, bColor, iNum, x, y, value);
}
inline void Draw_Int(uint8_t iNum, long value) {
Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
MoveBy(iNum * fontWidth(fontid), 0);
inline void drawInt(uint8_t iNum, long value) {
drawInt(false, 0, fontID, textColor, backColor, iNum, cursor.x, cursor.y, value);
moveBy(iNum * fontWidth(fontID), 0);
}
inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, x, y, value);
inline void drawInt(uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(false, 0, fontID, textColor, backColor, iNum, x, y, value);
}
inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(false, 0, fontid, color, backcolor, iNum, x, y, value);
inline void drawInt(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(false, 0, fontID, color, backColor, iNum, x, y, value);
}
inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(true, 0, fontid, color, bColor, iNum, x, y, value);
inline void drawInt(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(true, 0, fontID, color, bColor, iNum, x, y, value);
}
inline void Draw_Int(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(true, 0, fid, color, bColor, iNum, x, y, value);
inline void drawInt(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(true, 0, fid, color, bColor, iNum, x, y, value);
}
// Draw a signed integer
inline void Draw_Signed_Int(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(bShow, 1, fid, color, bColor, iNum, x, y, value);
inline void drawSignedInt(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(bShow, 1, fid, color, bColor, iNum, x, y, value);
}
inline void Draw_Signed_Int(uint8_t iNum, long value) {
Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
MoveBy(iNum * fontWidth(fontid), 0);
inline void drawSignedInt(uint8_t iNum, long value) {
drawInt(false, 1, fontID, textColor, backColor, iNum, cursor.x, cursor.y, value);
moveBy(iNum * fontWidth(fontID), 0);
}
inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, x, y, value);
inline void drawSignedInt(uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(false, 1, fontID, textColor, backColor, iNum, x, y, value);
}
inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(false, 1, fontid, color, backcolor, iNum, x, y, value);
inline void drawSignedInt(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(false, 1, fontID, color, backColor, iNum, x, y, value);
}
inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(true, 1, fontid, color, bColor, iNum, x, y, value);
inline void drawSignedInt(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(true, 1, fontID, color, bColor, iNum, x, y, value);
}
inline void Draw_Signed_Int(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(true, 1, fid, color, bColor, iNum, x, y, value);
inline void drawSignedInt(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
drawInt(true, 1, fid, color, bColor, iNum, x, y, value);
}
// Draw a numeric float value
@@ -395,48 +395,48 @@ namespace DWINUI {
// fNum: Number of decimal digits
// x/y: Upper-left coordinate
// value: float value
void Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
void drawFloat(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
// Draw a positive floating point number
inline void Draw_Float(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(bShow, 0, fid, color, bColor, iNum, fNum, x, y, value);
inline void drawFloat(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(bShow, 0, fid, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0);
inline void drawFloat(uint8_t iNum, uint8_t fNum, float value) {
drawFloat(false, 0, fontID, textColor, backColor, iNum, fNum, cursor.x, cursor.y, value);
moveBy((iNum + fNum + 1) * fontWidth(fontID), 0);
}
inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, x, y, value);
inline void drawFloat(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(false, 0, fontID, textColor, backColor, iNum, fNum, x, y, value);
}
inline void Draw_Float(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(false, 0, fid, textcolor, backcolor, iNum, fNum, x, y, value);
inline void drawFloat(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(false, 0, fid, textColor, 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, float value) {
Draw_Float(true, 0, fontid, color, bColor, iNum, fNum, x, y, value);
inline void drawFloat(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(true, 0, fontID, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Float(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(true, 0, fid, color, bColor, iNum, fNum, x, y, value);
inline void drawFloat(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(true, 0, fid, color, bColor, iNum, fNum, x, y, value);
}
// Draw a signed floating point number
inline void Draw_Signed_Float(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(bShow, 1, fid, color, bColor, iNum, fNum, x, y, value);
inline void drawSignedFloat(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(bShow, 1, fid, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0);
inline void drawSignedFloat(uint8_t iNum, uint8_t fNum, float value) {
drawFloat(false, 1, fontID, textColor, backColor, iNum, fNum, cursor.x, cursor.y, value);
moveBy((iNum + fNum + 1) * fontWidth(fontID), 0);
}
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, x, y, value);
inline void drawSignedFloat(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(false, 1, fontID, textColor, backColor, iNum, fNum, x, y, value);
}
inline void Draw_Signed_Float(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(false, 1, fid, textcolor, backcolor, iNum, fNum, x, y, value);
inline void drawSignedFloat(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(false, 1, fid, 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, float value) {
Draw_Float(true, 1, fontid, color, bColor, iNum, fNum, x, y, value);
inline void drawSignedFloat(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(true, 1, fontID, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Signed_Float(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(true, 1, fid, color, bColor, iNum, fNum, x, y, value);
inline void drawSignedFloat(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
drawFloat(true, 1, fid, color, bColor, iNum, fNum, x, y, value);
}
// Draw a char
@@ -444,23 +444,23 @@ namespace DWINUI {
// x: abscissa of the display
// y: ordinate of the display
// c: ASCII code of char
void Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c);
inline void Draw_Char(uint16_t x, uint16_t y, const char c) { Draw_Char(textcolor, x, y, c); };
void drawChar(uint16_t color, uint16_t x, uint16_t y, const char c);
inline void drawChar(uint16_t x, uint16_t y, const char c) { drawChar(textColor, x, y, c); };
// Draw a char at cursor position and increment cursor
void Draw_Char(uint16_t color, const char c);
inline void Draw_Char(const char c) { Draw_Char(textcolor, c); }
void drawChar(uint16_t color, const char c);
inline void drawChar(const char c) { drawChar(textColor, c); }
// Draw a string at cursor position
// color: Character color
// *string: The string
// rlimit: For draw less chars than string length use rlimit
void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF);
void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF);
inline void Draw_String(FSTR_P string, uint16_t rlimit = 0xFFFF) {
Draw_String(FTOP(string), rlimit);
void drawString(const char * const string, uint16_t rlimit = 0xFFFF);
void drawString(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF);
inline void drawString(FSTR_P string, uint16_t rlimit = 0xFFFF) {
drawString(FTOP(string), rlimit);
}
inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) {
Draw_String(color, FTOP(string), rlimit);
inline void drawString(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) {
drawString(color, FTOP(string), rlimit);
}
// Draw a string
@@ -469,29 +469,29 @@ namespace DWINUI {
// bColor: Background color
// x/y: Upper-left coordinate of the string
// *string: The string
inline void Draw_String(uint16_t x, uint16_t y, const char * const string) {
dwinDrawString(false, fontid, textcolor, backcolor, x, y, string);
inline void drawString(uint16_t x, uint16_t y, const char * const string) {
dwinDrawString(false, fontID, textColor, backColor, x, y, string);
}
inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) {
dwinDrawString(false, fontid, textcolor, backcolor, x, y, FTOP(title));
inline void drawString(uint16_t x, uint16_t y, FSTR_P fTitle) {
dwinDrawString(false, fontID, textColor, backColor, x, y, FTOP(fTitle));
}
inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) {
dwinDrawString(false, fontid, color, backcolor, x, y, string);
inline void drawString(uint16_t color, uint16_t x, uint16_t y, const char * const string) {
dwinDrawString(false, fontID, color, backColor, x, y, string);
}
inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) {
dwinDrawString(false, fontid, color, backcolor, x, y, title);
inline void drawString(uint16_t color, uint16_t x, uint16_t y, FSTR_P fTitle) {
dwinDrawString(false, fontID, color, backColor, x, y, fTitle);
}
inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
dwinDrawString(true, fontid, color, bgcolor, x, y, string);
inline void drawString(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
dwinDrawString(true, fontID, color, bgcolor, x, y, string);
}
inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
dwinDrawString(true, fontid, color, bgcolor, x, y, title);
inline void drawString(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P fTitle) {
dwinDrawString(true, fontID, color, bgcolor, x, y, fTitle);
}
inline void Draw_String(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
inline void drawString(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
dwinDrawString(true, fid, color, bgcolor, x, y, string);
}
inline void Draw_String(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
dwinDrawString(true, fid, color, bgcolor, x, y, title);
inline void drawString(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P fTitle) {
dwinDrawString(true, fid, color, bgcolor, x, y, fTitle);
}
// Draw a centered string using DWIN_WIDTH
@@ -501,40 +501,40 @@ namespace DWINUI {
// bColor: Background color
// y: Upper coordinate of the string
// *string: The string
void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string);
inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
Draw_CenteredString(bShow, fid, color, bColor, 0, DWIN_WIDTH, y, string);
void drawCenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string);
inline void drawCenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
drawCenteredString(bShow, fid, color, bColor, 0, DWIN_WIDTH, y, string);
}
inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) {
Draw_CenteredString(bShow, fid, color, bColor, y, FTOP(string));
inline void drawCenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) {
drawCenteredString(bShow, fid, color, bColor, y, FTOP(string));
}
inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) {
Draw_CenteredString(true, fontid, color, bcolor, y, string);
inline void drawCenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) {
drawCenteredString(true, fontID, color, bcolor, y, string);
}
inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, const char * const string) {
Draw_CenteredString(false, fid, color, backcolor, y, string);
inline void drawCenteredString(fontid_t fid, uint16_t color, uint16_t y, const char * const string) {
drawCenteredString(false, fid, color, backColor, y, string);
}
inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, FSTR_P title) {
Draw_CenteredString(false, fid, color, backcolor, y, title);
inline void drawCenteredString(fontid_t fid, uint16_t color, uint16_t y, FSTR_P fTitle) {
drawCenteredString(false, fid, color, backColor, y, fTitle);
}
inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) {
Draw_CenteredString(false, fontid, color, backcolor, y, string);
inline void drawCenteredString(uint16_t color, uint16_t y, const char * const string) {
drawCenteredString(false, fontID, color, backColor, y, string);
}
inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) {
Draw_CenteredString(false, fontid, color, backcolor, y, title);
inline void drawCenteredString(uint16_t color, uint16_t y, FSTR_P fTitle) {
drawCenteredString(false, fontID, color, backColor, y, fTitle);
}
inline void Draw_CenteredString(uint16_t y, const char * const string) {
Draw_CenteredString(false, fontid, textcolor, backcolor, y, string);
inline void drawCenteredString(uint16_t y, const char * const string) {
drawCenteredString(false, fontID, textColor, backColor, y, string);
}
inline void Draw_CenteredString(uint16_t y, FSTR_P title) {
Draw_CenteredString(false, fontid, textcolor, backcolor, y, title);
inline void drawCenteredString(uint16_t y, FSTR_P fTitle) {
drawCenteredString(false, fontID, textColor, backColor, y, fTitle);
}
// Draw a box
// mode: 0=frame, 1=fill, 2=XOR fill
// color: Rectangle color
// frame: Box coordinates and size
inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) {
inline void drawBox(uint8_t mode, uint16_t color, frame_rect_t frame) {
dwinDrawBox(mode, color, frame.x, frame.y, frame.w, frame.h);
}
@@ -543,9 +543,9 @@ namespace DWINUI {
// 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);
inline void Draw_Circle(uint16_t color, uint8_t r) {
Draw_Circle(color, cursor.x, cursor.y, r);
void drawCircle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
inline void drawCircle(uint16_t color, uint8_t r) {
drawCircle(color, cursor.x, cursor.y, r);
}
// Draw a checkbox
@@ -553,9 +553,9 @@ namespace DWINUI {
// bColor: Background color
// x/y: Upper-left point
// checked : 0 : unchecked, 1 : checked
void Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked);
inline void Draw_Checkbox(uint16_t x, uint16_t y, bool checked=false) {
Draw_Checkbox(textcolor, backcolor, x, y, checked);
void drawCheckbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked);
inline void drawCheckbox(uint16_t x, uint16_t y, bool checked=false) {
drawCheckbox(textColor, backColor, x, y, checked);
}
// Color Interpolator
@@ -568,14 +568,14 @@ namespace DWINUI {
// ------------------------- Buttons ------------------------------//
void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption);
inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) {
Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption));
void drawButton(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption);
inline void drawButton(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) {
drawButton(color, bcolor, x1, y1, x2, y2, FTOP(caption));
}
inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) {
Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption);
inline void drawButton(FSTR_P caption, uint16_t x, uint16_t y) {
drawButton(textColor, buttonColor, x, y, x + 99, y + 37, caption);
}
void Draw_Button(uint8_t id, uint16_t x, uint16_t y);
void drawButton(uint8_t id, uint16_t x, uint16_t y);
// -------------------------- Extra -------------------------------//
@@ -584,9 +584,9 @@ namespace DWINUI {
// 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);
inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) {
Draw_FillCircle(bcolor, cursor.x, cursor.y, r);
void drawFillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
inline void drawFillCircle(uint16_t bcolor, uint8_t r) {
drawFillCircle(bcolor, cursor.x, cursor.y, r);
}
// Color Interpolator through Red->Yellow->Green->Blue
@@ -600,7 +600,7 @@ namespace DWINUI {
// length: Bytes to write
// data: address of the buffer with data
inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) {
DWIN_WriteToMem(0x5A, addr, length, data);
dwinWriteToMem(0x5A, addr, length, data);
}
// Write buffer data to the Flash
@@ -608,11 +608,11 @@ namespace DWINUI {
// length: Bytes to write
// data: address of the buffer with data
inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) {
DWIN_WriteToMem(0xA5, addr, length, data);
dwinWriteToMem(0xA5, addr, length, data);
}
// Clear by filling the area with background color
// Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1)
void ClearMainArea();
void clearMainArea();
};

View File

@@ -46,38 +46,38 @@
#include "../../../module/probe.h"
#endif
ESDiagClass ESDiag;
ESDiag esDiag;
void draw_es_label(FSTR_P const flabel=nullptr) {
DWINUI::cursor.x = 40;
if (flabel) DWINUI::Draw_String(F(flabel));
DWINUI::Draw_String(F(": "));
DWINUI::MoveBy(0, 25);
if (flabel) DWINUI::drawString(F(flabel));
DWINUI::drawString(F(": "));
DWINUI::moveBy(0, 25);
}
void draw_es_state(const bool is_hit) {
const uint8_t LM = 130;
DWINUI::cursor.x = LM;
dwinDrawRectangle(1, HMI_data.PopupBg_Color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20);
is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN));
DWINUI::MoveBy(0, 25);
dwinDrawRectangle(1, hmiData.colorPopupBg, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20);
is_hit ? DWINUI::drawString(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::drawString(RGB(16,63,16), F(STR_ENDSTOP_OPEN));
DWINUI::moveBy(0, 25);
}
void ESDiagClass::Draw() {
Title.ShowCaption(GET_TEXT_F(MSG_ENDSTOP_TEST));
DWINUI::ClearMainArea();
Draw_Popup_Bkgd();
DWINUI::Draw_Button(BTN_Continue, 86, 250);
void ESDiag::draw() {
title.showCaption(GET_TEXT_F(MSG_ENDSTOP_TEST));
DWINUI::clearMainArea();
drawPopupBkgd();
DWINUI::drawButton(BTN_Continue, 86, 250);
DWINUI::cursor.y = 80;
#define ES_LABEL(S) draw_es_label(F(STR_##S))
TERN_(USE_X_MIN, ES_LABEL(X_MIN)); TERN_(USE_X_MAX, ES_LABEL(X_MAX));
TERN_(USE_Y_MIN, ES_LABEL(Y_MIN)); TERN_(USE_Y_MAX, ES_LABEL(Y_MAX));
TERN_(HAS_Z_MIN_PIN, ES_LABEL(Z_MIN)); TERN_(USE_Z_MAX, ES_LABEL(Z_MAX));
TERN_(HAS_FILAMENT_SENSOR, draw_es_label(F(STR_FILAMENT)));
Update();
update();
}
void ESDiagClass::Update() {
void ESDiag::update() {
DWINUI::cursor.y = 80;
#define ES_REPORT(S) draw_es_state(READ(S##_PIN) == S##_ENDSTOP_HIT_STATE)
TERN_(USE_X_MIN, ES_REPORT(X_MIN)); TERN_(USE_X_MAX, ES_REPORT(X_MAX));

View File

@@ -28,10 +28,10 @@
* Date: 2023/05/10
*/
class ESDiagClass {
class ESDiag {
public:
static void Draw();
static void Update();
static void draw();
static void update();
};
extern ESDiagClass ESDiag;
extern ESDiag esDiag;

View File

@@ -200,27 +200,27 @@ void Preview_DrawFromSD() {
if (Has_Preview()) {
MString<45> buf;
char str_1[6] = "", str_2[6] = "", str_3[6] = "";
dwinDrawRectangle(1, HMI_data.Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1);
dwinDrawRectangle(1, hmiData.colorBackground, 0, 0, DWIN_WIDTH, STATUS_Y - 1);
if (fileprop.time) {
buf.setf(F("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60);
DWINUI::Draw_String(20, 10, &buf);
DWINUI::drawString(20, 10, &buf);
}
if (fileprop.filament) {
buf.setf(F("Filament used: %s m"), dtostrf(fileprop.filament, 1, 2, str_1));
DWINUI::Draw_String(20, 30, &buf);
DWINUI::drawString(20, 30, &buf);
}
if (fileprop.layer) {
buf.setf(F("Layer height: %s mm"), dtostrf(fileprop.layer, 1, 2, str_1));
DWINUI::Draw_String(20, 50, &buf);
DWINUI::drawString(20, 50, &buf);
}
if (fileprop.width) {
buf.setf(F("Volume: %sx%sx%s mm"), dtostrf(fileprop.width, 1, 1, str_1), dtostrf(fileprop.length, 1, 1, str_2), dtostrf(fileprop.height, 1, 1, str_3));
DWINUI::Draw_String(20, 70, &buf);
DWINUI::drawString(20, 70, &buf);
}
DWINUI::Draw_Button(BTN_Print, 26, 290);
DWINUI::Draw_Button(BTN_Cancel, 146, 290);
DWINUI::drawButton(BTN_Print, 26, 290);
DWINUI::drawButton(BTN_Cancel, 146, 290);
Preview_Show();
Draw_Select_Highlight(true, 290);
drawSelectHighlight(true, 290);
dwinUpdateLCD();
}
else {

View File

@@ -36,39 +36,39 @@
#include "dwin.h"
#include "lockscreen.h"
LockScreenClass lockScreen;
LockScreen lockScreen;
uint8_t LockScreenClass::lock_pos = 0;
bool LockScreenClass::unlocked = false;
uint8_t LockScreenClass::rprocess = 0;
uint8_t LockScreen::lock_pos = 0;
bool LockScreen::unlocked = false;
uint8_t LockScreen::rprocess = 0;
void LockScreenClass::init() {
void LockScreen::init() {
lock_pos = 0;
unlocked = false;
draw();
}
void LockScreenClass::draw() {
Title.SetCaption(GET_TEXT_F(MSG_LOCKSCREEN));
DWINUI::ClearMainArea();
DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo
DWINUI::Draw_CenteredString(Color_White, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED));
DWINUI::Draw_CenteredString(Color_White, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK));
DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
dwinDrawBox(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
dwinDrawVLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
void LockScreen::draw() {
title.setCaption(GET_TEXT_F(MSG_LOCKSCREEN));
DWINUI::clearMainArea();
DWINUI::drawIcon(ICON_LOGO, 71, 120); // CREALITY logo
DWINUI::drawCenteredString(COLOR_WHITE, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED));
DWINUI::drawCenteredString(COLOR_WHITE, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK));
DWINUI::drawCenteredString(COLOR_WHITE, 240, F("-> | <-"));
dwinDrawBox(1, hmiData.colorBarfill, 0, 260, DWIN_WIDTH, 20);
dwinDrawVLine(COLOR_YELLOW, lock_pos * DWIN_WIDTH / 255, 260, 20);
dwinUpdateLCD();
}
void LockScreenClass::onEncoder(EncoderState encoder_diffState) {
void LockScreen::onEncoder(EncoderState encoder_diffState) {
switch (encoder_diffState) {
case ENCODER_DIFF_CW: lock_pos += 8; break;
case ENCODER_DIFF_CCW: lock_pos -= 8; break;
case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break;
default: break;
}
dwinDrawBox(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
dwinDrawVLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
dwinDrawBox(1, hmiData.colorBarfill, 0, 260, DWIN_WIDTH, 20);
dwinDrawVLine(COLOR_YELLOW, lock_pos * DWIN_WIDTH / 255, 260, 20);
dwinUpdateLCD();
}

View File

@@ -31,7 +31,7 @@
#include "../common/encoder.h"
#include <stdint.h>
class LockScreenClass {
class LockScreen {
private:
static bool unlocked;
static uint8_t lock_pos;
@@ -43,4 +43,4 @@ public:
static bool isUnlocked() { return unlocked; }
};
extern LockScreenClass lockScreen;
extern LockScreen lockScreen;

View File

@@ -37,135 +37,135 @@
int8_t MenuItemTotal = 0;
int8_t MenuItemCount = 0;
CustomMenuItemClass** MenuItems = nullptr;
MenuClass *CurrentMenu = nullptr;
MenuClass *PreviousMenu = nullptr;
MenuData_t MenuData;
CustomMenuItem** menuItems = nullptr;
Menu *currentMenu = nullptr;
Menu *previousMenu = nullptr;
MenuData_t menuData;
// Menuitem Drawing functions =================================================
void Draw_Title(TitleClass* title) {
dwinDrawRectangle(1, HMI_data.TitleBg_Color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1);
if (title->frameid)
DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1);
void drawTitle(Title* aTitle) {
dwinDrawRectangle(1, hmiData.colorTitleBg, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1);
if (aTitle->frameid)
dwinFrameAreaCopy(aTitle->frameid, aTitle->frame.left, aTitle->frame.top, aTitle->frame.right, aTitle->frame.bottom, 14, (TITLE_HEIGHT - (aTitle->frame.bottom - aTitle->frame.top)) / 2 - 1);
else
#if ENABLED(TITLE_CENTERED)
DWINUI::Draw_CenteredString(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_Color, HMI_data.TitleBg_Color, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption);
DWINUI::drawCenteredString(false, DWIN_FONT_HEAD, hmiData.colorTitleTxt, hmiData.colorTitleBg, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, aTitle->caption);
#else
dwinDrawString(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_Color, HMI_data.TitleBg_Color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption);
dwinDrawString(false, DWIN_FONT_HEAD, hmiData.colorTitleTxt, hmiData.colorTitleBg, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, aTitle->caption);
#endif
}
void Draw_Menu_Cursor(const int8_t line) {
void drawMenuCursor(const int8_t line) {
const uint16_t ypos = MYPOS(line);
DWINUI::Draw_Box(1, HMI_data.Cursor_Color, {0, ypos, 15, MLINE - 1});
DWINUI::drawBox(1, hmiData.colorCursor, {0, ypos, 15, MLINE - 1});
}
void Erase_Menu_Cursor(const int8_t line) {
void eraseMenuCursor(const int8_t line) {
const uint16_t ypos = MYPOS(line);
DWINUI::Draw_Box(1, HMI_data.Background_Color, {0, ypos, 15, MLINE - 1});
DWINUI::drawBox(1, hmiData.colorBackground, {0, ypos, 15, MLINE - 1});
}
void Erase_Menu_Text(const int8_t line) {
void eraseMenuText(const int8_t line) {
if (line < 0 || line >= TROWS) return;
const uint16_t ypos = MYPOS(line) + 1;
DWINUI::Draw_Box(1, HMI_data.Background_Color, {LBLX, ypos, DWIN_WIDTH - LBLX, MLINE - 2});
DWINUI::drawBox(1, hmiData.colorBackground, {LBLX, ypos, DWIN_WIDTH - LBLX, MLINE - 2});
}
void Draw_Menu_Line(const uint8_t line, const uint8_t icon/*=0*/, const char * const label/*=nullptr*/, bool more/*=false*/, bool selected/*=false*/) {
if (icon) DWINUI::Draw_Icon(icon, ICOX, MBASE(line) - 3);
if (label) DWINUI::Draw_String(LBLX, MBASE(line) - 1, (char*)label);
if (more) DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3);
if (selected) Draw_Menu_Cursor(line);
dwinDrawHLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240);
void drawMenuLine(const uint8_t line, const uint8_t icon/*=0*/, const char * const label/*=nullptr*/, bool more/*=false*/, bool selected/*=false*/) {
if (icon) DWINUI::drawIcon(icon, ICOX, MBASE(line) - 3);
if (label) DWINUI::drawString(LBLX, MBASE(line) - 1, (char*)label);
if (more) DWINUI::drawIcon(ICON_More, VALX + 16, MBASE(line) - 3);
if (selected) drawMenuCursor(line);
dwinDrawHLine(hmiData.colorSplitLine, 16, MYPOS(line + 1), 240);
}
void Draw_Menu_Line(const uint8_t line, const uint8_t icon/*=0*/, FSTR_P label/*=nullptr*/, bool more/*=false*/, bool selected/*=false*/) {
Draw_Menu_Line(line, icon, FTOP(label), more, selected);
void drawMenuLine(const uint8_t line, const uint8_t icon/*=0*/, FSTR_P label/*=nullptr*/, bool more/*=false*/, bool selected/*=false*/) {
drawMenuLine(line, icon, FTOP(label), more, selected);
}
void Draw_Chkb_Line(const uint8_t line, const bool checked) {
DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked);
void drawCheckboxLine(const uint8_t line, const bool checked) {
DWINUI::drawCheckbox(hmiData.colorText, hmiData.colorBackground, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked);
}
void Show_Chkb_Line(const bool checked) {
const uint8_t line = CurrentMenu->line();
DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked);
void showCheckboxLine(const bool checked) {
const uint8_t line = currentMenu->line();
DWINUI::drawCheckbox(hmiData.colorText, hmiData.colorBackground, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked);
dwinUpdateLCD();
}
void Toggle_Chkb_Line(bool &checked) {
void toggleCheckboxLine(bool &checked) {
checked = !checked;
Show_Chkb_Line(checked);
showCheckboxLine(checked);
}
void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value/*=0*/) {
DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value);
void drawMenuIntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value/*=0*/) {
DWINUI::drawSignedInt(hmiData.colorText, bcolor, iNum , VALX, MBASE(line) - 1, value);
}
void onDrawMenuItem(MenuItemClass* menuitem, int8_t line) {
if (menuitem->icon) DWINUI::Draw_Icon(menuitem->icon, ICOX, MBASE(line) - 3);
void onDrawMenuItem(MenuItem* menuitem, int8_t line) {
if (menuitem->icon) DWINUI::drawIcon(menuitem->icon, ICOX, MBASE(line) - 3);
if (menuitem->frameid)
DWIN_Frame_AreaCopy(menuitem->frameid, menuitem->frame.left, menuitem->frame.top, menuitem->frame.right, menuitem->frame.bottom, LBLX, MBASE(line));
dwinFrameAreaCopy(menuitem->frameid, menuitem->frame.left, menuitem->frame.top, menuitem->frame.right, menuitem->frame.bottom, LBLX, MBASE(line));
else if (menuitem->caption)
DWINUI::Draw_String(LBLX, MBASE(line) - 1, menuitem->caption);
dwinDrawHLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240);
DWINUI::drawString(LBLX, MBASE(line) - 1, menuitem->caption);
dwinDrawHLine(hmiData.colorSplitLine, 16, MYPOS(line + 1), 240);
}
void onDrawSubMenu(MenuItemClass* menuitem, int8_t line) {
void onDrawSubMenu(MenuItem* menuitem, int8_t line) {
onDrawMenuItem(menuitem, line);
DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3);
DWINUI::drawIcon(ICON_More, VALX + 16, MBASE(line) - 3);
}
void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, int32_t value) {
void onDrawIntMenu(MenuItem* menuitem, int8_t line, int32_t value) {
onDrawMenuItem(menuitem, line);
Draw_Menu_IntValue(HMI_data.Background_Color, line, 4, value);
drawMenuIntValue(hmiData.colorBackground, line, 4, value);
}
void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line) {
const int16_t value = *(int16_t*)static_cast<MenuItemPtrClass*>(menuitem)->value;
void onDrawPIntMenu(MenuItem* menuitem, int8_t line) {
const int16_t value = *(int16_t*)static_cast<MenuItemPtr*>(menuitem)->value;
onDrawIntMenu(menuitem, line, value);
}
void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line) {
const uint8_t value = *(uint8_t*)static_cast<MenuItemPtrClass*>(menuitem)->value;
void onDrawPInt8Menu(MenuItem* menuitem, int8_t line) {
const uint8_t value = *(uint8_t*)static_cast<MenuItemPtr*>(menuitem)->value;
onDrawIntMenu(menuitem, line, value);
}
void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) {
const uint32_t value = *(uint32_t*)static_cast<MenuItemPtrClass*>(menuitem)->value;
void onDrawPInt32Menu(MenuItem* menuitem, int8_t line) {
const uint32_t value = *(uint32_t*)static_cast<MenuItemPtr*>(menuitem)->value;
onDrawIntMenu(menuitem, line, value);
}
void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) {
void onDrawFloatMenu(MenuItem* menuitem, int8_t line, uint8_t dp, const float value) {
onDrawMenuItem(menuitem, line);
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value);
DWINUI::drawSignedFloat(hmiData.colorText, hmiData.colorBackground, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value);
}
void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp) {
const float value = *(float*)static_cast<MenuItemPtrClass*>(menuitem)->value;
void onDrawPFloatMenu(MenuItem* menuitem, int8_t line, uint8_t dp) {
const float value = *(float*)static_cast<MenuItemPtr*>(menuitem)->value;
onDrawFloatMenu(menuitem, line, dp, value);
}
void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) {
void onDrawChkbMenu(MenuItem* menuitem, int8_t line, bool checked) {
onDrawMenuItem(menuitem, line);
Draw_Chkb_Line(line, checked);
drawCheckboxLine(line, checked);
}
void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line) {
const bool val = *(bool*)static_cast<MenuItemPtrClass*>(menuitem)->value;
void onDrawChkbMenu(MenuItem* menuitem, int8_t line) {
const bool val = *(bool*)static_cast<MenuItemPtr*>(menuitem)->value;
onDrawChkbMenu(menuitem, line, val);
}
void DrawItemEdit(const bool selected) {
const uint16_t bcolor = selected ? HMI_data.Selected_Color : HMI_data.Background_Color;
const uint8_t iNum = 4 - ((MenuData.dp > 0) ? (MenuData.dp - 1) : 0);
const uint16_t bcolor = selected ? hmiData.colorSelected : hmiData.colorBackground;
const uint8_t iNum = 4 - ((menuData.dp > 0) ? (menuData.dp - 1) : 0);
switch (checkkey) {
case SetIntNoDraw: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break;
case SetInt:
case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break;
case SetFloat:
case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, bcolor, iNum, MenuData.dp, VALX - 2 * DWINUI::fontWidth(), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break;
case ID_SetIntNoDraw: if (menuData.liveUpdate) menuData.liveUpdate(); break;
case ID_SetInt:
case ID_SetPInt: DWINUI::drawSignedInt(hmiData.colorText, bcolor, iNum , VALX, MBASE(currentMenu->line()) - 1, menuData.value); break;
case ID_SetFloat:
case ID_SetPFloat: DWINUI::drawSignedFloat(hmiData.colorText, bcolor, iNum, menuData.dp, VALX - 2 * DWINUI::fontWidth(), MBASE(currentMenu->line()), menuData.value / POW(10, menuData.dp)); break;
default: break;
}
}
@@ -180,16 +180,16 @@ void DrawItemEdit(const bool selected) {
// hi: high limit
// dp: decimal places, 0 for integers
// val: value / scaled value
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) {
// liveUpdate: live update function when the encoder changes
// apply: update function when the encoder is pressed
void setOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*apply)()/*=nullptr*/, void (*liveUpdate)()/*=nullptr*/) {
checkkey = process;
MenuData.MinValue = lo;
MenuData.MaxValue = hi;
MenuData.dp = dp;
MenuData.Apply = Apply;
MenuData.LiveUpdate = LiveUpdate;
MenuData.Value = constrain(val, lo, hi);
menuData.minValue = lo;
menuData.maxValue = hi;
menuData.dp = dp;
menuData.apply = apply;
menuData.liveUpdate = liveUpdate;
menuData.value = constrain(val, lo, hi);
encoderRate.enabled = true;
}
@@ -198,10 +198,10 @@ void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp,
// lo: scaled low limit
// hi: scaled high limit
// val: value
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) {
SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate);
// liveUpdate: live update function when the encoder changes
// apply: update function when the encoder is pressed
void setValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*apply)()/*=nullptr*/, void (*liveUpdate)()/*=nullptr*/) {
setOnClick(process, lo, hi, 0, val, apply, liveUpdate);
DrawItemEdit(true);
}
@@ -210,11 +210,11 @@ void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const
// lo: scaled low limit
// hi: scaled high limit
// val: value
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) {
// liveUpdate: live update function when the encoder changes
// apply: update function when the encoder is pressed
void setValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*apply)()/*=nullptr*/, void (*liveUpdate)()/*=nullptr*/) {
const int32_t value = round(val * POW(10, dp));
SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate);
setOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, apply, liveUpdate);
DrawItemEdit(true);
}
@@ -222,21 +222,21 @@ void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp
// lo: scaled low limit
// hi: scaled high limit
// val: value
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) {
SetValueOnClick(SetInt, lo, hi, val, Apply, LiveUpdate);
// liveUpdate: live update function when the encoder changes
// apply: update function when the encoder is pressed
void setIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*apply)()/*=nullptr*/, void (*liveUpdate)()/*=nullptr*/) {
setValueOnClick(ID_SetInt, lo, hi, val, apply, liveUpdate);
}
// Generic onclick event for set pointer to 16 bit uinteger values
// lo: low limit
// hi: high limit
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) {
MenuData.P_Int = (int16_t*)static_cast<MenuItemPtrClass*>(CurrentMenu->SelectedItem())->value;
const int32_t value = *MenuData.P_Int;
SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate);
// liveUpdate: live update function when the encoder changes
// apply: update function when the encoder is pressed
void setPIntOnClick(const int32_t lo, const int32_t hi, void (*apply)()/*=nullptr*/, void (*liveUpdate)()/*=nullptr*/) {
menuData.intPtr = (int16_t*)static_cast<MenuItemPtr*>(currentMenu->selectedItem())->value;
const int32_t value = *menuData.intPtr;
setValueOnClick(ID_SetPInt, lo, hi, value, apply, liveUpdate);
}
// Generic onclick event for float values
@@ -245,31 +245,31 @@ void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)()/*=nullpt
// hi: high limit
// dp: decimal places
// val: value
void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) {
SetValueOnClick(SetFloat, lo, hi, dp, val, Apply, LiveUpdate);
void setFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*apply)()/*=nullptr*/, void (*liveUpdate)()/*=nullptr*/) {
setValueOnClick(ID_SetFloat, lo, hi, dp, val, apply, liveUpdate);
}
// Generic onclick event for set pointer to float values
// lo: low limit
// hi: high limit
// LiveUpdate: live update function when the encoder changes
// Apply: update function when the encoder is pressed
void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) {
MenuData.P_Float = (float*)static_cast<MenuItemPtrClass*>(CurrentMenu->SelectedItem())->value;
SetValueOnClick(SetPFloat, lo, hi, dp, *MenuData.P_Float, Apply, LiveUpdate);
// liveUpdate: live update function when the encoder changes
// apply: update function when the encoder is pressed
void setPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*apply)()/*=nullptr*/, void (*liveUpdate)()/*=nullptr*/) {
menuData.floatPtr = (float*)static_cast<MenuItemPtr*>(currentMenu->selectedItem())->value;
setValueOnClick(ID_SetPFloat, lo, hi, dp, *menuData.floatPtr, apply, liveUpdate);
}
// HMI Control functions ======================================================
// Generic menu control using the encoder
void HMI_Menu() {
void hmiMenu() {
EncoderState encoder_diffState = get_encoder_state();
if (CurrentMenu) {
if (currentMenu) {
if (encoder_diffState == ENCODER_DIFF_NO) return;
if (encoder_diffState == ENCODER_DIFF_ENTER)
CurrentMenu->onClick();
currentMenu->onClick();
else
CurrentMenu->onScroll(encoder_diffState == ENCODER_DIFF_CW);
currentMenu->onScroll(encoder_diffState == ENCODER_DIFF_CW);
}
}
@@ -279,283 +279,283 @@ void HMI_Menu() {
// 0 : no change
// 1 : live change
// 2 : apply change
int8_t HMI_Get(bool draw) {
const int32_t lo = MenuData.MinValue;
const int32_t hi = MenuData.MaxValue;
const int32_t cval = MenuData.Value;
int8_t hmiGet(bool draw) {
const int32_t lo = menuData.minValue;
const int32_t hi = menuData.maxValue;
const int32_t cval = menuData.value;
EncoderState encoder_diffState = TERN(SMOOTH_ENCODER_MENUITEMS, get_encoder_state(), encoderReceiveAnalyze());
if (encoder_diffState != ENCODER_DIFF_NO) {
if (applyEncoder(encoder_diffState, MenuData.Value)) {
if (applyEncoder(encoder_diffState, menuData.value)) {
encoderRate.enabled = false;
if (draw) DrawItemEdit(false);
checkkey = Menu;
checkkey = ID_Menu;
return 2;
}
LIMIT(MenuData.Value, lo, hi);
LIMIT(menuData.value, lo, hi);
}
const bool change = cval != MenuData.Value;
const bool change = cval != menuData.value;
if (change) DrawItemEdit(true);
return int8_t(change);
}
// Set and draw a value using the encoder
void HMI_SetDraw() {
int8_t val = HMI_Get(true);
void hmiSetDraw() {
int8_t val = hmiGet(true);
switch (val) {
case 0: return;
case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break;
case 2: if (MenuData.Apply) MenuData.Apply(); break;
case 1: if (menuData.liveUpdate) menuData.liveUpdate(); break;
case 2: if (menuData.apply) menuData.apply(); break;
}
}
// Set an value without drawing
void HMI_SetNoDraw() {
int8_t val = HMI_Get(false);
void hmiSetNoDraw() {
int8_t val = hmiGet(false);
switch (val) {
case 0: return;
case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break;
case 2: if (MenuData.Apply) MenuData.Apply(); break;
case 1: if (menuData.liveUpdate) menuData.liveUpdate(); break;
case 2: if (menuData.apply) menuData.apply(); break;
}
}
// Set an integer pointer variable using the encoder
void HMI_SetPInt() {
int8_t val = HMI_Get(true);
void hmiSetPInt() {
int8_t val = hmiGet(true);
switch (val) {
case 0: return;
case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break;
case 2: *MenuData.P_Int = MenuData.Value; if (MenuData.Apply) MenuData.Apply(); break;
case 1: if (menuData.liveUpdate) menuData.liveUpdate(); break;
case 2: *menuData.intPtr = menuData.value; if (menuData.apply) menuData.apply(); break;
}
}
// Set a scaled float pointer variable using the encoder
void HMI_SetPFloat() {
const int8_t val = HMI_Get(true);
void hmiSetPFloat() {
const int8_t val = hmiGet(true);
switch (val) {
case 0: return;
case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break;
case 2: *MenuData.P_Float = MenuData.Value / POW(10, MenuData.dp); if (MenuData.Apply) MenuData.Apply(); break;
case 1: if (menuData.liveUpdate) menuData.liveUpdate(); break;
case 2: *menuData.floatPtr = menuData.value / POW(10, menuData.dp); if (menuData.apply) menuData.apply(); break;
}
}
// Menu Class ===============================================================
MenuClass::MenuClass() {
Menu::Menu() {
selected = 0;
topline = 0;
}
void MenuClass::draw() {
MenuTitle.draw();
DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color);
dwinDrawRectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
void Menu::draw() {
menuTitle.draw();
DWINUI::setColors(hmiData.colorText, hmiData.colorBackground, hmiData.colorStatusBg);
dwinDrawRectangle(1, DWINUI::backColor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
for (int8_t i = 0; i < MenuItemCount; i++)
MenuItems[i]->draw(i - topline);
Draw_Menu_Cursor(line());
menuItems[i]->draw(i - topline);
drawMenuCursor(line());
dwinUpdateLCD();
}
void MenuClass::onScroll(bool dir) {
void Menu::onScroll(bool dir) {
int8_t sel = selected;
if (dir) sel++; else sel--;
LIMIT(sel, 0, MenuItemCount - 1);
if (sel != selected) {
Erase_Menu_Cursor(line());
eraseMenuCursor(line());
dwinUpdateLCD();
if ((sel - topline) == TROWS) {
dwinFrameAreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
dwinFrameAreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backColor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
topline++;
MenuItems[sel]->draw(TROWS - 1);
menuItems[sel]->draw(TROWS - 1);
}
if ((sel < topline)) {
dwinFrameAreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
dwinFrameAreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backColor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
topline--;
MenuItems[sel]->draw(0);
menuItems[sel]->draw(0);
}
selected = sel;
Draw_Menu_Cursor(line());
drawMenuCursor(line());
dwinUpdateLCD();
}
}
void MenuClass::onClick() {
if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)();
void Menu::onClick() {
if (menuItems[selected]->onClick != nullptr) (*menuItems[selected]->onClick)();
}
CustomMenuItemClass *MenuClass::SelectedItem() {
return MenuItems[selected];
CustomMenuItem *Menu::selectedItem() {
return menuItems[selected];
}
CustomMenuItemClass** MenuClass::Items() {
return MenuItems;
CustomMenuItem** Menu::items() {
return menuItems;
}
int8_t MenuClass::count() {
int8_t Menu::count() {
return MenuItemCount;
};
/* MenuItem Class ===========================================================*/
void CustomMenuItemClass::draw(int8_t line) {
void CustomMenuItem::draw(int8_t line) {
if (line < 0 || line >= TROWS) return;
if (onDraw != nullptr) (*onDraw)(static_cast<MenuItemClass*>(this), line);
if (onDraw != nullptr) (*onDraw)(static_cast<MenuItem*>(this), line);
};
void CustomMenuItemClass::redraw(bool erase/*=false*/) {
const int8_t line = CurrentMenu->line(this->pos);
if (erase) Erase_Menu_Text(line);
void CustomMenuItem::redraw(bool erase/*=false*/) {
const int8_t line = currentMenu->line(this->pos);
if (erase) eraseMenuText(line);
draw(line);
}
CustomMenuItemClass::CustomMenuItemClass(OnDrawItem ondraw, OnClickItem onclick) {
CustomMenuItem::CustomMenuItem(OnDrawItem ondraw, OnClickItem onclick) {
onClick = onclick;
onDraw = ondraw;
}
MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItemClass(ondraw, onclick) {
MenuItem::MenuItem(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItem(ondraw, onclick) {
icon = cicon;
SetCaption(text);
setCaption(text);
}
MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItemClass(ondraw, onclick) {
MenuItem::MenuItem(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItem(ondraw, onclick) {
icon = cicon;
caption[0] = '\0';
frameid = id;
frame = { x1, y1, x2, y2 };
}
void MenuItemClass::SetCaption(const char * const text) {
void MenuItem::setCaption(const char * const text) {
const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text));
memcpy(&caption[0], text, len);
caption[len] = '\0';
}
void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
void MenuItem::setFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
caption[0] = '\0';
frameid = id;
frame = { x1, y1, x2, y2 };
}
MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemClass(cicon, text, ondraw, onclick) {
MenuItemPtr::MenuItemPtr(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItem(cicon, text, ondraw, onclick) {
value = val;
};
// Menu auxiliary functions ===================================================
void MenuItemsClear() {
if (MenuItems == nullptr) return;
for (int8_t i = 0; i < MenuItemCount; i++) delete MenuItems[i];
delete[] MenuItems;
MenuItems = nullptr;
void menuItemsClear() {
if (menuItems == nullptr) return;
for (int8_t i = 0; i < MenuItemCount; i++) delete menuItems[i];
delete[] menuItems;
menuItems = nullptr;
MenuItemCount = 0;
MenuItemTotal = 0;
}
void MenuItemsPrepare(int8_t totalitems) {
MenuItemsClear();
void menuItemsPrepare(int8_t totalitems) {
menuItemsClear();
MenuItemTotal = _MIN(totalitems, MENU_MAX_ITEMS);
MenuItems = new CustomMenuItemClass*[totalitems];
menuItems = new CustomMenuItem*[totalitems];
}
bool IsMenu(MenuClass* _menu) {
return ((checkkey == Menu) && !!CurrentMenu && (CurrentMenu == _menu));
bool isMenu(Menu* _menu) {
return ((checkkey == ID_Menu) && !!currentMenu && (currentMenu == _menu));
}
template<typename T>
T* MenuItemAdd(T* menuitem) {
MenuItems[MenuItemCount] = menuitem;
T* menuItemAdd(T* menuitem) {
menuItems[MenuItemCount] = menuitem;
menuitem->pos = MenuItemCount++;
return menuitem;
}
CustomMenuItemClass* MenuItemAdd(OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) {
CustomMenuItem* menuItemAdd(OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) {
if (MenuItemCount < MenuItemTotal) {
CustomMenuItemClass* menuitem = new CustomMenuItemClass(ondraw, onclick);
return MenuItemAdd(menuitem);
CustomMenuItem* menuitem = new CustomMenuItem(ondraw, onclick);
return menuItemAdd(menuitem);
}
else return nullptr;
}
MenuItemClass* MenuItemAdd(uint8_t cicon, const char * const text/*=nullptr*/, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) {
MenuItem* menuItemAdd(uint8_t cicon, const char * const text/*=nullptr*/, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) {
if (MenuItemCount < MenuItemTotal) {
MenuItemClass* menuitem = new MenuItemClass(cicon, text, ondraw, onclick);
return MenuItemAdd(menuitem);
MenuItem* menuitem = new MenuItem(cicon, text, ondraw, onclick);
return menuItemAdd(menuitem);
}
else return nullptr;
}
MenuItemClass* MenuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) {
MenuItem* menuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) {
if (MenuItemCount < MenuItemTotal) {
MenuItemClass* menuitem = new MenuItemClass(cicon, id, x1, y1, x2, y2, ondraw, onclick);
return MenuItemAdd(menuitem);
MenuItem* menuitem = new MenuItem(cicon, id, x1, y1, x2, y2, ondraw, onclick);
return menuItemAdd(menuitem);
}
else return nullptr;
}
MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) {
MenuItem* editItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) {
if (MenuItemCount < MenuItemTotal) {
MenuItemClass* menuitem = new MenuItemPtrClass(cicon, text, ondraw, onclick, val);
return MenuItemAdd(menuitem);
MenuItem* menuitem = new MenuItemPtr(cicon, text, ondraw, onclick, val);
return menuItemAdd(menuitem);
}
else return nullptr;
}
void InitMenu() {
CurrentMenu = nullptr;
PreviousMenu = nullptr;
void initMenu() {
currentMenu = nullptr;
previousMenu = nullptr;
}
bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) {
if (!menu) menu = new MenuClass();
const bool NotCurrent = (CurrentMenu != menu);
bool setMenu(Menu* &menu, FSTR_P fTitle, int8_t totalitems) {
if (!menu) menu = new Menu();
const bool NotCurrent = (currentMenu != menu);
if (NotCurrent) {
menu->MenuTitle.SetCaption(title);
MenuItemsPrepare(totalitems);
menu->menuTitle.setCaption(fTitle);
menuItemsPrepare(totalitems);
}
return NotCurrent;
}
bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems) {
if (!menu) menu = new MenuClass();
const bool NotCurrent = (CurrentMenu != menu);
bool setMenu(Menu* &menu, frame_rect_t cn, FSTR_P fTitle, int8_t totalitems) {
if (!menu) menu = new Menu();
const bool NotCurrent = (currentMenu != menu);
if (NotCurrent) {
if (cn.w != 0)
menu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h);
menu->menuTitle.setFrame(cn.x, cn.y, cn.w, cn.h);
else
menu->MenuTitle.SetCaption(title);
MenuItemsPrepare(totalitems);
menu->menuTitle.setCaption(fTitle);
menuItemsPrepare(totalitems);
}
return NotCurrent;
}
void ResetMenu(MenuClass* &menu) {
void resetMenu(Menu* &menu) {
if (menu) {
menu->topline = 0;
menu->selected = 0;
}
}
void InvalidateMenu() {
ResetMenu(CurrentMenu);
CurrentMenu = nullptr;
void invalidateMenu() {
resetMenu(currentMenu);
currentMenu = nullptr;
}
void UpdateMenu(MenuClass* &menu) {
void updateMenu(Menu* &menu) {
if (!menu) return;
if (CurrentMenu != menu) {
PreviousMenu = CurrentMenu;
CurrentMenu = menu;
if (currentMenu != menu) {
previousMenu = currentMenu;
currentMenu = menu;
}
menu->draw();
}
void ReDrawMenu(bool force/*=false*/) {
if (CurrentMenu && (force || checkkey == Menu)) CurrentMenu->draw();
if (currentMenu && (force || checkkey == ID_Menu)) currentMenu->draw();
if (force) DrawItemEdit(true);
}
void ReDrawItem() {
static_cast<MenuItemClass*>(CurrentMenu->SelectedItem())->redraw(false);
static_cast<MenuItem*>(currentMenu->selectedItem())->redraw(false);
}
#endif // DWIN_LCD_PROUI

View File

@@ -37,154 +37,154 @@
#endif
typedef struct {
int32_t MaxValue = 0; // Auxiliar max integer/scaled float value
int32_t MinValue = 0; // Auxiliar min integer/scaled float value
int32_t maxValue = 0; // Auxiliar max integer/scaled float value
int32_t minValue = 0; // Auxiliar min integer/scaled float value
int8_t dp = 0; // Auxiliar decimal places
int32_t Value = 0; // Auxiliar integer / scaled float value
int16_t *P_Int = nullptr; // Auxiliar pointer to 16 bit integer variable
float *P_Float = nullptr; // Auxiliar pointer to float variable
void (*Apply)() = nullptr; // Auxiliar apply function
void (*LiveUpdate)() = nullptr; // Auxiliar live update function
int32_t value = 0; // Auxiliar integer / scaled float value
int16_t *intPtr = nullptr; // Auxiliar pointer to 16 bit integer variable
float *floatPtr = nullptr; // Auxiliar pointer to float variable
void (*apply)() = nullptr; // Auxiliar apply function
void (*liveUpdate)() = nullptr; // Auxiliar live update function
} MenuData_t;
extern MenuData_t MenuData;
extern MenuData_t menuData;
// Auxiliary Macros ===========================================================
// Create and add a MenuItem object to the menu array
#define SET_MENU(I,L,V) SetMenu(I, GET_TEXT_F(L), V)
#define SET_MENU_F(I,L,V) SetMenu(I, F(L), V)
#define SET_MENU_R(I,R,L,V) SetMenu(I, R, GET_TEXT_F(L), V)
#define SET_MENU(I,L,V) setMenu(I, GET_TEXT_F(L), V)
#define SET_MENU_F(I,L,V) setMenu(I, F(L), V)
#define SET_MENU_R(I,R,L,V) setMenu(I, R, GET_TEXT_F(L), V)
#define BACK_ITEM(H) MenuItemAdd(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, H)
#define MENU_ITEM(I,L,V...) MenuItemAdd(I, GET_TEXT_F(L), V)
#define EDIT_ITEM(I,L,V...) EditItemAdd(I, GET_TEXT_F(L), V)
#define MENU_ITEM_F(I,L,V...) MenuItemAdd(I, F(L), V)
#define EDIT_ITEM_F(I,L,V...) EditItemAdd(I, F(L), V)
#define BACK_ITEM(H) menuItemAdd(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, H)
#define MENU_ITEM(I,L,V...) menuItemAdd(I, GET_TEXT_F(L), V)
#define EDIT_ITEM(I,L,V...) editItemAdd(I, GET_TEXT_F(L), V)
#define MENU_ITEM_F(I,L,V...) menuItemAdd(I, F(L), V)
#define EDIT_ITEM_F(I,L,V...) editItemAdd(I, F(L), V)
// Menu Classes ===============================================================
class CustomMenuItemClass;
class MenuItemClass;
class CustomMenuItem;
class MenuItem;
typedef void (*OnDrawCustomItem)(CustomMenuItemClass* menuitem, int8_t line);
typedef void (*OnDrawItem)(MenuItemClass* menuitem, int8_t line);
typedef void (*OnDrawCustomItem)(CustomMenuItem* menuitem, int8_t line);
typedef void (*OnDrawItem)(MenuItem* menuitem, int8_t line);
typedef void (*OnClickItem)();
class CustomMenuItemClass {
class CustomMenuItem {
public:
int8_t pos = 0;
OnDrawItem onDraw = nullptr;
void (*onClick)() = nullptr;
CustomMenuItemClass() {};
CustomMenuItemClass(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
virtual ~CustomMenuItemClass(){};
CustomMenuItem() {};
CustomMenuItem(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
virtual ~CustomMenuItem(){};
virtual void draw(int8_t line);
void redraw(bool erase=false);
};
class MenuItemClass: public CustomMenuItemClass {
class MenuItem: public CustomMenuItem {
public:
uint8_t icon = 0;
char caption[MENU_CHAR_LIMIT] = "";
uint8_t frameid = 0;
rect_t frame = {0};
using CustomMenuItemClass::CustomMenuItemClass;
MenuItemClass(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
void SetCaption(const char * const text = nullptr);
using CustomMenuItem::CustomMenuItem;
MenuItem(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
MenuItem(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
void setFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
void setCaption(const char * const text = nullptr);
};
class MenuItemPtrClass: public MenuItemClass {
class MenuItemPtr: public MenuItem {
public:
void *value = nullptr;
using MenuItemClass::MenuItemClass;
MenuItemPtrClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val);
MenuItemPtrClass(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){}
using MenuItem::MenuItem;
MenuItemPtr(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val);
MenuItemPtr(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemPtr(cicon, FTOP(text), ondraw, onclick, val){}
};
class MenuClass {
class Menu {
public:
int8_t topline = 0;
int8_t selected = 0;
TitleClass MenuTitle;
MenuClass();
virtual ~MenuClass(){};
Title menuTitle;
Menu();
virtual ~Menu(){};
inline int8_t line() { return selected - topline; };
inline int8_t line(uint8_t pos) {return pos - topline; };
int8_t count();
virtual void draw();
virtual void onScroll(bool dir);
void onClick();
CustomMenuItemClass* SelectedItem();
static CustomMenuItemClass** Items();
CustomMenuItem* selectedItem();
static CustomMenuItem** items();
};
extern MenuClass *CurrentMenu;
extern MenuClass *PreviousMenu;
extern Menu *currentMenu;
extern Menu *previousMenu;
// Menuitem Drawing functions =================================================
void Draw_Title(TitleClass* title);
void Draw_Menu_Cursor(const int8_t line);
void Erase_Menu_Cursor(const int8_t line);
void Erase_Menu_Text(const int8_t line);
void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false, bool selected=false);
void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, FSTR_P label=nullptr, bool more=false, bool selected=false);
void Draw_Chkb_Line(const uint8_t line, const bool checked);
void Show_Chkb_Line(const bool checked);
void Toggle_Chkb_Line(bool &checked);
void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value=0);
void onDrawMenuItem(MenuItemClass* menuitem, int8_t line);
void onDrawSubMenu(MenuItemClass* menuitem, int8_t line);
void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, int32_t value);
void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line);
void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line);
void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line);
void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value);
void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp);
inline void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, UNITFDIGITS); };
inline void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 2); };
inline void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 3); };
inline void onDrawPFloat4Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 4); };
void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked);
void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line);
void drawTitle(Title* aTitle);
void drawMenuCursor(const int8_t line);
void eraseMenuCursor(const int8_t line);
void eraseMenuText(const int8_t line);
void drawMenuLine(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false, bool selected=false);
void drawMenuLine(const uint8_t line, const uint8_t icon=0, FSTR_P label=nullptr, bool more=false, bool selected=false);
void drawCheckboxLine(const uint8_t line, const bool checked);
void showCheckboxLine(const bool checked);
void toggleCheckboxLine(bool &checked);
void drawMenuIntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value=0);
void onDrawMenuItem(MenuItem* menuitem, int8_t line);
void onDrawSubMenu(MenuItem* menuitem, int8_t line);
void onDrawIntMenu(MenuItem* menuitem, int8_t line, int32_t value);
void onDrawPIntMenu(MenuItem* menuitem, int8_t line);
void onDrawPInt8Menu(MenuItem* menuitem, int8_t line);
void onDrawPInt32Menu(MenuItem* menuitem, int8_t line);
void onDrawFloatMenu(MenuItem* menuitem, int8_t line, uint8_t dp, const float value);
void onDrawPFloatMenu(MenuItem* menuitem, int8_t line, uint8_t dp);
inline void onDrawPFloatMenu(MenuItem* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, UNITFDIGITS); };
inline void onDrawPFloat2Menu(MenuItem* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 2); };
inline void onDrawPFloat3Menu(MenuItem* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 3); };
inline void onDrawPFloat4Menu(MenuItem* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 4); };
void onDrawChkbMenu(MenuItem* menuitem, int8_t line, bool checked);
void onDrawChkbMenu(MenuItem* menuitem, int8_t line);
// On click functions =========================================================
void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr);
void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr);
void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr);
void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr);
void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr);
void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr);
void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr);
void setOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*apply)()=nullptr, void (*liveUpdate)()=nullptr);
void setValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*apply)()=nullptr, void (*liveUpdate)()=nullptr);
void setValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*apply)()=nullptr, void (*liveUpdate)()=nullptr);
void setIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*apply)()=nullptr, void (*liveUpdate)()=nullptr);
void setPIntOnClick(const int32_t lo, const int32_t hi, void (*apply)()=nullptr, void (*liveUpdate)()=nullptr);
void setFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*apply)()=nullptr, void (*liveUpdate)()=nullptr);
void setPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*apply)()=nullptr, void (*liveUpdate)()=nullptr);
// HMI user control functions =================================================
void HMI_Menu();
void HMI_SetDraw();
void HMI_SetNoDraw();
void HMI_SetPInt();
void HMI_SetPFloat();
void hmiMenu();
void hmiSetDraw();
void hmiSetNoDraw();
void hmiSetPInt();
void hmiSetPFloat();
// Menu auxiliary functions ===================================================
// Initialize menu
void InitMenu();
void initMenu();
// Create a new menu
bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems);
bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems);
bool setMenu(Menu* &menu, FSTR_P fTitle, int8_t totalitems);
bool setMenu(Menu* &menu, frame_rect_t cn, FSTR_P fTitle, int8_t totalitems);
// Reset top line and selected item
void ResetMenu(MenuClass* &menu);
void resetMenu(Menu* &menu);
// Invalidate CurrentMenu to prepare for full menu drawing
void InvalidateMenu();
// Invalidate currentMenu to prepare for full menu drawing
void invalidateMenu();
//Update the Menu and Draw if it is valid
void UpdateMenu(MenuClass* &menu);
void updateMenu(Menu* &menu);
//Redraw the current Menu if it is valid
void ReDrawMenu(bool force=false);
@@ -192,23 +192,23 @@ void ReDrawMenu(bool force=false);
//Redraw selected menu item
void ReDrawItem();
// Clear MenuItems array and free MenuItems elements
void MenuItemsClear();
// Clear menuItems array and free menuItems elements
void menuItemsClear();
// Prepare MenuItems array
void MenuItemsPrepare(int8_t totalitems);
// Prepare menuItems array
void menuItemsPrepare(int8_t totalitems);
// Is the current menu = menu?
bool IsMenu(MenuClass* menu);
bool isMenu(Menu* menu);
// Add elements to the MenuItems array
CustomMenuItemClass* MenuItemAdd(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
MenuItemClass* MenuItemAdd(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
inline MenuItemClass* MenuItemAdd(uint8_t cicon, FSTR_P text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr) {
return MenuItemAdd(cicon, FTOP(text), ondraw, onclick);
// Add elements to the menuItems array
CustomMenuItem* menuItemAdd(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
MenuItem* menuItemAdd(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
inline MenuItem* menuItemAdd(uint8_t cicon, FSTR_P text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr) {
return menuItemAdd(cicon, FTOP(text), ondraw, onclick);
}
MenuItemClass* MenuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val);
inline MenuItemClass* EditItemAdd(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) {
return EditItemAdd(cicon, FTOP(text), ondraw, onclick, val);
MenuItem* menuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
MenuItem* editItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val);
inline MenuItem* editItemAdd(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) {
return editItemAdd(cicon, FTOP(text), ondraw, onclick, val);
}

View File

@@ -56,101 +56,101 @@ uint8_t rmax; // Maximum radius
constexpr uint8_t meshfont = TERN(TJC_DISPLAY, font8x16, font6x12);
MeshViewerClass MeshViewer;
MeshViewer meshViewer;
float MeshViewerClass::max, MeshViewerClass::min;
float MeshViewer::max, MeshViewer::min;
void MeshViewerClass::DrawMeshGrid(const uint8_t csizex, const uint8_t csizey) {
void MeshViewer::drawMeshGrid(const uint8_t csizex, const uint8_t csizey) {
sizex = csizex;
sizey = csizey;
rmax = _MIN(margin - 2, 0.5 * (width) / (sizex - 1));
min = 100;
max = -100;
DWINUI::ClearMainArea();
dwinDrawRectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(sizex - 1), py(sizey - 1));
for (uint8_t x = 1; x < sizex - 1; ++x) dwinDrawVLine(HMI_data.SplitLine_Color, px(x), py(sizey - 1), width);
for (uint8_t y = 1; y < sizey - 1; ++y) dwinDrawHLine(HMI_data.SplitLine_Color, px(0), py(y), width);
DWINUI::clearMainArea();
dwinDrawRectangle(0, hmiData.colorSplitLine, px(0), py(0), px(sizex - 1), py(sizey - 1));
for (uint8_t x = 1; x < sizex - 1; ++x) dwinDrawVLine(hmiData.colorSplitLine, px(x), py(sizey - 1), width);
for (uint8_t y = 1; y < sizey - 1; ++y) dwinDrawHLine(hmiData.colorSplitLine, px(0), py(y), width);
}
void MeshViewerClass::DrawMeshPoint(const uint8_t x, const uint8_t y, const float z) {
void MeshViewer::drawMeshPoint(const uint8_t x, const uint8_t y, const float z) {
const uint8_t fs = DWINUI::fontWidth(meshfont);
const int16_t v = isnan(z) ? 0 : round(z * 100);
NOLESS(max, z);
NOMORE(min, z);
const uint16_t color = DWINUI::RainbowInt(v, zmin, zmax);
DWINUI::Draw_FillCircle(color, px(x), py(y), r(_MAX(_MIN(v,zmax),zmin)));
DWINUI::drawFillCircle(color, px(x), py(y), r(_MAX(_MIN(v,zmax),zmin)));
TERN_(TJC_DISPLAY, delay(100));
if (sizex < (ENABLED(TJC_DISPLAY) ? 8 : 9)) {
if (v == 0) DWINUI::Draw_Float(meshfont, 1, 2, px(x) - 2*fs, py(y) - fs, 0);
else DWINUI::Draw_Signed_Float(meshfont, 1, 2, px(x) - 3*fs, py(y) - fs, z);
if (v == 0) DWINUI::drawFloat(meshfont, 1, 2, px(x) - 2*fs, py(y) - fs, 0);
else DWINUI::drawSignedFloat(meshfont, 1, 2, px(x) - 3*fs, py(y) - fs, z);
}
else {
char str_1[9];
str_1[0] = '\0';
switch (v) {
case -999 ... -100:
DWINUI::Draw_Signed_Float(meshfont, 1, 1, px(x) - 3*fs, py(y) - fs, z);
DWINUI::drawSignedFloat(meshfont, 1, 1, px(x) - 3*fs, py(y) - fs, z);
break;
case -99 ... -1:
sprintf_P(str_1, PSTR("-.%02i"), -v);
break;
case 0:
dwinDrawString(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, py(y) - fs, "0");
dwinDrawString(false, meshfont, DWINUI::textColor, DWINUI::backColor, px(x) - 4, py(y) - fs, "0");
break;
case 1 ... 99:
sprintf_P(str_1, PSTR(".%02i"), v);
break;
case 100 ... 999:
DWINUI::Draw_Signed_Float(meshfont, 1, 1, px(x) - 3 * fs, py(y) - fs, z);
DWINUI::drawSignedFloat(meshfont, 1, 1, px(x) - 3 * fs, py(y) - fs, z);
break;
}
if (str_1[0])
dwinDrawString(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, px(x) - 2 * fs, py(y) - fs, str_1);
dwinDrawString(false, meshfont, DWINUI::textColor, DWINUI::backColor, px(x) - 2 * fs, py(y) - fs, str_1);
}
}
void MeshViewerClass::DrawMesh(const bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey) {
DrawMeshGrid(csizex, csizey);
void MeshViewer::drawMesh(const bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey) {
drawMeshGrid(csizex, csizey);
for (uint8_t y = 0; y < csizey; ++y) {
hal.watchdog_refresh();
for (uint8_t x = 0; x < csizex; ++x) DrawMeshPoint(x, y, zval[x][y]);
for (uint8_t x = 0; x < csizex; ++x) drawMeshPoint(x, y, zval[x][y]);
}
}
void MeshViewerClass::Draw(const bool withsave/*=false*/, const bool redraw/*=true*/) {
Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER));
void MeshViewer::draw(const bool withsave/*=false*/, const bool redraw/*=true*/) {
title.showCaption(GET_TEXT_F(MSG_MESH_VIEWER));
#if ENABLED(USE_GRID_MESHVIEWER)
DWINUI::ClearMainArea();
DWINUI::clearMainArea();
bedLevelTools.viewer_print_value = true;
bedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT);
bedLevelTools.drawBedMesh(-1, 1, 8, 10 + TITLE_HEIGHT);
#else
if (redraw) DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
else DWINUI::Draw_Box(1, HMI_data.Background_Color, { 89, 305, 99, 38 });
if (redraw) drawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
else DWINUI::drawBox(1, hmiData.colorBackground, { 89, 305, 99, 38 });
#endif
if (withsave) {
DWINUI::Draw_Button(BTN_Save, 26, 305);
DWINUI::Draw_Button(BTN_Continue, 146, 305);
Draw_Select_Highlight(hmiFlag.select_flag, 305);
DWINUI::drawButton(BTN_Save, 26, 305);
DWINUI::drawButton(BTN_Continue, 146, 305);
drawSelectHighlight(hmiFlag.select_flag, 305);
}
else
DWINUI::Draw_Button(BTN_Continue, 86, 305);
DWINUI::drawButton(BTN_Continue, 86, 305);
#if ENABLED(USE_GRID_MESHVIEWER)
bedLevelTools.Set_Mesh_Viewer_Status();
bedLevelTools.setMeshViewerStatus();
#else
char str_1[6], str_2[6] = "";
ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), dtostrf(min, 1, 2, str_1), dtostrf(max, 1, 2, str_2));
#endif
}
void Draw_MeshViewer() { MeshViewer.Draw(true, meshredraw); }
void drawMeshViewer() { meshViewer.draw(true, meshredraw); }
void onClick_MeshViewer() { if (hmiFlag.select_flag) SaveMesh(); HMI_ReturnScreen(); }
void onClick_MeshViewer() { if (hmiFlag.select_flag) saveMesh(); hmiReturnScreen(); }
void Goto_MeshViewer(const bool redraw) {
void gotoMeshViewer(const bool redraw) {
meshredraw = redraw;
if (leveling_is_valid()) Goto_Popup(Draw_MeshViewer, onClick_MeshViewer);
else HMI_ReturnScreen();
if (leveling_is_valid()) gotoPopup(drawMeshViewer, onClick_MeshViewer);
else hmiReturnScreen();
}
#endif // DWIN_LCD_PROUI && HAS_MESH

View File

@@ -28,15 +28,15 @@
* Date: 2023/05/05
*/
class MeshViewerClass {
class MeshViewer {
public:
static float max, min;
static void DrawMeshGrid(const uint8_t csizex, const uint8_t csizey);
static void DrawMeshPoint(const uint8_t x, const uint8_t y, const float z);
static void Draw(const bool withsave=false, const bool redraw=true);
static void DrawMesh(const bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey);
static void drawMeshGrid(const uint8_t csizex, const uint8_t csizey);
static void drawMeshPoint(const uint8_t x, const uint8_t y, const float z);
static void draw(const bool withsave=false, const bool redraw=true);
static void drawMesh(const bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey);
};
extern MeshViewerClass MeshViewer;
extern MeshViewer meshViewer;
void Goto_MeshViewer(const bool redraw);
void gotoMeshViewer(const bool redraw);

View File

@@ -29,7 +29,7 @@
#include "../../../inc/MarlinConfig.h"
#if ALL(DWIN_LCD_PROUI, SHOW_TUNING_GRAPH)
#if ALL(DWIN_LCD_PROUI, PROUI_TUNING_GRAPH)
#include "dwin.h"
#include "../../../core/types.h"
@@ -44,32 +44,32 @@ uint16_t grphpoints, r, x2, y2 = 0;
frame_rect_t grphframe = {0};
float scale = 0;
void PlotClass::Draw(const frame_rect_t &frame, const_float_t max, const_float_t ref/*=0*/) {
void PlotClass::draw(const frame_rect_t &frame, const_float_t max, const_float_t ref/*=0*/) {
grphframe = frame;
grphpoints = 0;
scale = frame.h / max;
x2 = frame.x + frame.w - 1;
y2 = frame.y + frame.h - 1;
r = round((y2) - ref * scale);
DWINUI::Draw_Box(1, Plot_Bg_Color, frame);
for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) dwinDrawVLine(Line_Color, i * 50 + frame.x, frame.y, frame.h);
DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1));
dwinDrawHLine(Color_Red, frame.x, r, frame.w);
DWINUI::drawBox(1, Plot_Bg_Color, frame);
for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) dwinDrawVLine(COLOR_LINE, i * 50 + frame.x, frame.y, frame.h);
DWINUI::drawBox(0, COLOR_WHITE, DWINUI::extendFrame(frame, 1));
dwinDrawHLine(COLOR_RED, frame.x, r, frame.w);
}
void PlotClass::Update(const_float_t value) {
void PlotClass::update(const_float_t value) {
if (!scale) return;
const uint16_t y = round((y2) - value * scale);
if (grphpoints < grphframe.w) {
dwinDrawPoint(Color_Yellow, 1, 1, grphpoints + grphframe.x, y);
dwinDrawPoint(COLOR_YELLOW, 1, 1, grphpoints + grphframe.x, y);
}
else {
dwinFrameAreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2);
if ((grphpoints % 50) == 0) dwinDrawVLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2);
dwinDrawPoint(Color_Red, 1, 1, x2 - 1, r);
dwinDrawPoint(Color_Yellow, 1, 1, x2 - 1, y);
if ((grphpoints % 50) == 0) dwinDrawVLine(COLOR_LINE, x2 - 1, grphframe.y + 1, grphframe.h - 2);
dwinDrawPoint(COLOR_RED, 1, 1, x2 - 1, r);
dwinDrawPoint(COLOR_YELLOW, 1, 1, x2 - 1, y);
}
grphpoints++;
}
#endif // DWIN_LCD_PROUI && SHOW_TUNING_GRAPH
#endif // DWIN_LCD_PROUI && PROUI_TUNING_GRAPH

View File

@@ -32,8 +32,8 @@
class PlotClass {
public:
static void Draw(const frame_rect_t &frame, const_float_t max, const_float_t ref=0);
static void Update(const_float_t value);
static void draw(const frame_rect_t &frame, const_float_t max, const_float_t ref=0);
static void update(const_float_t value);
};
extern PlotClass plot;

View File

@@ -40,43 +40,43 @@
#include "dwin.h"
#include "dwin_popup.h"
PrintStatsClass PrintStats;
PrintStats printStats;
void PrintStatsClass::Draw() {
void PrintStats::draw() {
char str[30] = "";
constexpr int8_t MRG = 30;
Title.ShowCaption(GET_TEXT_F(MSG_INFO_STATS_MENU));
DWINUI::ClearMainArea();
Draw_Popup_Bkgd();
DWINUI::Draw_Button(BTN_Continue, 86, 250);
title.showCaption(GET_TEXT_F(MSG_INFO_STATS_MENU));
DWINUI::clearMainArea();
drawPopupBkgd();
DWINUI::drawButton(BTN_Continue, 86, 250);
printStatistics ps = print_job_timer.getStats();
DWINUI::Draw_String(MRG, 80, TS(GET_TEXT_F(MSG_INFO_PRINT_COUNT), F(": "), ps.totalPrints));
DWINUI::Draw_String(MRG, 100, TS(GET_TEXT_F(MSG_INFO_COMPLETED_PRINTS), F(": "), ps.finishedPrints));
DWINUI::drawString(MRG, 80, TS(GET_TEXT_F(MSG_INFO_PRINT_COUNT), F(": "), ps.totalPrints));
DWINUI::drawString(MRG, 100, TS(GET_TEXT_F(MSG_INFO_COMPLETED_PRINTS), F(": "), ps.finishedPrints));
duration_t(print_job_timer.getStats().printTime).toDigital(str, true);
DWINUI::Draw_String(MRG, 120, MString<50>(GET_TEXT_F(MSG_INFO_PRINT_TIME), F(": "), str));
DWINUI::drawString(MRG, 120, MString<50>(GET_TEXT_F(MSG_INFO_PRINT_TIME), F(": "), str));
duration_t(print_job_timer.getStats().longestPrint).toDigital(str, true);
DWINUI::Draw_String(MRG, 140, MString<50>(GET_TEXT(MSG_INFO_PRINT_LONGEST), F(": "), str));
DWINUI::Draw_String(MRG, 160, TS(GET_TEXT_F(MSG_INFO_PRINT_FILAMENT), F(": "), p_float_t(ps.filamentUsed / 1000, 2), F(" m")));
DWINUI::drawString(MRG, 140, MString<50>(GET_TEXT(MSG_INFO_PRINT_LONGEST), F(": "), str));
DWINUI::drawString(MRG, 160, TS(GET_TEXT_F(MSG_INFO_PRINT_FILAMENT), F(": "), p_float_t(ps.filamentUsed / 1000, 2), F(" m")));
}
void PrintStatsClass::Reset() {
void PrintStats::reset() {
print_job_timer.initStats();
DONE_BUZZ(true);
}
void Goto_PrintStats() {
PrintStats.Draw();
HMI_SaveProcessID(WaitResponse);
void gotoPrintStats() {
printStats.draw();
hmiSaveProcessID(ID_WaitResponse);
}
// Print Stats Reset popup
void Popup_ResetStats() { DWIN_Popup_ConfirmCancel(ICON_Info_0, GET_TEXT_F(MSG_RESET_STATS)); }
void OnClick_ResetStats() {
if (hmiFlag.select_flag) PrintStatsClass::Reset();
HMI_ReturnScreen();
void popupResetStats() { dwinPopupConfirmCancel(ICON_Info_0, GET_TEXT_F(MSG_RESET_STATS)); }
void onClickResetStats() {
if (hmiFlag.select_flag) printStats.reset();
hmiReturnScreen();
}
void PrintStatsReset() { Goto_Popup(Popup_ResetStats, OnClick_ResetStats); }
void printStatsReset() { gotoPopup(popupResetStats, onClickResetStats); }
#endif // DWIN_LCD_PROUI && PRINTCOUNTER

View File

@@ -28,13 +28,13 @@
* Date: 2022/12/03
*/
class PrintStatsClass {
class PrintStats {
public:
static void Draw();
static void Reset();
static void draw();
static void reset();
};
extern PrintStatsClass PrintStats;
extern PrintStats printStats;
void Goto_PrintStats();
void PrintStatsReset();
void gotoPrintStats();
void printStatsReset();

View File

@@ -1600,7 +1600,7 @@ void MarlinUI::host_status() {
TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message));
TERN_(DWIN_CREALITY_LCD, dwinStatusChanged(status_message));
TERN_(DWIN_LCD_PROUI, DWIN_CheckStatusMessage());
TERN_(DWIN_LCD_PROUI, dwinCheckStatusMessage());
TERN_(DWIN_CREALITY_LCD_JYERSUI, jyersDWIN.updateStatus(status_message));
}

View File

@@ -413,7 +413,7 @@ void restore_feedrate_and_scaling();
#if HAS_Z_AXIS
#if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING)
#define Z_POST_CLEARANCE HMI_data.z_after_homing
#define Z_POST_CLEARANCE hmiData.z_after_homing
#elif defined(Z_AFTER_HOMING)
#define Z_POST_CLEARANCE Z_AFTER_HOMING
#else

View File

@@ -377,7 +377,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(ds_str));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str));
TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
TERN_(DWIN_LCD_PROUI, dwinPopupConfirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
ui.reset_status();

View File

@@ -1610,7 +1610,7 @@ void MarlinSettings::postprocess() {
{
_FIELD_TEST(dwin_data);
char dwin_data[eeprom_data_size] = { 0 };
DWIN_CopySettingsTo(dwin_data);
dwinCopySettingsTo(dwin_data);
EEPROM_WRITE(dwin_data);
}
#endif
@@ -2675,7 +2675,7 @@ void MarlinSettings::postprocess() {
const char dwin_data[eeprom_data_size] = { 0 };
_FIELD_TEST(dwin_data);
EEPROM_READ(dwin_data);
if (!validating) DWIN_CopySettingsFrom(dwin_data);
if (!validating) dwinCopySettingsFrom(dwin_data);
}
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
{
@@ -3022,7 +3022,7 @@ void MarlinSettings::postprocess() {
#endif
#if ENABLED(DWIN_LCD_PROUI)
status = !bedLevelTools.meshvalidate();
status = !bedLevelTools.meshValidate();
if (status) {
bedlevel.invalidate();
LCD_MESSAGE(MSG_UBL_MESH_INVALID);
@@ -3559,7 +3559,7 @@ void MarlinSettings::reset() {
//
// Ender-3 V2 with ProUI
//
TERN_(DWIN_LCD_PROUI, DWIN_SetDataDefaults());
TERN_(DWIN_LCD_PROUI, dwinSetDataDefaults());
//
// Model predictive control

View File

@@ -2639,7 +2639,7 @@ hal_timer_t Stepper::block_phase_isr() {
oversampling_factor = 0; // Assume no axis smoothing (via oversampling)
// Decide if axis smoothing is possible
uint32_t max_rate = current_block->nominal_rate; // Get the step event rate
if (TERN1(DWIN_LCD_PROUI, HMI_data.AdaptiveStepSmoothing)) {
if (TERN1(DWIN_LCD_PROUI, hmiData.adaptiveStepSmoothing)) {
while (max_rate < MIN_STEP_ISR_FREQUENCY) { // As long as more ISRs are possible...
max_rate <<= 1; // Try to double the rate
if (max_rate < MIN_STEP_ISR_FREQUENCY) // Don't exceed the estimated ISR limit

View File

@@ -723,12 +723,12 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(HAS_FAN_LOGIC, fan_update_ms = next_temp_ms + fan_update_interval_ms);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED));
TERN_(DWIN_PID_TUNE, DWIN_PidTuning(isbed ? PIDTEMPBED_START : PIDTEMP_START));
TERN_(PROUI_PID_TUNE, dwinPidTuning(isbed ? PIDTEMPBED_START : PIDTEMP_START));
if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) {
SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
TERN_(DWIN_PID_TUNE, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
TERN_(PROUI_PID_TUNE, dwinPidTuning(PID_TEMP_TOO_HIGH));
TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH)));
return;
}
@@ -820,7 +820,7 @@ volatile bool Temperature::raw_temps_ready = false;
if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
TERN_(DWIN_PID_TUNE, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
TERN_(PROUI_PID_TUNE, dwinPidTuning(PID_TEMP_TOO_HIGH));
TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH)));
break;
}
@@ -857,7 +857,7 @@ volatile bool Temperature::raw_temps_ready = false;
#endif
if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) {
TERN_(DWIN_CREALITY_LCD, dwinPopupTemperature(0));
TERN_(DWIN_PID_TUNE, DWIN_PidTuning(PID_TUNING_TIMEOUT));
TERN_(PROUI_PID_TUNE, dwinPidTuning(PID_TUNING_TIMEOUT));
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT));
TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT)));
SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT);
@@ -910,7 +910,7 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color));
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
TERN_(DWIN_PID_TUNE, DWIN_PidTuning(AUTOTUNE_DONE));
TERN_(PROUI_PID_TUNE, dwinPidTuning(AUTOTUNE_DONE));
goto EXIT_M303;
}
@@ -928,7 +928,7 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color));
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
TERN_(DWIN_PID_TUNE, DWIN_PidTuning(AUTOTUNE_DONE));
TERN_(PROUI_PID_TUNE, dwinPidTuning(AUTOTUNE_DONE));
EXIT_M303:
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = true);
@@ -1147,7 +1147,7 @@ volatile bool Temperature::raw_temps_ready = false;
// Ensure we don't drift too far from the window between the last sampled temp and the target temperature
if (!WITHIN(current_temp, get_sample_3_temp() - 15.0f, hotend.target + 15.0f)) {
SERIAL_ECHOLNPGM(STR_MPC_TEMPERATURE_ERROR);
TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_TEMP_ERROR));
TERN_(DWIN_LCD_PROUI, dwinMPCTuning(MPC_TEMP_ERROR));
wait_for_heatup = false;
return FAILED;
}
@@ -1187,7 +1187,7 @@ volatile bool Temperature::raw_temps_ready = false;
if (!wait_for_heatup) {
SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_INTERRUPTED);
TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_INTERRUPTED));
TERN_(DWIN_LCD_PROUI, dwinMPCTuning(MPC_INTERRUPTED));
return MeasurementState::CANCELLED;
}
@@ -1215,7 +1215,7 @@ volatile bool Temperature::raw_temps_ready = false;
// Determine ambient temperature.
SERIAL_ECHOLNPGM(STR_MPC_COOLING_TO_AMBIENT);
#if ENABLED(DWIN_LCD_PROUI)
DWIN_MPCTuning(MPCTEMP_START);
dwinMPCTuning(MPCTEMP_START);
LCD_ALERTMESSAGE(MSG_MPC_COOLING_TO_AMBIENT);
#else
LCD_MESSAGE(MSG_COOLING);
@@ -1305,7 +1305,7 @@ volatile bool Temperature::raw_temps_ready = false;
}
SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_FINISHED);
TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(AUTOTUNE_DONE));
TERN_(DWIN_LCD_PROUI, dwinMPCTuning(AUTOTUNE_DONE));
SERIAL_ECHOLNPGM("MPC_BLOCK_HEAT_CAPACITY ", mpc.block_heat_capacity);
SERIAL_ECHOLNPGM("MPC_SENSOR_RESPONSIVENESS ", p_float_t(mpc.sensor_responsiveness, 4));