🚸 JyersUI updates (#24451)

This commit is contained in:
Meilleur Gars 2022-07-06 13:46:11 -07:00 committed by Scott Lahteine
parent 03760fd79e
commit e93a1dd2fa
32 changed files with 4336 additions and 984 deletions

View File

@ -51,6 +51,8 @@
#include "../../../lcd/e3v2/creality/dwin.h"
#elif ENABLED(DWIN_LCD_PROUI)
#include "../../../lcd/e3v2/proui/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../../lcd/e3v2/jyersui/dwin.h"
#endif
#if HAS_MULTI_HOTEND

View File

@ -26,6 +26,10 @@
#include "../gcode.h"
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../lcd/e3v2/jyersui/dwin.h"
#endif
/**
* M575 - Change serial baud rate
*
@ -65,7 +69,10 @@ void GcodeSuite::M575() {
SERIAL_FLUSH();
if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); }
if (set1) {
MYSERIAL1.end(); MYSERIAL1.begin(baud);
TERN_(DWIN_CREALITY_LCD_JYERSUI, eeprom_settings.Baud115k = (baud == 115200));
}
#if HAS_MULTI_SERIAL
if (set2) { MYSERIAL2.end(); MYSERIAL2.begin(baud); }
#ifdef SERIAL_PORT_3

View File

@ -26,6 +26,8 @@
#if ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../lcd/e3v2/jyersui/dwin.h"
#endif
/**
@ -34,6 +36,7 @@
void GcodeSuite::M997() {
TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen());
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.DWIN_RebootScreen());
flashFirmware(parser.intval('S'));

View File

@ -38,6 +38,8 @@
#elif ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin_popup.h"
#include "../../lcd/e3v2/proui/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../lcd/e3v2/jyersui/dwin.h"
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
@ -76,6 +78,8 @@ void GcodeSuite::M0_M1() {
DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT));
else
DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT_F(MSG_STOPPED), GET_TEXT_F(MSG_USERWAIT));
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
CrealityDWIN.Confirm_Handler(UserInput, parser.string_arg == nullptr);
#else
if (parser.string_arg) {

View File

@ -33,7 +33,7 @@
#include "../../feature/probe_temp_comp.h"
#endif
#if ENABLED(DWIN_LCD_PROUI)
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
#include "../../lcd/marlinui.h"
#endif
@ -53,7 +53,7 @@ void GcodeSuite::G30() {
parser.linearval('Y', current_position.y + probe.offset_xy.y) };
if (!probe.can_reach(pos)) {
#if ENABLED(DWIN_LCD_PROUI)
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT));
LCD_MESSAGE(MSG_ZPROBE_OUT);
#endif
@ -65,7 +65,9 @@ void GcodeSuite::G30() {
remember_feedrate_scaling_off();
TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O")));
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
process_subcommands_now(F("G28O"));
#endif
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
@ -74,7 +76,7 @@ void GcodeSuite::G30() {
TERN_(HAS_PTC, ptc.set_enabled(true));
if (!isnan(measured_z)) {
SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
#if ENABLED(DWIN_LCD_PROUI)
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
char msg[31], str_1[6], str_2[6], str_3[6];
sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"),
dtostrf(pos.x, 1, 1, str_1),

View File

@ -33,15 +33,23 @@
#include "../../lcd/e3v2/proui/dwin.h"
#endif
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../lcd/e3v2/jyersui/dwin.h"
#endif
/**
* M75: Start print timer
*/
void GcodeSuite::M75() {
startOrResumeJob();
#if ENABLED(DWIN_LCD_PROUI)
DWIN_Print_Started(false);
if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
#endif
TERN_(DWIN_LCD_PROUI, DWIN_Print_Started(false));
if (!IS_SD_PRINTING()) {
#if ENABLED(DWIN_LCD_PROUI)
DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
CrealityDWIN.Update_Print_Filename(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
#endif
}
}
/**

View File

@ -32,6 +32,8 @@
#include "../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_LCD_PROUI)
#include "../../lcd/e3v2/proui/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../lcd/e3v2/jyersui/dwin.h"
#endif
/**
@ -75,6 +77,7 @@ void GcodeSuite::M303() {
SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM));
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_BAD_EXTRUDER_NUM));
return;
}

View File

@ -1256,6 +1256,8 @@
#endif
#if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT)
#define HAS_ABL_NOT_UBL 1
#else
#undef PROBE_MANUALLY
#endif
#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
#define HAS_MESH 1
@ -1274,14 +1276,11 @@
#if DISABLED(AUTO_BED_LEVELING_UBL)
#define PLANNER_LEVELING 1
#endif
#endif
#if !HAS_LEVELING
#else
#undef RESTORE_LEVELING_AFTER_G28
#undef ENABLE_LEVELING_AFTER_G28
#undef G29_RETRY_AND_RECOVER
#endif
#if !HAS_LEVELING || EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
#undef PROBE_MANUALLY
#undef PREHEAT_BEFORE_LEVELING
#endif
#if ANY(HAS_BED_PROBE, PROBE_MANUALLY, MESH_BED_LEVELING)
#define PROBE_SELECTED 1

View File

@ -3541,7 +3541,7 @@
#ifndef MESH_MAX_Y
#define MESH_MAX_Y _MESH_MAX_Y
#endif
#else
#elif DISABLED(DWIN_CREALITY_LCD_JYERSUI)
#undef MESH_MIN_X
#undef MESH_MIN_Y
#undef MESH_MAX_X

View File

@ -3671,7 +3671,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
#error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel."
#endif
#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI)
#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
#error "LED_CONTROL_MENU requires an LCD controller that implements the menu."
#endif

View File

@ -234,7 +234,7 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
// *string: The string
// rlimit: To limit the drawn string length
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) {
#if DISABLED(DWIN_LCD_PROUI)
#if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size));
#endif
constexpr uint8_t widthAdjust = 0;
@ -266,7 +266,9 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor,
void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) {
size_t i = 0;
DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size));
#if DISABLED(DWIN_CREALITY_LCD_JYERSUI)
DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size));
#endif
DWIN_Byte(i, 0x14);
// Bit 7: bshow
// Bit 6: 1 = signed; 0 = unsigned number;
@ -314,7 +316,9 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
//uint8_t *fvalue = (uint8_t*)&value;
size_t i = 0;
DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size));
#if DISABLED(DWIN_CREALITY_LCD_JYERSUI)
DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size));
#endif
DWIN_Byte(i, 0x14);
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
DWIN_Word(i, color);

View File

@ -0,0 +1,208 @@
/**
* Base64 encoder/decoder for arduino repo
* Uses common web conventions - '+' for 62, '/' for 63, '=' for padding.
* Note that invalid base64 characters are interpreted as padding.
* Author: Densaugeo
* Maintainer: Densaugeo
* Version: 1.2.1.1
* Changed unsigned int to uint16_t for use in the professional Ender 3V2/S1 firmware
* Url: https://www.arduino.cc/reference/en/libraries/base64/
*/
#ifndef BASE64_H_INCLUDED
#define BASE64_H_INCLUDED
/* binary_to_base64:
* Description:
* Converts a single byte from a binary value to the corresponding base64 character
* Parameters:
* v - Byte to convert
* Returns:
* ascii code of base64 character. If byte is >= 64, then there is not corresponding base64 character
* and 255 is returned
*/
unsigned char binary_to_base64(unsigned char v);
/* base64_to_binary:
* Description:
* Converts a single byte from a base64 character to the corresponding binary value
* Parameters:
* c - Base64 character (as ascii code)
* Returns:
* 6-bit binary value
*/
unsigned char base64_to_binary(unsigned char c);
/* encode_base64_length:
* Description:
* Calculates length of base64 string needed for a given number of binary bytes
* Parameters:
* input_length - Amount of binary data in bytes
* Returns:
* Number of base64 characters needed to encode input_length bytes of binary data
*/
uint16_t encode_base64_length(uint16_t input_length);
/* decode_base64_length:
* Description:
* Calculates number of bytes of binary data in a base64 string
* Variant that does not use input_length no longer used within library, retained for API compatibility
* Parameters:
* input - Base64-encoded null-terminated string
* input_length (optional) - Number of bytes to read from input pointer
* Returns:
* Number of bytes of binary data in input
*/
uint16_t decode_base64_length(unsigned char input[]);
uint16_t decode_base64_length(unsigned char input[], uint16_t input_length);
/* encode_base64:
* Description:
* Converts an array of bytes to a base64 null-terminated string
* Parameters:
* input - Pointer to input data
* input_length - Number of bytes to read from input pointer
* output - Pointer to output string. Null terminator will be added automatically
* Returns:
* Length of encoded string in bytes (not including null terminator)
*/
uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]);
/* decode_base64:
* Description:
* Converts a base64 null-terminated string to an array of bytes
* Parameters:
* input - Pointer to input string
* input_length (optional) - Number of bytes to read from input pointer
* output - Pointer to output array
* Returns:
* Number of bytes in the decoded binary
*/
uint16_t decode_base64(unsigned char input[], unsigned char output[]);
uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]);
unsigned char binary_to_base64(unsigned char v) {
// Capital letters - 'A' is ascii 65 and base64 0
if (v < 26) return v + 'A';
// Lowercase letters - 'a' is ascii 97 and base64 26
if (v < 52) return v + 71;
// Digits - '0' is ascii 48 and base64 52
if (v < 62) return v - 4;
// '+' is ascii 43 and base64 62
if (v == 62) return '+';
// '/' is ascii 47 and base64 63
if (v == 63) return '/';
return 64;
}
unsigned char base64_to_binary(unsigned char c) {
// Capital letters - 'A' is ascii 65 and base64 0
if ('A' <= c && c <= 'Z') return c - 'A';
// Lowercase letters - 'a' is ascii 97 and base64 26
if ('a' <= c && c <= 'z') return c - 71;
// Digits - '0' is ascii 48 and base64 52
if ('0' <= c && c <= '9') return c + 4;
// '+' is ascii 43 and base64 62
if (c == '+') return 62;
// '/' is ascii 47 and base64 63
if (c == '/') return 63;
return 255;
}
uint16_t encode_base64_length(uint16_t input_length) {
return (input_length + 2)/3*4;
}
uint16_t decode_base64_length(unsigned char input[]) {
return decode_base64_length(input, -1);
}
uint16_t decode_base64_length(unsigned char input[], uint16_t input_length) {
unsigned char *start = input;
while (base64_to_binary(input[0]) < 64 && (unsigned char)(input - start) < input_length) {
++input;
}
input_length = input - start;
return input_length/4*3 + (input_length % 4 ? input_length % 4 - 1 : 0);
}
uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) {
uint16_t full_sets = input_length/3;
// While there are still full sets of 24 bits...
for (uint16_t i = 0; i < full_sets; ++i) {
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4);
output[2] = binary_to_base64((input[1] & 0x0F) << 2 | input[2] >> 6);
output[3] = binary_to_base64( input[2] & 0x3F);
input += 3;
output += 4;
}
switch (input_length % 3) {
case 0:
output[0] = '\0';
break;
case 1:
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4);
output[2] = '=';
output[3] = '=';
output[4] = '\0';
break;
case 2:
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4);
output[2] = binary_to_base64((input[1] & 0x0F) << 2);
output[3] = '=';
output[4] = '\0';
break;
}
return encode_base64_length(input_length);
}
uint16_t decode_base64(unsigned char input[], unsigned char output[]) {
return decode_base64(input, -1, output);
}
uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) {
uint16_t output_length = decode_base64_length(input, input_length);
// While there are still full sets of 24 bits...
for (uint16_t i = 2; i < output_length; i += 3) {
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2;
output[2] = base64_to_binary(input[2]) << 6 | base64_to_binary(input[3]);
input += 4;
output += 3;
}
switch (output_length % 3) {
case 1:
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
break;
case 2:
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2;
break;
}
return output_length;
}
#endif // BASE64_H_INCLUDED

