🚸 Enhanced UI => Professional UI - with updates (#23624)
This commit is contained in:
committed by
Scott Lahteine
parent
ac76ed7ece
commit
1b2715ccf2
3975
Marlin/src/lcd/e3v2/proui/dwin.cpp
Normal file
3975
Marlin/src/lcd/e3v2/proui/dwin.cpp
Normal file
File diff suppressed because it is too large
Load Diff
274
Marlin/src/lcd/e3v2/proui/dwin.h
Normal file
274
Marlin/src/lcd/e3v2/proui/dwin.h
Normal file
@@ -0,0 +1,274 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Enhanced DWIN implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.9.2
|
||||
* date: 2021/11/21
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
#include "dwinui.h"
|
||||
#include "../common/encoder.h"
|
||||
#include "../../../libs/BL24CXX.h"
|
||||
|
||||
#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY)
|
||||
#define HAS_ONESTEP_LEVELING 1
|
||||
#endif
|
||||
|
||||
#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING)
|
||||
#define JUST_BABYSTEP 1
|
||||
#endif
|
||||
|
||||
#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET)
|
||||
#define HAS_ZOFFSET_ITEM 1
|
||||
#endif
|
||||
|
||||
#include "dwin_defines.h"
|
||||
|
||||
enum processID : uint8_t {
|
||||
// Process ID
|
||||
MainMenu,
|
||||
Menu,
|
||||
SetInt,
|
||||
SetPInt,
|
||||
SetIntNoDraw,
|
||||
SetFloat,
|
||||
SetPFloat,
|
||||
SelectFile,
|
||||
PrintProcess,
|
||||
PrintDone,
|
||||
PwrlossRec,
|
||||
Reboot,
|
||||
Info,
|
||||
ConfirmToPrint,
|
||||
|
||||
// Popup Windows
|
||||
Homing,
|
||||
Leveling,
|
||||
PidProcess,
|
||||
ESDiagProcess,
|
||||
PrintStatsProcess,
|
||||
PauseOrStop,
|
||||
FilamentPurge,
|
||||
WaitResponse,
|
||||
Locked,
|
||||
NothingToDo,
|
||||
};
|
||||
|
||||
enum pidresult_t : uint8_t {
|
||||
PID_BAD_EXTRUDER_NUM,
|
||||
PID_TEMP_TOO_HIGH,
|
||||
PID_TUNING_TIMEOUT,
|
||||
PID_EXTR_START,
|
||||
PID_BED_START,
|
||||
PID_DONE
|
||||
};
|
||||
|
||||
#define DWIN_CHINESE 123
|
||||
#define DWIN_ENGLISH 0
|
||||
|
||||
typedef struct {
|
||||
int8_t Color[3]; // Color components
|
||||
uint16_t pidgrphpoints = 0;
|
||||
pidresult_t pidresult = PID_DONE;
|
||||
int8_t Preheat = 0; // Material Select 0: PLA, 1: ABS, 2: Custom
|
||||
AxisEnum axis = X_AXIS; // Axis Select
|
||||
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
|
||||
} HMI_value_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t language;
|
||||
bool pause_flag:1; // printing is paused
|
||||
bool pause_action:1; // flag a pause action
|
||||
bool print_finish:1; // print was finished
|
||||
bool select_flag:1; // Popup button selected
|
||||
bool home_flag:1; // homing in course
|
||||
bool heat_flag:1; // 0: heating done 1: during heating
|
||||
} HMI_flag_t;
|
||||
|
||||
extern HMI_value_t HMI_value;
|
||||
extern HMI_flag_t HMI_flag;
|
||||
extern uint8_t checkkey;
|
||||
extern millis_t dwin_heat_time;
|
||||
|
||||
// Popups
|
||||
#if HAS_HOTEND || HAS_HEATED_BED
|
||||
void DWIN_Popup_Temperature(const bool toohigh);
|
||||
#endif
|
||||
#if HAS_HOTEND
|
||||
void Popup_Window_ETempTooLow();
|
||||
#endif
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
void Popup_PowerLossRecovery();
|
||||
#endif
|
||||
|
||||
// SD Card
|
||||
void HMI_SDCardInit();
|
||||
void HMI_SDCardUpdate();
|
||||
|
||||
// Other
|
||||
void Goto_PrintProcess();
|
||||
void Goto_Main_Menu();
|
||||
void Goto_Info_Menu();
|
||||
void Goto_PowerLossRecovery();
|
||||
void Goto_ConfirmToPrint();
|
||||
void Draw_Status_Area(const bool with_update); // Status Area
|
||||
void Draw_Main_Area(); // Redraw main area;
|
||||
void DWIN_Redraw_screen(); // Redraw all screen elements
|
||||
void HMI_StartFrame(const bool with_update); // Prepare the menu view
|
||||
void HMI_MainMenu(); // Main process screen
|
||||
void HMI_SelectFile(); // File page
|
||||
void HMI_Printing(); // Print page
|
||||
void HMI_ReturnScreen(); // Return to previous screen before popups
|
||||
void ApplyExtMinT();
|
||||
void HMI_SetLanguageCache(); // Set the languaje image cache
|
||||
|
||||
void HMI_Init();
|
||||
void HMI_Popup();
|
||||
void HMI_SaveProcessID(const uint8_t id);
|
||||
void HMI_AudioFeedback(const bool success=true);
|
||||
void EachMomentUpdate();
|
||||
void update_variable();
|
||||
void DWIN_HandleScreen();
|
||||
void DWIN_Update();
|
||||
void DWIN_CheckStatusMessage();
|
||||
void DWIN_StartHoming();
|
||||
void DWIN_CompletedHoming();
|
||||
#if HAS_MESH
|
||||
void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval);
|
||||
#endif
|
||||
void DWIN_MeshLevelingStart();
|
||||
void DWIN_CompletedLeveling();
|
||||
void DWIN_PidTuning(pidresult_t result);
|
||||
void DWIN_Print_Started(const bool sd = false);
|
||||
void DWIN_Print_Finished();
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
void DWIN_FilamentRunout(const uint8_t extruder);
|
||||
#endif
|
||||
void DWIN_Progress_Update();
|
||||
void DWIN_Print_Header(const char *text);
|
||||
void DWIN_SetColorDefaults();
|
||||
void DWIN_StoreSettings(char *buff);
|
||||
void DWIN_LoadSettings(const char *buff);
|
||||
void DWIN_SetDataDefaults();
|
||||
void DWIN_RebootScreen();
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
void Draw_Popup_FilamentPurge();
|
||||
void DWIN_Popup_FilamentPurge();
|
||||
void HMI_FilamentPurge();
|
||||
#endif
|
||||
|
||||
// Utility and extensions
|
||||
void DWIN_LockScreen();
|
||||
void DWIN_UnLockScreen();
|
||||
void HMI_LockScreen();
|
||||
#if HAS_MESH
|
||||
void DWIN_MeshViewer();
|
||||
#endif
|
||||
#if HAS_GCODE_PREVIEW
|
||||
void HMI_ConfirmToPrint();
|
||||
#endif
|
||||
#if HAS_ESDIAG
|
||||
void Draw_EndStopDiag();
|
||||
#endif
|
||||
#if ENABLED(PRINTCOUNTER)
|
||||
void Draw_PrintStats();
|
||||
#endif
|
||||
|
||||
// HMI user control functions
|
||||
void HMI_Menu();
|
||||
void HMI_SetInt();
|
||||
void HMI_SetPInt();
|
||||
void HMI_SetIntNoDraw();
|
||||
void HMI_SetFloat();
|
||||
void HMI_SetPFloat();
|
||||
|
||||
// Menu drawing functions
|
||||
void Draw_Control_Menu();
|
||||
void Draw_AdvancedSettings_Menu();
|
||||
void Draw_Prepare_Menu();
|
||||
void Draw_Move_Menu();
|
||||
void Draw_Tramming_Menu();
|
||||
#if HAS_HOME_OFFSET
|
||||
void Draw_HomeOffset_Menu();
|
||||
#endif
|
||||
#if HAS_BED_PROBE
|
||||
void Draw_ProbeSet_Menu();
|
||||
#endif
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
void Draw_FilSet_Menu();
|
||||
#endif
|
||||
#if ENABLED(NOZZLE_PARK_FEATURE)
|
||||
void Draw_ParkPos_Menu();
|
||||
#endif
|
||||
void Draw_PhySet_Menu();
|
||||
void Draw_SelectColors_Menu();
|
||||
void Draw_GetColor_Menu();
|
||||
#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
|
||||
void Draw_CaseLight_Menu();
|
||||
#endif
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
void Draw_LedControl_Menu();
|
||||
#endif
|
||||
void Draw_Tune_Menu();
|
||||
void Draw_Motion_Menu();
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
void Draw_FilamentMan_Menu();
|
||||
#endif
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
void Draw_ManualMesh_Menu();
|
||||
#endif
|
||||
#if HAS_HOTEND
|
||||
void Draw_Preheat1_Menu();
|
||||
void Draw_Preheat2_Menu();
|
||||
void Draw_Preheat3_Menu();
|
||||
void Draw_HotendPID_Menu();
|
||||
#endif
|
||||
void Draw_Temperature_Menu();
|
||||
void Draw_MaxSpeed_Menu();
|
||||
void Draw_MaxAccel_Menu();
|
||||
#if HAS_CLASSIC_JERK
|
||||
void Draw_MaxJerk_Menu();
|
||||
#endif
|
||||
void Draw_Steps_Menu();
|
||||
#if HAS_HEATED_BED
|
||||
void Draw_BedPID_Menu();
|
||||
#endif
|
||||
#if EITHER(HAS_BED_PROBE, BABYSTEPPING)
|
||||
void Draw_ZOffsetWiz_Menu();
|
||||
#endif
|
||||
#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU)
|
||||
void Draw_Homing_Menu();
|
||||
#endif
|
115
Marlin/src/lcd/e3v2/proui/dwin_defines.h
Normal file
115
Marlin/src/lcd/e3v2/proui/dwin_defines.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN general defines and data structs
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.9.2
|
||||
* Date: 2021/11/21
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
//#define NEED_HEX_PRINT 1
|
||||
//#define DEBUG_DWIN 1
|
||||
|
||||
#include "../../../core/types.h"
|
||||
#include "../common/dwin_color.h"
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
#include "../../../feature/leds/leds.h"
|
||||
#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 HAS_GCODE_PREVIEW 1
|
||||
#define HAS_ESDIAG 1
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS)
|
||||
#define Def_Leds_Color LEDColorWhite()
|
||||
#endif
|
||||
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
|
||||
#define Def_CaseLight_Brightness 255
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
// Color settings
|
||||
uint16_t Background_Color = Def_Background_Color;
|
||||
uint16_t Cursor_color = Def_Cursor_color;
|
||||
uint16_t TitleBg_color = Def_TitleBg_color;
|
||||
uint16_t TitleTxt_color = Def_TitleTxt_color;
|
||||
uint16_t Text_Color = Def_Text_Color;
|
||||
uint16_t Selected_Color = Def_Selected_Color;
|
||||
uint16_t SplitLine_Color = Def_SplitLine_Color;
|
||||
uint16_t Highlight_Color = Def_Highlight_Color;
|
||||
uint16_t StatusBg_Color = Def_StatusBg_Color;
|
||||
uint16_t StatusTxt_Color = Def_StatusTxt_Color;
|
||||
uint16_t PopupBg_color = Def_PopupBg_color;
|
||||
uint16_t PopupTxt_Color = Def_PopupTxt_Color;
|
||||
uint16_t AlertBg_Color = Def_AlertBg_Color;
|
||||
uint16_t AlertTxt_Color = Def_AlertTxt_Color;
|
||||
uint16_t PercentTxt_Color = Def_PercentTxt_Color;
|
||||
uint16_t Barfill_Color = Def_Barfill_Color;
|
||||
uint16_t Indicator_Color = Def_Indicator_Color;
|
||||
uint16_t Coordinate_Color = Def_Coordinate_Color;
|
||||
// Temperatures
|
||||
#if HAS_HOTEND && defined(PREHEAT_1_TEMP_HOTEND)
|
||||
int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND;
|
||||
#endif
|
||||
#if HAS_HEATED_BED && defined(PREHEAT_1_TEMP_BED)
|
||||
int16_t BedPidT = PREHEAT_1_TEMP_BED;
|
||||
#endif
|
||||
#if HAS_HOTEND || HAS_HEATED_BED
|
||||
int16_t PidCycles = 10;
|
||||
#endif
|
||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||
int16_t ExtMinT = EXTRUDE_MINTEMP;
|
||||
#endif
|
||||
// Led
|
||||
#if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
|
||||
LEDColor Led_Color = Def_Leds_Color;
|
||||
#endif
|
||||
// Case Light
|
||||
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
|
||||
uint8_t CaseLight_Brightness = Def_CaseLight_Brightness;
|
||||
#endif
|
||||
} HMI_data_t;
|
||||
|
||||
static constexpr size_t eeprom_data_size = 64;
|
||||
extern HMI_data_t HMI_data;
|
162
Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp
Normal file
162
Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.8.1
|
||||
* Date: 2021/11/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#include "dwin_lcd.h"
|
||||
|
||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
||||
|
||||
// Display QR code
|
||||
// The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
|
||||
// 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) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x21);
|
||||
DWIN_Word(i, x);
|
||||
DWIN_Word(i, y);
|
||||
DWIN_Byte(i, QR_Pixel);
|
||||
DWIN_Text(i, string);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
// Draw an Icon with transparent background
|
||||
// libID: Icon library ID
|
||||
// picID: Icon ID
|
||||
// x/y: Upper-left point
|
||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
||||
DWIN_ICON_Show(false, false, true, libID, picID, x, 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) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x26);
|
||||
DWIN_Word(i, xStart);
|
||||
DWIN_Word(i, yStart);
|
||||
DWIN_Word(i, xEnd);
|
||||
DWIN_Word(i, yEnd);
|
||||
DWIN_Word(i, x);
|
||||
DWIN_Word(i, y);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
// 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
|
||||
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
||||
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
||||
// cacheID: virtual area number
|
||||
// xStart/yStart: Upper-left of virtual area
|
||||
// xEnd/yEnd: Lower-right of virtual area
|
||||
// x/y: Screen paste point
|
||||
void DWIN_Frame_AreaCopy(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;
|
||||
DWIN_Byte(i, 0x27);
|
||||
DWIN_Byte(i, (IBD & 1) << 7 | (BIR & 1) << 6 | (BFI & 1) << 5 | cacheID);
|
||||
DWIN_Word(i, xStart);
|
||||
DWIN_Word(i, yStart);
|
||||
DWIN_Word(i, xEnd);
|
||||
DWIN_Word(i, yEnd);
|
||||
DWIN_Word(i, x);
|
||||
DWIN_Word(i, y);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
// Copy area from virtual display area to current screen with transparent background
|
||||
// cacheID: virtual area number
|
||||
// xStart/yStart: Upper-left of virtual area
|
||||
// xEnd/yEnd: Lower-right of virtual area
|
||||
// x/y: Screen paste point
|
||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
||||
DWIN_Frame_AreaCopy(false, false, true, cacheID, xStart, yStart, xEnd, yEnd, x, 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) {
|
||||
const uint8_t max_size = 128;
|
||||
uint16_t pending = length;
|
||||
uint16_t to_send;
|
||||
uint16_t indx;
|
||||
uint8_t block = 0;
|
||||
|
||||
while (pending > 0) {
|
||||
indx = block * max_size;
|
||||
to_send = _MIN(pending, max_size);
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x31);
|
||||
DWIN_Byte(i, mem);
|
||||
DWIN_Word(i, addr + indx); // start address of the data block
|
||||
++i;
|
||||
LOOP_L_N(j, i) { LCD_SERIAL.write(DWIN_SendBuf[j]); delayMicroseconds(1); } // Buf header
|
||||
for (uint16_t j = indx; j <= indx + to_send - 1; j++) LCD_SERIAL.write(*(data + j)); delayMicroseconds(1); // write block of data
|
||||
LOOP_L_N(j, 4) { LCD_SERIAL.write(DWIN_BufTail[j]); delayMicroseconds(1); }
|
||||
block++;
|
||||
pending -= to_send;
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x33);
|
||||
DWIN_Byte(i, 0x5A);
|
||||
DWIN_Byte(i, 0xA5);
|
||||
DWIN_Byte(i, picID);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
//--------------------------Test area -------------------------
|
||||
|
||||
//void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
|
||||
// size_t i = 0;
|
||||
// DWIN_Byte(i, 0x32);
|
||||
// DWIN_Byte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash
|
||||
// DWIN_Word(i, addr); // 0x0000 to 0x7FFF
|
||||
// const size_t len = _MIN(0xF0, length);
|
||||
// DWIN_Byte(i, len);
|
||||
// DWIN_Send(i);
|
||||
//}
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
78
Marlin/src/lcd/e3v2/proui/dwin_lcd.h
Normal file
78
Marlin/src/lcd/e3v2/proui/dwin_lcd.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.8.1
|
||||
* Date: 2021/11/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../common/dwin_api.h"
|
||||
|
||||
// Display QR code
|
||||
// The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
|
||||
// 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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Copy area from virtual display area to current screen
|
||||
// cacheID: virtual area number
|
||||
// xStart/yStart: Upper-left of virtual area
|
||||
// xEnd/yEnd: Lower-right of virtual area
|
||||
// x/y: Screen paste point
|
||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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
|
||||
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
||||
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
||||
// cacheID: virtual area number
|
||||
// xStart/yStart: Upper-left of virtual area
|
||||
// xEnd/yEnd: Lower-right of virtual area
|
||||
// x/y: Screen paste point
|
||||
void DWIN_Frame_AreaCopy(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);
|
||||
|
||||
// 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);
|
63
Marlin/src/lcd/e3v2/proui/dwin_popup.cpp
Normal file
63
Marlin/src/lcd/e3v2/proui/dwin_popup.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.10.1
|
||||
* Date: 2022/01/21
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||
|
||||
#include "dwin.h"
|
||||
#include "dwin_popup.h"
|
||||
|
||||
void Draw_Select_Highlight(const bool sel) {
|
||||
HMI_flag.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;
|
||||
DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318);
|
||||
DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319);
|
||||
DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318);
|
||||
DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319);
|
||||
}
|
||||
|
||||
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, ICON_Continue_E); // Button Continue
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) {
|
||||
DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), fmsg2);
|
||||
DWINUI::Draw_IconWB(ICON_Confirm_E, 26, 280);
|
||||
DWINUI::Draw_IconWB(ICON_Cancel_E, 146, 280);
|
||||
Draw_Select_Highlight(true);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
70
Marlin/src/lcd/e3v2/proui/dwin_popup.h
Normal file
70
Marlin/src/lcd/e3v2/proui/dwin_popup.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.10.1
|
||||
* Date: 2022/01/21
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "dwinui.h"
|
||||
#include "dwin.h"
|
||||
|
||||
// Popup windows
|
||||
|
||||
void Draw_Select_Highlight(const bool sel);
|
||||
|
||||
inline void Draw_Popup_Bkgd() {
|
||||
DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330);
|
||||
DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 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::ClearMenuArea();
|
||||
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_IconWB(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);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
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, ICON_Confirm_E); // Button Confirm
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
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);
|
456
Marlin/src/lcd/e3v2/proui/dwinui.cpp
Normal file
456
Marlin/src/lcd/e3v2/proui/dwinui.cpp
Normal file
@@ -0,0 +1,456 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.8.2
|
||||
* Date: 2021/11/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "dwin_lcd.h"
|
||||
#include "dwinui.h"
|
||||
#include "dwin_defines.h"
|
||||
|
||||
//#define DEBUG_OUT 1
|
||||
#include "../../../core/debug_out.h"
|
||||
|
||||
int8_t MenuItemTotal = 0;
|
||||
int8_t MenuItemCount = 0;
|
||||
MenuItemClass** MenuItems = nullptr;
|
||||
MenuClass *CurrentMenu = nullptr;
|
||||
MenuClass *PreviousMenu = nullptr;
|
||||
|
||||
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;
|
||||
uint8_t DWINUI::font = font8x16;
|
||||
|
||||
void (*DWINUI::onCursorErase)(const int8_t line)=nullptr;
|
||||
void (*DWINUI::onCursorDraw)(const int8_t line)=nullptr;
|
||||
void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr;
|
||||
void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr;
|
||||
|
||||
void DWINUI::init() {
|
||||
DEBUG_ECHOPGM("\r\nDWIN handshake ");
|
||||
delay(750); // Delay here or init later in the boot process
|
||||
const bool success = DWIN_Handshake();
|
||||
if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
|
||||
DWIN_Frame_SetDir(1);
|
||||
TERN(SHOW_BOOTSCREEN,,DWIN_Frame_Clear(Color_Bg_Black));
|
||||
DWIN_UpdateLCD();
|
||||
cursor.x = 0;
|
||||
cursor.y = 0;
|
||||
pencolor = Color_White;
|
||||
textcolor = Def_Text_Color;
|
||||
backcolor = Def_Background_Color;
|
||||
font = font8x16;
|
||||
}
|
||||
|
||||
// Set text/number font
|
||||
void DWINUI::setFont(uint8_t cfont) {
|
||||
font = cfont;
|
||||
}
|
||||
|
||||
// Get font character width
|
||||
uint8_t DWINUI::fontWidth(uint8_t cfont) {
|
||||
switch (cfont) {
|
||||
case font6x12 : return 6;
|
||||
case font8x16 : return 8;
|
||||
case font10x20: return 10;
|
||||
case font12x24: return 12;
|
||||
case font14x28: return 14;
|
||||
case font16x32: return 16;
|
||||
case font20x40: return 20;
|
||||
case font24x48: return 24;
|
||||
case font28x56: return 28;
|
||||
case font32x64: return 32;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Get font character height
|
||||
uint8_t DWINUI::fontHeight(uint8_t cfont) {
|
||||
switch (cfont) {
|
||||
case font6x12 : return 12;
|
||||
case font8x16 : return 16;
|
||||
case font10x20: return 20;
|
||||
case font12x24: return 24;
|
||||
case font14x28: return 28;
|
||||
case font16x32: return 32;
|
||||
case font20x40: return 40;
|
||||
case font24x48: return 48;
|
||||
case font28x56: return 56;
|
||||
case font32x64: return 64;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Get screen x coordinates from text column
|
||||
uint16_t DWINUI::ColToX(uint8_t col) {
|
||||
return col * fontWidth(font);
|
||||
}
|
||||
|
||||
// Get screen y coordinates from text row
|
||||
uint16_t DWINUI::RowToY(uint8_t row) {
|
||||
return row * fontHeight(font);
|
||||
}
|
||||
|
||||
// Set text/number color
|
||||
void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor) {
|
||||
textcolor = fgcolor;
|
||||
backcolor = bgcolor;
|
||||
}
|
||||
void DWINUI::SetTextColor(uint16_t fgcolor) {
|
||||
textcolor = fgcolor;
|
||||
}
|
||||
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) {
|
||||
cursor.x = x;
|
||||
cursor.y = y;
|
||||
}
|
||||
void DWINUI::MoveTo(xy_int_t point) {
|
||||
cursor = point;
|
||||
}
|
||||
|
||||
// Moves cursor relative to the actual position
|
||||
// x: abscissa of the display
|
||||
// y: ordinate of the display
|
||||
// point: xy coordinate
|
||||
void DWINUI::MoveBy(int16_t x, int16_t y) {
|
||||
cursor.x += x;
|
||||
cursor.y += y;
|
||||
}
|
||||
void DWINUI::MoveBy(xy_int_t point) {
|
||||
cursor += point;
|
||||
}
|
||||
|
||||
// Draw a Centered string using DWIN_WIDTH
|
||||
void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
|
||||
const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * fontWidth(size)) / 2 - 1;
|
||||
DWIN_Draw_String(bShow, size, color, bColor, x, y, string);
|
||||
}
|
||||
|
||||
// Draw a char at cursor position
|
||||
void DWINUI::Draw_Char(const char c) {
|
||||
const char string[2] = { c, 0};
|
||||
DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, 1);
|
||||
MoveBy(fontWidth(font), 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) {
|
||||
DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
|
||||
MoveBy(strlen(string) * fontWidth(font), 0);
|
||||
}
|
||||
void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) {
|
||||
DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit);
|
||||
MoveBy(strlen(string) * fontWidth(font), 0);
|
||||
}
|
||||
|
||||
// Draw a signed floating point number
|
||||
// bShow: true=display background color; false=don't display background color
|
||||
// zeroFill: true=zero fill; false=no zero fill
|
||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
||||
// size: Font size
|
||||
// bColor: Background color
|
||||
// iNum: Number of whole digits
|
||||
// fNum: Number of decimal digits
|
||||
// x/y: Upper-left point
|
||||
// value: Float value
|
||||
void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value < 0 ? -value : value);
|
||||
DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, value < 0 ? F("-") : F(" "));
|
||||
}
|
||||
|
||||
// Draw a circle
|
||||
// color: circle color
|
||||
// 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) {
|
||||
int a = 0, b = 0;
|
||||
while (a <= b) {
|
||||
b = SQRT(sq(r) - sq(a));
|
||||
if (a == 0) b--;
|
||||
DWIN_Draw_Point(color, 1, 1, x + a, y + b); // Draw some sector 1
|
||||
DWIN_Draw_Point(color, 1, 1, x + b, y + a); // Draw some sector 2
|
||||
DWIN_Draw_Point(color, 1, 1, x + b, y - a); // Draw some sector 3
|
||||
DWIN_Draw_Point(color, 1, 1, x + a, y - b); // Draw some sector 4
|
||||
DWIN_Draw_Point(color, 1, 1, x - a, y - b); // Draw some sector 5
|
||||
DWIN_Draw_Point(color, 1, 1, x - b, y - a); // Draw some sector 6
|
||||
DWIN_Draw_Point(color, 1, 1, x - b, y + a); // Draw some sector 7
|
||||
DWIN_Draw_Point(color, 1, 1, x - a, y + b); // Draw some sector 8
|
||||
a++;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a circle filled with color
|
||||
// bcolor: fill color
|
||||
// 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) {
|
||||
int a = 0, b = 0;
|
||||
while (a <= b) {
|
||||
b = SQRT(sq(r) - sq(a)); // b=sqrt(r*r-a*a);
|
||||
if (a == 0) b--;
|
||||
DWIN_Draw_Line(bcolor, x-b,y-a,x+b,y-a);
|
||||
DWIN_Draw_Line(bcolor, x-a,y-b,x+a,y-b);
|
||||
DWIN_Draw_Line(bcolor, x-b,y+a,x+b,y+a);
|
||||
DWIN_Draw_Line(bcolor, x-a,y+b,x+a,y+b);
|
||||
a++;
|
||||
}
|
||||
}
|
||||
|
||||
// Color Interpolator
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximum value
|
||||
// color1 : Start color
|
||||
// color2 : End color
|
||||
uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) {
|
||||
uint8_t B,G,R;
|
||||
float n;
|
||||
n = (float)(val-minv)/(maxv-minv);
|
||||
R = (1-n)*GetRColor(color1) + n*GetRColor(color2);
|
||||
G = (1-n)*GetGColor(color1) + n*GetGColor(color2);
|
||||
B = (1-n)*GetBColor(color1) + n*GetBColor(color2);
|
||||
return RGB(R,G,B);
|
||||
}
|
||||
|
||||
// Color Interpolator through Red->Yellow->Green->Blue
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximum value
|
||||
uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
|
||||
uint8_t B,G,R;
|
||||
const uint8_t maxB = 28;
|
||||
const uint8_t maxR = 28;
|
||||
const uint8_t maxG = 38;
|
||||
const int16_t limv = _MAX(abs(minv), abs(maxv));
|
||||
float n;
|
||||
if (minv>=0) {
|
||||
n = (float)(val-minv)/(maxv-minv);
|
||||
} else {
|
||||
n = (float)val/limv;
|
||||
}
|
||||
n = _MIN(1, n);
|
||||
n = _MAX(-1, n);
|
||||
if (n < 0) {
|
||||
R = 0;
|
||||
G = (1+n)*maxG;
|
||||
B = (-n)*maxB;
|
||||
} else if (n < 0.5) {
|
||||
R = maxR*n*2;
|
||||
G = maxG;
|
||||
B = 0;
|
||||
} else {
|
||||
R = maxR;
|
||||
G = maxG*(1-n);
|
||||
B = 0;
|
||||
}
|
||||
return RGB(R,G,B);
|
||||
}
|
||||
|
||||
// Draw a checkbox
|
||||
// Color: frame color
|
||||
// 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) {
|
||||
DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" "));
|
||||
DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17);
|
||||
}
|
||||
|
||||
// Clear Menu by filling the menu area with background color
|
||||
void DWINUI::ClearMenuArea() {
|
||||
DWIN_Draw_Rectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
|
||||
}
|
||||
|
||||
void DWINUI::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 DWINUI::MenuItemsPrepare(int8_t totalitems) {
|
||||
MenuItemsClear();
|
||||
MenuItemTotal = totalitems;
|
||||
MenuItems = new MenuItemClass*[totalitems];
|
||||
}
|
||||
|
||||
MenuItemClass* DWINUI::MenuItemsAdd(MenuItemClass* menuitem) {
|
||||
if (MenuItemCount < MenuItemTotal) {
|
||||
MenuItems[MenuItemCount] = menuitem;
|
||||
menuitem->pos = MenuItemCount++;
|
||||
return menuitem;
|
||||
}
|
||||
else {
|
||||
delete menuitem;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* Title Class ==============================================================*/
|
||||
|
||||
TitleClass Title;
|
||||
|
||||
void TitleClass::draw() {
|
||||
if (DWINUI::onTitleDraw != nullptr) (*DWINUI::onTitleDraw)(this);
|
||||
}
|
||||
|
||||
void TitleClass::SetCaption(const char * const title) {
|
||||
frameid = 0;
|
||||
if ( caption == title ) return;
|
||||
const uint8_t len = _MIN(sizeof(caption) - 1, strlen(title));
|
||||
memcpy(&caption[0], title, len);
|
||||
caption[len] = '\0';
|
||||
}
|
||||
|
||||
void TitleClass::ShowCaption(const char * const title) {
|
||||
SetCaption(title);
|
||||
draw();
|
||||
}
|
||||
|
||||
void TitleClass::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 TitleClass::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);
|
||||
}
|
||||
|
||||
/* Menu Class ===============================================================*/
|
||||
|
||||
MenuClass::MenuClass() {
|
||||
selected = 0;
|
||||
topline = 0;
|
||||
}
|
||||
|
||||
void MenuClass::draw() {
|
||||
MenuTitle.draw();
|
||||
if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this);
|
||||
for (int8_t i = 0; i < MenuItemCount; i++)
|
||||
MenuItems[i]->draw(i - topline);
|
||||
if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
void MenuClass::onScroll(bool dir) {
|
||||
int8_t sel = selected;
|
||||
if (dir) sel++; else sel--;
|
||||
LIMIT(sel, 0, MenuItemCount - 1);
|
||||
if (sel != selected) {
|
||||
if (DWINUI::onCursorErase != nullptr) DWINUI::onCursorErase(line());
|
||||
if ((sel - topline) == TROWS) {
|
||||
DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
|
||||
topline++;
|
||||
MenuItems[sel]->draw(TROWS - 1);
|
||||
}
|
||||
if ((sel < topline)) {
|
||||
DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
|
||||
topline--;
|
||||
MenuItems[sel]->draw(0);
|
||||
}
|
||||
selected = sel;
|
||||
if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuClass::onClick() {
|
||||
if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)();
|
||||
}
|
||||
|
||||
MenuItemClass *MenuClass::SelectedItem() {
|
||||
return MenuItems[selected];
|
||||
}
|
||||
|
||||
/* MenuItem Class ===========================================================*/
|
||||
|
||||
MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) {
|
||||
icon = cicon;
|
||||
onClick = onclick;
|
||||
onDraw = ondraw;
|
||||
const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text));
|
||||
memcpy(&caption[0], text, len);
|
||||
caption[len] = '\0';
|
||||
}
|
||||
|
||||
MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) {
|
||||
icon = cicon;
|
||||
onClick = onclick;
|
||||
onDraw = ondraw;
|
||||
caption[0] = '\0';
|
||||
frameid = id;
|
||||
frame = { x1, y1, x2, y2 };
|
||||
}
|
||||
|
||||
void MenuItemClass::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 MenuItemClass::draw(int8_t line) {
|
||||
if (line < 0 || line >= TROWS) return;
|
||||
if (onDraw != nullptr) (*onDraw)(this, line);
|
||||
};
|
||||
|
||||
MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemClass(cicon, text, ondraw, onclick) {
|
||||
value = val;
|
||||
};
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
537
Marlin/src/lcd/e3v2/proui/dwinui.h
Normal file
537
Marlin/src/lcd/e3v2/proui/dwinui.h
Normal file
@@ -0,0 +1,537 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.11.1
|
||||
* Date: 2022/01/19
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "dwin_lcd.h"
|
||||
#include "../common/dwin_set.h"
|
||||
#include "../common/dwin_font.h"
|
||||
#include "../common/dwin_color.h"
|
||||
|
||||
// Extra Icons
|
||||
#define ICON_AdvSet ICON_Language
|
||||
#define ICON_BedSizeX ICON_PrintSize
|
||||
#define ICON_BedSizeY ICON_PrintSize
|
||||
#define ICON_Binary ICON_Contact
|
||||
#define ICON_Brightness ICON_Motion
|
||||
#define ICON_Cancel ICON_StockConfiguration
|
||||
#define ICON_CustomPreheat ICON_SetEndTemp
|
||||
#define ICON_Error ICON_TempTooHigh
|
||||
#define ICON_ESDiag ICON_Info
|
||||
#define ICON_ExtrudeMinT ICON_HotendTemp
|
||||
#define ICON_FilLoad ICON_WriteEEPROM
|
||||
#define ICON_FilMan ICON_ResumeEEPROM
|
||||
#define ICON_FilSet ICON_ResumeEEPROM
|
||||
#define ICON_FilUnload ICON_ReadEEPROM
|
||||
#define ICON_Flow ICON_StepE
|
||||
#define ICON_Folder ICON_More
|
||||
#define ICON_FWRetLength ICON_StepE
|
||||
#define ICON_FWRetSpeed ICON_Setspeed
|
||||
#define ICON_FWRetZRaise ICON_MoveZ
|
||||
#define ICON_FWRecSpeed ICON_Setspeed
|
||||
#define ICON_HomeX ICON_MoveX
|
||||
#define ICON_HomeY ICON_MoveY
|
||||
#define ICON_HomeZ ICON_MoveZ
|
||||
#define ICON_HomeOffset ICON_AdvSet
|
||||
#define ICON_HomeOffsetX ICON_StepX
|
||||
#define ICON_HomeOffsetY ICON_StepY
|
||||
#define ICON_HomeOffsetZ ICON_StepZ
|
||||
#define ICON_HSMode ICON_StockConfiguration
|
||||
#define ICON_InvertE0 ICON_StepE
|
||||
#define ICON_Tram ICON_SetEndTemp
|
||||
#define ICON_Level ICON_HotendTemp
|
||||
#define ICON_Lock ICON_Cool
|
||||
#define ICON_ManualMesh ICON_HotendTemp
|
||||
#define ICON_MaxPosX ICON_MoveX
|
||||
#define ICON_MaxPosY ICON_MoveY
|
||||
#define ICON_MaxPosZ ICON_MoveZ
|
||||
#define ICON_MeshNext ICON_Axis
|
||||
#define ICON_MeshPoints ICON_SetEndTemp
|
||||
#define ICON_MeshSave ICON_WriteEEPROM
|
||||
#define ICON_MeshViewer ICON_HotendTemp
|
||||
#define ICON_MoveZ0 ICON_HotendTemp
|
||||
#define ICON_Park ICON_Motion
|
||||
#define ICON_ParkPos ICON_AdvSet
|
||||
#define ICON_ParkPosX ICON_StepX
|
||||
#define ICON_ParkPosY ICON_StepY
|
||||
#define ICON_ParkPosZ ICON_StepZ
|
||||
#define ICON_PhySet ICON_PrintSize
|
||||
#define ICON_PIDbed ICON_SetBedTemp
|
||||
#define ICON_PIDcycles ICON_ResumeEEPROM
|
||||
#define ICON_PIDValue ICON_Contact
|
||||
#define ICON_PrintStats ICON_PrintTime
|
||||
#define ICON_PrintStatsReset ICON_RemainTime
|
||||
#define ICON_ProbeDeploy ICON_SetEndTemp
|
||||
#define ICON_ProbeMargin ICON_PrintSize
|
||||
#define ICON_ProbeOffsetX ICON_StepX
|
||||
#define ICON_ProbeOffsetY ICON_StepY
|
||||
#define ICON_ProbeOffsetZ ICON_StepZ
|
||||
#define ICON_ProbeSet ICON_SetEndTemp
|
||||
#define ICON_ProbeStow ICON_SetEndTemp
|
||||
#define ICON_ProbeTest ICON_SetEndTemp
|
||||
#define ICON_ProbeZSpeed ICON_MaxSpeedZ
|
||||
#define ICON_Pwrlossr ICON_Motion
|
||||
#define ICON_Reboot ICON_ResumeEEPROM
|
||||
#define ICON_Runout ICON_MaxAccE
|
||||
#define ICON_Scolor ICON_MaxSpeed
|
||||
#define ICON_SetBaudRate ICON_Setspeed
|
||||
#define ICON_SetCustomPreheat ICON_SetEndTemp
|
||||
#define ICON_Sound ICON_Cool
|
||||
#define ICON_CaseLight ICON_Motion
|
||||
#define ICON_LedControl ICON_Motion
|
||||
|
||||
// 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)
|
||||
|
||||
// UI element defines and constants
|
||||
#define DWIN_FONT_MENU font8x16
|
||||
#define DWIN_FONT_STAT font10x20
|
||||
#define DWIN_FONT_HEAD font10x20
|
||||
#define DWIN_FONT_ALERT font10x20
|
||||
#define STATUS_Y 354
|
||||
#define LCD_WIDTH (DWIN_WIDTH / 8)
|
||||
|
||||
constexpr uint16_t TITLE_HEIGHT = 30, // Title bar height
|
||||
MLINE = 53, // Menu line height
|
||||
TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows
|
||||
MROWS = TROWS - 1, // Other-than-Back
|
||||
ICOX = 26, // Menu item icon X position
|
||||
LBLX = 60, // Menu item label X position
|
||||
VALX = 210, // Menu item value X position
|
||||
MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16
|
||||
STAT_CHR_W = 10;
|
||||
|
||||
// Menuitem Y position
|
||||
#define MYPOS(L) (TITLE_HEIGHT + MLINE * (L))
|
||||
|
||||
// Menuitem caption Offset
|
||||
#define CAPOFF ((MLINE - MENU_CHR_H) / 2)
|
||||
|
||||
// Menuitem caption Y position
|
||||
#define MBASE(L) (MYPOS(L) + CAPOFF)
|
||||
|
||||
// Create and add a MenuItem object to the menu array
|
||||
#define MENU_ITEM(V...) DWINUI::MenuItemsAdd(new MenuItemClass(V))
|
||||
#define EDIT_ITEM(V...) DWINUI::MenuItemsAdd(new MenuItemPtrClass(V))
|
||||
|
||||
typedef struct { uint16_t left, top, right, bottom; } rect_t;
|
||||
typedef struct { uint16_t x, y, w, h; } frame_rect_t;
|
||||
|
||||
class TitleClass {
|
||||
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);
|
||||
};
|
||||
extern TitleClass Title;
|
||||
|
||||
class MenuItemClass {
|
||||
protected:
|
||||
public:
|
||||
int8_t pos = 0;
|
||||
uint8_t icon = 0;
|
||||
char caption[32] = "";
|
||||
uint8_t frameid = 0;
|
||||
rect_t frame = {0};
|
||||
void (*onDraw)(MenuItemClass* menuitem, int8_t line) = nullptr;
|
||||
void (*onClick)() = nullptr;
|
||||
MenuItemClass() {};
|
||||
MenuItemClass(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
|
||||
MenuItemClass(uint8_t cicon, FSTR_P text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) : MenuItemClass(cicon, FTOP(text), ondraw, onclick){}
|
||||
MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
|
||||
void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||
virtual ~MenuItemClass(){};
|
||||
virtual void draw(int8_t line);
|
||||
};
|
||||
|
||||
class MenuItemPtrClass: public MenuItemClass {
|
||||
public:
|
||||
void *value = nullptr;
|
||||
using MenuItemClass::MenuItemClass;
|
||||
MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val);
|
||||
MenuItemPtrClass(uint8_t cicon, FSTR_P text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){}
|
||||
};
|
||||
|
||||
class MenuClass {
|
||||
public:
|
||||
int8_t topline = 0;
|
||||
int8_t selected = 0;
|
||||
TitleClass MenuTitle;
|
||||
MenuClass();
|
||||
virtual ~MenuClass(){};
|
||||
inline int8_t line() { return selected - topline; };
|
||||
inline int8_t line(uint8_t pos) {return pos - topline; };
|
||||
void draw();
|
||||
void onScroll(bool dir);
|
||||
void onClick();
|
||||
MenuItemClass* SelectedItem();
|
||||
};
|
||||
extern MenuClass *CurrentMenu;
|
||||
|
||||
namespace DWINUI {
|
||||
extern xy_int_t cursor;
|
||||
extern uint16_t pencolor;
|
||||
extern uint16_t textcolor;
|
||||
extern uint16_t backcolor;
|
||||
extern uint8_t font;
|
||||
|
||||
extern void (*onCursorErase)(const int8_t line);
|
||||
extern void (*onCursorDraw)(const int8_t line);
|
||||
extern void (*onTitleDraw)(TitleClass* title);
|
||||
extern void (*onMenuDraw)(MenuClass* menu);
|
||||
|
||||
// DWIN LCD Initialization
|
||||
void init();
|
||||
|
||||
// Set text/number font
|
||||
void setFont(uint8_t cfont);
|
||||
|
||||
// Get font character width
|
||||
uint8_t fontWidth(uint8_t cfont);
|
||||
inline uint8_t fontWidth() { return fontWidth(font); };
|
||||
|
||||
// Get font character height
|
||||
uint8_t fontHeight(uint8_t cfont);
|
||||
inline uint8_t fontHeight() { return fontHeight(font); };
|
||||
|
||||
// Get screen x coordinates from text column
|
||||
uint16_t ColToX(uint8_t col);
|
||||
|
||||
// Get screen y coordinates from text row
|
||||
uint16_t RowToY(uint8_t row);
|
||||
|
||||
// Set text/number color
|
||||
void SetColors(uint16_t fgcolor, uint16_t bgcolor);
|
||||
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);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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) {
|
||||
DWIN_Draw_Line(color, cursor.x, cursor.y, x, y);
|
||||
}
|
||||
inline void LineTo(uint16_t x, uint16_t y) {
|
||||
DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
DWIN_ICON_Show(ICON, 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) {
|
||||
DWIN_ICON_Show(true, false, false, ICON, icon, x, y);
|
||||
}
|
||||
|
||||
// Draw a positive integer
|
||||
// bShow: true=display background color; false=don't display background color
|
||||
// zeroFill: true=zero fill; false=no zero fill
|
||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
||||
// size: Font size
|
||||
// color: Character color
|
||||
// bColor: Background color
|
||||
// iNum: Number of digits
|
||||
// x/y: Upper-left coordinate
|
||||
// value: Integer value
|
||||
inline void Draw_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
|
||||
DWIN_Draw_IntValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, x, y, value);
|
||||
}
|
||||
inline void Draw_Int(uint8_t iNum, long value) {
|
||||
DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
|
||||
MoveBy(iNum * fontWidth(font), 0);
|
||||
}
|
||||
inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
|
||||
DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value);
|
||||
}
|
||||
inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
|
||||
DWIN_Draw_IntValue(false, true, 0, font, 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) {
|
||||
DWIN_Draw_IntValue(true, true, 0, font, color, bColor, iNum, x, y, value);
|
||||
}
|
||||
inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
|
||||
DWIN_Draw_IntValue(true, true, 0, size, color, bColor, iNum, x, y, value);
|
||||
}
|
||||
|
||||
// Draw a floating point number
|
||||
// bShow: true=display background color; false=don't display background color
|
||||
// zeroFill: true=zero fill; false=no zero fill
|
||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
||||
// size: Font size
|
||||
// color: Character color
|
||||
// bColor: Background color
|
||||
// iNum: Number of whole digits
|
||||
// fNum: Number of decimal digits
|
||||
// x/y: Upper-left point
|
||||
// value: Float value
|
||||
inline void Draw_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value);
|
||||
}
|
||||
inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
|
||||
DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
|
||||
MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
|
||||
}
|
||||
inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||
DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
|
||||
}
|
||||
inline void Draw_Float(uint16_t color, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||
DWIN_Draw_FloatValue(false, true, 0, font, color, 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) {
|
||||
DWIN_Draw_FloatValue(true, true, 0, font, color, bColor, iNum, fNum, x, y, value);
|
||||
}
|
||||
inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||
DWIN_Draw_FloatValue(true, true, 0, size, color, bColor, iNum, fNum, x, y, value);
|
||||
}
|
||||
|
||||
// Draw a signed floating point number
|
||||
// bShow: true=display background color; false=don't display background color
|
||||
// zeroFill: true=zero fill; false=no zero fill
|
||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
||||
// size: Font size
|
||||
// bColor: Background color
|
||||
// iNum: Number of whole digits
|
||||
// fNum: Number of decimal digits
|
||||
// x/y: Upper-left point
|
||||
// value: Float value
|
||||
void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
|
||||
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
|
||||
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
|
||||
MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
|
||||
}
|
||||
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
|
||||
}
|
||||
inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||
Draw_Signed_Float(false, true, 0, size, 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_Signed_Float(true, true, 0, font, color, bColor, iNum, fNum, x, y, value);
|
||||
}
|
||||
inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||
Draw_Signed_Float(true, true, 0, size, color, bColor, iNum, fNum, x, y, value);
|
||||
}
|
||||
|
||||
// Draw a char at cursor position
|
||||
void Draw_Char(const char 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);
|
||||
}
|
||||
inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) {
|
||||
Draw_String(color, FTOP(string), rlimit);
|
||||
}
|
||||
|
||||
// Draw a string
|
||||
// size: Font size
|
||||
// color: Character color
|
||||
// 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) {
|
||||
DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string);
|
||||
}
|
||||
inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) {
|
||||
DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title));
|
||||
}
|
||||
inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) {
|
||||
DWIN_Draw_String(false, font, color, backcolor, x, y, string);
|
||||
}
|
||||
inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) {
|
||||
DWIN_Draw_String(false, font, color, backcolor, x, y, title);
|
||||
}
|
||||
inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
|
||||
DWIN_Draw_String(true, font, color, bgcolor, x, y, string);
|
||||
}
|
||||
inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
|
||||
DWIN_Draw_String(true, font, color, bgcolor, x, y, title);
|
||||
}
|
||||
inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
|
||||
DWIN_Draw_String(true, size, color, bgcolor, x, y, string);
|
||||
}
|
||||
inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
|
||||
DWIN_Draw_String(true, size, color, bgcolor, x, y, title);
|
||||
}
|
||||
|
||||
// Draw a centered string using DWIN_WIDTH
|
||||
// bShow: true=display background color; false=don't display background color
|
||||
// size: Font size
|
||||
// color: Character color
|
||||
// bColor: Background color
|
||||
// y: Upper coordinate of the string
|
||||
// *string: The string
|
||||
void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string);
|
||||
inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) {
|
||||
Draw_CenteredString(bShow, size, 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, font, color, bcolor, y, string);
|
||||
}
|
||||
inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) {
|
||||
Draw_CenteredString(false, size, color, backcolor, y, string);
|
||||
}
|
||||
inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) {
|
||||
Draw_CenteredString(false, size, color, backcolor, y, title);
|
||||
}
|
||||
inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) {
|
||||
Draw_CenteredString(false, font, color, backcolor, y, string);
|
||||
}
|
||||
inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) {
|
||||
Draw_CenteredString(false, font, color, backcolor, y, title);
|
||||
}
|
||||
inline void Draw_CenteredString(uint16_t y, const char * const string) {
|
||||
Draw_CenteredString(false, font, textcolor, backcolor, y, string);
|
||||
}
|
||||
inline void Draw_CenteredString(uint16_t y, FSTR_P title) {
|
||||
Draw_CenteredString(false, font, textcolor, backcolor, y, title);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h);
|
||||
}
|
||||
|
||||
// Draw a circle
|
||||
// Color: circle color
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Draw a checkbox
|
||||
// Color: frame color
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Color Interpolator
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximum value
|
||||
// color1 : Start color
|
||||
// color2 : End color
|
||||
uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
|
||||
|
||||
// -------------------------- Extra -------------------------------//
|
||||
|
||||
// Draw a circle filled with color
|
||||
// bcolor: fill color
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Color Interpolator through Red->Yellow->Green->Blue
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximum value
|
||||
uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
|
||||
|
||||
// Write buffer data to the SRAM
|
||||
// addr: SRAM start address 0x0000-0x7FFF
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Write buffer data to the Flash
|
||||
// addr: Flash start address 0x0000-0x3FFF
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Clear Menu by filling the area with background color
|
||||
// Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1)
|
||||
void ClearMenuArea();
|
||||
|
||||
// Clear MenuItems array and free MenuItems elements
|
||||
void MenuItemsClear();
|
||||
|
||||
// Prepare MenuItems array
|
||||
void MenuItemsPrepare(int8_t totalitems);
|
||||
|
||||
// Add elements to the MenuItems array
|
||||
MenuItemClass* MenuItemsAdd(MenuItemClass* menuitem);
|
||||
|
||||
};
|
111
Marlin/src/lcd/e3v2/proui/endstop_diag.cpp
Normal file
111
Marlin/src/lcd/e3v2/proui/endstop_diag.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DWIN End Stops diagnostic page
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 1.0.2
|
||||
* Date: 2021/11/06
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
#include "dwin_defines.h"
|
||||
|
||||
#if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_ESDIAG)
|
||||
|
||||
#include "endstop_diag.h"
|
||||
|
||||
#include "../../../core/types.h"
|
||||
#include "../../marlinui.h"
|
||||
#include "dwin_lcd.h"
|
||||
#include "dwinui.h"
|
||||
#include "dwin_popup.h"
|
||||
#include "dwin.h"
|
||||
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
#include "../../../feature/runout.h"
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#include "../../../module/probe.h"
|
||||
#endif
|
||||
|
||||
ESDiagClass 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);
|
||||
}
|
||||
|
||||
void draw_es_state(const bool is_hit) {
|
||||
const uint8_t LM = 130;
|
||||
DWINUI::cursor.x = LM;
|
||||
DWIN_Draw_Rectangle(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);
|
||||
}
|
||||
|
||||
void ESDiagClass::Draw() {
|
||||
Title.ShowCaption(F("End-stops Diagnostic"));
|
||||
DWINUI::ClearMenuArea();
|
||||
Draw_Popup_Bkgd();
|
||||
DWINUI::Draw_Icon(ICON_Continue_E, 86, 250);
|
||||
DWINUI::cursor.y = 80;
|
||||
#define ES_LABEL(S) draw_es_label(F(STR_##S))
|
||||
#if HAS_X_MIN
|
||||
ES_LABEL(X_MIN);
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
ES_LABEL(Y_MIN);
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
ES_LABEL(Z_MIN);
|
||||
#endif
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
draw_es_label(F(STR_FILAMENT));
|
||||
#endif
|
||||
Update();
|
||||
}
|
||||
|
||||
void ESDiagClass::Update() {
|
||||
DWINUI::cursor.y = 80;
|
||||
#define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING)
|
||||
#if HAS_X_MIN
|
||||
ES_REPORT(X_MIN);
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
ES_REPORT(Y_MIN);
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
ES_REPORT(Z_MIN);
|
||||
#endif
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE);
|
||||
#endif
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_ESDIAG
|
39
Marlin/src/lcd/e3v2/proui/endstop_diag.h
Normal file
39
Marlin/src/lcd/e3v2/proui/endstop_diag.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN End Stops diagnostic page
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 1.0
|
||||
* Date: 2021/11/06
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
class ESDiagClass {
|
||||
public:
|
||||
void Draw();
|
||||
void Update();
|
||||
};
|
||||
|
||||
extern ESDiagClass ESDiag;
|
78
Marlin/src/lcd/e3v2/proui/lockscreen.cpp
Normal file
78
Marlin/src/lcd/e3v2/proui/lockscreen.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lock screen implementation for DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 2.1
|
||||
* Date: 2021/11/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||
|
||||
#include "../../../core/types.h"
|
||||
#include "dwin_lcd.h"
|
||||
#include "dwinui.h"
|
||||
#include "dwin.h"
|
||||
#include "lockscreen.h"
|
||||
|
||||
LockScreenClass lockScreen;
|
||||
|
||||
uint8_t LockScreenClass::lock_pos = 0;
|
||||
bool LockScreenClass::unlocked = false;
|
||||
uint8_t LockScreenClass::rprocess = 0;
|
||||
|
||||
void LockScreenClass::init() {
|
||||
lock_pos = 0;
|
||||
unlocked = false;
|
||||
draw();
|
||||
}
|
||||
|
||||
void LockScreenClass::draw() {
|
||||
Title.SetCaption(PSTR("Lock Screen"));
|
||||
DWINUI::ClearMenuArea();
|
||||
DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo
|
||||
DWINUI::Draw_CenteredString(Color_White, 180, F("Printer is Locked,"));
|
||||
DWINUI::Draw_CenteredString(Color_White, 200, F("Scroll to unlock."));
|
||||
DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
|
||||
DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
|
||||
DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
void LockScreenClass::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;
|
||||
}
|
||||
DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
|
||||
DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
48
Marlin/src/lcd/e3v2/proui/lockscreen.h
Normal file
48
Marlin/src/lcd/e3v2/proui/lockscreen.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Lock screen implementation for DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 2.1
|
||||
* Date: 2021/11/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../common/encoder.h"
|
||||
#include <stdint.h>
|
||||
|
||||
class LockScreenClass {
|
||||
private:
|
||||
static bool unlocked;
|
||||
static uint8_t lock_pos;
|
||||
public:
|
||||
static uint8_t rprocess;
|
||||
static void init();
|
||||
static void onEncoder(EncoderState encoder_diffState);
|
||||
static void draw();
|
||||
static bool isUnlocked() { return unlocked; }
|
||||
};
|
||||
|
||||
extern LockScreenClass lockScreen;
|
112
Marlin/src/lcd/e3v2/proui/meshviewer.cpp
Normal file
112
Marlin/src/lcd/e3v2/proui/meshviewer.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DWIN Mesh Viewer
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.9.1
|
||||
* Date: 2021/11/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_MESH)
|
||||
|
||||
#include "meshviewer.h"
|
||||
|
||||
#include "../../../core/types.h"
|
||||
#include "../../marlinui.h"
|
||||
#include "dwin_lcd.h"
|
||||
#include "dwinui.h"
|
||||
#include "dwin.h"
|
||||
#include "../../../feature/bedlevel/bedlevel.h"
|
||||
|
||||
MeshViewerClass MeshViewer;
|
||||
|
||||
void MeshViewerClass::Draw() {
|
||||
const int8_t mx = 25, my = 25; // Margins
|
||||
const int16_t stx = (DWIN_WIDTH - 2 * mx) / (GRID_MAX_POINTS_X - 1), // Steps
|
||||
sty = (DWIN_WIDTH - 2 * my) / (GRID_MAX_POINTS_Y - 1);
|
||||
const int8_t rmax = _MIN(mx - 2, stx / 2);
|
||||
const int8_t rmin = 7;
|
||||
int16_t zmesh[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y], maxz =-32000, minz = 32000;
|
||||
#define px(xp) (mx + (xp) * stx)
|
||||
#define py(yp) (30 + DWIN_WIDTH - my - (yp) * sty)
|
||||
#define rm(z) ((z - minz) * (rmax - rmin) / _MAX(1, (maxz - minz)) + rmin)
|
||||
#define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 12, py(yp) - 6, zv)
|
||||
#define DrawMeshHLine(yp) DWIN_Draw_HLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx)
|
||||
#define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(GRID_MAX_POINTS_Y - 1), DWIN_WIDTH - 2 * my)
|
||||
GRID_LOOP(x, y) {
|
||||
const float v = isnan(Z_VALUES(x,y)) ? 0 : round(Z_VALUES(x,y) * 100);
|
||||
zmesh[x][y] = v;
|
||||
NOLESS(maxz, v);
|
||||
NOMORE(minz, v);
|
||||
}
|
||||
Title.ShowCaption(F("Mesh Viewer"));
|
||||
DWINUI::ClearMenuArea();
|
||||
DWINUI::Draw_Icon(ICON_Continue_E, 86, 305);
|
||||
DWIN_Draw_Rectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(GRID_MAX_POINTS_X - 1), py(GRID_MAX_POINTS_Y - 1));
|
||||
LOOP_S_L_N(x, 1, GRID_MAX_POINTS_X - 1) DrawMeshVLine(x);
|
||||
LOOP_S_L_N(y, 1, GRID_MAX_POINTS_Y - 1) DrawMeshHLine(y);
|
||||
LOOP_L_N(y, GRID_MAX_POINTS_Y) {
|
||||
watchdog_refresh();
|
||||
LOOP_L_N(x, GRID_MAX_POINTS_X) {
|
||||
uint16_t color = DWINUI::RainbowInt(zmesh[x][y], _MIN(-5, minz), _MAX(5, maxz));
|
||||
uint8_t radius = rm(zmesh[x][y]);
|
||||
DWINUI::Draw_FillCircle(color, px(x), py(y), radius);
|
||||
if (GRID_MAX_POINTS_X < 9)
|
||||
DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 12, py(y) - 6, Z_VALUES(x,y));
|
||||
else {
|
||||
char str_1[9];
|
||||
str_1[0] = 0;
|
||||
switch (zmesh[x][y]) {
|
||||
case -999 ... -100:
|
||||
DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y));
|
||||
break;
|
||||
case -99 ... -1:
|
||||
sprintf_P(str_1, PSTR("-.%02i"), -zmesh[x][y]);
|
||||
break;
|
||||
case 0:
|
||||
DWIN_Draw_String(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, py(y) - 6, "0");;
|
||||
break;
|
||||
case 1 ... 99:
|
||||
sprintf_P(str_1, PSTR(".%02i"), zmesh[x][y]);
|
||||
break;
|
||||
case 100 ... 999:
|
||||
DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y));
|
||||
break;
|
||||
}
|
||||
if (str_1[0])
|
||||
DWIN_Draw_String(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 12, py(y) - 6, str_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
char str_1[6], str_2[6] = "";
|
||||
ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"),
|
||||
dtostrf((float)minz / 100, 1, 2, str_1),
|
||||
dtostrf((float)maxz / 100, 1, 2, str_2)
|
||||
);
|
||||
}
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_MESH
|
38
Marlin/src/lcd/e3v2/proui/meshviewer.h
Normal file
38
Marlin/src/lcd/e3v2/proui/meshviewer.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN Mesh Viewer
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 3.9.1
|
||||
* Date: 2021/11/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
class MeshViewerClass {
|
||||
public:
|
||||
void Draw();
|
||||
};
|
||||
|
||||
extern MeshViewerClass MeshViewer;
|
78
Marlin/src/lcd/e3v2/proui/printstats.cpp
Normal file
78
Marlin/src/lcd/e3v2/proui/printstats.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DWIN Print Stats page
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 1.1
|
||||
* Date: 2022/01/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if BOTH(DWIN_CREALITY_LCD_ENHANCED, PRINTCOUNTER)
|
||||
|
||||
#include "printstats.h"
|
||||
|
||||
#include "../../../core/types.h"
|
||||
#include "../../marlinui.h"
|
||||
#include "../../../module/printcounter.h"
|
||||
#include "dwin_lcd.h"
|
||||
#include "dwinui.h"
|
||||
#include "dwin_popup.h"
|
||||
#include "dwin.h"
|
||||
|
||||
PrintStatsClass PrintStats;
|
||||
|
||||
void PrintStatsClass::Draw() {
|
||||
char buf[50] = "";
|
||||
char str[30] = "";
|
||||
constexpr int8_t MRG = 30;
|
||||
|
||||
Title.ShowCaption(GET_TEXT_F(MSG_INFO_STATS_MENU));
|
||||
DWINUI::ClearMenuArea();
|
||||
Draw_Popup_Bkgd();
|
||||
DWINUI::Draw_Icon(ICON_Continue_E, 86, 250);
|
||||
printStatistics ps = print_job_timer.getStats();
|
||||
|
||||
sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_PRINT_COUNT), ps.totalPrints);
|
||||
DWINUI::Draw_String(MRG, 80, buf);
|
||||
sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_COMPLETED_PRINTS), ps.finishedPrints);
|
||||
DWINUI::Draw_String(MRG, 100, buf);
|
||||
duration_t(print_job_timer.getStats().printTime).toDigital(str, true);
|
||||
sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_TIME), str);
|
||||
DWINUI::Draw_String(MRG, 120, buf);
|
||||
duration_t(print_job_timer.getStats().longestPrint).toDigital(str, true);
|
||||
sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_LONGEST), str);
|
||||
DWINUI::Draw_String(MRG, 140, buf);
|
||||
sprintf_P(buf, PSTR(S_FMT ": %s m"), GET_TEXT(MSG_INFO_PRINT_FILAMENT), dtostrf(ps.filamentUsed / 1000, 1, 2, str));
|
||||
DWINUI::Draw_String(MRG, 160, buf);
|
||||
}
|
||||
|
||||
void PrintStatsClass::Reset() {
|
||||
print_job_timer.initStats();
|
||||
HMI_AudioFeedback();
|
||||
}
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED && PRINTCOUNTER
|
39
Marlin/src/lcd/e3v2/proui/printstats.h
Normal file
39
Marlin/src/lcd/e3v2/proui/printstats.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN Print Stats page
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* Version: 1.1
|
||||
* Date: 2022/01/09
|
||||
*
|
||||
* Based on the original code provided by Creality under GPL
|
||||
*/
|
||||
|
||||
class PrintStatsClass {
|
||||
public:
|
||||
void Draw();
|
||||
static void Reset();
|
||||
};
|
||||
|
||||
extern PrintStatsClass PrintStats;
|
Reference in New Issue
Block a user