File diff suppressed because it is too large Load Diff

View File

@ -23,27 +23,26 @@
/**
* lcd/e3v2/jyersui/dwin.h
* JYERSUI Author: Jacob Myers
*
* JYERSUI Enhanced by LCH-77
* Version: 1.9
* Date: Jun 16, 2022
*/
#include "dwin_lcd.h"
#include "../common/dwin_set.h"
#include "../common/dwin_font.h"
#include "../common/dwin_color.h"
#include "../common/encoder.h"
#include "../../../libs/BL24CXX.h"
#include "dwin_defines.h"
#include "../../../inc/MarlinConfigPre.h"
//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
#include "../../../inc/MarlinConfig.h"
enum processID : uint8_t {
Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait, Locked, Cancel, Keyboard
};
enum PopupID : uint8_t {
Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot,
Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, PIDWait, Resuming, ManualProbing,
FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom
Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, Resuming, ManualProbing,
FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom, ESDiagPopup, PrintConfirm,
PIDWait, PIDWaitH, PIDWaitB, BadextruderNumber, TempTooHigh, PIDTimeout, PIDDone
};
enum menuID : uint8_t {
@ -55,6 +54,7 @@ enum menuID : uint8_t {
ZOffset,
Preheat,
ChangeFilament,
HostActions,
MenuCustom,
Control,
TempMenu,
@ -69,105 +69,108 @@ enum menuID : uint8_t {
HomeOffsets,
MaxSpeed,
MaxAcceleration,
MaxJerk,
#if HAS_CLASSIC_JERK
MaxJerk,
#endif
#if HAS_JUNCTION_DEVIATION
JDmenu,
#endif
Steps,
#if ENABLED(FWRETRACT)
FwRetraction,
#endif
Visual,
ColorSettings,
HostSettings,
ActionCommands,
Advanced,
ProbeMenu,
#if HAS_BED_PROBE
ProbeMenu,
#endif
Info,
Leveling,
LevelManual,
LevelView,
MeshViewer,
LevelSettings,
ManualMesh,
UBLMesh,
#if HAS_MESH
Leveling,
LevelManual,
LevelView,
MeshViewer,
LevelSettings,
#if ENABLED(PROBE_MANUALLY)
ManualMesh,
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE
UBLMesh,
#endif
#endif
InfoMain,
Tune,
PreheatHotend
PreheatHotend,
#if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU)
Ledsmenu,
#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
CaseLightmenu,
#endif
#if ENABLED(LED_CONTROL_MENU)
LedControlmenu,
#if HAS_COLOR_LEDS
#if ENABLED(LED_COLOR_PRESETS)
LedControlpresets,
#else
LedControlcustom,
#endif
#endif
#endif
#endif
};
// Custom icons
#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
// index of every custom icon should be >= CUSTOM_ICON_START
#define CUSTOM_ICON_START ICON_Checkbox_F
#define ICON_Checkbox_F 200
#define ICON_Checkbox_T 201
#define ICON_Fade 202
#define ICON_Mesh 203
#define ICON_Tilt 204
#define ICON_Brightness 205
#define ICON_AxisD 249
#define ICON_AxisBR 250
#define ICON_AxisTR 251
#define ICON_AxisBL 252
#define ICON_AxisTL 253
#define ICON_AxisC 254
#else
#define ICON_Fade ICON_Version
#define ICON_Mesh ICON_Version
#define ICON_Tilt ICON_Version
#define ICON_Brightness ICON_Version
#define ICON_AxisD ICON_Axis
#define ICON_AxisBR ICON_Axis
#define ICON_AxisTR ICON_Axis
#define ICON_AxisBL ICON_Axis
#define ICON_AxisTL ICON_Axis
#define ICON_AxisC ICON_Axis
#endif
typedef struct {
// Flags
bool flag_tune = false;
bool auto_fw_retract = false;
bool printing = false;
bool paused = false;
bool sdprint = false;
bool livemove = false;
bool liveadjust = false;
bool probe_deployed = false;
// Auxiliary values
AxisEnum axis = X_AXIS; // Axis Select
int16_t pausetemp = 0;
int16_t pausebed = 0;
int16_t pausefan = 0;
uint8_t preheatmode = 0;
uint8_t zoffsetmode = 0;
float zoffsetvalue = 0;
uint8_t gridpoint;
float corner_avg;
float corner_pos;
float zval;
#if ENABLED(PREHEAT_BEFORE_LEVELING)
uint8_t LevelingTempmode = 0;
#endif
#if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
uint32_t LED_Color = Def_Leds_Color;
#endif
#if HAS_PID_HEATING
uint16_t PID_e_temp = 180;
uint16_t PID_bed_temp = 60;
#endif
} temp_val_t;
extern temp_val_t temp_val;
#define Custom_Colors 10
enum colorID : uint8_t {
Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
};
#define Custom_Colors 10
#define Color_Aqua RGB(0x00,0x3F,0x1F)
#define Color_Light_White 0xBDD7
#define Color_Green RGB(0x00,0x3F,0x00)
#define Color_Light_Green 0x3460
#define Color_Cyan 0x07FF
#define Color_Light_Cyan 0x04F3
#define Color_Blue 0x015F
#define Color_Light_Blue 0x3A6A
#define Color_Magenta 0xF81F
#define Color_Light_Magenta 0x9813
#define Color_Light_Red 0x8800
#define Color_Orange 0xFA20
#define Color_Light_Orange 0xFBC0
#define Color_Light_Yellow 0x8BE0
#define Color_Brown 0xCC27
#define Color_Light_Brown 0x6204
#define Color_Black 0x0000
#define Color_Grey 0x18E3
#define Check_Color 0x4E5C // Check-box check color
#define Confirm_Color 0x34B9
#define Cancel_Color 0x3186
enum pidresult_t : uint8_t { PID_STARTED, PID_EXTR_START, PID_BED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE };
class CrealityDWINClass {
public:
static constexpr size_t eeprom_data_size = 48;
static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes
bool time_format_textual : 1;
#if ENABLED(AUTO_BED_LEVELING_UBL)
uint8_t tilt_grid_size : 3;
#endif
uint16_t corner_pos : 10;
uint8_t cursor_color : 4;
uint8_t menu_split_line : 4;
uint8_t menu_top_bg : 4;
uint8_t menu_top_txt : 4;
uint8_t highlight_box : 4;
uint8_t progress_percent : 4;
uint8_t progress_time : 4;
uint8_t status_bar_text : 4;
uint8_t status_area_text : 4;
uint8_t coordinates_text : 4;
uint8_t coordinates_split_line : 4;
} eeprom_settings;
static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" };
static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" };
static constexpr const char * const zoffset_modes[3] = { "No Live" , "OnClick", " Live" };
#if ENABLED(PREHEAT_BEFORE_LEVELING)
static constexpr const char * const preheat_levmodes[4] = { " Both", " Hotend", " Bed", " None" };
#endif
static void Clear_Screen(uint8_t e=3);
static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10);
@ -192,7 +195,7 @@ public:
static void Draw_Print_ProgressRemain();
#endif
static void Draw_Print_ProgressElapsed();
static void Draw_Print_confirm();
static void Draw_PrintDone_confirm();
static void Draw_SD_Item(uint8_t item, uint8_t row);
static void Draw_SD_List(bool removed=false);
static void Draw_Status_Area(bool icons=false);
@ -209,8 +212,8 @@ public:
static uint8_t Get_Menu_Size(uint8_t menu);
static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true);
static void Popup_Handler(PopupID popupid, bool option = false);
static void Confirm_Handler(PopupID popupid);
static void Popup_Handler(PopupID popupid, bool option=false);
static void Confirm_Handler(PopupID popupid, bool option=false);
static void Main_Menu_Control();
static void Menu_Control();
@ -231,6 +234,7 @@ public:
static void Modify_Option(uint8_t value, const char * const * options, uint8_t max);
static void Update_Status(const char * const text);
static void Update_Status(FSTR_P text);
static void Start_Print(bool sd);
static void Stop_Print();
static void Update();
@ -240,6 +244,40 @@ public:
static void Save_Settings(char *buff);
static void Load_Settings(const char *buff);
static void Reset_Settings();
static void PreheatBefore();
#if HAS_ESDIAG
static void DWIN_EndstopsDiag();
#endif
#if HAS_LOCKSCREEN
static void DWIN_LockScreen();
static void DWIN_UnLockScreen();
static void HMI_LockScreen();
#endif
static void DWIN_RebootScreen();
static void RebootPrinter();
static void Update_Print_Filename(const char * const text);
#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS)
static void ApplyLEDColor();
#endif
#if HAS_HOSTACTION_MENUS
static void Draw_String(char * string, uint8_t row, bool selected=false, bool below=false);
static const uint64_t Encode_String(const char * string);
static void Decode_String(uint64_t num, char * string);
static void Draw_Keyboard(bool restrict, bool numeric, uint8_t selected=0, bool uppercase=false, bool lock=false);
static void Draw_Keys(uint8_t index, bool selected, bool uppercase=false, bool lock=false);
static void Modify_String(char * string, uint8_t maxlength, bool restrict);
static void Keyboard_Control();
#endif
#if HAS_PIDPLOT
static void DWIN_Draw_PIDPopup(const pidresult_t pidresult);
#endif
#if HAS_PID_HEATING
static void DWIN_PidTuning(const pidresult_t pidresult);
#endif
};
extern CrealityDWINClass CrealityDWIN;

View File

@ -0,0 +1,131 @@
/**
* 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 for PRO UI
* Author: Miguel A. Risco-Castillo (MRISCOC)
* Version: 3.11.2
* Date: 2022/02/28
*
* Modded for JYERSUI by LCH-77
* Version: 1.9
* Date: Jun 16, 2022
*/
#include "../../../inc/MarlinConfigPre.h"
#define HAS_ESDIAG 1
#define HAS_LOCKSCREEN 1
#define HAS_PIDPLOT 1
#define HAS_GCODE_PREVIEW 1
//#define DEBUG_DWIN 1
//#define NEED_HEX_PRINT 1
#if ENABLED(HOST_ACTION_COMMANDS)
#define HAS_HOSTACTION_MENUS 1
#endif
#include "../../../core/types.h"
#include "../common/dwin_color.h"
// Default UI Colors
#define Def_Background_Color RGB(4,4,0)
#define Def_Cursor_color RGB(24,24,0)
#define Def_TitleBg_color RGB(12,12,0)
#define Def_TitleTxt_color Color_White
#define Def_Text_Color Color_White
#define Def_Selected_Color RGB(24,24,0)
#define Def_SplitLine_Color RGB(24,24,0)
#define Def_Highlight_Color RGB(31,40,0)
#define Def_StatusBg_Color RGB(12,12,0)
#define Def_StatusTxt_Color Color_White
#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 RGB(31,48,8)
#define Def_Barfill_Color RGB(12,12,0)
#define Def_Indicator_Color RGB(31,48,8)
#define Def_Coordinate_Color Color_White
#define Def_Button_Color RGB(12,12,0)
#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS)
#define Def_Leds_Color 0xFFFFFFFF
#endif
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
#define Def_CaseLight_Brightness 255
#endif
#if HAS_MESH
#ifndef MESH_INSET
#define MESH_INSET 25
#endif
#ifndef MESH_MIN_X
#define MESH_MIN_X MESH_INSET
#endif
#ifndef MESH_MIN_Y
#define MESH_MIN_Y MESH_INSET
#endif
#ifndef MESH_MAX_X
#define MESH_MAX_X X_BED_SIZE - (MESH_INSET)
#endif
#ifndef MESH_MAX_Y
#define MESH_MAX_Y X_BED_SIZE - (MESH_INSET)
#endif
#endif
typedef struct {
bool time_format_textual : 1;
#if ENABLED(AUTO_BED_LEVELING_UBL)
uint8_t tilt_grid_size : 3;
#endif
uint16_t corner_pos : 10;
uint8_t cursor_color : 4;
uint8_t menu_split_line : 4;
uint8_t menu_top_bg : 4;
uint8_t menu_top_txt : 4;
uint8_t highlight_box : 4;
uint8_t progress_percent : 4;
uint8_t progress_time : 4;
uint8_t status_bar_text : 4;
uint8_t status_area_text : 4;
uint8_t coordinates_text : 4;
uint8_t coordinates_split_line : 4;
#if ENABLED(BAUD_RATE_GCODE)
bool Baud115k : 1;
#endif
#if ENABLED(PREHEAT_BEFORE_LEVELING)
bool ena_hotend_levtemp : 1;
bool ena_bed_levtemp : 1;
celsius_t hotend_levtemp = LEVELING_NOZZLE_TEMP;
celsius_t bed_levtemp = LEVELING_BED_TEMP;
#endif
#if HAS_HOSTACTION_MENUS
uint64_t host_action_label_1 : 48;
uint64_t host_action_label_2 : 48;
uint64_t host_action_label_3 : 48;
#endif
} eeprom_settings_t;
static constexpr size_t eeprom_data_size = 48;
extern eeprom_settings_t eeprom_settings;

View File

@ -53,12 +53,41 @@ void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
/*---------------------------------------- Picture related functions ----------------------------------------*/
// Draw an Icon
// 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(true, false, false, libID, picID, x, y);
DWIN_ICON_Show(false, false, true, libID, picID, x, y);
}
// From DWIN Enhanced implementation for PRO UI v3.10.1
// 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;
}
}
#endif // DWIN_CREALITY_LCD_JYERSUI

View File

@ -32,3 +32,11 @@
// Color: color
// x/y: Upper-left coordinate of the first pixel
void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y);
// From DWIN Enhanced implementation for PRO UI v3.10.1
// 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);

View File

@ -0,0 +1,340 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 Enhanced implementation for PRO UI
* Author: Miguel A. Risco-Castillo (MRISCOC)
* Version: 3.17.1
* Date: 2022/04/12
*
* Modded for JYERSUI by LCH-77
* Version: 1.9
* Date: Jun 16, 2022
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../../inc/MarlinConfig.h"
#include "dwin_lcd.h"
#include "dwinui.h"
#include "dwin_defines.h"
//#define DEBUG_OUT 1
#include "../../../core/debug_out.h"
xy_int_t DWINUI::cursor = { 0 };
uint16_t DWINUI::pencolor = Color_White;
uint16_t DWINUI::textcolor = Def_Text_Color;
uint16_t DWINUI::backcolor = Def_Background_Color;
uint16_t DWINUI::buttoncolor = Def_Button_Color;
uint8_t DWINUI::font = font8x16;
FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR);
void DWINUI::init() {
delay(750); // Delay for wait to wakeup screen
const bool hs = DWIN_Handshake(); UNUSED(hs);
#if ENABLED(DEBUG_DWIN)
SERIAL_ECHOPGM("DWIN_Handshake ");
SERIAL_ECHOLNF(hs ? F("ok.") : F("error."));
#endif
DWIN_Frame_SetDir(1);
cursor.reset();
pencolor = Color_White;
textcolor = Def_Text_Color;
backcolor = Def_Background_Color;
buttoncolor = Def_Button_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, uint16_t alcolor) {
textcolor = fgcolor;
backcolor = bgcolor;
buttoncolor = alcolor;
}
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 arbitrary x1 and x2 margins
void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) {
const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1;
DWIN_Draw_String(bShow, size, color, bColor, x, y, string);
}
// Draw a char
// color: Character color
// x: abscissa of the display
// y: ordinate of the display
// c: ASCII code of char
void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) {
const char string[2] = { c, 0};
DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1);
}
// Draw a char at cursor position and increment cursor
void DWINUI::Draw_Char(uint16_t color, const char c) {
Draw_Char(color, cursor.x, cursor.y, c);
MoveBy(fontWidth(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 numeric integer value
// bShow: true=display background color; false=don't display background color
// signedMode: 1=signed; 0=unsigned
// size: Font size
// color: Character color
// bColor: Background color
// iNum: Number of digits
// x/y: Upper-left coordinate
// value: Integer value
void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) {
char nstr[10];
sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value);
DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr);
}
// Draw a numeric float value
// bShow: true=display background color; false=don't display background color
// signedMode: 1=signed; 0=unsigned
// size: Font size
// color: Character color
// bColor: Background color
// iNum: Number of digits
// fNum: Number of decimal digits
// x/y: Upper-left coordinate
// value: float value
void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
char nstr[10];
DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr));
}
// ------------------------- Buttons ------------------------------//
void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) {
DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2);
Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption);
}
void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) {
switch (id) {
case BTN_Cancel : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break;
case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break;
case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break;
case BTN_Print : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break;
case BTN_Save : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break;
case BTN_Purge : Draw_Button(GET_TEXT_F(MSG_BUTTON_PURGE), x, y); break;
default: break;
}
}
// -------------------------- Extra -------------------------------//
// 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;
const float 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 (Pro UI)
// 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, maxR = 28, maxG = 38;
const int16_t limv = _MAX(abs(minv), abs(maxv));
float n = minv >= 0 ? (float)(val - minv) / (maxv - minv) : (float)val / limv;
LIMIT(n, -1, 1);
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::ClearMainArea() {
DWIN_Draw_Rectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
}
#endif // DWIN_CREALITY_LCD_JYERSUI

View File

@ -0,0 +1,527 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 Enhanced implementation for PRO UI
* Author: Miguel A. Risco-Castillo (MRISCOC)
* Version: 3.17.1
* Date: 2022/04/12
*
* Modded for JYERSUI by LCH-77
* Version: 1.9
* Date: Jun 16, 2022
*/
#include "dwin_lcd.h"
#include "../common/dwin_set.h"
#include "../common/dwin_font.h"
#include "../common/dwin_color.h"
#include "../common/dwin_api.h"
// Custom icons
//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
// index of every custom icon should be >= CUSTOM_ICON_START
#define CUSTOM_ICON_START ICON_Checkbox_F
#define ICON_Checkbox_F 200
#define ICON_Checkbox_T 201
#define ICON_Fade 202
#define ICON_Mesh 203
#define ICON_Tilt 204
#define ICON_Brightness 205
#define ICON_AxisD 249
#define ICON_AxisBR 250
#define ICON_AxisTR 251
#define ICON_AxisBL 252
#define ICON_AxisTL 253
#define ICON_AxisC 254
#else
#define ICON_Fade ICON_Version
#define ICON_Mesh ICON_Version
#define ICON_Tilt ICON_Version
#define ICON_Brightness ICON_Version
#define ICON_AxisD ICON_Axis
#define ICON_AxisBR ICON_Axis
#define ICON_AxisTR ICON_Axis
#define ICON_AxisBL ICON_Axis
#define ICON_AxisTL ICON_Axis
#define ICON_AxisC ICON_Axis
#define ICON_ESDiag ICON_Info
#define ICON_Lock ICON_Cool
#define ICON_Reboot ICON_ResumeEEPROM
#define ICON_ProbeAlarm ICON_SetEndTemp
#define ICON_ProbeMargin ICON_PrintSize
#define ICON_ProbeSelfTest ICON_SetEndTemp
#define ICON_ProbeSet ICON_SetEndTemp
#define ICON_ProbeDeploy ICON_SetEndTemp
#define ICON_ProbeTest ICON_SetEndTemp
#define ICON_ProbeTestCount ICON_SetEndTemp
#define ICON_ProbeZSpeed ICON_MaxSpeedZ
#define ICON_FWRetLength ICON_StepE
#define ICON_FWRetSpeed ICON_Setspeed
#define ICON_FWRetZRaise ICON_MoveZ
#define ICON_FWRecExtLength ICON_StepE
#define ICON_FWRecSpeed ICON_Setspeed
#define ICON_HSMode ICON_StockConfiguration
#define ICON_Sound ICON_Cool
#define ICON_CaseLight ICON_Motion
#define ICON_LedControl ICON_Motion
#define ICON_MeshActive ICON_HotendTemp
#define ICON_Park ICON_Motion
#endif
// Buttons
#define BTN_Continue 85
#define BTN_Cancel 87
#define BTN_Confirm 89
#define BTN_Print 90
#define BTN_Save 91
#define BTN_Purge 92
// Extended UI Colors
#define Color_Aqua RGB(0,63,31)
#define Color_Light_White 0xBDD7
#define Color_Green RGB(0,63,0)
#define Color_Light_Green 0x3460
#define Color_Cyan 0x07FF
#define Color_Light_Cyan 0x04F3
#define Color_Blue RGB(0,0,31)
#define Color_Light_Blue 0x3A6A
#define Color_Magenta 0xF81F
#define Color_Light_Magenta 0x9813
#define Color_Light_Red 0x8800
#define Color_Orange 0xFA20
#define Color_Light_Orange 0xFBC0
#define Color_Light_Yellow 0x8BE0
#define Color_Brown 0xCC27
#define Color_Light_Brown 0x6204
#define Color_Black 0x0000
#define Color_Grey 0x18E3
#define Check_Color 0x4E5C
#define Confirm_Color 0x34B9
#define Cancel_Color 0x3186
// 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) // only if the default font is font8x16
// Minimum unit (0.1) : multiple (10)
#define UNITFDIGITS 1
#define MINUNITMULT POW(10, UNITFDIGITS)
constexpr uint8_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)
typedef struct { uint16_t left, top, right, bottom; } rect_t;
typedef struct { uint16_t x, y, w, h; } frame_rect_t;
namespace DWINUI {
extern xy_int_t cursor;
extern uint16_t pencolor;
extern uint16_t textcolor;
extern uint16_t backcolor;
extern uint16_t buttoncolor;
extern uint8_t font;
extern FSTR_P const Author;
// 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, uint16_t alcolor);
void SetTextColor(uint16_t fgcolor);
void SetBackgroundColor(uint16_t bgcolor);
// Moves cursor to point
// x: abscissa of the display
// y: ordinate of the display
// point: xy coordinate
void MoveTo(int16_t x, int16_t y);
void MoveTo(xy_int_t point);
// 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);
}
// Extend a frame box
// v: value to extend
inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) {
frame_rect_t t;
t.x = frame.x - v;
t.y = frame.y - v;
t.w = frame.w + 2 * v;
t.h = frame.h + 2 * v;
return t;
}
// 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);
}
inline void DRAW_IconWB(uint8_t libID, uint8_t icon, uint16_t x, uint16_t y) {
DWIN_ICON_Show(true, false, false, libID, icon, x, y);
}
// Draw a numeric integer value
// bShow: true=display background color; false=don't display background color
// signedMode: 1=signed; 0=unsigned
// size: Font size
// color: Character color
// bColor: Background color
// iNum: Number of digits
// x/y: Upper-left coordinate
// value: Integer value
void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value);
// Draw a positive integer
inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value);
}
inline void Draw_Int(uint8_t iNum, long value) {
Draw_Int(false, 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) {
Draw_Int(false, 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) {
Draw_Int(false, 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) {
Draw_Int(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) {
Draw_Int(true, 0, size, color, bColor, iNum, x, y, value);
}
// Draw a signed integer
inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value);
}
inline void Draw_Signed_Int(uint8_t iNum, long value) {
Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
MoveBy(iNum * fontWidth(font), 0);
}
inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value);
}
inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value);
}
inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(true, 1, font, color, bColor, iNum, x, y, value);
}
inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
Draw_Int(true, 1, size, color, bColor, iNum, x, y, value);
}
// Draw a numeric float value
// bShow: true=display background color; false=don't display background color
// signedMode: 1=signed; 0=unsigned
// size: Font size
// color: Character color
// bColor: Background color
// iNum: Number of digits
// fNum: Number of decimal digits
// x/y: Upper-left coordinate
// value: float value
void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
// Draw a positive floating point number
inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
Draw_Float(false, 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) {
Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
}
inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value);
}
inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(true, 0, 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) {
Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value);
}
// Draw a signed floating point number
inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value);
}
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
Draw_Float(false, 1, 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_Float(false, 1, 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_Float(false, 1, 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_Float(true, 1, 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_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value);
}
// Draw a char
// color: Character color
// x: abscissa of the display
// y: ordinate of the display
// c: ASCII code of char
void Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c);
inline void Draw_Char(uint16_t x, uint16_t y, const char c) { Draw_Char(textcolor, x, y, c); };
// Draw a char at cursor position and increment cursor
void Draw_Char(uint16_t color, const char c);
inline void Draw_Char(const char c) { Draw_Char(textcolor, c); }
// 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 x1, uint16_t x2, 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, const char * const string) {
Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, 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);
// ------------------------- Buttons ------------------------------//
void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption);
inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) {
Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption));
}
inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) {
Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption);
}
void Draw_Button(uint8_t id, uint16_t x, uint16_t y);
// -------------------------- 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 by filling the area with background color
// Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1)
void ClearMainArea();
};

View File

@ -0,0 +1,111 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
* Version: 1.0
* Date: 2021/11/06
*
* Modded for JYERSUI by LCH-77
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "dwin_defines.h"
#if HAS_ESDIAG
#include "endstop_diag.h"
#include "dwinui.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, Color_Bg_Window, 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() {
CrealityDWINClass::Clear_Screen(1);
CrealityDWINClass::Draw_Title(F("End-stops Diagnostic"));
DWINUI::ClearMainArea();
DWIN_Draw_Rectangle(0, Color_White, 14, 60, 258, 330);
DWINUI::Draw_Button(BTN_Continue, 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 // HAS_ES_DIAG
#endif // DWIN_CREALITY_LCD_JYERSUI

View File

@ -0,0 +1,39 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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
* Version: 1.0
* Date: 2021/11/06
*
* Modded for JYERSUI by LCH-77
*/
class ESDiagClass {
public:
void Draw();
void Update();
};
extern ESDiagClass ESDiag;

View File

@ -0,0 +1,244 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 G-code thumbnail preview
* Author: Miguel A. Risco-Castillo
* version: 2.1
* Date: 2021/06/19
*
* Modded for JYERSUI by LCH-77
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "dwin_defines.h"
#if HAS_GCODE_PREVIEW
#include "../../../core/types.h"
#include "../../marlinui.h"
#include "../../../sd/cardreader.h"
#include "../../../MarlinCore.h" // for wait_for_user
#include "dwin_lcd.h"
#include "dwinui.h"
#include "dwin.h"
#include "base64.hpp"
#include "gcode_preview.h"
typedef struct {
char name[13] = ""; //8.3 + null
uint32_t thumbstart = 0;
int thumbsize = 0;
int thumbheight = 0;
int thumbwidth = 0;
uint8_t *thumbdata = nullptr;
float time = 0;
float filament = 0;
float layer = 0;
float width = 0;
float height = 0;
float length = 0;
void setname(const char * const fn);
void clear();
} fileprop_t;
fileprop_t fileprop;
void fileprop_t::setname(const char * const fn) {
const uint8_t len = _MIN(sizeof(name) - 1, strlen(fn));
memcpy(&name[0], fn, len);
name[len] = '\0';
}
void fileprop_t::clear() {
fileprop.name[0] = '\0';
fileprop.thumbstart = 0;
fileprop.thumbsize = 0;
fileprop.thumbheight = 0;
fileprop.thumbwidth = 0;
fileprop.thumbdata = nullptr;
fileprop.time = 0;
fileprop.filament = 0;
fileprop.layer = 0;
fileprop.height = 0;
fileprop.width = 0;
fileprop.length = 0;
}
void Get_Value(char *buf, const char * const key, float &value) {
char num[10] = "";
char * posptr = 0;
uint8_t i = 0;
if (!!value) return;
posptr = strstr(buf, key);
if (posptr != nullptr) {
while (i < sizeof(num)) {
char c = posptr[0];
if (!ISEOL(c) && (c != 0)) {
if ((c > 47 && c < 58) || (c == '.')) num[i++] = c;
posptr++;
}
else {
num[i] = '\0';
value = atof(num);
return;
}
}
}
}
bool Has_Preview() {
const char * tbstart = "; thumbnail begin 230x180";
char * posptr = 0;
uint8_t nbyte = 1;
uint32_t indx = 0;
char buf[256];
float tmp = 0;
fileprop.clear();
fileprop.setname(card.filename);
card.openFileRead(fileprop.name);
while ((nbyte > 0) && (indx < 4 * sizeof(buf)) && !fileprop.thumbstart) {
nbyte = card.read(buf, sizeof(buf) - 1);
if (nbyte > 0) {
buf[nbyte] = '\0';
Get_Value(buf, ";TIME:", fileprop.time);
Get_Value(buf, ";Filament used:", fileprop.filament);
Get_Value(buf, ";Layer height:", fileprop.layer);
Get_Value(buf, ";MINX:", tmp);
Get_Value(buf, ";MAXX:", fileprop.width);
fileprop.width -= tmp;
tmp = 0;
Get_Value(buf, ";MINY:", tmp);
Get_Value(buf, ";MAXY:", fileprop.length);
fileprop.length -= tmp;
tmp = 0;
Get_Value(buf, ";MINZ:", tmp);
Get_Value(buf, ";MAXZ:", fileprop.height);
fileprop.height -= tmp;
posptr = strstr(buf, tbstart);
if (posptr != NULL) {
fileprop.thumbstart = indx + (posptr - &buf[0]);
}
else {
indx += _MAX(10, nbyte - (signed)strlen(tbstart));
card.setIndex(indx);
}
}
}
if (!fileprop.thumbstart) {
card.closefile();
LCD_MESSAGE_F("Thumbnail not found");
return 0;
}
// Get the size of the thumbnail
card.setIndex(fileprop.thumbstart + strlen(tbstart));
for (uint8_t i = 0; i < 16; i++) {
char c = card.get();
if (!ISEOL(c)) {
buf[i] = c;
}
else {
buf[i] = '\0';
break;
}
}
fileprop.thumbsize = atoi(buf);
// Exit if there isn't a thumbnail
if (!fileprop.thumbsize) {
card.closefile();
LCD_MESSAGE_F("Invalid Thumbnail Size");
return 0;
}
uint16_t readed = 0;
uint8_t buf64[fileprop.thumbsize];
fileprop.thumbdata = new uint8_t[3 + 3 * (fileprop.thumbsize / 4)]; // Reserve space for the JPEG thumbnail
while (readed < fileprop.thumbsize) {
uint8_t c = card.get();
if (!ISEOL(c) && (c != ';') && (c != ' ')) {
buf64[readed] = c;
readed++;
}
}
card.closefile();
buf64[readed] = 0;
fileprop.thumbsize = decode_base64(buf64, fileprop.thumbdata); card.closefile();
DWINUI::WriteToSRAM(0x00, fileprop.thumbsize, fileprop.thumbdata);
delete[] fileprop.thumbdata;
return true;
}
void Preview_DrawFromSD() {
bool _has_preview = Has_Preview();
CrealityDWIN.Popup_Handler(PrintConfirm, _has_preview);
if (_has_preview) {
char buf[46];
char str_1[6] = "", str_2[6] = "", str_3[6] = "";
// DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1);
if (fileprop.time) {
sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60);
DWINUI::Draw_String(20, 10, buf);
}
if (fileprop.filament) {
sprintf_P(buf, PSTR("Filament used: %s m"), dtostrf(fileprop.filament, 1, 2, str_1));
DWINUI::Draw_String(20, 30, buf);
}
if (fileprop.layer) {
sprintf_P(buf, PSTR("Layer height: %s mm"), dtostrf(fileprop.layer, 1, 2, str_1));
DWINUI::Draw_String(20, 50, buf);
}
if (fileprop.width) {
sprintf_P(buf, PSTR("Volume: %sx%sx%s mm"), dtostrf(fileprop.width, 1, 1, str_1), dtostrf(fileprop.length, 1, 1, str_2), dtostrf(fileprop.height, 1, 1, str_3));
DWINUI::Draw_String(20, 70, buf);
}
// DWINUI::Draw_Button(BTN_Print, 26, 290);
// DWINUI::Draw_Button(BTN_Cancel, 146, 290);
DWIN_ICON_Show(0, 0, 1, 21, 90, 0x00);
// Draw_Select_Highlight(true, 290);
DWIN_UpdateLCD();
}
// else {
// HMI_flag.select_flag = 1;
// wait_for_user = false;
// }
}
bool Preview_Valid() {
return !!fileprop.thumbstart;
}
void Preview_Reset() {
fileprop.thumbsize = 0;
}
#endif // HAS_GCODE_PREVIEW
#endif // DWIN_LCD_PROUI

View File

@ -0,0 +1,34 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 G-code thumbnail preview
* Author: Miguel A. Risco-Castillo
* version: 2.1
* Date: 2021/06/19
*/
#pragma once
void Preview_DrawFromSD();
bool Preview_Valid();
void Preview_Reset();

View File

@ -0,0 +1,83 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 PRO UI
* Author: Miguel A. Risco-Castillo (MRISCOC)
* Version: 2.2.0
* Date: 2022/04/11
*
* Modded for JYERSUI by LCH-77
*/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "dwin_defines.h"
#if HAS_LOCKSCREEN
#include "../common/dwin_color.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() {
CrealityDWINClass::Clear_Screen(1);
CrealityDWINClass::Draw_Title(GET_TEXT_F(MSG_LOCKSCREEN));
DWINUI::ClearMainArea();
DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo
DWINUI::Draw_CenteredString(Color_White, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED));
DWINUI::Draw_CenteredString(Color_White, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK));
DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
DWIN_Draw_Box(1, 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, BarFill_Color, 0, 260, DWIN_WIDTH, 20);
DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
DWIN_UpdateLCD();
}
#endif // HAS_LOCKSCREEN
#endif // DWIN_CREALITY_LCD_JYERSUI

View File

@ -0,0 +1,49 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 PRO UI
* Author: Miguel A. Risco-Castillo (MRISCOC)
* Version: 2.2.0
* Date: 2022/04/11
*
* Modded for JYERSUI by LCH-77
*/
#include "../../../core/types.h"
#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;

View File

@ -0,0 +1,86 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 Single var plot
* Author: Miguel A. Risco-Castillo
* Version: 2.0
* Date: 2022/01/31
*
* Modded for JYERSUI by LCH-77
*/
#include "../../../inc/MarlinConfigPre.h"
#ifdef DWIN_CREALITY_LCD_JYERSUI
#include "dwin_defines.h"
#ifdef HAS_PIDPLOT
#include "plot.h"
#include "../../../core/types.h"
#include "../../marlinui.h"
#include "dwin_lcd.h"
#include "dwinui.h"
#include "dwin.h"
#define Plot_Bg_Color RGB( 1, 12, 8)
PlotClass Plot;
uint16_t grphpoints, r, x2, y2 = 0;
frame_rect_t grphframe = {0};
float scale = 0;
void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) {
grphframe = frame;
grphpoints = 0;
scale = frame.h / max;
x2 = frame.x + frame.w - 1;
y2 = frame.y + frame.h - 1;
r = round((y2) - ref * scale);
DWINUI::Draw_Box(1, Plot_Bg_Color, frame);
for (uint8_t i = 1; i < 4; i++) if (i*50 < frame.w) DWIN_Draw_VLine(Line_Color, i*50 + frame.x, frame.y, frame.h);
DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1));
DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w);
}
void PlotClass::Update(const float value) {
if (!scale) return;
uint16_t y = round((y2) - value * scale);
if (grphpoints < grphframe.w) {
DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y);
}
else {
DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2);
if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2);
DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r);
DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y);
}
grphpoints++;
}
#endif // HAS_PIDPLOT
#endif // DWIN_CREALITY_LCD_JYERSUI

View File

@ -0,0 +1,41 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 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 Single var plot
* Author: Miguel A. Risco-Castillo
* Version: 1.0
* Date: 2022/01/30
*
* Modded for JYERSUI by LCH-77
*/
#include "dwinui.h"
class PlotClass {
public:
void Draw(frame_rect_t frame, float max, float ref = 0);
void Update(float value);
};
extern PlotClass Plot;

View File

@ -152,7 +152,7 @@ uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned ch
output += 4;
}
switch(input_length % 3) {
switch (input_length % 3) {
case 0:
output[0] = '\0';
break;
@ -192,7 +192,7 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch
output += 3;
}
switch(output_length % 3) {
switch (output_length % 3) {
case 1:
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
break;
@ -205,4 +205,4 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch
return output_length;
}
#endif // ifndef
#endif // BASE64_H_INCLUDED

View File

@ -21,7 +21,7 @@
*/
/**
* DWIN g-code thumbnail preview
* DWIN G-code thumbnail preview
* Author: Miguel A. Risco-Castillo
* version: 2.1
* Date: 2021/06/19
@ -214,9 +214,7 @@ bool Has_Preview() {
void Preview_DrawFromSD() {
if (Has_Preview()) {
char buf[46];
char str_1[6] = "";
char str_2[6] = "";
char str_3[6] = "";
char str_1[6] = "", str_2[6] = "", str_3[6] = "";
DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1);
if (fileprop.time) {
sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60);

View File

@ -1,5 +1,5 @@
/**
* DWIN g-code thumbnail preview
* DWIN G-code thumbnail preview
* Author: Miguel A. Risco-Castillo
* version: 2.1
* Date: 2021/06/19

View File

@ -503,7 +503,7 @@ typedef struct SettingsDataStruct {
#if ENABLED(DWIN_LCD_PROUI)
uint8_t dwin_data[eeprom_data_size];
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
uint8_t dwin_settings[CrealityDWIN.eeprom_data_size];
uint8_t dwin_settings[eeprom_data_size];
#endif
//
@ -1525,7 +1525,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
{
_FIELD_TEST(dwin_settings);
char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 };
char dwin_settings[eeprom_data_size] = { 0 };
CrealityDWIN.Save_Settings(dwin_settings);
EEPROM_WRITE(dwin_settings);
}
@ -2497,7 +2497,7 @@ void MarlinSettings::postprocess() {
}
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
{
const char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 };
const char dwin_settings[eeprom_data_size] = { 0 };
_FIELD_TEST(dwin_settings);
EEPROM_READ(dwin_settings);
if (!validating) CrealityDWIN.Load_Settings(dwin_settings);

View File

@ -53,6 +53,8 @@
#include "../lcd/e3v2/creality/dwin.h"
#elif ENABLED(DWIN_LCD_PROUI)
#include "../lcd/e3v2/proui/dwin.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../lcd/e3v2/jyersui/dwin.h"
#endif
#if ENABLED(EXTENSIBLE_UI)
@ -644,12 +646,14 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED));
TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START));
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START));
if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) {
SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH));
TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH)));
return;
}
@ -744,6 +748,7 @@ volatile bool Temperature::raw_temps_ready = false;
SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH));
TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH)));
break;
}
@ -782,6 +787,7 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT));
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT));
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TUNING_TIMEOUT));
TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT)));
SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_PID_TIMEOUT);
@ -839,6 +845,7 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE));
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE));
goto EXIT_M303;
}
@ -857,6 +864,7 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE));
TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE));
EXIT_M303:
TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true);