From 9d5a9621de30e5a2c62727a479a6e73007ced7de Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Thu, 17 Sep 2020 01:06:01 -0700 Subject: [PATCH 01/63] Demo and test multiple PID defaults (#19413) --- Marlin/Configuration.h | 29 ++++++++++---------------- buildroot/tests/BIGTREE_GTR_V1_0-tests | 5 ++++- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 52af1375a509..2635bc750eb0 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -486,24 +486,17 @@ //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] - - // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it - - // Ultimaker - #define DEFAULT_Kp 22.2 - #define DEFAULT_Ki 1.08 - #define DEFAULT_Kd 114 - - // MakerGear - //#define DEFAULT_Kp 7.0 - //#define DEFAULT_Ki 0.1 - //#define DEFAULT_Kd 12 - - // Mendel Parts V9 on 12V - //#define DEFAULT_Kp 63.0 - //#define DEFAULT_Ki 2.25 - //#define DEFAULT_Kd 440 - + #if ENABLED(PID_PARAMS_PER_HOTEND) + // Specify between 1 and HOTENDS values per array. + // If fewer than EXTRUDER values are provided, the last element will be repeated. + #define DEFAULT_Kp_LIST { 22.20, 20.0 } + #define DEFAULT_Ki_LIST { 1.08, 1.0 } + #define DEFAULT_Kd_LIST { 114.00, 112.0 } + #else + #define DEFAULT_Kp 22.20 + #define DEFAULT_Ki 1.08 + #define DEFAULT_Kd 114.00 + #endif #endif // PIDTEMP //=========================================================================== diff --git a/buildroot/tests/BIGTREE_GTR_V1_0-tests b/buildroot/tests/BIGTREE_GTR_V1_0-tests index 58f6f71fda9e..e8d47562aa61 100644 --- a/buildroot/tests/BIGTREE_GTR_V1_0-tests +++ b/buildroot/tests/BIGTREE_GTR_V1_0-tests @@ -36,7 +36,10 @@ opt_set TEMP_SENSOR_3 1 opt_set TEMP_SENSOR_4 1 opt_set TEMP_SENSOR_5 1 opt_set NUM_Z_STEPPER_DRIVERS 3 -opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_INIT_BEFORE_SWAP TOOLCHANGE_FS_PRIME_FIRST_USED +opt_set DEFAULT_Kp_LIST "{ 22.2, 20.0, 21.0, 19.0, 18.0, 17.0 }" +opt_set DEFAULT_Ki_LIST "{ 1.08 }" +opt_set DEFAULT_Kd_LIST "{ 114.0, 112.0, 110.0, 108.0 }" +opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_INIT_BEFORE_SWAP TOOLCHANGE_FS_PRIME_FIRST_USED PID_PARAMS_PER_HOTEND exec_test $1 $2 "BigTreeTech GTR 6 Extruders Triple Z" # clean up From c5204807e9f55da13364901aec94927f7a25d5a2 Mon Sep 17 00:00:00 2001 From: tovam Date: Thu, 17 Sep 2020 10:07:03 +0200 Subject: [PATCH 02/63] Fix missing spaces in info menu (#19404) --- Marlin/src/lcd/menu/menu_info.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_info.cpp b/Marlin/src/lcd/menu/menu_info.cpp index 864e855df23d..a4cbc31d8b6b 100644 --- a/Marlin/src/lcd/menu/menu_info.cpp +++ b/Marlin/src/lcd/menu/menu_info.cpp @@ -179,7 +179,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_BED #include "../thermistornames.h" - STATIC_ITEM_P(PSTR("BED:" THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR("BED: " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(BED_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(BED_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_BED, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -189,7 +189,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_CHAMBER #include "../thermistornames.h" - STATIC_ITEM_P(PSTR("CHAM:" THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_P(PSTR("CHAM: " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(CHAMBER_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(CHAMBER_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_CHAMBER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); From 5926bacea132744abacd31c83a4d6005f9caa495 Mon Sep 17 00:00:00 2001 From: enigmaquip Date: Thu, 17 Sep 2020 02:17:47 -0600 Subject: [PATCH 03/63] Add more DWIN commands, docs (#19395) --- Marlin/src/lcd/dwin/dwin_lcd.cpp | 92 ++++++++++++++++++++++++++++++++ Marlin/src/lcd/dwin/dwin_lcd.h | 21 ++++++++ 2 files changed, 113 insertions(+) diff --git a/Marlin/src/lcd/dwin/dwin_lcd.cpp b/Marlin/src/lcd/dwin/dwin_lcd.cpp index 3b30629a8dae..7d1528bed19b 100644 --- a/Marlin/src/lcd/dwin/dwin_lcd.cpp +++ b/Marlin/src/lcd/dwin/dwin_lcd.cpp @@ -153,6 +153,20 @@ void DWIN_Frame_Clear(const uint16_t color) { DWIN_Send(i); } +// Draw a point +// width: point width 0x01-0x0F +// height: point height 0x01-0x0F +// x,y: upper left point +void DWIN_Draw_Point(uint8_t width, uint8_t height, uint16_t x, uint16_t y) { + size_t i = 0; + DWIN_Byte(i, 0x02); + DWIN_Byte(i, width); + DWIN_Byte(i, height); + DWIN_Word(i, x); + DWIN_Word(i, y); + DWIN_Send(i); +} + // Draw a line // color: Line segment color // xStart/yStart: Start point @@ -221,6 +235,10 @@ void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) { size_t i = 0; DWIN_Byte(i, 0x11); + // Bit 7: widthAdjust + // Bit 6: bShow + // Bit 5-4: Unused (0) + // Bit 3-0: size DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size); DWIN_Word(i, color); DWIN_Word(i, bColor); @@ -244,6 +262,11 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) { size_t i = 0; DWIN_Byte(i, 0x14); + // Bit 7: bshow + // Bit 6: 1 = signed; 0 = unsigned number; + // Bit 5: zeroFill + // Bit 4: zeroMode + // Bit 3-0: size DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); DWIN_Word(i, color); DWIN_Word(i, bColor); @@ -360,4 +383,73 @@ void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, DWIN_Send(i); } +// Animate a series of icons +// animID: Animation ID; 0x00-0x0F +// animate: true on; false off; +// libID: Icon library ID +// picIDs: Icon starting ID +// picIDe: Icon ending ID +// x/y: Upper-left point +// interval: Display time interval, unit 10mS +void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) { + NOMORE(x, DWIN_WIDTH - 1); + NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl + size_t i = 0; + DWIN_Byte(i, 0x28); + DWIN_Word(i, x); + DWIN_Word(i, y); + // Bit 7: animation on or off + // Bit 6: start from begin or end + // Bit 5-4: unused (0) + // Bit 3-0: animID + DWIN_Byte(i, (animate * 0x80) | 0x40 | animID); + DWIN_Byte(i, libID); + DWIN_Byte(i, picIDs); + DWIN_Byte(i, picIDe); + DWIN_Byte(i, interval); + DWIN_Send(i); +} + +// Animation Control +// state: 16 bits, each bit is the state of an animation id +void DWIN_ICON_AnimationControl(uint16_t state) { + size_t i = 0; + DWIN_Byte(i, 0x28); + DWIN_Word(i, state); + DWIN_Send(i); +} + +/*---------------------------------------- Memory functions ----------------------------------------*/ +// The LCD has an additional 32KB SRAM and 16KB Flash + +// Data can be written to the sram and save to one of the jpeg page files + +// Write Data Memory +// command 0x31 +// Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash +// Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash +// Data: data +// +// Flash writing returns 0xA5 0x4F 0x4B + +// Read Data Memory +// command 0x32 +// Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash +// Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash +// Length: leangth of data to read; 0x01-0xF0 +// +// Response: +// Type, Address, Length, Data + +// Write Picture Memory +// Write the contents of the 32KB SRAM data memory into the designated image memory space +// Issued: 0x5A, 0xA5, PIC_ID +// Response: 0xA5 0x4F 0x4B +// +// command 0x33 +// 0x5A, 0xA5 +// PicId: Picture Memory location, 0x00-0x0F +// +// Flash writing returns 0xA5 0x4F 0x4B + #endif // DWIN_CREALITY_LCD diff --git a/Marlin/src/lcd/dwin/dwin_lcd.h b/Marlin/src/lcd/dwin/dwin_lcd.h index 0893974e4c3f..11409666d893 100644 --- a/Marlin/src/lcd/dwin/dwin_lcd.h +++ b/Marlin/src/lcd/dwin/dwin_lcd.h @@ -67,6 +67,12 @@ void DWIN_UpdateLCD(void); // color: Clear screen color void DWIN_Frame_Clear(const uint16_t color); +// Draw a point +// width: point width 0x01-0x0F +// height: point height 0x01-0x0F +// x,y: upper left point +void DWIN_Draw_Point(uint8_t width, uint8_t height, uint16_t x, uint16_t y); + // Draw a line // color: Line segment color // xStart/yStart: Start point @@ -190,3 +196,18 @@ inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); } // 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); + +// Animate a series of icons +// animID: Animation ID up to 16 +// animate: animation on or off +// libID: Icon library ID +// picIDs: Icon starting ID +// picIDe: Icon ending ID +// x/y: Upper-left point +// interval: Display time interval, unit 10mS +void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, + uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval); + +// Animation Control +// state: 16 bits, each bit is the state of an animation id +void DWIN_ICON_AnimationControl(uint16_t state); From 073b7f1e3a77f6d00d58bb144fe3aa96ce3770f3 Mon Sep 17 00:00:00 2001 From: cosmoderp <36945803+cosmoderp@users.noreply.github.com> Date: Thu, 17 Sep 2020 06:35:04 -0400 Subject: [PATCH 04/63] E3 V2 DWIN: Z-Offset, cleanup, versatility (#19384) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 2 +- Marlin/src/inc/Conditionals_adv.h | 2 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 2252 +++++++++-------- Marlin/src/lcd/dwin/e3v2/dwin.h | 136 +- Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp | 2 +- Marlin/src/lcd/dwin/e3v2/rotary_encoder.h | 2 +- Marlin/src/module/temperature.cpp | 26 +- .../PlatformIO/scripts/common-dependencies.h | 4 - platformio.ini | 2 - 9 files changed, 1349 insertions(+), 1079 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2712312747de..d46ba55a922e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1572,6 +1572,7 @@ #if ENABLED(BABYSTEPPING) //#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR //#define BABYSTEP_WITHOUT_HOMING + //#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). //#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA! #define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way //#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps @@ -1582,7 +1583,6 @@ #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) #define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds. // Note: Extra time may be added to mitigate controller latency. - //#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). //#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on doubleclick when printer is idle. #if ENABLED(MOVE_Z_WHEN_IDLE) #define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size. diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 9742967a09d9..ff13d2897df2 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -59,7 +59,7 @@ #if TEMP_SENSOR_BED == 0 #undef THERMAL_PROTECTION_BED #undef THERMAL_PROTECTION_BED_PERIOD -#endif +#endif #if TEMP_SENSOR_CHAMBER == 0 #undef THERMAL_PROTECTION_CHAMBER diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index c94292980506..d45511f5bc84 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -28,15 +28,19 @@ #if ENABLED(DWIN_CREALITY_LCD) +#include "dwin.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_HOTEND || HAS_HEATED_BED || HAS_FAN - #define HAS_COOLDOWN 1 +#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) + #define HAS_ZOFFSET_ITEM 1 #endif -#include "dwin.h" +#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) + #define JUST_BABYSTEP 1 +#endif #include #include @@ -52,8 +56,6 @@ #include "../../../core/macros.h" #include "../../../gcode/queue.h" -#include "../../../feature/babystep.h" - #include "../../../module/temperature.h" #include "../../../module/printcounter.h" #include "../../../module/motion.h" @@ -75,6 +77,10 @@ #include "../../../module/probe.h" #endif +#if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) + #include "../../../feature/babystep.h" +#endif + #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../feature/powerloss.h" #endif @@ -89,7 +95,7 @@ #define CORP_WEBSITE_E "www.creality.com" #endif -#define PAUSE_HEAT true +#define PAUSE_HEAT #define USE_STRING_HEADINGS @@ -98,6 +104,7 @@ #define HEADER_FONT font10x20 #define MENU_CHAR_LIMIT 24 +#define STATUS_Y 360 // Fan speed limit #define FANON 255 @@ -146,11 +153,9 @@ constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other HMI_value_t HMI_ValueStruct; HMI_Flag HMI_flag{0}; -millis_t Encoder_ms = 0; -millis_t Wait_ms = 0; millis_t dwin_heat_time = 0; -int checkkey = 0, last_checkkey = 0; +uint8_t checkkey = 0; typedef struct { uint8_t now, last; @@ -158,7 +163,7 @@ typedef struct { void reset() { set(0); } bool changed() { bool c = (now != last); if (c) last = now; return c; } bool dec() { if (now) now--; return changed(); } - bool inc(uint8_t v) { if (now < v) now++; else now = v; return changed(); } + bool inc(uint8_t v) { if (now < (v - 1)) now++; else now = (v - 1); return changed(); } } select_t; select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0} @@ -175,13 +180,9 @@ uint8_t index_file = MROWS, index_prepare = MROWS, index_control = MROWS, index_leveling = MROWS, - index_tune = 5; - -// char filebuf[50]; - -uint8_t countbuf = 0; + index_tune = MROWS; -bool recovery_flag = false, abort_flag = false; +bool dwin_abort_flag = false; constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; @@ -189,38 +190,41 @@ constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, constexpr float default_axis_steps_per_unit[] = DEFAULT_AXIS_STEPS_PER_UNIT; uint8_t Percentrecord = 0; -uint16_t last_Printtime = 0, remain_time = 0; -float last_temp_hotend_target = 0, last_temp_bed_target = 0; -float last_temp_hotend_current = 0, last_temp_bed_current = 0; -uint8_t last_fan_speed = 0; -uint16_t last_speed = 0; -float last_E_scale = 0; -bool DWIN_lcd_sd_status = 0; -bool pause_action_flag = 0; -int temphot = 0, tempbed = 0; -float dwin_zoffset = 0; -float last_zoffset = 0; +uint16_t remain_time = 0; + +#if ENABLED(PAUSE_HEAT) + #if HAS_HOTEND + uint16_t temphot = 0; + #endif + #if HAS_HEATED_BED + uint16_t tempbed = 0; + #endif +#endif + +#if HAS_ZOFFSET_ITEM + float dwin_zoffset = 0, last_zoffset = 0; +#endif #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 -void HMI_SetLanguage(void) { - BL24CXX::read(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); - if (HMI_flag.language_chinese) - DWIN_JPG_CacheTo1(Language_Chinese); - else - DWIN_JPG_CacheTo1(Language_English); +void HMI_SetLanguageCache() { + DWIN_JPG_CacheTo1(HMI_flag.language_chinese ? Language_Chinese : Language_English); } -void HMI_SetAndSaveLanguageWestern(void) { - HMI_flag.language_chinese = false; - DWIN_JPG_CacheTo1(Language_English); - BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); +void HMI_SetLanguage() { + #if ENABLED(EEPROM_SETTINGS) + BL24CXX::read(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); + #endif + HMI_SetLanguageCache(); } -void HMI_SetAndSaveLanguageChinese(void) { - HMI_flag.language_chinese = true; - DWIN_JPG_CacheTo1(Language_Chinese); - BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); + +void HMI_ToggleLanguage() { + HMI_flag.language_chinese ^= true; + HMI_SetLanguageCache(); + #if ENABLED(EEPROM_SETTINGS) + BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); + #endif } void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) { @@ -331,14 +335,14 @@ void ICON_Tune() { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 121, 447, 148, 458, 34, 325); else - DWIN_Frame_AreaCopy(1, 1, 465, 34, 477, 31, 325); + DWIN_Frame_AreaCopy(1, 0, 466, 34, 476, 31, 325); } else { DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 121, 405, 148, 420, 34, 325); else - DWIN_Frame_AreaCopy(1, 1, 438, 32, 448, 31, 325); + DWIN_Frame_AreaCopy(1, 0, 438, 32, 448, 31, 325); } } @@ -367,7 +371,7 @@ void ICON_Continue() { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 447, 28, 460, 124, 325); else - DWIN_Frame_AreaCopy(1, 1, 451, 32, 463, 121, 325); + DWIN_Frame_AreaCopy(1, 1, 452, 32, 464, 121, 325); } else { DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252); @@ -385,7 +389,7 @@ void ICON_Stop() { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 151, 447, 178, 459, 210, 325); else - DWIN_Frame_AreaCopy(1, 218, 451, 249, 465, 209, 325); + DWIN_Frame_AreaCopy(1, 218, 452, 249, 466, 209, 325); } else { DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252); @@ -396,8 +400,8 @@ void ICON_Stop() { } } -inline void Clear_Title_Bar(void) { - DWIN_Draw_Rectangle(1, Background_blue, 0, 0, DWIN_WIDTH, 30); +inline void Clear_Title_Bar() { + DWIN_Draw_Rectangle(1, Background_blue, 0, 0, DWIN_WIDTH, 30); } inline void Draw_Title(const char * const title) { @@ -408,21 +412,21 @@ inline void Draw_Title(const __FlashStringHelper * title) { DWIN_Draw_String(false, false, HEADER_FONT, White, Background_blue, 14, 4, (char*)title); } -inline void Clear_Menu_Area(void) { - DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, 360); +inline void Clear_Menu_Area() { + DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, STATUS_Y); } -inline void Clear_Main_Window(void) { +inline void Clear_Main_Window() { Clear_Title_Bar(); Clear_Menu_Area(); } -inline void Clear_Popup_Area(void) { +inline void Clear_Popup_Area() { Clear_Title_Bar(); DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); } -void Draw_Popup_Bkgd_105(void) { +void Draw_Popup_Bkgd_105() { DWIN_Draw_Rectangle(1, Background_window, 14, 105, 258, 374); } @@ -476,7 +480,7 @@ inline void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char } // The "Back" label is always on the first line -inline void Draw_Back_Label(void) { +inline void Draw_Back_Label() { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); else @@ -494,13 +498,61 @@ inline void Draw_Back_First(const bool is_sel=true) { // Draw Menus // +#define MOTION_CASE_RATE 1 +#define MOTION_CASE_ACCEL 2 +#define MOTION_CASE_JERK (MOTION_CASE_ACCEL + ENABLED(HAS_CLASSIC_JERK)) +#define MOTION_CASE_STEPS (MOTION_CASE_JERK + 1) +#define MOTION_CASE_TOTAL MOTION_CASE_STEPS + +#define PREPARE_CASE_MOVE 1 +#define PREPARE_CASE_DISA 2 +#define PREPARE_CASE_HOME 3 +#define PREPARE_CASE_ZOFF (PREPARE_CASE_HOME + ENABLED(HAS_ZOFFSET_ITEM)) +#define PREPARE_CASE_PLA (PREPARE_CASE_ZOFF + ENABLED(HAS_HOTEND)) +#define PREPARE_CASE_ABS (PREPARE_CASE_PLA + ENABLED(HAS_HOTEND)) +#define PREPARE_CASE_COOL (PREPARE_CASE_ABS + EITHER(HAS_HOTEND, HAS_HEATED_BED)) +#define PREPARE_CASE_LANG (PREPARE_CASE_COOL + 1) +#define PREPARE_CASE_TOTAL PREPARE_CASE_LANG + +#define CONTROL_CASE_TEMP 1 +#define CONTROL_CASE_MOVE (CONTROL_CASE_TEMP + 1) +#define CONTROL_CASE_SAVE (CONTROL_CASE_MOVE + ENABLED(EEPROM_SETTINGS)) +#define CONTROL_CASE_LOAD (CONTROL_CASE_SAVE + ENABLED(EEPROM_SETTINGS)) +#define CONTROL_CASE_RESET (CONTROL_CASE_LOAD + ENABLED(EEPROM_SETTINGS)) +#define CONTROL_CASE_INFO (CONTROL_CASE_RESET + 1) +#define CONTROL_CASE_TOTAL CONTROL_CASE_INFO + +#define TUNE_CASE_SPEED 1 +#define TUNE_CASE_TEMP (TUNE_CASE_SPEED + ENABLED(HAS_HOTEND)) +#define TUNE_CASE_BED (TUNE_CASE_TEMP + ENABLED(HAS_HEATED_BED)) +#define TUNE_CASE_FAN (TUNE_CASE_BED + ENABLED(HAS_FAN)) +#define TUNE_CASE_ZOFF (TUNE_CASE_FAN + ENABLED(HAS_ZOFFSET_ITEM)) +#define TUNE_CASE_TOTAL TUNE_CASE_ZOFF + +#define TEMP_CASE_TEMP (0 + ENABLED(HAS_HOTEND)) +#define TEMP_CASE_BED (TEMP_CASE_TEMP + ENABLED(HAS_HEATED_BED)) +#define TEMP_CASE_FAN (TEMP_CASE_BED + ENABLED(HAS_FAN)) +#define TEMP_CASE_PLA (TEMP_CASE_FAN + ENABLED(HAS_HOTEND)) +#define TEMP_CASE_ABS (TEMP_CASE_PLA + ENABLED(HAS_HOTEND)) +#define TEMP_CASE_TOTAL TEMP_CASE_ABS + +#define PREHEAT_CASE_TEMP (0 + ENABLED(HAS_HOTEND)) +#define PREHEAT_CASE_BED (PREHEAT_CASE_TEMP + ENABLED(HAS_HEATED_BED)) +#define PREHEAT_CASE_FAN (PREHEAT_CASE_BED + ENABLED(HAS_FAN)) +#define PREHEAT_CASE_SAVE (PREHEAT_CASE_FAN + ENABLED(EEPROM_SETTINGS)) +#define PREHEAT_CASE_TOTAL PREHEAT_CASE_SAVE + +// +// Draw Menus +// + inline void draw_move_en(const uint16_t line) { DWIN_Frame_AreaCopy(1, 69, 61, 102, 71, LBLX, line); // "Move" } inline void DWIN_Frame_TitleCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { DWIN_Frame_AreaCopy(id, x1, y1, x2, y2, 14, 8); } -inline void Prepare_Item_Move(const uint8_t row) { +inline void Item_Prepare_Move(const uint8_t row) { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 159, 70, 200, 84, LBLX, MBASE(row)); else @@ -509,7 +561,7 @@ inline void Prepare_Item_Move(const uint8_t row) { Draw_More_Icon(row); } -inline void Prepare_Item_Disable(const uint8_t row) { +inline void Item_Prepare_Disable(const uint8_t row) { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 204, 70, 259, 82, LBLX, MBASE(row)); else @@ -517,7 +569,7 @@ inline void Prepare_Item_Disable(const uint8_t row) { Draw_Menu_Line(row, ICON_CloseMotor); } -inline void Prepare_Item_Home(const uint8_t row) { +inline void Item_Prepare_Home(const uint8_t row) { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 0, 89, 41, 101, LBLX, MBASE(row)); else @@ -525,57 +577,65 @@ inline void Prepare_Item_Home(const uint8_t row) { Draw_Menu_Line(row, ICON_Homing); } -inline void Prepare_Item_Offset(const uint8_t row) { - if (HMI_flag.language_chinese) { - #if HAS_BED_PROBE - DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(row)); - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); - #else - DWIN_Frame_AreaCopy(1, 43, 89, 98, 101, LBLX, MBASE(row)); - #endif - } - else { - #if HAS_BED_PROBE - DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset" - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); - #else - DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "..." - #endif - } - Draw_Menu_Line(row, ICON_SetHome); -} +#if HAS_ZOFFSET_ITEM -inline void Prepare_Item_PLA(const uint8_t row) { - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 100, 89, 151, 101, LBLX, MBASE(row)); - } - else { - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(row)); // "PLA" + inline void Item_Prepare_Offset(const uint8_t row) { + if (HMI_flag.language_chinese) { + #if HAS_BED_PROBE + DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(row)); + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); + #else + DWIN_Frame_AreaCopy(1, 43, 89, 98, 101, LBLX, MBASE(row)); + #endif + } + else { + #if HAS_BED_PROBE + DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset" + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); + #else + DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "..." + #endif + } + Draw_Menu_Line(row, ICON_SetHome); } - Draw_Menu_Line(row, ICON_PLAPreheat); -} -inline void Prepare_Item_ABS(const uint8_t row) { - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 180, 89, 233, 100, LBLX, MBASE(row)); +#endif + +#if HAS_HOTEND + inline void Item_Prepare_PLA(const uint8_t row) { + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 100, 89, 151, 101, LBLX, MBASE(row)); + } + else { + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(row)); // "PLA" + } + Draw_Menu_Line(row, ICON_PLAPreheat); } - else { - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(row)); // "ABS" + + inline void Item_Prepare_ABS(const uint8_t row) { + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 180, 89, 233, 100, LBLX, MBASE(row)); + } + else { + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(row)); // "ABS" + } + Draw_Menu_Line(row, ICON_ABSPreheat); } - Draw_Menu_Line(row, ICON_ABSPreheat); -} +#endif -inline void Prepare_Item_Cool(const uint8_t row) { - if (HMI_flag.language_chinese) - DWIN_Frame_AreaCopy(1, 1, 104, 56, 117, LBLX, MBASE(row)); - else - DWIN_Frame_AreaCopy(1, 200, 76, 264, 86, LBLX, MBASE(row)); // "Cooldown" - Draw_Menu_Line(row, ICON_Cool); -} +#if HAS_PREHEAT + inline void Item_Prepare_Cool(const uint8_t row) { + if (HMI_flag.language_chinese) + DWIN_Frame_AreaCopy(1, 1, 104, 56, 117, LBLX, MBASE(row)); + else + DWIN_Frame_AreaCopy(1, 200, 76, 264, 86, LBLX, MBASE(row)); // "Cooldown" + Draw_Menu_Line(row, ICON_Cool); + } +#endif -inline void Prepare_Item_Lang(const uint8_t row) { +inline void Item_Prepare_Lang(const uint8_t row) { if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 239, 134, 266, 146, LBLX, MBASE(row)); DWIN_Draw_String(false, false, font8x16, White, Background_black, 226, MBASE(row), F("CN")); @@ -605,15 +665,21 @@ inline void Draw_Prepare_Menu() { #endif } - if (PVISI(0)) Draw_Back_First(select_prepare.now == 0); // < Back - if (PVISI(1)) Prepare_Item_Move(PSCROL(1)); // Move > - if (PVISI(2)) Prepare_Item_Disable(PSCROL(2)); // Disable Stepper - if (PVISI(3)) Prepare_Item_Home(PSCROL(3)); // Auto Home - if (PVISI(4)) Prepare_Item_Offset(PSCROL(4)); // Z-Offset - if (PVISI(5)) Prepare_Item_PLA(PSCROL(5)); // Preheat PLA - if (PVISI(6)) Prepare_Item_ABS(PSCROL(6)); // Preheat ABS - if (PVISI(7)) Prepare_Item_Cool(PSCROL(7)); // Cooldown - if (PVISI(8)) Prepare_Item_Lang(PSCROL(8)); // Language CN/EN + if (PVISI(0)) Draw_Back_First(select_prepare.now == 0); // < Back + if (PVISI(PREPARE_CASE_MOVE)) Item_Prepare_Move(PSCROL(PREPARE_CASE_MOVE)); // Move > + if (PVISI(PREPARE_CASE_DISA)) Item_Prepare_Disable(PSCROL(PREPARE_CASE_DISA)); // Disable Stepper + if (PVISI(PREPARE_CASE_HOME)) Item_Prepare_Home(PSCROL(PREPARE_CASE_HOME)); // Auto Home + #if HAS_ZOFFSET_ITEM + if (PVISI(PREPARE_CASE_ZOFF)) Item_Prepare_Offset(PSCROL(PREPARE_CASE_ZOFF)); // Edit Z-Offset / Babystep / Set Home Offset + #endif + #if HAS_HOTEND + if (PVISI(PREPARE_CASE_PLA)) Item_Prepare_PLA(PSCROL(PREPARE_CASE_PLA)); // Preheat PLA + if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS)); // Preheat ABS + #endif + #if HAS_PREHEAT + if (PVISI(PREPARE_CASE_COOL)) Item_Prepare_Cool(PSCROL(PREPARE_CASE_COOL)); // Cooldown + #endif + if (PVISI(PREPARE_CASE_LANG)) Item_Prepare_Lang(PSCROL(PREPARE_CASE_LANG)); // Language CN/EN if (select_prepare.now) Draw_Menu_Cursor(PSCROL(select_prepare.now)); } @@ -621,52 +687,55 @@ inline void Draw_Prepare_Menu() { inline void Draw_Control_Menu() { Clear_Main_Window(); - const int16_t scroll = TERN(HAS_ONESTEP_LEVELING, MROWS - index_control, 0); // Scrolled-up lines - - #define CSCROL(L) (scroll + (L)) + #if CONTROL_CASE_TOTAL >= 6 + const int16_t scroll = MROWS - index_control; // Scrolled-up lines + #define CSCROL(L) (scroll + (L)) + #else + #define CSCROL(L) (L) + #endif #define CLINE(L) MBASE(CSCROL(L)) #define CVISI(L) WITHIN(CSCROL(L), 0, MROWS) if (CVISI(0)) Draw_Back_First(select_control.now == 0); // < Back if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 103, 1, 130, 14, 14, 8); - DWIN_Frame_AreaCopy(1, 57, 104, 84, 116, LBLX, CLINE(1)); // Temperature > - DWIN_Frame_AreaCopy(1, 87, 104, 114, 116, LBLX, CLINE(2)); // Motion > - DWIN_Frame_AreaCopy(1, 117, 104, 172, 116, LBLX, CLINE(3)); // Store Config - DWIN_Frame_AreaCopy(1, 174, 103, 229, 116, LBLX, CLINE(4)); // Read Config - DWIN_Frame_AreaCopy(1, 1, 118, 56, 131, LBLX, CLINE(5)); // Reset Config + DWIN_Frame_TitleCopy(1, 103, 1, 130, 14); // "Control" + + DWIN_Frame_AreaCopy(1, 57, 104, 84, 116, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature > + DWIN_Frame_AreaCopy(1, 87, 104, 114, 116, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion > + + #if ENABLED(EEPROM_SETTINGS) + DWIN_Frame_AreaCopy(1, 117, 104, 172, 116, LBLX, CLINE(CONTROL_CASE_SAVE)); // Store Configuration + DWIN_Frame_AreaCopy(1, 174, 103, 229, 116, LBLX, CLINE(CONTROL_CASE_LOAD)); // Read Configuration + DWIN_Frame_AreaCopy(1, 1, 118, 56, 131, LBLX, CLINE(CONTROL_CASE_RESET)); // Reset Configuration + #endif - if (CVISI(6)) - DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, CLINE(6)); // Info > + if (CVISI(CONTROL_CASE_INFO)) + DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, CLINE(CONTROL_CASE_TEMP)); // Info > } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_CONTROL)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), GET_TEXT_F(MSG_TEMPERATURE)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), GET_TEXT_F(MSG_MOTION)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION)); #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_STORE_EEPROM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_LOAD_EEPROM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(5), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); - if (CVISI(6)) DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(6), F("Info")); - #else - if (CVISI(3)) DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), F("Info")); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); #endif + if (CVISI(CONTROL_CASE_INFO)) DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_INFO), F("Info")); #else - DWIN_Frame_AreaCopy(1, 128, 2, 176, 12, 14, 8); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(1)); // Temperature > - DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(2)); // Motion > + DWIN_Frame_TitleCopy(1, 128, 2, 176, 12); // "Control" + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature > + DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion > #if ENABLED(EEPROM_SETTINGS) - DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX, CLINE(3)); // "Store Configuration" - DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX, CLINE(4)); // "Read" - DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(4)); // "Configuration" - DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX, CLINE(5)); // "Reset" - DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, CLINE(5)); // "Configuration" - if (CVISI(6)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(6)); // Info > - #else - if (CVISI(3)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(3)); // Info > + DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX , CLINE(CONTROL_CASE_SAVE // "Store Configuration" + DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX , CLINE(CONTROL_CASE_LOAD)); // "Read" + DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(CONTROL_CASE_LOAD)); // "Configuration" + DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX , CLINE(CONTROL_CASE_RESET)); // "Reset" + DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, CLINE(CONTROL_CASE_RESET)); // "Configuration" #endif + if (CVISI(CONTROL_CASE_INFO)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(CONTROL_CASE_INFO)); // Info > #endif } @@ -674,12 +743,23 @@ inline void Draw_Control_Menu() { Draw_Menu_Cursor(CSCROL(select_control.now)); // Draw icons and lines - LOOP_L_N(i, 6) - if (CVISI(i + 1)) Draw_Menu_Line(CSCROL(i + 1), ICON_Temperature + i); + uint8_t i = 0; + #define _TEMP_ICON(N) do{ ++i; if (CVISI(i)) Draw_Menu_Line(CSCROL(i), ICON_SetEndTemp + (N) - 1); }while(0) + + _TEMP_ICON(CONTROL_CASE_TEMP); + if (CVISI(i)) Draw_More_Icon(CSCROL(i)); + + _TEMP_ICON(CONTROL_CASE_MOVE); + Draw_More_Icon(CSCROL(i)); - Draw_More_Icon(CSCROL(1)); - Draw_More_Icon(CSCROL(2)); - if (CVISI(6)) Draw_More_Icon(CSCROL(6)); + #if ENABLED(EEPROM_SETTINGS) + _TEMP_ICON(CONTROL_CASE_SAVE); + _TEMP_ICON(CONTROL_CASE_LOAD); + _TEMP_ICON(CONTROL_CASE_RESET); + #endif + + _TEMP_ICON(CONTROL_CASE_INFO); + if (CVISI(CONTROL_CASE_INFO)) Draw_More_Icon(CSCROL(i)); } inline void Draw_Tune_Menu() { @@ -687,46 +767,76 @@ inline void Draw_Tune_Menu() { if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 73, 2, 100, 13, 14, 9); - DWIN_Frame_AreaCopy(1, 116, 164, 171, 176, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(2)); - DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(5)); + DWIN_Frame_AreaCopy(1, 116, 164, 171, 176, LBLX, MBASE(TUNE_CASE_SPEED)); + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(TUNE_CASE_TEMP)); + #endif + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(TUNE_CASE_BED)); + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(TUNE_CASE_FAN)); + #endif + #if HAS_ZOFFSET_ITEM + DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(TUNE_CASE_ZOFF)); + #endif } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TUNE)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), GET_TEXT_F(MSG_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_FAN_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(5), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_SPEED), GET_TEXT_F(MSG_SPEED)); + #if HAS_HOTEND + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + #endif + #if HAS_HEATED_BED + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + #endif + #if HAS_FAN + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + #endif + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_ZOFF), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); #else DWIN_Frame_AreaCopy(1, 94, 2, 126, 12, 14, 9); - DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(1)); // print speed - DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(2)); // Hotend... - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(2)); // ...Temperature - DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(3)); // Bed... - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(3)); // ...Temperature - DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(4)); // fan speed - DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(5)); // Z-offset + DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(TUNE_CASE_SPEED)); // Print speed + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TUNE_CASE_TEMP)); // Hotend... + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(TUNE_CASE_TEMP)); // ...Temperature + #endif + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(TUNE_CASE_BED)); // Bed... + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(TUNE_CASE_BED)); // ...Temperature + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(TUNE_CASE_FAN)); // Fan speed + #endif + #if HAS_ZOFFSET_ITEM + DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(TUNE_CASE_ZOFF)); // Z-offset + #endif #endif } Draw_Back_First(select_tune.now == 0); if (select_tune.now) Draw_Menu_Cursor(select_tune.now); - Draw_Menu_Line(1, ICON_Speed); - Draw_Menu_Line(2, ICON_HotendTemp); - Draw_Menu_Line(3, ICON_BedTemp); - Draw_Menu_Line(4, ICON_FanSpeed); - Draw_Menu_Line(5, ICON_Zoffset); + Draw_Menu_Line(TUNE_CASE_SPEED, ICON_Speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_SPEED), feedrate_percentage); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), feedrate_percentage); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_hotend[0].target); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.temp_bed.target); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4), thermalManager.fan_speed[0]); - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(5), BABY_Z_VAR * 100); + #if HAS_HOTEND + Draw_Menu_Line(TUNE_CASE_TEMP, ICON_HotendTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.temp_hotend[0].target); + #endif + #if HAS_HEATED_BED + Draw_Menu_Line(TUNE_CASE_BED, ICON_BedTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.temp_bed.target); + #endif + #if HAS_FAN + Draw_Menu_Line(TUNE_CASE_FAN, ICON_FanSpeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_FAN), thermalManager.fan_speed[0]); + #endif + #if HAS_ZOFFSET_ITEM + Draw_Menu_Line(TUNE_CASE_ZOFF, ICON_Zoffset); + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(TUNE_CASE_ZOFF), BABY_Z_VAR * 100); + #endif } inline void draw_max_en(const uint16_t line) { @@ -762,74 +872,84 @@ inline void Draw_Motion_Menu() { Clear_Main_Window(); if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 1, 16, 28, 28, 14, 8); - - DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, MBASE(1)); // Max speed - DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(2)); // Max... - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(2) + 1); // ...acceleration - DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(3)); // Max... - DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(3) + 1); // ... - DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(3)); // ...jerk - DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(4)); // Flow ratio + DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Motion" + DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, MBASE(MOTION_CASE_RATE)); // Max speed + DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(MOTION_CASE_ACCEL)); // Max... + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(MOTION_CASE_ACCEL) + 1); // ...Acceleration + #if HAS_CLASSIC_JERK + DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(MOTION_CASE_JERK)); // Max... + DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(MOTION_CASE_JERK) + 1); // ... + DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(MOTION_CASE_JERK)); // ...Jerk + #endif + DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(MOTION_CASE_STEPS)); // Flow ratio } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_MOTION)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Feedrate")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), GET_TEXT_F(MSG_ACCELERATION)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_JERK)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_STEPS_PER_MM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_RATE), F("Feedrate")); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_ACCEL), GET_TEXT_F(MSG_ACCELERATION)); + #if HAS_CLASSIC_JERK + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_JERK), GET_TEXT_F(MSG_JERK)); + #endif + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_STEPS), GET_TEXT_F(MSG_STEPS_PER_MM)); #else - DWIN_Frame_AreaCopy(1, 144, 16, 189, 26, 14, 8); - draw_max_en(MBASE(1)); draw_speed_en(27, MBASE(1)); // "Max Speed" - draw_max_accel_en(MBASE(2)); // "Max Acceleration" - draw_max_en(MBASE(3)); draw_jerk_en(MBASE(3)); // "Max Jerk" - draw_steps_per_mm(MBASE(4)); // "Steps-per-mm" + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Motion" + draw_max_en(MBASE(MOTION_CASE_RATE)); draw_speed_en(27, MBASE(MOTION_CASE_RATE)); // "Max Speed" + draw_max_accel_en(MBASE(MOTION_CASE_ACCEL)); // "Max Acceleration" + #if HAS_CLASSIC_JERK + draw_max_en(MBASE(MOTION_CASE_JERK)); draw_jerk_en(MBASE(MOTION_CASE_JERK)); // "Max Jerk" + #endif + draw_steps_per_mm(MBASE(MOTION_CASE_STEPS)); // "Steps-per-mm" #endif } Draw_Back_First(select_motion.now == 0); if (select_motion.now) Draw_Menu_Cursor(select_motion.now); - LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxSpeed + i); - - Draw_More_Icon(1); - Draw_More_Icon(2); - Draw_More_Icon(3); - Draw_More_Icon(4); + uint8_t i = 0; + #define _MOTION_ICON(N) Draw_Menu_Line(++i, ICON_MaxSpeed + (N) - 1) + _MOTION_ICON(MOTION_CASE_RATE); Draw_More_Icon(i); + _MOTION_ICON(MOTION_CASE_ACCEL); Draw_More_Icon(i); + #if HAS_CLASSIC_JERK + _MOTION_ICON(MOTION_CASE_JERK); Draw_More_Icon(i); + #endif + _MOTION_ICON(MOTION_CASE_STEPS); Draw_More_Icon(i); } // // Draw Popup Windows // - -void Popup_Window_Temperature(const bool toohigh) { - Clear_Popup_Area(); - Draw_Popup_Bkgd_105(); - if (toohigh) { - DWIN_ICON_Show(ICON, ICON_TempTooHigh, 102, 165); - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285); - DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); - DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); - } - else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too high")); - } - } - else { - DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 165); - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 103, 371, 270, 386, 52, 285); - DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); +#if HAS_HOTEND || HAS_HEATED_BED + + void DWIN_Popup_Temperature(const bool toohigh) { + Clear_Popup_Area(); + Draw_Popup_Bkgd_105(); + if (toohigh) { + DWIN_ICON_Show(ICON, ICON_TempTooHigh, 102, 165); + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285); + DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); + DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); + } + else { + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too high")); + } } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too low")); + DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 165); + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 103, 371, 270, 386, 52, 285); + DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); + } + else { + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too low")); + } } } -} + +#endif inline void Draw_Popup_Bkgd_60() { DWIN_Draw_Rectangle(1, Background_window, 14, 60, 258, 330); @@ -837,7 +957,7 @@ inline void Draw_Popup_Bkgd_60() { #if HAS_HOTEND - void Popup_Window_ETempTooLow(void) { + void Popup_Window_ETempTooLow() { Clear_Main_Window(); Draw_Popup_Bkgd_60(); DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 105); @@ -854,7 +974,7 @@ inline void Draw_Popup_Bkgd_60() { #endif -void Popup_Window_Resume(void) { +void Popup_Window_Resume() { Clear_Popup_Area(); Draw_Popup_Bkgd_105(); if (HMI_flag.language_chinese) { @@ -864,15 +984,15 @@ void Popup_Window_Resume(void) { DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 307); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 120, 115, F("Tips")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 192, F("I see the file stopped")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 68, 212, F("unexpectedly last time")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 14) / 2, 115, F("Continue Print")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 22) / 2, 192, F("It looks like the last")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 22) / 2, 212, F("file was interrupted.")); DWIN_ICON_Show(ICON, ICON_Continue_E, 26, 307); DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 307); } } -void Popup_Window_Home(void) { +void Popup_Window_Home(const bool parking/*=false*/) { Clear_Main_Window(); Draw_Popup_Bkgd_60(); DWIN_ICON_Show(ICON, ICON_BLTouch, 101, 105); @@ -882,24 +1002,28 @@ void Popup_Window_Home(void) { DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 80, 230, GET_TEXT_F(MSG_LEVEL_BED_HOMING)); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 260, F("Please wait until completed")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * (parking ? 7 : 10)) / 2, 230, parking ? F("Parking") : F("Homing XYZ")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); } } -void Popup_Window_Leveling(void) { - Clear_Main_Window(); - Draw_Popup_Bkgd_60(); - DWIN_ICON_Show(ICON, ICON_AutoLeveling, 101, 105); - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 0, 371, 100, 386, 84, 240); - DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); - } - else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 76, 230, GET_TEXT_F(MSG_BED_LEVELING)); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 260, F("Please wait until completed")); +#if HAS_ONESTEP_LEVELING + + void Popup_Window_Leveling() { + Clear_Main_Window(); + Draw_Popup_Bkgd_60(); + DWIN_ICON_Show(ICON, ICON_AutoLeveling, 101, 105); + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 0, 371, 100, 386, 84, 240); + DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); + } + else { + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 13) / 2, 230, GET_TEXT_F(MSG_BED_LEVELING)); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); + } } -} + +#endif void Draw_Select_Highlight(const bool sel) { HMI_flag.select_flag = sel; @@ -911,34 +1035,34 @@ void Draw_Select_Highlight(const bool sel) { DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319); } -void Popup_window_PauseOrStop(void) { +void Popup_window_PauseOrStop() { Clear_Main_Window(); Draw_Popup_Bkgd_60(); if (HMI_flag.language_chinese) { - if (select_print.now == 1) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); + if (select_print.now == 1) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); else if (select_print.now == 2) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); DWIN_ICON_Show(ICON, ICON_Confirm_C, 26, 280); DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 280); } else { - if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 88, 150, GET_TEXT_F(MSG_PAUSE_PRINT)); - else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 150, GET_TEXT_F(MSG_STOP_PRINT)); + if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 11) / 2, 150, GET_TEXT_F(MSG_PAUSE_PRINT)); + else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 10) / 2, 150, GET_TEXT_F(MSG_STOP_PRINT)); DWIN_ICON_Show(ICON, ICON_Confirm_E, 26, 280); DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 280); } Draw_Select_Highlight(true); } -void Draw_Printing_Screen(void) { +void Draw_Printing_Screen() { if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 30, 1, 71, 14, 14, 9); // Tune - DWIN_Frame_AreaCopy(1, 0, 72, 63, 86, 41, 188); // Pause + DWIN_Frame_AreaCopy(1, 30, 1, 71, 14, 14, 9); // Tune + DWIN_Frame_AreaCopy(1, 0, 72, 63, 86, 41, 188); // Pause DWIN_Frame_AreaCopy(1, 65, 72, 128, 86, 176, 188); // Stop } else { - DWIN_Frame_AreaCopy(1, 40, 2, 92, 14, 14, 9); // Tune - DWIN_Frame_AreaCopy(1, 0, 44, 96, 58, 41, 188); // Pause + DWIN_Frame_AreaCopy(1, 40, 2, 92, 14, 14, 9); // Tune + DWIN_Frame_AreaCopy(1, 0, 44, 96, 58, 41, 188); // Pause DWIN_Frame_AreaCopy(1, 98, 44, 152, 58, 176, 188); // Stop } } @@ -963,7 +1087,7 @@ void Draw_Print_ProgressRemain() { DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 200, 212, (remain_time % 3600) / 60); } -void Goto_PrintProcess(void) { +void Goto_PrintProcess() { checkkey = PrintProcess; Clear_Main_Window(); @@ -986,7 +1110,7 @@ void Goto_PrintProcess(void) { Draw_Print_ProgressRemain(); } -void Goto_MainMenu(void) { +void Goto_MainMenu() { checkkey = MainMenu; Clear_Main_Window(); @@ -1011,6 +1135,7 @@ void Goto_MainMenu(void) { } inline ENCODER_DiffState get_encoder_state() { + static millis_t Encoder_ms = 0; const millis_t ms = millis(); if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; const ENCODER_DiffState state = Encoder_ReceiveAnalyze(); @@ -1018,7 +1143,7 @@ inline ENCODER_DiffState get_encoder_state() { return state; } -void HMI_Move_X(void) { +void HMI_Move_X() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1029,7 +1154,7 @@ void HMI_Move_X(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); if (!planner.is_full()) { // Wait for planner moves to finish! @@ -1047,7 +1172,7 @@ void HMI_Move_X(void) { } } -void HMI_Move_Y(void) { +void HMI_Move_Y() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1058,7 +1183,7 @@ void HMI_Move_Y(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); if (!planner.is_full()) { // Wait for planner moves to finish! @@ -1076,7 +1201,7 @@ void HMI_Move_Y(void) { } } -void HMI_Move_Z(void) { +void HMI_Move_Z() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1087,7 +1212,7 @@ void HMI_Move_Z(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); if (!planner.is_full()) { // Wait for planner moves to finish! @@ -1107,7 +1232,8 @@ void HMI_Move_Z(void) { #if HAS_HOTEND - void HMI_Move_E(void) { + void HMI_Move_E() { + static float last_E_scale = 0; ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1118,7 +1244,7 @@ void HMI_Move_Z(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; last_E_scale = HMI_ValueStruct.Move_E_scale; DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); if (!planner.is_full()) { @@ -1140,53 +1266,66 @@ void HMI_Move_Z(void) { #endif -void HMI_Zoffset(void) { - ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - last_zoffset = dwin_zoffset; - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - EncoderRate.encoderRateEnabled = 0; - dwin_zoffset = HMI_ValueStruct.offset_value / 100; - #if HAS_BED_PROBE - if (WITHIN(dwin_zoffset - last_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) - probe.offset.z = dwin_zoffset; - TERN_(EEPROM_SETTINGS, settings.save()); - #elif ENABLED(BABYSTEPPING) - babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset); - #endif +#if HAS_ZOFFSET_ITEM - if (HMI_ValueStruct.show_mode == -4) { - checkkey = Prepare; - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(4 + MROWS - index_prepare), TERN(HAS_BED_PROBE, probe.offset.z * 100, HMI_ValueStruct.offset_value)); + bool printer_busy() { return planner.movesplanned() || printingIsActive(); } + + void HMI_Zoffset() { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + uint8_t zoff_line; + switch (HMI_ValueStruct.show_mode) { + case -4: zoff_line = PREPARE_CASE_ZOFF + MROWS - index_prepare; break; + default: zoff_line = TUNE_CASE_ZOFF + MROWS - index_tune; } - else { - checkkey = Tune; - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(5 + MROWS - index_tune), TERN(HAS_BED_PROBE, probe.offset.z * 100, HMI_ValueStruct.offset_value)); + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + EncoderRate.enabled = false; + #if HAS_BED_PROBE + probe.offset.z = dwin_zoffset; + TERN_(EEPROM_SETTINGS, settings.save()); + #endif + if (HMI_ValueStruct.show_mode == -4) { + checkkey = Prepare; + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value)); + } + else { + checkkey = Tune; + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value)); + } + DWIN_UpdateLCD(); + return; } + NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100); + NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100); + last_zoffset = dwin_zoffset; + dwin_zoffset = HMI_ValueStruct.offset_value / 100.0f; + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) + if ( (ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_known()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()) ) + babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset); + #endif + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(zoff_line), HMI_ValueStruct.offset_value); DWIN_UpdateLCD(); - return; } - NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100); - NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100); - if (HMI_ValueStruct.show_mode == -4) - DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value); - else - DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value); - DWIN_UpdateLCD(); } -} + +#endif // HAS_ZOFFSET_ITEM #if HAS_HOTEND - void HMI_ETemp(void) { + void HMI_ETemp() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { + uint8_t temp_line; + switch (HMI_ValueStruct.show_mode) { + case -1: temp_line = TEMP_CASE_TEMP; break; + case -2: temp_line = PREHEAT_CASE_TEMP; break; + case -3: temp_line = PREHEAT_CASE_TEMP; break; + default: temp_line = TUNE_CASE_TEMP + MROWS - index_tune; + } if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.E_Temp += EncoderRate.encoderMoveValue; } @@ -1194,26 +1333,26 @@ void HMI_Zoffset(void) { HMI_ValueStruct.E_Temp -= EncoderRate.encoderMoveValue; } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { // temperature checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_Temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[0].hotend_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), ui.material_preset[0].hotend_temp); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_Temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[1].hotend_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), ui.material_preset[1].hotend_temp); return; } else { // tune checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2 + MROWS - index_tune), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } thermalManager.setTargetHotend(HMI_ValueStruct.E_Temp, 0); return; @@ -1222,10 +1361,7 @@ void HMI_Zoffset(void) { NOMORE(HMI_ValueStruct.E_Temp, MAX_E_TEMP); NOLESS(HMI_ValueStruct.E_Temp, MIN_E_TEMP); // E_Temp value - if (HMI_ValueStruct.show_mode >= 0) // tune - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2 + MROWS - index_tune), HMI_ValueStruct.E_Temp); - else // other page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } } @@ -1233,9 +1369,16 @@ void HMI_Zoffset(void) { #if HAS_HEATED_BED - void HMI_BedTemp(void) { + void HMI_BedTemp() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { + uint8_t bed_line; + switch (HMI_ValueStruct.show_mode) { + case -1: bed_line = TEMP_CASE_BED; break; + case -2: bed_line = PREHEAT_CASE_BED; break; + case -3: bed_line = PREHEAT_CASE_BED; break; + default: bed_line = TUNE_CASE_BED + MROWS - index_tune; + } if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Bed_Temp += EncoderRate.encoderMoveValue; } @@ -1243,26 +1386,26 @@ void HMI_Zoffset(void) { HMI_ValueStruct.Bed_Temp -= EncoderRate.encoderMoveValue; } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_Temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[0].bed_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), ui.material_preset[0].bed_temp); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].bed_temp = HMI_ValueStruct.Bed_Temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[1].bed_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), ui.material_preset[1].bed_temp); return; } else { checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3 + MROWS - index_tune), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } thermalManager.setTargetBed(HMI_ValueStruct.Bed_Temp); return; @@ -1271,20 +1414,25 @@ void HMI_Zoffset(void) { NOMORE(HMI_ValueStruct.Bed_Temp, BED_MAX_TARGET); NOLESS(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP); // Bed_Temp value - if (HMI_ValueStruct.show_mode >= 0) // tune page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3 + MROWS - index_tune), HMI_ValueStruct.Bed_Temp); - else // other page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } } #endif // HAS_HEATED_BED -#if HAS_FAN +#if HAS_PREHEAT - void HMI_FanSpeed(void) { + void HMI_FanSpeed() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { + uint8_t fan_line; + switch (HMI_ValueStruct.show_mode) { + case -1: fan_line = TEMP_CASE_FAN; break; + case -2: fan_line = PREHEAT_CASE_FAN; break; + case -3: fan_line = PREHEAT_CASE_FAN; break; + default: fan_line = TUNE_CASE_FAN + MROWS - index_tune; + } + if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Fan_speed += EncoderRate.encoderMoveValue; } @@ -1292,26 +1440,26 @@ void HMI_Zoffset(void) { HMI_ValueStruct.Fan_speed -= EncoderRate.encoderMoveValue; } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].fan_speed = HMI_ValueStruct.Fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[0].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), ui.material_preset[0].fan_speed); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[1].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), ui.material_preset[1].fan_speed); return; } else { checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4 + MROWS - index_tune), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed); return; @@ -1320,16 +1468,13 @@ void HMI_Zoffset(void) { NOMORE(HMI_ValueStruct.Fan_speed, FANON); NOLESS(HMI_ValueStruct.Fan_speed, FANOFF); // Fan_speed value - if (HMI_ValueStruct.show_mode >= 0) // tune page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(4 + MROWS - index_tune), HMI_ValueStruct.Fan_speed); - else // other page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } } -#endif // HAS_FAN +#endif // HAS_PREHEAT -void HMI_PrintSpeed(void) { +void HMI_PrintSpeed() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1340,20 +1485,20 @@ void HMI_PrintSpeed(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return checkkey = Tune; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; feedrate_percentage = HMI_ValueStruct.print_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1 + MROWS - index_tune), HMI_ValueStruct.print_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); return; } // print_speed limit NOMORE(HMI_ValueStruct.print_speed, MAX_PRINT_SPEED); NOLESS(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED); // print_speed value - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1 + MROWS - index_tune), HMI_ValueStruct.print_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); } } -void HMI_MaxFeedspeedXYZE(void) { +void HMI_MaxFeedspeedXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1364,82 +1509,76 @@ void HMI_MaxFeedspeedXYZE(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return checkkey = MaxSpeed; - EncoderRate.encoderRateEnabled = 0; - if (WITHIN(HMI_flag.feedspeed_flag, X_AXIS, E_AXIS)) - planner.set_max_feedrate(HMI_flag.feedspeed_flag, HMI_ValueStruct.Max_Feedspeed); + EncoderRate.enabled = false; + if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) + planner.set_max_feedrate(HMI_flag.feedspeed_axis, HMI_ValueStruct.Max_Feedspeed); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); return; } // MaxFeedspeed limit - if (WITHIN(HMI_flag.feedspeed_flag, X_AXIS, E_AXIS)) - NOMORE(HMI_ValueStruct.Max_Feedspeed, default_max_feedrate[HMI_flag.feedspeed_flag] * 2); + if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) + NOMORE(HMI_ValueStruct.Max_Feedspeed, default_max_feedrate[HMI_flag.feedspeed_axis] * 2); if (HMI_ValueStruct.Max_Feedspeed < MIN_MAXFEEDSPEED) HMI_ValueStruct.Max_Feedspeed = MIN_MAXFEEDSPEED; // MaxFeedspeed value DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); } } -void HMI_MaxAccelerationXYZE(void) { +void HMI_MaxAccelerationXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Max_Acceleration += EncoderRate.encoderMoveValue;} else if (encoder_diffState == ENCODER_DIFF_CCW) { HMI_ValueStruct.Max_Acceleration -= EncoderRate.encoderMoveValue;} else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return checkkey = MaxAcceleration; - EncoderRate.encoderRateEnabled = 0; - if (HMI_flag.acc_flag == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration); - else if (HMI_flag.acc_flag == Y_AXIS) planner.set_max_acceleration(Y_AXIS, HMI_ValueStruct.Max_Acceleration); - else if (HMI_flag.acc_flag == Z_AXIS) planner.set_max_acceleration(Z_AXIS, HMI_ValueStruct.Max_Acceleration); + EncoderRate.enabled = false; + if (HMI_flag.acc_axis == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_axis == Y_AXIS) planner.set_max_acceleration(Y_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_axis == Z_AXIS) planner.set_max_acceleration(Z_AXIS, HMI_ValueStruct.Max_Acceleration); #if HAS_HOTEND - else if (HMI_flag.acc_flag == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_axis == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration); #endif DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); return; } // MaxAcceleration limit - if (WITHIN(HMI_flag.acc_flag, X_AXIS, E_AXIS)) - NOMORE(HMI_ValueStruct.Max_Acceleration, default_max_acceleration[HMI_flag.acc_flag] * 2); + if (WITHIN(HMI_flag.acc_axis, X_AXIS, E_AXIS)) + NOMORE(HMI_ValueStruct.Max_Acceleration, default_max_acceleration[HMI_flag.acc_axis] * 2); if (HMI_ValueStruct.Max_Acceleration < MIN_MAXACCELERATION) HMI_ValueStruct.Max_Acceleration = MIN_MAXACCELERATION; // MaxAcceleration value DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); } } -void HMI_MaxJerkXYZE(void) { - ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Max_Jerk += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Max_Jerk -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return - checkkey = MaxJerk; - EncoderRate.encoderRateEnabled = 0; - if (HMI_flag.jerk_flag == X_AXIS) planner.set_max_jerk(X_AXIS, HMI_ValueStruct.Max_Jerk / 10); - else if (HMI_flag.jerk_flag == Y_AXIS) planner.set_max_jerk(Y_AXIS, HMI_ValueStruct.Max_Jerk / 10); - else if (HMI_flag.jerk_flag == Z_AXIS) planner.set_max_jerk(Z_AXIS, HMI_ValueStruct.Max_Jerk / 10); - else if (HMI_flag.jerk_flag == E_AXIS) planner.set_max_jerk(E_AXIS, HMI_ValueStruct.Max_Jerk / 10); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); - return; +#if HAS_CLASSIC_JERK + + void HMI_MaxJerkXYZE() { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Max_Jerk += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Max_Jerk -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + checkkey = MaxJerk; + EncoderRate.enabled = false; + if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) + planner.set_max_jerk(HMI_flag.step_axis, HMI_ValueStruct.Max_Jerk / 10); + DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + return; + } + // MaxJerk limit + if (WITHIN(HMI_flag.jerk_axis, X_AXIS, E_AXIS)) + NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[HMI_flag.jerk_axis] * 2 * MINUNITMULT); + NOLESS(HMI_ValueStruct.Max_Jerk, (MIN_MAXJERK) * MINUNITMULT); + // MaxJerk value + DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); } - // MaxJerk limit - if (HMI_flag.jerk_flag == X_AXIS) - NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[X_AXIS] * 2 * MINUNITMULT); - else if (HMI_flag.jerk_flag == Y_AXIS) - NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[Y_AXIS] * 2 * MINUNITMULT); - else if (HMI_flag.jerk_flag == Z_AXIS) - NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[Z_AXIS] * 2 * MINUNITMULT); - else if (HMI_flag.jerk_flag == E_AXIS) - NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[E_AXIS] * 2 * MINUNITMULT); - NOLESS(HMI_ValueStruct.Max_Jerk, (MIN_MAXJERK) * MINUNITMULT); - // MaxJerk value - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); } -} -void HMI_StepXYZE(void) { +#endif // HAS_CLASSIC_JERK + +void HMI_StepXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1450,71 +1589,100 @@ void HMI_StepXYZE(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return checkkey = Step; - EncoderRate.encoderRateEnabled = 0; - if (WITHIN(HMI_flag.step_flag, X_AXIS, E_AXIS)) - planner.settings.axis_steps_per_mm[HMI_flag.step_flag] = HMI_ValueStruct.Max_Step / 10; + EncoderRate.enabled = false; + if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) + planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step / 10; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); return; } // Step limit - if (WITHIN(HMI_flag.step_flag, X_AXIS, E_AXIS)) - NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[HMI_flag.step_flag] * 2 * MINUNITMULT); + if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) + NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[HMI_flag.step_axis] * 2 * MINUNITMULT); NOLESS(HMI_ValueStruct.Max_Step, MIN_STEP); // Step value DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); } } -void update_variable(void) { +void update_variable() { + #if HAS_HOTEND + static float last_temp_hotend_target = 0, last_temp_hotend_current = 0; + #endif + #if HAS_HEATED_BED + static float last_temp_bed_target = 0, last_temp_bed_current = 0; + #endif + #if HAS_FAN + static uint8_t last_fan_speed = 0; + #endif + /* Tune page temperature update */ if (checkkey == Tune) { - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2 + MROWS - index_tune), thermalManager.temp_hotend[0].target); - if (last_temp_bed_target != thermalManager.temp_bed.target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3 + MROWS - index_tune), thermalManager.temp_bed.target); - if (last_fan_speed != thermalManager.fan_speed[0]) { - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4 + MROWS - index_tune), thermalManager.fan_speed[0]); - last_fan_speed = thermalManager.fan_speed[0]; - } + #if HAS_HOTEND + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); + #endif + #if HAS_HEATED_BED + if (last_temp_bed_target != thermalManager.temp_bed.target) + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); + #endif + #if HAS_FAN + if (last_fan_speed != thermalManager.fan_speed[0]) { + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); + last_fan_speed = thermalManager.fan_speed[0]; + } + #endif } /* Temperature page temperature update */ if (checkkey == TemperatureID) { - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); - if (last_temp_bed_target != thermalManager.temp_bed.target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_bed.target); - if (last_fan_speed != thermalManager.fan_speed[0]) { - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.fan_speed[0]); - last_fan_speed = thermalManager.fan_speed[0]; - } + #if HAS_HOTEND + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_TEMP), thermalManager.temp_hotend[0].target); + #endif + #if HAS_HEATED_BED + if (last_temp_bed_target != thermalManager.temp_bed.target) + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_BED), thermalManager.temp_bed.target); + #endif + #if HAS_FAN + if (last_fan_speed != thermalManager.fan_speed[0]) { + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_FAN), thermalManager.fan_speed[0]); + last_fan_speed = thermalManager.fan_speed[0]; + } + #endif } /* Bottom temperature update */ - if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); - last_temp_hotend_current = thermalManager.temp_hotend[0].celsius; - } - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); - last_temp_hotend_target = thermalManager.temp_hotend[0].target; - } - if (last_temp_bed_current != thermalManager.temp_bed.celsius) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); - last_temp_bed_current = thermalManager.temp_bed.celsius; - } - if (last_temp_bed_target != thermalManager.temp_bed.target) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); - last_temp_bed_target = thermalManager.temp_bed.target; - } + #if HAS_HOTEND + if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) { + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); + last_temp_hotend_current = thermalManager.temp_hotend[0].celsius; + } + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); + last_temp_hotend_target = thermalManager.temp_hotend[0].target; + } + #endif + #if HAS_HEATED_BED + if (last_temp_bed_current != thermalManager.temp_bed.celsius) { + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); + last_temp_bed_current = thermalManager.temp_bed.celsius; + } + if (last_temp_bed_target != thermalManager.temp_bed.target) { + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); + last_temp_bed_target = thermalManager.temp_bed.target; + } + #endif + static uint16_t last_speed = 0; if (last_speed != feedrate_percentage) { DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); last_speed = feedrate_percentage; } - if (last_zoffset != BABY_Z_VAR) { - DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100); - last_zoffset = BABY_Z_VAR; - } + #if HAS_ZOFFSET_ITEM + if (last_zoffset != BABY_Z_VAR) { + DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100); + last_zoffset = BABY_Z_VAR; + } + #endif } /** @@ -1553,38 +1721,37 @@ inline void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_ while (pos--) dst[pos] = src[pos]; } -inline void HMI_SDCardInit(void) { card.cdroot(); } +inline void HMI_SDCardInit() { card.cdroot(); } -void MarlinUI::refresh() { - // The card was mounted or unmounted - // or some other status change occurred - // DWIN_lcd_sd_status = false; // On next DWIN_Update - // HMI_SDCardUpdate(); -} +void MarlinUI::refresh() { /* Nothing to see here */ } #define ICON_Folder ICON_More -char shift_name[LONG_FILENAME_LENGTH + 1]; -int8_t shift_amt; // = 0 -millis_t shift_ms; // = 0 +#if ENABLED(SCROLL_LONG_FILENAMES) -// Init the shift name based on the highlighted item -inline void Init_Shift_Name() { - const bool is_subdir = !card.flag.workDirIsRoot; - const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".." - const uint16_t fileCnt = card.get_num_Files(); - if (WITHIN(filenum, 0, fileCnt - 1)) { - card.getfilename_sorted(SD_ORDER(filenum, fileCnt)); - char * const name = card.longest_filename(); - make_name_without_ext(shift_name, name, 100); + char shift_name[LONG_FILENAME_LENGTH + 1]; + int8_t shift_amt; // = 0 + millis_t shift_ms; // = 0 + + // Init the shift name based on the highlighted item + inline void Init_Shift_Name() { + const bool is_subdir = !card.flag.workDirIsRoot; + const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".." + const uint16_t fileCnt = card.get_num_Files(); + if (WITHIN(filenum, 0, fileCnt - 1)) { + card.getfilename_sorted(SD_ORDER(filenum, fileCnt)); + char * const name = card.longest_filename(); + make_name_without_ext(shift_name, name, 100); + } } -} -inline void Init_SDItem_Shift() { - shift_amt = 0; - shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT - ? millis() + 750UL : 0; -} + inline void Init_SDItem_Shift() { + shift_amt = 0; + shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT + ? millis() + 750UL : 0; + } + +#endif /** * Display an SD item, adding a CDUP for subfolders. @@ -1600,37 +1767,42 @@ inline void Draw_SDItem(const uint16_t item, int16_t row=-1) { card.getfilename_sorted(item - is_subdir); char * const name = card.longest_filename(); - // Init the current selected name - // This is used during scroll drawing - if (item == select_file.now - 1) { - make_name_without_ext(shift_name, name, 100); - Init_SDItem_Shift(); - } + #if ENABLED(SCROLL_LONG_FILENAMES) + // Init the current selected name + // This is used during scroll drawing + if (item == select_file.now - 1) { + make_name_without_ext(shift_name, name, 100); + Init_SDItem_Shift(); + } + #endif + // Draw the file/folder with name aligned left char str[strlen(name) + 1]; - make_name_without_ext(str, name); - Draw_Menu_Line(row, card.flag.filenameIsDir ? ICON_Folder : ICON_File, str); } -inline void Draw_SDItem_Shifted(int8_t &shift) { - // Limit to the number of chars past the cutoff - const size_t len = strlen(shift_name); - NOMORE(shift, _MAX((signed)len - MENU_CHAR_LIMIT, 0)); +#if ENABLED(SCROLL_LONG_FILENAMES) - // Shorten to the available space - const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); + inline void Draw_SDItem_Shifted(int8_t &shift) { + // Limit to the number of chars past the cutoff + const size_t len = strlen(shift_name); + NOMORE(shift, _MAX((signed)len - MENU_CHAR_LIMIT, 0)); - const char c = shift_name[lastchar]; - shift_name[lastchar] = '\0'; + // Shorten to the available space + const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); - const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll - Erase_Menu_Text(row); - Draw_Menu_Line(row, 0, &shift_name[shift]); + const char c = shift_name[lastchar]; + shift_name[lastchar] = '\0'; - shift_name[lastchar] = c; -} + const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll + Erase_Menu_Text(row); + Draw_Menu_Line(row, 0, &shift_name[shift]); + + shift_name[lastchar] = c; + } + +#endif // Redraw the first set of SD Files inline void Redraw_SD_List() { @@ -1645,10 +1817,12 @@ inline void Redraw_SD_List() { LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS)) Draw_SDItem(i, i + 1); - Init_SDItem_Shift(); + TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); } -inline void SDCard_Up(void) { +bool DWIN_lcd_sd_status = false; + +inline void SDCard_Up() { card.cdup(); Redraw_SD_List(); DWIN_lcd_sd_status = false; // On next DWIN_Update @@ -1663,7 +1837,7 @@ inline void SDCard_Folder(char * const dirname) { // // Watch for media mount / unmount // -void HMI_SDCardUpdate(void) { +void HMI_SDCardUpdate() { if (HMI_flag.home_flag) return; if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); @@ -1681,40 +1855,50 @@ void HMI_SDCardUpdate(void) { // TODO: Move card removed abort handling // to CardReader::manage_media. card.flag.abort_sd_printing = true; - wait_for_heatup = false; - abort_flag = true; + wait_for_heatup = false; + dwin_abort_flag = true; } } DWIN_UpdateLCD(); } } -/* Start */ +/* Start Frame */ + void HMI_StartFrame(const bool with_update) { Goto_MainMenu(); - DWIN_Draw_Rectangle(1, Background_black, 0, 360, DWIN_WIDTH, DWIN_HEIGHT - 1); + // Clear the bottom area of the screen + DWIN_Draw_Rectangle(1, Background_black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); - DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381); + // + // Status Area + // + #if HAS_HOTEND + DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381); + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 3 * STAT_CHR_W + 5, 383, F("/")); + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); + #endif #if HOTENDS > 1 // DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381); #endif - DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381); - DWIN_ICON_Show(ICON, ICON_Speed, 13, 429); - DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428); - // Draw initial Status Area - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); + #if HAS_HEATED_BED + DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381); + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); + DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 178 + 3 * STAT_CHR_W + 5, 383, F("/")); + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); + #endif + DWIN_ICON_Show(ICON, ICON_Speed, 13, 429); DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 5 * STAT_CHR_W + 2, 429, F("%")); - DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178, 429, BABY_Z_VAR * 100); - DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 3 * STAT_CHR_W + 5, 383, F("/")); - DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 178 + 3 * STAT_CHR_W + 5, 383, F("/")); + #if HAS_ZOFFSET_ITEM + DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428); + DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178, 429, BABY_Z_VAR * 100); + #endif if (with_update) { DWIN_UpdateLCD(); @@ -1774,12 +1958,12 @@ inline void Draw_Print_File_Menu() { } /* Main Process */ -void HMI_MainMenu(void) { +void HMI_MainMenu() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_page.inc(3)) { + if (select_page.inc(4)) { switch (select_page.now) { case 0: ICON_Print(); break; case 1: ICON_Print(); ICON_Prepare(); break; @@ -1834,27 +2018,29 @@ void HMI_MainMenu(void) { } // Select (and Print) File -void HMI_SelectFile(void) { +void HMI_SelectFile() { ENCODER_DiffState encoder_diffState = get_encoder_state(); const uint16_t hasUpDir = !card.flag.workDirIsRoot; if (encoder_diffState == ENCODER_DIFF_NO) { - if (shift_ms && select_file.now >= 1 + hasUpDir) { - // Scroll selected filename every second - const millis_t ms = millis(); - if (ELAPSED(ms, shift_ms)) { - const bool was_reset = shift_amt < 0; - shift_ms = ms + 375UL + was_reset * 250UL; // ms per character - int8_t shift_new = shift_amt + 1; // Try to shift by... - Draw_SDItem_Shifted(shift_new); // Draw the item - if (!was_reset && shift_new == 0) // Was it limited to 0? - shift_ms = 0; // No scrolling needed - else if (shift_new == shift_amt) // Scroll reached the end - shift_new = -1; // Reset - shift_amt = shift_new; // Set new scroll + #if ENABLED(SCROLL_LONG_FILENAMES) + if (shift_ms && select_file.now >= 1 + hasUpDir) { + // Scroll selected filename every second + const millis_t ms = millis(); + if (ELAPSED(ms, shift_ms)) { + const bool was_reset = shift_amt < 0; + shift_ms = ms + 375UL + was_reset * 250UL; // ms per character + int8_t shift_new = shift_amt + 1; // Try to shift by... + Draw_SDItem_Shifted(shift_new); // Draw the item + if (!was_reset && shift_new == 0) // Was it limited to 0? + shift_ms = 0; // No scrolling needed + else if (shift_new == shift_amt) // Scroll reached the end + shift_new = -1; // Reset + shift_amt = shift_new; // Set new scroll + } } - } + #endif return; } @@ -1864,10 +2050,10 @@ void HMI_SelectFile(void) { const uint16_t fullCnt = nr_sd_menu_items(); if (encoder_diffState == ENCODER_DIFF_CW && fullCnt) { - if (select_file.inc(fullCnt)) { + if (select_file.inc(1 + fullCnt)) { const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - if (shift_ms) { // If line was shifted - Erase_Menu_Text(select_file.now - 1 + MROWS - index_file); // Erase and + if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted + Erase_Menu_Text(itemnum + MROWS - index_file); // Erase and Draw_SDItem(itemnum - 1); // redraw } if (select_file.now > MROWS && select_file.now > index_file) { // Cursor past the bottom @@ -1877,15 +2063,15 @@ void HMI_SelectFile(void) { } else { Move_Highlight(1, select_file.now + MROWS - index_file); // Just move highlight - Init_Shift_Name(); // ...and init the shift name + TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name } - Init_SDItem_Shift(); + TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); } } else if (encoder_diffState == ENCODER_DIFF_CCW && fullCnt) { if (select_file.dec()) { const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - if (shift_ms) { // If line was shifted + if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted Erase_Menu_Text(select_file.now + 1 + MROWS - index_file); // Erase and Draw_SDItem(itemnum + 1); // redraw } @@ -1894,7 +2080,7 @@ void HMI_SelectFile(void) { Scroll_Menu(DWIN_SCROLL_DOWN); if (index_file == MROWS) { Draw_Back_First(); - shift_ms = 0; + TERN_(SCROLL_LONG_FILENAMES, shift_ms = 0); } else { Draw_SDItem(itemnum, 0); // Draw the item (and init shift name) @@ -1902,19 +2088,17 @@ void HMI_SelectFile(void) { } else { Move_Highlight(-1, select_file.now + MROWS - index_file); // Just move highlight - Init_Shift_Name(); // ...and init the shift name + TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name } - Init_SDItem_Shift(); // Reset left. Init timer. + TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); // Reset left. Init timer. } } else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (select_file.now == 0) { - /* back */ + if (select_file.now == 0) { // Back select_page.set(0); Goto_MainMenu(); } - else if (hasUpDir && select_file.now == 1) { - /* CDUP */ + else if (hasUpDir && select_file.now == 1) { // CD-Up SDCard_Up(); goto HMI_SelectFileExit; } @@ -1933,8 +2117,8 @@ void HMI_SelectFile(void) { select_file.reset(); // Start choice and print SD file - HMI_flag.heat_flag = 1; - HMI_flag.print_finish = 0; + HMI_flag.heat_flag = true; + HMI_flag.print_finish = false; HMI_ValueStruct.show_mode = 0; card.openAndPrintFile(card.filename); @@ -1954,21 +2138,21 @@ void HMI_SelectFile(void) { } /* Printing */ -void HMI_Printing(void) { +void HMI_Printing() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; - if (HMI_flag.confirm_flag) { + if (HMI_flag.done_confirm_flag) { if (encoder_diffState == ENCODER_DIFF_ENTER) { - HMI_flag.confirm_flag = 0; - abort_flag = 1; + HMI_flag.done_confirm_flag = false; + dwin_abort_flag = true; } return; } // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_print.inc(2)) { + if (select_print.inc(3)) { switch (select_print.now) { case 0: ICON_Tune(); break; case 1: @@ -1999,15 +2183,14 @@ void HMI_Printing(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { switch (select_print.now) { - case 0: // Setting + case 0: // Tune checkkey = Tune; HMI_ValueStruct.show_mode = 0; select_tune.reset(); - index_tune = 5; + index_tune = MROWS; Draw_Tune_Menu(); break; case 1: // Pause - /* pause */ if (HMI_flag.pause_flag) { ICON_Pause(); @@ -2015,23 +2198,26 @@ void HMI_Printing(void) { cmd[0] = '\0'; #if ENABLED(PAUSE_HEAT) - if (tempbed) sprintf_P(cmd, PSTR("M190 S%i\n"), tempbed); - if (temphot) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), temphot); + #if HAS_HEATED_BED + if (tempbed) sprintf_P(cmd, PSTR("M190 S%i\n"), tempbed); + #endif + #if HAS_HOTEND + if (temphot) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), temphot); + #endif #endif strcat_P(cmd, PSTR("M24")); queue.inject(cmd); } else { - HMI_flag.select_flag = 1; + HMI_flag.select_flag = true; checkkey = Print_window; Popup_window_PauseOrStop(); } break; case 2: // Stop - /* stop */ - HMI_flag.select_flag = 1; + HMI_flag.select_flag = true; checkkey = Print_window; Popup_window_PauseOrStop(); break; @@ -2043,7 +2229,7 @@ void HMI_Printing(void) { } /* Pause and Stop window */ -void HMI_PauseOrStop(void) { +void HMI_PauseOrStop() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; @@ -2056,7 +2242,7 @@ void HMI_PauseOrStop(void) { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (select_print.now == 1) { // pause window if (HMI_flag.select_flag) { - pause_action_flag = 1; + HMI_flag.pause_action = true; ICON_Continue(); #if ENABLED(POWER_LOSS_RECOVERY) if (recovery.enabled) recovery.save(true); @@ -2084,10 +2270,10 @@ void HMI_PauseOrStop(void) { host_action_cancel(); #endif #ifdef EVENT_GCODE_SD_ABORT - Popup_Window_Home(); + Popup_Window_Home(true); queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT)); #endif - abort_flag = true; + dwin_abort_flag = true; #endif } else { @@ -2114,20 +2300,20 @@ inline void Draw_Move_Menu() { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_MOVE_AXIS)); #else - DWIN_Frame_TitleCopy(1, 231, 2, 265, 12); // "Move" + DWIN_Frame_TitleCopy(1, 231, 2, 265, 12); // "Move" #endif draw_move_en(MBASE(1)); say_x(36, MBASE(1)); // "Move X" draw_move_en(MBASE(2)); say_y(36, MBASE(2)); // "Move Y" draw_move_en(MBASE(3)); say_z(36, MBASE(3)); // "Move Z" #if HAS_HOTEND - DWIN_Frame_AreaCopy(1, 123, 192, 176, 202, LBLX, MBASE(4)); // "Extruder" + DWIN_Frame_AreaCopy(1, 123, 192, 176, 202, LBLX, MBASE(4)); // "Extruder" #endif } Draw_Back_First(select_axis.now == 0); if (select_axis.now) Draw_Menu_Cursor(select_axis.now); - // Draw separators so it looks like a menu + // Draw separators and icons LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MoveX + i); } @@ -2144,13 +2330,13 @@ void HMI_AudioFeedback(const bool success=true) { } /* Prepare */ -void HMI_Prepare(void) { +void HMI_Prepare() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_prepare.inc(8)) { + if (select_prepare.inc(1 + PREPARE_CASE_TOTAL)) { if (select_prepare.now > MROWS && select_prepare.now > index_prepare) { index_prepare = select_prepare.now; @@ -2161,9 +2347,13 @@ void HMI_Prepare(void) { // Draw "More" icon for sub-menus if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1); - if (index_prepare == 6) Prepare_Item_ABS(MROWS); - else if (index_prepare == 7) Prepare_Item_Cool(MROWS); - else if (index_prepare == 8) Prepare_Item_Lang(MROWS); + #if HAS_HOTEND + if (index_prepare == PREPARE_CASE_ABS) Item_Prepare_ABS(MROWS); + #endif + #if HAS_PREHEAT + if (index_prepare == PREPARE_CASE_COOL) Item_Prepare_Cool(MROWS); + #endif + if (index_prepare == PREPARE_CASE_LANG) Item_Prepare_Lang(MROWS); } else { Move_Highlight(1, select_prepare.now + MROWS - index_prepare); @@ -2183,9 +2373,9 @@ void HMI_Prepare(void) { if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1); - if (index_prepare == 6) Prepare_Item_Move(0); - else if (index_prepare == 7) Prepare_Item_Disable(0); - else if (index_prepare == 8) Prepare_Item_Home(0); + if (index_prepare == 6) Item_Prepare_Move(0); + else if (index_prepare == 7) Item_Prepare_Disable(0); + else if (index_prepare == 8) Item_Prepare_Home(0); } else { Move_Highlight(-1, select_prepare.now + MROWS - index_prepare); @@ -2198,67 +2388,66 @@ void HMI_Prepare(void) { select_page.set(1); Goto_MainMenu(); break; - case 1: // axis move + case PREPARE_CASE_MOVE: // Axis move checkkey = AxisMove; select_axis.reset(); Draw_Move_Menu(); - queue.inject_P(PSTR("G92 E0")); - current_position.e = HMI_ValueStruct.Move_E_scale = 0; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), current_position.x * MINUNITMULT); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), current_position.y * MINUNITMULT); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), current_position.z * MINUNITMULT); #if HAS_HOTEND - DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), current_position.e * MINUNITMULT); + queue.inject_P(PSTR("G92 E0")); + current_position.e = HMI_ValueStruct.Move_E_scale = 0; + DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), 0); #endif break; - case 2: // close motion + case PREPARE_CASE_DISA: // Disable steppers queue.inject_P(PSTR("M84")); break; - case 3: // homing + case PREPARE_CASE_HOME: // Homing checkkey = Last_Prepare; index_prepare = MROWS; queue.inject_P(PSTR("G28")); // G28 will set home_flag Popup_Window_Home(); break; - case 4: // Z-offset - #if HAS_BED_PROBE - checkkey = Homeoffset; - HMI_ValueStruct.show_mode = -4; - HMI_ValueStruct.offset_value = probe.offset.z * 100; - DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value); - EncoderRate.encoderRateEnabled = 1; - #else - // Apply workspace offset, making the current position 0,0,0 - queue.inject_P(PSTR("G92 X0 Y0 Z0")); - HMI_AudioFeedback(); - #endif - break; - case 5: // PLA preheat - thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0); - thermalManager.setTargetBed(ui.material_preset[0].bed_temp); - thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed); - break; - case 6: // ABS preheat - thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0); - thermalManager.setTargetBed(ui.material_preset[1].bed_temp); - thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed); - break; - case 7: // cool - thermalManager.zero_fan_speeds(); - thermalManager.disable_all_heaters(); - break; - case 8: // language - /* select language */ - HMI_flag.language_chinese ^= true; - if (HMI_flag.language_chinese) { - HMI_SetAndSaveLanguageChinese(); - DWIN_JPG_CacheTo1(Language_Chinese); - } - else { - HMI_SetAndSaveLanguageWestern(); - DWIN_JPG_CacheTo1(Language_English); - } + #if HAS_ZOFFSET_ITEM + case PREPARE_CASE_ZOFF: // Z-offset + #if EITHER(HAS_BED_PROBE, BABYSTEPPING) + checkkey = Homeoffset; + HMI_ValueStruct.show_mode = -4; + HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(PREPARE_CASE_ZOFF + MROWS - index_prepare), HMI_ValueStruct.offset_value); + EncoderRate.enabled = true; + #else + // Apply workspace offset, making the current position 0,0,0 + queue.inject_P(PSTR("G92 X0 Y0 Z0")); + HMI_AudioFeedback(); + #endif + break; + #endif + #if HAS_HOTEND + case PREPARE_CASE_PLA: // PLA preheat + thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0); + thermalManager.setTargetBed(ui.material_preset[0].bed_temp); + thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed); + break; + case PREPARE_CASE_ABS: // ABS preheat + thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0); + thermalManager.setTargetBed(ui.material_preset[1].bed_temp); + thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed); + break; + #endif + #if HAS_PREHEAT + case PREPARE_CASE_COOL: // Cool + TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); + #if HAS_HOTEND || HAS_HEATED_BED + thermalManager.disable_all_heaters(); + #endif + break; + #endif + case PREPARE_CASE_LANG: // Toggle Language + HMI_ToggleLanguage(); Draw_Prepare_Menu(); break; default: break; @@ -2271,72 +2460,108 @@ void Draw_Temperature_Menu() { Clear_Main_Window(); if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 236, 2, 263, 13, 14, 8); - - DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(2)); - DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 100, 89, 178, 101, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 180, 89, 260, 100, LBLX, MBASE(5)); + DWIN_Frame_TitleCopy(1, 236, 2, 263, 13); // "Temperature" + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(TEMP_CASE_TEMP)); + #endif + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(TEMP_CASE_BED)); + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(TEMP_CASE_FAN)); + #endif + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 100, 89, 178, 101, LBLX, MBASE(TEMP_CASE_PLA)); + DWIN_Frame_AreaCopy(1, 180, 89, 260, 100, LBLX, MBASE(TEMP_CASE_ABS)); + #endif } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TEMPERATURE)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_FAN_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), F("PLA Preheat Settings")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(5), F("ABS Preheat Settings")); + #if HAS_HOTEND + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + #endif + #if HAS_HEATED_BED + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + #endif + #if HAS_FAN + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + #endif + #if HAS_HOTEND + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_PLA), F("PLA Preheat Settings")); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_ABS), F("ABS Preheat Settings")); + #endif #else - DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8); - DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(1)); // Nozzle... - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(1)); // ...Temperature - DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(2)); // Bed... - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(2)); // ...Temperature - DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(3)); // Fan speed - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(4)); // Preheat... - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(4)); // ...PLA - DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 79, MBASE(4)); // PLA setting - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(5)); // Preheat... - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(5)); // ...ABS - DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 81, MBASE(5)); // ABS setting + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "Temperature" + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TEMP_CASE_TEMP)); // Nozzle... + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(TEMP_CASE_TEMP)); // ...Temperature + #endif + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(TEMP_CASE_BED)); // Bed... + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(TEMP_CASE_BED)); // ...Temperature + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(TEMP_CASE_FAN)); // Fan speed + #endif + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(TEMP_CASE_PLA)); // Preheat... + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(TEMP_CASE_PLA)); // ...PLA + DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 79, MBASE(TEMP_CASE_PLA)); // PLA setting + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(TEMP_CASE_ABS)); // Preheat... + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(TEMP_CASE_ABS)); // ...ABS + DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 81, MBASE(TEMP_CASE_ABS)); // ABS setting + #endif #endif } Draw_Back_First(select_temp.now == 0); if (select_temp.now) Draw_Menu_Cursor(select_temp.now); - LOOP_L_N(i, 5) Draw_Menu_Line(i + 1, ICON_SetEndTemp + i); - - Draw_More_Icon(4); - Draw_More_Icon(5); - - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_bed.target); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.fan_speed[0]); + // Draw icons and lines + uint8_t i = 0; + #define _TMENU_ICON(N) Draw_Menu_Line(++i, ICON_SetEndTemp + (N) - 1) + #if HAS_HOTEND + _TMENU_ICON(TEMP_CASE_TEMP); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.temp_hotend[0].target); + #endif + #if HAS_HEATED_BED + _TMENU_ICON(TEMP_CASE_BED); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.temp_bed.target); + #endif + #if HAS_FAN + _TMENU_ICON(TEMP_CASE_FAN); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.fan_speed[0]); + #endif + #if HAS_HOTEND + // PLA/ABS items have submenus + _TMENU_ICON(TEMP_CASE_PLA); + Draw_More_Icon(i); + _TMENU_ICON(TEMP_CASE_ABS); + Draw_More_Icon(i); + #endif } /* Control */ -void HMI_Control(void) { +void HMI_Control() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - #define CONTROL_ITEMS (5 + ENABLED(HAS_ONESTEP_LEVELING)) - if (select_control.inc(CONTROL_ITEMS)) { + if (select_control.inc(1 + CONTROL_CASE_TOTAL)) { if (select_control.now > MROWS && select_control.now > index_control) { index_control = select_control.now; Scroll_Menu(DWIN_SCROLL_UP); - Draw_Menu_Icon(MROWS, ICON_Temperature + select_control.now - 1); - Draw_More_Icon(1 + MROWS - index_control); // Temperature > - Draw_More_Icon(2 + MROWS - index_control); // Motion > + Draw_Menu_Icon(MROWS, ICON_Temperature + index_control - 1); + Draw_More_Icon(CONTROL_CASE_TEMP + MROWS - index_control); // Temperature > + Draw_More_Icon(CONTROL_CASE_MOVE + MROWS - index_control); // Motion > if (index_control > MROWS) { - Draw_More_Icon(6 + MROWS - index_control); // Info > + Draw_More_Icon(CONTROL_CASE_INFO + MROWS - index_control); // Info > if (HMI_flag.language_chinese) - DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, MBASE(5)); + DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, MBASE(CONTROL_CASE_INFO - 1)); else - DWIN_Frame_AreaCopy(1, 0, 104, 24, 114, LBLX, MBASE(5)); + DWIN_Frame_AreaCopy(1, 0, 104, 24, 114, LBLX, MBASE(CONTROL_CASE_INFO - 1)); } } else { @@ -2367,33 +2592,32 @@ void HMI_Control(void) { select_page.set(2); Goto_MainMenu(); break; - case 1: // temperature + case CONTROL_CASE_TEMP: // Temperature checkkey = TemperatureID; HMI_ValueStruct.show_mode = -1; select_temp.reset(); Draw_Temperature_Menu(); break; - case 2: // motion + case CONTROL_CASE_MOVE: // Motion checkkey = Motion; select_motion.reset(); Draw_Motion_Menu(); break; - case 3: #if ENABLED(EEPROM_SETTINGS) - { // write EEPROM + case CONTROL_CASE_SAVE: { // Write EEPROM const bool success = settings.save(); HMI_AudioFeedback(success); } break; - case 4: { // read EEPROM + case CONTROL_CASE_LOAD: { // Read EEPROM const bool success = settings.load(); HMI_AudioFeedback(success); } break; - case 5: // resume EEPROM + case CONTROL_CASE_RESET: // Reset EEPROM settings.reset(); HMI_AudioFeedback(); break; - case 6: // info #endif + case CONTROL_CASE_INFO: // Info checkkey = Info; Draw_Info_Menu(); break; @@ -2407,7 +2631,7 @@ void HMI_Control(void) { #if HAS_ONESTEP_LEVELING /* Leveling */ - void HMI_Leveling(void) { + void HMI_Leveling() { Popup_Window_Leveling(); DWIN_UpdateLCD(); queue.inject_P(PSTR("G28O\nG29")); @@ -2416,21 +2640,21 @@ void HMI_Control(void) { #endif /* Axis Move */ -void HMI_AxisMove(void) { +void HMI_AxisMove() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; - #if HAS_HOTEND + #if ENABLED(PREVENT_COLD_EXTRUSION) // popup window resume if (HMI_flag.ETempTooLow_flag) { if (encoder_diffState == ENCODER_DIFF_ENTER) { - HMI_flag.ETempTooLow_flag = 0; - Draw_Move_Menu(); + HMI_flag.ETempTooLow_flag = false; current_position.e = HMI_ValueStruct.Move_E_scale = 0; + Draw_Move_Menu(); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); - DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), 0); DWIN_UpdateLCD(); } return; @@ -2439,7 +2663,7 @@ void HMI_AxisMove(void) { // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_axis.inc(4)) Move_Highlight(1, select_axis.now); + if (select_axis.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_axis.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_axis.dec()) Move_Highlight(-1, select_axis.now); @@ -2456,26 +2680,26 @@ void HMI_AxisMove(void) { checkkey = Move_X; HMI_ValueStruct.Move_X_scale = current_position.x * MINUNITMULT; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; break; case 2: // Y axis move checkkey = Move_Y; HMI_ValueStruct.Move_Y_scale = current_position.y * MINUNITMULT; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; break; case 3: // Z axis move checkkey = Move_Z; HMI_ValueStruct.Move_Z_scale = current_position.z * MINUNITMULT; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; break; #if HAS_HOTEND case 4: // Extruder // window tips #ifdef PREVENT_COLD_EXTRUSION if (thermalManager.temp_hotend[0].celsius < EXTRUDE_MINTEMP) { - HMI_flag.ETempTooLow_flag = 1; + HMI_flag.ETempTooLow_flag = true; Popup_Window_ETempTooLow(); DWIN_UpdateLCD(); return; @@ -2484,7 +2708,7 @@ void HMI_AxisMove(void) { checkkey = Extruder; HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT; DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; break; #endif } @@ -2493,13 +2717,13 @@ void HMI_AxisMove(void) { } /* TemperatureID */ -void HMI_Temperature(void) { +void HMI_Temperature() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_temp.inc(5)) Move_Highlight(1, select_temp.now); + if (select_temp.inc(1 + TEMP_CASE_TOTAL)) Move_Highlight(1, select_temp.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_temp.dec()) Move_Highlight(-1, select_temp.now); @@ -2512,141 +2736,184 @@ void HMI_Temperature(void) { index_control = MROWS; Draw_Control_Menu(); break; - #if HAS_HOTEND - case 1: // nozzle temperature - checkkey = ETemp; - HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_HEATED_BED - case 2: // bed temperature - checkkey = BedTemp; - HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_FAN - case 3: // fan speed - checkkey = FanSpeed; - HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_HOTEND - case 4: // PLA preheat setting - checkkey = PLAPreheat; - select_PLA.reset(); - HMI_ValueStruct.show_mode = -2; - - Clear_Main_Window(); - - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 59, 16, 139, 29, 14, 8); - - DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(1)); // PLA nozzle temp - DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(2)); - DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(2)); // PLA bed temp - DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(3)); // PLA fan speed - DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(4)); // save PLA configuration - } - else { - #ifdef USE_STRING_HEADINGS - Draw_Title("PLA Settings"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Nozzle Temp")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), F("Bed Temp")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_FAN_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_STORE_EEPROM)); - #else - DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8); - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(1)); // PLA nozzle temp - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(2) + 3); // PLA bed temp - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(3)); // PLA fan speed - DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(4)); // save PLA configuration - #endif - } - - Draw_Back_First(); - - Draw_Menu_Line(1, ICON_SetEndTemp); - Draw_Menu_Line(2, ICON_SetBedTemp); - Draw_Menu_Line(3, ICON_FanSpeed); + #if HAS_HOTEND + case TEMP_CASE_TEMP: // Nozzle temperature + checkkey = ETemp; + HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); + EncoderRate.enabled = true; + break; + #endif + #if HAS_HEATED_BED + case TEMP_CASE_BED: // Bed temperature + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target); + EncoderRate.enabled = true; + break; + #endif + #if HAS_FAN + case TEMP_CASE_FAN: // Fan speed + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]); + EncoderRate.enabled = true; + break; + #endif + #if HAS_HOTEND + case TEMP_CASE_PLA: { // PLA preheat setting + checkkey = PLAPreheat; + select_PLA.reset(); + HMI_ValueStruct.show_mode = -2; + + Clear_Main_Window(); + + if (HMI_flag.language_chinese) { + DWIN_Frame_TitleCopy(1, 59, 16, 139, 29); // "PLA Settings" + DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_BED)); + DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(PREHEAT_CASE_BED)); // PLA bed temp + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_FAN)); + DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(PREHEAT_CASE_FAN)); // PLA fan speed + #endif #if ENABLED(EEPROM_SETTINGS) - Draw_Menu_Line(4, ICON_WriteEEPROM); + DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration + #endif + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("PLA Settings"); // TODO: GET_TEXT_F + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); + #if HAS_HEATED_BED + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); + #endif + #if HAS_FAN + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + #endif + #if ENABLED(EEPROM_SETTINGS) + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + #endif + #else + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings" + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3); + DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3); + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(PREHEAT_CASE_BED) + 3); // PLA bed temp + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_FAN)); + DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN)); // PLA fan speed + #endif + #if ENABLED(EEPROM_SETTINGS) + DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration + #endif #endif + } - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[0].hotend_temp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[0].bed_temp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[0].fan_speed); + Draw_Back_First(); - break; + uint8_t i = 0; + Draw_Menu_Line(++i, ICON_SetEndTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].hotend_temp); + #if HAS_HEATED_BED + Draw_Menu_Line(++i, ICON_SetBedTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].bed_temp); + #endif + #if HAS_FAN + Draw_Menu_Line(++i, ICON_FanSpeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].fan_speed); + #endif + #if ENABLED(EEPROM_SETTINGS) + Draw_Menu_Line(++i, ICON_WriteEEPROM); + #endif + } break; - case 5: // ABS preheat setting - checkkey = ABSPreheat; - select_ABS.reset(); - HMI_ValueStruct.show_mode = -3; - - Clear_Main_Window(); - - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 142, 16, 223, 29, 14, 8); - - DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(1)); // ABS nozzle temp - DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(2)); - DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(2)); // ABS bed temp - DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(3)); // ABS fan speed - DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX + 28, MBASE(4) + 2); // save ABS configuration - } - else { - #ifdef USE_STRING_HEADINGS - Draw_Title("ABS Settings"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Nozzle Temp")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), F("Bed Temp")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_FAN_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_STORE_EEPROM)); - #else - DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8); - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(1)); // ABS nozzle temp - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(2) + 3); // ABS bed temp - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(3)); // ABS fan speed - DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 33, MBASE(4)); // save ABS configuration - #endif - } + case TEMP_CASE_ABS: { // ABS preheat setting + checkkey = ABSPreheat; + select_ABS.reset(); + HMI_ValueStruct.show_mode = -3; - Draw_Back_First(); + Clear_Main_Window(); - Draw_Menu_Line(1, ICON_SetEndTemp); - Draw_Menu_Line(2, ICON_SetBedTemp); - Draw_Menu_Line(3, ICON_FanSpeed); + if (HMI_flag.language_chinese) { + DWIN_Frame_TitleCopy(1, 142, 16, 223, 29); // "ABS Settings" + + DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(PREHEAT_CASE_TEMP)); // ABS nozzle temp + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_BED)); + DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(PREHEAT_CASE_BED)); // ABS bed temp + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_FAN)); + DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(PREHEAT_CASE_FAN)); // ABS fan speed + #endif #if ENABLED(EEPROM_SETTINGS) - Draw_Menu_Line(4, ICON_WriteEEPROM); + DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(PREHEAT_CASE_SAVE)); + DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX + 28, MBASE(PREHEAT_CASE_SAVE) + 2); // Save ABS configuration + #endif + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("ABS Settings"); // TODO: GET_TEXT_F + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); + #if HAS_HEATED_BED + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); + #endif + #if HAS_FAN + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + #endif + #if ENABLED(EEPROM_SETTINGS) + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + #endif + #else + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "ABS Settings" + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // ABS nozzle temp + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3); + DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3); + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(PREHEAT_CASE_BED) + 3); // ABS bed temp + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_FAN)); + DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN)); // ABS fan speed + #endif + #if ENABLED(EEPROM_SETTINGS) + DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 33, MBASE(PREHEAT_CASE_SAVE)); // Save ABS configuration + #endif #endif + } - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[1].hotend_temp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[1].bed_temp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[1].fan_speed); + Draw_Back_First(); - break; - #endif // HAS_HOTEND + uint8_t i = 0; + Draw_Menu_Line(++i, ICON_SetEndTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].hotend_temp); + #if HAS_HEATED_BED + Draw_Menu_Line(++i, ICON_SetBedTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].bed_temp); + #endif + #if HAS_FAN + Draw_Menu_Line(++i, ICON_FanSpeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].fan_speed); + #endif + #if ENABLED(EEPROM_SETTINGS) + Draw_Menu_Line(++i, ICON_WriteEEPROM); + #endif + + } break; + + #endif // HAS_HOTEND } } DWIN_UpdateLCD(); @@ -2659,18 +2926,18 @@ inline void Draw_Max_Speed_Menu() { DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Max Speed (mm/s)" auto say_max_speed = [](const uint16_t row) { - DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, row); // "Max speed" + DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, row); // "Max speed" }; - say_max_speed(MBASE(1)); // "Max speed" - DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(1)); // X - say_max_speed(MBASE(2)); // "Max speed" - DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(2) + 3); // Y - say_max_speed(MBASE(3)); // "Max speed" - DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(3) + 3); // Z + say_max_speed(MBASE(1)); // "Max speed" + DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(1)); // X + say_max_speed(MBASE(2)); // "Max speed" + DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(2) + 3); // Y + say_max_speed(MBASE(3)); // "Max speed" + DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(3) + 3); // Z #if HAS_HOTEND - say_max_speed(MBASE(4)); // "Max speed" - DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(4) + 3); // E + say_max_speed(MBASE(4)); // "Max speed" + DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(4) + 3); // E #endif } else { @@ -2745,7 +3012,7 @@ inline void Draw_Max_Accel_Menu() { DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), F("Max Accel E")); #endif #else - DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Acceleration" + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Acceleration" draw_max_accel_en(MBASE(1)); say_x(108, MBASE(1)); // "Max Acceleration X" draw_max_accel_en(MBASE(2)); say_y(108, MBASE(2)); // "Max Acceleration Y" draw_max_accel_en(MBASE(3)); say_z(108, MBASE(3)); // "Max Acceleration Z" @@ -2883,13 +3150,13 @@ inline void Draw_Steps_Menu() { } /* Motion */ -void HMI_Motion(void) { +void HMI_Motion() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_motion.inc(4)) Move_Highlight(1, select_motion.now); + if (select_motion.inc(1 + MOTION_CASE_TOTAL)) Move_Highlight(1, select_motion.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_motion.dec()) Move_Highlight(-1, select_motion.now); @@ -2898,26 +3165,28 @@ void HMI_Motion(void) { switch (select_motion.now) { case 0: // Back checkkey = Control; - select_control.set(2); + select_control.set(CONTROL_CASE_MOVE); index_control = MROWS; Draw_Control_Menu(); break; - case 1: // max speed + case MOTION_CASE_RATE: // Max speed checkkey = MaxSpeed; select_speed.reset(); Draw_Max_Speed_Menu(); break; - case 2: // max acceleration + case MOTION_CASE_ACCEL: // Max acceleration checkkey = MaxAcceleration; select_acc.reset(); Draw_Max_Accel_Menu(); break; - case 3: // max jerk speed - checkkey = MaxJerk; - select_jerk.reset(); - Draw_Max_Jerk_Menu(); - break; - case 4: // transmission ratio + #if HAS_CLASSIC_JERK + case MOTION_CASE_JERK: // Max jerk + checkkey = MaxJerk; + select_jerk.reset(); + Draw_Max_Jerk_Menu(); + break; + #endif + case MOTION_CASE_STEPS: // Steps per mm checkkey = Step; select_step.reset(); Draw_Steps_Menu(); @@ -2929,13 +3198,13 @@ void HMI_Motion(void) { } /* Info */ -void HMI_Info(void) { +void HMI_Info() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_ENTER) { #if HAS_ONESTEP_LEVELING checkkey = Control; - select_control.set(CONTROL_ITEMS); + select_control.set(CONTROL_CASE_INFO); Draw_Control_Menu(); #else select_page.set(3); @@ -2946,17 +3215,16 @@ void HMI_Info(void) { } /* Tune */ -void HMI_Tune(void) { +void HMI_Tune() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_tune.inc(6)) { + if (select_tune.inc(1 + TUNE_CASE_TOTAL)) { if (select_tune.now > MROWS && select_tune.now > index_tune) { index_tune = select_tune.now; Scroll_Menu(DWIN_SCROLL_UP); - Prepare_Item_Lang(5); } else { Move_Highlight(1, select_tune.now + MROWS - index_tune); @@ -2982,186 +3250,180 @@ void HMI_Tune(void) { Goto_PrintProcess(); } break; - case 1: // Print speed + case TUNE_CASE_SPEED: // Print speed checkkey = PrintSpeed; HMI_ValueStruct.print_speed = feedrate_percentage; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1 + MROWS - index_tune), feedrate_percentage); - EncoderRate.encoderRateEnabled = 1; - break; - #if HAS_HOTEND - case 2: // Nozzle temp - checkkey = ETemp; - HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2 + MROWS - index_tune), thermalManager.temp_hotend[0].target); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_HEATED_BED - case 3: // Bed temp - checkkey = BedTemp; - HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3 + MROWS - index_tune), thermalManager.temp_bed.target); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_FAN - case 4: // Fan speed - checkkey = FanSpeed; - HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(4 + MROWS - index_tune), thermalManager.fan_speed[0]); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - case 5: // Z-offset - checkkey = Homeoffset; - HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; - DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), feedrate_percentage); + EncoderRate.enabled = true; break; - case 6: // Language - // Select language - HMI_flag.language_chinese ^= true; - - Clear_Main_Window(); - - if (HMI_flag.language_chinese) { - HMI_SetAndSaveLanguageChinese(); - DWIN_JPG_CacheTo1(Language_Chinese); - } - else { - HMI_SetAndSaveLanguageWestern(); - DWIN_JPG_CacheTo1(Language_English); - } - - Draw_Tune_Menu(); + #if HAS_HOTEND + case TUNE_CASE_TEMP: // Nozzle temp + checkkey = ETemp; + HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); + EncoderRate.enabled = true; + break; + #endif + #if HAS_HEATED_BED + case TUNE_CASE_BED: // Bed temp + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); + EncoderRate.enabled = true; + break; + #endif + #if HAS_FAN + case TUNE_CASE_FAN: // Fan speed + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); + EncoderRate.enabled = true; + break; + #endif + #if HAS_ZOFFSET_ITEM + case TUNE_CASE_ZOFF: // Z-offset + #if EITHER(HAS_BED_PROBE, BABYSTEPPING) + checkkey = Homeoffset; + HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(TUNE_CASE_ZOFF + MROWS - index_tune), HMI_ValueStruct.offset_value); + EncoderRate.enabled = true; + #else + // Apply workspace offset, making the current position 0,0,0 + queue.inject_P(PSTR("G92 X0 Y0 Z0")); + HMI_AudioFeedback(); + #endif break; - + #endif default: break; } } DWIN_UpdateLCD(); } -/* PLA Preheat */ -void HMI_PLAPreheatSetting(void) { - ENCODER_DiffState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; +#if HAS_PREHEAT - // Avoid flicker by updating only the previous menu - if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_PLA.inc(4)) Move_Highlight(1, select_PLA.now); - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - if (select_PLA.dec()) Move_Highlight(-1, select_PLA.now); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - switch (select_PLA.now) { - case 0: // Back - checkkey = TemperatureID; - select_temp.now = 4; - HMI_ValueStruct.show_mode = -1; - Draw_Temperature_Menu(); - break; + /* PLA Preheat */ + void HMI_PLAPreheatSetting() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_PLA.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_PLA.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_PLA.dec()) Move_Highlight(-1, select_PLA.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_PLA.now) { + case 0: // Back + checkkey = TemperatureID; + select_temp.now = TEMP_CASE_PLA; + HMI_ValueStruct.show_mode = -1; + Draw_Temperature_Menu(); + break; #if HAS_HOTEND - case 1: // set nozzle temperature + case PREHEAT_CASE_TEMP: // Nozzle temperature checkkey = ETemp; HMI_ValueStruct.E_Temp = ui.material_preset[0].hotend_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), ui.material_preset[0].hotend_temp); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[0].hotend_temp); + EncoderRate.enabled = true; break; #endif #if HAS_HEATED_BED - case 2: // set bed temperature + case PREHEAT_CASE_BED: // Bed temperature checkkey = BedTemp; HMI_ValueStruct.Bed_Temp = ui.material_preset[0].bed_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), ui.material_preset[0].bed_temp); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[0].bed_temp); + EncoderRate.enabled = true; break; #endif #if HAS_FAN - case 3: // set fan speed + case PREHEAT_CASE_FAN: // Fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = ui.material_preset[0].fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), ui.material_preset[0].fan_speed); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[0].fan_speed); + EncoderRate.enabled = true; break; #endif - #if ENABLED(EEPROM_SETTINGS) - case 4: { // Save PLA configuration - const bool success = settings.save(); - HMI_AudioFeedback(success); - } break; - #endif - default: break; + #if ENABLED(EEPROM_SETTINGS) + case 4: { // Save PLA configuration + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + #endif + default: break; + } } + DWIN_UpdateLCD(); } - DWIN_UpdateLCD(); -} -/* ABS Preheat */ -void HMI_ABSPreheatSetting(void) { - ENCODER_DiffState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; + /* ABS Preheat */ + void HMI_ABSPreheatSetting() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; - // Avoid flicker by updating only the previous menu - if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_ABS.inc(4)) Move_Highlight(1, select_ABS.now); - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - switch (select_ABS.now) { - case 0: // Back - checkkey = TemperatureID; - select_temp.now = 5; - HMI_ValueStruct.show_mode = -1; - Draw_Temperature_Menu(); - break; + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_ABS.now) { + case 0: // Back + checkkey = TemperatureID; + select_temp.now = TEMP_CASE_ABS; + HMI_ValueStruct.show_mode = -1; + Draw_Temperature_Menu(); + break; #if HAS_HOTEND - case 1: // set nozzle temperature + case PREHEAT_CASE_TEMP: // Set nozzle temperature checkkey = ETemp; HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), ui.material_preset[1].hotend_temp); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[1].hotend_temp); + EncoderRate.enabled = true; break; #endif #if HAS_HEATED_BED - case 2: // set bed temperature + case PREHEAT_CASE_BED: // Set bed temperature checkkey = BedTemp; HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), ui.material_preset[1].bed_temp); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[1].bed_temp); + EncoderRate.enabled = true; break; #endif #if HAS_FAN - case 3: // set fan speed + case PREHEAT_CASE_FAN: // Set fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), ui.material_preset[1].fan_speed); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[1].fan_speed); + EncoderRate.enabled = true; break; #endif - #if ENABLED(EEPROM_SETTINGS) - case 4: { // save ABS configuration - const bool success = settings.save(); - HMI_AudioFeedback(success); - } break; - #endif - default: break; + #if ENABLED(EEPROM_SETTINGS) + case PREHEAT_CASE_SAVE: { // Save ABS configuration + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + #endif + default: break; + } } + DWIN_UpdateLCD(); } - DWIN_UpdateLCD(); -} + +#endif /* Max Speed */ -void HMI_MaxSpeed(void) { +void HMI_MaxSpeed() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_speed.inc(4)) Move_Highlight(1, select_speed.now); + if (select_speed.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_speed.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_speed.dec()) Move_Highlight(-1, select_speed.now); @@ -3169,14 +3431,14 @@ void HMI_MaxSpeed(void) { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (WITHIN(select_speed.now, 1, 4)) { checkkey = MaxSpeed_value; - HMI_flag.feedspeed_flag = AxisEnum(select_speed.now - 1); - HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[HMI_flag.feedspeed_flag]; + HMI_flag.feedspeed_axis = AxisEnum(select_speed.now - 1); + HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[HMI_flag.feedspeed_axis]; DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; } else { // Back checkkey = Motion; - select_motion.now = 1; + select_motion.now = MOTION_CASE_RATE; Draw_Motion_Menu(); } } @@ -3184,13 +3446,13 @@ void HMI_MaxSpeed(void) { } /* Max Acceleration */ -void HMI_MaxAcceleration(void) { +void HMI_MaxAcceleration() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_acc.inc(4)) Move_Highlight(1, select_acc.now); + if (select_acc.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_acc.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_acc.dec()) Move_Highlight(-1, select_acc.now); @@ -3198,57 +3460,59 @@ void HMI_MaxAcceleration(void) { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (WITHIN(select_acc.now, 1, 4)) { checkkey = MaxAcceleration_value; - HMI_flag.acc_flag = AxisEnum(select_acc.now - 1); - HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[HMI_flag.acc_flag]; + HMI_flag.acc_axis = AxisEnum(select_acc.now - 1); + HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[HMI_flag.acc_axis]; DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; } else { // Back checkkey = Motion; - select_motion.now = 2; + select_motion.now = MOTION_CASE_ACCEL; Draw_Motion_Menu(); } } DWIN_UpdateLCD(); } -/* Max Jerk */ -void HMI_MaxJerk(void) { - ENCODER_DiffState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; +#if HAS_CLASSIC_JERK + /* Max Jerk */ + void HMI_MaxJerk() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; - // Avoid flicker by updating only the previous menu - if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_jerk.inc(4)) Move_Highlight(1, select_jerk.now); - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - if (select_jerk.dec()) Move_Highlight(-1, select_jerk.now); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (WITHIN(select_jerk.now, 1, 4)) { - checkkey = MaxJerk_value; - HMI_flag.jerk_flag = AxisEnum(select_jerk.now - 1); - HMI_ValueStruct.Max_Jerk = planner.max_jerk[HMI_flag.jerk_flag] * MINUNITMULT; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); - EncoderRate.encoderRateEnabled = 1; + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_jerk.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_jerk.now); } - else { // Back - checkkey = Motion; - select_motion.now = 3; - Draw_Motion_Menu(); + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_jerk.dec()) Move_Highlight(-1, select_jerk.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (WITHIN(select_jerk.now, 1, 4)) { + checkkey = MaxJerk_value; + HMI_flag.jerk_axis = AxisEnum(select_jerk.now - 1); + HMI_ValueStruct.Max_Jerk = planner.max_jerk[HMI_flag.jerk_axis] * MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + EncoderRate.enabled = true; + } + else { // Back + checkkey = Motion; + select_motion.now = MOTION_CASE_JERK; + Draw_Motion_Menu(); + } } + DWIN_UpdateLCD(); } - DWIN_UpdateLCD(); -} +#endif // HAS_CLASSIC_JERK /* Step */ -void HMI_Step(void) { +void HMI_Step() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_step.inc(4)) Move_Highlight(1, select_step.now); + if (select_step.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_step.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_step.dec()) Move_Highlight(-1, select_step.now); @@ -3256,21 +3520,21 @@ void HMI_Step(void) { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (WITHIN(select_step.now, 1, 4)) { checkkey = Step_value; - HMI_flag.step_flag = AxisEnum(select_step.now - 1); - HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[HMI_flag.step_flag] * MINUNITMULT; + HMI_flag.step_axis = AxisEnum(select_step.now - 1); + HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[HMI_flag.step_axis] * MINUNITMULT; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; } else { // Back checkkey = Motion; - select_motion.now = 4; + select_motion.now = MOTION_CASE_STEPS; Draw_Motion_Menu(); } } DWIN_UpdateLCD(); } -void HMI_Init(void) { +void HMI_Init() { HMI_SDCardInit(); for (uint16_t t = 0; t <= 100; t += 2) { @@ -3283,13 +3547,13 @@ void HMI_Init(void) { HMI_SetLanguage(); } -void DWIN_Update(void) { +void DWIN_Update() { EachMomentUpdate(); // Status update HMI_SDCardUpdate(); // SD card update DWIN_HandleScreen(); // Rotary encoder update } -void EachMomentUpdate(void) { +void EachMomentUpdate() { static millis_t next_rts_update_ms = 0; const millis_t ms = millis(); if (PENDING(ms, next_rts_update_ms)) return; @@ -3300,9 +3564,9 @@ void EachMomentUpdate(void) { if (checkkey == PrintProcess) { // if print done - if (HMI_flag.print_finish && !HMI_flag.confirm_flag) { - HMI_flag.print_finish = 0; - HMI_flag.confirm_flag = 1; + if (HMI_flag.print_finish && !HMI_flag.done_confirm_flag) { + HMI_flag.print_finish = false; + HMI_flag.done_confirm_flag = true; TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); @@ -3313,7 +3577,7 @@ void EachMomentUpdate(void) { Draw_Print_ProgressBar(); // show print done confirm - DWIN_Draw_Rectangle(1, Background_black, 0, 250, 271, 360); + DWIN_Draw_Rectangle(1, Background_black, 0, 250, DWIN_WIDTH - 1, STATUS_Y); DWIN_ICON_Show(ICON, HMI_flag.language_chinese ? ICON_Confirm_C : ICON_Confirm_E, 86, 283); } else if (HMI_flag.pause_flag != printingIsPaused()) { @@ -3324,11 +3588,15 @@ void EachMomentUpdate(void) { } // pause after homing - if (pause_action_flag && printingIsPaused() && !planner.has_blocks_queued()) { - pause_action_flag = 0; + if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) { + HMI_flag.pause_action = false; #if ENABLED(PAUSE_HEAT) - tempbed = thermalManager.temp_bed.target; - temphot = thermalManager.temp_hotend[0].target; + #if HAS_HEATED_BED + tempbed = thermalManager.temp_bed.target; + #endif + #if HAS_HOTEND + temphot = thermalManager.temp_hotend[0].target; + #endif thermalManager.disable_all_heaters(); #endif queue.inject_P(PSTR("G1 F1200 X0 Y0")); @@ -3348,6 +3616,7 @@ void EachMomentUpdate(void) { duration_t elapsed = print_job_timer.duration(); // print timer // Print time so far + static uint16_t last_Printtime = 0; const uint16_t min = (elapsed.value % 3600) / 60; if (last_Printtime != min) { // 1 minute update last_Printtime = min; @@ -3356,14 +3625,14 @@ void EachMomentUpdate(void) { // Estimate remaining time every 20 seconds static millis_t next_remain_time_update = 0; - if (Percentrecord > 1 && ELAPSED(ms, next_remain_time_update) && HMI_flag.heat_flag == 0) { + if (Percentrecord > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) { remain_time = (elapsed.value - dwin_heat_time) / (Percentrecord * 0.01f) - (elapsed.value - dwin_heat_time); next_remain_time_update += 20 * 1000UL; Draw_Print_ProgressRemain(); } } - else if (abort_flag && !HMI_flag.home_flag) { // Print Stop - abort_flag = 0; + else if (dwin_abort_flag && !HMI_flag.home_flag) { // Print Stop + dwin_abort_flag = false; HMI_ValueStruct.print_speed = feedrate_percentage = 100; dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); @@ -3378,6 +3647,7 @@ void EachMomentUpdate(void) { } #if ENABLED(POWER_LOSS_RECOVERY) else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off + static bool recovery_flag = false; recovery.dwin_flag = false; recovery.load(); @@ -3403,8 +3673,8 @@ void EachMomentUpdate(void) { // with the active filename which can come from CardReader. card.getfilename_sorted(SD_ORDER(i, fileCnt)); if (!strcmp(card.filename, &recovery.info.sd_filename[1])) { // Resume print before power failure while have the same file - recovery_flag = 1; - HMI_flag.select_flag = 1; + recovery_flag = true; + HMI_flag.select_flag = true; Popup_Window_Resume(); draw_first_option(false); char * const name = card.longest_filename(); @@ -3422,7 +3692,7 @@ void EachMomentUpdate(void) { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_ENTER) { - recovery_flag = 0; + recovery_flag = false; if (HMI_flag.select_flag) break; TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); HMI_StartFrame(true); @@ -3445,7 +3715,7 @@ void EachMomentUpdate(void) { DWIN_UpdateLCD(); } -void DWIN_HandleScreen(void) { +void DWIN_HandleScreen() { switch (checkkey) { case MainMenu: HMI_MainMenu(); break; case SelectFile: HMI_SelectFile(); break; @@ -3459,8 +3729,10 @@ void DWIN_HandleScreen(void) { case Motion: HMI_Motion(); break; case Info: HMI_Info(); break; case Tune: HMI_Tune(); break; - case PLAPreheat: HMI_PLAPreheatSetting(); break; - case ABSPreheat: HMI_ABSPreheatSetting(); break; + #if HAS_PREHEAT + case PLAPreheat: HMI_PLAPreheatSetting(); break; + case ABSPreheat: HMI_ABSPreheatSetting(); break; + #endif case MaxSpeed: HMI_MaxSpeed(); break; case MaxAcceleration: HMI_MaxAcceleration(); break; case MaxJerk: HMI_MaxJerk(); break; @@ -3472,11 +3744,13 @@ void DWIN_HandleScreen(void) { case Extruder: HMI_Move_E(); break; case ETemp: HMI_ETemp(); break; #endif - case Homeoffset: HMI_Zoffset(); break; + #if EITHER(HAS_BED_PROBE, BABYSTEPPING) + case Homeoffset: HMI_Zoffset(); break; + #endif #if HAS_HEATED_BED case BedTemp: HMI_BedTemp(); break; #endif - #if HAS_FAN + #if HAS_PREHEAT case FanSpeed: HMI_FanSpeed(); break; #endif case PrintSpeed: HMI_PrintSpeed(); break; @@ -3488,11 +3762,11 @@ void DWIN_HandleScreen(void) { } } -void DWIN_CompletedHoming(void) { +void DWIN_CompletedHoming() { HMI_flag.home_flag = false; if (checkkey == Last_Prepare) { checkkey = Prepare; - select_prepare.now = 3; + select_prepare.now = PREPARE_CASE_HOME; index_prepare = MROWS; Draw_Prepare_Menu(); } @@ -3504,7 +3778,7 @@ void DWIN_CompletedHoming(void) { } } -void DWIN_CompletedLeveling(void) { +void DWIN_CompletedLeveling() { if (checkkey == Leveling) Goto_MainMenu(); } diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index abdf343a9ded..fedb87afdd81 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -29,9 +29,16 @@ #include "rotary_encoder.h" #include "../../../libs/BL24CXX.h" -#include +#include "../../../inc/MarlinConfigPre.h" -enum processID { +#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT + #define HAS_PREHEAT 1 + #if PREHEAT_COUNT < 2 + #error "Creality DWIN requires two material preheat presets." + #endif +#endif + +enum processID : uint8_t { // Process ID MainMenu, SelectFile, @@ -44,7 +51,7 @@ enum processID { Motion, Info, Tune, - #if HAS_HOTEND + #if HAS_PREHEAT PLAPreheat, ABSPreheat, #endif @@ -218,7 +225,7 @@ enum processID { #define BarFill_Color 0x10E4 // fill color of progress bar #define Select_Color 0x33BB // selected color -extern int checkkey, last_checkkey; +extern uint8_t checkkey; extern float zprobe_zoffset; extern char print_filename[16]; @@ -227,7 +234,7 @@ extern millis_t dwin_heat_time; typedef struct { TERN_(HAS_HOTEND, int16_t E_Temp = 0); TERN_(HAS_HEATED_BED, int16_t Bed_Temp = 0); - TERN_(HAS_FAN, int16_t Fan_speed = 0); + TERN_(HAS_PREHEAT, int16_t Fan_speed = 0); int16_t print_speed = 100; float Max_Feedspeed = 0; float Max_Acceleration = 0; @@ -236,7 +243,7 @@ typedef struct { float Move_X_scale = 0; float Move_Y_scale = 0; float Move_Z_scale = 0; - #if EXTRUDERS + #if HAS_HOTEND float Move_E_scale = 0; #endif float offset_value = 0; @@ -246,33 +253,27 @@ typedef struct { typedef struct { bool language_chinese; // 0: EN, 1: CN bool pause_flag:1; + bool pause_action:1; bool print_finish:1; - bool confirm_flag:1; + bool done_confirm_flag:1; bool select_flag:1; bool home_flag:1; bool heat_flag:1; // 0: heating done 1: during heating - #if HAS_HOTEND + #if ENABLED(PREVENT_COLD_EXTRUSION) bool ETempTooLow_flag:1; #endif #if HAS_LEVELING bool leveling_offset_flag:1; #endif #if HAS_FAN - AxisEnum feedspeed_flag; + AxisEnum feedspeed_axis; #endif - AxisEnum acc_flag; - AxisEnum jerk_flag; - AxisEnum step_flag; + AxisEnum acc_axis, jerk_axis, step_axis; } HMI_Flag; extern HMI_value_t HMI_ValueStruct; extern HMI_Flag HMI_flag; -// Language -void HMI_SetLanguage(void); -void HMI_SetAndSaveLanguageWestern(void); -void HMI_SetAndSaveLanguageChinese(void); - // Show ICO void ICON_Print(bool show); void ICON_Prepare(bool show); @@ -285,44 +286,47 @@ void ICON_Pause(bool show); void ICON_Continue(bool show); void ICON_Stop(bool show); -// Popup window tips +#if HAS_HOTEND || HAS_HEATED_BED + // Popup message window + void DWIN_Popup_Temperature(const bool toohigh); +#endif + #if HAS_HOTEND - void Popup_Window_Temperature(const bool toohigh); - void Popup_Window_ETempTooLow(void); + void Popup_Window_ETempTooLow(); #endif -void Popup_Window_Resume(void); -void Popup_Window_Home(void); -void Popup_Window_Leveling(void); +void Popup_Window_Resume(); +void Popup_Window_Home(const bool parking=false); +void Popup_Window_Leveling(); -void Goto_PrintProcess(void); -void Goto_MainMenu(void); +void Goto_PrintProcess(); +void Goto_MainMenu(); // Variable control -void HMI_Move_X(void); -void HMI_Move_Y(void); -void HMI_Move_Z(void); -void HMI_Move_E(void); +void HMI_Move_X(); +void HMI_Move_Y(); +void HMI_Move_Z(); +void HMI_Move_E(); -void HMI_Zoffset(void); +void HMI_Zoffset(); -TERN_(HAS_HOTEND, void HMI_ETemp(void)); -TERN_(HAS_HEATED_BED, void HMI_BedTemp(void)); -TERN_(HAS_FAN, void HMI_FanSpeed(void)); +TERN_(HAS_HOTEND, void HMI_ETemp()); +TERN_(HAS_HEATED_BED, void HMI_BedTemp()); +TERN_(HAS_FAN, void HMI_FanSpeed()); -void HMI_PrintSpeed(void); +void HMI_PrintSpeed(); -void HMI_MaxFeedspeedXYZE(void); -void HMI_MaxAccelerationXYZE(void); -void HMI_MaxJerkXYZE(void); -void HMI_StepXYZE(void); +void HMI_MaxFeedspeedXYZE(); +void HMI_MaxAccelerationXYZE(); +void HMI_MaxJerkXYZE(); +void HMI_StepXYZE(); -void update_variable(void); +void update_variable(); void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value); // SD Card -void HMI_SDCardInit(void); -void HMI_SDCardUpdate(void); +void HMI_SDCardInit(); +void HMI_SDCardUpdate(); // Main Process void Icon_print(bool value); @@ -333,32 +337,32 @@ void Icon_leveling(bool value); // Other bool Pause_HeatStatus(); void HMI_StartFrame(const bool with_update); // Startup screen -void HMI_MainMenu(void); // Main process screen -void HMI_SelectFile(void); // File page -void HMI_Printing(void); // Print page -void HMI_Prepare(void); // Prepare page -void HMI_Control(void); // Control page -void HMI_Leveling(void); // Level the page -void HMI_AxisMove(void); // Axis movement menu -void HMI_Temperature(void); // Temperature menu -void HMI_Motion(void); // Sports menu -void HMI_Info(void); // Information menu -void HMI_Tune(void); // Adjust the menu - -#if HAS_HOTEND - void HMI_PLAPreheatSetting(void); // PLA warm-up setting - void HMI_ABSPreheatSetting(void); // ABS warm-up setting +void HMI_MainMenu(); // Main process screen +void HMI_SelectFile(); // File page +void HMI_Printing(); // Print page +void HMI_Prepare(); // Prepare page +void HMI_Control(); // Control page +void HMI_Leveling(); // Level the page +void HMI_AxisMove(); // Axis movement menu +void HMI_Temperature(); // Temperature menu +void HMI_Motion(); // Sports menu +void HMI_Info(); // Information menu +void HMI_Tune(); // Adjust the menu + +#if HAS_PREHEAT + void HMI_PLAPreheatSetting(); // PLA warm-up setting + void HMI_ABSPreheatSetting(); // ABS warm-up setting #endif -void HMI_MaxSpeed(void); // Maximum speed submenu -void HMI_MaxAcceleration(void); // Maximum acceleration submenu -void HMI_MaxJerk(void); // Maximum jerk speed submenu -void HMI_Step(void); // Transmission ratio +void HMI_MaxSpeed(); // Maximum speed submenu +void HMI_MaxAcceleration(); // Maximum acceleration submenu +void HMI_MaxJerk(); // Maximum jerk speed submenu +void HMI_Step(); // Transmission ratio -void HMI_Init(void); -void DWIN_Update(void); -void EachMomentUpdate(void); -void DWIN_HandleScreen(void); +void HMI_Init(); +void DWIN_Update(); +void EachMomentUpdate(); +void DWIN_HandleScreen(); -void DWIN_CompletedHoming(void); -void DWIN_CompletedLeveling(void); +void DWIN_CompletedHoming(); +void DWIN_CompletedLeveling(); diff --git a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp index dbbd356eff2d..b1d905d9adcd 100644 --- a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp +++ b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp @@ -124,7 +124,7 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) { int32_t encoderMultiplier = 1; // if must encoder rati multiplier - if (EncoderRate.encoderRateEnabled) { + if (EncoderRate.enabled) { const float abs_diff = ABS(temp_diff), encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP); if (EncoderRate.lastEncoderTime) { diff --git a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h index fb8102f8b22a..93e54839d625 100644 --- a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h +++ b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h @@ -44,7 +44,7 @@ #define BUTTON_PRESSED(BN) !READ(BTN_## BN) typedef struct { - bool encoderRateEnabled = 0; + bool enabled = false; int encoderMoveValue = 0; millis_t lastEncoderTime = 0; } ENCODER_Rate; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e0fa6fa98f53..d2145bcc804a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -576,7 +576,7 @@ volatile bool Temperature::raw_temps_ready = false; #define MAX_CYCLE_TIME_PID_AUTOTUNE 20L #endif if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) { - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); break; @@ -812,12 +812,16 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms } void Temperature::max_temp_error(const heater_id_t heater_id) { - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(1)); + #if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED) + DWIN_Popup_Temperature(1); + #endif _temp_error(heater_id, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP)); } void Temperature::min_temp_error(const heater_id_t heater_id) { - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + #if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED) + DWIN_Popup_Temperature(0); + #endif _temp_error(heater_id, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP)); } @@ -1055,7 +1059,7 @@ void Temperature::manage_heater() { // Make sure temperature is increasing if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder? if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough? - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); } else // Start again if the target is still far off @@ -1098,7 +1102,7 @@ void Temperature::manage_heater() { // Make sure temperature is increasing if (watch_bed.elapsed(ms)) { // Time to check the bed? if (degBed() < watch_bed.target) { // Failed to increase enough? - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); _temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); } else // Start again if the target is still far off @@ -2023,7 +2027,7 @@ void Temperature::init() { state = TRRunaway; case TRRunaway: - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); _temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY)); } } @@ -2440,14 +2444,8 @@ void Temperature::tick() { #if DISABLED(SLOW_PWM_HEATERS) - #if HAS_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER - constexpr uint8_t pwm_mask = - #if ENABLED(SOFT_PWM_DITHER) - _BV(SOFT_PWM_SCALE) - 1 - #else - 0 - #endif - ; + #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_HEATED_CHAMBER, FAN_SOFT_PWM) + constexpr uint8_t pwm_mask = TERN0(SOFT_PWM_DITHER, _BV(SOFT_PWM_SCALE) - 1); #define _PWM_MOD(N,S,T) do{ \ const bool on = S.add(pwm_mask, T.soft_pwm_amount); \ WRITE_HEATER_##N(on); \ diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index c41027003e9e..e27e628b9a0d 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -89,10 +89,6 @@ #define HAS_GCODE_M876 #endif -#if PREHEAT_COUNT - #define HAS_PREHEAT_COUNT -#endif - #if EXTRUDERS #define HAS_EXTRUDERS #if EXTRUDERS > 1 diff --git a/platformio.ini b/platformio.ini index d0a4cb7b10ea..bf43936df682 100644 --- a/platformio.ini +++ b/platformio.ini @@ -153,7 +153,6 @@ default_src_filter = + - - + - - - - - - - - @@ -330,7 +329,6 @@ HOST_KEEPALIVE_FEATURE = src_filter=+ REPETIER_GCODE_M360 = src_filter=+ HAS_GCODE_M876 = src_filter=+ HAS_RESUME_CONTINUE = src_filter=+ -HAS_PREHEAT_COUNT = src_filter=+ HAS_LCD_CONTRAST = src_filter=+ LCD_SET_PROGRESS_MANUALLY = src_filter=+ TOUCH_SCREEN_CALIBRATION = src_filter=+ From 24d8daa01bfbb18b039045775f8fc7a33608d923 Mon Sep 17 00:00:00 2001 From: deram Date: Thu, 17 Sep 2020 13:41:13 +0300 Subject: [PATCH 05/63] SHOW_REMAINING_TIME for HD44780 character LCD (#19416) --- Marlin/Configuration_adv.h | 31 +++++++++++---------- Marlin/src/inc/SanityCheck.h | 6 ++-- Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp | 29 ++++++++++++++++--- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d46ba55a922e..214bf4afdda1 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1105,23 +1105,26 @@ #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) #endif -#if HAS_GRAPHICAL_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) - //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits - //#define SHOW_REMAINING_TIME // Display estimated time to completion +#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && (HAS_GRAPHICAL_LCD || HAS_CHARACTER_LCD) + //#define SHOW_REMAINING_TIME // Display estimated time to completion #if ENABLED(SHOW_REMAINING_TIME) - //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation - //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time + //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation + //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time + #endif + + #if HAS_GRAPHICAL_LCD + //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits #endif -#endif -#if HAS_CHARACTER_LCD && EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) - //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing - #if ENABLED(LCD_PROGRESS_BAR) - #define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar - #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message - #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever) - //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it - //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar + #if HAS_CHARACTER_LCD + //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing + #if ENABLED(LCD_PROGRESS_BAR) + #define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar + #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message + #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever) + //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it + //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar + #endif #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1ee082720d7d..9f15d7e5e3e3 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -692,8 +692,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif PROGRESS_MSG_EXPIRE < 0 #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." #endif -#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_GRAPHICAL_LCD, HAS_GRAPHICAL_TFT, EXTENSIBLE_UI) - #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Graphical LCD, TFT, or EXTENSIBLE_UI." +#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_GRAPHICAL_LCD, HAS_GRAPHICAL_TFT, HAS_CHARACTER_LCD, EXTENSIBLE_UI) + #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, or EXTENSIBLE_UI." #endif #if !HAS_LCD_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) @@ -3055,8 +3055,6 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #if !HAS_GRAPHICAL_LCD #if ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) #error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD." - #elif ENABLED(SHOW_REMAINING_TIME) - #error "SHOW_REMAINING_TIME currently requires a Graphical LCD." #endif #endif diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp index 0a1177d63ee9..3dc0925b432f 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp @@ -845,10 +845,31 @@ void MarlinUI::draw_status_screen() { lcd_put_wchar('%'); char buffer[14]; - duration_t elapsed = print_job_timer.duration(); - const uint8_t len = elapsed.toDigital(buffer), - timepos = LCD_WIDTH - len - 1; - lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]); + uint8_t timepos = 0; + #if ENABLED(SHOW_REMAINING_TIME) + const bool show_remain = TERN1(ROTATE_PROGRESS_DISPLAY, blink) && (printingIsActive() || marlin_state == MF_SD_COMPLETE); + if (show_remain) { + #if ENABLED(USE_M73_REMAINING_TIME) + duration_t remaining = get_remaining_time(); + #else + uint8_t progress = get_progress_percent(); + uint32_t elapsed = print_job_timer.duration(); + duration_t remaining = (progress > 0) ? ((elapsed * 25600 / progress) >> 8) - elapsed : 0; + #endif + const uint8_t len = remaining.toDigital(buffer); + timepos = LCD_WIDTH - 1 - len; + lcd_put_wchar(timepos, 2, 'R'); + } + #else + constexpr bool show_remain = false; + #endif + + if (!show_remain) { + duration_t elapsed = print_job_timer.duration(); + const uint8_t len = elapsed.toDigital(buffer); + timepos = LCD_WIDTH - 1 - len; + lcd_put_wchar(timepos, 2, LCD_STR_CLOCK[0]); + } lcd_put_u8str(buffer); #if LCD_WIDTH >= 20 From c539254101f33b0782dca6fa7e00275e033c6ba3 Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Mon, 14 Sep 2020 16:32:54 -0600 Subject: [PATCH 06/63] Add warning to ExtUI Bed Mesh Screen. (#19397) - Show a warning on the Mesh Bed Leveling screen if some points aren't probed. --- .../ftdi_eve_touch_ui/language/language_en.h | 1 + .../screens/bed_mesh_screen.cpp | 27 ++++++-- .../ftdi_eve_touch_ui/screens/screen_data.h | 64 ++++++++++--------- .../lib/ftdi_eve_touch_ui/screens/screens.h | 1 + 4 files changed, 58 insertions(+), 35 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h index e465aa0b93a7..bd64032729fd 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h @@ -145,6 +145,7 @@ namespace Language_en { PROGMEM Language_Str MSG_TOUCH_CALIBRATION_PROMPT = u8"Touch the dots to calibrate"; PROGMEM Language_Str MSG_AUTOLEVEL_X_AXIS = u8"Level X Axis"; PROGMEM Language_Str MSG_BED_MAPPING_DONE = u8"Bed mapping finished"; + PROGMEM Language_Str MSG_BED_MAPPING_INCOMPLETE = u8"Not all points probed"; PROGMEM Language_Str MSG_LEVELING = u8"Leveling"; PROGMEM Language_Str MSG_SHOW_MESH = u8"Show Bed Mesh"; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp index eea2268c5b9c..5f7c8d3b9990 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp @@ -223,7 +223,7 @@ bool BedMeshScreen::tagToPoint(uint8_t tag, uint8_t &x, uint8_t &y) { void BedMeshScreen::onEntry() { screen_data.BedMeshScreen.highlightedTag = 0; screen_data.BedMeshScreen.count = GRID_MAX_POINTS; - screen_data.BedMeshScreen.showMappingDone = false; + screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_NONE; BaseScreen::onEntry(); } @@ -253,8 +253,10 @@ void BedMeshScreen::drawHighlightedPointValue() { .tag(1).button( OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY)) .tag(0); - if (screen_data.BedMeshScreen.showMappingDone) { - cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE)); + switch(screen_data.BedMeshScreen.message) { + case screen_data.BedMeshScreen.MSG_MESH_COMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE)); break; + case screen_data.BedMeshScreen.MSG_MESH_INCOMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE)); break; + default: break; } } @@ -307,15 +309,30 @@ void BedMeshScreen::onMeshUpdate(const int8_t, const int8_t, const float) { onRefresh(); } +bool BedMeshScreen::isMeshComplete(ExtUI::bed_mesh_t data) { + for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { + for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { + if (isnan(data[x][y])) { + return false; + } + } + } + return true; +} + void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { switch(state) { case ExtUI::MESH_START: screen_data.BedMeshScreen.count = 0; - screen_data.BedMeshScreen.showMappingDone = false; + screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_NONE; break; case ExtUI::MESH_FINISH: + if (screen_data.BedMeshScreen.count == GRID_MAX_POINTS && isMeshComplete(ExtUI::getMeshArray())) { + screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_MESH_COMPLETE; + } else { + screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_MESH_INCOMPLETE; + } screen_data.BedMeshScreen.count = GRID_MAX_POINTS; - screen_data.BedMeshScreen.showMappingDone = true; break; case ExtUI::PROBE_START: screen_data.BedMeshScreen.highlightedTag = pointToTag(x, y); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h index 39e9ce4bc568..a274fef9e747 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h @@ -52,42 +52,46 @@ union screen_data_t { uint8_t num_page; uint8_t cur_page; #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) - uint16_t scroll_pos; - uint16_t scroll_max; + uint16_t scroll_pos; + uint16_t scroll_max; #endif } FilesScreen; struct { struct base_numeric_adjustment_t placeholder; float e_rel[ExtUI::extruderCount]; } MoveAxisScreen; -#if HAS_MESH - struct { - bool showMappingDone; - uint8_t count; - uint8_t highlightedTag; - } BedMeshScreen; -#endif -#if ENABLED(TOUCH_UI_DEVELOPER_MENU) - struct { - uint32_t next_watchdog_trigger; - const char* message; - } StressTestScreen; -#endif -#if ENABLED(TOUCH_UI_COCOA_PRESS) - struct { - uint32_t start_ms; - } PreheatTimerScreen; -#endif -#if ENABLED(BABYSTEPPING) - struct { - struct base_numeric_adjustment_t placeholder; - xyz_int_t rel; - #if EXTRUDERS > 1 - bool link_nozzles; - #endif - bool show_offsets; - } NudgeNozzleScreen; -#endif + #if HAS_MESH + struct { + enum : uint8_t { + MSG_NONE, + MSG_MESH_COMPLETE, + MSG_MESH_INCOMPLETE + } message; + uint8_t count; + uint8_t highlightedTag; + } BedMeshScreen; + #endif + #if ENABLED(TOUCH_UI_DEVELOPER_MENU) + struct { + uint32_t next_watchdog_trigger; + const char* message; + } StressTestScreen; + #endif + #if ENABLED(TOUCH_UI_COCOA_PRESS) + struct { + uint32_t start_ms; + } PreheatTimerScreen; + #endif + #if ENABLED(BABYSTEPPING) + struct { + struct base_numeric_adjustment_t placeholder; + xyz_int_t rel; + #if EXTRUDERS > 1 + bool link_nozzles; + #endif + bool show_offsets; + } NudgeNozzleScreen; + #endif }; extern screen_data_t screen_data; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h index ec8df2760789..b425c4fa45fb 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h @@ -533,6 +533,7 @@ class StepsScreen : public BaseNumericAdjustmentScreen, public CachedScreen Date: Thu, 17 Sep 2020 07:52:47 -0300 Subject: [PATCH 07/63] Fix MKS UI SPI flash typo (#19410) --- Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp b/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp index 9d3adc1bab93..ad116d5045df 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp @@ -221,7 +221,7 @@ void SPIFlashStorage::flushPage() { #if HAS_SPI_FLASH_COMPRESSION // Restart the compressed buffer, keep the pointers of the uncompressed buffer m_compressedDataUsed = 0; - #elif + #else m_pageDataUsed = 0; #endif m_currentPage++; From da1a60aeb6b1701941066d3e5a9abd62b5551526 Mon Sep 17 00:00:00 2001 From: jahartley <52391697+jahartley@users.noreply.github.com> Date: Thu, 17 Sep 2020 07:01:10 -0400 Subject: [PATCH 08/63] Expose JOYSTICK_DEBUG to the general user (#19394) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 1 + Marlin/src/feature/joystick.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 214bf4afdda1..35b1dcc563ef 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3339,6 +3339,7 @@ #define JOY_X_LIMITS { 5600, 8190-100, 8190+100, 10800 } // min, deadzone start, deadzone end, max #define JOY_Y_LIMITS { 5600, 8250-100, 8250+100, 11000 } #define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 } + //#define JOYSTICK_DEBUG #endif /** diff --git a/Marlin/src/feature/joystick.h b/Marlin/src/feature/joystick.h index ca46834578cc..1d25a30cc24d 100644 --- a/Marlin/src/feature/joystick.h +++ b/Marlin/src/feature/joystick.h @@ -30,8 +30,6 @@ #include "../core/macros.h" #include "../module/temperature.h" -//#define JOYSTICK_DEBUG - class Joystick { friend class Temperature; private: From 62206c03864746456f09767d4af351820b30a43a Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Thu, 17 Sep 2020 07:36:21 -0400 Subject: [PATCH 09/63] Host Action: Start (#19398) --- Marlin/src/feature/host_actions.cpp | 3 +++ Marlin/src/feature/host_actions.h | 3 +++ Marlin/src/inc/Conditionals_adv.h | 3 +++ Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/menu/menu_main.cpp | 8 ++++++++ 5 files changed, 18 insertions(+) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index 9539c82b6454..30126392207d 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -62,6 +62,9 @@ void host_action(PGM_P const pstr, const bool eol) { #ifdef ACTION_ON_CANCEL void host_action_cancel() { host_action(PSTR(ACTION_ON_CANCEL)); } #endif +#ifdef ACTION_ON_START + void host_action_start() { host_action(PSTR(ACTION_ON_START)); } +#endif #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index a6ad2c048505..09eeed23e215 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -44,6 +44,9 @@ void host_action(PGM_P const pstr, const bool eol=true); #ifdef ACTION_ON_CANCEL void host_action_cancel(); #endif +#ifdef ACTION_ON_START + void host_action_start(); +#endif #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index ff13d2897df2..73e034d05f2f 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -196,6 +196,9 @@ #ifndef ACTION_ON_CANCEL #define ACTION_ON_CANCEL "cancel" #endif + #ifndef ACTION_ON_START + #define ACTION_ON_START "start" + #endif #ifndef ACTION_ON_KILL #define ACTION_ON_KILL "poweroff" #endif diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index fc9e065abe0d..04c58fd22a1d 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -366,6 +366,7 @@ namespace Language_en { PROGMEM Language_Str MSG_PAUSING = _UxGT("Pausing..."); PROGMEM Language_Str MSG_PAUSE_PRINT = _UxGT("Pause Print"); PROGMEM Language_Str MSG_RESUME_PRINT = _UxGT("Resume Print"); + PROGMEM Language_Str MSG_HOST_START_PRINT = _UxGT("Host Start"); PROGMEM Language_Str MSG_STOP_PRINT = _UxGT("Stop Print"); PROGMEM Language_Str MSG_PRINTING_OBJECT = _UxGT("Printing Object"); PROGMEM Language_Str MSG_CANCEL_OBJECT = _UxGT("Cancel Object"); diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 8908f49fb22f..334d998d5c6f 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -54,6 +54,10 @@ #include "../../feature/password/password.h" #endif +#ifdef ACTION_ON_START + #include "../../feature/host_actions.h" +#endif + void menu_tune(); void menu_cancelobject(); void menu_motion(); @@ -158,6 +162,10 @@ void menu_main() { if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print); + #ifdef ACTION_ON_START + ACTION_ITEM(MSG_HOST_START_PRINT, host_action_start); + #endif + SUBMENU(MSG_MOTION, menu_motion); } From 5b56d6698a2a9b78a5dd40446bcb606cbfff010d Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Thu, 17 Sep 2020 08:52:21 -0300 Subject: [PATCH 10/63] Move screen for Color UI (#19386) --- .../src/lcd/tft/bitmaps/btn_64x52_rounded.bmp | Bin 0 -> 10040 bytes Marlin/src/lcd/tft/bitmaps/home.bmp | Bin 0 -> 12344 bytes .../lcd/tft/images/btn_rounded_64x52x4.cpp | 82 ++++ Marlin/src/lcd/tft/images/home_64x64x4.cpp | 94 ++++ Marlin/src/lcd/tft/tft_color.h | 10 +- Marlin/src/lcd/tft/tft_image.cpp | 2 + Marlin/src/lcd/tft/tft_image.h | 6 + Marlin/src/lcd/tft/touch.cpp | 11 + Marlin/src/lcd/tft/touch.h | 5 + Marlin/src/lcd/tft/ui_320x240.cpp | 3 + Marlin/src/lcd/tft/ui_320x240.h | 2 + Marlin/src/lcd/tft/ui_480x320.cpp | 435 ++++++++++++++++++ Marlin/src/lcd/tft/ui_480x320.h | 2 + Marlin/src/lcd/ultralcd.h | 4 + .../src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 12 +- 15 files changed, 662 insertions(+), 6 deletions(-) create mode 100644 Marlin/src/lcd/tft/bitmaps/btn_64x52_rounded.bmp create mode 100644 Marlin/src/lcd/tft/bitmaps/home.bmp create mode 100644 Marlin/src/lcd/tft/images/btn_rounded_64x52x4.cpp create mode 100644 Marlin/src/lcd/tft/images/home_64x64x4.cpp diff --git a/Marlin/src/lcd/tft/bitmaps/btn_64x52_rounded.bmp b/Marlin/src/lcd/tft/bitmaps/btn_64x52_rounded.bmp new file mode 100644 index 0000000000000000000000000000000000000000..04e879dbb0d8ff6406b5808f0e3cdcba32af85fb GIT binary patch literal 10040 zcmeI2OG{fp7>3jSh|)h$+8`{3Z=(1tRbAyb?WP7Gfr@bKp5=9e}B%<=JYp-`X^Spq6*ZEf{T zAfE59&HO1y*4EapudhMf*w|nTQH9_?KR+i)nXC(|LltPQ3AtT0kh0koJN0ntyGLO`m0b?eomvmyjChk8vRwM zDnF;uUtTK}BaQwlRF$98=r6C8ijhWt6{^b5`9k#9_W3zr*3;&O&!08-FaE*rbUHC* zboP&g&nxt|{3HB3k-?h86k}1axv`LhQ%}7FUDL!64B}J+V1m~2@9(`m#PC9oE_lU-e1v;&S((*q1( zK*HMvwN|TvD*S6qy;7+}^6Kh}O``Mp0S*aZ@`Ad)zHXf#5Pv(4j*iIVUvF=3W2Djo zEP*BmArK!Y9b+9lAgk3X%Cn=y`3?A4fEK_zZPUI$()k3bX@R31T4SHSfVObmiN zM7RhNo>A~3M`FT(1aA;dcpwB8O-K|Fi0&5(n@;sicTZ2x4D3<~Jyq2;e|`Voe^>qW z5AlCQ{O;H-;ao%bi{1PC$?+RChvR4N|N4vg+wI`;=+UFU4{ZVduR~t2{o&O>IF1?q zJ0^;u91}9`7z$AjFvHKJ4Gj%D0)<@+BoDd@(vYn(>kZ(WL+6$&=^LpU=w5LKI)o z0!uym{K6%|!ouR?F(~neEG685&V?X zr%z8!O_>w({mq*<7cX9v-O#2#Gm)>-Gf;a$Z6Kr)&>Oyy?XV^6|mIrFMjr~;NW0FRsuf^ zP9f|hsy}}GcxY%SL9)c@s_8HOZ{NN>e*8EsEiF4cTRE$xq@>WCpPzR{tL?YOPs~pd zF%lIE>yMViT93rP%jM*7t;BB(P!8$5cc^f1_~F5l6bN0#pWG7X>!PBf8#iw7>Kzb% zz~E<1D=aM39__I|ivwfo>gpmRBYE`*c<^4%ZX6%D>u&sG&0DnJ!he{ZRSQd|rltl4 z26DR3$jBf;Ap#QdAQ&?%F4=|oSdenCivUi+qLq&-2?x_ zhYztT>lkYnXV|5srNza?7cX9r$-y_&{2VjUZfgy*(gx~|Do{0!vFd6X9)}y7)d@v>i0pjwY8Pp{@B=b$`$;~%nYbXYD@6*AW)&8pulOWVQXuP7vEFVDX!Jbn69AD&lIfmib%1Qmqa=vZEYm-zjwLQ6{vmLDA* zb>%i%crCxbR1j{{-{0>RyiFH@wANq$8 z#j55jHu5Vfz{!S1HkBMK8NB7?WzL3VENzEpMtk{%3gl;?C0EZc4s2fJkkN>%I&Wj% z!ulg^=NHp)WZ>5j{(Fa98Oc>~g3u?icGpY%)?h4r>p#G6LF)tcmBar3^A5+qc0^VJ literal 0 HcmV?d00001 diff --git a/Marlin/src/lcd/tft/images/btn_rounded_64x52x4.cpp b/Marlin/src/lcd/tft/images/btn_rounded_64x52x4.cpp new file mode 100644 index 000000000000..69a045d85af1 --- /dev/null +++ b/Marlin/src/lcd/tft/images/btn_rounded_64x52x4.cpp @@ -0,0 +1,82 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if HAS_GRAPHICAL_TFT + +extern const uint8_t btn_rounded_64x52x4[1664] = { + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x88, + 0x88, 0x88, 0x79, 0xce, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xeb, 0x87, 0x77, 0x78, + 0x88, 0x78, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x66, 0x78, + 0x88, 0x8d, 0xff, 0xb8, 0x54, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x45, 0x7b, 0xff, 0xc6, 0x67, + 0x87, 0xbf, 0xf7, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x6f, 0xf9, 0x56, + 0x87, 0xef, 0x84, 0x44, 0x45, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x58, 0xfd, 0x46, + 0x87, 0xff, 0x54, 0x44, 0x56, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xff, 0x45, + 0x87, 0xff, 0x44, 0x45, 0x67, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x76, 0xff, 0x45, + 0x87, 0xff, 0x44, 0x56, 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x77, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x77, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xff, 0x44, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0xff, 0x44, + 0x87, 0xef, 0x84, 0x56, 0x77, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7a, 0xfe, 0x44, + 0x87, 0xaf, 0xf6, 0x56, 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x77, 0x9f, 0xf9, 0x44, + 0x87, 0x7d, 0xff, 0xb8, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x78, 0x9c, 0xff, 0xd4, 0x45, + 0x87, 0x76, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x54, 0x45, + 0x87, 0x76, 0x56, 0xad, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0x64, 0x44, 0x46, + 0x87, 0x77, 0x65, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x56, + 0x88, 0x77, 0x76, 0x55, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x55, 0x67, + 0x88, 0x77, 0x77, 0x66, 0x65, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56, 0x66, 0x78, + 0x88, 0x88, 0x77, 0x77, 0x76, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x67, 0x77, 0x78, +}; + +#endif // HAS_GRAPHICAL_TFT diff --git a/Marlin/src/lcd/tft/images/home_64x64x4.cpp b/Marlin/src/lcd/tft/images/home_64x64x4.cpp new file mode 100644 index 000000000000..107c76e54ef3 --- /dev/null +++ b/Marlin/src/lcd/tft/images/home_64x64x4.cpp @@ -0,0 +1,94 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if HAS_GRAPHICAL_TFT + +extern const uint8_t home_64x64x4[2048] = { + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0x77, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x67, 0x88, 0x76, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9d, 0xff, 0xea, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xeb, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x40, 0xbf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf6, 0x54, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x57, 0xff, 0x80, 0xaf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xf9, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0x90, 0xaf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xff, 0xff, 0xf9, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0xaf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0xaf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0xaf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0xbf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0xaf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0xaf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xa, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, 0x88, + 0x88, 0x86, 0x9f, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0xaf, 0xff, 0xff, 0xfc, 0x67, 0x88, 0x88, + 0x88, 0x69, 0xff, 0xff, 0xff, 0xf5, 0x6f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xb, 0xff, 0xff, 0xff, 0xc6, 0x78, 0x88, + 0x87, 0x7f, 0xff, 0xff, 0xff, 0x66, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x90, 0xbf, 0xff, 0xff, 0xfb, 0x68, 0x88, + 0x87, 0x7f, 0xff, 0xff, 0xf7, 0x3c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0xb, 0xff, 0xff, 0xfd, 0x67, 0x88, + 0x87, 0x3d, 0xff, 0xff, 0x75, 0x59, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x30, 0xbf, 0xff, 0xfa, 0x68, 0x88, + 0x88, 0x44, 0xce, 0xd7, 0x58, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x74, 0x19, 0xee, 0xa6, 0x88, 0x88, + 0x88, 0x73, 0x24, 0x56, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x52, 0x35, 0x68, 0x88, 0x88, + 0x88, 0x87, 0x66, 0x78, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x87, 0x67, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0x55, 0x55, 0x55, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x92, 0x44, 0x44, 0x44, 0x12, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x77, 0x88, 0x88, 0x88, 0x72, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x97, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x49, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x64, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0x88, 0x88, 0x88, 0x84, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb6, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x83, 0x4c, 0xee, 0xee, 0xee, 0xee, 0xee, 0xff, 0x97, 0x88, 0x88, 0x88, 0x84, 0xae, 0xee, 0xee, 0xee, 0xee, 0xee, 0xea, 0x67, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0x32, 0x44, 0x44, 0x44, 0x44, 0x33, 0x57, 0x88, 0x88, 0x88, 0x88, 0x86, 0x43, 0x34, 0x44, 0x44, 0x44, 0x34, 0x55, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x76, 0x55, 0x55, 0x55, 0x55, 0x55, 0x67, 0x88, 0x88, 0x88, 0x88, 0x87, 0x65, 0x55, 0x55, 0x55, 0x55, 0x56, 0x78, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 +}; + +#endif // HAS_GRAPHICAL_TFT diff --git a/Marlin/src/lcd/tft/tft_color.h b/Marlin/src/lcd/tft/tft_color.h index d2c5d8e7db7e..14906a1bcf66 100644 --- a/Marlin/src/lcd/tft/tft_color.h +++ b/Marlin/src/lcd/tft/tft_color.h @@ -42,6 +42,7 @@ #define COLOR_SCARLET 0xF904 // #FF2020 #define COLOR_LIME 0x7E00 // #00FF00 #define COLOR_BLUE 0x001F // #0000FF +#define COLOR_LIGHT_BLUE 0x061F // #00C3FF #define COLOR_YELLOW 0xFFE0 // #FFFF00 #define COLOR_MAGENTA 0xF81F // #FF00FF #define COLOR_FUCHSIA 0xF81F // #FF00FF @@ -66,10 +67,11 @@ #define COLOR_DARK_PURPLE 0x9930 // #992380 - -#define COLOR_BACKGROUND 0x20AC // #1E156E -#define COLOR_SELECTION_BG 0x9930 // #992380 -#define COLOR_WEBSITE_URL 0x03B7 +#ifndef COLOR_BACKGROUND + #define COLOR_BACKGROUND 0x20AC // #1E156E +#endif +#define COLOR_SELECTION_BG 0x9930 // #992380 +#define COLOR_WEBSITE_URL 0x03B7 #define COLOR_INACTIVE COLOR_GREY #define COLOR_COLD COLOR_AQUA diff --git a/Marlin/src/lcd/tft/tft_image.cpp b/Marlin/src/lcd/tft/tft_image.cpp index ff60bee9a9df..27749cb7f3ae 100644 --- a/Marlin/src/lcd/tft/tft_image.cpp +++ b/Marlin/src/lcd/tft/tft_image.cpp @@ -45,6 +45,8 @@ const tImage Fan_Slow1_64x64x4 = { (void *)fan_slow1_64x64x4, 64, 64, GREYS const tImage Fan_Fast0_64x64x4 = { (void *)fan_fast0_64x64x4, 64, 64, GREYSCALE4 }; const tImage Fan_Fast1_64x64x4 = { (void *)fan_fast1_64x64x4, 64, 64, GREYSCALE4 }; const tImage SD_64x64x4 = { (void *)sd_64x64x4, 64, 64, GREYSCALE4 }; +const tImage Home_64x64x4 = { (void *)home_64x64x4, 64, 64, GREYSCALE4 }; +const tImage BtnRounded_64x52x4 = { (void *)btn_rounded_64x52x4, 64, 52, GREYSCALE4 }; const tImage Menu_64x64x4 = { (void *)menu_64x64x4, 64, 64, GREYSCALE4 }; const tImage Settings_64x64x4 = { (void *)settings_64x64x4, 64, 64, GREYSCALE4 }; const tImage Confirm_64x64x4 = { (void *)confirm_64x64x4, 64, 64, GREYSCALE4 }; diff --git a/Marlin/src/lcd/tft/tft_image.h b/Marlin/src/lcd/tft/tft_image.h index cf48065968b1..1f13967ba248 100644 --- a/Marlin/src/lcd/tft/tft_image.h +++ b/Marlin/src/lcd/tft/tft_image.h @@ -39,6 +39,8 @@ extern const uint8_t fan0_64x64x4[], fan1_64x64x4[]; extern const uint8_t fan_slow0_64x64x4[], fan_slow1_64x64x4[]; extern const uint8_t fan_fast0_64x64x4[], fan_fast1_64x64x4[]; extern const uint8_t sd_64x64x4[]; +extern const uint8_t home_64x64x4[]; +extern const uint8_t btn_rounded_64x52x4[]; extern const uint8_t menu_64x64x4[]; extern const uint8_t settings_64x64x4[]; extern const uint8_t confirm_64x64x4[]; @@ -90,6 +92,8 @@ enum MarlinImage : uint8_t { imgRefresh, imgLeveling, imgSlider, + imgHome, + imgBtn52Rounded, imgCount, noImage = imgCount, imgPageUp = imgLeft, @@ -136,6 +140,8 @@ extern const tImage Fan_Slow1_64x64x4; extern const tImage Fan_Fast0_64x64x4; extern const tImage Fan_Fast1_64x64x4; extern const tImage SD_64x64x4; +extern const tImage Home_64x64x4; +extern const tImage BtnRounded_64x52x4; extern const tImage Menu_64x64x4; extern const tImage Settings_64x64x4; extern const tImage Confirm_64x64x4; diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index d2b860ab155f..d19cc4bf1d95 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -35,6 +35,7 @@ #include "tft.h" +bool Touch::enabled = true; int16_t Touch::x, Touch::y; touch_control_t Touch::controls[]; touch_control_t *Touch::current_control; @@ -54,6 +55,7 @@ void Touch::init() { calibration_reset(); reset(); io.Init(); + enable(); } void Touch::add_control(TouchControlType type, uint16_t x, uint16_t y, uint16_t width, uint16_t height, int32_t data) { @@ -72,6 +74,8 @@ void Touch::idle() { uint16_t i; int16_t _x, _y; + if (!enabled) return; + if (now == millis()) return; now = millis(); @@ -253,6 +257,13 @@ void Touch::touch(touch_control_t *control) { case UBL: hold(control, UBL_REPEAT_DELAY); ui.encoderPosition += control->data; break; #endif + case MOVE_AXIS: + ui.goto_screen((screenFunc_t)ui.move_axis_screen); + break; + + // TODO: TOUCH could receive data to pass to the callback + case BUTTON: ((screenFunc_t)control->data)(); break; + default: break; } } diff --git a/Marlin/src/lcd/tft/touch.h b/Marlin/src/lcd/tft/touch.h index f3e53ae461c5..7d8f222918db 100644 --- a/Marlin/src/lcd/tft/touch.h +++ b/Marlin/src/lcd/tft/touch.h @@ -79,6 +79,8 @@ enum TouchControlType : uint16_t { FEEDRATE, FLOWRATE, UBL, + MOVE_AXIS, + BUTTON, }; typedef void (*screenFunc_t)(); @@ -132,6 +134,7 @@ class Touch { private: static TOUCH_DRIVER io; static int16_t x, y; + static bool enabled; static touch_control_t controls[MAX_CONTROLS]; static touch_control_t *current_control; @@ -162,6 +165,8 @@ class Touch { static void clear() { controls_count = 0; } static void idle(); static bool is_clicked() { return touch_control_type == CLICK; } + static void disable() { enabled = false; } + static void enable() { enabled = true; } static void add_control(TouchControlType type, uint16_t x, uint16_t y, uint16_t width, uint16_t height, int32_t data = 0); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index a4ac1465ea25..2f4c90e17083 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -650,4 +650,7 @@ void menu_item(const uint8_t row, bool sel ) { TERN_(TOUCH_SCREEN, touch.add_control(sel ? CLICK : MENU_ITEM, 0, 2 + 34 * row, 320, 32, encoderTopLine + row)); } +void MarlinUI::move_axis_screen() { +} + #endif // HAS_UI_320x240 diff --git a/Marlin/src/lcd/tft/ui_320x240.h b/Marlin/src/lcd/tft/ui_320x240.h index ed69acbcd2e9..c9822f11cc69 100644 --- a/Marlin/src/lcd/tft/ui_320x240.h +++ b/Marlin/src/lcd/tft/ui_320x240.h @@ -73,6 +73,8 @@ const tImage Images[imgCount] = { Refresh_32x32x4, Leveling_32x32x4, Slider8x16x4, + Home_64x64x4, + BtnRounded_64x52x4, }; #if HAS_TEMP_CHAMBER && HOTENDS > 1 diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index c9f0bfd0e9b1..d6409c1dca7e 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -291,6 +291,7 @@ void MarlinUI::draw_status_screen() { offset += 32 - tft_string.width(); } tft.add_text(455 - tft_string.width() - offset, 3, is_homed ? COLOR_AXIS_HOMED : COLOR_AXIS_NOT_HOMED, tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, 132, TFT_WIDTH - 8, 34)); // feed rate tft.canvas(96, 180, 100, 32); @@ -654,4 +655,438 @@ void menu_item(const uint8_t row, bool sel ) { TERN_(TOUCH_SCREEN, touch.add_control(sel ? CLICK : MENU_ITEM, 0, 4 + 45 * row, TFT_WIDTH, 43, encoderTopLine + row)); } +#if ENABLED(BABYSTEP_ZPROBE_OFFSET) + #include "../../feature/babystep.h" +#endif + +#if HAS_BED_PROBE + #include "../../module/probe.h" +#endif + +#define Z_SELECTION_Z 1 +#define Z_SELECTION_Z_PROBE -1 + +struct MotionAxisState { + xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; + float currentStepSize = 10.0; + int z_selection = Z_SELECTION_Z; + uint8_t e_selection = 0; + bool homming = false; + bool blocked = false; + char message[32]; +}; + +MotionAxisState motionAxisState; + +#define E_BTN_COLOR COLOR_YELLOW +#define X_BTN_COLOR COLOR_CORAL_RED +#define Y_BTN_COLOR COLOR_VIVID_GREEN +#define Z_BTN_COLOR COLOR_LIGHT_BLUE + +#define BTN_WIDTH 64 +#define BTN_HEIGHT 52 +#define X_MARGIN 20 +#define Y_MARGIN 15 + +static void quick_feedback() { + #if HAS_CHIRP + ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? + #if BOTH(HAS_LCD_MENU, USE_BEEPER) + for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } + #elif HAS_LCD_MENU + delay(10); + #endif + #endif +} + +#define CUR_STEP_VALUE_WIDTH 104 +static void drawCurStepValue() { + tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize)); + tft_string.add("mm"); + tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string); +} + +static void drawCurZSelection() { + tft_string.set("Z"); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + tft.queue.sync(); + tft_string.set("Offset"); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34); + tft.set_background(COLOR_BACKGROUND); + if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + } +} + +static void drawCurESelection() { + tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set("E"); + tft.add_text(0, 0, E_BTN_COLOR , tft_string); + tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); +} + +static void drawMessage(const char *msg) { + tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(0, 0, COLOR_YELLOW, msg); +} + +static void drawAxisValue(AxisEnum axis) { + const float value = + #if HAS_BED_PROBE + axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? + probe.offset.z : + #endif + NATIVE_TO_LOGICAL( + ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset), + axis + ); + xy_int_t pos; + uint16_t color; + switch (axis) { + case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; + case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; + case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; + case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + default: return; + } + tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(ftostr52sp(value)); + tft.add_text(0, 0, color, tft_string); +} + +static void moveAxis(AxisEnum axis, const int8_t direction) { + quick_feedback(); + + if (axis == E_AXIS && thermalManager.temp_hotend[motionAxisState.e_selection].celsius < EXTRUDE_MINTEMP) { + drawMessage("Too cold"); + return; + } + + const float diff = motionAxisState.currentStepSize * direction; + + if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) + const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; + const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; + const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment, + new_probe_offset = probe.offset.z + bsDiff, + new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET + , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff + , new_probe_offset + ); + if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + babystep.add_steps(Z_AXIS, babystep_increment); + if (do_probe) + probe.offset.z = new_offs; + else + TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); + drawMessage(""); // clear the error + drawAxisValue(axis); + } + else { + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + #elif HAS_BED_PROBE + // only change probe.offset.z + probe.offset.z += diff; + if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + else { + drawMessage(""); // clear the error + } + drawAxisValue(axis); + #endif + return; + } + + if (!ui.manual_move.processing) { + // Start with no limits to movement + float min = current_position[axis] - 1000, + max = current_position[axis] + 1000; + + // Limit to software endstops, if enabled + #if HAS_SOFTWARE_ENDSTOPS + if (soft_endstops_enabled) switch (axis) { + case X_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_X, min = soft_endstop.min.x); + TERN_(MAX_SOFTWARE_ENDSTOP_X, max = soft_endstop.max.x); + break; + case Y_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_Y, min = soft_endstop.min.y); + TERN_(MAX_SOFTWARE_ENDSTOP_Y, max = soft_endstop.max.y); + break; + case Z_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_Z, min = soft_endstop.min.z); + TERN_(MAX_SOFTWARE_ENDSTOP_Z, max = soft_endstop.max.z); + default: break; + } + #endif // HAS_SOFTWARE_ENDSTOPS + + // Delta limits XY based on the current offset from center + // This assumes the center is 0,0 + #if ENABLED(DELTA) + if (axis != Z_AXIS && axis != E_AXIS) { + max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis + min = -max; + } + #endif + + // Get the new position + #if IS_KINEMATIC + ui.manual_move.offset += diff; + if (direction < 0) + NOLESS(ui.manual_move.offset, min - current_position[axis]); + else + NOMORE(ui.manual_move.offset, max - current_position[axis]); + #else + current_position[axis] += diff; + if (direction < 0 && current_position[axis] < min) { + current_position[axis] = min; + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + else if (direction > 0 && current_position[axis] > max) { + current_position[axis] = max; + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + else { + drawMessage(""); // clear the error + } + #endif + + ui.manual_move.soon(axis + #if MULTI_MANUAL + , motionAxisState.e_selection + #endif + ); + } + + drawAxisValue(axis); +} + +static void e_plus() { + moveAxis(E_AXIS, 1); +} + +static void e_minus() { + moveAxis(E_AXIS, -1); +} + +static void x_minus() { + moveAxis(X_AXIS, -1); +} + +static void x_plus() { + moveAxis(X_AXIS, 1); +} + +static void y_plus() { + moveAxis(Y_AXIS, 1); +} + +static void y_minus() { + moveAxis(Y_AXIS, -1); +} + +static void z_plus() { + moveAxis(Z_AXIS, 1); +} + +static void z_minus() { + moveAxis(Z_AXIS, -1); +} + +static void e_select() { + motionAxisState.e_selection++; + if (motionAxisState.e_selection >= EXTRUDERS) { + motionAxisState.e_selection = 0; + } + + quick_feedback(); + drawCurESelection(); + drawAxisValue(E_AXIS); +} + +static void do_home() { + quick_feedback(); + drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING)); + queue.inject_P(G28_STR); + // Disable touch until home is done + touch.disable(); + drawAxisValue(E_AXIS); + drawAxisValue(X_AXIS); + drawAxisValue(Y_AXIS); + drawAxisValue(Z_AXIS); +} + +static void step_size() { + motionAxisState.currentStepSize = motionAxisState.currentStepSize / 10.0; + if (motionAxisState.currentStepSize < 0.0015) motionAxisState.currentStepSize = 10.0; + quick_feedback(); + drawCurStepValue(); +} + +#if HAS_BED_PROBE + static void z_select() { + motionAxisState.z_selection *= -1; + quick_feedback(); + drawCurZSelection(); + drawAxisValue(Z_AXIS); + } +#endif + +static void disable_steppers() { + quick_feedback(); + queue.inject_P(PSTR("M84")); +} + +static void drawBtn(int x, int y, const char* label, int32_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { + uint16_t width = Images[imgBtn52Rounded].width; + uint16_t height = Images[imgBtn52Rounded].height; + + tft.queue.sync(); //need sync to change font + + if (!enabled) bgColor = COLOR_CONTROL_DISABLED; + + tft.canvas(x, y, width, height); + tft.set_background(COLOR_BACKGROUND); + tft.add_image(0, 0, imgBtn52Rounded, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); + + if (label != NULL) { + tft.set_font(Helvetica12Bold); + tft_string.set_font(Helvetica12Bold); + tft_string.set(label); + tft_string.trim(); + tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string); + + tft.queue.sync(); + tft_string.set_font(Helvetica18); + tft.set_font(Helvetica18); + } + else { + tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); + } + + if (enabled) touch.add_control(BUTTON, x, y, width, height, data); +} + +void MarlinUI::move_axis_screen() { + // Reset + motionAxisState.blocked = false; + touch.enable(); + + ui.clear_lcd(); + + TERN_(TOUCH_SCREEN, touch.clear()); + + const bool busy = printingIsActive(); + + // if we have baby step and we are printing, select baby step + if (busy && ENABLED(BABYSTEP_ZPROBE_OFFSET)) motionAxisState.z_selection = Z_SELECTION_Z_PROBE; + + // ROW 1 -> E- Y- CurY Z+ + int x = X_MARGIN, y = Y_MARGIN, spacing = 0; + + drawBtn(x, y, "E+", (int32_t)e_plus, imgUp, E_BTN_COLOR, !busy); + + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Y+", (int32_t)y_plus, imgUp, Y_BTN_COLOR, !busy); + + // Cur Y + x += BTN_WIDTH; + motionAxisState.yValuePos.x = x + 2; + motionAxisState.yValuePos.y = y; + drawAxisValue(Y_AXIS); + + x += spacing; + drawBtn(x, y, "Z+", (int32_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + + // ROW 2 -> "Ex" X- HOME X+ "Z" + y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; + x = X_MARGIN; + spacing = (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; + + motionAxisState.eNamePos.x = x; + motionAxisState.eNamePos.y = y; + drawCurESelection(); + if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (int32_t)e_select); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "X-", (int32_t)x_minus, imgLeft, X_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; //imgHome is 64x64 + add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (int32_t)do_home, imgHome, !busy); + + x += BTN_WIDTH + spacing; + uint16_t xplus_x = x; + drawBtn(x, y, "X+", (int32_t)x_plus, imgRight, X_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + motionAxisState.zTypePos.x = x; + motionAxisState.zTypePos.y = y; + drawCurZSelection(); + #if HAS_BED_PROBE + if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (int32_t)z_select); + #endif + + // ROW 3 -> E- CurX Y- Z- + y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; + x = X_MARGIN; + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + + drawBtn(x, y, "E-", (int32_t)e_minus, imgDown, E_BTN_COLOR, !busy); + + // Cur E + motionAxisState.eValuePos.x = x; + motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(E_AXIS); + + // Cur X + motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos + motionAxisState.xValuePos.y = y - 10; + drawAxisValue(X_AXIS); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Y-", (int32_t)y_minus, imgDown, Y_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Z-", (int32_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + + // Cur Z + motionAxisState.zValuePos.x = x; + motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(Z_AXIS); + + // ROW 4 -> step_size disable steppers back + y = TFT_HEIGHT - Y_MARGIN - 32; // + x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2; + motionAxisState.stepValuePos.x = x; + motionAxisState.stepValuePos.y = y; + if (!busy) { + drawCurStepValue(); + touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (int32_t)step_size); + } + + // alinged with x+ + drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (int32_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); + + add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack); +} + +#undef BTN_WIDTH +#undef BTN_HEIGHT + #endif // HAS_UI_480x320 diff --git a/Marlin/src/lcd/tft/ui_480x320.h b/Marlin/src/lcd/tft/ui_480x320.h index d803df4a247d..053ee78158cb 100644 --- a/Marlin/src/lcd/tft/ui_480x320.h +++ b/Marlin/src/lcd/tft/ui_480x320.h @@ -73,6 +73,8 @@ const tImage Images[imgCount] = { Refresh_32x32x4, Leveling_32x32x4, Slider8x16x4, + Home_64x64x4, + BtnRounded_64x52x4, }; #if HAS_TEMP_CHAMBER && HOTENDS > 1 diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index ee7f50dabf72..59e7cbe7d1ce 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -682,6 +682,10 @@ class MarlinUI { static void touch_calibration(); #endif + #if HAS_GRAPHICAL_TFT + static void move_axis_screen(); + #endif + private: #if HAS_DISPLAY diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 1295c7c46b12..f9652f39348b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -325,13 +325,21 @@ #define LCD_PINS_RS PC6 #elif ENABLED(TFT_480x320_SPI) + #ifndef XPT2046_X_CALIBRATION #define XPT2046_X_CALIBRATION -17253 + #endif + #ifndef XPT2046_Y_CALIBRATION #define XPT2046_Y_CALIBRATION 11579 + #endif + #ifndef XPT2046_X_OFFSET #define XPT2046_X_OFFSET 514 + #endif + #ifndef XPT2046_Y_OFFSET #define XPT2046_Y_OFFSET -24 + #endif - #define TFT_DRIVER ST7796 - #define TFT_BUFFER_SIZE 14400 + #define TFT_DRIVER ST7796 + #define TFT_BUFFER_SIZE 14400 #endif From 648269e0ec02887d353ec972359cbf30fd72ebbe Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 18 Sep 2020 00:13:20 +0000 Subject: [PATCH 11/63] [cron] Bump distribution date (2020-09-18) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 0ae661f1b18e..ed8314a3a5fd 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-17" + #define STRING_DISTRIBUTION_DATE "2020-09-18" #endif /** From 55ba5044ef493e2651c5a34951d6c0973aab9e1b Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Fri, 18 Sep 2020 02:45:56 -0700 Subject: [PATCH 12/63] Fix missing include (#19418) Co-authored-by: ellensp <530024+ellensp@users.noreply.github.com> --- Marlin/src/gcode/bedlevel/G35.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 7595067dbf85..926e6e82c535 100755 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -29,6 +29,10 @@ #include "../../module/probe.h" #include "../../feature/bedlevel/bedlevel.h" +#if HAS_MULTI_HOTEND + #include "../../module/tool_change.h" +#endif + #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" From e65deacabb4ada7dd13c6e5edfeb207e80f2a3f6 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 19 Sep 2020 00:13:10 +0000 Subject: [PATCH 13/63] [cron] Bump distribution date (2020-09-19) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index ed8314a3a5fd..0faa1f8b28e4 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-18" + #define STRING_DISTRIBUTION_DATE "2020-09-19" #endif /** From 4628f0e237d452a7c6633c3d6127a460b3bb477b Mon Sep 17 00:00:00 2001 From: Cole Markham Date: Sat, 19 Sep 2020 08:14:34 -0500 Subject: [PATCH 14/63] Fix CoreXY compile with backlash cal. (#19422) --- Marlin/src/gcode/calibrate/M425.cpp | 2 +- Marlin/src/inc/Conditionals_post.h | 5 +---- Marlin/src/lcd/menu/menu_backlash.cpp | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index 3e54186a5fa3..40441ac08d16 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -56,7 +56,7 @@ void GcodeSuite::M425() { }; LOOP_XYZ(a) { - if (AXIS_CAN_CALIBRATE(a) && parser.seen(XYZ_CHAR(a))) { + if (axis_can_calibrate(a) && parser.seen(XYZ_CHAR(a))) { planner.synchronize(); backlash.distance_mm[a] = parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a)); noArgs = false; diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 71ae4bb28539..2b232623a33b 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -159,10 +159,7 @@ // Calibration codes only for non-core axes #if EITHER(BACKLASH_GCODE, CALIBRATION_GCODE) #if EITHER(IS_CORE, MARKFORGED_XY) - #define X_AXIS_INDEX 0 - #define Y_AXIS_INDEX 1 - #define Z_AXIS_INDEX 2 - #define CAN_CALIBRATE(A,B) (A##_AXIS_INDEX == B##_INDEX) + #define CAN_CALIBRATE(A,B) (_AXIS(A) == B) #else #define CAN_CALIBRATE(A,B) 1 #endif diff --git a/Marlin/src/lcd/menu/menu_backlash.cpp b/Marlin/src/lcd/menu/menu_backlash.cpp index 0e1bfb591099..9d0b970ae1d3 100644 --- a/Marlin/src/lcd/menu/menu_backlash.cpp +++ b/Marlin/src/lcd/menu/menu_backlash.cpp @@ -50,4 +50,4 @@ void menu_backlash() { END_MENU(); } -#endif // HAS_LCD_MENU && BACKLASH_COMPENSATION +#endif // HAS_LCD_MENU && BACKLASH_GCODE From 435e1535cc6f3b06d82a62cbb2697281f7cedbc8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 19 Sep 2020 07:56:01 -0500 Subject: [PATCH 15/63] Change some dwin defines --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 446 +++++++++++++++--------------- Marlin/src/lcd/dwin/e3v2/dwin.h | 18 +- 2 files changed, 232 insertions(+), 232 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index d45511f5bc84..ca3a5cccffc6 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -99,9 +99,9 @@ #define USE_STRING_HEADINGS -#define MENU_FONT font8x16 -#define STAT_FONT font10x20 -#define HEADER_FONT font10x20 +#define DWIN_FONT_MENU font8x16 +#define DWIN_FONT_STAT font10x20 +#define DWIN_FONT_HEAD font10x20 #define MENU_CHAR_LIMIT 24 #define STATUS_Y 360 @@ -229,19 +229,19 @@ void HMI_ToggleLanguage() { void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) { if (value < 0) { - DWIN_Draw_String(false, true, size, White, bColor, x - 6, y, F("-")); - DWIN_Draw_FloatValue(true, true, 0, size, White, bColor, iNum, fNum, x, y, -value); + DWIN_Draw_String(false, true, size, Color_White, bColor, x - 6, y, F("-")); + DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, -value); } else { - DWIN_Draw_String(false, true, size, White, bColor, x - 6, y, F(" ")); - DWIN_Draw_FloatValue(true, true, 0, size, White, bColor, iNum, fNum, x, y, value); + DWIN_Draw_String(false, true, size, Color_White, bColor, x - 6, y, F(" ")); + DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, value); } } void ICON_Print() { if (select_page.now == 0) { DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130); - DWIN_Draw_Rectangle(0, White, 17, 130, 126, 229); + DWIN_Draw_Rectangle(0, Color_White, 17, 130, 126, 229); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 447, 28, 460, 58, 201); else @@ -259,7 +259,7 @@ void ICON_Print() { void ICON_Prepare() { if (select_page.now == 1) { DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130); - DWIN_Draw_Rectangle(0, White, 145, 130, 254, 229); + DWIN_Draw_Rectangle(0, Color_White, 145, 130, 254, 229); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 31, 447, 58, 460, 186, 201); else @@ -277,7 +277,7 @@ void ICON_Prepare() { void ICON_Control() { if (select_page.now == 2) { DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246); - DWIN_Draw_Rectangle(0, White, 17, 246, 126, 345); + DWIN_Draw_Rectangle(0, Color_White, 17, 246, 126, 345); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 61, 447, 88, 460, 58, 318); else @@ -295,7 +295,7 @@ void ICON_Control() { void ICON_StartInfo(bool show) { if (show) { DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246); - DWIN_Draw_Rectangle(0, White, 145, 246, 254, 345); + DWIN_Draw_Rectangle(0, Color_White, 145, 246, 254, 345); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 91, 447, 118, 460, 186, 318); else @@ -313,7 +313,7 @@ void ICON_StartInfo(bool show) { void ICON_Leveling(bool show) { if (show) { DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246); - DWIN_Draw_Rectangle(0, White, 145, 246, 254, 345); + DWIN_Draw_Rectangle(0, Color_White, 145, 246, 254, 345); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 211, 447, 238, 460, 186, 318); else @@ -331,7 +331,7 @@ void ICON_Leveling(bool show) { void ICON_Tune() { if (select_print.now == 0) { DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252); - DWIN_Draw_Rectangle(0, White, 8, 252, 87, 351); + DWIN_Draw_Rectangle(0, Color_White, 8, 252, 87, 351); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 121, 447, 148, 458, 34, 325); else @@ -349,7 +349,7 @@ void ICON_Tune() { void ICON_Pause() { if (select_print.now == 1) { DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252); - DWIN_Draw_Rectangle(0, White, 96, 252, 175, 351); + DWIN_Draw_Rectangle(0, Color_White, 96, 252, 175, 351); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 181, 447, 208, 459, 124, 325); else @@ -367,7 +367,7 @@ void ICON_Pause() { void ICON_Continue() { if (select_print.now == 1) { DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252); - DWIN_Draw_Rectangle(0, White, 96, 252, 175, 351); + DWIN_Draw_Rectangle(0, Color_White, 96, 252, 175, 351); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 447, 28, 460, 124, 325); else @@ -385,7 +385,7 @@ void ICON_Continue() { void ICON_Stop() { if (select_print.now == 2) { DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252); - DWIN_Draw_Rectangle(0, White, 184, 252, 263, 351); + DWIN_Draw_Rectangle(0, Color_White, 184, 252, 263, 351); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 151, 447, 178, 459, 210, 325); else @@ -401,19 +401,19 @@ void ICON_Stop() { } inline void Clear_Title_Bar() { - DWIN_Draw_Rectangle(1, Background_blue, 0, 0, DWIN_WIDTH, 30); + DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, 0, DWIN_WIDTH, 30); } inline void Draw_Title(const char * const title) { - DWIN_Draw_String(false, false, HEADER_FONT, White, Background_blue, 14, 4, (char*)title); + DWIN_Draw_String(false, false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title); } inline void Draw_Title(const __FlashStringHelper * title) { - DWIN_Draw_String(false, false, HEADER_FONT, White, Background_blue, 14, 4, (char*)title); + DWIN_Draw_String(false, false, DWIN_FONT_HEAD, Color_White, Color_Bg_Blue, 14, 4, (char*)title); } inline void Clear_Menu_Area() { - DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, STATUS_Y); + DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y); } inline void Clear_Main_Window() { @@ -423,11 +423,11 @@ inline void Clear_Main_Window() { inline void Clear_Popup_Area() { Clear_Title_Bar(); - DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); + DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); } void Draw_Popup_Bkgd_105() { - DWIN_Draw_Rectangle(1, Background_window, 14, 105, 258, 374); + DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 105, 258, 374); } inline void Draw_More_Icon(const uint8_t line) { @@ -440,7 +440,7 @@ inline void Draw_Menu_Cursor(const uint8_t line) { } inline void Erase_Menu_Cursor(const uint8_t line) { - DWIN_Draw_Rectangle(1, Background_black, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); + DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); } inline void Move_Highlight(const int16_t from, const uint16_t newline) { @@ -454,7 +454,7 @@ inline void Add_Menu_Line() { } inline void Scroll_Menu(const uint8_t dir) { - DWIN_Frame_AreaMove(1, dir, MLINE, Background_black, 0, 31, DWIN_WIDTH, 349); + DWIN_Frame_AreaMove(1, dir, MLINE, Color_Bg_Black, 0, 31, DWIN_WIDTH, 349); switch (dir) { case DWIN_SCROLL_DOWN: Move_Highlight(-1, 0); break; case DWIN_SCROLL_UP: Add_Menu_Line(); break; @@ -470,11 +470,11 @@ inline void Draw_Menu_Icon(const uint8_t line, const uint8_t icon) { } inline void Erase_Menu_Text(const uint8_t line) { - DWIN_Draw_Rectangle(1, Background_black, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); + DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); } inline void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr) { - if (label) DWIN_Draw_String(false, false, font8x16, White, Background_black, LBLX, MBASE(line) - 1, (char*)label); + if (label) DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(line) - 1, (char*)label); if (icon) Draw_Menu_Icon(line, icon); DWIN_Draw_Line(Line_Color, 16, MBASE(line) + 33, 256, MBASE(line) + 34); } @@ -583,7 +583,7 @@ inline void Item_Prepare_Home(const uint8_t row) { if (HMI_flag.language_chinese) { #if HAS_BED_PROBE DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(row)); - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); #else DWIN_Frame_AreaCopy(1, 43, 89, 98, 101, LBLX, MBASE(row)); #endif @@ -591,7 +591,7 @@ inline void Item_Prepare_Home(const uint8_t row) { else { #if HAS_BED_PROBE DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset" - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); #else DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "..." #endif @@ -638,11 +638,11 @@ inline void Item_Prepare_Home(const uint8_t row) { inline void Item_Prepare_Lang(const uint8_t row) { if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 239, 134, 266, 146, LBLX, MBASE(row)); - DWIN_Draw_String(false, false, font8x16, White, Background_black, 226, MBASE(row), F("CN")); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), F("CN")); } else { DWIN_Frame_AreaCopy(1, 0, 194, 121, 207, LBLX, MBASE(row)); // "Language selection" - DWIN_Draw_String(false, false, font8x16, White, Background_black, 226, MBASE(row), F("EN")); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 226, MBASE(row), F("EN")); } Draw_Menu_Icon(row, ICON_Language); } @@ -716,14 +716,14 @@ inline void Draw_Control_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_CONTROL)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION)); #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); #endif - if (CVISI(CONTROL_CASE_INFO)) DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_INFO), F("Info")); + if (CVISI(CONTROL_CASE_INFO)) DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(CONTROL_CASE_INFO), F("Info")); #else DWIN_Frame_TitleCopy(1, 128, 2, 176, 12); // "Control" DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature > @@ -784,17 +784,17 @@ inline void Draw_Tune_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TUNE)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_SPEED), GET_TEXT_F(MSG_SPEED)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_SPEED), GET_TEXT_F(MSG_SPEED)); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); #endif #if HAS_HEATED_BED - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); #endif #if HAS_FAN - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); #endif - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_ZOFF), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TUNE_CASE_ZOFF), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); #else DWIN_Frame_AreaCopy(1, 94, 2, 126, 12, 14, 9); DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(TUNE_CASE_SPEED)); // Print speed @@ -819,23 +819,23 @@ inline void Draw_Tune_Menu() { if (select_tune.now) Draw_Menu_Cursor(select_tune.now); Draw_Menu_Line(TUNE_CASE_SPEED, ICON_Speed); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_SPEED), feedrate_percentage); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_SPEED), feedrate_percentage); #if HAS_HOTEND Draw_Menu_Line(TUNE_CASE_TEMP, ICON_HotendTemp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED Draw_Menu_Line(TUNE_CASE_BED, ICON_BedTemp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.temp_bed.target); #endif #if HAS_FAN Draw_Menu_Line(TUNE_CASE_FAN, ICON_FanSpeed); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_FAN), thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_FAN), thermalManager.fan_speed[0]); #endif #if HAS_ZOFFSET_ITEM Draw_Menu_Line(TUNE_CASE_ZOFF, ICON_Zoffset); - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(TUNE_CASE_ZOFF), BABY_Z_VAR * 100); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(TUNE_CASE_ZOFF), BABY_Z_VAR * 100); #endif } @@ -886,12 +886,12 @@ inline void Draw_Motion_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_MOTION)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_RATE), F("Feedrate")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_ACCEL), GET_TEXT_F(MSG_ACCELERATION)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_RATE), F("Feedrate")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_ACCEL), GET_TEXT_F(MSG_ACCELERATION)); #if HAS_CLASSIC_JERK - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_JERK), GET_TEXT_F(MSG_JERK)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_JERK), GET_TEXT_F(MSG_JERK)); #endif - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_STEPS), GET_TEXT_F(MSG_STEPS_PER_MM)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(MOTION_CASE_STEPS), GET_TEXT_F(MSG_STEPS_PER_MM)); #else DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Motion" draw_max_en(MBASE(MOTION_CASE_RATE)); draw_speed_en(27, MBASE(MOTION_CASE_RATE)); // "Max Speed" @@ -932,8 +932,8 @@ inline void Draw_Motion_Menu() { DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too high")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 36, 300, F("Nozzle or Bed temperature")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 92, 300, F("is too high")); } } else { @@ -943,8 +943,8 @@ inline void Draw_Motion_Menu() { DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too low")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 36, 300, F("Nozzle or Bed temperature")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 92, 300, F("is too low")); } } } @@ -952,7 +952,7 @@ inline void Draw_Motion_Menu() { #endif inline void Draw_Popup_Bkgd_60() { - DWIN_Draw_Rectangle(1, Background_window, 14, 60, 258, 330); + DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 330); } #if HAS_HOTEND @@ -967,7 +967,7 @@ inline void Draw_Popup_Bkgd_60() { DWIN_ICON_Show(ICON, ICON_Confirm_C, 86, 280); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 20, 235, F("Nozzle is too cold")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, 20, 235, F("Nozzle is too cold")); DWIN_ICON_Show(ICON, ICON_Confirm_E, 86, 280); } } @@ -984,9 +984,9 @@ void Popup_Window_Resume() { DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 307); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 14) / 2, 115, F("Continue Print")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 22) / 2, 192, F("It looks like the last")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 22) / 2, 212, F("file was interrupted.")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 14) / 2, 115, F("Continue Print")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 192, F("It looks like the last")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 212, F("file was interrupted.")); DWIN_ICON_Show(ICON, ICON_Continue_E, 26, 307); DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 307); } @@ -1002,8 +1002,8 @@ void Popup_Window_Home(const bool parking/*=false*/) { DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * (parking ? 7 : 10)) / 2, 230, parking ? F("Parking") : F("Homing XYZ")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * (parking ? 7 : 10)) / 2, 230, parking ? F("Parking") : F("Homing XYZ")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); } } @@ -1018,8 +1018,8 @@ void Popup_Window_Home(const bool parking/*=false*/) { DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 13) / 2, 230, GET_TEXT_F(MSG_BED_LEVELING)); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 13) / 2, 230, GET_TEXT_F(MSG_BED_LEVELING)); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); } } @@ -1027,8 +1027,8 @@ void Popup_Window_Home(const bool parking/*=false*/) { void Draw_Select_Highlight(const bool sel) { HMI_flag.select_flag = sel; - const uint16_t c1 = sel ? Select_Color : Background_window, - c2 = sel ? Background_window : Select_Color; + const uint16_t c1 = sel ? Select_Color : Color_Bg_Window, + c2 = sel ? Color_Bg_Window : Select_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); @@ -1046,8 +1046,8 @@ void Popup_window_PauseOrStop() { DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 280); } else { - if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 11) / 2, 150, GET_TEXT_F(MSG_PAUSE_PRINT)); - else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 10) / 2, 150, GET_TEXT_F(MSG_STOP_PRINT)); + if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 11) / 2, 150, GET_TEXT_F(MSG_PAUSE_PRINT)); + else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 10) / 2, 150, GET_TEXT_F(MSG_STOP_PRINT)); DWIN_ICON_Show(ICON, ICON_Confirm_E, 26, 280); DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 280); } @@ -1070,21 +1070,21 @@ void Draw_Printing_Screen() { void Draw_Print_ProgressBar() { DWIN_ICON_Show(ICON, ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, BarFill_Color, 16 + Percentrecord * 240 / 100, 93, 256, 113); - DWIN_Draw_IntValue(true, true, 0, font8x16, Percent_Color, Background_black, 2, 117, 133, Percentrecord); - DWIN_Draw_String(false, false, font8x16, Percent_Color, Background_black, 133, 133, F("%")); + DWIN_Draw_IntValue(true, true, 0, font8x16, Percent_Color, Color_Bg_Black, 2, 117, 133, Percentrecord); + DWIN_Draw_String(false, false, font8x16, Percent_Color, Color_Bg_Black, 133, 133, F("%")); } void Draw_Print_ProgressElapsed() { duration_t elapsed = print_job_timer.duration(); // print timer - DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 42, 212, elapsed.value / 3600); - DWIN_Draw_String(false, false, font8x16, White, Background_black, 58, 212, F(":")); - DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 66, 212, (elapsed.value % 3600) / 60); + DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 42, 212, elapsed.value / 3600); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 58, 212, F(":")); + DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 66, 212, (elapsed.value % 3600) / 60); } void Draw_Print_ProgressRemain() { - DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 176, 212, remain_time / 3600); - DWIN_Draw_String(false, false, font8x16, White, Background_black, 192, 212, F(":")); - DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 200, 212, (remain_time % 3600) / 60); + DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 176, 212, remain_time / 3600); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 192, 212, F(":")); + DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 200, 212, (remain_time % 3600) / 60); } void Goto_PrintProcess() { @@ -1100,7 +1100,7 @@ void Goto_PrintProcess() { // Copy into filebuf string before entry char * const name = card.longest_filename(); const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, false, font8x16, White, Background_black, npos, 60, name); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, npos, 60, name); DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193); DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191); @@ -1155,7 +1155,7 @@ void HMI_Move_X() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; EncoderRate.enabled = false; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); if (!planner.is_full()) { // Wait for planner moves to finish! planner.synchronize(); @@ -1167,7 +1167,7 @@ void HMI_Move_X() { NOLESS(HMI_ValueStruct.Move_X_scale, (X_MIN_POS) * MINUNITMULT); NOMORE(HMI_ValueStruct.Move_X_scale, (X_MAX_POS) * MINUNITMULT); current_position.x = HMI_ValueStruct.Move_X_scale / 10; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); DWIN_UpdateLCD(); } } @@ -1184,7 +1184,7 @@ void HMI_Move_Y() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; EncoderRate.enabled = false; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); if (!planner.is_full()) { // Wait for planner moves to finish! planner.synchronize(); @@ -1196,7 +1196,7 @@ void HMI_Move_Y() { NOLESS(HMI_ValueStruct.Move_Y_scale, (Y_MIN_POS) * MINUNITMULT); NOMORE(HMI_ValueStruct.Move_Y_scale, (Y_MAX_POS) * MINUNITMULT); current_position.y = HMI_ValueStruct.Move_Y_scale / 10; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); DWIN_UpdateLCD(); } } @@ -1213,7 +1213,7 @@ void HMI_Move_Z() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; EncoderRate.enabled = false; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); if (!planner.is_full()) { // Wait for planner moves to finish! planner.synchronize(); @@ -1225,7 +1225,7 @@ void HMI_Move_Z() { NOLESS(HMI_ValueStruct.Move_Z_scale, Z_MIN_POS * MINUNITMULT); NOMORE(HMI_ValueStruct.Move_Z_scale, Z_MAX_POS * MINUNITMULT); current_position.z = HMI_ValueStruct.Move_Z_scale / 10; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); DWIN_UpdateLCD(); } } @@ -1246,7 +1246,7 @@ void HMI_Move_Z() { checkkey = AxisMove; EncoderRate.enabled = false; last_E_scale = HMI_ValueStruct.Move_E_scale; - DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); if (!planner.is_full()) { planner.synchronize(); // Wait for planner moves to finish! planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder); @@ -1290,11 +1290,11 @@ void HMI_Move_Z() { #endif if (HMI_ValueStruct.show_mode == -4) { checkkey = Prepare; - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value)); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value)); } else { checkkey = Tune; - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value)); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value)); } DWIN_UpdateLCD(); return; @@ -1336,23 +1336,23 @@ void HMI_Move_Z() { EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { // temperature checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_Temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), ui.material_preset[0].hotend_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(temp_line), ui.material_preset[0].hotend_temp); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_Temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), ui.material_preset[1].hotend_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(temp_line), ui.material_preset[1].hotend_temp); return; } else { // tune checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } thermalManager.setTargetHotend(HMI_ValueStruct.E_Temp, 0); return; @@ -1361,7 +1361,7 @@ void HMI_Move_Z() { NOMORE(HMI_ValueStruct.E_Temp, MAX_E_TEMP); NOLESS(HMI_ValueStruct.E_Temp, MIN_E_TEMP); // E_Temp value - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } } @@ -1389,23 +1389,23 @@ void HMI_Move_Z() { EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_Temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), ui.material_preset[0].bed_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(bed_line), ui.material_preset[0].bed_temp); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].bed_temp = HMI_ValueStruct.Bed_Temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), ui.material_preset[1].bed_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(bed_line), ui.material_preset[1].bed_temp); return; } else { checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } thermalManager.setTargetBed(HMI_ValueStruct.Bed_Temp); return; @@ -1414,7 +1414,7 @@ void HMI_Move_Z() { NOMORE(HMI_ValueStruct.Bed_Temp, BED_MAX_TARGET); NOLESS(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP); // Bed_Temp value - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } } @@ -1443,23 +1443,23 @@ void HMI_Move_Z() { EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].fan_speed = HMI_ValueStruct.Fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), ui.material_preset[0].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), ui.material_preset[0].fan_speed); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), ui.material_preset[1].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), ui.material_preset[1].fan_speed); return; } else { checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed); return; @@ -1468,7 +1468,7 @@ void HMI_Move_Z() { NOMORE(HMI_ValueStruct.Fan_speed, FANON); NOLESS(HMI_ValueStruct.Fan_speed, FANOFF); // Fan_speed value - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } } @@ -1487,14 +1487,14 @@ void HMI_PrintSpeed() { checkkey = Tune; EncoderRate.enabled = false; feedrate_percentage = HMI_ValueStruct.print_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); return; } // print_speed limit NOMORE(HMI_ValueStruct.print_speed, MAX_PRINT_SPEED); NOLESS(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED); // print_speed value - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); } } @@ -1512,7 +1512,7 @@ void HMI_MaxFeedspeedXYZE() { EncoderRate.enabled = false; if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) planner.set_max_feedrate(HMI_flag.feedspeed_axis, HMI_ValueStruct.Max_Feedspeed); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); return; } // MaxFeedspeed limit @@ -1520,7 +1520,7 @@ void HMI_MaxFeedspeedXYZE() { NOMORE(HMI_ValueStruct.Max_Feedspeed, default_max_feedrate[HMI_flag.feedspeed_axis] * 2); if (HMI_ValueStruct.Max_Feedspeed < MIN_MAXFEEDSPEED) HMI_ValueStruct.Max_Feedspeed = MIN_MAXFEEDSPEED; // MaxFeedspeed value - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); } } @@ -1538,7 +1538,7 @@ void HMI_MaxAccelerationXYZE() { #if HAS_HOTEND else if (HMI_flag.acc_axis == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration); #endif - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); return; } // MaxAcceleration limit @@ -1546,7 +1546,7 @@ void HMI_MaxAccelerationXYZE() { NOMORE(HMI_ValueStruct.Max_Acceleration, default_max_acceleration[HMI_flag.acc_axis] * 2); if (HMI_ValueStruct.Max_Acceleration < MIN_MAXACCELERATION) HMI_ValueStruct.Max_Acceleration = MIN_MAXACCELERATION; // MaxAcceleration value - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); } } @@ -1564,7 +1564,7 @@ void HMI_MaxAccelerationXYZE() { EncoderRate.enabled = false; if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) planner.set_max_jerk(HMI_flag.step_axis, HMI_ValueStruct.Max_Jerk / 10); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); return; } // MaxJerk limit @@ -1572,7 +1572,7 @@ void HMI_MaxAccelerationXYZE() { NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[HMI_flag.jerk_axis] * 2 * MINUNITMULT); NOLESS(HMI_ValueStruct.Max_Jerk, (MIN_MAXJERK) * MINUNITMULT); // MaxJerk value - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); } } @@ -1592,7 +1592,7 @@ void HMI_StepXYZE() { EncoderRate.enabled = false; if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step / 10; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); return; } // Step limit @@ -1600,7 +1600,7 @@ void HMI_StepXYZE() { NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[HMI_flag.step_axis] * 2 * MINUNITMULT); NOLESS(HMI_ValueStruct.Max_Step, MIN_STEP); // Step value - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); } } @@ -1619,15 +1619,15 @@ void update_variable() { if (checkkey == Tune) { #if HAS_HOTEND if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED if (last_temp_bed_target != thermalManager.temp_bed.target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); #endif #if HAS_FAN if (last_fan_speed != thermalManager.fan_speed[0]) { - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); last_fan_speed = thermalManager.fan_speed[0]; } #endif @@ -1637,15 +1637,15 @@ void update_variable() { if (checkkey == TemperatureID) { #if HAS_HOTEND if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_TEMP), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_TEMP), thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED if (last_temp_bed_target != thermalManager.temp_bed.target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_BED), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_BED), thermalManager.temp_bed.target); #endif #if HAS_FAN if (last_fan_speed != thermalManager.fan_speed[0]) { - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_FAN), thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_FAN), thermalManager.fan_speed[0]); last_fan_speed = thermalManager.fan_speed[0]; } #endif @@ -1654,32 +1654,32 @@ void update_variable() { /* Bottom temperature update */ #if HAS_HOTEND if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); last_temp_hotend_current = thermalManager.temp_hotend[0].celsius; } if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); last_temp_hotend_target = thermalManager.temp_hotend[0].target; } #endif #if HAS_HEATED_BED if (last_temp_bed_current != thermalManager.temp_bed.celsius) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, thermalManager.temp_bed.celsius); last_temp_bed_current = thermalManager.temp_bed.celsius; } if (last_temp_bed_target != thermalManager.temp_bed.target) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); last_temp_bed_target = thermalManager.temp_bed.target; } #endif static uint16_t last_speed = 0; if (last_speed != feedrate_percentage) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); last_speed = feedrate_percentage; } #if HAS_ZOFFSET_ITEM if (last_zoffset != BABY_Z_VAR) { - DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100); + DWIN_Draw_Signed_Float(DWIN_FONT_STAT, Color_Bg_Black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100); last_zoffset = BABY_Z_VAR; } #endif @@ -1869,16 +1869,16 @@ void HMI_StartFrame(const bool with_update) { Goto_MainMenu(); // Clear the bottom area of the screen - DWIN_Draw_Rectangle(1, Background_black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); + DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); // // Status Area // #if HAS_HOTEND DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); - DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 3 * STAT_CHR_W + 5, 383, F("/")); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 33 + 3 * STAT_CHR_W + 5, 383, F("/")); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); #endif #if HOTENDS > 1 // DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381); @@ -1886,18 +1886,18 @@ void HMI_StartFrame(const bool with_update) { #if HAS_HEATED_BED DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); - DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 178 + 3 * STAT_CHR_W + 5, 383, F("/")); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, thermalManager.temp_bed.celsius); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 178 + 3 * STAT_CHR_W + 5, 383, F("/")); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); #endif DWIN_ICON_Show(ICON, ICON_Speed, 13, 429); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); - DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 5 * STAT_CHR_W + 2, 429, F("%")); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); + DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 33 + 5 * STAT_CHR_W + 2, 429, F("%")); #if HAS_ZOFFSET_ITEM DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428); - DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178, 429, BABY_Z_VAR * 100); + DWIN_Draw_Signed_Float(DWIN_FONT_STAT, Color_Bg_Black, 2, 2, 178, 429, BABY_Z_VAR * 100); #endif if (with_update) { @@ -1909,8 +1909,8 @@ void HMI_StartFrame(const bool with_update) { inline void Draw_Info_Menu() { Clear_Main_Window(); - DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, (char*)MACHINE_SIZE); - DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, (char*)SHORT_BUILD_VERSION); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(MACHINE_SIZE) * MENU_CHR_W) / 2, 122, (char*)MACHINE_SIZE); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(SHORT_BUILD_VERSION) * MENU_CHR_W) / 2, 195, (char*)SHORT_BUILD_VERSION); if (HMI_flag.language_chinese) { DWIN_Frame_TitleCopy(1, 30, 17, 57, 29); // "Info" @@ -1918,7 +1918,7 @@ inline void Draw_Info_Menu() { DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102); DWIN_Frame_AreaCopy(1, 1, 164, 56, 176, 108, 175); DWIN_Frame_AreaCopy(1, 58, 164, 113, 176, 105, 248); - DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(CORP_WEBSITE_C) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_C); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE_C) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_C); } else { #ifdef USE_STRING_HEADINGS @@ -1930,7 +1930,7 @@ inline void Draw_Info_Menu() { DWIN_Frame_AreaCopy(1, 120, 150, 146, 161, 124, 102); DWIN_Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175); DWIN_Frame_AreaCopy(1, 0, 165, 94, 175, 89, 248); - DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(CORP_WEBSITE_E) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_E); + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, (DWIN_WIDTH - strlen(CORP_WEBSITE_E) * MENU_CHR_W) / 2, 268, (char*)CORP_WEBSITE_E); } Draw_Back_First(); @@ -2393,13 +2393,13 @@ void HMI_Prepare() { select_axis.reset(); Draw_Move_Menu(); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), current_position.x * MINUNITMULT); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), current_position.y * MINUNITMULT); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), current_position.z * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), current_position.x * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), current_position.y * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), current_position.z * MINUNITMULT); #if HAS_HOTEND queue.inject_P(PSTR("G92 E0")); current_position.e = HMI_ValueStruct.Move_E_scale = 0; - DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), 0); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), 0); #endif break; case PREPARE_CASE_DISA: // Disable steppers @@ -2479,17 +2479,17 @@ void Draw_Temperature_Menu() { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TEMPERATURE)); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); #endif #if HAS_HEATED_BED - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); #endif #if HAS_FAN - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); #endif #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_PLA), F("PLA Preheat Settings")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_ABS), F("ABS Preheat Settings")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_PLA), F("PLA Preheat Settings")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(TEMP_CASE_ABS), F("ABS Preheat Settings")); #endif #else DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "Temperature" @@ -2523,15 +2523,15 @@ void Draw_Temperature_Menu() { #define _TMENU_ICON(N) Draw_Menu_Line(++i, ICON_SetEndTemp + (N) - 1) #if HAS_HOTEND _TMENU_ICON(TEMP_CASE_TEMP); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED _TMENU_ICON(TEMP_CASE_BED); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_bed.target); #endif #if HAS_FAN _TMENU_ICON(TEMP_CASE_FAN); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.fan_speed[0]); #endif #if HAS_HOTEND // PLA/ABS items have submenus @@ -2651,10 +2651,10 @@ void HMI_AxisMove() { HMI_flag.ETempTooLow_flag = false; current_position.e = HMI_ValueStruct.Move_E_scale = 0; Draw_Move_Menu(); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); - DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), 0); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), 0); DWIN_UpdateLCD(); } return; @@ -2679,19 +2679,19 @@ void HMI_AxisMove() { case 1: // X axis move checkkey = Move_X; HMI_ValueStruct.Move_X_scale = current_position.x * MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); EncoderRate.enabled = true; break; case 2: // Y axis move checkkey = Move_Y; HMI_ValueStruct.Move_Y_scale = current_position.y * MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); EncoderRate.enabled = true; break; case 3: // Z axis move checkkey = Move_Z; HMI_ValueStruct.Move_Z_scale = current_position.z * MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); EncoderRate.enabled = true; break; #if HAS_HOTEND @@ -2740,7 +2740,7 @@ void HMI_Temperature() { case TEMP_CASE_TEMP: // Nozzle temperature checkkey = ETemp; HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); EncoderRate.enabled = true; break; #endif @@ -2748,7 +2748,7 @@ void HMI_Temperature() { case TEMP_CASE_BED: // Bed temperature checkkey = BedTemp; HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target); EncoderRate.enabled = true; break; #endif @@ -2756,7 +2756,7 @@ void HMI_Temperature() { case TEMP_CASE_FAN: // Fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]); EncoderRate.enabled = true; break; #endif @@ -2787,15 +2787,15 @@ void HMI_Temperature() { else { #ifdef USE_STRING_HEADINGS Draw_Title("PLA Settings"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); #if HAS_HEATED_BED - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); #endif #if HAS_FAN - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); #endif #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); #endif #else DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings" @@ -2821,14 +2821,14 @@ void HMI_Temperature() { uint8_t i = 0; Draw_Menu_Line(++i, ICON_SetEndTemp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].hotend_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[0].hotend_temp); #if HAS_HEATED_BED Draw_Menu_Line(++i, ICON_SetBedTemp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].bed_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[0].bed_temp); #endif #if HAS_FAN Draw_Menu_Line(++i, ICON_FanSpeed); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[0].fan_speed); #endif #if ENABLED(EEPROM_SETTINGS) Draw_Menu_Line(++i, ICON_WriteEEPROM); @@ -2863,15 +2863,15 @@ void HMI_Temperature() { else { #ifdef USE_STRING_HEADINGS Draw_Title("ABS Settings"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); #if HAS_HEATED_BED - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); #endif #if HAS_FAN - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); #endif #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); #endif #else DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "ABS Settings" @@ -2898,14 +2898,14 @@ void HMI_Temperature() { uint8_t i = 0; Draw_Menu_Line(++i, ICON_SetEndTemp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].hotend_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[1].hotend_temp); #if HAS_HEATED_BED Draw_Menu_Line(++i, ICON_SetBedTemp); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].bed_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[1].bed_temp); #endif #if HAS_FAN Draw_Menu_Line(++i, ICON_FanSpeed); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), ui.material_preset[1].fan_speed); #endif #if ENABLED(EEPROM_SETTINGS) Draw_Menu_Line(++i, ICON_WriteEEPROM); @@ -2943,11 +2943,11 @@ inline void Draw_Max_Speed_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title("Max Speed (mm/s)"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Max Feedrate X")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), F("Max Feedrate Y")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), F("Max Feedrate Z")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Feedrate X")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Feedrate Y")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Feedrate Z")); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), F("Max Feedrate E")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Feedrate E")); #endif #else DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Max Speed (mm/s)" @@ -2973,11 +2973,11 @@ inline void Draw_Max_Speed_Menu() { Draw_Back_First(); LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MaxSpeedX + i); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(1), planner.settings.max_feedrate_mm_s[X_AXIS]); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(2), planner.settings.max_feedrate_mm_s[Y_AXIS]); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(3), planner.settings.max_feedrate_mm_s[Z_AXIS]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(1), planner.settings.max_feedrate_mm_s[X_AXIS]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(2), planner.settings.max_feedrate_mm_s[Y_AXIS]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(3), planner.settings.max_feedrate_mm_s[Z_AXIS]); #if HAS_HOTEND - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(4), planner.settings.max_feedrate_mm_s[E_AXIS]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(4), planner.settings.max_feedrate_mm_s[E_AXIS]); #endif } @@ -3005,11 +3005,11 @@ inline void Draw_Max_Accel_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_ACCELERATION)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Max Accel X")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), F("Max Accel Y")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), F("Max Accel Z")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Accel X")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Accel Y")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Accel Z")); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), F("Max Accel E")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Accel E")); #endif #else DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Acceleration" @@ -3024,11 +3024,11 @@ inline void Draw_Max_Accel_Menu() { Draw_Back_First(); LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MaxAccX + i); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(1), planner.settings.max_acceleration_mm_per_s2[X_AXIS]); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(2), planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(3), planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(1), planner.settings.max_acceleration_mm_per_s2[X_AXIS]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(2), planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(3), planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); #if HAS_HOTEND - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(4), planner.settings.max_acceleration_mm_per_s2[E_AXIS]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(4), planner.settings.max_acceleration_mm_per_s2[E_AXIS]); #endif } @@ -3060,11 +3060,11 @@ inline void Draw_Max_Jerk_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_JERK)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Max Jerk X")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), F("Max Jerk Y")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), F("Max Jerk Z")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Max Jerk X")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Max Jerk Y")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Max Jerk Z")); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), F("Max Jerk E")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Max Jerk E")); #endif #else DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Jerk" @@ -3094,11 +3094,11 @@ inline void Draw_Max_Jerk_Menu() { Draw_Back_First(); LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MaxSpeedJerkX + i); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(1), planner.max_jerk[X_AXIS] * MINUNITMULT); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(2), planner.max_jerk[Y_AXIS] * MINUNITMULT); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(3), planner.max_jerk[Z_AXIS] * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(1), planner.max_jerk[X_AXIS] * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(2), planner.max_jerk[Y_AXIS] * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(3), planner.max_jerk[Z_AXIS] * MINUNITMULT); #if HAS_HOTEND - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(4), planner.max_jerk[E_AXIS] * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(4), planner.max_jerk[E_AXIS] * MINUNITMULT); #endif } @@ -3122,11 +3122,11 @@ inline void Draw_Steps_Menu() { else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_STEPS_PER_MM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Steps/mm X")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), F("Steps/mm Y")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), F("Steps/mm Z")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(1), F("Steps/mm X")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(2), F("Steps/mm Y")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(3), F("Steps/mm Z")); #if HAS_HOTEND - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), F("Steps/mm E")); + DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(4), F("Steps/mm E")); #endif #else DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Steps per mm" @@ -3141,11 +3141,11 @@ inline void Draw_Steps_Menu() { Draw_Back_First(); LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_StepX + i); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(1), planner.settings.axis_steps_per_mm[X_AXIS] * MINUNITMULT); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(2), planner.settings.axis_steps_per_mm[Y_AXIS] * MINUNITMULT); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(3), planner.settings.axis_steps_per_mm[Z_AXIS] * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(1), planner.settings.axis_steps_per_mm[X_AXIS] * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(2), planner.settings.axis_steps_per_mm[Y_AXIS] * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(3), planner.settings.axis_steps_per_mm[Z_AXIS] * MINUNITMULT); #if HAS_HOTEND - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(4), planner.settings.axis_steps_per_mm[E_AXIS] * MINUNITMULT); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(4), planner.settings.axis_steps_per_mm[E_AXIS] * MINUNITMULT); #endif } @@ -3253,14 +3253,14 @@ void HMI_Tune() { case TUNE_CASE_SPEED: // Print speed checkkey = PrintSpeed; HMI_ValueStruct.print_speed = feedrate_percentage; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), feedrate_percentage); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), feedrate_percentage); EncoderRate.enabled = true; break; #if HAS_HOTEND case TUNE_CASE_TEMP: // Nozzle temp checkkey = ETemp; HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); EncoderRate.enabled = true; break; #endif @@ -3268,7 +3268,7 @@ void HMI_Tune() { case TUNE_CASE_BED: // Bed temp checkkey = BedTemp; HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); EncoderRate.enabled = true; break; #endif @@ -3276,7 +3276,7 @@ void HMI_Tune() { case TUNE_CASE_FAN: // Fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); EncoderRate.enabled = true; break; #endif @@ -3326,7 +3326,7 @@ void HMI_Tune() { case PREHEAT_CASE_TEMP: // Nozzle temperature checkkey = ETemp; HMI_ValueStruct.E_Temp = ui.material_preset[0].hotend_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[0].hotend_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[0].hotend_temp); EncoderRate.enabled = true; break; #endif @@ -3334,7 +3334,7 @@ void HMI_Tune() { case PREHEAT_CASE_BED: // Bed temperature checkkey = BedTemp; HMI_ValueStruct.Bed_Temp = ui.material_preset[0].bed_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[0].bed_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[0].bed_temp); EncoderRate.enabled = true; break; #endif @@ -3342,7 +3342,7 @@ void HMI_Tune() { case PREHEAT_CASE_FAN: // Fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = ui.material_preset[0].fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[0].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[0].fan_speed); EncoderRate.enabled = true; break; #endif @@ -3382,7 +3382,7 @@ void HMI_Tune() { case PREHEAT_CASE_TEMP: // Set nozzle temperature checkkey = ETemp; HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[1].hotend_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[1].hotend_temp); EncoderRate.enabled = true; break; #endif @@ -3390,7 +3390,7 @@ void HMI_Tune() { case PREHEAT_CASE_BED: // Set bed temperature checkkey = BedTemp; HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[1].bed_temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[1].bed_temp); EncoderRate.enabled = true; break; #endif @@ -3398,7 +3398,7 @@ void HMI_Tune() { case PREHEAT_CASE_FAN: // Set fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[1].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[1].fan_speed); EncoderRate.enabled = true; break; #endif @@ -3433,7 +3433,7 @@ void HMI_MaxSpeed() { checkkey = MaxSpeed_value; HMI_flag.feedspeed_axis = AxisEnum(select_speed.now - 1); HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[HMI_flag.feedspeed_axis]; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); EncoderRate.enabled = true; } else { // Back @@ -3462,7 +3462,7 @@ void HMI_MaxAcceleration() { checkkey = MaxAcceleration_value; HMI_flag.acc_axis = AxisEnum(select_acc.now - 1); HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[HMI_flag.acc_axis]; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); EncoderRate.enabled = true; } else { // Back @@ -3492,7 +3492,7 @@ void HMI_MaxAcceleration() { checkkey = MaxJerk_value; HMI_flag.jerk_axis = AxisEnum(select_jerk.now - 1); HMI_ValueStruct.Max_Jerk = planner.max_jerk[HMI_flag.jerk_axis] * MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); EncoderRate.enabled = true; } else { // Back @@ -3522,7 +3522,7 @@ void HMI_Step() { checkkey = Step_value; HMI_flag.step_axis = AxisEnum(select_step.now - 1); HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[HMI_flag.step_axis] * MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); EncoderRate.enabled = true; } else { // Back @@ -3539,7 +3539,7 @@ void HMI_Init() { for (uint16_t t = 0; t <= 100; t += 2) { DWIN_ICON_Show(ICON, ICON_Bar, 15, 260); - DWIN_Draw_Rectangle(1, Background_black, 15 + t * 242 / 100, 260, 257, 280); + DWIN_Draw_Rectangle(1, Color_Bg_Black, 15 + t * 242 / 100, 260, 257, 280); DWIN_UpdateLCD(); delay(20); } @@ -3577,7 +3577,7 @@ void EachMomentUpdate() { Draw_Print_ProgressBar(); // show print done confirm - DWIN_Draw_Rectangle(1, Background_black, 0, 250, DWIN_WIDTH - 1, STATUS_Y); + DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 250, DWIN_WIDTH - 1, STATUS_Y); DWIN_ICON_Show(ICON, HMI_flag.language_chinese ? ICON_Confirm_C : ICON_Confirm_E, 86, 283); } else if (HMI_flag.pause_flag != printingIsPaused()) { @@ -3654,7 +3654,7 @@ void EachMomentUpdate() { if (!recovery.valid()) return recovery.purge(); auto draw_first_option = [](const bool sel) { - const uint16_t c1 = sel ? Background_window : Select_Color; + const uint16_t c1 = sel ? Color_Bg_Window : Select_Color; DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345); DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346); }; @@ -3662,7 +3662,7 @@ void EachMomentUpdate() { auto update_selection = [&](const bool sel) { HMI_flag.select_flag = sel; draw_first_option(sel); - const uint16_t c2 = sel ? Select_Color : Background_window; + const uint16_t c2 = sel ? Select_Color : Color_Bg_Window; DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345); DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346); }; @@ -3679,7 +3679,7 @@ void EachMomentUpdate() { draw_first_option(false); char * const name = card.longest_filename(); const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2; - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, npos, 252, name); + DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name); DWIN_UpdateLCD(); break; } diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index fedb87afdd81..7b759d9cbfea 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -214,16 +214,16 @@ enum processID : uint8_t { #define font32x64 0x09 // Color -#define White 0xFFFF -#define Background_window 0x31E8 // Popup background color -#define Background_blue 0x1125 // Dark blue background color -#define Background_black 0x0841 // black background color -#define Font_window 0xD6BA // Popup font background color +#define Color_White 0xFFFF +#define Color_Bg_Window 0x31E8 // Popup background color +#define Color_Bg_Blue 0x1125 // Dark blue background color +#define Color_Bg_Black 0x0841 // Black background color +#define Popup_Text_Color 0xD6BA // Popup font background color #define Line_Color 0x3A6A // Split line color -#define Rectangle_Color 0xEE2F // blue square cursor color -#define Percent_Color 0xFE29 // percentage color -#define BarFill_Color 0x10E4 // fill color of progress bar -#define Select_Color 0x33BB // selected color +#define Rectangle_Color 0xEE2F // Blue square cursor color +#define Percent_Color 0xFE29 // Percentage color +#define BarFill_Color 0x10E4 // Fill color of progress bar +#define Select_Color 0x33BB // Selected color extern uint8_t checkkey; extern float zprobe_zoffset; From 4696142a31fe74ad32a57a5939e3af1cbae23e52 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sat, 19 Sep 2020 10:20:15 -0400 Subject: [PATCH 16/63] Fix compile for Taz Pro (#19424) --- .../ftdi_eve_touch_ui/screens/boot_screen.cpp | 2 +- .../screens/leveling_menu.cpp | 3 -- .../lib/ftdi_eve_touch_ui/screens/screens.h | 4 ++ .../theme/bootscreen_logo_portrait.h | 42 +++++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/bootscreen_logo_portrait.h diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.cpp index 2c2c0c6a18ec..4ce8f608f123 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.cpp @@ -32,7 +32,7 @@ #ifdef SHOW_CUSTOM_BOOTSCREEN #ifdef TOUCH_UI_PORTRAIT - #include "../theme/_bootscreen_portrait.h" + #include "../theme/bootscreen_logo_portrait.h" #else #include "../theme/_bootscreen_landscape.h" #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp index 2eab27c6086b..74ab332fb4d7 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp @@ -94,9 +94,6 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) { switch (tag) { case 1: GOTO_PREVIOUS(); break; case 2: - #ifndef BED_LEVELING_COMMANDS - #define BED_LEVELING_COMMANDS "G29" - #endif #if HAS_MESH BedMeshScreen::startMeshProbe(); #else diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h index b425c4fa45fb..2108cff8df2a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h @@ -27,6 +27,10 @@ #include "../theme/theme.h" #include "string_format.h" +#ifndef BED_LEVELING_COMMANDS + #define BED_LEVELING_COMMANDS "G29" +#endif + extern tiny_timer_t refresh_timer; /********************************* DL CACHE SLOTS ******************************/ diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/bootscreen_logo_portrait.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/bootscreen_logo_portrait.h new file mode 100644 index 000000000000..6ea317dbc3cd --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/bootscreen_logo_portrait.h @@ -0,0 +1,42 @@ +/**************************************************************************** + * 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. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +/** + * This file was auto-generated using "svg2cpp.pl" + * + * The encoding consists of x,y pairs with the min and max scaled to + * 0x0000 and 0xFFFE. A single 0xFFFF in the data stream indicates the + * start of a new closed path. + */ + +#pragma once + +constexpr float x_min = 0.000000, x_max = 272.000000, + y_min = 0.000000, y_max = 480.000000; + +const PROGMEM uint16_t logo_green[] = {0x8048, 0x46D9, 0x27BC, 0x9DBA, 0xD8D3, 0x9DBA}; +const PROGMEM uint16_t logo_mark[] = {0xDB9F, 0xAC0C, 0xDA6F, 0xAC2D, 0xD970, 0xAC91, 0xD8C0, 0xAD23, 0xD885, 0xADCF, 0xD8C0, 0xAE7A, 0xD970, 0xAF0C, 0xDA6F, 0xAF6F, 0xDB9F, 0xAF8F, 0xDCCE, 0xAF6F, 0xDDD0, 0xAF0C, 0xDE7D, 0xAE7B, 0xDEB9, 0xADCF, 0xDE7D, 0xAD22, 0xDDD0, 0xAC91, 0xDCCE, 0xAC2D, 0xFFFF, 0xDB9F, 0xABC3, 0xDCFE, 0xABEA, 0xDE28, 0xAC5E, 0xDEF1, 0xAD06, 0xDF36, 0xADCF, 0xDEF1, 0xAE95, 0xDE28, 0xAF3E, 0xDCFE, 0xAFB1, 0xDB9F, 0xAFD8, 0xDA3F, 0xAFB1, 0xD916, 0xAF3E, 0xD849, 0xAE95, 0xD808, 0xADCF, 0xD849, 0xAD06, 0xD916, 0xAC5E, 0xDA3F, 0xABEA, 0xFFFF, 0xDB7D, 0xACE6, 0xDAE4, 0xACE6, 0xDAE4, 0xADA9, 0xDB7D, 0xADA9, 0xDC3B, 0xAD94, 0xDC71, 0xAD48, 0xDC3B, 0xACFD, 0xFFFF, 0xDB85, 0xAC9E, 0xDCCB, 0xACC8, 0xDD37, 0xAD47, 0xDCF6, 0xADAC, 0xDC3E, 0xADDE, 0xDC85, 0xADFF, 0xDCE8, 0xAE4E, 0xDD92, 0xAEEA, 0xDCBD, 0xAEEA, 0xDC1E, 0xAE58, 0xDBA7, 0xAE03, 0xDB36, 0xADEF, 0xDAE4, 0xADEF, 0xDAE4, 0xAEEA, 0xDA26, 0xAEEA, 0xDA26, 0xAC9E}; +const PROGMEM uint16_t logo_type[] = {0xD8D5, 0xA520, 0xD8A5, 0xA563, 0xD82E, 0xA57F, 0xD348, 0xA57F, 0xD2D1, 0xA598, 0xD2A0, 0xA5D9, 0xD2A0, 0xAF7A, 0xD274, 0xAFBE, 0xD202, 0xAFDA, 0xCD37, 0xAFDA, 0xCCBF, 0xAFBE, 0xCC8F, 0xAF7A, 0xCC8F, 0xA5D9, 0xCC63, 0xA598, 0xCBF1, 0xA57F, 0xC70B, 0xA57F, 0xC694, 0xA563, 0xC664, 0xA520, 0xC664, 0xA28C, 0xC70B, 0xA22C, 0xD82E, 0xA22C, 0xD8A5, 0xA248, 0xD8D5, 0xA28C, 0xFFFF, 0xB138, 0xAC8C, 0xB952, 0xAC8C, 0xB952, 0xA57F, 0xB138, 0xA57F, 0xFFFF, 0xBF27, 0xA421, 0xBF57, 0xA476, 0xBF6D, 0xA4D0, 0xBF6D, 0xAD36, 0xBF57, 0xAD90, 0xBF27, 0xADE6, 0xBBFA, 0xAFB2, 0xBB60, 0xAFCF, 0xBABD, 0xAFDA, 0xAFCE, 0xAFDA, 0xAF30, 0xAFCF, 0xAE9A, 0xAFB2, 0xAB6E, 0xADE6, 0xAB39, 0xAD90, 0xAB28, 0xAD36, 0xAB28, 0xA4D0, 0xAB39, 0xA476, 0xAB6E, 0xA421, 0xAE9A, 0xA255, 0xAF30, 0xA239, 0xAFCE, 0xA22C, 0xBABD, 0xA22C, 0xBB60, 0xA239, 0xBBFA, 0xA255, 0xFFFF, 0x93A4, 0xACDC, 0x9CEA, 0xACDC, 0x9CEA, 0xAA34, 0x93A4, 0xAA34, 0x93A4, 0xACDC, 0xFFFF, 0x93A4, 0xA796, 0x9CEA, 0xA796, 0x9CEA, 0xA525, 0x93A4, 0xA525, 0xFFFF, 0xA227, 0xA421, 0xA258, 0xA478, 0xA26E, 0xA4D5, 0xA26E, 0xA700, 0xA24F, 0xA757, 0xA204, 0xA7A5, 0xA089, 0xA8B8, 0xA061, 0xA903, 0xA092, 0xA949, 0xA1FC, 0xAA43, 0xA24B, 0xAA91, 0xA26E, 0xAAE8, 0xA26E, 0xAD36, 0xA258, 0xAD90, 0xA227, 0xADE6, 0x9EFC, 0xAFB2, 0x9E61, 0xAFCF, 0x9DBE, 0xAFDA, 0x8ED0, 0xAFDA, 0x8E28, 0xAF7A, 0x8E28, 0xA28C, 0x8E59, 0xA248, 0x8ED0, 0xA22C, 0x9DBE, 0xA22C, 0x9E61, 0xA239, 0x9EFC, 0xA255, 0xFFFF, 0x853C, 0xA502, 0x8517, 0xA557, 0x84C9, 0xA5A2, 0x7994, 0xACC8, 0x8494, 0xACC8, 0x850A, 0xACE4, 0x853C, 0xAD27, 0x853C, 0xAF7A, 0x850A, 0xAFBE, 0x8494, 0xAFDA, 0x7371, 0xAFDA, 0x72C9, 0xAF7A, 0x72C9, 0xAD09, 0x72E8, 0xACB2, 0x7333, 0xAC64, 0x7EA5, 0xA53E, 0x73A6, 0xA53E, 0x732F, 0xA522, 0x72FE, 0xA4DF, 0x72FE, 0xA28C, 0x732F, 0xA248, 0x73A6, 0xA22C, 0x8494, 0xA22C, 0x850A, 0xA248, 0x853C, 0xA28C, 0xFFFF, 0x6B68, 0xAC87, 0x6BDB, 0xACA3, 0x6C07, 0xACE6, 0x6C07, 0xAF7A, 0x6BDB, 0xAFBE, 0x6B68, 0xAFDA, 0x5C84, 0xAFDA, 0x5BDC, 0xAF7A, 0x5BDC, 0xA28C, 0x5C84, 0xA22C, 0x6146, 0xA22C, 0x61EE, 0xA28C, 0x61EE, 0xAC2D, 0x621E, 0xAC6E, 0x6295, 0xAC87, 0xFFFF, 0x52C6, 0xA248, 0x52F7, 0xA28C, 0x52F7, 0xAD45, 0x52EE, 0xAD45, 0x52DC, 0xAD9B, 0x52B1, 0xADE6, 0x4F85, 0xAFB2, 0x4EEA, 0xAFCF, 0x4E47, 0xAFDA, 0x4359, 0xAFDA, 0x42BA, 0xAFCF, 0x4224, 0xAFB2, 0x3EF8, 0xADE6, 0x3EC3, 0xAD90, 0x3EB2, 0xAD36, 0x3EB2, 0xA28C, 0x3EE2, 0xA248, 0x3F5A, 0xA22C, 0x441B, 0xA22C, 0x4493, 0xA248, 0x44C3, 0xA28C, 0x44C3, 0xAC2D, 0x44F4, 0xAC71, 0x456B, 0xAC8C, 0x4C3E, 0xAC8C, 0x4CB1, 0xAC71, 0x4CDD, 0xAC2D, 0x4CDD, 0xA28C, 0x4D0D, 0xA248, 0x4D85, 0xA22C, 0x524F, 0xA22C, 0xFFFF, 0x3748, 0xAC87, 0x37BB, 0xACA3, 0x37E7, 0xACE6, 0x37E7, 0xAF7A, 0x37BB, 0xAFBE, 0x3748, 0xAFDA, 0x2864, 0xAFDA, 0x27BC, 0xAF7A, 0x27BC, 0xA28C, 0x2864, 0xA22C, 0x2D26, 0xA22C, 0x2DCD, 0xA28C, 0x2DCD, 0xAC2D, 0x2DFE, 0xAC6E, 0x2E75, 0xAC87}; +const PROGMEM uint16_t logo_black[] = {0x8048, 0x527A, 0x8ADE, 0x5CDE, 0x75B2, 0x5CDE, 0xFFFF, 0x8048, 0x4FF6, 0x71D9, 0x5E20, 0x8EB8, 0x5E20, 0x8048, 0x4FF6, 0xFFFF, 0x4436, 0x8D8E, 0x4ECC, 0x97F2, 0x39A0, 0x97F2, 0xFFFF, 0x4436, 0x8B0A, 0x35C8, 0x9934, 0x52A5, 0x9934, 0xFFFF, 0xBC3D, 0x8D8E, 0xC6D4, 0x97F2, 0xB1A7, 0x97F2, 0xFFFF, 0xBC3D, 0x8B0A, 0xADCE, 0x9934, 0xCAAC, 0x9934, 0xFFFF, 0x8045, 0x6778, 0x7F6D, 0x67A7, 0x7E9D, 0x689F, 0x7D49, 0x69EA, 0x7B41, 0x6A81, 0x7908, 0x6A3A, 0x7726, 0x692C, 0x75EA, 0x685A, 0x7505, 0x684C, 0x744A, 0x6899, 0x73F5, 0x69A8, 0x7345, 0x6B1A, 0x7193, 0x6BF8, 0x6F4D, 0x6C08, 0x6CFA, 0x6B45, 0x6B61, 0x6AA3, 0x6A7D, 0x6AB7, 0x69EB, 0x6B1D, 0x6A1D, 0x6C34, 0x6A22, 0x6DB8, 0x68E5, 0x6ECD, 0x66B9, 0x6F33, 0x6417, 0x6EC5, 0x6239, 0x6E5C, 0x6165, 0x6E91, 0x6108, 0x6F09, 0x61C1, 0x7018, 0x6282, 0x7196, 0x61CF, 0x72D1, 0x5FE5, 0x7384, 0x5D38, 0x7380, 0x5B4B, 0x7365, 0x5A97, 0x73B7, 0x5A74, 0x7438, 0x5B90, 0x7520, 0x5CE8, 0x7671, 0x5CCB, 0x77BB, 0x5B43, 0x78B0, 0x58B6, 0x7914, 0x56D7, 0x7944, 0x564F, 0x79AD, 0x5667, 0x7A2F, 0x57DA, 0x7AE3, 0x59B7, 0x7BF3, 0x5A31, 0x7D37, 0x5927, 0x7E5D, 0x56E0, 0x7F1E, 0x5529, 0x7F93, 0x54D7, 0x800D, 0x5529, 0x8087, 0x56E0, 0x80FD, 0x5926, 0x81BE, 0x5A30, 0x82E5, 0x59B5, 0x8428, 0x57D8, 0x8538, 0x5664, 0x85EB, 0x564C, 0x866D, 0x56D4, 0x86D7, 0x58B2, 0x8708, 0x5B3F, 0x876B, 0x5CC6, 0x8860, 0x5CE3, 0x89AA, 0x5B8B, 0x8AFC, 0x5A6D, 0x8BE3, 0x5A91, 0x8C65, 0x5B44, 0x8CB7, 0x5D32, 0x8C9C, 0x5FDE, 0x8C98, 0x61C7, 0x8D4B, 0x627A, 0x8E87, 0x61B9, 0x9005, 0x60FF, 0x9114, 0x615C, 0x918B, 0x622F, 0x91C0, 0x640E, 0x9158, 0x66B0, 0x90EA, 0x68DC, 0x9150, 0x6A18, 0x9266, 0x6A12, 0x93E9, 0x69E0, 0x9501, 0x6A72, 0x9567, 0x6B56, 0x957B, 0x6CEE, 0x94D9, 0x6F43, 0x9417, 0x7188, 0x9428, 0x7339, 0x9506, 0x73E9, 0x9678, 0x743E, 0x9787, 0x74F8, 0x97D4, 0x75DD, 0x97C6, 0x771A, 0x96F4, 0x78FB, 0x95E6, 0x7B35, 0x95A1, 0x7D3D, 0x9637, 0x7E91, 0x9782, 0x7F60, 0x987A, 0x8038, 0x98AA, 0x810F, 0x987B, 0x81DF, 0x9782, 0x8333, 0x9638, 0x853B, 0x95A1, 0x8775, 0x95E7, 0x8956, 0x96F5, 0x8A92, 0x97C8, 0x8B78, 0x97D6, 0x8C32, 0x9789, 0x8C88, 0x967A, 0x8D37, 0x9508, 0x8EE9, 0x942A, 0x912F, 0x941A, 0x9383, 0x94DD, 0x951B, 0x957F, 0x95FF, 0x956B, 0x9690, 0x9505, 0x9660, 0x93ED, 0x9659, 0x926A, 0x9797, 0x9154, 0x99C3, 0x90EF, 0x9C65, 0x915D, 0x9E43, 0x91C6, 0x9F17, 0x9191, 0x9F74, 0x9119, 0x9EBB, 0x900A, 0x9DFA, 0x8E8C, 0x9EAE, 0x8D51, 0xA098, 0x8C9E, 0xA345, 0x8CA2, 0xA531, 0x8CBE, 0xA5E5, 0x8C6B, 0xA609, 0x8BEA, 0xA4EC, 0x8B02, 0xA394, 0x89B1, 0xA3B2, 0x8867, 0xA53A, 0x8772, 0xA7C6, 0x870E, 0xA9A5, 0x86DE, 0xAA2D, 0x8675, 0xAA14, 0x85F2, 0xA8A2, 0x853F, 0xA6C5, 0x842E, 0xA64B, 0x82EB, 0xA755, 0x81C5, 0xA99C, 0x8104, 0xAB52, 0x808F, 0xABA6, 0x8015, 0xAB52, 0x7F9B, 0xA99C, 0x7F25, 0xA755, 0x7E64, 0xA64C, 0x7D3E, 0xA6C7, 0x7BFA, 0xA8A5, 0x7AEA, 0xAA18, 0x7A37, 0xAA31, 0x79B5, 0xA9A9, 0x794B, 0xA7CA, 0x791B, 0xA53C, 0x78B7, 0xA3B6, 0x77C1, 0xA39A, 0x7677, 0xA4F1, 0x7526, 0xA60E, 0x743F, 0xA5EB, 0x73BD, 0xA538, 0x736B, 0xA34B, 0x7387, 0xA09E, 0x738A, 0x9EB4, 0x72D6, 0x9E02, 0x719B, 0x9EC4, 0x701D, 0x9F7E, 0x6F0E, 0x9F20, 0x6E96, 0x9E4E, 0x6E61, 0x9C6E, 0x6ECA, 0x99CB, 0x6F37, 0x97A0, 0x6ED2, 0x9664, 0x6DBC, 0x966B, 0x6C38, 0x969B, 0x6B21, 0x960B, 0x6ABB, 0x9526, 0x6AA6, 0x938E, 0x6B48, 0x913B, 0x6C0B, 0x8EF4, 0x6BFA, 0x8D43, 0x6B1D, 0x8C94, 0x69AA, 0x8C3F, 0x689B, 0x8B85, 0x684D, 0x8A9E, 0x685C, 0x8962, 0x692E, 0x8781, 0x6A3C, 0x8546, 0x6A82, 0x833F, 0x69EA, 0x81EC, 0x68A0, 0x811C, 0x67A8, 0x8045, 0x6778, 0x8045, 0x6778, 0xFFFF, 0x8047, 0x6AA0, 0x81C8, 0x6AFA, 0x8268, 0x6BD5, 0x81C8, 0x6CAF, 0x8047, 0x6D09, 0x7EC6, 0x6CAF, 0x7E27, 0x6BD5, 0x7EC6, 0x6AFA, 0x8047, 0x6AA0, 0x8047, 0x6AA0, 0xFFFF, 0x803E, 0x6E19, 0x867C, 0x6E71, 0x8C65, 0x6F75, 0x91D7, 0x711B, 0x96AD, 0x735B, 0x9ABC, 0x762C, 0x9DA2, 0x794C, 0x9F5F, 0x7CA2, 0x9FF3, 0x8011, 0x9F5E, 0x8380, 0x9DA1, 0x86D5, 0x9ABA, 0x89F6, 0x96AB, 0x8CC7, 0x91D6, 0x8F08, 0x8C65, 0x90AD, 0x867C, 0x91B1, 0x803D, 0x9209, 0x7A00, 0x91B1, 0x7416, 0x90AD, 0x6EA6, 0x8F08, 0x69D0, 0x8CC7, 0x65D6, 0x8A0A, 0x62EE, 0x86F4, 0x6125, 0x839B, 0x6089, 0x8011, 0x6124, 0x7C88, 0x62ED, 0x792E, 0x65D6, 0x7619, 0x69CF, 0x735B, 0x6EA5, 0x711B, 0x7416, 0x6F75, 0x7A00, 0x6E71, 0x803E, 0x6E19, 0x803E, 0x6E19, 0xFFFF, 0x803E, 0x6EB2, 0x7A5A, 0x6F04, 0x74B2, 0x6FF8, 0x6F4B, 0x7194, 0x6A8F, 0x73C7, 0x66A2, 0x7681, 0x63D5, 0x7986, 0x6226, 0x7CBF, 0x6197, 0x8011, 0x6226, 0x8363, 0x63D5, 0x869C, 0x66A2, 0x89A2, 0x6A8F, 0x8C5B, 0x6F4B, 0x8E8E, 0x74B2, 0x902B, 0x7A5A, 0x911E, 0x803D, 0x9170, 0x803E, 0x9170, 0x8621, 0x911E, 0x8BCA, 0x902B, 0x9130, 0x8E8E, 0x95ED, 0x8C5B, 0x99CF, 0x89AB, 0x9CA7, 0x869C, 0x9E55, 0x8367, 0x9EE5, 0x8011, 0x9E55, 0x7CBB, 0x9CA7, 0x7986, 0x99CF, 0x7677, 0x95ED, 0x73C7, 0x9130, 0x7194, 0x8BCA, 0x6FF8, 0x8621, 0x6F04, 0x803E, 0x6EB2, 0x803E, 0x6EB2, 0xFFFF, 0x80BC, 0x6FD7, 0x80AF, 0x71D8, 0x7FC8, 0x71D9, 0x7FB7, 0x6FD8, 0x80BC, 0x6FD7, 0x80BC, 0x6FD7, 0xFFFF, 0x83CB, 0x6FF6, 0x84CD, 0x700B, 0x843E, 0x7206, 0x835B, 0x71F4, 0xFFFF, 0x7CA9, 0x6FF8, 0x7D1A, 0x71F5, 0x7C37, 0x7207, 0x7BA7, 0x700D, 0x7CA9, 0x6FF8, 0x7CA9, 0x6FF8, 0xFFFF, 0x87CD, 0x7068, 0x88C7, 0x7092, 0x87BA, 0x727C, 0x86DF, 0x7258, 0xFFFF, 0x78A8, 0x706B, 0x7997, 0x725A, 0x78BA, 0x727E, 0x77AD, 0x7095, 0x78A8, 0x706B, 0x78A8, 0x706B, 0xFFFF, 0x6700, 0x708A, 0x6880, 0x70E5, 0x6920, 0x71BF, 0x6880, 0x7299, 0x66FF, 0x72F4, 0x657F, 0x7299, 0x64E0, 0x71BF, 0x657F, 0x70E4, 0x6700, 0x708A, 0x6700, 0x708A, 0xFFFF, 0x998D, 0x708C, 0x9B0E, 0x70E6, 0x9BAE, 0x71C0, 0x9B0E, 0x729B, 0x998D, 0x72F6, 0x980D, 0x729B, 0x976E, 0x71C1, 0x980D, 0x70E7, 0x998D, 0x708C, 0x998D, 0x708C, 0xFFFF, 0x8BA7, 0x712C, 0x8C95, 0x716A, 0x8B10, 0x7339, 0x8A3F, 0x7303, 0x8BA7, 0x712C, 0xFFFF, 0x74CE, 0x712F, 0x7635, 0x7307, 0x7564, 0x733C, 0x73DE, 0x716D, 0x74CE, 0x712F, 0x74CE, 0x712F, 0xFFFF, 0x8F47, 0x723F, 0x9023, 0x728E, 0x8E2D, 0x743A, 0x8D6B, 0x73F4, 0x8F47, 0x723F, 0xFFFF, 0x712D, 0x7242, 0x7308, 0x73F7, 0x7248, 0x743D, 0x7050, 0x7292, 0x712D, 0x7242, 0x712D, 0x7242, 0xFFFF, 0x803E, 0x72F6, 0x891B, 0x73F4, 0x909A, 0x76CC, 0x959F, 0x7B0B, 0x975E, 0x8011, 0x959F, 0x8517, 0x909A, 0x8957, 0x891B, 0x8C2E, 0x803E, 0x8D2B, 0x7761, 0x8C2E, 0x6FE2, 0x8957, 0x6ADD, 0x8517, 0x691E, 0x8011, 0x6ADD, 0x7B0B, 0x6FE2, 0x76CC, 0x7761, 0x73F4, 0x803E, 0x72F6, 0x803E, 0x72F6, 0xFFFF, 0x803E, 0x738F, 0x77C8, 0x7481, 0x70A0, 0x7738, 0x6BD7, 0x7B46, 0x6A2C, 0x8011, 0x6BD7, 0x84DC, 0x70A1, 0x88EA, 0x77C9, 0x8BA1, 0x803E, 0x8C93, 0x88B4, 0x8BA1, 0x8FDB, 0x88EA, 0x94A5, 0x84DD, 0x9650, 0x8011, 0x94A5, 0x7B46, 0x8FDB, 0x7738, 0x88B4, 0x7481, 0x803E, 0x738F, 0x803E, 0x738F, 0xFFFF, 0x929B, 0x739A, 0x935C, 0x73FA, 0x9100, 0x7578, 0x905A, 0x7527, 0x9175, 0x745E, 0xFFFF, 0x6DDC, 0x739D, 0x7022, 0x7527, 0x6F74, 0x757C, 0x6D16, 0x73FF, 0x6DDC, 0x739D, 0x6DDC, 0x739D, 0xFFFF, 0x9589, 0x7533, 0x9634, 0x75A4, 0x937E, 0x76ED, 0x92E8, 0x768B, 0xFFFF, 0x6AEB, 0x7539, 0x6D8D, 0x7690, 0x6CFB, 0x76F0, 0x6CEC, 0x76FA, 0x6BED, 0x7674, 0x6A40, 0x75A9, 0x6A45, 0x75A7, 0x6AEB, 0x7539, 0x6AEB, 0x7539, 0xFFFF, 0x980B, 0x7707, 0x989A, 0x7784, 0x9597, 0x7892, 0x951A, 0x7825, 0xFFFF, 0x686A, 0x770C, 0x6B5B, 0x782A, 0x6ADF, 0x7897, 0x67DD, 0x7788, 0x686A, 0x770C, 0x686A, 0x770C, 0xFFFF, 0x9A12, 0x790A, 0x9A7E, 0x7991, 0x9740, 0x7A5E, 0x96E1, 0x79E8, 0x9A12, 0x790A, 0xFFFF, 0x6664, 0x790F, 0x6996, 0x79ED, 0x6937, 0x7A63, 0x65F9, 0x7996, 0x6664, 0x790F, 0x6664, 0x790F, 0xFFFF, 0x9B91, 0x7B32, 0x9BDB, 0x7BC1, 0x9870, 0x7C48, 0x9831, 0x7BCB, 0xFFFF, 0x64E6, 0x7B37, 0x6847, 0x7BD0, 0x6807, 0x7C4C, 0x649D, 0x7BC5, 0x64E6, 0x7B37, 0x64E6, 0x7B37, 0xFFFF, 0x9C82, 0x7D72, 0x9CA7, 0x7E06, 0x9925, 0x7E46, 0x9903, 0x7DC5, 0xFFFF, 0x63F7, 0x7D78, 0x6776, 0x7DC9, 0x6756, 0x7E49, 0x63D3, 0x7E0A, 0x63F7, 0x7D78, 0x63F7, 0x7D78, 0xFFFF, 0x5C87, 0x7EDB, 0x5E08, 0x7F35, 0x5EA8, 0x800F, 0x5E08, 0x80E9, 0x5C87, 0x8144, 0x5C85, 0x8144, 0x5B06, 0x80E9, 0x5A67, 0x800F, 0x5B06, 0x7F35, 0x5C87, 0x7EDB, 0x5C87, 0x7EDB, 0xFFFF, 0xA402, 0x7EDE, 0xA583, 0x7F38, 0xA623, 0x8011, 0xA623, 0x8013, 0xA583, 0x80EC, 0xA402, 0x8147, 0xA281, 0x80ED, 0xA1E2, 0x8013, 0xA281, 0x7F38, 0xA402, 0x7EDE, 0xA402, 0x7EDE, 0xFFFF, 0x9CE0, 0x7FC0, 0x9CE0, 0x8055, 0x9957, 0x804D, 0x9957, 0x7FCB, 0xFFFF, 0x639D, 0x7FC5, 0x6726, 0x7FCE, 0x6726, 0x8051, 0x639D, 0x805A, 0x639D, 0x7FC5, 0x639D, 0x7FC5, 0xFFFF, 0x9927, 0x81D1, 0x9CAA, 0x8210, 0x9C87, 0x82A2, 0x9907, 0x8252, 0x9927, 0x81D1, 0x9927, 0x81D1, 0xFFFF, 0x6757, 0x81D5, 0x6777, 0x8255, 0x63F9, 0x82A7, 0x63D4, 0x8214, 0xFFFF, 0x9877, 0x83CF, 0x9BE2, 0x8455, 0x9B99, 0x84E3, 0x9838, 0x844C, 0x9877, 0x83CF, 0x9877, 0x83CF, 0xFFFF, 0x6808, 0x83D3, 0x6848, 0x8450, 0x64E7, 0x84E8, 0x649E, 0x845A, 0xFFFF, 0x9749, 0x85B9, 0x9A88, 0x8684, 0x9A1D, 0x870C, 0x96EB, 0x862E, 0x9749, 0x85B9, 0x9749, 0x85B9, 0xFFFF, 0x6938, 0x85BD, 0x6997, 0x8634, 0x6665, 0x8710, 0x65F9, 0x8689, 0xFFFF, 0x95A2, 0x8785, 0x98A5, 0x8892, 0x9818, 0x890F, 0x9527, 0x87F2, 0x95A2, 0x8785, 0x95A2, 0x8785, 0xFFFF, 0x6ADF, 0x878A, 0x6B5B, 0x87F8, 0x686A, 0x8914, 0x67DC, 0x8897, 0x6ADF, 0x878A, 0xFFFF, 0x6CF7, 0x892F, 0x6D8D, 0x8991, 0x6AEB, 0x8AE9, 0x6A40, 0x8A79, 0xFFFF, 0x9380, 0x8932, 0x9645, 0x8A72, 0x963E, 0x8A77, 0x9599, 0x8AE3, 0x92F5, 0x898D, 0x9380, 0x8932, 0x9380, 0x8932, 0xFFFF, 0x9110, 0x8AA1, 0x936F, 0x8C1F, 0x92AA, 0x8C80, 0x9064, 0x8AF7, 0x9110, 0x8AA1, 0x9110, 0x8AA1, 0xFFFF, 0x6F73, 0x8AA5, 0x7021, 0x8AFB, 0x7035, 0x8B04, 0x6DED, 0x8C8B, 0x6DE1, 0x8C87, 0x6D17, 0x8C23, 0xFFFF, 0x8E3E, 0x8BE1, 0x9037, 0x8D8B, 0x8F59, 0x8DDC, 0x8D7C, 0x8C27, 0x8E3E, 0x8BE1, 0x8E3E, 0x8BE1, 0xFFFF, 0x7259, 0x8BEB, 0x731B, 0x8C31, 0x7140, 0x8DE7, 0x7064, 0x8D97, 0xFFFF, 0x8B21, 0x8CE3, 0x8CA9, 0x8EB2, 0x8BBA, 0x8EEF, 0x8A51, 0x8D18, 0x8B21, 0x8CE3, 0x8B21, 0x8CE3, 0xFFFF, 0x7576, 0x8CEB, 0x7648, 0x8D20, 0x74E0, 0x8EF8, 0x73F2, 0x8EBB, 0xFFFF, 0x66F3, 0x8D2F, 0x6874, 0x8D8A, 0x687D, 0x8D8F, 0x6886, 0x8D94, 0x6926, 0x8E6E, 0x6887, 0x8F48, 0x6705, 0x8FA2, 0x6584, 0x8F49, 0x657F, 0x8F45, 0x6570, 0x8F3E, 0x6573, 0x8F3E, 0x64D3, 0x8E63, 0x6573, 0x8D89, 0x66F3, 0x8D2F, 0x66F3, 0x8D2F, 0xFFFF, 0x9993, 0x8D31, 0x9B13, 0x8D8C, 0x9BB4, 0x8E66, 0x9B16, 0x8F40, 0x9993, 0x8F9A, 0x9814, 0x8F40, 0x9774, 0x8E66, 0x9812, 0x8D8C, 0x9993, 0x8D31, 0x9993, 0x8D31, 0xFFFF, 0x87CD, 0x8DA1, 0x88DC, 0x8F8B, 0x87E0, 0x8FB5, 0x86F0, 0x8DC6, 0x87CD, 0x8DA1, 0x87CD, 0x8DA1, 0xFFFF, 0x78CD, 0x8DA8, 0x79A8, 0x8DCB, 0x78BC, 0x8FBB, 0x77C1, 0x8F92, 0xFFFF, 0x8450, 0x8E19, 0x84E2, 0x9014, 0x83E0, 0x9029, 0x836C, 0x8E2C, 0x8450, 0x8E19, 0x8450, 0x8E19, 0xFFFF, 0x7C48, 0x8E1C, 0x7D2B, 0x8E2E, 0x7CBD, 0x902C, 0x7BBB, 0x9017, 0x7C48, 0x8E1C, 0xFFFF, 0x80BF, 0x8E49, 0x80D2, 0x904A, 0x7FCC, 0x904A, 0x7FD9, 0x8E49, 0x80BF, 0x8E49, 0x80BF, 0x8E49, 0xFFFF, 0x804F, 0x9321, 0x81D0, 0x937A, 0x8271, 0x9455, 0x81D1, 0x952F, 0x8051, 0x958A, 0x7ECF, 0x9530, 0x7E2F, 0x9456, 0x7ECE, 0x937B, 0x804F, 0x9321, 0x804F, 0x9321, 0xFFFF, 0x8048, 0x46D9, 0x27BC, 0x9DBA, 0xD8D3, 0x9DBA, 0xFFFF, 0x8048, 0x4BC9, 0x952E, 0x604A, 0x6B62, 0x604A, 0xFFFF, 0x68D2, 0x62CE, 0x97BF, 0x62CE, 0xB9BA, 0x8427, 0xA239, 0x9B36, 0x5E16, 0x9B36, 0x46B6, 0x8446, 0x68D2, 0x62CE, 0xFFFF, 0xBC3E, 0x869F, 0xD13B, 0x9B36, 0xA742, 0x9B36, 0xFFFF, 0x4431, 0x86BE, 0x590E, 0x9B36, 0x2F54, 0x9B36, 0x4431, 0x86BE}; +const PROGMEM uint16_t logo_white[] = {0x80BC, 0x6FD7, 0x80AF, 0x71D8, 0x7FC8, 0x71D9, 0x7FB7, 0x6FD8, 0x80BC, 0x6FD7, 0xFFFF, 0x83CB, 0x6FF6, 0x84CD, 0x700B, 0x843E, 0x7206, 0x835B, 0x71F4, 0xFFFF, 0x7CA9, 0x6FF8, 0x7D1A, 0x71F5, 0x7C37, 0x7207, 0x7BA7, 0x700D, 0x7CA9, 0x6FF8, 0x7CA9, 0x6FF8, 0xFFFF, 0x87CD, 0x7068, 0x88C7, 0x7092, 0x87BA, 0x727C, 0x86DF, 0x7258, 0xFFFF, 0x78A8, 0x706B, 0x7997, 0x725A, 0x78BA, 0x727E, 0x77AD, 0x7095, 0x78A8, 0x706B, 0x78A8, 0x706B, 0xFFFF, 0x8BA7, 0x712C, 0x8C95, 0x716A, 0x8B10, 0x7339, 0x8A3F, 0x7303, 0xFFFF, 0x74CE, 0x712F, 0x7635, 0x7307, 0x7564, 0x733C, 0x73DE, 0x716D, 0x74CE, 0x712F, 0x74CE, 0x712F, 0xFFFF, 0x8F47, 0x723F, 0x9023, 0x728E, 0x8E2D, 0x743A, 0x8D6B, 0x73F4, 0xFFFF, 0x712D, 0x7242, 0x7309, 0x73F7, 0x7248, 0x743D, 0x7050, 0x7292, 0x712D, 0x7242, 0x712D, 0x7242, 0xFFFF, 0x929B, 0x739A, 0x935C, 0x73FA, 0x9100, 0x7578, 0x905A, 0x7527, 0xFFFF, 0x6DDC, 0x739D, 0x7022, 0x7527, 0x6F74, 0x757C, 0x6D16, 0x73FF, 0x6DDC, 0x739D, 0x6DDC, 0x739D, 0xFFFF, 0x9589, 0x7533, 0x9634, 0x75A4, 0x937E, 0x76ED, 0x92E8, 0x768B, 0xFFFF, 0x6AEB, 0x7539, 0x6D8D, 0x7690, 0x6CFB, 0x76F0, 0x6A40, 0x75A9, 0x6AEB, 0x7539, 0xFFFF, 0x980B, 0x7707, 0x989A, 0x7784, 0x9597, 0x7892, 0x951A, 0x7825, 0xFFFF, 0x686A, 0x770C, 0x6B5B, 0x782A, 0x6ADF, 0x7897, 0x67DD, 0x7788, 0x686A, 0x770C, 0x686A, 0x770C, 0xFFFF, 0x9A12, 0x790A, 0x9A7E, 0x7991, 0x9740, 0x7A5E, 0x96E1, 0x79E8, 0xFFFF, 0x6664, 0x790F, 0x6996, 0x79ED, 0x6937, 0x7A63, 0x65F9, 0x7996, 0x6664, 0x790F, 0x6664, 0x790F, 0xFFFF, 0x9B91, 0x7B32, 0x9BDB, 0x7BC1, 0x9870, 0x7C48, 0x9831, 0x7BCC, 0xFFFF, 0x64E6, 0x7B37, 0x6847, 0x7BD0, 0x6807, 0x7C4C, 0x649D, 0x7BC5, 0x64E6, 0x7B37, 0x64E6, 0x7B37, 0xFFFF, 0x9C82, 0x7D72, 0x9CA7, 0x7E06, 0x9925, 0x7E46, 0x9903, 0x7DC5, 0xFFFF, 0x63F7, 0x7D78, 0x6776, 0x7DC9, 0x6756, 0x7E49, 0x63D3, 0x7E0A, 0x63F7, 0x7D78, 0x63F7, 0x7D78, 0xFFFF, 0x9CE0, 0x7FC0, 0x9CE0, 0x8055, 0x9957, 0x804D, 0x9957, 0x7FCB, 0xFFFF, 0x639D, 0x7FC5, 0x6726, 0x7FCE, 0x6726, 0x8051, 0x639D, 0x805A, 0x639D, 0x7FC5, 0xFFFF, 0x9927, 0x81D1, 0x9CAA, 0x8210, 0x9C87, 0x82A2, 0x9907, 0x8252, 0x9927, 0x81D1, 0x9927, 0x81D1, 0xFFFF, 0x6757, 0x81D5, 0x6777, 0x8256, 0x63F9, 0x82A7, 0x63D4, 0x8214, 0xFFFF, 0x9877, 0x83CF, 0x9BE2, 0x8455, 0x9B99, 0x84E3, 0x9838, 0x844C, 0x9877, 0x83CF, 0xFFFF, 0x6808, 0x83D3, 0x6848, 0x8450, 0x64E7, 0x84E8, 0x649E, 0x845A, 0xFFFF, 0x9749, 0x85B9, 0x9A88, 0x8684, 0x9A1D, 0x870C, 0x96EB, 0x862E, 0x9749, 0x85B9, 0x9749, 0x85B9, 0xFFFF, 0x6938, 0x85BD, 0x6997, 0x8634, 0x6665, 0x8710, 0x65F9, 0x8689, 0xFFFF, 0x95A2, 0x8785, 0x98A5, 0x8892, 0x9818, 0x890F, 0x9527, 0x87F2, 0x95A2, 0x8785, 0x95A2, 0x8785, 0xFFFF, 0x6ADF, 0x878A, 0x6B5B, 0x87F8, 0x686A, 0x8915, 0x67DC, 0x8897, 0xFFFF, 0x6CF7, 0x8930, 0x6D8D, 0x8991, 0x6AEB, 0x8AE9, 0x6A40, 0x8A79, 0xFFFF, 0x9380, 0x8932, 0x9645, 0x8A72, 0x9599, 0x8AE3, 0x92F5, 0x898D, 0x9380, 0x8932, 0xFFFF, 0x9110, 0x8AA1, 0x936F, 0x8C1F, 0x92AA, 0x8C80, 0x9064, 0x8AF7, 0x9110, 0x8AA1, 0x9110, 0x8AA1, 0xFFFF, 0x6F73, 0x8AA5, 0x7021, 0x8AFB, 0x6DED, 0x8C8C, 0x6D17, 0x8C23, 0xFFFF, 0x8E3E, 0x8BE1, 0x9037, 0x8D8B, 0x8F59, 0x8DDC, 0x8D7C, 0x8C27, 0x8E3E, 0x8BE1, 0x8E3E, 0x8BE1, 0xFFFF, 0x7259, 0x8BEB, 0x731B, 0x8C31, 0x7140, 0x8DE7, 0x7064, 0x8D97, 0xFFFF, 0x8B21, 0x8CE3, 0x8CA9, 0x8EB2, 0x8BBA, 0x8EEF, 0x8A51, 0x8D18, 0x8B21, 0x8CE3, 0x8B21, 0x8CE3, 0xFFFF, 0x7576, 0x8CEB, 0x7648, 0x8D20, 0x74E0, 0x8EF8, 0x73F2, 0x8EBB, 0xFFFF, 0x87CD, 0x8DA1, 0x88DC, 0x8F8B, 0x87E0, 0x8FB5, 0x86F0, 0x8DC6, 0x87CD, 0x8DA1, 0x87CD, 0x8DA1, 0xFFFF, 0x78CC, 0x8DA8, 0x79A8, 0x8DCB, 0x78BC, 0x8FBB, 0x77C0, 0x8F92, 0xFFFF, 0x8450, 0x8E19, 0x84E2, 0x9014, 0x83E0, 0x9029, 0x836C, 0x8E2C, 0x8450, 0x8E19, 0x8450, 0x8E19, 0xFFFF, 0x7C48, 0x8E1C, 0x7D2B, 0x8E2E, 0x7CBD, 0x902C, 0x7BBB, 0x9017, 0xFFFF, 0x80BE, 0x8E49, 0x80D1, 0x904A, 0x7FCC, 0x904A, 0x7FD9, 0x8E49, 0x80BE, 0x8E49, 0xFFFF, 0x8276, 0x75D6, 0x83AF, 0x75FE, 0x8436, 0x7628, 0x84AE, 0x7661, 0x8542, 0x7706, 0x8512, 0x77BA, 0x8457, 0x7845, 0x8335, 0x788B, 0x8318, 0x7882, 0x82D8, 0x7860, 0x831E, 0x7830, 0x8353, 0x7823, 0x83E6, 0x77F9, 0x8464, 0x7790, 0x847A, 0x771A, 0x8415, 0x76B7, 0x83B6, 0x7691, 0x8351, 0x7676, 0x827F, 0x7662, 0x81BB, 0x7687, 0x8161, 0x76AF, 0x8123, 0x76DA, 0x80E5, 0x771A, 0x80C5, 0x774D, 0x80B8, 0x77C1, 0x80D1, 0x77EE, 0x8107, 0x7814, 0x81CC, 0x786B, 0x837F, 0x7918, 0x8464, 0x7983, 0x84C0, 0x79B2, 0x852D, 0x79FD, 0x859D, 0x7ABC, 0x858E, 0x7B79, 0x8545, 0x7C25, 0x84D9, 0x7CC5, 0x8469, 0x7D4D, 0x843B, 0x7DCD, 0x8555, 0x7DA8, 0x85D3, 0x7D67, 0x870D, 0x7CA0, 0x87E0, 0x7BC0, 0x880D, 0x7B5B, 0x886D, 0x7A46, 0x88B3, 0x799B, 0x88CC, 0x7970, 0x893A, 0x78EA, 0x8995, 0x78A8, 0x8A01, 0x786F, 0x8AF8, 0x781F, 0x8BA6, 0x77FD, 0x8C0C, 0x77EF, 0x8C96, 0x77FB, 0x8D1D, 0x7815, 0x8D59, 0x7826, 0x8E40, 0x7889, 0x8EDB, 0x7925, 0x8EFC, 0x797B, 0x8EFF, 0x79D4, 0x8E71, 0x7A7B, 0x8D58, 0x7AD2, 0x8C23, 0x7ADE, 0x8AFF, 0x7A97, 0x8AF5, 0x7A81, 0x8AEF, 0x7A4E, 0x8B68, 0x7A52, 0x8B96, 0x7A5F, 0x8C39, 0x7A87, 0x8D33, 0x7A7F, 0x8E07, 0x7A3F, 0x8E66, 0x79CB, 0x8E63, 0x7985, 0x8E43, 0x793F, 0x8DC6, 0x78C6, 0x8CFA, 0x7876, 0x8C7E, 0x785F, 0x8C18, 0x7857, 0x8B84, 0x7874, 0x8B22, 0x788F, 0x8A7D, 0x78CA, 0x8A2E, 0x78F9, 0x89F0, 0x7930, 0x89A3, 0x79A5, 0x8979, 0x7AC0, 0x897C, 0x7B9C, 0x8972, 0x7BF2, 0x88CC, 0x7D32, 0x87B7, 0x7E4C, 0x8665, 0x7F52, 0x8660, 0x7F5A, 0x878F, 0x7F01, 0x88AE, 0x7EC2, 0x89FD, 0x7E9E, 0x8B8D, 0x7EC6, 0x8C40, 0x7F0E, 0x8CB6, 0x7F68, 0x8D1D, 0x7FD7, 0x8DFA, 0x80BD, 0x8EA8, 0x816E, 0x8F34, 0x81D4, 0x8F8A, 0x81F9, 0x8FDA, 0x820A, 0x90AB, 0x820F, 0x9120, 0x81FF, 0x91A5, 0x81DC, 0x91F4, 0x81B8, 0x922C, 0x8198, 0x9288, 0x812B, 0x927D, 0x80AB, 0x9252, 0x8068, 0x921C, 0x8033, 0x9174, 0x7FEB, 0x9099, 0x7FEB, 0x8FCF, 0x8029, 0x8F5D, 0x808D, 0x8F47, 0x80A4, 0x8ED4, 0x80A4, 0x8EC5, 0x8070, 0x8F65, 0x7FE6, 0x906D, 0x7F92, 0x91A4, 0x7F90, 0x92A8, 0x7FF7, 0x92FC, 0x8043, 0x9331, 0x8090, 0x9349, 0x813D, 0x92D1, 0x81E3, 0x9264, 0x8227, 0x91E5, 0x825B, 0x915D, 0x8280, 0x90D3, 0x8296, 0x8FA0, 0x829A, 0x8F2C, 0x8286, 0x8EE7, 0x8273, 0x8E78, 0x824A, 0x8DA9, 0x81D4, 0x8CB9, 0x8127, 0x8B68, 0x802C, 0x8B22, 0x8001, 0x8AC3, 0x7FE7, 0x8A50, 0x7FF4, 0x88FD, 0x8068, 0x87A4, 0x811D, 0x879E, 0x812D, 0x8904, 0x81F1, 0x89D4, 0x8285, 0x8A7C, 0x8343, 0x8A94, 0x8431, 0x8A4E, 0x84A1, 0x89E8, 0x850E, 0x892F, 0x85E5, 0x88B0, 0x86E5, 0x88C0, 0x8757, 0x88F2, 0x878D, 0x8927, 0x87AD, 0x8ABF, 0x8821, 0x8B0E, 0x881E, 0x8B70, 0x8811, 0x8C1B, 0x87D6, 0x8C9B, 0x8776, 0x8CC4, 0x873D, 0x8CD3, 0x8705, 0x8CA2, 0x86A3, 0x8C06, 0x8662, 0x8B39, 0x864F, 0x8A77, 0x8662, 0x89F9, 0x864D, 0x8A10, 0x8606, 0x8A66, 0x85F7, 0x8B35, 0x85DC, 0x8C50, 0x85FD, 0x8D3C, 0x8663, 0x8D94, 0x870A, 0x8D7D, 0x875F, 0x8D3A, 0x87B8, 0x8CB1, 0x882D, 0x8BC1, 0x888C, 0x8B30, 0x88A7, 0x8A8D, 0x88AE, 0x89EE, 0x8898, 0x896E, 0x887E, 0x8869, 0x882D, 0x87EE, 0x87EA, 0x87A4, 0x87A8, 0x878E, 0x8785, 0x874D, 0x86E3, 0x875D, 0x8637, 0x87FD, 0x8466, 0x8705, 0x835A, 0x86B8, 0x8359, 0x84A4, 0x8358, 0x7F20, 0x851B, 0x7F13, 0x864D, 0x8016, 0x86F9, 0x818E, 0x87D8, 0x823B, 0x8869, 0x8272, 0x88C9, 0x8276, 0x8915, 0x8266, 0x893D, 0x81FB, 0x89D8, 0x8197, 0x8A21, 0x8119, 0x8A62, 0x80A7, 0x8A8A, 0x8016, 0x8AAA, 0x7EDC, 0x8AAE, 0x7DC5, 0x8A63, 0x7D55, 0x8A29, 0x7CFA, 0x89E5, 0x7CAD, 0x8939, 0x7D1B, 0x8895, 0x7E00, 0x8825, 0x7F27, 0x8800, 0x7F66, 0x880F, 0x7F69, 0x8850, 0x7E49, 0x8873, 0x7D9A, 0x88C9, 0x7D4F, 0x893E, 0x7D8B, 0x89B2, 0x7DD8, 0x89E6, 0x7E36, 0x8A10, 0x7F02, 0x8A40, 0x7FDB, 0x8A34, 0x8046, 0x8A16, 0x8091, 0x89F5, 0x80A5, 0x89EB, 0x80FE, 0x89AB, 0x8126, 0x8981, 0x8159, 0x8918, 0x814F, 0x88E6, 0x8128, 0x88B8, 0x8094, 0x8856, 0x7EFC, 0x8796, 0x7D74, 0x86E7, 0x7D3D, 0x86C5, 0x7CD8, 0x8674, 0x7C98, 0x8605, 0x7CA0, 0x8536, 0x7D7C, 0x83E6, 0x7E07, 0x8357, 0x7DED, 0x835B, 0x79CC, 0x843E, 0x7962, 0x8448, 0x77CB, 0x8450, 0x76F3, 0x8438, 0x763E, 0x841E, 0x7502, 0x83FE, 0x746C, 0x83FD, 0x73E4, 0x840A, 0x72CE, 0x8444, 0x729B, 0x8457, 0x71E6, 0x84B7, 0x71B5, 0x84EB, 0x719B, 0x853B, 0x719B, 0x8558, 0x71D4, 0x85E0, 0x72B0, 0x8642, 0x73D4, 0x8661, 0x74B3, 0x8616, 0x74AD, 0x84D7, 0x74B2, 0x84B3, 0x74B5, 0x849B, 0x751E, 0x8496, 0x753B, 0x84B8, 0x75C5, 0x856E, 0x756D, 0x865A, 0x74D0, 0x86B8, 0x73FA, 0x86EA, 0x7250, 0x86CF, 0x70E7, 0x863F, 0x707E, 0x85C8, 0x705F, 0x8549, 0x7075, 0x84CC, 0x70AC, 0x8475, 0x70CD, 0x8452, 0x71FF, 0x839C, 0x7287, 0x8376, 0x736A, 0x833A, 0x7443, 0x8319, 0x751E, 0x8311, 0x76AC, 0x8327, 0x77C4, 0x8341, 0x7810, 0x8340, 0x799F, 0x8313, 0x7A2A, 0x82EA, 0x7B24, 0x8281, 0x7BE4, 0x820C, 0x7BEC, 0x81B1, 0x7A5E, 0x81C8, 0x7809, 0x81ED, 0x7751, 0x81F8, 0x7664, 0x81EF, 0x7571, 0x81B4, 0x74BB, 0x8141, 0x7483, 0x80F9, 0x7408, 0x802F, 0x73D9, 0x7FEB, 0x7359, 0x7F50, 0x72A0, 0x7EC4, 0x719E, 0x7E89, 0x7074, 0x7EA8, 0x7015, 0x7ECC, 0x6FD0, 0x7EF8, 0x6FA3, 0x7F19, 0x6F6B, 0x7FBB, 0x6F93, 0x8017, 0x6FA7, 0x8032, 0x6FD7, 0x805A, 0x70DF, 0x8092, 0x7205, 0x805A, 0x729E, 0x7FCB, 0x72B3, 0x7FBC, 0x7309, 0x7FA6, 0x733B, 0x7FDE, 0x72F9, 0x804B, 0x726D, 0x80A7, 0x70E6, 0x80FB, 0x700D, 0x80EC, 0x6F48, 0x80A8, 0x6EFC, 0x8073, 0x6EC1, 0x8026, 0x6E93, 0x7FCC, 0x6ED4, 0x7ED8, 0x6F54, 0x7E72, 0x6FCB, 0x7E3A, 0x700B, 0x7E25, 0x71AB, 0x7DED, 0x7356, 0x7E3E, 0x7472, 0x7EF4, 0x7536, 0x7FBD, 0x75DA, 0x8075, 0x7628, 0x80B6, 0x767B, 0x80D8, 0x76D9, 0x80EF, 0x7755, 0x80FC, 0x7881, 0x80D5, 0x7931, 0x8093, 0x7A00, 0x801E, 0x799B, 0x7D9B, 0x789A, 0x7CD8, 0x77C0, 0x7BE5, 0x7783, 0x7B55, 0x7787, 0x7AB9, 0x77AE, 0x7A67, 0x77E6, 0x7A1D, 0x781E, 0x79CD, 0x785E, 0x7909, 0x7853, 0x78C0, 0x7823, 0x788B, 0x7808, 0x7875, 0x7649, 0x77E8, 0x74B6, 0x7869, 0x7488, 0x78B3, 0x7472, 0x7901, 0x74D2, 0x796F, 0x75D8, 0x799A, 0x76EE, 0x7971, 0x774A, 0x797A, 0x7751, 0x79B4, 0x76A0, 0x79F0, 0x75E4, 0x7A0A, 0x7454, 0x79E1, 0x73AF, 0x7986, 0x7369, 0x7909, 0x7374, 0x7891, 0x739D, 0x783C, 0x73B6, 0x781E, 0x74B7, 0x7768, 0x765D, 0x772C, 0x77ED, 0x7769, 0x7932, 0x77FC, 0x7979, 0x7836, 0x79B8, 0x787B, 0x79DF, 0x7912, 0x7998, 0x7A14, 0x7967, 0x7AB4, 0x796A, 0x7AD8, 0x79C5, 0x7B60, 0x7A9D, 0x7BE9, 0x7B72, 0x7C47, 0x7EBA, 0x7BD6, 0x8206, 0x7CA8, 0x82FA, 0x7C2E, 0x8391, 0x7BB4, 0x83F6, 0x7B40, 0x8413, 0x7AD0, 0x83DD, 0x7A71, 0x838A, 0x7A39, 0x8296, 0x79B7, 0x80F3, 0x78FA, 0x8016, 0x788A, 0x7FB4, 0x7833, 0x7F8D, 0x77DF, 0x7F92, 0x77A9, 0x7FB3, 0x7718, 0x7FF6, 0x76C2, 0x8036, 0x768A, 0x8097, 0x764A, 0x80DF, 0x762A, 0x813C, 0x7605, 0x8275, 0x75D5}; + +#define LOGO_BACKGROUND 0xDEEA5C + +#define LOGO_PAINT_PATHS \ + LOGO_PAINT_PATH(0xC1D82F, logo_green) \ + LOGO_PAINT_PATH(0x000000, logo_black) \ + LOGO_PAINT_PATH(0x000000, logo_type) \ + LOGO_PAINT_PATH(0x000000, logo_mark) \ + LOGO_PAINT_PATH(0xFFFFFF, logo_white) From 9fd06fa7678efd6838fbe7c47e2b65a892be4b2c Mon Sep 17 00:00:00 2001 From: Marcio T Date: Sat, 19 Sep 2020 08:23:56 -0600 Subject: [PATCH 17/63] Fix case light brightness save/load (#19436) --- Marlin/src/module/settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 2c679068b936..3cb88da4eee1 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -138,7 +138,7 @@ void M710_report(const bool forReplay); #endif -#if ENABLED(CASE_LIGHT_MENU) && DISABLED(CASE_LIGHT_NO_BRIGHTNESS) +#if ENABLED(CASE_LIGHT_ENABLE) && DISABLED(CASE_LIGHT_NO_BRIGHTNESS) #include "../feature/caselight.h" #define HAS_CASE_LIGHT_BRIGHTNESS 1 #endif From af8f9f790a34f3a14b3478cd5ae98d219a8cf9e4 Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Sat, 19 Sep 2020 17:17:24 +0200 Subject: [PATCH 18/63] Optional Host Start menu item (#19443) --- Marlin/Configuration_adv.h | 1 + Marlin/src/lcd/menu/menu_main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 35b1dcc563ef..a010856d1871 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3232,6 +3232,7 @@ //#define HOST_ACTION_COMMANDS #if ENABLED(HOST_ACTION_COMMANDS) //#define HOST_PROMPT_SUPPORT + //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start #endif /** diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 334d998d5c6f..5b983825599e 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -54,7 +54,7 @@ #include "../../feature/password/password.h" #endif -#ifdef ACTION_ON_START +#if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START) #include "../../feature/host_actions.h" #endif @@ -162,7 +162,7 @@ void menu_main() { if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print); - #ifdef ACTION_ON_START + #if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START) ACTION_ITEM(MSG_HOST_START_PRINT, host_action_start); #endif From 98bcb25fd4494875e6c76a5bacef8b7c2fd452f0 Mon Sep 17 00:00:00 2001 From: ellensp Date: Sun, 20 Sep 2020 03:18:42 +1200 Subject: [PATCH 19/63] Ultratronics Pro SPI pins (#19444) --- Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h index 671307bc00cf..75b29629e90d 100644 --- a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h +++ b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h @@ -23,6 +23,7 @@ /** * ReprapWorld ULTRATRONICS v1.0 + * https://reprapworld.com/documentation/datasheet_ultratronics10_05.pdf */ #ifndef ARDUINO_ARCH_SAM @@ -146,6 +147,10 @@ #define SPI_EEPROM2_CS -1 #define SPI_FLASH_CS -1 +#define SCK_PIN 76 +#define MISO_PIN 74 +#define MOSI_PIN 75 + // SPI for Max6675 or Max31855 Thermocouple #define MAX6675_SS_PIN 65 #define MAX31855_SS0 65 From b5e4511de8c4b147d791e90bb102299e77ee4fb0 Mon Sep 17 00:00:00 2001 From: enigmaquip Date: Sat, 19 Sep 2020 09:19:45 -0600 Subject: [PATCH 20/63] Fix Creality DWIN Control menu icons (#19441) --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index ca3a5cccffc6..131c96bef1e1 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -744,7 +744,7 @@ inline void Draw_Control_Menu() { // Draw icons and lines uint8_t i = 0; - #define _TEMP_ICON(N) do{ ++i; if (CVISI(i)) Draw_Menu_Line(CSCROL(i), ICON_SetEndTemp + (N) - 1); }while(0) + #define _TEMP_ICON(N) do{ ++i; if (CVISI(i)) Draw_Menu_Line(CSCROL(i), ICON_Temperature + (N) - 1); }while(0) _TEMP_ICON(CONTROL_CASE_TEMP); if (CVISI(i)) Draw_More_Icon(CSCROL(i)); From 0c7035d8a3725d799cb286516a1bba40c578d202 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 20 Sep 2020 00:13:46 +0000 Subject: [PATCH 21/63] [cron] Bump distribution date (2020-09-20) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 0faa1f8b28e4..b33163f5f3c5 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-19" + #define STRING_DISTRIBUTION_DATE "2020-09-20" #endif /** From 8e0fac897b2ab0352059d5f9bd2d6293ae7d9bbf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 20 Sep 2020 18:24:05 -0500 Subject: [PATCH 22/63] Whitespace cleanup --- Marlin/src/HAL/ESP32/WebSocketSerial.cpp | 5 +-- Marlin/src/HAL/STM32/tft/xpt2046.cpp | 4 +- Marlin/src/feature/binary_stream.h | 4 +- Marlin/src/feature/spindle_laser.h | 2 +- Marlin/src/gcode/control/M993_M994.cpp | 2 +- Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp | 4 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 2 +- Marlin/src/lcd/tft/ili9341.h | 4 +- Marlin/src/lcd/tft/st7735.h | 4 +- Marlin/src/lcd/tft/st7789v.h | 2 +- Marlin/src/lcd/tft/st7796s.h | 42 +++++++++---------- Marlin/src/lcd/tft/ui_320x240.cpp | 2 +- Marlin/src/lcd/tft/ui_480x320.cpp | 2 +- 14 files changed, 41 insertions(+), 42 deletions(-) diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp index 533f873e4ffd..ca7f47a1f8bd 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp +++ b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp @@ -86,7 +86,7 @@ int RingBuffer::read() { ring_buffer_pos_t RingBuffer::read(uint8_t *buffer) { ring_buffer_pos_t len = available(); - for(ring_buffer_pos_t i = 0; read_index != write_index; i++) { + for (ring_buffer_pos_t i = 0; read_index != write_index; i++) { buffer[i] = data[read_index]; read_index = NEXT_INDEX(read_index, size); } @@ -139,9 +139,8 @@ size_t WebSocketSerial::write(const uint8_t c) { size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) { size_t written = 0; - for(size_t i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) written += write(buffer[i]); - } return written; } diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.cpp b/Marlin/src/HAL/STM32/tft/xpt2046.cpp index 49e64da6a113..921e377a9f4e 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.cpp +++ b/Marlin/src/HAL/STM32/tft/xpt2046.cpp @@ -155,9 +155,9 @@ uint16_t XPT2046::getRawData(const XPTCoordinate coordinate) { uint16_t XPT2046::HardwareIO(uint16_t data) { __HAL_SPI_ENABLE(&SPIx); - while((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {} + while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {} SPIx.Instance->DR = data; - while((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {} + while ((SPIx.Instance->SR & SPI_FLAG_RXNE) != SPI_FLAG_RXNE) {} __HAL_SPI_DISABLE(&SPIx); return SPIx.Instance->DR; diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index 10dea10d47bb..32ebcce2f62f 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -441,9 +441,9 @@ class BinaryStream { } void dispatch() { - switch(static_cast(packet.header.protocol())) { + switch (static_cast(packet.header.protocol())) { case Protocol::CONTROL: - switch(static_cast(packet.header.type())) { + switch (static_cast(packet.header.type())) { case ProtocolControl::CLOSE: // revert back to ASCII mode card.flag.binary_mode = false; break; diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 8240efa2ddee..15ff661c73e6 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -224,7 +224,7 @@ class SpindleLaser { */ // Force disengage planner power control - static inline void inline_disable() { + static inline void inline_disable() { isReady = false; unitPower = 0; planner.laser_inline.status.isPlanned = false; diff --git a/Marlin/src/gcode/control/M993_M994.cpp b/Marlin/src/gcode/control/M993_M994.cpp index ddc95238bf89..ff9ff85bf5bd 100644 --- a/Marlin/src/gcode/control/M993_M994.cpp +++ b/Marlin/src/gcode/control/M993_M994.cpp @@ -74,7 +74,7 @@ void GcodeSuite::M994() { W25QXX.init(SPI_QUARTER_SPEED); W25QXX.SPI_FLASH_BulkErase(); SERIAL_ECHOPGM("Load SPI Flash"); - while(addr < SPI_FLASH_SIZE) { + while (addr < SPI_FLASH_SIZE) { card.read(buf, COUNT(buf)); W25QXX.SPI_FLASH_BufferWrite(buf, addr, COUNT(buf)); addr += COUNT(buf); diff --git a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp index b1d905d9adcd..d39c6cfbd5e8 100644 --- a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp +++ b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp @@ -194,7 +194,7 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) { unsigned char temp_Counter; for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) { LED_DataArray[temp_Counter] = 0; - switch(RGB_Scale) { + switch (RGB_Scale) { case RGB_SCALE_R10_G7_B5: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*5/10; break; case RGB_SCALE_R10_G7_B4: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*4/10; break; case RGB_SCALE_R10_G8_B7: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*8/10) << 16 | luminance*7/10; break; @@ -213,7 +213,7 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) { bool LED_R_Flag = 0, LED_G_Flag = 0, LED_B_Flag = 0; for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) { - switch(RGB_Scale) { + switch (RGB_Scale) { case RGB_SCALE_R10_G7_B5: { LED_R_Data[temp_Counter] = luminance*10/10; LED_G_Data[temp_Counter] = luminance*7/10; diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 9b54dbdd2ba2..a7173b1ad2a7 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -27,8 +27,8 @@ #include "../../../../inc/MarlinConfig.h" #include "../../ui_api.h" -#include "../../../../MarlinCore.h" // for quickstop_stepper and disable_steppers -#include "../../../../module/motion.h" // for A20 read printing speed feedrate_percentage +#include "../../../../MarlinCore.h" // for quickstop_stepper and disable_steppers +#include "../../../../module/motion.h" // for A20 read printing speed feedrate_percentage // command sending macro's with debugging capability #define SEND_PGM(x) send_P(PSTR(x)) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h index 595565e1c704..21c3b6185ae1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -161,7 +161,7 @@ typedef struct { uint8_t waitEndMoves; uint16_t moveSpeed; float move_dist; - uint8_t F[4]; + uint8_t F[4]; } UI_CFG; typedef enum { diff --git a/Marlin/src/lcd/tft/ili9341.h b/Marlin/src/lcd/tft/ili9341.h index 22709e4cf7d3..d4a493412fb2 100644 --- a/Marlin/src/lcd/tft/ili9341.h +++ b/Marlin/src/lcd/tft/ili9341.h @@ -33,10 +33,10 @@ #define ILI9341_MADCTL_RGB 0x00 #define ILI9341_MADCTL_MH 0x04 // Horizontal Refresh Order -#define ILI9341_ORIENTATION_UP ILI9341_MADCTL_MY // 240x320 ; Cable on the upper side +#define ILI9341_ORIENTATION_UP ILI9341_MADCTL_MY // 240x320 ; Cable on the upper side #define ILI9341_ORIENTATION_RIGHT ILI9341_MADCTL_MV // 320x240 ; Cable on the right side #define ILI9341_ORIENTATION_LEFT ILI9341_MADCTL_MY | ILI9341_MADCTL_MX | ILI9341_MADCTL_MV // 320x240 ; Cable on the left side -#define ILI9341_ORIENTATION_DOWN ILI9341_MADCTL_MX // 240x320 ; Cable on the upper side +#define ILI9341_ORIENTATION_DOWN ILI9341_MADCTL_MX // 240x320 ; Cable on the upper side #ifndef ILI9341_COLOR_RGB #define ILI9341_COLOR_BGR diff --git a/Marlin/src/lcd/tft/st7735.h b/Marlin/src/lcd/tft/st7735.h index 30e77fbd91ab..62f93d5044c0 100644 --- a/Marlin/src/lcd/tft/st7735.h +++ b/Marlin/src/lcd/tft/st7735.h @@ -33,7 +33,7 @@ #define ST7735_MADCTL_RGB 0x00 #define ST7735_MADCTL_MH 0x04 // Horizontal Refresh Order -#define ST7735_ORIENTATION_UP 0x00 // 128x160 ; Cable on the upper side +#define ST7735_ORIENTATION_UP 0x00 // 128x160 ; Cable on the upper side #define ST7735_ORIENTATION_RIGHT ST7735_MADCTL_MV | ST7735_MADCTL_MY // 160x128 ; Cable on the right side #define ST7735_ORIENTATION_LEFT ST7735_MADCTL_MV | ST7735_MADCTL_MX // 160x128 ; Cable on the left side #define ST7735_ORIENTATION_DOWN ST7735_MADCTL_MX | ST7735_MADCTL_MY // 128x160 ; Cable on the lower side @@ -71,7 +71,7 @@ #define ST7735_IDMOFF 0x38 // Idle Mode Off #define ST7735_IDMON 0x39 // Idle Mode On #define ST7735_COLMOD 0x3A // Interface Pixel Format -#define ST7735_RDID1 0xDA // Read ID1 Value +#define ST7735_RDID1 0xDA // Read ID1 Value #define ST7735_RDID2 0xDB // Read ID2 Value #define ST7735_RDID3 0xDC // Read ID3 Value diff --git a/Marlin/src/lcd/tft/st7789v.h b/Marlin/src/lcd/tft/st7789v.h index f6e937c2c2b3..67da67966d2c 100644 --- a/Marlin/src/lcd/tft/st7789v.h +++ b/Marlin/src/lcd/tft/st7789v.h @@ -89,7 +89,7 @@ #define ST7789V_WRCABCMB 0x5E // Write CABC Minimum Brightness #define ST7789V_RDCABCMB 0x5F // Read CABC Minimum Brightness #define ST7789V_RDABCSDR 0x68 // Read Automatic Brightness Control Self-Diagnostic Result -#define ST7789V_RDID1 0xDA // Read ID1 Value +#define ST7789V_RDID1 0xDA // Read ID1 Value #define ST7789V_RDID2 0xDB // Read ID2 Value #define ST7789V_RDID3 0xDC // Read ID3 Value diff --git a/Marlin/src/lcd/tft/st7796s.h b/Marlin/src/lcd/tft/st7796s.h index 7ddbcfae840d..806977732cfb 100644 --- a/Marlin/src/lcd/tft/st7796s.h +++ b/Marlin/src/lcd/tft/st7796s.h @@ -133,8 +133,8 @@ static const uint16_t st7796s_init[] = { ESC_REG(ST7796S_DOCA), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033, /* Gamma Correction. */ - ESC_REG(ST7796S_PGC), 0x00F0, 0x0004, 0x0008, 0x0009, 0x0008, 0x0015, 0x002F, 0x0042, 0x0046, 0x0028, 0x0015, 0x0016, 0x0029, 0x002D, - ESC_REG(ST7796S_NGC), 0x00F0, 0x0004, 0x0009, 0x0009, 0x0008, 0x0015, 0x002E, 0x0046, 0x0046, 0x0028, 0x0015, 0x0015, 0x0029, 0x002D, + ESC_REG(ST7796S_PGC), 0x00F0, 0x0004, 0x0008, 0x0009, 0x0008, 0x0015, 0x002F, 0x0042, 0x0046, 0x0028, 0x0015, 0x0016, 0x0029, 0x002D, + ESC_REG(ST7796S_NGC), 0x00F0, 0x0004, 0x0009, 0x0009, 0x0008, 0x0015, 0x002E, 0x0046, 0x0046, 0x0028, 0x0015, 0x0015, 0x0029, 0x002D, ESC_REG(ST7796S_NORON), ESC_REG(ST7796S_WRCTRLD), 0x0024, @@ -146,30 +146,30 @@ static const uint16_t st7796s_init[] = { static const uint16_t lerdge_st7796s_init[] = { DATASIZE_8BIT, - ESC_REG(ST7796S_CSCON), 0x00C3, // enable command 2 part I - ESC_REG(ST7796S_CSCON), 0x0096, // enable command 2 part II + ESC_REG(ST7796S_CSCON), 0x00C3, // enable command 2 part I + ESC_REG(ST7796S_CSCON), 0x0096, // enable command 2 part II - ESC_REG(ST7796S_MADCTL), ST7796S_MADCTL_DATA, + ESC_REG(ST7796S_MADCTL), ST7796S_MADCTL_DATA, ESC_REG(ST7796S_COLMOD), 0x0055, - ESC_REG(ST7796S_DIC), 0x0001, // 1-dot inversion - ESC_REG(ST7796S_EM), 0x00C6, + ESC_REG(ST7796S_DIC), 0x0001, // 1-dot inversion + ESC_REG(ST7796S_EM), 0x00C6, - ESC_REG(ST7796S_PWR2), 0x0015, - ESC_REG(ST7796S_PWR3), 0x00AF, - ESC_REG(0xC3), 0x0009, // Register not documented in datasheet - ESC_REG(ST7796S_VCMPCTL), 0x0022, - ESC_REG(ST7796S_VCMOST), 0x0000, - ESC_REG(ST7796S_DOCA), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033, + ESC_REG(ST7796S_PWR2), 0x0015, + ESC_REG(ST7796S_PWR3), 0x00AF, + ESC_REG(0xC3), 0x0009, // Register not documented in datasheet + ESC_REG(ST7796S_VCMPCTL), 0x0022, + ESC_REG(ST7796S_VCMOST), 0x0000, + ESC_REG(ST7796S_DOCA), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033, /* Gamma Correction. */ - ESC_REG(ST7796S_PGC), 0x00F0, 0x0004, 0x0008, 0x0009, 0x0008, 0x0015, 0x002F, 0x0042, 0x0046, 0x0028, 0x0015, 0x0016, 0x0029, 0x002D, - ESC_REG(ST7796S_NGC), 0x00F0, 0x0004, 0x0009, 0x0009, 0x0008, 0x0015, 0x002E, 0x0046, 0x0046, 0x0028, 0x0015, 0x0015, 0x0029, 0x002D, - - ESC_REG(ST7796S_INVON), // Display inversion ON - ESC_REG(ST7796S_WRCTRLD), 0x0024, - ESC_REG(ST7796S_CSCON), 0x003C, // disable command 2 part I - ESC_REG(ST7796S_CSCON), 0x0069, // disable command 2 part II - ESC_REG(ST7796S_DISPON), + ESC_REG(ST7796S_PGC), 0x00F0, 0x0004, 0x0008, 0x0009, 0x0008, 0x0015, 0x002F, 0x0042, 0x0046, 0x0028, 0x0015, 0x0016, 0x0029, 0x002D, + ESC_REG(ST7796S_NGC), 0x00F0, 0x0004, 0x0009, 0x0009, 0x0008, 0x0015, 0x002E, 0x0046, 0x0046, 0x0028, 0x0015, 0x0015, 0x0029, 0x002D, + + ESC_REG(ST7796S_INVON), // Display inversion ON + ESC_REG(ST7796S_WRCTRLD), 0x0024, + ESC_REG(ST7796S_CSCON), 0x003C, // disable command 2 part I + ESC_REG(ST7796S_CSCON), 0x0069, // disable command 2 part II + ESC_REG(ST7796S_DISPON), ESC_END }; diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 2f4c90e17083..de8498c5ff0f 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -603,7 +603,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const touch.clear(); if (calibration_stage < CALIBRATION_SUCCESS) { - switch(calibration_stage) { + switch (calibration_stage) { case CALIBRATION_POINT_1: tft_string.set("Top Left"); break; case CALIBRATION_POINT_2: y = TFT_HEIGHT - 21; tft_string.set("Bottom Left"); break; case CALIBRATION_POINT_3: x = TFT_WIDTH - 21; tft_string.set("Top Right"); break; diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index d6409c1dca7e..b5b332910bd6 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -608,7 +608,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const touch.clear(); if (calibration_stage < CALIBRATION_SUCCESS) { - switch(calibration_stage) { + switch (calibration_stage) { case CALIBRATION_POINT_1: tft_string.set("Top Left"); break; case CALIBRATION_POINT_2: y = TFT_HEIGHT - 21; tft_string.set("Bottom Left"); break; case CALIBRATION_POINT_3: x = TFT_WIDTH - 21; tft_string.set("Top Right"); break; From 76d8d1742c1d4a1efe0fd6c0645d3fc656bfd0b2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 20 Sep 2020 18:29:08 -0500 Subject: [PATCH 23/63] Add multi-extruder condition --- Marlin/Configuration_adv.h | 4 ++-- Marlin/src/HAL/DUE/HAL_SPI.cpp | 2 +- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 10 +++++----- Marlin/src/feature/dac/dac_dac084s085.cpp | 6 +++--- Marlin/src/feature/fwretract.cpp | 16 +++++++--------- Marlin/src/feature/fwretract.h | 4 ++-- Marlin/src/feature/powerloss.cpp | 10 +++++----- Marlin/src/feature/powerloss.h | 2 +- Marlin/src/gcode/config/M217.cpp | 4 ++-- Marlin/src/gcode/control/T.cpp | 2 +- Marlin/src/gcode/feature/fwretract/G10_G11.cpp | 4 ++-- Marlin/src/gcode/feature/pause/M600.cpp | 6 +++--- Marlin/src/gcode/feature/pause/M603.cpp | 2 +- Marlin/src/gcode/feature/pause/M701_M702.cpp | 12 ++++++------ Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 4 +--- Marlin/src/inc/Conditionals_LCD.h | 2 ++ Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 4 ++-- .../screens/endstop_state_screen.cpp | 2 +- .../screens/linear_advance_screen.cpp | 4 ++-- .../screens/max_velocity_screen.cpp | 2 +- .../screens/move_axis_screen.cpp | 4 ++-- .../screens/nudge_nozzle_screen.cpp | 12 ++++++------ .../lib/ftdi_eve_touch_ui/screens/screen_data.h | 2 +- .../screens/stepper_current_screen.cpp | 4 ++-- .../ftdi_eve_touch_ui/screens/steps_screen.cpp | 4 ++-- .../screens/stress_test_screen.cpp | 4 +--- .../lcd/extui/lib/mks_ui/draw_change_speed.cpp | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/draw_extrusion.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 4 ++-- .../src/lcd/extui/lib/mks_ui/draw_printing.cpp | 12 +++++++----- Marlin/src/lcd/extui/ui_api.cpp | 17 ++++++----------- Marlin/src/lcd/menu/menu_advanced.cpp | 12 ++++++------ Marlin/src/lcd/menu/menu_configuration.cpp | 10 +++++----- Marlin/src/lcd/menu/menu_tune.cpp | 4 ++-- Marlin/src/lcd/ultralcd.cpp | 6 ++---- Marlin/src/module/endstops.cpp | 2 +- Marlin/src/module/motion.cpp | 2 +- Marlin/src/module/motion.h | 2 +- Marlin/src/module/planner.cpp | 4 ++-- Marlin/src/module/planner.h | 2 +- Marlin/src/module/settings.cpp | 12 ++++++------ Marlin/src/module/stepper.cpp | 12 ++++++------ Marlin/src/module/stepper.h | 13 ++++--------- Marlin/src/module/tool_change.cpp | 6 +++--- Marlin/src/module/tool_change.h | 2 +- Marlin/src/pins/sensitive_pins.h | 4 ++-- .../PlatformIO/scripts/common-dependencies.h | 3 --- 50 files changed, 127 insertions(+), 144 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a010856d1871..23d39b4d0ad7 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1979,7 +1979,7 @@ * Universal tool change settings. * Applies to all types of extruders except where explicitly noted. */ -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER // Z raise distance for tool-change, as needed for some extruders #define TOOLCHANGE_ZRAISE 2 // (mm) //#define TOOLCHANGE_ZRAISE_BEFORE_RETRACT // Apply raise before swap retraction (if enabled) @@ -2043,7 +2043,7 @@ //#define TOOLCHANGE_PARK_X_ONLY // X axis only move //#define TOOLCHANGE_PARK_Y_ONLY // Y axis only move #endif -#endif // EXTRUDERS > 1 +#endif // HAS_MULTI_EXTRUDER /** * Advanced Pause diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp index 6d8f7ef81939..97d69f0d726b 100644 --- a/Marlin/src/HAL/DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp @@ -595,7 +595,7 @@ SPI_Enable(SPI0); SET_OUTPUT(DAC0_SYNC); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SET_OUTPUT(DAC1_SYNC); WRITE(DAC1_SYNC, HIGH); #endif diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index caec347bf599..3fc1dd801a45 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -141,7 +141,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "Serial port pins (2) conflict with probe pin!" #elif IS_TX2(X_ENABLE_PIN) || IS_RX2(X_DIR_PIN) || IS_TX2(Y_ENABLE_PIN) || IS_RX2(Y_DIR_PIN) #error "Serial port pins (2) conflict with X/Y stepper pins!" - #elif EXTRUDERS > 1 && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN))) + #elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN))) #error "Serial port pins (2) conflict with E1 stepper pins!" #elif EXTRUDERS && (IS_RX2(E0_DIR_PIN) || IS_RX2(E0_STEP_PIN)) #error "Serial port pins (2) conflict with E stepper pins!" @@ -168,7 +168,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "Serial port pins (3) conflict with Z3 pins!" #elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP) #error "Serial port pins (3) conflict with Z4 pins!" - #elif EXTRUDERS > 1 && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP)) + #elif HAS_MULTI_EXTRUDER && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP)) #error "Serial port pins (3) conflict with E1 pins!" #endif #undef PIN_IS_TX3 @@ -214,7 +214,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals." #elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP) #error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals." - #elif EXTRUDERS > 1 && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP)) + #elif HAS_MULTI_EXTRUDER && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP)) #error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals." #endif #undef PIN_IS_SDA1 @@ -240,9 +240,9 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals." #elif PIN_IS_SDA2(Z4_ENABLE) #error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals." - #elif EXTRUDERS > 1 && PIN_IS_SDA2(E1_ENABLE) + #elif HAS_MULTI_EXTRUDER && PIN_IS_SDA2(E1_ENABLE) #error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals." - #elif EXTRUDERS > 1 && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS) + #elif HAS_MULTI_EXTRUDER && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS) #error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals." #elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR)) #error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals." diff --git a/Marlin/src/feature/dac/dac_dac084s085.cpp b/Marlin/src/feature/dac/dac_dac084s085.cpp index a07dc071dd43..82d17fa28f07 100644 --- a/Marlin/src/feature/dac/dac_dac084s085.cpp +++ b/Marlin/src/feature/dac/dac_dac084s085.cpp @@ -21,7 +21,7 @@ void dac084s085::begin() { // All SPI chip-select HIGH SET_OUTPUT(DAC0_SYNC); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SET_OUTPUT(DAC1_SYNC); #endif cshigh(); @@ -38,7 +38,7 @@ void dac084s085::begin() { spiSend(SPI_CHAN_DAC, externalDac_buf, COUNT(externalDac_buf)); WRITE(DAC0_SYNC, HIGH); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER //init Piggy DAC DELAY_US(2); WRITE(DAC1_SYNC, LOW); @@ -86,7 +86,7 @@ void dac084s085::setValue(const uint8_t channel, const uint8_t value) { void dac084s085::cshigh() { WRITE(DAC0_SYNC, HIGH); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER WRITE(DAC1_SYNC, HIGH); #endif WRITE(SPI_EEPROM1_CS, HIGH); diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index c0e4db0a455f..e5c52562a9ad 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -42,7 +42,7 @@ FWRetract fwretract; // Single instance - this calls the constructor // private: -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER bool FWRetract::retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted #endif @@ -73,9 +73,7 @@ void FWRetract::reset() { LOOP_L_N(i, EXTRUDERS) { retracted[i] = false; - #if EXTRUDERS > 1 - retracted_swap[i] = false; - #endif + TERN_(HAS_MULTI_EXTRUDER, retracted_swap[i] = false); current_retract[i] = 0.0; } } @@ -92,7 +90,7 @@ void FWRetract::reset() { * included in the G-code. Use M207 Z0 to to prevent double hop. */ void FWRetract::retract(const bool retracting - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER , bool swapping/*=false*/ #endif ) { @@ -100,7 +98,7 @@ void FWRetract::retract(const bool retracting if (retracted[active_extruder] == retracting) return; // Prevent two swap-retract or recovers in a row - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER // Allow G10 S1 only after G11 if (swapping && retracted_swap[active_extruder] == retracting) return; // G11 priority to recover the long retract if activated @@ -117,7 +115,7 @@ void FWRetract::retract(const bool retracting ); LOOP_L_N(i, EXTRUDERS) { SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); #endif } @@ -180,7 +178,7 @@ void FWRetract::retract(const bool retracting retracted[active_extruder] = retracting; // Active extruder now retracted / recovered // If swap retract/recover update the retracted_swap flag too - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER if (swapping) retracted_swap[active_extruder] = retracting; #endif @@ -190,7 +188,7 @@ void FWRetract::retract(const bool retracting SERIAL_ECHOLNPAIR("active_extruder ", active_extruder); LOOP_L_N(i, EXTRUDERS) { SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); #endif } diff --git a/Marlin/src/feature/fwretract.h b/Marlin/src/feature/fwretract.h index 3d6873642911..134851965dc4 100644 --- a/Marlin/src/feature/fwretract.h +++ b/Marlin/src/feature/fwretract.h @@ -42,7 +42,7 @@ typedef struct { class FWRetract { private: - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER static bool retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted #endif @@ -75,7 +75,7 @@ class FWRetract { } static void retract(const bool retracting - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER , bool swapping = false #endif ); diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 06296dd215fa..ed3a4b9fadea 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -186,13 +186,13 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/ TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift); info.feedrate = uint16_t(feedrate_mm_s * 60.0f); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER info.active_extruder = active_extruder; #endif #if DISABLED(NO_VOLUMETRICS) info.volumetric_enabled = parser.volumetric_enabled; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e]; #else if (parser.volumetric_enabled) info.filament_size[0] = planner.filament_size[active_extruder]; @@ -369,7 +369,7 @@ void PrintJobRecovery::resume() { // Recover volumetric extrusion state #if DISABLED(NO_VOLUMETRICS) - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER for (int8_t e = 0; e < EXTRUDERS; e++) { sprintf_P(cmd, PSTR("M200 T%i D%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1)); gcode.process_subcommands_now(cmd); @@ -411,7 +411,7 @@ void PrintJobRecovery::resume() { #endif // Select the previously active tool (with no_move) - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER sprintf_P(cmd, PSTR("T%i S"), info.active_extruder); gcode.process_subcommands_now(cmd); #endif @@ -543,7 +543,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOLNPAIR("feedrate: ", info.feedrate); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER DEBUG_ECHOLNPAIR("active_extruder: ", int(info.active_extruder)); #endif diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 10653493ab8f..1943175b0564 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -58,7 +58,7 @@ typedef struct { uint16_t feedrate; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER uint8_t active_extruder; #endif diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 0d049ede16e4..b57dec31f360 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfigPre.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../gcode.h" #include "../../module/tool_change.h" @@ -170,4 +170,4 @@ void GcodeSuite::M217() { M217_report(); } -#endif // EXTRUDERS > 1 +#endif // HAS_MULTI_EXTRUDER diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index 46cdfebf11ce..729f7f222341 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -23,7 +23,7 @@ #include "../gcode.h" #include "../../module/tool_change.h" -#if ENABLED(DEBUG_LEVELING_FEATURE) || EXTRUDERS > 1 +#if EITHER(HAS_MULTI_EXTRUDER, DEBUG_LEVELING_FEATURE) #include "../../module/motion.h" #endif diff --git a/Marlin/src/gcode/feature/fwretract/G10_G11.cpp b/Marlin/src/gcode/feature/fwretract/G10_G11.cpp index 05f015036001..219502f28a8e 100644 --- a/Marlin/src/gcode/feature/fwretract/G10_G11.cpp +++ b/Marlin/src/gcode/feature/fwretract/G10_G11.cpp @@ -33,11 +33,11 @@ * TODO: Handle 'G10 P' for tool settings and 'G10 L' for workspace settings */ void GcodeSuite::G10() { - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER const bool rs = parser.boolval('S'); #endif fwretract.retract(true - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER , rs #endif ); diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index fe1d90109eef..7c9be54b2916 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -29,7 +29,7 @@ #include "../../../module/motion.h" #include "../../../module/printcounter.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../../module/tool_change.h" #endif @@ -105,7 +105,7 @@ void GcodeSuite::M600() { if (!all_axes_known()) home_all_axes(); #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER // Change toolhead if specified const uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder && TERN1(DUAL_X_CARRIAGE, !dxc_is_duplicating())) @@ -163,7 +163,7 @@ void GcodeSuite::M600() { #endif } - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) tool_change(active_extruder_before_filament_change, false); diff --git a/Marlin/src/gcode/feature/pause/M603.cpp b/Marlin/src/gcode/feature/pause/M603.cpp index a62b5cd46d18..c40f3ae6e136 100644 --- a/Marlin/src/gcode/feature/pause/M603.cpp +++ b/Marlin/src/gcode/feature/pause/M603.cpp @@ -29,7 +29,7 @@ #include "../../../module/motion.h" #include "../../../module/printcounter.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../../module/tool_change.h" #endif diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index a02f2368e21c..c1f7223142c3 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -30,7 +30,7 @@ #include "../../../module/temperature.h" #include "../../../feature/pause.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../../module/tool_change.h" #endif @@ -86,7 +86,7 @@ void GcodeSuite::M701() { // Show initial "wait for load" message TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_LOAD, PAUSE_MODE_LOAD_FILAMENT, target_extruder)); - #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) @@ -121,7 +121,7 @@ void GcodeSuite::M701() { if (park_point.z > 0) do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); - #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) tool_change(active_extruder_before_filament_change, false); @@ -186,7 +186,7 @@ void GcodeSuite::M702() { // Show initial "wait for unload" message TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, PAUSE_MODE_UNLOAD_FILAMENT, target_extruder)); - #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) // Change toolhead if specified uint8_t active_extruder_before_filament_change = active_extruder; if (active_extruder != target_extruder) @@ -201,7 +201,7 @@ void GcodeSuite::M702() { #if ENABLED(PRUSA_MMU2) mmu2.unload(); #else - #if EXTRUDERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS) + #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_UNLOAD_ALL_EXTRUDERS) if (!parser.seenval('T')) { HOTEND_LOOP() { if (e != active_extruder) tool_change(e, false); @@ -227,7 +227,7 @@ void GcodeSuite::M702() { if (park_point.z > 0) do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); - #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) + #if HAS_MULTI_EXTRUDER && DISABLED(PRUSA_MMU2) // Restore toolhead if it was changed if (active_extruder_before_filament_change != active_extruder) tool_change(active_extruder_before_filament_change, false); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index c1b6deeadda8..39276bc72909 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -614,7 +614,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 211: M211(); break; // M211: Enable, Disable, and/or Report software endstops #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 217: M217(); break; // M217: Set filament swap parameters #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 24273012629f..085f6b361895 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -661,9 +661,7 @@ class GcodeSuite { static void M211(); - #if EXTRUDERS > 1 - static void M217(); - #endif + TERN_(HAS_MULTI_EXTRUDER, static void M217()); TERN_(HAS_HOTEND_OFFSET, static void M218()); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index d5ef62b621b6..95c93beb9ec1 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -501,6 +501,8 @@ #undef MK2_MULTIPLEXER #undef PRUSA_MMU2 #undef HOTEND_IDLE_TIMEOUT +#elif EXTRUDERS > 1 + #define HAS_MULTI_EXTRUDER 1 #endif #if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 2b232623a33b..2ae4f4e399d6 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2334,7 +2334,7 @@ #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0 #endif -#if EXTRUDERS > 1 && !defined(TOOLCHANGE_FS_EXTRA_PRIME) +#if HAS_MULTI_EXTRUDER && !defined(TOOLCHANGE_FS_EXTRA_PRIME) #define TOOLCHANGE_FS_EXTRA_PRIME 0 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 9f15d7e5e3e3..8d68b33ece20 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -865,7 +865,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Options only for EXTRUDERS > 1 */ -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #if EXTRUDERS > 8 #error "Marlin supports a maximum of 8 EXTRUDERS." @@ -987,7 +987,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Mixing Extruder requirements */ #if ENABLED(MIXING_EXTRUDER) - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER #error "For MIXING_EXTRUDER set MIXING_STEPPERS > 1 instead of EXTRUDERS > 1." #elif MIXING_STEPPERS < 2 #error "You must set MIXING_STEPPERS >= 2 for a mixing extruder." diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp index 6044d0a951eb..7f3f507fd64f 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp @@ -96,7 +96,7 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { #else PIN_DISABLED(1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT) #endif - #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2) && EXTRUDERS > 1 + #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2) PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, FIL_RUNOUT_STATE) #else PIN_DISABLED(3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.cpp index fb90ae1133c7..8a5c675facc4 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.cpp @@ -34,7 +34,7 @@ void LinearAdvanceScreen::onRedraw(draw_mode_t what) { widgets_t w(what); w.precision(2, DEFAULT_LOWEST).color(e_axis); w.heading( GET_TEXT_F(MSG_LINEAR_ADVANCE)); - #if EXTRUDERS == 1 + #if !HAS_MULTI_EXTRUDER w.adjuster( 2, GET_TEXT_F(MSG_LINEAR_ADVANCE_K), getLinearAdvance_mm_mm_s(E0) ); #else w.adjuster( 2, GET_TEXT_F(MSG_LINEAR_ADVANCE_K1), getLinearAdvance_mm_mm_s(E0) ); @@ -55,7 +55,7 @@ bool LinearAdvanceScreen::onTouchHeld(uint8_t tag) { switch (tag) { case 2: UI_DECREMENT(LinearAdvance_mm_mm_s, E0); break; case 3: UI_INCREMENT(LinearAdvance_mm_mm_s, E0); break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 4: UI_DECREMENT(LinearAdvance_mm_mm_s, E1); break; case 5: UI_INCREMENT(LinearAdvance_mm_mm_s, E1); break; #if EXTRUDERS > 2 diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp index 95e29c197de6..2316f93ee236 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.cpp @@ -41,7 +41,7 @@ void MaxVelocityScreen::onRedraw(draw_mode_t what) { w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_VMAX_Z), getAxisMaxFeedrate_mm_s(Z) ); #if EXTRUDERS == 1 || DISABLED(DISTINCT_E_FACTORS) w.color(e_axis) .adjuster( 8, GET_TEXT_F(MSG_VMAX_E), getAxisMaxFeedrate_mm_s(E0) ); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER w.heading(GET_TEXT_F(MSG_VMAX_E)); w.color(e_axis) .adjuster( 8, F(LCD_STR_E0), getAxisMaxFeedrate_mm_s(E0) ); w.color(e_axis) .adjuster( 10, F(LCD_STR_E1), getAxisMaxFeedrate_mm_s(E1) ); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp index 14ca6fe2973e..5dd3174821e2 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.cpp @@ -55,7 +55,7 @@ void MoveAxisScreen::onRedraw(draw_mode_t what) { w.color(Theme::e_axis); #if EXTRUDERS == 1 w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E), screen_data.MoveAxisScreen.e_rel[0], canMove(E0)); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), screen_data.MoveAxisScreen.e_rel[0], canMove(E0)); w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), screen_data.MoveAxisScreen.e_rel[1], canMove(E1)); #if EXTRUDERS > 2 @@ -82,7 +82,7 @@ bool MoveAxisScreen::onTouchHeld(uint8_t tag) { // For extruders, also update relative distances. case 8: UI_DECREMENT_AXIS(E0); screen_data.MoveAxisScreen.e_rel[0] -= increment; break; case 9: UI_INCREMENT_AXIS(E0); screen_data.MoveAxisScreen.e_rel[0] += increment; break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 10: UI_DECREMENT_AXIS(E1); screen_data.MoveAxisScreen.e_rel[1] -= increment; break; case 11: UI_INCREMENT_AXIS(E1); screen_data.MoveAxisScreen.e_rel[1] += increment; break; #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp index 091ad8f124fa..ed3c8d999b4b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.cpp @@ -33,7 +33,7 @@ using namespace ExtUI; void NudgeNozzleScreen::onEntry() { screen_data.NudgeNozzleScreen.show_offsets = false; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER screen_data.NudgeNozzleScreen.link_nozzles = true; #endif screen_data.NudgeNozzleScreen.rel.reset(); @@ -52,11 +52,11 @@ void NudgeNozzleScreen::onRedraw(draw_mode_t what) { #endif w.color(z_axis).adjuster(6, GET_TEXT_F(MSG_AXIS_Z), screen_data.NudgeNozzleScreen.rel.z / getAxisSteps_per_mm(Z)); w.increments(); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER w.toggle(8, GET_TEXT_F(MSG_ADJUST_BOTH_NOZZLES), screen_data.NudgeNozzleScreen.link_nozzles); #endif - #if EXTRUDERS > 1 || HAS_BED_PROBE + #if HAS_MULTI_EXTRUDER || HAS_BED_PROBE w.toggle(9, GET_TEXT_F(MSG_SHOW_OFFSETS), screen_data.NudgeNozzleScreen.show_offsets); if (screen_data.NudgeNozzleScreen.show_offsets) { @@ -82,7 +82,7 @@ void NudgeNozzleScreen::onRedraw(draw_mode_t what) { bool NudgeNozzleScreen::onTouchHeld(uint8_t tag) { const float inc = getIncrement(); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER const bool link = screen_data.NudgeNozzleScreen.link_nozzles; #else constexpr bool link = true; @@ -95,13 +95,13 @@ bool NudgeNozzleScreen::onTouchHeld(uint8_t tag) { case 5: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps( steps, Y, link); screen_data.NudgeNozzleScreen.rel.y += steps; break; case 6: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps(-steps, Z, link); screen_data.NudgeNozzleScreen.rel.z -= steps; break; case 7: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps( steps, Z, link); screen_data.NudgeNozzleScreen.rel.z += steps; break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 8: screen_data.NudgeNozzleScreen.link_nozzles = !link; break; #endif case 9: screen_data.NudgeNozzleScreen.show_offsets = !screen_data.NudgeNozzleScreen.show_offsets; break; default: return false; } - #if EXTRUDERS > 1 || HAS_BED_PROBE + #if HAS_MULTI_EXTRUDER || HAS_BED_PROBE SaveSettingsDialogBox::settingsChanged(); #endif return true; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h index a274fef9e747..dc38890a0efc 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screen_data.h @@ -86,7 +86,7 @@ union screen_data_t { struct { struct base_numeric_adjustment_t placeholder; xyz_int_t rel; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER bool link_nozzles; #endif bool show_offsets; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp index a8e948a9c3ed..e89bbd20201f 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.cpp @@ -40,7 +40,7 @@ void StepperCurrentScreen::onRedraw(draw_mode_t what) { w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getAxisCurrent_mA(Z) ); #if EXTRUDERS == 1 w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AXIS_E), getAxisCurrent_mA(E0) ); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), getAxisCurrent_mA(E0) ); w.color(e_axis).adjuster(10, GET_TEXT_F(MSG_AXIS_E2), getAxisCurrent_mA(E1) ); #if EXTRUDERS > 2 @@ -64,7 +64,7 @@ bool StepperCurrentScreen::onTouchHeld(uint8_t tag) { case 7: UI_INCREMENT(AxisCurrent_mA, Z ); break; case 8: UI_DECREMENT(AxisCurrent_mA, E0); break; case 9: UI_INCREMENT(AxisCurrent_mA, E0); break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 10: UI_DECREMENT(AxisCurrent_mA, E1); break; case 11: UI_INCREMENT(AxisCurrent_mA, E1); break; #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.cpp index f3957c0173bc..92035d1b1c04 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.cpp @@ -40,7 +40,7 @@ void StepsScreen::onRedraw(draw_mode_t what) { w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getAxisSteps_per_mm(Z) ); #if EXTRUDERS == 1 || DISABLED(DISTINCT_E_FACTORS) w.color(e_axis) .adjuster( 8, GET_TEXT_F(MSG_AXIS_E), getAxisSteps_per_mm(E0) ); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER w.color(e_axis) .adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), getAxisSteps_per_mm(E0) ); w.color(e_axis) .adjuster(10, GET_TEXT_F(MSG_AXIS_E2), getAxisSteps_per_mm(E1) ); #if EXTRUDERS > 2 @@ -64,7 +64,7 @@ bool StepsScreen::onTouchHeld(uint8_t tag) { case 7: UI_INCREMENT(AxisSteps_per_mm, Z); break; case 8: UI_DECREMENT(AxisSteps_per_mm, E0); break; case 9: UI_INCREMENT(AxisSteps_per_mm, E0); break; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER case 10: UI_DECREMENT(AxisSteps_per_mm, E1); break; case 11: UI_INCREMENT(AxisSteps_per_mm, E1); break; #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp index 321c608abd92..0f1fdaceaca5 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp @@ -127,9 +127,7 @@ void StressTestScreen::onIdle() { injectCommands_P(PSTR( "G0 X100 Y100 Z100 F6000\n" "T0\nG4 S1" - #if EXTRUDERS > 1 - "\nT1\nG4 S1" - #endif + TERN_(HAS_MULTI_EXTRUDER, "\nT1\nG4 S1") "\nG0 X150 Y150 Z150" )); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp index 264d528c0311..3589b96d6a9a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp @@ -70,7 +70,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { //planner.flow_percentage[1] = planner.flow_percentage[0]; //planner.e_factor[1]= planner.flow_percentage[1]*0.01; planner.refresh_e_factor(0); - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER planner.flow_percentage[1] = planner.flow_percentage[0]; planner.refresh_e_factor(1); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index aad5e4362e38..3b4fc8d2071c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -95,7 +95,7 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { //saved_feedrate_percentage = feedrate_percentage; planner.flow_percentage[0] = 100; planner.e_factor[0] = planner.flow_percentage[0] * 0.01f; - #if EXTRUDERS == 2 + #if HAS_MULTI_EXTRUDER planner.flow_percentage[1] = 100; planner.e_factor[1] = planner.flow_percentage[1] * 0.01f; #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index ca84b4b5ecdd..95d0a15bea72 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -90,7 +90,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - if (EXTRUDERS == 2) { + if (ENABLED(HAS_MULTI_EXTRUDER)) { if (uiCfg.curSprayerChoose == 0) { uiCfg.curSprayerChoose = 1; queue.inject_P(PSTR("T1")); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp index 801114e6b2ea..196522b8d42d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -61,7 +61,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); } } - #if !defined(SINGLENOZZLE) && EXTRUDERS >= 2 + #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); @@ -117,7 +117,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { if (uiCfg.curTempType == 0) { - if (EXTRUDERS == 2) { + if (ENABLED(HAS_MULTI_EXTRUDER)) { if (uiCfg.curSprayerChoose == 0) { uiCfg.curSprayerChoose = 1; } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index 2079ed824560..e5a7bb18d999 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -242,8 +242,10 @@ void lv_draw_printing(void) { #endif // if 1 lv_obj_set_pos(buttonExt1, 205, 136); - if (EXTRUDERS == 2) + + #if HAS_MULTI_EXTRUDER lv_obj_set_pos(buttonExt2, 350, 136); + #endif #if HAS_HEATED_BED lv_obj_set_pos(buttonBedstate, 205, 186); @@ -275,11 +277,11 @@ void lv_draw_printing(void) { lv_obj_set_style(labelExt1, &tft_style_label_rel); lv_obj_set_pos(labelExt1, 250, 146); - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER labelExt2 = lv_label_create(scr, NULL); lv_obj_set_style(labelExt2, &tft_style_label_rel); lv_obj_set_pos(labelExt2, 395, 146); - } + #endif #if HAS_HEATED_BED labelBed = lv_label_create(scr, NULL); @@ -344,11 +346,11 @@ void disp_ext_temp() { sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); lv_label_set_text(labelExt1, public_buf_l); - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER ZERO(public_buf_l); sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target); lv_label_set_text(labelExt2, public_buf_l); - } + #endif } void disp_bed_temp() { diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 1637d32877e4..afc9c6692e00 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -61,7 +61,7 @@ #include "../../libs/numtostr.h" #endif -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../module/tool_change.h" #endif @@ -348,7 +348,7 @@ namespace ExtUI { } void setActiveTool(const extruder_t extruder, bool no_move) { - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER const uint8_t e = extruder - E0; if (e != active_extruder) tool_change(e, no_move); active_extruder = e; @@ -699,21 +699,17 @@ namespace ExtUI { */ void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles) { const float mm = steps * planner.steps_to_mm[axis]; + UNUSED(mm); if (!babystepAxis_steps(steps, axis)) return; #if ENABLED(BABYSTEP_ZPROBE_OFFSET) // Make it so babystepping in Z adjusts the Z probe offset. - if (axis == Z - #if EXTRUDERS > 1 - && (linked_nozzles || active_extruder == 0) - #endif - ) probe.offset.z += mm; - #else - UNUSED(mm); + if (axis == Z && TERN1(HAS_MULTI_EXTRUDER, linked_nozzles || active_extruder == 0)) + probe.offset.z += mm; #endif - #if EXTRUDERS > 1 && HAS_HOTEND_OFFSET + #if HAS_MULTI_EXTRUDER && HAS_HOTEND_OFFSET /** * When linked_nozzles is false, as an axis is babystepped * adjust the hotend offsets so that the other nozzles are @@ -730,7 +726,6 @@ namespace ExtUI { } #else UNUSED(linked_nozzles); - UNUSED(mm); #endif } diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 9978bc7eabef..5bca89141f8b 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -111,7 +111,7 @@ void menu_backlash(); #if ENABLED(LIN_ADVANCE) #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); #endif @@ -122,7 +122,7 @@ void menu_backlash(); #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) EDIT_ITEM_FAST(float42_52, MSG_VOLUMETRIC_LIMIT, &planner.volumetric_extruder_limit[active_extruder], 0.0f, 20.0f, planner.calculate_volumetric_extruder_limits); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_FAST_N(float42_52, n, MSG_VOLUMETRIC_LIMIT_E, &planner.volumetric_extruder_limit[n], 0.0f, 20.00f, planner.calculate_volumetric_extruder_limits); #endif @@ -130,7 +130,7 @@ void menu_backlash(); if (parser.volumetric_enabled) { EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); #endif @@ -141,13 +141,13 @@ void menu_backlash(); constexpr float extrude_maxlength = TERN(PREVENT_LENGTHY_EXTRUDE, EXTRUDE_MAXLENGTH, 999); EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength); #endif EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength); #endif @@ -583,7 +583,7 @@ void menu_advanced_settings() { #elif ENABLED(LIN_ADVANCE) #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER LOOP_L_N(n, E_STEPPERS) EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); #endif diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index a77e9a735462..2953b3b46454 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -94,7 +94,7 @@ void menu_advanced_settings(); #endif -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "../../module/tool_change.h" @@ -280,17 +280,17 @@ void menu_advanced_settings(); EDIT_ITEM(bool, MSG_AUTORETRACT, &fwretract.autoretract_enabled, fwretract.refresh_autoretract); #endif EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT, &fwretract.settings.retract_length, 0, 100); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_SWAP, &fwretract.settings.swap_retract_length, 0, 100); #endif EDIT_ITEM(float3, MSG_CONTROL_RETRACTF, &fwretract.settings.retract_feedrate_mm_s, 1, 999); EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_ZHOP, &fwretract.settings.retract_zraise, 0, 999); EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_RECOVER, &fwretract.settings.retract_recover_extra, -100, 100); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_RECOVER_SWAP, &fwretract.settings.swap_retract_recover_extra, -100, 100); #endif EDIT_ITEM(float3, MSG_CONTROL_RETRACT_RECOVERF, &fwretract.settings.retract_recover_feedrate_mm_s, 1, 999); - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER EDIT_ITEM(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &fwretract.settings.swap_retract_recover_feedrate_mm_s, 1, 999); #endif END_MENU(); @@ -380,7 +380,7 @@ void menu_configuration() { // // Set single nozzle filament retract and prime length // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER SUBMENU(MSG_TOOL_CHANGE, menu_tool_change); #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) SUBMENU(MSG_TOOL_MIGRATION, menu_toolchange_migration); diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index c02906f7f946..758d75c8e915 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -215,7 +215,7 @@ void menu_tune() { #if EXTRUDERS EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); }); // Flow En: - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); #endif @@ -227,7 +227,7 @@ void menu_tune() { #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS) #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999); - #elif EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER LOOP_L_N(n, EXTRUDERS) EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999); #endif diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index b30f6e49c9e0..fc55c3c2f6c9 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -695,7 +695,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #if IS_KINEMATIC - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER const int8_t old_extruder = active_extruder; if (axis == E_AXIS) active_extruder = e_index; #endif @@ -716,9 +716,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { prepare_internal_move_to_destination(fr_mm_s); // will set current_position from destination processing = false; - #if EXTRUDERS > 1 - active_extruder = old_extruder; - #endif + TERN_(HAS_MULTI_EXTRUDER, active_extruder = old_extruder); #else diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 1169ede2dc1e..a3a89736e5aa 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -505,7 +505,7 @@ void Endstops::update() { // With Dual X, endstops are only checked in the homing direction for the active extruder #if ENABLED(DUAL_X_CARRIAGE) - #define E0_ACTIVE stepper.movement_extruder() == 0 + #define E0_ACTIVE stepper.last_moved_extruder == 0 #define X_MIN_TEST() ((X_HOME_DIR < 0 && E0_ACTIVE) || (X2_HOME_DIR < 0 && !E0_ACTIVE)) #define X_MAX_TEST() ((X_HOME_DIR > 0 && E0_ACTIVE) || (X2_HOME_DIR > 0 && !E0_ACTIVE)) #else diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 2f12302e5915..b904309018d6 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -111,7 +111,7 @@ xyze_pos_t destination; // {0} #endif // The active extruder (tool). Set with T command. -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER uint8_t active_extruder = 0; // = 0 #endif diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 052e3180c86e..2b108b053177 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -98,7 +98,7 @@ extern feedRate_t feedrate_mm_s; extern int16_t feedrate_percentage; // The active extruder (tool). Set with T command. -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER extern uint8_t active_extruder; #else constexpr uint8_t active_extruder = 0; diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 82c62ed579de..30e1ffb0cafb 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1992,7 +1992,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->e_to_p_pressure = baricuda_e_to_p_pressure; #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER block->extruder = extruder; #endif @@ -2843,7 +2843,7 @@ bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, con FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER block->extruder = extruder; #endif diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index f3a3a0e0fc7c..660d9ad5aa1e 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -164,7 +164,7 @@ typedef struct block_t { }; uint32_t step_event_count; // The number of step events required to complete this block - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER uint8_t extruder; // The extruder to move (if E move) #else static constexpr uint8_t extruder = 0; diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 3cb88da4eee1..6608b4033265 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -115,7 +115,7 @@ extern float other_extruder_advance_K[EXTRUDERS]; #endif -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER #include "tool_change.h" void M217_report(const bool eeprom); #endif @@ -388,7 +388,7 @@ typedef struct SettingsDataStruct { // // Tool-change settings // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER toolchange_settings_t toolchange_settings; // M217 S P R #endif @@ -1320,7 +1320,7 @@ void MarlinSettings::postprocess() { // Multiple Extruders // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER _FIELD_TEST(toolchange_settings); EEPROM_WRITE(toolchange_settings); #endif @@ -2167,7 +2167,7 @@ void MarlinSettings::postprocess() { // // Tool-change settings // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER _FIELD_TEST(toolchange_settings); EEPROM_READ(toolchange_settings); #endif @@ -2488,7 +2488,7 @@ void MarlinSettings::reset() { // Tool-change Settings // - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) toolchange_settings.swap_length = TOOLCHANGE_FS_LENGTH; toolchange_settings.extra_resume = TOOLCHANGE_FS_EXTRA_RESUME_LENGTH; @@ -3719,7 +3719,7 @@ void MarlinSettings::reset() { #endif #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER CONFIG_ECHO_HEADING("Tool-changing:"); CONFIG_ECHO_START(); M217_report(true); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index fab1a615482d..56a75d1b4812 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -155,7 +155,7 @@ uint8_t Stepper::last_direction_bits, // = 0 bool Stepper::abort_current_block; -#if DISABLED(MIXING_EXTRUDER) && EXTRUDERS > 1 +#if DISABLED(MIXING_EXTRUDER) && HAS_MULTI_EXTRUDER uint8_t Stepper::last_moved_extruder = 0xFF; #endif @@ -191,7 +191,7 @@ uint32_t Stepper::advance_divisor = 0, Stepper::decelerate_after, // The count at which to start decelerating Stepper::step_event_count; // The total event count for the current block -#if EXTRUDERS > 1 || ENABLED(MIXING_EXTRUDER) +#if EITHER(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER) uint8_t Stepper::stepper_extruder; #else constexpr uint8_t Stepper::stepper_extruder; @@ -357,11 +357,11 @@ xyze_int8_t Stepper::count_direction{0}; #elif ENABLED(DUAL_X_CARRIAGE) #define X_APPLY_DIR(v,ALWAYS) do{ \ if (extruder_duplication_enabled || ALWAYS) { X_DIR_WRITE(v); X2_DIR_WRITE(mirrored_duplication_mode ? !(v) : v); } \ - else if (movement_extruder()) X2_DIR_WRITE(v); else X_DIR_WRITE(v); \ + else if (last_moved_extruder) X2_DIR_WRITE(v); else X_DIR_WRITE(v); \ }while(0) #define X_APPLY_STEP(v,ALWAYS) do{ \ if (extruder_duplication_enabled || ALWAYS) { X_STEP_WRITE(v); X2_STEP_WRITE(v); } \ - else if (movement_extruder()) X2_STEP_WRITE(v); else X_STEP_WRITE(v); \ + else if (last_moved_extruder) X2_STEP_WRITE(v); else X_STEP_WRITE(v); \ }while(0) #else #define X_APPLY_DIR(v,Q) X_DIR_WRITE(v) @@ -2131,7 +2131,7 @@ uint32_t Stepper::block_phase_isr() { MIXER_STEPPER_SETUP(); #endif - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER stepper_extruder = current_block->extruder; #endif @@ -2156,7 +2156,7 @@ uint32_t Stepper::block_phase_isr() { || TERN(MIXING_EXTRUDER, false, stepper_extruder != last_moved_extruder) ) { last_direction_bits = current_block->direction_bits; - #if EXTRUDERS > 1 + #if HAS_MULTI_EXTRUDER last_moved_extruder = stepper_extruder; #endif diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 3b68553689cc..f83142444a49 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -263,10 +263,10 @@ class Stepper { static bool abort_current_block; // Signals to the stepper that current block should be aborted // Last-moved extruder, as set when the last movement was fetched from planner - #if EXTRUDERS < 2 - static constexpr uint8_t last_moved_extruder = 0; - #elif DISABLED(MIXING_EXTRUDER) + #if HAS_MULTI_EXTRUDER static uint8_t last_moved_extruder; + #else + static constexpr uint8_t last_moved_extruder = 0; #endif #if ENABLED(X_DUAL_ENDSTOPS) @@ -304,7 +304,7 @@ class Stepper { decelerate_after, // The point from where we need to start decelerating step_event_count; // The total event count for the current block - #if EXTRUDERS > 1 || ENABLED(MIXING_EXTRUDER) + #if EITHER(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER) static uint8_t stepper_extruder; #else static constexpr uint8_t stepper_extruder = 0; @@ -451,11 +451,6 @@ class Stepper { // The last movement direction was not null on the specified axis. Note that motor direction is not necessarily the same. FORCE_INLINE static bool axis_is_moving(const AxisEnum axis) { return TEST(axis_did_move, axis); } - // The extruder associated to the last movement - FORCE_INLINE static uint8_t movement_extruder() { - return (EXTRUDERS > 1 && DISABLED(MIXING_EXTRUDER)) ? last_moved_extruder : 0; - } - // Handle a triggered endstop static void endstop_triggered(const AxisEnum axis); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 855756026684..0f823cfbd000 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -36,7 +36,7 @@ #define DEBUG_OUT ENABLED(DEBUG_TOOL_CHANGE) #include "../core/debug_out.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER toolchange_settings_t toolchange_settings; // Initialized by settings.load() #endif @@ -870,7 +870,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (new_tool) invalid_extruder_error(new_tool); return; - #else // EXTRUDERS > 1 + #elif HAS_MULTI_EXTRUDER planner.synchronize(); @@ -1197,7 +1197,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(active_extruder)); - #endif // EXTRUDERS > 1 + #endif // HAS_MULTI_EXTRUDER } #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index d0cb57841bf1..38347191d390 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -24,7 +24,7 @@ #include "../inc/MarlinConfigPre.h" #include "../core/types.h" -#if EXTRUDERS > 1 +#if HAS_MULTI_EXTRUDER typedef struct { #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index 5f61389cf977..169f74b43787 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -354,7 +354,7 @@ #endif #endif -#elif EXTRUDERS > 1 || ENABLED(MIXING_EXTRUDER) +#elif EITHER(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER) #undef _E1_PINS #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, _E1_CS _E1_MS1 _E1_MS2 _E1_MS3 @@ -383,7 +383,7 @@ #endif // EXTRUDERS > 3 || MIXING_EXTRUDER > 3 #endif // EXTRUDERS > 2 || MIXING_EXTRUDER > 2 -#endif // EXTRUDERS > 1 || MIXING_EXTRUDER +#endif // HAS_MULTI_EXTRUDER || MIXING_EXTRUDER // // Heaters, Fans, Temp Sensors diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index e27e628b9a0d..e88e74e81d04 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -91,9 +91,6 @@ #if EXTRUDERS #define HAS_EXTRUDERS - #if EXTRUDERS > 1 - #define HAS_MULTI_EXTRUDER - #endif #endif #if HAS_LCD_MENU From 60ab7a1ddbda1b1a6d20cbeb5c574ce775f57a4b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 20 Sep 2020 19:07:59 -0500 Subject: [PATCH 24/63] Cleanup before MKS changes --- Marlin/src/HAL/DUE/usb/compiler.h | 39 ++-- Marlin/src/HAL/STM32/tft/tft_fsmc.cpp | 2 +- .../archim2-flash/flash_storage.cpp | 12 +- .../ftdi_eve_lib/extended/dl_cache.cpp | 3 +- .../ftdi_eve_lib/extended/grid_layout.h | 4 +- .../ftdi_eve_lib/extended/screen_types.cpp | 5 +- .../ftdi_eve_lib/extended/text_box.cpp | 8 +- .../ftdi_eve_lib/extended/text_ellipsis.cpp | 6 +- .../screens/bed_mesh_screen.cpp | 4 +- .../screens/files_screen.cpp | 2 +- .../screens/interface_settings_screen.cpp | 4 +- .../screens/interface_sounds_screen.cpp | 2 +- .../screens/status_screen.cpp | 13 +- .../screens/stress_test_screen.cpp | 4 +- .../src/lcd/extui/lib/mks_ui/draw_about.cpp | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_about.h | 4 +- .../lib/mks_ui/draw_acceleration_settings.h | 4 +- .../extui/lib/mks_ui/draw_advance_settings.h | 4 +- .../extui/lib/mks_ui/draw_change_speed.cpp | 24 +-- .../lcd/extui/lib/mks_ui/draw_change_speed.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h | 4 +- .../extui/lib/mks_ui/draw_eeprom_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_error_message.h | 4 +- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 21 ++- .../src/lcd/extui/lib/mks_ui/draw_extrusion.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp | 27 +-- Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp | 1 - Marlin/src/lcd/extui/lib/mks_ui/draw_home.h | 4 +- .../lcd/extui/lib/mks_ui/draw_jerk_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_language.cpp | 21 +-- .../src/lcd/extui/lib/mks_ui/draw_language.h | 4 +- .../lcd/extui/lib/mks_ui/draw_machine_para.h | 4 +- .../extui/lib/mks_ui/draw_machine_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_manuaLevel.cpp | 16 +- .../lcd/extui/lib/mks_ui/draw_manuaLevel.h | 4 +- .../lib/mks_ui/draw_max_feedrate_settings.h | 4 +- .../extui/lib/mks_ui/draw_motor_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_move_motor.cpp | 20 +-- .../lcd/extui/lib/mks_ui/draw_move_motor.h | 4 +- .../lcd/extui/lib/mks_ui/draw_number_key.cpp | 15 +- .../lcd/extui/lib/mks_ui/draw_number_key.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_operation.h | 4 +- .../lcd/extui/lib/mks_ui/draw_pause_message.h | 4 +- .../extui/lib/mks_ui/draw_pause_position.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 13 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.h | 4 +- .../lcd/extui/lib/mks_ui/draw_print_file.cpp | 4 +- .../lcd/extui/lib/mks_ui/draw_print_file.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_printing.h | 4 +- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 10 +- .../lcd/extui/lib/mks_ui/draw_ready_print.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_set.h | 4 +- .../lcd/extui/lib/mks_ui/draw_step_settings.h | 4 +- .../lib/mks_ui/draw_tmc_current_settings.cpp | 1 + .../lib/mks_ui/draw_tmc_current_settings.h | 4 +- .../lib/mks_ui/draw_tmc_step_mode_settings.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 2 +- Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h | 4 +- .../extui/lib/mks_ui/printer_operation.cpp | 1 + .../lcd/extui/lib/mks_ui/printer_operation.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h | 4 +- Marlin/src/lcd/tft/st7796s.h | 168 +++++++++--------- Marlin/src/pins/pins.h | 20 +-- 66 files changed, 296 insertions(+), 320 deletions(-) diff --git a/Marlin/src/HAL/DUE/usb/compiler.h b/Marlin/src/HAL/DUE/usb/compiler.h index 7b746543c4c6..879007fa2a90 100644 --- a/Marlin/src/HAL/DUE/usb/compiler.h +++ b/Marlin/src/HAL/DUE/usb/compiler.h @@ -173,11 +173,11 @@ # define __always_inline __forceinline #elif (defined __GNUC__) #ifdef __always_inline -# undef __always_inline +# undef __always_inline #endif -# define __always_inline inline __attribute__((__always_inline__)) +# define __always_inline inline __attribute__((__always_inline__)) #elif (defined __ICCARM__) -# define __always_inline _Pragma("inline=forced") +# define __always_inline _Pragma("inline=forced") #endif /** @@ -188,11 +188,11 @@ * heuristics and not inline the function. */ #ifdef __CC_ARM -# define __no_inline __attribute__((noinline)) +# define __no_inline __attribute__((noinline)) #elif (defined __GNUC__) -# define __no_inline __attribute__((__noinline__)) +# define __no_inline __attribute__((__noinline__)) #elif (defined __ICCARM__) -# define __no_inline _Pragma("inline=never") +# define __no_inline _Pragma("inline=never") #endif /*! \brief This macro is used to test fatal errors. @@ -211,9 +211,9 @@ # else #undef TEST_SUITE_DEFINE_ASSERT_MACRO # define Assert(expr) \ - {\ - if (!(expr)) while (true);\ - } + {\ + if (!(expr)) while (true);\ + } # endif #else # define Assert(expr) ((void) 0) @@ -1106,17 +1106,16 @@ static inline uint16_t convert_byte_array_to_16_bit(uint8_t *data) /* Converts a 8 Byte array into a 32-Bit value */ static inline uint32_t convert_byte_array_to_32_bit(uint8_t *data) { - union - { - uint32_t u32; - uint8_t u8[8]; - }long_addr; - uint8_t index; - for (index = 0; index < 4; index++) - { - long_addr.u8[index] = *data++; - } - return long_addr.u32; + union + { + uint32_t u32; + uint8_t u8[8]; + }long_addr; + uint8_t index; + for (index = 0; index < 4; index++) { + long_addr.u8[index] = *data++; + } + return long_addr.u32; } /** diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index f11fab39dbad..3a080d5e271e 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -87,7 +87,7 @@ void TFT_FSMC::Init() { __HAL_RCC_FSMC_CLK_ENABLE(); - for(uint16_t i = 0; PinMap_FSMC[i].pin != NC; i++) + for (uint16_t i = 0; PinMap_FSMC[i].pin != NC; i++) pinmap_pinout(PinMap_FSMC[i].pin, PinMap_FSMC); pinmap_pinout(digitalPinToPinName(TFT_CS_PIN), PinMap_FSMC_CS); pinmap_pinout(digitalPinToPinName(TFT_RS_PIN), PinMap_FSMC_RS); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp index 0c38c8216c1d..6a635b9ddb94 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp @@ -188,7 +188,7 @@ bool UIFlashStorage::is_present = false; } void UIFlashStorage::initialize() { - for(uint8_t i = 0; i < 10; i++) { + for (uint8_t i = 0; i < 10; i++) { if (check_known_device()) { is_present = true; break; @@ -239,7 +239,7 @@ bool UIFlashStorage::is_present = false; uint16_t stride = 4 + block_size; int32_t read_offset = -1; - for(uint32_t offset = 0; offset < (data_storage_area_size - stride); offset += stride) { + for (uint32_t offset = 0; offset < (data_storage_area_size - stride); offset += stride) { uint32_t delim; spi_read_begin(offset); spi_read_bulk (&delim, sizeof(delim)); @@ -395,9 +395,8 @@ bool UIFlashStorage::is_present = false; uint32_t UIFlashStorage::get_media_file_start(uint8_t slot) { uint32_t addr = media_storage_addr + sizeof(uint32_t) * media_storage_slots; spi_read_begin(media_storage_addr); - for(uint8_t i = 0; i < slot; i++) { + for (uint8_t i = 0; i < slot; i++) addr += spi_read_32(); - } spi_read_end(); return addr; } @@ -442,7 +441,7 @@ bool UIFlashStorage::is_present = false; addr = get_media_file_start(slot); // Write out the file itself - for(;;) { + for (;;) { const int16_t nBytes = reader.read(buff, write_page_size); if (nBytes == -1) { SERIAL_ECHOLNPGM("Failed to read from file"); @@ -450,8 +449,7 @@ bool UIFlashStorage::is_present = false; } addr = write(addr, buff, nBytes); - if (nBytes != write_page_size) - break; + if (nBytes != write_page_size) break; TERN_(EXTENSIBLE_UI, ExtUI::yield()); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp index f736916a3be4..baed9f8502fe 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp @@ -69,9 +69,8 @@ using namespace FTDI; void DLCache::init() { CLCD::mem_write_32(DL_FREE_ADDR, DL_FREE_ADDR + 4); - for(uint8_t slot = 0; slot < DL_CACHE_SLOTS; slot++) { + for (uint8_t slot = 0; slot < DL_CACHE_SLOTS; slot++) save_slot(slot, 0, 0, 0); - } } bool DLCache::has_data() { diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h index 1975d36af716..e3c3ebb39d5a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h @@ -74,12 +74,12 @@ #define DRAW_LAYOUT_GRID \ { \ cmd.cmd(LINE_WIDTH(4)); \ - for(int i = 1; i <= GRID_COLS; i++) { \ + for (int i = 1; i <= GRID_COLS; i++) { \ cmd.cmd(BEGIN(LINES)); \ cmd.cmd(VERTEX2F(GRID_X(i) *16, 0 *16)); \ cmd.cmd(VERTEX2F(GRID_X(i) *16, FTDI::display_height *16)); \ } \ - for(int i = 1; i < GRID_ROWS; i++) { \ + for (int i = 1; i < GRID_ROWS; i++) { \ cmd.cmd(BEGIN(LINES)); \ cmd.cmd(VERTEX2F(0 *16, GRID_Y(i) *16)); \ cmd.cmd(VERTEX2F(FTDI::display_width *16, GRID_Y(i) *16)); \ diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.cpp index bebee5467da7..57a9e3e89b0a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.cpp @@ -26,7 +26,7 @@ /********************** VIRTUAL DISPATCH DATA TYPE ******************************/ uint8_t ScreenRef::lookupScreen(onRedraw_func_t onRedraw_ptr) { - for(uint8_t type = 0; type < functionTableSize; type++) { + for (uint8_t type = 0; type < functionTableSize; type++) { if (GET_METHOD(type, onRedraw) == onRedraw_ptr) { return type; } @@ -50,9 +50,8 @@ void ScreenRef::setScreen(onRedraw_func_t onRedraw_ptr) { } void ScreenRef::initializeAll() { - for(uint8_t type = 0; type < functionTableSize; type++) { + for (uint8_t type = 0; type < functionTableSize; type++) GET_METHOD(type, onStartup)(); - } } /********************** SCREEN STACK ******************************/ diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp index 9600bd128946..3616f15ab620 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp @@ -34,7 +34,7 @@ namespace FTDI { const char *p = str; end = str; uint16_t lw = 0, result = 0; - for(;;) { + for (;;) { utf8_char_t c = get_utf8_char_and_inc(p); if (c == ' ' || c == '\n' || c == '\0') { if (lw < w || end == str) { @@ -60,7 +60,7 @@ namespace FTDI { const char *line_end; const uint16_t wrap_width = width; width = height = 0; - for(;;) { + for (;;) { uint16_t line_width = find_line_break(fm, wrap_width, line_start, line_end); if (line_end == line_start) break; width = max(width, line_width); @@ -78,7 +78,7 @@ namespace FTDI { FontMetrics fm(font); // Shrink the font until we find a font that fits - for(;;) { + for (;;) { box_width = w; measure_text_box(fm, str, box_width, box_height); if (box_width <= (uint16_t)w && box_height <= (uint16_t)h) break; @@ -91,7 +91,7 @@ namespace FTDI { const char *line_start = str; const char *line_end; - for(;;) { + for (;;) { find_line_break(fm, w, line_start, line_end); if (line_end == line_start) break; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp index 266b6efdab1e..b2f62f060ccc 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp @@ -37,13 +37,13 @@ namespace FTDI { // split and still allow the ellipsis to fit. int16_t lineWidth = 0; char *breakPoint = str; - for(char* c = str; *c; c++) { + for (char* c = str; *c; c++) { lineWidth += fm.get_char_width(*c); - if(lineWidth + ellipsisWidth < w) + if (lineWidth + ellipsisWidth < w) breakPoint = c; } - if(lineWidth > w) { + if (lineWidth > w) { *breakPoint = '\0'; strcpy_P(breakPoint,PSTR("...")); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp index 5f7c8d3b9990..a11609dd97d2 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp @@ -253,7 +253,7 @@ void BedMeshScreen::drawHighlightedPointValue() { .tag(1).button( OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY)) .tag(0); - switch(screen_data.BedMeshScreen.message) { + switch (screen_data.BedMeshScreen.message) { case screen_data.BedMeshScreen.MSG_MESH_COMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE)); break; case screen_data.BedMeshScreen.MSG_MESH_INCOMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE)); break; default: break; @@ -321,7 +321,7 @@ bool BedMeshScreen::isMeshComplete(ExtUI::bed_mesh_t data) { } void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { - switch(state) { + switch (state) { case ExtUI::MESH_START: screen_data.BedMeshScreen.count = 0; screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_NONE; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.cpp index dd0eb263d5fa..f4c224dbe8cf 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.cpp @@ -115,7 +115,7 @@ void FilesScreen::drawFileList() { #define MARGIN_T 0 #define MARGIN_B 0 uint16_t fileIndex = screen_data.FilesScreen.cur_page * files_per_page; - for(uint8_t i = 0; i < files_per_page; i++, fileIndex++) { + for (uint8_t i = 0; i < files_per_page; i++, fileIndex++) { if (files.seek(fileIndex)) { drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.cpp index def31e4a403f..c806ef499b65 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.cpp @@ -222,7 +222,7 @@ void InterfaceSettingsScreen::saveSettings(char *buff) { eeprom.touch_transform_f = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_F); eeprom.display_h_offset_adj = CLCD::mem_read_16(CLCD::REG::HOFFSET) - FTDI::Hoffset; eeprom.display_v_offset_adj = CLCD::mem_read_16(CLCD::REG::VOFFSET) - FTDI::Voffset; - for(uint8_t i = 0; i < InterfaceSoundsScreen::NUM_EVENTS; i++) + for (uint8_t i = 0; i < InterfaceSoundsScreen::NUM_EVENTS; i++) eeprom.event_sounds[i] = InterfaceSoundsScreen::event_sounds[i]; memcpy(buff, &eeprom, sizeof(eeprom)); @@ -251,7 +251,7 @@ void InterfaceSettingsScreen::loadSettings(const char *buff) { CLCD::mem_write_32(CLCD::REG::TOUCH_TRANSFORM_F, eeprom.touch_transform_f); CLCD::mem_write_16(CLCD::REG::HOFFSET, eeprom.display_h_offset_adj + FTDI::Hoffset); CLCD::mem_write_16(CLCD::REG::VOFFSET, eeprom.display_v_offset_adj + FTDI::Voffset); - for(uint8_t i = 0; i < InterfaceSoundsScreen::NUM_EVENTS; i++) + for (uint8_t i = 0; i < InterfaceSoundsScreen::NUM_EVENTS; i++) InterfaceSoundsScreen::event_sounds[i] = eeprom.event_sounds[i]; TERN_(TOUCH_UI_DEVELOPER_MENU, StressTestScreen::startupCheck()); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_sounds_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_sounds_screen.cpp index 6c05c3a887ad..25a44c1adbb5 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_sounds_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_sounds_screen.cpp @@ -43,7 +43,7 @@ void InterfaceSoundsScreen::toggleSoundSelection(event_t event) { } void InterfaceSoundsScreen::setSoundSelection(event_t event, const SoundPlayer::sound_t* sound) { - for(uint8_t i = 0; i < SoundList::n; i++) + for (uint8_t i = 0; i < SoundList::n; i++) if (SoundList::data(i) == sound) event_sounds[event] = i; } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp index 6b258b53893b..fc7453fca70f 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.cpp @@ -176,11 +176,7 @@ void StatusScreen::draw_temperature(draw_mode_t what) { char bed_str[20]; char fan_str[20]; - sprintf_P( - fan_str, - PSTR("%-3d %%"), - int8_t(getActualFan_percent(FAN0)) - ); + sprintf_P(fan_str, PSTR("%-3d %%"), int8_t(getActualFan_percent(FAN0))); if (isHeaterIdle(BED)) format_temp_and_idle(bed_str, getActualTemp_celsius(BED)); @@ -193,16 +189,13 @@ void StatusScreen::draw_temperature(draw_mode_t what) { format_temp_and_temp(e0_str, getActualTemp_celsius(H0), getTargetTemp_celsius(H0)); - #if EXTRUDERS == 2 + #if HAS_MULTI_EXTRUDER if (isHeaterIdle(H1)) format_temp_and_idle(e1_str, getActualTemp_celsius(H1)); else format_temp_and_temp(e1_str, getActualTemp_celsius(H1), getTargetTemp_celsius(H1)); #else - strcpy_P( - e1_str, - PSTR("-") - ); + strcpy_P(e1_str, PSTR("-")); #endif cmd.tag(5) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp index 0f1fdaceaca5..44ee453f15e6 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.cpp @@ -38,7 +38,7 @@ using namespace ExtUI; void StressTestScreen::drawDots(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { CommandProcessor cmd; - for(uint8_t i = 0; i < 100; i++) { + for (uint8_t i = 0; i < 100; i++) { cmd.cmd(BEGIN(POINTS)) .cmd(POINT_SIZE(20*16)) .cmd(COLOR_RGB(random(0xFFFFFF))) @@ -111,7 +111,7 @@ void StressTestScreen::recursiveLockup() { void StressTestScreen::iterativeLockup() { screen_data.StressTestScreen.message = PSTR("Test 3: Printer will restart."); - for(;;) current_screen.onRefresh(); + for (;;) current_screen.onRefresh(); } void StressTestScreen::onIdle() { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp index 94a865d04557..e2df14a36b56 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp @@ -75,7 +75,7 @@ void lv_draw_about(void) { LV_IMG_DECLARE(bmp_pic); - /*Create an Image button*/ + // Create an Image button buttonBack = lv_imgbtn_create(scr, NULL); #if 1 @@ -88,8 +88,8 @@ void lv_draw_about(void) { lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - /*Create a label on the Image button*/ + // Create a label on the image button label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h index 4c6c288d088d..2ee7ec04c61a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_about(void); @@ -30,5 +30,5 @@ extern void lv_clear_about(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.h index b5b62fdc4ca1..6ab49713c9dd 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_acceleration_settings(void); extern void lv_clear_acceleration_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.h index bfd76125bb8a..84e4a4d4cf60 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_advance_settings(void); extern void lv_clear_advance_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp index 3589b96d6a9a..cc3f847bced7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp @@ -73,7 +73,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { #if HAS_MULTI_EXTRUDER planner.flow_percentage[1] = planner.flow_percentage[0]; planner.refresh_e_factor(1); - } + #endif } disp_print_speed(); } @@ -98,10 +98,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { //planner.flow_percentage[1] = planner.flow_percentage[0]; //planner.e_factor[1]= planner.flow_percentage[1] * 0.01; planner.refresh_e_factor(0); - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER planner.flow_percentage[1] = planner.flow_percentage[0]; planner.refresh_e_factor(1); - } + #endif } disp_print_speed(); } @@ -177,7 +177,7 @@ void lv_draw_change_speed(void) { LV_IMG_DECLARE(bmp_pic); - /*Create an Image button*/ + // Create an Image button buttonAdd = lv_imgbtn_create(scr, NULL); buttonDec = lv_imgbtn_create(scr, NULL); buttonMov = lv_imgbtn_create(scr, NULL); @@ -228,7 +228,7 @@ void lv_draw_change_speed(void) { lv_obj_set_pos(buttonStep, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonAdd, LV_LAYOUT_OFF); lv_btn_set_layout(buttonDec, LV_LAYOUT_OFF); lv_btn_set_layout(buttonMov, LV_LAYOUT_OFF); @@ -236,12 +236,12 @@ void lv_draw_change_speed(void) { lv_btn_set_layout(buttonStep, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - lv_obj_t * labelAdd = lv_label_create(buttonAdd, NULL); - lv_obj_t * labelDec = lv_label_create(buttonDec, NULL); - labelMov = lv_label_create(buttonMov, NULL); - labelExt = lv_label_create(buttonExt, NULL); - labelStep = lv_label_create(buttonStep, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + lv_obj_t *labelAdd = lv_label_create(buttonAdd, NULL); + lv_obj_t *labelDec = lv_label_create(buttonDec, NULL); + labelMov = lv_label_create(buttonMov, NULL); + labelExt = lv_label_create(buttonExt, NULL); + labelStep = lv_label_create(buttonStep, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelAdd, speed_menu.add); @@ -286,7 +286,7 @@ void disp_speed_step() { } void disp_print_speed() { - char buf[30] = {0}; + char buf[30] = { 0 }; public_buf_l[0] = '\0'; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h index d071da20bb11..c4996a3ef732 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif #define MIN_EXT_SPEED_PERCENT 10 @@ -36,5 +36,5 @@ extern void disp_speed_type(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h index a5b829a2cf94..f08c7b779ae1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif #define DIALOG_TYPE_STOP 0 @@ -79,5 +79,5 @@ extern void lv_clear_dialog(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.h index da699353babd..6d5ecf0870eb 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_eeprom_settings(void); extern void lv_clear_eeprom_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h index 010b612ff708..8f64d67f93da 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif #ifndef PGM_P @@ -34,5 +34,5 @@ extern void lv_clear_error_message(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index 95d0a15bea72..9f5977d70c70 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -100,9 +100,9 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { queue.inject_P(PSTR("T0")); } } - else { + else uiCfg.curSprayerChoose = 0; - } + extructAmount = 0; disp_hotend_temp(); disp_ext_type(); @@ -149,7 +149,6 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } } - void lv_draw_extrusion(void) { lv_obj_t *buttonAdd, *buttonDec, *buttonBack; @@ -174,7 +173,7 @@ void lv_draw_extrusion(void) { LV_IMG_DECLARE(bmp_pic); - /*Create an Image button*/ + // Create image buttons buttonAdd = lv_imgbtn_create(scr, NULL); buttonDec = lv_imgbtn_create(scr, NULL); buttoType = lv_imgbtn_create(scr, NULL); @@ -224,7 +223,7 @@ void lv_draw_extrusion(void) { lv_obj_set_pos(buttonSpeed, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonAdd, LV_LAYOUT_OFF); lv_btn_set_layout(buttonDec, LV_LAYOUT_OFF); lv_btn_set_layout(buttoType, LV_LAYOUT_OFF); @@ -232,12 +231,12 @@ void lv_draw_extrusion(void) { lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - lv_obj_t * labelAdd = lv_label_create(buttonAdd, NULL); - lv_obj_t * labelDec = lv_label_create(buttonDec, NULL); - labelType = lv_label_create(buttoType, NULL); - labelStep = lv_label_create(buttonStep, NULL); - labelSpeed = lv_label_create(buttonSpeed, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + lv_obj_t *labelAdd = lv_label_create(buttonAdd, NULL); + lv_obj_t *labelDec = lv_label_create(buttonDec, NULL); + labelType = lv_label_create(buttoType, NULL); + labelStep = lv_label_create(buttonStep, NULL); + labelSpeed = lv_label_create(buttonSpeed, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelAdd, extrude_menu.in); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h index a7b2afcd8ab5..576cc6c66c15 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_extrusion(void); @@ -35,5 +35,5 @@ extern void disp_extru_amount(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp index 4dcac62aeefd..e1975aca7e9c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp @@ -140,12 +140,12 @@ void lv_draw_fan(void) { LV_IMG_DECLARE(bmp_pic); - /*Create an Image button*/ - buttonAdd = lv_imgbtn_create(scr, NULL); - buttonDec = lv_imgbtn_create(scr, NULL); + // Create an Image button + buttonAdd = lv_imgbtn_create(scr, NULL); + buttonDec = lv_imgbtn_create(scr, NULL); buttonHigh = lv_imgbtn_create(scr, NULL); - buttonMid = lv_imgbtn_create(scr, NULL); - buttonOff = lv_imgbtn_create(scr, NULL); + buttonMid = lv_imgbtn_create(scr, NULL); + buttonOff = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_F_ADD, "bmp_Add.bin", 0); @@ -154,6 +154,7 @@ void lv_draw_fan(void) { lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel); lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); + #if 1 lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_F_DEC, "bmp_Dec.bin", 0); lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); @@ -184,6 +185,7 @@ void lv_draw_fan(void) { lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + #endif lv_obj_set_pos(buttonAdd, INTERVAL_V, titleHeight); @@ -193,7 +195,7 @@ void lv_draw_fan(void) { lv_obj_set_pos(buttonOff, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonAdd, LV_LAYOUT_OFF); lv_btn_set_layout(buttonDec, LV_LAYOUT_OFF); lv_btn_set_layout(buttonHigh, LV_LAYOUT_OFF); @@ -201,13 +203,12 @@ void lv_draw_fan(void) { lv_btn_set_layout(buttonOff, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - lv_obj_t * labelAdd = lv_label_create(buttonAdd, NULL); - lv_obj_t * labelDec = lv_label_create(buttonDec, NULL); - lv_obj_t * labelHigh = lv_label_create(buttonHigh, NULL); - lv_obj_t * labelMid = lv_label_create(buttonMid, NULL); - lv_obj_t * labelOff = lv_label_create(buttonOff, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); - + lv_obj_t *labelAdd = lv_label_create(buttonAdd, NULL); + lv_obj_t *labelDec = lv_label_create(buttonDec, NULL); + lv_obj_t *labelHigh = lv_label_create(buttonHigh, NULL); + lv_obj_t *labelMid = lv_label_create(buttonMid, NULL); + lv_obj_t *labelOff = lv_label_create(buttonOff, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelAdd, fan_menu.add); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h index ef17885926f8..602d02c6c044 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_fan(void); @@ -31,5 +31,5 @@ extern void disp_fan_value(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp index 35d442ebae76..595d1078c76a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp @@ -96,7 +96,6 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { lv_draw_tool(); } break; - } } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h index e93c0a0fad88..c5060127a876 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_home(void); @@ -30,5 +30,5 @@ extern void lv_clear_home(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.h index 5badcde52932..0531dae9da96 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_jerk_settings(void); extern void lv_clear_jerk_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp index 65d0961248ed..9029f6868c02 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp @@ -246,7 +246,7 @@ void lv_draw_language(void) { LV_IMG_DECLARE(bmp_pic); - /*Create an Image button*/ + // Create image buttons buttonCN = lv_imgbtn_create(scr, NULL); buttonT_CN = lv_imgbtn_create(scr, NULL); buttonEN = lv_imgbtn_create(scr, NULL); @@ -304,6 +304,7 @@ void lv_draw_language(void) { lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + #endif // if 1 lv_obj_set_pos(buttonCN, INTERVAL_V, titleHeight); @@ -315,7 +316,7 @@ void lv_draw_language(void) { lv_obj_set_pos(buttonIT, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonCN, LV_LAYOUT_OFF); lv_btn_set_layout(buttonT_CN, LV_LAYOUT_OFF); lv_btn_set_layout(buttonEN, LV_LAYOUT_OFF); @@ -325,14 +326,14 @@ void lv_draw_language(void) { lv_btn_set_layout(buttonIT, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - lv_obj_t * label_CN = lv_label_create(buttonCN, NULL); - lv_obj_t * label_T_CN = lv_label_create(buttonT_CN, NULL); - lv_obj_t * label_EN = lv_label_create(buttonEN, NULL); - lv_obj_t * label_RU = lv_label_create(buttonRU, NULL); - lv_obj_t * label_ES = lv_label_create(buttonES, NULL); - lv_obj_t * label_FR = lv_label_create(buttonFR, NULL); - lv_obj_t * label_IT = lv_label_create(buttonIT, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + lv_obj_t *label_CN = lv_label_create(buttonCN, NULL); + lv_obj_t *label_T_CN = lv_label_create(buttonT_CN, NULL); + lv_obj_t *label_EN = lv_label_create(buttonEN, NULL); + lv_obj_t *label_RU = lv_label_create(buttonRU, NULL); + lv_obj_t *label_ES = lv_label_create(buttonES, NULL); + lv_obj_t *label_FR = lv_label_create(buttonFR, NULL); + lv_obj_t *label_IT = lv_label_create(buttonIT, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); disp_language(gCfgItems.language, SELECTED); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h index 4b6b2b022169..ca6d40bfc3ca 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_language(void); @@ -30,5 +30,5 @@ extern void lv_clear_language(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.h index d75df293b11c..e830f75db7e5 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_machine_para(void); extern void lv_clear_machine_para(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.h index 37029c85c43c..38d02e718948 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_machine_settings(void); extern void lv_clear_machine_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp index ab4d9eb881ee..6530b1554c47 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp @@ -187,7 +187,7 @@ void lv_draw_manualLevel(void) { LV_IMG_DECLARE(bmp_pic); - /*Create an Image button*/ + // Create an Image button buttonPoint1 = lv_imgbtn_create(scr, NULL); buttonPoint2 = lv_imgbtn_create(scr, NULL); buttonPoint3 = lv_imgbtn_create(scr, NULL); @@ -240,7 +240,7 @@ void lv_draw_manualLevel(void) { lv_obj_set_pos(buttonPoint5, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonPoint1, LV_LAYOUT_OFF); lv_btn_set_layout(buttonPoint2, LV_LAYOUT_OFF); lv_btn_set_layout(buttonPoint3, LV_LAYOUT_OFF); @@ -248,12 +248,12 @@ void lv_draw_manualLevel(void) { lv_btn_set_layout(buttonPoint5, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - lv_obj_t * label_Point1 = lv_label_create(buttonPoint1, NULL); - lv_obj_t * label_Point2 = lv_label_create(buttonPoint2, NULL); - lv_obj_t * label_Point3 = lv_label_create(buttonPoint3, NULL); - lv_obj_t * label_Point4 = lv_label_create(buttonPoint4, NULL); - lv_obj_t * label_Point5 = lv_label_create(buttonPoint5, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + lv_obj_t *label_Point1 = lv_label_create(buttonPoint1, NULL); + lv_obj_t *label_Point2 = lv_label_create(buttonPoint2, NULL); + lv_obj_t *label_Point3 = lv_label_create(buttonPoint3, NULL); + lv_obj_t *label_Point4 = lv_label_create(buttonPoint4, NULL); + lv_obj_t *label_Point5 = lv_label_create(buttonPoint5, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(label_Point1, leveling_menu.position1); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h index 4ec33afce397..cfa10370e128 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_manualLevel(void); @@ -30,5 +30,5 @@ extern void lv_clear_manualLevel(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.h index 24edae27e415..78caca5adea4 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_max_feedrate_settings(void); extern void lv_clear_max_feedrate_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.h index bae1918ad581..9a1c7a4db517 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_motor_settings(void); extern void lv_clear_motor_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp index e0d29467e616..24abadb57c9a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp @@ -34,7 +34,7 @@ static lv_obj_t * scr; -static lv_obj_t * labelV, *buttonV; +static lv_obj_t *labelV, *buttonV; #define ID_M_X_P 1 #define ID_M_X_N 2 @@ -181,7 +181,7 @@ void lv_draw_move_motor(void) { LV_IMG_DECLARE(bmp_pic); - /*Create an Image button*/ + // Create an Image button buttonXI = lv_imgbtn_create(scr, NULL); buttonXD = lv_imgbtn_create(scr, NULL); buttonYI = lv_imgbtn_create(scr, NULL); @@ -249,7 +249,7 @@ void lv_draw_move_motor(void) { lv_obj_set_pos(buttonZD, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonXI, LV_LAYOUT_OFF); lv_btn_set_layout(buttonXD, LV_LAYOUT_OFF); lv_btn_set_layout(buttonYI, LV_LAYOUT_OFF); @@ -259,14 +259,14 @@ void lv_draw_move_motor(void) { lv_btn_set_layout(buttonV, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - lv_obj_t * labelXI = lv_label_create(buttonXI, NULL); - lv_obj_t * labelXD = lv_label_create(buttonXD, NULL); - lv_obj_t * labelYI = lv_label_create(buttonYI, NULL); - lv_obj_t * labelYD = lv_label_create(buttonYD, NULL); - lv_obj_t * labelZI = lv_label_create(buttonZI, NULL); - lv_obj_t * labelZD = lv_label_create(buttonZD, NULL); + lv_obj_t *labelXI = lv_label_create(buttonXI, NULL); + lv_obj_t *labelXD = lv_label_create(buttonXD, NULL); + lv_obj_t *labelYI = lv_label_create(buttonYI, NULL); + lv_obj_t *labelYD = lv_label_create(buttonYD, NULL); + lv_obj_t *labelZI = lv_label_create(buttonZI, NULL); + lv_obj_t *labelZD = lv_label_create(buttonZD, NULL); labelV = lv_label_create(buttonV, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelXI, move_menu.x_add); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h index c2583c7ef346..fdbb61f6f95f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_move_motor(void); @@ -31,5 +31,5 @@ extern void disp_move_dist(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp index 7a4e7257e203..2fe32b04c934 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp @@ -34,8 +34,9 @@ #include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" #include "../../../../gcode/queue.h" + #if ENABLED(POWER_LOSS_RECOVERY) - #include "../../../../../feature/powerloss.h" + #include "../../../../feature/powerloss.h" #endif #include "../../../../gcode/gcode.h" @@ -253,15 +254,12 @@ static void set_value_confirm() { switch (value) { case PrintAcceleration: planner.settings.acceleration = atof(key_value); - break; case RetractAcceleration: planner.settings.retract_acceleration = atof(key_value); - break; case TravelAcceleration: planner.settings.travel_acceleration = atof(key_value); - break; case XAcceleration: planner.settings.max_acceleration_mm_per_s2[X_AXIS] = atof(key_value); @@ -293,7 +291,6 @@ static void set_value_confirm() { case E1MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); break; - case XJerk: #if HAS_CLASSIC_JERK planner.max_jerk[X_AXIS] = atof(key_value); @@ -314,7 +311,6 @@ static void set_value_confirm() { planner.max_jerk[E_AXIS] = atof(key_value); #endif break; - case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); break; @@ -330,43 +326,36 @@ static void set_value_confirm() { case E1step: planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); break; - case Xcurrent: #if AXIS_IS_TMC(X) current_mA = atoi(key_value); stepperX.rms_current(current_mA); #endif break; - case Ycurrent: #if AXIS_IS_TMC(Y) current_mA = atoi(key_value); stepperY.rms_current(current_mA); #endif break; - case Zcurrent: #if AXIS_IS_TMC(Z) current_mA = atoi(key_value); stepperZ.rms_current(current_mA); #endif break; - case E0current: #if AXIS_IS_TMC(E0) current_mA = atoi(key_value); stepperE0.rms_current(current_mA); #endif break; - case E1current: #if AXIS_IS_TMC(E1) current_mA = atoi(key_value); stepperE1.rms_current(current_mA); #endif break; - - break; case pause_pos_x: gCfgItems.pausePosX = atof(key_value); update_spi_flash(); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.h index d35cee63439c..7902da36493a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_number_key(void); extern void lv_clear_number_key(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.h index e2eaaf06a499..cca1f6a2a5aa 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_operation(void); @@ -30,5 +30,5 @@ extern void lv_clear_operation(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h index ce541ee68b8d..7d55d8375601 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_pause_message(const PauseMessage msg); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.h index 5f1b4dc96091..3e9e0798271b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_pause_position(void); extern void lv_clear_pause_position(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp index 196522b8d42d..ff7641ddfda3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -267,7 +267,7 @@ void lv_draw_preHeat(void) { lv_obj_set_pos(buttonOff, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonAdd, LV_LAYOUT_OFF); lv_btn_set_layout(buttonDec, LV_LAYOUT_OFF); lv_btn_set_layout(buttoType, LV_LAYOUT_OFF); @@ -275,13 +275,12 @@ void lv_draw_preHeat(void) { lv_btn_set_layout(buttonOff, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - lv_obj_t * labelAdd = lv_label_create(buttonAdd, NULL); - lv_obj_t * labelDec = lv_label_create(buttonDec, NULL); + lv_obj_t *labelAdd = lv_label_create(buttonAdd, NULL); + lv_obj_t *labelDec = lv_label_create(buttonDec, NULL); labelType = lv_label_create(buttoType, NULL); labelStep = lv_label_create(buttonStep, NULL); - lv_obj_t * labelOff = lv_label_create(buttonOff, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); - + lv_obj_t *labelOff = lv_label_create(buttonOff, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelAdd, preheat_menu.add); @@ -306,7 +305,6 @@ void lv_draw_preHeat(void) { } void disp_temp_type() { - if (uiCfg.curTempType == 0) { if (uiCfg.curSprayerChoose == 1) { lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_extru2.bin", 0); @@ -331,7 +329,6 @@ void disp_temp_type() { lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } } - } void disp_desire_temp() { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h index db0e3617641b..c8de942f3f60 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_preHeat(void); @@ -33,5 +33,5 @@ extern void disp_desire_temp(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp index 33405a905fe4..13a92269f8a0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp @@ -305,6 +305,7 @@ void disp_gcode_icon(uint8_t file_num) { lv_refr_now(lv_refr_get_disp_refreshing()); + // Create image buttons buttonPageUp = lv_imgbtn_create(scr, NULL); buttonPageDown = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); @@ -334,8 +335,7 @@ void disp_gcode_icon(uint8_t file_num) { lv_obj_set_pos(buttonPageDown, OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H); lv_obj_set_pos(buttonBack, OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL * 2 + INTERVAL_H * 2); - /*Create a label on the Image button*/ - + // Create labels on the image buttons lv_btn_set_layout(buttonPageUp, LV_LAYOUT_OFF); lv_btn_set_layout(buttonPageDown, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h index 987282c07906..226e4f668e93 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif typedef struct { @@ -61,5 +61,5 @@ extern void lv_clear_print_file(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h index 1f7d9f909def..b7d464e4f093 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif #define IDLE 0 @@ -48,5 +48,5 @@ extern void setProBarRate(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index c987ddb0846b..38750d608d0d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -159,7 +159,7 @@ void lv_draw_ready_print(void) { //lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); //lv_label_set_text(title, creat_title_text()); - /*Create an Image button*/ + // Create image buttons //buttonPrint = lv_imgbtn_create(scr, NULL); buttonTool = lv_imgbtn_create(scr, NULL); //buttonSet = lv_imgbtn_create(scr, NULL); @@ -196,14 +196,14 @@ void lv_draw_ready_print(void) { //lv_obj_set_pos(buttonSet,BTN_X_PIXEL+SIMPLE_FIRST_PAGE_GRAP*2+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2); //lv_obj_set_pos(buttonPrint,BTN_X_PIXEL*2+SIMPLE_FIRST_PAGE_GRAP*3+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2); - /*Create a label on the Image button*/ + // Create labels on the image buttons //lv_btn_set_layout(buttonPrint, LV_LAYOUT_OFF); //lv_btn_set_layout(buttonSet, LV_LAYOUT_OFF); lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF); - //lv_obj_t * label_print = lv_label_create(buttonPrint, NULL); - //lv_obj_t * label_set = lv_label_create(buttonSet, NULL); - lv_obj_t * label_tool = lv_label_create(buttonTool, NULL); + //lv_obj_t *label_print = lv_label_create(buttonPrint, NULL); + //lv_obj_t *label_set = lv_label_create(buttonSet, NULL); + lv_obj_t *label_tool = lv_label_create(buttonTool, NULL); if (gCfgItems.multiple_language != 0) { //lv_label_set_text(label_print, main_menu.print); //lv_obj_align(label_print, buttonPrint, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h index 9951beaa4172..5cefe8b59b36 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_ready_print(void); @@ -35,5 +35,5 @@ extern void lv_clear_ready_print(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h index 1cb60b5681e3..b243bca296ad 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_set(void); @@ -30,5 +30,5 @@ extern void lv_clear_set(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.h index 1a5efda40825..b7eaeb4c61e3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_step_settings(void); extern void lv_clear_step_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp index f1559e0f553e..24650ee9309f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp @@ -25,6 +25,7 @@ #include "lv_conf.h" #include "draw_ui.h" + #include "../../../../MarlinCore.h" #include "../../../../module/planner.h" #include "../../../../module/stepper/indirection.h" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.h index 46463dd3c6d1..927db37138e6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.h @@ -22,13 +22,13 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_tmc_current_settings(void); extern void lv_clear_tmc_current_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.h index 93085b7ca16b..35c57ab0cc01 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.h @@ -22,12 +22,12 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_tmc_step_mode_settings(void); extern void lv_clear_tmc_step_mode_settings(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp index 91dd2f36ab9e..a2d0937e4767 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -140,7 +140,7 @@ void lv_draw_tool(void) { LV_IMG_DECLARE(bmp_pic); - /*Create an Image button*/ + // Create image buttons buttonPreHeat = lv_imgbtn_create(scr, NULL); buttonExtrusion = lv_imgbtn_create(scr, NULL); buttonMove = lv_imgbtn_create(scr, NULL); @@ -210,7 +210,7 @@ void lv_draw_tool(void) { //lv_obj_set_pos(buttonMore,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonPreHeat, LV_LAYOUT_OFF); lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF); lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h index 14be3bce4f26..8a033e2c40b9 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif extern void lv_draw_tool(void); @@ -30,5 +30,5 @@ extern void lv_clear_tool(); //extern void disp_temp_ready_print(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h index 21c3b6185ae1..8cd4670ffa8d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -328,5 +328,5 @@ extern void LV_TASK_HANDLER(); extern void lv_ex_line(lv_obj_t * line, lv_point_t *points); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h index f1086fd1b941..24b2945d73e7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h @@ -124,7 +124,7 @@ #define VAR_INF_ADDR 0x000000 #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif union union32 { @@ -157,5 +157,5 @@ extern void default_view_Read(uint8_t *default_view_Rbuff, uint32_t default_view extern void flash_view_Read(uint8_t *flash_view_Rbuff, uint32_t flash_view_Readsize); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp index 138168b12fb0..2d03373a7f4f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp @@ -51,6 +51,7 @@ void printer_state_polling() { if (uiCfg.waitEndMoves > 20) { uiCfg.waitEndMoves = 0; planner.synchronize(); + gcode.process_subcommands_now_P(PSTR("M25")); if (gCfgItems.pausePosZ != (float)-1) { gcode.process_subcommands_now_P(PSTR("G91")); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.h b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.h index 9605d65085d7..f30415882451 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.h @@ -22,7 +22,7 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif #define MIN_FILE_PRINTED 100 //5000 @@ -32,5 +32,5 @@ extern void filament_pin_setup(); extern void filament_check(); #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h index f7b0e0d31060..b2e19d66f8f8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.h @@ -22,9 +22,9 @@ #pragma once #ifdef __cplusplus -extern "C" { /* C-declarations for C++ */ + extern "C" { /* C-declarations for C++ */ #endif #ifdef __cplusplus -} /* C-declarations for C++ */ + } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/tft/st7796s.h b/Marlin/src/lcd/tft/st7796s.h index 806977732cfb..10452293de0b 100644 --- a/Marlin/src/lcd/tft/st7796s.h +++ b/Marlin/src/lcd/tft/st7796s.h @@ -25,92 +25,92 @@ #include "../../inc/MarlinConfig.h" -#define ST7796S_MADCTL_MY 0x80 // Row Address Order -#define ST7796S_MADCTL_MX 0x40 // Column Address Order -#define ST7796S_MADCTL_MV 0x20 // Row/Column Exchange -#define ST7796S_MADCTL_ML 0x10 // Vertical Refresh Order -#define ST7796S_MADCTL_BGR 0x08 // RGB-BGR ORDER -#define ST7796S_MADCTL_RGB 0x00 -#define ST7796S_MADCTL_MH 0x04 // Horizontal Refresh Order +#define ST7796S_MADCTL_MY 0x80 // Row Address Order +#define ST7796S_MADCTL_MX 0x40 // Column Address Order +#define ST7796S_MADCTL_MV 0x20 // Row/Column Exchange +#define ST7796S_MADCTL_ML 0x10 // Vertical Refresh Order +#define ST7796S_MADCTL_BGR 0x08 // RGB-BGR ORDER +#define ST7796S_MADCTL_RGB 0x00 +#define ST7796S_MADCTL_MH 0x04 // Horizontal Refresh Order #define ST7796S_COLOR_BGR -#define ST7796S_ORIENTATION ST7796S_MADCTL_MV -#define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION | TERN(ST7796S_COLOR_BGR, ST7796S_MADCTL_BGR, ST7796S_MADCTL_RGB)) - -#define ST7796S_NOP 0x00 // No Operation -#define ST7796S_SWRESET 0x01 // Software reset -#define ST7796S_RDDID 0x04 // Read Display ID -#define ST7796S_RDNUMED 0x05 // Read Number of the Errors on DSI -#define ST7796S_RDDST 0x09 // Read Display Status -#define ST7796S_RDDPM 0x0A // Read Display Power Mode -#define ST7796S_RDDMADCTL 0x0B // Read Display MADCTL -#define ST7796S_RDDCOLMOD 0x0C // Read Display Pixel Format -#define ST7796S_RDDIM 0x0D // Read Display Image Mode -#define ST7796S_RDDSM 0x0E // Read Display Signal Status -#define ST7796S_RDDSDR 0x0F // Read Display Self-Diagnostic Result -#define ST7796S_SLPIN 0x10 // Sleep In -#define ST7796S_SLPOUT 0x11 // Sleep Out -#define ST7796S_PTLON 0x12 // Partial Display Mode On -#define ST7796S_NORON 0x13 // Normal Display Mode On -#define ST7796S_INVOFF 0x20 // Display Inversion Off -#define ST7796S_INVON 0x21 // Display Inversion On -#define ST7796S_DISPOFF 0x28 // Display Off -#define ST7796S_DISPON 0x29 // Display On -#define ST7796S_CASET 0x2A // Column Address Set -#define ST7796S_RASET 0x2B // Row Address Set -#define ST7796S_RAMWR 0x2C // Memory Write -#define ST7796S_RAMRD 0x2E // Memory Read -#define ST7796S_PTLAR 0x30 // Partial Area -#define ST7796S_VSCRDEF 0x33 // Vertical Scrolling Definition -#define ST7796S_TEOFF 0x34 // Tearing Effect Line OFF -#define ST7796S_TEON 0x35 // Tearing Effect Line On -#define ST7796S_MADCTL 0x36 // Memory Data Access Control -#define ST7796S_VSCSAD 0x37 // Vertical Scroll Start Address of RAM -#define ST7796S_IDMOFF 0x38 // Idle Mode Off -#define ST7796S_IDMON 0x39 // Idle Mode On -#define ST7796S_COLMOD 0x3A // Interface Pixel Format -#define ST7796S_WRMEMC 0x3C // Write Memory Continue -#define ST7796S_RDMEMC 0x3E // Read Memory Continue -#define ST7796S_STE 0x44 // Set Tear ScanLine -#define ST7796S_GSCAN 0x45 // Get ScanLine -#define ST7796S_WRDISBV 0x51 // Write Display Brightness -#define ST7796S_RDDISBV 0x52 // Read Display Brightness Value -#define ST7796S_WRCTRLD 0x53 // Write CTRL Display -#define ST7796S_RDCTRLD 0x54 // Read CTRL value Display -#define ST7796S_WRCABC 0x55 // Write Adaptive Brightness Control -#define ST7796S_RDCABC 0x56 // Read Content Adaptive Brightness Control -#define ST7796S_WRCABCMB 0x5E // Write CABC Minimum Brightness -#define ST7796S_RDCABCMB 0x5F // Read CABC Minimum Brightness -#define ST7796S_RDFCS 0xAA // Read First Checksum -#define ST7796S_RDCFCS 0xAF // Read Continue Checksum -#define ST7796S_RDID1 0xDA // Read ID1 -#define ST7796S_RDID2 0xDB // Read ID2 -#define ST7796S_RDID3 0xDC // Read ID3 - -#define ST7796S_IFMODE 0xB0 // Interface Mode Control -#define ST7796S_FRMCTR1 0xB1 // Frame Rate Control (In Normal Mode/Full Colors) -#define ST7796S_FRMCTR2 0xB2 // Frame Rate Control 2 (In Idle Mode/8 colors) -#define ST7796S_FRMCTR3 0xB3 // Frame Rate Control 3(In Partial Mode/Full Colors) -#define ST7796S_DIC 0xB4 // Display Inversion Control -#define ST7796S_BPC 0xB5 // Blanking Porch Control -#define ST7796S_DFC 0xB6 // Display Function Control -#define ST7796S_EM 0xB7 // Entry Mode Set -#define ST7796S_PWR1 0xC0 // Power Control 1 -#define ST7796S_PWR2 0xC1 // Power Control 2 -#define ST7796S_PWR3 0xC2 // Power Control 3 -#define ST7796S_VCMPCTL 0xC5 // VCOM Control -#define ST7796S_VCMOST 0xC6 // VCOM Offset Register -#define ST7796S_NVMADW 0xD0 // NVM Address/Data Write -#define ST7796S_NVMBPROG 0xD1 // NVM Byte Program -#define ST7796S_NVMSTRD 0xD2 // NVM Status Read -#define ST7796S_RDID4 0xD3 // Read ID4 -#define ST7796S_PGC 0xE0 // Positive Gamma Control -#define ST7796S_NGC 0xE1 // Negative Gamma Control -#define ST7796S_DGC1 0xE2 // Digital Gamma Control 1 -#define ST7796S_DGC2 0xE3 // Digital Gamma Control 2 -#define ST7796S_DOCA 0xE8 // Display Output Ctrl Adjust -#define ST7796S_CSCON 0xF0 // Command Set Control -#define ST7796S_SPIRC 0xFB // SPI Read Control +#define ST7796S_ORIENTATION ST7796S_MADCTL_MV +#define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION | TERN(ST7796S_COLOR_BGR, ST7796S_MADCTL_BGR, ST7796S_MADCTL_RGB)) + +#define ST7796S_NOP 0x00 // No Operation +#define ST7796S_SWRESET 0x01 // Software reset +#define ST7796S_RDDID 0x04 // Read Display ID +#define ST7796S_RDNUMED 0x05 // Read Number of the Errors on DSI +#define ST7796S_RDDST 0x09 // Read Display Status +#define ST7796S_RDDPM 0x0A // Read Display Power Mode +#define ST7796S_RDDMADCTL 0x0B // Read Display MADCTL +#define ST7796S_RDDCOLMOD 0x0C // Read Display Pixel Format +#define ST7796S_RDDIM 0x0D // Read Display Image Mode +#define ST7796S_RDDSM 0x0E // Read Display Signal Status +#define ST7796S_RDDSDR 0x0F // Read Display Self-Diagnostic Result +#define ST7796S_SLPIN 0x10 // Sleep In +#define ST7796S_SLPOUT 0x11 // Sleep Out +#define ST7796S_PTLON 0x12 // Partial Display Mode On +#define ST7796S_NORON 0x13 // Normal Display Mode On +#define ST7796S_INVOFF 0x20 // Display Inversion Off +#define ST7796S_INVON 0x21 // Display Inversion On +#define ST7796S_DISPOFF 0x28 // Display Off +#define ST7796S_DISPON 0x29 // Display On +#define ST7796S_CASET 0x2A // Column Address Set +#define ST7796S_RASET 0x2B // Row Address Set +#define ST7796S_RAMWR 0x2C // Memory Write +#define ST7796S_RAMRD 0x2E // Memory Read +#define ST7796S_PTLAR 0x30 // Partial Area +#define ST7796S_VSCRDEF 0x33 // Vertical Scrolling Definition +#define ST7796S_TEOFF 0x34 // Tearing Effect Line OFF +#define ST7796S_TEON 0x35 // Tearing Effect Line On +#define ST7796S_MADCTL 0x36 // Memory Data Access Control +#define ST7796S_VSCSAD 0x37 // Vertical Scroll Start Address of RAM +#define ST7796S_IDMOFF 0x38 // Idle Mode Off +#define ST7796S_IDMON 0x39 // Idle Mode On +#define ST7796S_COLMOD 0x3A // Interface Pixel Format +#define ST7796S_WRMEMC 0x3C // Write Memory Continue +#define ST7796S_RDMEMC 0x3E // Read Memory Continue +#define ST7796S_STE 0x44 // Set Tear ScanLine +#define ST7796S_GSCAN 0x45 // Get ScanLine +#define ST7796S_WRDISBV 0x51 // Write Display Brightness +#define ST7796S_RDDISBV 0x52 // Read Display Brightness Value +#define ST7796S_WRCTRLD 0x53 // Write CTRL Display +#define ST7796S_RDCTRLD 0x54 // Read CTRL value Display +#define ST7796S_WRCABC 0x55 // Write Adaptive Brightness Control +#define ST7796S_RDCABC 0x56 // Read Content Adaptive Brightness Control +#define ST7796S_WRCABCMB 0x5E // Write CABC Minimum Brightness +#define ST7796S_RDCABCMB 0x5F // Read CABC Minimum Brightness +#define ST7796S_RDFCS 0xAA // Read First Checksum +#define ST7796S_RDCFCS 0xAF // Read Continue Checksum +#define ST7796S_RDID1 0xDA // Read ID1 +#define ST7796S_RDID2 0xDB // Read ID2 +#define ST7796S_RDID3 0xDC // Read ID3 + +#define ST7796S_IFMODE 0xB0 // Interface Mode Control +#define ST7796S_FRMCTR1 0xB1 // Frame Rate Control (In Normal Mode/Full Colors) +#define ST7796S_FRMCTR2 0xB2 // Frame Rate Control 2 (In Idle Mode/8 colors) +#define ST7796S_FRMCTR3 0xB3 // Frame Rate Control 3(In Partial Mode/Full Colors) +#define ST7796S_DIC 0xB4 // Display Inversion Control +#define ST7796S_BPC 0xB5 // Blanking Porch Control +#define ST7796S_DFC 0xB6 // Display Function Control +#define ST7796S_EM 0xB7 // Entry Mode Set +#define ST7796S_PWR1 0xC0 // Power Control 1 +#define ST7796S_PWR2 0xC1 // Power Control 2 +#define ST7796S_PWR3 0xC2 // Power Control 3 +#define ST7796S_VCMPCTL 0xC5 // VCOM Control +#define ST7796S_VCMOST 0xC6 // VCOM Offset Register +#define ST7796S_NVMADW 0xD0 // NVM Address/Data Write +#define ST7796S_NVMBPROG 0xD1 // NVM Byte Program +#define ST7796S_NVMSTRD 0xD2 // NVM Status Read +#define ST7796S_RDID4 0xD3 // Read ID4 +#define ST7796S_PGC 0xE0 // Positive Gamma Control +#define ST7796S_NGC 0xE1 // Negative Gamma Control +#define ST7796S_DGC1 0xE2 // Digital Gamma Control 1 +#define ST7796S_DGC2 0xE3 // Digital Gamma Control 2 +#define ST7796S_DOCA 0xE8 // Display Output Ctrl Adjust +#define ST7796S_CSCON 0xF0 // Command Set Control +#define ST7796S_SPIRC 0xFB // SPI Read Control static const uint16_t st7796s_init[] = { DATASIZE_8BIT, diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 9dce52b4204f..d07d36339934 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -498,10 +498,10 @@ #include "stm32f1/pins_STM3R_MINI.h" // STM32F1 env:STM32F103RE #elif MB(GTM32_PRO_VB) #include "stm32f1/pins_GTM32_PRO_VB.h" // STM32F1 env:STM32F103RE -#elif MB(GTM32_MINI_A30) - #include "stm32f1/pins_GTM32_MINI_A30.h" // STM32F1 env:STM32F103RE #elif MB(GTM32_MINI) #include "stm32f1/pins_GTM32_MINI.h" // STM32F1 env:STM32F103RE +#elif MB(GTM32_MINI_A30) + #include "stm32f1/pins_GTM32_MINI_A30.h" // STM32F1 env:STM32F103RE #elif MB(GTM32_REV_B) #include "stm32f1/pins_GTM32_REV_B.h" // STM32F1 env:STM32F103RE #elif MB(MORPHEUS) @@ -518,6 +518,14 @@ #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano35 #elif MB(MKS_ROBIN_LITE) #include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite +#elif MB(MKS_ROBIN_LITE3) + #include "stm32f1/pins_MKS_ROBIN_LITE3.h" // STM32F1 env:mks_robin_lite3 +#elif MB(MKS_ROBIN_PRO) + #include "stm32f1/pins_MKS_ROBIN_PRO.h" // STM32F1 env:mks_robin_pro +#elif MB(MKS_ROBIN_E3) + #include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3 +#elif MB(MKS_ROBIN_E3D) + #include "stm32f1/pins_MKS_ROBIN_E3D.h" // STM32F1 env:mks_robin_e3 #elif MB(BTT_SKR_MINI_V1_1) #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB #elif MB(BTT_SKR_MINI_E3_V1_0) @@ -538,14 +546,6 @@ #include "stm32f1/pins_FYSETC_CHEETAH_V12.h" // STM32F1 env:STM32F103RC_fysetc #elif MB(LONGER3D_LK) #include "stm32f1/pins_LONGER3D_LK.h" // STM32F1 env:STM32F103VE_longer -#elif MB(MKS_ROBIN_LITE3) - #include "stm32f1/pins_MKS_ROBIN_LITE3.h" // STM32F1 env:mks_robin_lite3 -#elif MB(MKS_ROBIN_PRO) - #include "stm32f1/pins_MKS_ROBIN_PRO.h" // STM32F1 env:mks_robin_pro -#elif MB(MKS_ROBIN_E3D) - #include "stm32f1/pins_MKS_ROBIN_E3D.h" // STM32F1 env:mks_robin_e3 -#elif MB(MKS_ROBIN_E3) - #include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3 #elif MB(CCROBOT_MEEB_3DP) #include "stm32f1/pins_CCROBOT_MEEB_3DP.h" // STM32F1 env:STM32F103RC_meeb #elif MB(CHITU3D_V5) From 4f73ac728991eed39946d1fdfff65d294b744a3f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 20 Sep 2020 19:08:08 -0500 Subject: [PATCH 25/63] Add HAS_ROTARY_ENCODER --- Marlin/src/inc/Conditionals_post.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 2ae4f4e399d6..c9a29b351cbb 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2622,6 +2622,10 @@ #endif #endif +#if BUTTONS_EXIST(EN1, EN2, ENC) + #define HAS_ROTARY_ENCODER 1 +#endif + #if !NUM_SERIAL #undef BAUD_RATE_GCODE #elif NUM_SERIAL > 1 From 77b06dce0c527833f00a24a55771049313ce59bb Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 21 Sep 2020 00:13:48 +0000 Subject: [PATCH 26/63] [cron] Bump distribution date (2020-09-21) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index b33163f5f3c5..c1b57d136716 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-20" + #define STRING_DISTRIBUTION_DATE "2020-09-21" #endif /** From d8ed74904559aa8bdccc8b68acbccfbf1bf779d3 Mon Sep 17 00:00:00 2001 From: makerbase <4164049@qq.com> Date: Mon, 21 Sep 2020 09:55:02 +0800 Subject: [PATCH 27/63] Add MKS Robin E3P, improve LVGL UI (#19442) --- Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp | 2 + Marlin/src/MarlinCore.cpp | 11 + Marlin/src/core/boards.h | 73 +- .../lcd/extui/lib/mks_ui/SPIFlashStorage.cpp | 2 + Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp | 5 +- .../src/lcd/extui/lib/mks_ui/draw_about.cpp | 41 +- .../lib/mks_ui/draw_acceleration_settings.cpp | 322 ++- .../lib/mks_ui/draw_advance_settings.cpp | 234 +- .../draw_auto_level_offset_settings.cpp | 203 ++ .../mks_ui/draw_auto_level_offset_settings.h | 33 + .../extui/lib/mks_ui/draw_baby_stepping.cpp | 352 +++ .../lcd/extui/lib/mks_ui/draw_baby_stepping.h | 36 + .../extui/lib/mks_ui/draw_change_speed.cpp | 83 +- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 455 +++- Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h | 5 + .../extui/lib/mks_ui/draw_eeprom_settings.cpp | 139 +- .../lib/mks_ui/draw_encoder_settings.cpp | 172 ++ .../extui/lib/mks_ui/draw_encoder_settings.h | 33 + .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 97 +- Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp | 56 +- .../extui/lib/mks_ui/draw_filament_change.cpp | 270 +++ .../extui/lib/mks_ui/draw_filament_change.h | 36 + .../lib/mks_ui/draw_filament_settings.cpp | 329 +++ .../extui/lib/mks_ui/draw_filament_settings.h | 33 + Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp | 137 +- .../draw_homing_sensitivity_settings.cpp | 262 +++ .../mks_ui/draw_homing_sensitivity_settings.h | 33 + .../extui/lib/mks_ui/draw_jerk_settings.cpp | 150 +- .../lcd/extui/lib/mks_ui/draw_keyboard.cpp | 286 +++ .../src/lcd/extui/lib/mks_ui/draw_keyboard.h | 33 + .../lcd/extui/lib/mks_ui/draw_language.cpp | 136 +- .../extui/lib/mks_ui/draw_level_settings.cpp | 261 +++ .../extui/lib/mks_ui/draw_level_settings.h | 33 + .../extui/lib/mks_ui/draw_machine_para.cpp | 114 +- .../lib/mks_ui/draw_machine_settings.cpp | 81 +- .../lcd/extui/lib/mks_ui/draw_manuaLevel.cpp | 69 +- .../mks_ui/draw_manual_level_pos_settings.cpp | 459 ++++ .../mks_ui/draw_manual_level_pos_settings.h | 33 + .../lib/mks_ui/draw_max_feedrate_settings.cpp | 212 +- .../extui/lib/mks_ui/draw_motor_settings.cpp | 160 +- .../lcd/extui/lib/mks_ui/draw_move_motor.cpp | 87 +- .../lcd/extui/lib/mks_ui/draw_number_key.cpp | 291 ++- .../lcd/extui/lib/mks_ui/draw_operation.cpp | 261 ++- .../extui/lib/mks_ui/draw_pause_position.cpp | 120 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 97 +- .../lcd/extui/lib/mks_ui/draw_print_file.cpp | 103 +- .../lcd/extui/lib/mks_ui/draw_print_file.h | 3 +- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 195 +- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 122 +- Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp | 249 ++- .../extui/lib/mks_ui/draw_step_settings.cpp | 216 +- .../lib/mks_ui/draw_tmc_current_settings.cpp | 389 ++-- .../mks_ui/draw_tmc_step_mode_settings.cpp | 456 ++-- Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp | 171 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 495 +++-- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 168 +- Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp | 222 ++ Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h | 38 + .../lcd/extui/lib/mks_ui/draw_wifi_list.cpp | 235 ++ .../src/lcd/extui/lib/mks_ui/draw_wifi_list.h | 76 + .../extui/lib/mks_ui/draw_wifi_settings.cpp | 299 +++ .../lcd/extui/lib/mks_ui/draw_wifi_settings.h | 36 + .../lcd/extui/lib/mks_ui/draw_wifi_tips.cpp | 85 + .../src/lcd/extui/lib/mks_ui/draw_wifi_tips.h | 51 + .../src/lcd/extui/lib/mks_ui/irq_overrid.cpp | 69 + .../extui/lib/mks_ui/mks_hardware_test.cpp | 100 +- .../src/lcd/extui/lib/mks_ui/pic_manager.cpp | 174 +- Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h | 13 +- .../extui/lib/mks_ui/printer_operation.cpp | 44 +- .../lcd/extui/lib/mks_ui/tft_Language_en.h | 54 +- .../lcd/extui/lib/mks_ui/tft_Language_fr.h | 5 - .../lcd/extui/lib/mks_ui/tft_Language_it.h | 5 - .../lcd/extui/lib/mks_ui/tft_Language_ru.h | 5 - .../lcd/extui/lib/mks_ui/tft_Language_s_cn.h | 52 +- .../lcd/extui/lib/mks_ui/tft_Language_sp.h | 5 - .../lcd/extui/lib/mks_ui/tft_Language_t_cn.h | 51 +- .../lib/mks_ui/tft_lvgl_configuration.cpp | 880 +++++--- .../extui/lib/mks_ui/tft_lvgl_configuration.h | 51 +- .../extui/lib/mks_ui/tft_multi_language.cpp | 291 +-- .../lcd/extui/lib/mks_ui/tft_multi_language.h | 75 +- .../src/lcd/extui/lib/mks_ui/wifiSerial.cpp | 120 + Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h | 102 + .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 1927 +++++++++++++++++ Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h | 202 ++ .../src/lcd/extui/lib/mks_ui/wifi_upload.cpp | 847 ++++++++ Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h | 74 + Marlin/src/module/stepper.h | 14 +- Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h | 377 ++++ Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h | 38 +- .../src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 48 +- .../PlatformIO/ldscripts/mks_robin_e3p.ld | 14 + .../share/PlatformIO/scripts/mks_robin_e3p.py | 40 + platformio.ini | 18 +- 94 files changed, 12673 insertions(+), 2970 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h create mode 100644 Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h create mode 100644 buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld create mode 100644 buildroot/share/PlatformIO/scripts/mks_robin_e3p.py diff --git a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp index bc1b012dc788..069be7ad54e3 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp @@ -201,6 +201,8 @@ uint32_t TFT_FSMC::GetID() { id = ReadID(LCD_READ_ID); if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) id = ReadID(LCD_READ_ID4); + if ((id & 0xFF00) == 0 && (id & 0xFF) != 0) + id = ReadID(LCD_READ_ID4); return id; } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 2927a3e40b28..22935c146073 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -796,6 +796,10 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr UNUSED(lcd_component); #endif + #if HAS_TFT_LVGL_UI + lv_draw_error_message(lcd_error); + #endif + #ifdef ACTION_ON_KILL host_action_kill(); #endif @@ -920,6 +924,13 @@ void setup() { SERIAL_ECHO_MSG("start"); #endif + #if BOTH(HAS_TFT_LVGL_UI, USE_WIFI_FUNCTION) + mks_esp_wifi_init(); + WIFISERIAL.begin(WIFI_BAUDRATE); + serial_connect_timeout = millis() + 1000UL; + while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + #endif + SETUP_RUN(HAL_init()); #if HAS_L64XX diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 581c801feb88..293c6a523076 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -282,42 +282,43 @@ // STM32 ARM Cortex-M3 // -#define BOARD_STM32F103RE 4000 // STM32F103RE Libmaple-based STM32F1 controller -#define BOARD_MALYAN_M200 4001 // STM32C8T6 Libmaple-based STM32F1 controller -#define BOARD_MALYAN_M200_V2 4002 // STM32F070CB STM32F0 controller -#define BOARD_STM3R_MINI 4003 // STM32F103RE Libmaple-based STM32F1 controller -#define BOARD_GTM32_PRO_VB 4004 // STM32F103VET6 controller -#define BOARD_MORPHEUS 4005 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller -#define BOARD_CHITU3D 4006 // Chitu3D (STM32F103RET6) -#define BOARD_MKS_ROBIN 4007 // MKS Robin (STM32F103ZET6) -#define BOARD_MKS_ROBIN_MINI 4008 // MKS Robin Mini (STM32F103VET6) -#define BOARD_MKS_ROBIN_NANO 4009 // MKS Robin Nano (STM32F103VET6) -#define BOARD_MKS_ROBIN_NANO_V2 4010 // MKS Robin Nano V2 (STM32F103VET6) -#define BOARD_MKS_ROBIN_LITE 4011 // MKS Robin Lite/Lite2 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_LITE3 4012 // MKS Robin Lite3 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_PRO 4013 // MKS Robin Pro (STM32F103ZET6) -#define BOARD_BTT_SKR_MINI_V1_1 4014 // BigTreeTech SKR Mini v1.1 (STM32F103RC) -#define BOARD_BTT_SKR_MINI_E3_V1_0 4015 // BigTreeTech SKR Mini E3 (STM32F103RC) -#define BOARD_BTT_SKR_MINI_E3_V1_2 4016 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC) -#define BOARD_BTT_SKR_MINI_E3_V2_0 4017 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC) -#define BOARD_BTT_SKR_E3_DIP 4018 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) -#define BOARD_JGAURORA_A5S_A1 4019 // JGAurora A5S A1 (STM32F103ZET6) -#define BOARD_FYSETC_AIO_II 4020 // FYSETC AIO_II -#define BOARD_FYSETC_CHEETAH 4021 // FYSETC Cheetah -#define BOARD_FYSETC_CHEETAH_V12 4022 // FYSETC Cheetah V1.2 -#define BOARD_LONGER3D_LK 4023 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6 -#define BOARD_GTM32_MINI 4024 // STM32F103VET6 controller -#define BOARD_GTM32_MINI_A30 4025 // STM32F103VET6 controller -#define BOARD_GTM32_REV_B 4026 // STM32F103VET6 controller -#define BOARD_MKS_ROBIN_E3D 4027 // MKS Robin E3D (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3 4028 // MKS Robin E3 (STM32F103RCT6) -#define BOARD_MALYAN_M300 4029 // STM32F070-based delta -#define BOARD_CCROBOT_MEEB_3DP 4030 // ccrobot-online.com MEEB_3DP (STM32F103RC) -#define BOARD_CHITU3D_V5 4031 // Chitu3D TronXY X5SA V5 Board -#define BOARD_CHITU3D_V6 4032 // Chitu3D TronXY X5SA V5 Board -#define BOARD_CREALITY_V4 4033 // Creality v4.x (STM32F103RE) -#define BOARD_CREALITY_V427 4034 // Creality v4.2.7 (STM32F103RE) -#define BOARD_TRIGORILLA_PRO 4035 // Trigorilla Pro (STM32F103ZET6) +#define BOARD_MALYAN_M200_V2 4000 // STM32F070CB STM32F0 controller +#define BOARD_MALYAN_M300 4001 // STM32F070-based delta +#define BOARD_STM32F103RE 4002 // STM32F103RE Libmaple-based STM32F1 controller +#define BOARD_MALYAN_M200 4003 // STM32C8T6 Libmaple-based STM32F1 controller +#define BOARD_STM3R_MINI 4004 // STM32F103RE Libmaple-based STM32F1 controller +#define BOARD_GTM32_PRO_VB 4005 // STM32F103VET6 controller +#define BOARD_GTM32_MINI 4006 // STM32F103VET6 controller +#define BOARD_GTM32_MINI_A30 4007 // STM32F103VET6 controller +#define BOARD_GTM32_REV_B 4008 // STM32F103VET6 controller +#define BOARD_MORPHEUS 4009 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller +#define BOARD_CHITU3D 4010 // Chitu3D (STM32F103RET6) +#define BOARD_MKS_ROBIN 4011 // MKS Robin (STM32F103ZET6) +#define BOARD_MKS_ROBIN_MINI 4012 // MKS Robin Mini (STM32F103VET6) +#define BOARD_MKS_ROBIN_NANO 4013 // MKS Robin Nano (STM32F103VET6) +#define BOARD_MKS_ROBIN_NANO_V2 4014 // MKS Robin Nano V2 (STM32F103VET6) +#define BOARD_MKS_ROBIN_LITE 4015 // MKS Robin Lite/Lite2 (STM32F103RCT6) +#define BOARD_MKS_ROBIN_LITE3 4016 // MKS Robin Lite3 (STM32F103RCT6) +#define BOARD_MKS_ROBIN_PRO 4017 // MKS Robin Pro (STM32F103ZET6) +#define BOARD_MKS_ROBIN_E3 4018 // MKS Robin E3 (STM32F103RCT6) +#define BOARD_MKS_ROBIN_E3D 4019 // MKS Robin E3D (STM32F103RCT6) +#define BOARD_MKS_ROBIN_E3P 4020 // MKS Robin E3p (STM32F103VET6) +#define BOARD_BTT_SKR_MINI_V1_1 4021 // BigTreeTech SKR Mini v1.1 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V1_0 4022 // BigTreeTech SKR Mini E3 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V1_2 4023 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V2_0 4024 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC) +#define BOARD_BTT_SKR_E3_DIP 4025 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) +#define BOARD_JGAURORA_A5S_A1 4026 // JGAurora A5S A1 (STM32F103ZET6) +#define BOARD_FYSETC_AIO_II 4027 // FYSETC AIO_II +#define BOARD_FYSETC_CHEETAH 4028 // FYSETC Cheetah +#define BOARD_FYSETC_CHEETAH_V12 4029 // FYSETC Cheetah V1.2 +#define BOARD_LONGER3D_LK 4030 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6 +#define BOARD_CCROBOT_MEEB_3DP 4031 // ccrobot-online.com MEEB_3DP (STM32F103RC) +#define BOARD_CHITU3D_V5 4032 // Chitu3D TronXY X5SA V5 Board +#define BOARD_CHITU3D_V6 4033 // Chitu3D TronXY X5SA V5 Board +#define BOARD_CREALITY_V4 4034 // Creality v4.x (STM32F103RE) +#define BOARD_CREALITY_V427 4035 // Creality v4.2.7 (STM32F103RE) +#define BOARD_TRIGORILLA_PRO 4036 // Trigorilla Pro (STM32F103ZET6) // // ARM Cortex-M4F diff --git a/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp b/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp index ad116d5045df..3f5712445138 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp @@ -27,6 +27,8 @@ #include "../../../../inc/MarlinConfig.h" #include "SPIFlashStorage.h" +extern W25QXXFlash W25QXX; + uint8_t SPIFlashStorage::m_pageData[SPI_FLASH_PageSize]; uint32_t SPIFlashStorage::m_currentPage; uint16_t SPIFlashStorage::m_pageDataUsed; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp b/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp index ea94d6c1a571..351d033d01ec 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp @@ -26,6 +26,7 @@ #include "SPI_TFT.h" #include "pic_manager.h" +#include "tft_lvgl_configuration.h" #include "../../../../inc/MarlinConfig.h" @@ -74,6 +75,7 @@ void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) { } void TFT::LCD_init() { + TFT_BLK_L; TFT_RST_H; delay(150); TFT_RST_L; @@ -92,8 +94,7 @@ void TFT::LCD_init() { LCD_WR_DATA(0x96); LCD_WR_REG(0x36); - LCD_WR_DATA(0x28); - + LCD_WR_DATA(0x28 + TERN0(GRAPHICAL_TFT_ROTATE_180, 0x80)); LCD_WR_REG(0x3A); LCD_WR_DATA(0x55); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp index e2df14a36b56..34b7427860ed 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp @@ -33,8 +33,9 @@ #include "../../../../MarlinCore.h" #include "../../../../module/temperature.h" +extern lv_group_t * g; static lv_obj_t * scr; -static lv_obj_t * fw_type, *board, *fw_version; +static lv_obj_t * fw_type, *board; //*fw_version; #define ID_A_RETURN 1 @@ -73,17 +74,18 @@ void lv_draw_about(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - // Create an Image button buttonBack = lv_imgbtn_create(scr, NULL); #if 1 - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_A_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_A_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif #endif lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); @@ -97,30 +99,27 @@ void lv_draw_about(void) { lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } - fw_version = lv_label_create(scr, NULL); - lv_obj_set_style(fw_version, &tft_style_label_rel); - lv_label_set_text(fw_version, SHORT_BUILD_VERSION); - lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60); + //fw_version = lv_label_create(scr, NULL); + //lv_obj_set_style(fw_version, &tft_style_label_rel); + //lv_label_set_text(fw_version, SHORT_BUILD_VERSION); + //lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60); fw_type = lv_label_create(scr, NULL); lv_obj_set_style(fw_type, &tft_style_label_rel); - lv_label_set_text(fw_type, - #if MB(MKS_ROBIN_PRO) - "Firmware: Robin_Pro35" - #elif MB(MKS_ROBIN_NANO, MKS_ROBIN_NANO_V2) - "Firmware: Robin_Nano35" - #else - CUSTOM_MACHINE_NAME - #endif - ); + lv_label_set_text(fw_type, "Firmware: Marlin " SHORT_BUILD_VERSION); lv_obj_align(fw_type, NULL, LV_ALIGN_CENTER, 0, -20); board = lv_label_create(scr, NULL); lv_obj_set_style(board, &tft_style_label_rel); lv_label_set_text(board, "Board: " BOARD_INFO_NAME); - lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, 20); + lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, -60); } -void lv_clear_about() { lv_obj_del(scr); } +void lv_clear_about() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp index b6906a6dfec4..a30c99dba07d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp @@ -29,6 +29,7 @@ #include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_ACCE_RETURN 1 @@ -160,14 +161,14 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { void lv_draw_acceleration_settings(void) { lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL; - lv_obj_t *buttonPrintText = NULL, *labelPrintText = NULL, *buttonPrintValue = NULL, *labelPrintValue = NULL; - lv_obj_t *buttonRetraText = NULL, *labelRetraText = NULL, *buttonRetraValue = NULL, *labelRetraValue = NULL; - lv_obj_t *buttonTravelText = NULL, *labelTravelText = NULL, *buttonTravelValue = NULL, *labelTravelValue = NULL; - lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; - lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; - lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; - lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL; - lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL; + lv_obj_t *labelPrintText = NULL, *buttonPrintValue = NULL, *labelPrintValue = NULL; + lv_obj_t *labelRetraText = NULL, *buttonRetraValue = NULL, *labelRetraValue = NULL; + lv_obj_t *labelTravelText = NULL, *buttonTravelValue = NULL, *labelTravelValue = NULL; + lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; + lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; + lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; + lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL; + lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL; lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ACCELERATION_UI) { disp_state_stack._disp_index++; @@ -188,231 +189,202 @@ void lv_draw_acceleration_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - // LV_IMG_DECLARE(bmp_para_arrow); - LV_IMG_DECLARE(bmp_para_bank); - if (uiCfg.para_ui_page != 1) { - buttonPrintText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonPrintText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonPrintText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonPrintText, event_handler); - lv_btn_set_style(buttonPrintText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonPrintText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonPrintText, LV_LAYOUT_OFF); - labelPrintText = lv_label_create(buttonPrintText, NULL); /*Add a label to the button*/ - - buttonPrintValue = lv_imgbtn_create(scr, NULL); + + labelPrintText = lv_label_create(scr, NULL); + lv_obj_set_style(labelPrintText, &tft_style_label_rel); + lv_obj_set_pos(labelPrintText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelPrintText, machine_menu.PrintAcceleration); + + buttonPrintValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonPrintValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonPrintValue, event_handler, ID_ACCE_PRINT, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonPrintValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonPrintValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonPrintValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonPrintValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonPrintValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonPrintValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonPrintValue, event_handler, ID_ACCE_PRINT, NULL, 0); + lv_btn_set_style(buttonPrintValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonPrintValue, LV_BTN_STYLE_PR, &style_para_value); labelPrintValue = lv_label_create(buttonPrintValue, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonRetraText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonRetraText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonRetraText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonRetraText, event_handler); - lv_btn_set_style(buttonRetraText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonRetraText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonRetraText, LV_LAYOUT_OFF); - labelRetraText = lv_label_create(buttonRetraText, NULL); /*Add a label to the button*/ + labelRetraText = lv_label_create(scr, NULL); + lv_obj_set_style(labelRetraText, &tft_style_label_rel); + lv_obj_set_pos(labelRetraText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelRetraText, machine_menu.RetractAcceleration); - buttonRetraValue = lv_imgbtn_create(scr, NULL); + buttonRetraValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonRetraValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonRetraValue, event_handler, ID_ACCE_RETRA, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonRetraValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonRetraValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonRetraValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonRetraValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonRetraValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonRetraValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonRetraValue, event_handler, ID_ACCE_RETRA, NULL, 0); + lv_btn_set_style(buttonRetraValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonRetraValue, LV_BTN_STYLE_PR, &style_para_value); labelRetraValue = lv_label_create(buttonRetraValue, NULL); line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); - buttonTravelText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonTravelText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ - lv_obj_set_size(buttonTravelText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonTravelText, event_handler); - lv_btn_set_style(buttonTravelText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonTravelText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonTravelText, LV_LAYOUT_OFF); - labelTravelText = lv_label_create(buttonTravelText, NULL); /*Add a label to the button*/ + labelTravelText = lv_label_create(scr, NULL); + lv_obj_set_style(labelTravelText, &tft_style_label_rel); + lv_obj_set_pos(labelTravelText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelTravelText, machine_menu.TravelAcceleration); - buttonTravelValue = lv_imgbtn_create(scr, NULL); + buttonTravelValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonTravelValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonTravelValue, event_handler, ID_ACCE_TRAVEL, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonTravelValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonTravelValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonTravelValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonTravelValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonTravelValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonTravelValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonTravelValue, event_handler, ID_ACCE_TRAVEL, NULL, 0); + lv_btn_set_style(buttonTravelValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonTravelValue, LV_BTN_STYLE_PR, &style_para_value); labelTravelValue = lv_label_create(buttonTravelValue, NULL); line3 = lv_line_create(scr, NULL); lv_ex_line(line3, line_points[2]); - buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/ - lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonXText, event_handler); - lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF); - labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/ + labelXText = lv_label_create(scr, NULL); + lv_obj_set_style(labelXText, &tft_style_label_rel); + lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelXText, machine_menu.X_Acceleration); - buttonXValue = lv_imgbtn_create(scr, NULL); + buttonXValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_ACCE_X, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_ACCE_X, NULL, 0); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); labelXValue = lv_label_create(buttonXValue, NULL); line4 = lv_line_create(scr, NULL); lv_ex_line(line4, line_points[3]); - buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_DOWN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_DOWN, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonPrintValue); + lv_group_add_obj(g, buttonRetraValue); + lv_group_add_obj(g, buttonTravelValue); + lv_group_add_obj(g, buttonXValue); + lv_group_add_obj(g, buttonTurnPage); + } + #endif } else { - buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonYText, event_handler); - lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF); - labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/ - - buttonYValue = lv_imgbtn_create(scr, NULL); + labelYText = lv_label_create(scr, NULL); + lv_obj_set_style(labelYText, &tft_style_label_rel); + lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelYText, machine_menu.Y_Acceleration); + + buttonYValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); labelYValue = lv_label_create(buttonYValue, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonZText, event_handler); - lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF); - labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/ + labelZText = lv_label_create(scr, NULL); + lv_obj_set_style(labelZText, &tft_style_label_rel); + lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelZText, machine_menu.Z_Acceleration); - buttonZValue = lv_imgbtn_create(scr, NULL); + buttonZValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_ACCE_Z, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0); + lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_ACCE_Z, NULL, 0); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); labelZValue = lv_label_create(buttonZValue, NULL); + line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); - buttonE0Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ - lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonE0Text, event_handler); - lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF); - labelE0Text = lv_label_create(buttonE0Text, NULL); /*Add a label to the button*/ + labelE0Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelE0Text, &tft_style_label_rel); + lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelE0Text, machine_menu.E0_Acceleration); - buttonE0Value = lv_imgbtn_create(scr, NULL); + buttonE0Value = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_ACCE_E0, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF); + lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0); + lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_ACCE_E0, NULL, 0); + lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value); labelE0Value = lv_label_create(buttonE0Value, NULL); + line3 = lv_line_create(scr, NULL); lv_ex_line(line3, line_points[2]); - buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/ - lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonE1Text, event_handler); - lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF); - labelE1Text = lv_label_create(buttonE1Text, NULL); /*Add a label to the button*/ + labelE1Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelE1Text, &tft_style_label_rel); + lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelE1Text, machine_menu.E1_Acceleration); - buttonE1Value = lv_imgbtn_create(scr, NULL); + buttonE1Value = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_ACCE_E1, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF); + lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0); + lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_ACCE_E1, NULL, 0); + lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value); labelE1Value = lv_label_create(buttonE1Value, NULL); + line4 = lv_line_create(scr, NULL); lv_ex_line(line4, line_points[3]); - buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_UP, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_UP, NULL, 0); + //lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + //lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); + //lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); + //lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonYValue); + lv_group_add_obj(g, buttonZValue); + lv_group_add_obj(g, buttonE0Value); + lv_group_add_obj(g, buttonE1Value); + lv_group_add_obj(g, buttonTurnPage); + } + #endif } + //lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); + //lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF); + //labelTurnPage = lv_label_create(buttonTurnPage, NULL); lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); - lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF); + lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); labelTurnPage = lv_label_create(buttonTurnPage, NULL); - buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ACCE_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); - + buttonBack = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ACCE_RETURN, NULL, 0); + //lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + //lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); + //lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + //lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); - lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); label_Back = lv_label_create(buttonBack, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + + //lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + //lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); if (gCfgItems.multiple_language != 0) { if (uiCfg.para_ui_page != 1) { - lv_label_set_text(labelPrintText, machine_menu.PrintAcceleration); - lv_obj_align(labelPrintText, buttonPrintText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelRetraText, machine_menu.RetractAcceleration); - lv_obj_align(labelRetraText, buttonRetraText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelTravelText, machine_menu.TravelAcceleration); - lv_obj_align(labelTravelText, buttonTravelText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelXText, machine_menu.X_Acceleration); - lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0); lv_label_set_text(labelTurnPage, machine_menu.next); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); @@ -438,17 +410,6 @@ void lv_draw_acceleration_settings(void) { lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0); } else { - lv_label_set_text(labelYText, machine_menu.Y_Acceleration); - lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelZText, machine_menu.Z_Acceleration); - lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelE0Text, machine_menu.E0_Acceleration); - lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelE1Text, machine_menu.E1_Acceleration); - lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0); lv_label_set_text(labelTurnPage, machine_menu.previous); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); @@ -478,6 +439,11 @@ void lv_draw_acceleration_settings(void) { } } -void lv_clear_acceleration_settings() { lv_obj_del(scr); } +void lv_clear_acceleration_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp index 7d3eab436bd9..5b1b24171697 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp @@ -28,11 +28,18 @@ #include "../../../../MarlinCore.h" +extern lv_group_t * g; static lv_obj_t * scr; -#define ID_ADVANCE_RETURN 1 -#define ID_PAUSE_POS 2 -#define ID_PAUSE_POS_ARROW 3 +#define ID_ADVANCE_RETURN 1 +#define ID_PAUSE_POS 2 +#define ID_PAUSE_POS_ARROW 3 +#define ID_WIFI_PARA 4 +#define ID_WIFI_PARA_ARROW 5 +#define ID_FILAMENT_SETTINGS 6 +#define ID_FILAMENT_SETTINGS_ARROW 7 +#define ID_ENCODER_SETTINGS 8 +#define ID_ENCODER_SETTINGS_ARROW 9 static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { @@ -63,13 +70,79 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { lv_draw_pause_position(); } break; + case ID_FILAMENT_SETTINGS: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_advance_settings(); + lv_draw_filament_settings(); + } + break; + case ID_FILAMENT_SETTINGS_ARROW: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_advance_settings(); + lv_draw_filament_settings(); + } + break; + #if ENABLED(USE_WIFI_FUNCTION) + case ID_WIFI_PARA: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_advance_settings(); + lv_draw_wifi_settings(); + } + break; + case ID_WIFI_PARA_ARROW: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_advance_settings(); + lv_draw_wifi_settings(); + } + break; + #endif + #if HAS_ROTARY_ENCODER + case ID_ENCODER_SETTINGS: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_advance_settings(); + lv_draw_encoder_settings(); + } + break; + case ID_ENCODER_SETTINGS_ARROW: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_advance_settings(); + lv_draw_encoder_settings(); + } + break; + #endif } } void lv_draw_advance_settings(void) { lv_obj_t *buttonBack, *label_Back; lv_obj_t *buttonPausePos, *labelPausePos, *buttonPausePosNarrow; - lv_obj_t * line1; + lv_obj_t *buttonFilamentSettings, *labelFilamentSettings, *buttonFilamentSettingsNarrow; + lv_obj_t * line1,* line2; + #if ENABLED(USE_WIFI_FUNCTION) + lv_obj_t *buttonWifiSet,*labelWifiSet,*buttonWifiSetNarrow; + #endif + #if HAS_ROTARY_ENCODER + lv_obj_t *buttonEcoder,*labelEcoder,*buttonEcoderNarrow; + #endif + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) { disp_state_stack._disp_index++; disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI; @@ -89,24 +162,24 @@ void lv_draw_advance_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - LV_IMG_DECLARE(bmp_para_arrow); - - buttonPausePos = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + buttonPausePos = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y); + lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); //lv_obj_set_event_cb(buttonMachine, event_handler); lv_obj_set_event_cb_mks(buttonPausePos, event_handler, ID_PAUSE_POS, NULL, 0); - lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_REL, &tft_style_label_rel); + lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_PR, &tft_style_label_pre); lv_btn_set_layout(buttonPausePos, LV_LAYOUT_OFF); - labelPausePos = lv_label_create(buttonPausePos, NULL); /*Add a label to the button*/ + labelPausePos = lv_label_create(buttonPausePos, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPausePos); + #endif buttonPausePosNarrow = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonPausePosNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonPausePosNarrow, event_handler, ID_PAUSE_POS_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_event_cb_mks(buttonPausePosNarrow, event_handler, ID_PAUSE_POS_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonPausePosNarrow, LV_LAYOUT_OFF); @@ -114,13 +187,117 @@ void lv_draw_advance_settings(void) { line1 = lv_line_create(lv_scr_act(), NULL); lv_ex_line(line1, line_points[0]); + buttonFilamentSettings = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonFilamentSettings, PARA_UI_POS_X, PARA_UI_POS_Y*2); + lv_obj_set_size(buttonFilamentSettings, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); + lv_obj_set_event_cb_mks(buttonFilamentSettings, event_handler, ID_FILAMENT_SETTINGS, NULL, 0); + lv_btn_set_style(buttonFilamentSettings, LV_BTN_STYLE_REL, &tft_style_label_rel); + lv_btn_set_style(buttonFilamentSettings, LV_BTN_STYLE_PR, &tft_style_label_pre); + lv_btn_set_layout(buttonFilamentSettings, LV_LAYOUT_OFF); + labelFilamentSettings = lv_label_create(buttonFilamentSettings, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonFilamentSettings); + #endif + + buttonFilamentSettingsNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonFilamentSettingsNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y*2 + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonFilamentSettingsNarrow, event_handler, ID_FILAMENT_SETTINGS_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonFilamentSettingsNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonFilamentSettingsNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonFilamentSettingsNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonFilamentSettingsNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonFilamentSettingsNarrow, LV_LAYOUT_OFF); + + line2 = lv_line_create(lv_scr_act(), NULL); + lv_ex_line(line2, line_points[1]); + + #if ENABLED(USE_WIFI_FUNCTION) + + buttonWifiSet = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonWifiSet, PARA_UI_POS_X,PARA_UI_POS_Y*3); + lv_obj_set_size(buttonWifiSet, PARA_UI_SIZE_X,PARA_UI_SIZE_Y); + lv_obj_set_event_cb_mks(buttonWifiSet, event_handler,ID_WIFI_PARA,NULL,0); + lv_btn_set_style(buttonWifiSet, LV_BTN_STYLE_REL, &tft_style_label_rel); + lv_btn_set_style(buttonWifiSet, LV_BTN_STYLE_PR, &tft_style_label_pre); + lv_btn_set_layout(buttonWifiSet, LV_LAYOUT_OFF); + labelWifiSet = lv_label_create(buttonWifiSet, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonWifiSet); + #endif + + buttonWifiSetNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonWifiSetNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*3+PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonWifiSetNarrow, event_handler,ID_WIFI_PARA_ARROW, NULL,0); + lv_imgbtn_set_src(buttonWifiSetNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonWifiSetNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonWifiSetNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonWifiSetNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonWifiSetNarrow, LV_LAYOUT_OFF); + + lv_obj_t * line3 = lv_line_create(scr, NULL); + lv_ex_line(line3,line_points[2]); + + #if HAS_ROTARY_ENCODER + buttonEcoder = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonEcoder, PARA_UI_POS_X,PARA_UI_POS_Y*4); + lv_obj_set_size(buttonEcoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y); + lv_obj_set_event_cb_mks(buttonEcoder, event_handler,ID_ENCODER_SETTINGS,NULL,0); + lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_REL, &tft_style_label_rel); + lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_PR, &tft_style_label_pre); + lv_btn_set_layout(buttonEcoder, LV_LAYOUT_OFF); + labelEcoder = lv_label_create(buttonEcoder, NULL); + + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEcoder); + + buttonEcoderNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonEcoderNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*4+PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonEcoderNarrow, event_handler,ID_ENCODER_SETTINGS_ARROW, NULL,0); + lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonEcoderNarrow, LV_LAYOUT_OFF); + + lv_obj_t * line4 = lv_line_create(scr, NULL); + lv_ex_line(line4,line_points[3]); + #endif + + #elif HAS_ROTARY_ENCODER + buttonEcoder = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonEcoder, PARA_UI_POS_X,PARA_UI_POS_Y*3); + lv_obj_set_size(buttonEcoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y); + lv_obj_set_event_cb_mks(buttonEcoder, event_handler,ID_ENCODER_SETTINGS,NULL,0); + lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_REL, &tft_style_label_rel); + lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_PR, &tft_style_label_pre); + lv_btn_set_layout(buttonEcoder, LV_LAYOUT_OFF); + labelEcoder = lv_label_create(buttonEcoder, NULL); + + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEcoder); + + buttonEcoderNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonEcoderNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*3+PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonEcoderNarrow, event_handler,ID_ENCODER_SETTINGS_ARROW, NULL,0); + lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonEcoderNarrow, LV_LAYOUT_OFF); + + lv_obj_t * line3 = lv_line_create(scr, NULL); + lv_ex_line(line3,line_points[2]); + #endif + buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ADVANCE_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ADVANCE_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); @@ -131,10 +308,27 @@ void lv_draw_advance_settings(void) { lv_label_set_text(labelPausePos, machine_menu.PausePosition); lv_obj_align(labelPausePos, buttonPausePos, LV_ALIGN_IN_LEFT_MID, 0, 0); + + lv_label_set_text(labelFilamentSettings, machine_menu.FilamentConf); + lv_obj_align(labelFilamentSettings, buttonFilamentSettings, LV_ALIGN_IN_LEFT_MID, 0, 0); + + #if ENABLED(USE_WIFI_FUNCTION) + lv_label_set_text(labelWifiSet, machine_menu.WifiSettings); + lv_obj_align(labelWifiSet, buttonWifiSet, LV_ALIGN_IN_LEFT_MID,0, 0); + #endif + #if HAS_ROTARY_ENCODER + lv_label_set_text(labelEcoder, machine_menu.EncoderSettings); + lv_obj_align(labelEcoder, buttonEcoder, LV_ALIGN_IN_LEFT_MID,0, 0); + #endif } } -void lv_clear_advance_settings() { lv_obj_del(scr); } +void lv_clear_advance_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp new file mode 100644 index 000000000000..bb6b45aebe48 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp @@ -0,0 +1,203 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if BOTH(HAS_TFT_LVGL_UI, HAS_BED_PROBE) + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/planner.h" +#include "../../../../module/probe.h" + +extern lv_group_t * g; +static lv_obj_t * scr; + +#define ID_OFFSET_RETURN 1 +#define ID_OFFSET_X 2 +#define ID_OFFSET_Y 3 +#define ID_OFFSET_Z 4 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_OFFSET_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_auto_level_offset_settings(); + draw_return_ui(); + } + break; + case ID_OFFSET_X: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = x_offset; + lv_clear_auto_level_offset_settings(); + lv_draw_number_key(); + } + break; + case ID_OFFSET_Y: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = y_offset; + lv_clear_auto_level_offset_settings(); + lv_draw_number_key(); + } + break; + case ID_OFFSET_Z: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = z_offset; + lv_clear_auto_level_offset_settings(); + lv_draw_number_key(); + } + break; + } +} + +void lv_draw_auto_level_offset_settings(void) { + lv_obj_t *buttonBack = NULL, *label_Back = NULL; + lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; + lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; + lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; + lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NOZZLE_PROBE_OFFSET_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI; + } + disp_state = NOZZLE_PROBE_OFFSET_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, machine_menu.OffsetConfTitle); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + labelXText = lv_label_create(scr, NULL); + lv_obj_set_style(labelXText, &tft_style_label_rel); + lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelXText, machine_menu.Xoffset); + + buttonXValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_OFFSET_X, NULL, 0); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); + labelXValue = lv_label_create(buttonXValue, NULL); + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1, line_points[0]); + + labelYText = lv_label_create(scr, NULL); + lv_obj_set_style(labelYText, &tft_style_label_rel); + lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelYText, machine_menu.Yoffset); + + buttonYValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_OFFSET_Y, NULL, 0); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); + labelYValue = lv_label_create(buttonYValue, NULL); + + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2, line_points[1]); + + labelZText = lv_label_create(scr, NULL); + lv_obj_set_style(labelZText, &tft_style_label_rel); + lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelZText, machine_menu.Zoffset); + + buttonZValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_OFFSET_Z, NULL, 0); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); + labelZValue = lv_label_create(buttonZValue, NULL); + + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3, line_points[2]); + + buttonBack = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_OFFSET_RETURN, NULL, 0); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + label_Back = lv_label_create(buttonBack, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonXValue); + lv_group_add_obj(g, buttonYValue); + lv_group_add_obj(g, buttonZValue); + lv_group_add_obj(g, buttonBack); + } + #endif + + if (gCfgItems.multiple_language != 0) { + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0)); + lv_label_set_text(labelXValue, public_buf_l); + lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0)); + lv_label_set_text(labelYValue, public_buf_l); + lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z); + lv_label_set_text(labelZValue, public_buf_l); + lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); + } +} + +void lv_clear_auto_level_offset_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI && HAS_BED_PROBE diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h new file mode 100644 index 000000000000..688cd205d04f --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_auto_level_offset_settings(void); +extern void lv_clear_auto_level_offset_settings(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp new file mode 100644 index 000000000000..70564c036c64 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp @@ -0,0 +1,352 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../MarlinCore.h" +#include "../../../../gcode/queue.h" +#include "../../../../gcode/gcode.h" + +#if HAS_BED_PROBE + #include "../../../../module/probe.h" +#endif + +extern lv_group_t * g; +static lv_obj_t * scr; + +static lv_obj_t *labelV, *buttonV, * zOffsetText; + +#define ID_BABY_STEP_X_P 1 +#define ID_BABY_STEP_X_N 2 +#define ID_BABY_STEP_Y_P 3 +#define ID_BABY_STEP_Y_N 4 +#define ID_BABY_STEP_Z_P 5 +#define ID_BABY_STEP_Z_N 6 +#define ID_BABY_STEP_DIST 7 +#define ID_BABY_STEP_RETURN 8 + +static float babystep_dist=0.01; +static uint8_t has_adjust_z = 0; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + char baby_buf[30]={0}; + switch (obj->mks_obj_id) { + case ID_BABY_STEP_X_P: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + ZERO(baby_buf); + sprintf_P(baby_buf, PSTR("M290 X%.3f"),babystep_dist); + gcode.process_subcommands_now_P(PSTR(baby_buf)); + has_adjust_z = 1; + } + break; + case ID_BABY_STEP_X_N: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + ZERO(baby_buf); + sprintf_P(baby_buf, PSTR("M290 X%.3f"),((float)0 - babystep_dist)); + gcode.process_subcommands_now_P(PSTR(baby_buf)); + has_adjust_z = 1; + } + break; + case ID_BABY_STEP_Y_P: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + ZERO(baby_buf); + sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist); + gcode.process_subcommands_now_P(PSTR(baby_buf)); + has_adjust_z = 1; + } + break; + case ID_BABY_STEP_Y_N: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + ZERO(baby_buf); + sprintf_P(baby_buf, PSTR("M290 Y%.3f"),((float)0 - babystep_dist)); + gcode.process_subcommands_now_P(PSTR(baby_buf)); + has_adjust_z = 1; + } + break; + case ID_BABY_STEP_Z_P: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + ZERO(baby_buf); + sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist); + gcode.process_subcommands_now_P(PSTR(baby_buf)); + has_adjust_z = 1; + } + break; + case ID_BABY_STEP_Z_N: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + ZERO(baby_buf); + sprintf_P(baby_buf, PSTR("M290 Z%.3f"),((float)0 - babystep_dist)); + gcode.process_subcommands_now_P(PSTR(baby_buf)); + has_adjust_z = 1; + } + break; + case ID_BABY_STEP_DIST: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (abs((int)(100 * babystep_dist)) == 1) + babystep_dist = 0.05; + else if (abs((int)(100 * babystep_dist)) == 5) + babystep_dist = 0.1; + else + babystep_dist = 0.01; + disp_baby_step_dist(); + } + + break; + case ID_BABY_STEP_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + if (has_adjust_z == 1) { + gcode.process_subcommands_now_P(PSTR("M500")); + has_adjust_z = 0; + } + clear_cur_ui(); + draw_return_ui(); + } + break; + } +} + +void lv_draw_baby_stepping(void) { + lv_obj_t *buttonXI, *buttonXD, *buttonYI, *buttonYD, *buttonZI, *buttonZD, *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != BABY_STEP_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = BABY_STEP_UI; + } + disp_state = BABY_STEP_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + // Create an Image button + buttonXI = lv_imgbtn_create(scr, NULL); + buttonXD = lv_imgbtn_create(scr, NULL); + buttonYI = lv_imgbtn_create(scr, NULL); + buttonYD = lv_imgbtn_create(scr, NULL); + buttonZI = lv_imgbtn_create(scr, NULL); + buttonZD = lv_imgbtn_create(scr, NULL); + buttonV = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_BABY_STEP_X_P, NULL, 0); + lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, "F:/bmp_xAdd.bin"); + lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, "F:/bmp_xAdd.bin"); + lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_REL, &tft_style_label_rel); + + #if 1 + lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_BABY_STEP_X_N, NULL, 0); + lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, "F:/bmp_xDec.bin"); + lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, "F:/bmp_xDec.bin"); + lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_BABY_STEP_Y_P, NULL, 0); + lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, "F:/bmp_yAdd.bin"); + lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, "F:/bmp_yAdd.bin"); + lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_BABY_STEP_Y_N, NULL, 0); + lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, "F:/bmp_yDec.bin"); + lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, "F:/bmp_yDec.bin"); + lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_BABY_STEP_Z_P, NULL, 0); + lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, "F:/bmp_zAdd.bin"); + lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, "F:/bmp_zAdd.bin"); + lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_BABY_STEP_Z_N, NULL, 0); + lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, "F:/bmp_zDec.bin"); + lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, "F:/bmp_zDec.bin"); + lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonV, event_handler, ID_BABY_STEP_DIST, NULL, 0); + lv_imgbtn_set_style(buttonV, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonV, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_BABY_STEP_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + + #endif // if 1 + lv_obj_set_pos(buttonXI, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonYI, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + lv_obj_set_pos(buttonZI, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); + lv_obj_set_pos(buttonV, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonXD, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonYD, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonZD, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + // Create labels on the image buttons + lv_btn_set_layout(buttonXI, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonXD, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonYI, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonYD, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonZI, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonZD, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonV, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t *labelXI = lv_label_create(buttonXI, NULL); + lv_obj_t *labelXD = lv_label_create(buttonXD, NULL); + lv_obj_t *labelYI = lv_label_create(buttonYI, NULL); + lv_obj_t *labelYD = lv_label_create(buttonYD, NULL); + lv_obj_t *labelZI = lv_label_create(buttonZI, NULL); + lv_obj_t *labelZD = lv_label_create(buttonZD, NULL); + labelV = lv_label_create(buttonV, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelXI, move_menu.x_add); + lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelXD, move_menu.x_dec); + lv_obj_align(labelXD, buttonXD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelYI, move_menu.y_add); + lv_obj_align(labelYI, buttonYI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelYD, move_menu.y_dec); + lv_obj_align(labelYD, buttonYD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelZI, move_menu.z_add); + lv_obj_align(labelZI, buttonZI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelZD, move_menu.z_dec); + lv_obj_align(labelZD, buttonZD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonXI); + lv_group_add_obj(g, buttonXD); + lv_group_add_obj(g, buttonYI); + lv_group_add_obj(g, buttonYD); + lv_group_add_obj(g, buttonZI); + lv_group_add_obj(g, buttonZD); + lv_group_add_obj(g, buttonV); + lv_group_add_obj(g, buttonBack); + } + #endif + + disp_baby_step_dist(); + + zOffsetText = lv_label_create(scr, NULL); + lv_obj_set_style(zOffsetText, &tft_style_label_rel); + lv_obj_set_pos(zOffsetText, 290, TITLE_YPOS); + disp_z_offset_value(); +} + +void disp_baby_step_dist() { + // char buf[30] = {0}; + + if ((int)(100 * babystep_dist) == 1) { + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_01.bin"); + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_01.bin"); + } + else if ((int)(100 * babystep_dist) == 5) { + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_05.bin"); + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_05.bin"); + } + else if ((int)(100 * babystep_dist) == 10) { + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_1.bin"); + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_1.bin"); + } + if (gCfgItems.multiple_language != 0) { + if ((int)(100 * babystep_dist) == 1) { + lv_label_set_text(labelV, move_menu.step_001mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if ((int)(100 * babystep_dist) == 5) { + lv_label_set_text(labelV, move_menu.step_005mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if ((int)(100 * babystep_dist) == 10) { + lv_label_set_text(labelV, move_menu.step_01mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void disp_z_offset_value() { + char buf[20]; + + ZERO(buf); + sprintf_P(buf, PSTR("offset Z: %.3f"), (double)TERN(HAS_BED_PROBE, probe.offset.z, 0)); + lv_label_set_text(zOffsetText, buf); +} + +void lv_clear_baby_stepping() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h new file mode 100644 index 000000000000..333ba2d59717 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h @@ -0,0 +1,36 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_baby_stepping(void); +extern void lv_clear_baby_stepping(); +extern void disp_baby_step_dist(); +extern void disp_z_offset_value(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp index cc3f847bced7..c60000afaee3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp @@ -34,9 +34,10 @@ #include "../../../../module/temperature.h" #include "../../../../module/planner.h" +extern lv_group_t * g; static lv_obj_t * scr; -static lv_obj_t * labelStep, *buttonStep, *buttonMov, *buttonExt; -static lv_obj_t * labelMov, *labelExt; +static lv_obj_t *labelStep, *buttonStep, *buttonMov, *buttonExt; +static lv_obj_t *labelMov, *labelExt; static lv_obj_t * printSpeedText; #define ID_C_ADD 1 @@ -175,7 +176,6 @@ void lv_draw_change_speed(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); // Create an Image button buttonAdd = lv_imgbtn_create(scr, NULL); @@ -185,38 +185,34 @@ void lv_draw_change_speed(void) { buttonStep = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_C_ADD, "bmp_Add.bin", 0); - lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_C_ADD, NULL, 0); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin"); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin"); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); #if 1 - lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_C_DEC, "bmp_Dec.bin", 0); - lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_C_DEC, NULL, 0); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin"); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin"); lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, NULL, 0); lv_imgbtn_set_style(buttonMov, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonMov, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, NULL, 0); lv_imgbtn_set_style(buttonExt, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonExt, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, NULL, 0); lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_C_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_C_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); #endif @@ -253,6 +249,17 @@ void lv_draw_change_speed(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonAdd); + lv_group_add_obj(g, buttonDec); + lv_group_add_obj(g, buttonMov); + lv_group_add_obj(g, buttonExt); + lv_group_add_obj(g, buttonStep); + lv_group_add_obj(g, buttonBack); + } + #endif + disp_speed_type(); disp_speed_step(); @@ -262,13 +269,18 @@ void lv_draw_change_speed(void) { } void disp_speed_step() { - if (uiCfg.stepPrintSpeed == 1) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step1_percent.bin", 0); - else if (uiCfg.stepPrintSpeed == 5) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step5_percent.bin", 0); - else if (uiCfg.stepPrintSpeed == 10) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step10_percent.bin", 0); - + if (uiCfg.stepPrintSpeed == 1) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_percent.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_percent.bin"); + } + else if (uiCfg.stepPrintSpeed == 5) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_percent.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_percent.bin"); + } + else if (uiCfg.stepPrintSpeed == 10) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_percent.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_percent.bin"); + } if (gCfgItems.multiple_language != 0) { if (uiCfg.stepPrintSpeed == 1) { lv_label_set_text(labelStep, speed_menu.step_1percent); @@ -309,13 +321,17 @@ void disp_print_speed() { void disp_speed_type() { switch (speedType) { case 1: - lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_extruct_sel.bin", 0); - lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_changeSpeed.bin", 0); + lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, "F:/bmp_mov_changeSpeed.bin"); + lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, "F:/bmp_mov_changeSpeed.bin"); + lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, "F:/bmp_extruct_sel.bin"); + lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, "F:/bmp_extruct_sel.bin"); break; default: - lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_speed_extruct.bin", 0); - lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_sel.bin", 0); + lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, "F:/bmp_mov_sel.bin"); + lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, "F:/bmp_mov_sel.bin"); + lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, "F:/bmp_speed_extruct.bin"); + lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, "F:/bmp_speed_extruct.bin"); break; } lv_obj_refresh_ext_draw_pad(buttonExt); @@ -330,6 +346,11 @@ void disp_speed_type() { } } -void lv_clear_change_speed() { lv_obj_del(scr); } +void lv_clear_change_speed() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index 3b4fc8d2071c..c8483230103c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -41,6 +41,7 @@ #include "../../../../gcode/queue.h" #include "../../../../module/temperature.h" #include "../../../../module/planner.h" +#include "../../../../gcode/gcode.h" #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../../feature/powerloss.h" @@ -51,20 +52,25 @@ #endif #include "../../../../gcode/gcode.h" -#include "pic_manager.h" - +extern lv_group_t * g; static lv_obj_t * scr; +static lv_obj_t * tempText1; +static lv_obj_t * filament_bar; + extern uint8_t sel_id; extern uint8_t once_flag; extern uint8_t gcode_preview_over; -uint8_t DialogType; +extern int upload_result ; +extern uint32_t upload_time; +extern uint32_t upload_size; +extern uint8_t temperature_change_frequency; static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { if (event == LV_EVENT_CLICKED) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - if (DialogType == DIALOG_TYPE_PRINT_FILE) { + if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) { #if HAS_GCODE_PREVIEW preview_gcode_prehandle(list_file.file_name[sel_id]); #endif @@ -108,7 +114,8 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { } #endif } - else if (DialogType == DIALOG_TYPE_STOP) { + else if (uiCfg.dialogType == DIALOG_TYPE_STOP) { + wait_for_heatup = false; stop_print_time(); lv_clear_dialog(); lv_draw_ready_print(); @@ -130,40 +137,57 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { //queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107")); #endif } - else if (DialogType == DIALOG_TYPE_FINISH_PRINT) { + else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) { clear_cur_ui(); lv_draw_ready_print(); } #if ENABLED(ADVANCED_PAUSE_FEATURE) - else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING - || DialogType == DIALOG_PAUSE_MESSAGE_INSERT - || DialogType == DIALOG_PAUSE_MESSAGE_HEAT + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT ) { wait_for_user = false; } - else if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) { pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; } - else if (DialogType == DIALOG_PAUSE_MESSAGE_RESUME) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) { clear_cur_ui(); draw_return_ui(); } #endif - else if (DialogType == DIALOG_STORE_EEPROM_TIPS) { + else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) { gcode.process_subcommands_now_P(PSTR("M500")); clear_cur_ui(); draw_return_ui(); } - else if (DialogType == DIALOG_READ_EEPROM_TIPS) { + else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) { gcode.process_subcommands_now_P(PSTR("M501")); clear_cur_ui(); draw_return_ui(); } - else if (DialogType == DIALOG_REVERT_EEPROM_TIPS) { + else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) { gcode.process_subcommands_now_P(PSTR("M502")); clear_cur_ui(); draw_return_ui(); } + else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) { + uiCfg.configWifi = 1; + clear_cur_ui(); + draw_return_ui(); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) { + uiCfg.filament_heat_completed_load = 1; + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) { + uiCfg.filament_heat_completed_unload = 1; + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED + || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED + ) { + clear_cur_ui(); + draw_return_ui(); + } } } @@ -172,11 +196,35 @@ static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) { + if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) { #if ENABLED(ADVANCED_PAUSE_FEATURE) pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; #endif } + else if ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT) + || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT) + || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) + || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) + ) { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak; + clear_cur_ui(); + draw_return_ui(); + } + else if ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING) + || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING) + ) { + queue.enqueue_one_P(PSTR("M410")); + uiCfg.filament_rate = 0; + uiCfg.filament_loading_completed = 0; + uiCfg.filament_unloading_completed = 0; + uiCfg.filament_loading_time_flg = 0; + uiCfg.filament_loading_time_cnt = 0; + uiCfg.filament_unloading_time_flg = 0; + uiCfg.filament_unloading_time_cnt = 0; + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak; + clear_cur_ui(); + draw_return_ui(); + } else { clear_cur_ui(); draw_return_ui(); @@ -186,13 +234,15 @@ static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) { void lv_draw_dialog(uint8_t type) { + lv_obj_t * btnOk = NULL; + lv_obj_t * btnCancel = NULL; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != DIALOG_UI) { disp_state_stack._disp_index++; disp_state_stack._disp_state[disp_state_stack._disp_index] = DIALOG_UI; } disp_state = DIALOG_UI; - DialogType = type; + uiCfg.dialogType = type; scr = lv_obj_create(NULL, NULL); @@ -208,7 +258,6 @@ void lv_draw_dialog(uint8_t type) { lv_refr_now(lv_refr_get_disp_refreshing()); - //LV_IMG_DECLARE(bmp_pic); static lv_style_t style_btn_rel; // A variable to store the released style lv_style_copy(&style_btn_rel, &lv_style_plain); // Initialize from a built-in style @@ -231,60 +280,151 @@ void lv_draw_dialog(uint8_t type) { style_btn_pr.text.color = lv_color_hex3(0xBCD); style_btn_pr.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22); - lv_obj_t * labelDialog = lv_label_create(scr, NULL); + lv_obj_t *labelDialog = lv_label_create(scr, NULL); lv_obj_set_style(labelDialog, &tft_style_label_rel); - if (DialogType == DIALOG_TYPE_FINISH_PRINT || DialogType == DIALOG_PAUSE_MESSAGE_RESUME) { - lv_obj_t * btnOk = lv_btn_create(scr, NULL); // Add a button the current screen - lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y); // Set its position - lv_obj_set_size(btnOk, 100, 50); // Set its size - lv_obj_set_event_cb(btnOk, btn_ok_event_cb); - lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style - lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style - lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button - lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text + if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) { + btnOk = lv_btn_create(scr, NULL); // Add a button the current screen + lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y); // Set its position + lv_obj_set_size(btnOk, 100, 50); // Set its size + lv_obj_set_event_cb(btnOk, btn_ok_event_cb); + lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style + lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style + lv_obj_t *labelOk = lv_label_create(btnOk, NULL); // Add a label to the button + lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text } - else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING - || DialogType == DIALOG_PAUSE_MESSAGE_INSERT - || DialogType == DIALOG_PAUSE_MESSAGE_HEAT + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT ) { - lv_obj_t * btnOk = lv_btn_create(scr, NULL); // Add a button the current screen + btnOk = lv_btn_create(scr, NULL); // Add a button the current screen lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y); // Set its position lv_obj_set_size(btnOk, 100, 50); // Set its size lv_obj_set_event_cb(btnOk, btn_ok_event_cb); lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style - lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button + lv_obj_t *labelOk = lv_label_create(btnOk, NULL); // Add a label to the button lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text } - else if (DialogType == DIALOG_PAUSE_MESSAGE_PAUSING - || DialogType == DIALOG_PAUSE_MESSAGE_CHANGING - || DialogType == DIALOG_PAUSE_MESSAGE_UNLOAD - || DialogType == DIALOG_PAUSE_MESSAGE_LOAD - || DialogType == DIALOG_PAUSE_MESSAGE_PURGE - || DialogType == DIALOG_PAUSE_MESSAGE_RESUME - || DialogType == DIALOG_PAUSE_MESSAGE_HEATING + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_CHANGING + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_UNLOAD + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_LOAD + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PURGE + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME + || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEATING ) { // nothing to do } + else if (uiCfg.dialogType == WIFI_ENABLE_TIPS) { + btnCancel = lv_btn_create(scr, NULL); + lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y); + lv_obj_set_size(btnCancel, 100, 50); + lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr); + lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL); + lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); + } + else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) { + btnCancel = lv_btn_create(scr, NULL); + lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y); + lv_obj_set_size(btnCancel, 100, 50); + lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr); + lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL); + lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); + } + #if ENABLED(USE_WIFI_FUNCTION) + else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) { + if (upload_result == 2) { + btnCancel = lv_btn_create(scr, NULL); + lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y); + lv_obj_set_size(btnCancel, 100, 50); + lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr); + lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL); + lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); + } + else if (upload_result == 3) { + btnOk = lv_btn_create(scr, NULL); + lv_obj_set_pos(btnOk, BTN_OK_X+90, BTN_OK_Y); + lv_obj_set_size(btnOk, 100, 50); + lv_obj_set_event_cb(btnOk, btn_ok_event_cb); + lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); + lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); + lv_obj_t *labelOk = lv_label_create(btnOk, NULL); + lv_label_set_text(labelOk, print_file_dialog_menu.confirm); + } + } + #endif //USE_WIFI_FUNCTION + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT + || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT + ) { + btnCancel = lv_btn_create(scr, NULL); + lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y); + lv_obj_set_size(btnCancel, 100, 50); + lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr); + lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL); + lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); + + tempText1 = lv_label_create(scr, NULL); + lv_obj_set_style(tempText1, &tft_style_label_rel); + filament_sprayer_temp(); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED + || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED + ) { + btnOk = lv_btn_create(scr, NULL); + lv_obj_set_pos(btnOk, BTN_OK_X+90, BTN_OK_Y); + lv_obj_set_size(btnOk, 100, 50); + lv_obj_set_event_cb(btnOk, btn_ok_event_cb); + lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); + lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); + lv_obj_t *labelOk = lv_label_create(btnOk, NULL); + lv_label_set_text(labelOk, print_file_dialog_menu.confirm); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING + || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING + ) { + btnCancel = lv_btn_create(scr, NULL); + lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y); + lv_obj_set_size(btnCancel, 100, 50); + lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); + lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr); + lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL); + lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); + + filament_bar = lv_bar_create(scr, NULL); + lv_obj_set_pos(filament_bar, (TFT_WIDTH-400)/2, ((TFT_HEIGHT - titleHeight)-40)/2); + lv_obj_set_size(filament_bar, 400, 25); + lv_bar_set_style(filament_bar, LV_BAR_STYLE_INDIC, &lv_bar_style_indic); + lv_bar_set_anim_time(filament_bar, 1000); + lv_bar_set_value(filament_bar, 0, LV_ANIM_ON); + } else { - lv_obj_t * btnOk = lv_btn_create(scr, NULL); // Add a button the current screen + btnOk = lv_btn_create(scr, NULL); // Add a button the current screen lv_obj_set_pos(btnOk, BTN_OK_X, BTN_OK_Y); // Set its position lv_obj_set_size(btnOk, 100, 50); // Set its size lv_obj_set_event_cb(btnOk, btn_ok_event_cb); lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style - lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button + lv_obj_t *labelOk = lv_label_create(btnOk, NULL); // Add a label to the button - lv_obj_t * btnCancel = lv_btn_create(scr, NULL); // Add a button the current screen + btnCancel = lv_btn_create(scr, NULL); // Add a button the current screen lv_obj_set_pos(btnCancel, BTN_CANCEL_X, BTN_CANCEL_Y); // Set its position lv_obj_set_size(btnCancel, 100, 50); // Set its size lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb); lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style - lv_obj_t * labelCancel = lv_label_create(btnCancel, NULL); // Add a label to the button + lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL); // Add a label to the button - if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) { + if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) { lv_label_set_text(labelOk, pause_msg_menu.purgeMore); // Set the labels text lv_label_set_text(labelCancel, pause_msg_menu.continuePrint); } @@ -293,82 +433,271 @@ void lv_draw_dialog(uint8_t type) { lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); } } - if (DialogType == DIALOG_TYPE_PRINT_FILE) { + if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) { lv_label_set_text(labelDialog, print_file_dialog_menu.print_file); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); - lv_obj_t * labelFile = lv_label_create(scr, NULL); + lv_obj_t *labelFile = lv_label_create(scr, NULL); lv_obj_set_style(labelFile, &tft_style_label_rel); lv_label_set_text(labelFile, list_file.long_name[sel_id]); lv_obj_align(labelFile, NULL, LV_ALIGN_CENTER, 0, -60); } - else if (DialogType == DIALOG_TYPE_STOP) { + else if (uiCfg.dialogType == DIALOG_TYPE_STOP) { lv_label_set_text(labelDialog, print_file_dialog_menu.cancle_print); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_TYPE_FINISH_PRINT) { + else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) { lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_PAUSING) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING) { lv_label_set_text(labelDialog, pause_msg_menu.pausing); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_CHANGING) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_CHANGING) { lv_label_set_text(labelDialog, pause_msg_menu.changing); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) { lv_label_set_text(labelDialog, pause_msg_menu.unload); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING) { lv_label_set_text(labelDialog, pause_msg_menu.waiting); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_INSERT) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT) { lv_label_set_text(labelDialog, pause_msg_menu.insert); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_LOAD) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_LOAD) { lv_label_set_text(labelDialog, pause_msg_menu.load); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_PURGE) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PURGE) { lv_label_set_text(labelDialog, pause_msg_menu.purge); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_RESUME) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) { lv_label_set_text(labelDialog, pause_msg_menu.resume); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_HEAT) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT) { lv_label_set_text(labelDialog, pause_msg_menu.heat); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_HEATING) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEATING) { lv_label_set_text(labelDialog, pause_msg_menu.heating); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) { + else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) { lv_label_set_text(labelDialog, pause_msg_menu.option); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_STORE_EEPROM_TIPS) { + else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) { lv_label_set_text(labelDialog, eeprom_menu.storeTips); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_READ_EEPROM_TIPS) { + else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) { lv_label_set_text(labelDialog, eeprom_menu.readTips); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } - else if (DialogType == DIALOG_REVERT_EEPROM_TIPS) { + else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) { lv_label_set_text(labelDialog, eeprom_menu.revertTips); lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); } + else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) { + lv_label_set_text(labelDialog, machine_menu.wifiConfigTips); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (uiCfg.dialogType == WIFI_ENABLE_TIPS) { + lv_label_set_text(labelDialog, print_file_dialog_menu.wifi_enable_tips); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) { + lv_label_set_text(labelDialog, DIALOG_UPDATE_NO_DEVICE_EN); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + #if ENABLED(USE_WIFI_FUNCTION) + else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) { + if (upload_result == 1) { + lv_label_set_text(labelDialog, DIALOG_UPLOAD_ING_EN); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (upload_result == 2) { + lv_label_set_text(labelDialog, DIALOG_UPLOAD_ERROR_EN); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (upload_result == 3) { + char buf[200]; + int _index = 0; + + ZERO(buf); + + strcpy(buf, DIALOG_UPLOAD_FINISH_EN); + _index = strlen(buf); + buf[_index] = '\n'; + _index++; + strcat(buf, DIALOG_UPLOAD_SIZE_EN); + + _index = strlen(buf); + buf[_index] = ':'; + _index++; + sprintf(&buf[_index], " %d KBytes\n", (int)(upload_size / 1024)); + + strcat(buf, DIALOG_UPLOAD_TIME_EN); + _index = strlen(buf); + buf[_index] = ':'; + _index++; + sprintf(&buf[_index], " %d s\n", (int)upload_time); + + strcat(buf, DIALOG_UPLOAD_SPEED_EN); + _index = strlen(buf); + buf[_index] = ':'; + _index++; + sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024)); + + lv_label_set_text(labelDialog, buf); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + + } + } + #endif //USE_WIFI_FUNCTION + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT) { + lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) { + lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat_confirm); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT) { + lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) { + lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat_confirm); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED) { + lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_completed); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED) { + lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_completed); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING) { + lv_label_set_text(labelDialog, filament_menu.filament_dialog_loading); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70); + } + else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING) { + lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading); + lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70); + } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + if (btnOk) lv_group_add_obj(g, btnOk); + if (btnCancel) lv_group_add_obj(g, btnCancel); + } + #endif +} + +void filament_sprayer_temp() { + char buf[20] = {0}; + + public_buf_l[0] = '\0'; + + if (uiCfg.curSprayerChoose < 1) + strcat(public_buf_l, preheat_menu.ext1); + else + strcat(public_buf_l, preheat_menu.ext2); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); + + strcat_P(public_buf_l, PSTR(": ")); + strcat(public_buf_l, buf); + lv_label_set_text(tempText1, public_buf_l); + lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50); +} + +void filament_dialog_handle() { + if ((temperature_change_frequency == 1) + && ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT) + || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT)) + ) { + filament_sprayer_temp(); + temperature_change_frequency = 0; + } + if (uiCfg.filament_heat_completed_load == 1) { + uiCfg.filament_heat_completed_load = 0; + lv_clear_dialog(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOADING); + planner.synchronize(); + uiCfg.filament_loading_time_flg = 1; + uiCfg.filament_loading_time_cnt = 0; + ZERO(public_buf_m); + sprintf_P(public_buf_m,PSTR("T%d\nG91\nG1 E%d F%d\nG90"),uiCfg.curSprayerChoose,gCfgItems.filamentchange_load_length,gCfgItems.filamentchange_load_speed); + queue.inject_P(PSTR(public_buf_m)); + //gcode.process_subcommands_now_P(PSTR(public_buf_m)); + } + if (uiCfg.filament_heat_completed_unload == 1) { + uiCfg.filament_heat_completed_unload = 0; + lv_clear_dialog(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOADING); + planner.synchronize(); + uiCfg.filament_unloading_time_flg = 1; + uiCfg.filament_unloading_time_cnt = 0; + ZERO(public_buf_m); + sprintf_P(public_buf_m,PSTR("T%d\nG91\nG1 E-%d F%d\nG90"),uiCfg.curSprayerChoose,gCfgItems.filamentchange_unload_length,gCfgItems.filamentchange_unload_speed); + queue.inject_P(PSTR(public_buf_m)); + } + + if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1) + || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper)) + && (uiCfg.filament_load_heat_flg == 1) + ) { + uiCfg.filament_load_heat_flg = 0; + lv_clear_dialog(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); + } + + if (uiCfg.filament_loading_completed == 1) { + uiCfg.filament_rate = 0; + uiCfg.filament_loading_completed = 0; + lv_clear_dialog(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED); + } + if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1) + || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper)) + && (uiCfg.filament_unload_heat_flg == 1) + ) { + uiCfg.filament_unload_heat_flg = 0; + lv_clear_dialog(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); + } + + if (uiCfg.filament_unloading_completed == 1) { + uiCfg.filament_rate = 0; + uiCfg.filament_unloading_completed = 0; + lv_clear_dialog(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED); + } + + if ( uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING + || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING + ) lv_filament_setbar(); } -void lv_clear_dialog() { lv_obj_del(scr); } +void lv_filament_setbar() { + lv_bar_set_value(filament_bar, uiCfg.filament_rate, LV_ANIM_ON); +} + +void lv_clear_dialog() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h index f08c7b779ae1..dc5adc5ad64c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h @@ -69,6 +69,8 @@ #define DIALOG_READ_EEPROM_TIPS 33 #define DIALOG_REVERT_EEPROM_TIPS 34 +#define DIALOG_WIFI_CONFIG_TIPS 35 +#define DIALOG_TRANSFER_NO_DEVICE 36 #define BTN_OK_X 100 #define BTN_OK_Y 180 #define BTN_CANCEL_X 280 @@ -76,6 +78,9 @@ extern void lv_draw_dialog(uint8_t type); extern void lv_clear_dialog(); +extern void filament_sprayer_temp(); +extern void filament_dialog_handle(); +extern void lv_filament_setbar(); //extern void disp_temp_ready_print(); #ifdef __cplusplus diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp index f340ca463223..ca7d2d1e31b8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp @@ -28,6 +28,7 @@ #include "../../../../MarlinCore.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_EEPROM_RETURN 1 @@ -48,26 +49,25 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { draw_return_ui(); } break; + case ID_EEPROM_STORE: + if (event == LV_EVENT_CLICKED) { - #if 0 - case ID_EEPROM_STORE: - if (event == LV_EVENT_CLICKED) { - - } - else if (event == LV_EVENT_RELEASED) { - lv_clear_eeprom_settings(); - lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS); - } - break; - case ID_EEPROM_STORE_ARROW: - if (event == LV_EVENT_CLICKED) { + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_eeprom_settings(); + lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS); + } + break; + case ID_EEPROM_STORE_ARROW: + if (event == LV_EVENT_CLICKED) { - } - else if (event == LV_EVENT_RELEASED) { - lv_clear_eeprom_settings(); - lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS); - } - break; + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_eeprom_settings(); + lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS); + } + break; + #if 0 case ID_EEPROM_READ: if (event == LV_EVENT_CLICKED) { @@ -111,10 +111,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { void lv_draw_eeprom_settings(void) { lv_obj_t *buttonBack, *label_Back; - //lv_obj_t *buttonStore,*labelStore,*buttonStoreNarrow; + lv_obj_t *buttonStore,*labelStore,*buttonStoreNarrow; //lv_obj_t *buttonRead,*labelRead,*buttonReadNarrow; lv_obj_t *buttonRevert, *labelRevert, *buttonRevertNarrow; - lv_obj_t * line1; // * line2,* line3; + lv_obj_t * line1, * line2; //* line3; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EEPROM_SETTINGS_UI) { disp_state_stack._disp_index++; disp_state_stack._disp_state[disp_state_stack._disp_index] = EEPROM_SETTINGS_UI; @@ -134,53 +134,6 @@ void lv_draw_eeprom_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - LV_IMG_DECLARE(bmp_para_arrow); - #if 0 - buttonStore = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonStore, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonStore, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - //lv_obj_set_event_cb(buttonMachine, event_handler); - lv_obj_set_event_cb_mks(buttonStore, event_handler, ID_EEPROM_STORE, NULL, 0); - lv_btn_set_style(buttonStore, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonStore, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF); - labelStore = lv_label_create(buttonStore, NULL); /*Add a label to the button*/ - - buttonStoreNarrow = lv_imgbtn_create(scr, NULL); - lv_obj_set_pos(buttonStoreNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonStoreNarrow, event_handler, ID_EEPROM_STORE_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); - lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_btn_set_layout(buttonStoreNarrow, LV_LAYOUT_OFF); - - line1 = lv_line_create(scr, NULL); - lv_ex_line(line1, line_points[0]); - - buttonRead = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonRead, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonRead, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - //lv_obj_set_event_cb(buttonMotor, event_handler); - lv_obj_set_event_cb_mks(buttonRead, event_handler, ID_EEPROM_READ, NULL, 0); - lv_btn_set_style(buttonRead, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonRead, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonRead, LV_LAYOUT_OFF); - labelRead = lv_label_create(buttonRead, NULL); /*Add a label to the button*/ - - buttonReadNarrow = lv_imgbtn_create(scr, NULL); - lv_obj_set_pos(buttonReadNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonReadNarrow, event_handler, ID_EEPROM_READ_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonReadNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonReadNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); - lv_imgbtn_set_style(buttonReadNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonReadNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_btn_set_layout(buttonReadNarrow, LV_LAYOUT_OFF); - - line2 = lv_line_create(scr, NULL); - lv_ex_line(line2, line_points[1]); - #endif // if 0 buttonRevert = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_set_pos(buttonRevert, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ lv_obj_set_size(buttonRevert, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ @@ -193,9 +146,9 @@ void lv_draw_eeprom_settings(void) { buttonRevertNarrow = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonRevertNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonRevertNarrow, event_handler, ID_EEPROM_REVERT_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_event_cb_mks(buttonRevertNarrow, event_handler, ID_EEPROM_REVERT_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonRevertNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonRevertNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonRevertNarrow, LV_LAYOUT_OFF); @@ -205,10 +158,32 @@ void lv_draw_eeprom_settings(void) { line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); + buttonStore = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonStore, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ + lv_obj_set_size(buttonStore, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + //lv_obj_set_event_cb(buttonMotor, event_handler); + lv_obj_set_event_cb_mks(buttonStore, event_handler, ID_EEPROM_STORE, NULL, 0); + lv_btn_set_style(buttonStore, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ + lv_btn_set_style(buttonStore, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF); + labelStore = lv_label_create(buttonStore, NULL); /*Add a label to the button*/ + + buttonStoreNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonStoreNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonStoreNarrow, event_handler, ID_EEPROM_STORE_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonStoreNarrow, LV_LAYOUT_OFF); + + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2, line_points[1]); + buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_EEPROM_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_EEPROM_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); @@ -220,8 +195,8 @@ void lv_draw_eeprom_settings(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); - //lv_label_set_text(labelStore, eeprom_menu.store); - //lv_obj_align(labelStore, buttonStore, LV_ALIGN_IN_LEFT_MID,0, 0); + lv_label_set_text(labelStore, eeprom_menu.store); + lv_obj_align(labelStore, buttonStore, LV_ALIGN_IN_LEFT_MID,0, 0); //lv_label_set_text(labelRead, eeprom_menu.read); //lv_obj_align(labelRead, buttonRead, LV_ALIGN_IN_LEFT_MID,0, 0); @@ -229,9 +204,21 @@ void lv_draw_eeprom_settings(void) { lv_label_set_text(labelRevert, eeprom_menu.revert); lv_obj_align(labelRevert, buttonRevert, LV_ALIGN_IN_LEFT_MID, 0, 0); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonRevert); + lv_group_add_obj(g, buttonStore); + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_eeprom_settings() { lv_obj_del(scr); } +void lv_clear_eeprom_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp new file mode 100644 index 000000000000..0ad2bb5f1ddb --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp @@ -0,0 +1,172 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/planner.h" +#include "../../../../module/stepper/indirection.h" +#include "../../../../feature/tmc_util.h" +#include "../../../../gcode/gcode.h" +#include "../../../../module/planner.h" + +#if BUTTONS_EXIST(EN1, EN2) + +extern lv_group_t * g; +static lv_obj_t * scr; +static lv_obj_t * buttonEncoderState = NULL; +static lv_obj_t *labelEncoderState = NULL; + +#define ID_ENCODER_RETURN 1 +#define ID_ENCODER_STATE 2 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_ENCODER_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_encoder_settings(); + draw_return_ui(); + } + break; + case ID_ENCODER_STATE: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + if (gCfgItems.encoder_enable) { + gCfgItems.encoder_enable = false; + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + lv_label_set_text(labelEncoderState, machine_menu.disable); + update_spi_flash(); + } + else { + gCfgItems.encoder_enable = true; + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + lv_label_set_text(labelEncoderState, machine_menu.enable); + update_spi_flash(); + } + } + break; + } +} + +void lv_draw_encoder_settings(void) { + lv_obj_t *buttonBack = NULL, *label_Back = NULL; + lv_obj_t *labelEncoderTips = NULL; + + lv_obj_t * line1 = NULL; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ENCODER_SETTINGS_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = ENCODER_SETTINGS_UI; + } + disp_state = ENCODER_SETTINGS_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, machine_menu.EncoderConfTitle); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + labelEncoderTips = lv_label_create(scr, NULL); + lv_obj_set_style(labelEncoderTips, &tft_style_label_rel); + lv_obj_set_pos(labelEncoderTips, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelEncoderTips, machine_menu.EncoderConfText); + + buttonEncoderState = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonEncoderState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V); + if (gCfgItems.encoder_enable) { + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + } + else { + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + } + + lv_obj_set_event_cb_mks(buttonEncoderState, event_handler, ID_ENCODER_STATE, NULL, 0); + + lv_imgbtn_set_style(buttonEncoderState, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonEncoderState, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonEncoderState, LV_LAYOUT_OFF); + labelEncoderState = lv_label_create(buttonEncoderState, NULL); + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1, line_points[0]); + + buttonBack = lv_imgbtn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ENCODER_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.encoder_enable) { + lv_label_set_text(labelEncoderState, machine_menu.enable); + lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0); + } + else { + lv_label_set_text(labelEncoderState, machine_menu.disable); + lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0); + } + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonEncoderState); + lv_group_add_obj(g, buttonBack); + } + #endif +} + +void lv_clear_encoder_settings() { + #if HAS_ROTARY_ENCODER + lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // BUTTONS_EXIST(EN1, EN2) + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h new file mode 100644 index 000000000000..62892a6ec142 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_encoder_settings(void); +extern void lv_clear_encoder_settings(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index 9f5977d70c70..543202067f59 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -35,10 +35,11 @@ #include "../../../../gcode/queue.h" static lv_obj_t * scr; +extern lv_group_t* g; static lv_obj_t * buttoType, *buttonStep, *buttonSpeed; -static lv_obj_t * labelType; -static lv_obj_t * labelStep; -static lv_obj_t * labelSpeed; +static lv_obj_t *labelType; +static lv_obj_t *labelStep; +static lv_obj_t *labelSpeed; static lv_obj_t * tempText; static lv_obj_t * ExtruText; @@ -171,8 +172,6 @@ void lv_draw_extrusion(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - // Create image buttons buttonAdd = lv_imgbtn_create(scr, NULL); buttonDec = lv_imgbtn_create(scr, NULL); @@ -181,37 +180,35 @@ void lv_draw_extrusion(void) { buttonSpeed = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_E_ADD, "bmp_in.bin", 0); - lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_E_ADD, NULL, 0); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_in.bin"); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_in.bin"); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel); lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); + #if 1 - lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_E_DEC, "bmp_out.bin", 0); - lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_E_DEC, NULL, 0); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_out.bin"); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_out.bin"); lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, NULL, 0); lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, NULL, 0); lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, NULL, 0); lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_E_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_E_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); #endif @@ -249,6 +246,17 @@ void lv_draw_extrusion(void) { lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonAdd); + lv_group_add_obj(g, buttonDec); + lv_group_add_obj(g, buttoType); + lv_group_add_obj(g, buttonStep); + lv_group_add_obj(g, buttonSpeed); + lv_group_add_obj(g, buttonBack); + } + #endif + disp_ext_type(); disp_ext_step(); disp_ext_speed(); @@ -264,14 +272,16 @@ void lv_draw_extrusion(void) { void disp_ext_type() { if (uiCfg.curSprayerChoose == 1) { - lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, "bmp_extru2.bin", 0); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin"); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin"); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelType, extrude_menu.ext2); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } } else { - lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, "bmp_extru1.bin", 0); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin"); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin"); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelType, extrude_menu.ext1); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -280,12 +290,18 @@ void disp_ext_type() { } void disp_ext_speed() { - if (uiCfg.extruSpeed == 20) - lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_high.bin", 0); - else if (uiCfg.extruSpeed == 1) - lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_slow.bin", 0); - else - lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_normal.bin", 0); + if (uiCfg.extruSpeed == 20) { + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_high.bin"); + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_high.bin"); + } + else if (uiCfg.extruSpeed == 1) { + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_slow.bin"); + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_slow.bin"); + } + else { + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_normal.bin"); + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_normal.bin"); + } if (gCfgItems.multiple_language != 0) { if (uiCfg.extruSpeed == 20) { @@ -348,12 +364,18 @@ void disp_extru_amount() { } void disp_ext_step() { - if (uiCfg.extruStep == 1) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step1_mm.bin", 0); - else if (uiCfg.extruStep == 5) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step5_mm.bin", 0); - else if (uiCfg.extruStep == 10) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step10_mm.bin", 0); + if (uiCfg.extruStep == 1) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_mm.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_mm.bin"); + } + else if (uiCfg.extruStep == 5) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_mm.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_mm.bin"); + } + else if (uiCfg.extruStep == 10) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_mm.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_mm.bin"); + } if (gCfgItems.multiple_language != 0) { if (uiCfg.extruStep == 1) { @@ -371,6 +393,11 @@ void disp_ext_step() { } } -void lv_clear_extrusion() { lv_obj_del(scr); } +void lv_clear_extrusion() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp index e1975aca7e9c..8cdc14964f4b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp @@ -35,6 +35,7 @@ #include "../../../../gcode/queue.h" #include "../../../../gcode/gcode.h" +extern lv_group_t * g; static lv_obj_t * scr; static lv_obj_t * fanText; @@ -138,8 +139,6 @@ void lv_draw_fan(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - // Create an Image button buttonAdd = lv_imgbtn_create(scr, NULL); buttonDec = lv_imgbtn_create(scr, NULL); @@ -148,41 +147,41 @@ void lv_draw_fan(void) { buttonOff = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_F_ADD, "bmp_Add.bin", 0); - lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_F_ADD, NULL, 0); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin"); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin"); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel); lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); #if 1 - lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_F_DEC, "bmp_Dec.bin", 0); - lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_F_DEC, NULL, 0); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin"); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin"); lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonHigh, event_handler,ID_F_HIGH,"bmp_speed255.bin",0); - lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonHigh, event_handler,ID_F_HIGH, NULL,0); + lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_REL, "F:/bmp_speed255.bin"); + lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_PR, "F:/bmp_speed255.bin"); lv_imgbtn_set_style(buttonHigh, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonHigh, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonMid, event_handler,ID_F_MID,"bmp_speed127.bin",0); - lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonMid, event_handler,ID_F_MID, NULL,0); + lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_REL, "F:/bmp_speed127.bin"); + lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_PR, "F:/bmp_speed127.bin"); lv_imgbtn_set_style(buttonMid, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonMid, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonOff, event_handler,ID_F_OFF,"bmp_speed0.bin",0); - lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonOff, event_handler,ID_F_OFF, NULL,0); + lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, "F:/bmp_speed0.bin"); + lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, "F:/bmp_speed0.bin"); lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_F_RETURN,"bmp_return.bin",0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_F_RETURN, NULL,0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); @@ -229,6 +228,16 @@ void lv_draw_fan(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonAdd); + lv_group_add_obj(g, buttonDec); + lv_group_add_obj(g, buttonHigh); + lv_group_add_obj(g, buttonMid); + lv_group_add_obj(g, buttonOff); + lv_group_add_obj(g, buttonBack); + } + #endif fanText = lv_label_create(scr, NULL); lv_obj_set_style(fanText, &tft_style_label_rel); @@ -246,6 +255,11 @@ void disp_fan_value() { lv_obj_align(fanText, NULL, LV_ALIGN_CENTER, 0, -65); } -void lv_clear_fan() { lv_obj_del(scr); } +void lv_clear_fan() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp new file mode 100644 index 000000000000..83f9e536774d --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -0,0 +1,270 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" +#include "../../../../gcode/queue.h" +#include "../../../../gcode/gcode.h" +#include "../../../../module/motion.h" +#include "../../../../module/planner.h" + +extern lv_group_t * g; +static lv_obj_t * scr; +static lv_obj_t *buttoType; +static lv_obj_t *labelType; +static lv_obj_t * tempText1; + +#define ID_FILAMNT_IN 1 +#define ID_FILAMNT_OUT 2 +#define ID_FILAMNT_TYPE 3 +#define ID_FILAMNT_RETURN 4 + +extern feedRate_t feedrate_mm_s; + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_FILAMNT_IN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.filament_load_heat_flg = 1; + if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1) + || (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) { + lv_clear_filament_change(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); + } + else { + lv_clear_filament_change(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT); + if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper; + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + } + } + } + break; + case ID_FILAMNT_OUT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.filament_unload_heat_flg=1; + if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0) + && ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1) + || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper)) + ) { + lv_clear_filament_change(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); + } + else { + lv_clear_filament_change(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT); + if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) { + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper; + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + } + filament_sprayer_temp(); + } + } + break; + case ID_FILAMNT_TYPE: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + #if HAS_MULTI_EXTRUDER + if (uiCfg.curSprayerChoose == 0) + uiCfg.curSprayerChoose = 1; + else if (uiCfg.curSprayerChoose == 1) + uiCfg.curSprayerChoose = 0; + #endif + disp_filament_type(); + } + break; + case ID_FILAMNT_RETURN: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + #if HAS_MULTI_EXTRUDER + if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED) + gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0")); + #endif + feedrate_mm_s = (float)uiCfg.moveSpeed_bak; + if (uiCfg.print_state == PAUSED) + planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak)); + //current_position.e = destination.e = uiCfg.current_e_position_bak; + thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak; + + clear_cur_ui(); + draw_return_ui(); + } + break; + } +} + +void lv_draw_filament_change(void) { + lv_obj_t *buttonIn, *buttonOut; + lv_obj_t *buttonBack; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENTCHANGE_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENTCHANGE_UI; + } + disp_state = FILAMENTCHANGE_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + // Create an Image button + buttonIn = lv_imgbtn_create(scr, NULL); + buttonOut = lv_imgbtn_create(scr, NULL); + buttoType = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonIn, event_handler, ID_FILAMNT_IN, NULL, 0); + lv_imgbtn_set_src(buttonIn, LV_BTN_STATE_REL, "F:/bmp_in.bin"); + lv_imgbtn_set_src(buttonIn, LV_BTN_STATE_PR, "F:/bmp_in.bin"); + lv_imgbtn_set_style(buttonIn, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonIn, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW); + + lv_obj_set_event_cb_mks(buttonOut, event_handler, ID_FILAMNT_OUT, NULL, 0); + lv_imgbtn_set_src(buttonOut, LV_BTN_STATE_REL, "F:/bmp_out.bin"); + lv_imgbtn_set_src(buttonOut, LV_BTN_STATE_PR, "F:/bmp_out.bin"); + lv_imgbtn_set_style(buttonOut, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonOut, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttoType, event_handler, ID_FILAMNT_TYPE, NULL, 0); + lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FILAMNT_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_pos(buttonIn, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonOut, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttoType, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + + // Create labels on the image buttons + lv_btn_set_layout(buttonIn, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonOut, LV_LAYOUT_OFF); + lv_btn_set_layout(buttoType, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + lv_obj_t *labelIn = lv_label_create(buttonIn, NULL); + lv_obj_t *labelOut = lv_label_create(buttonOut, NULL); + labelType = lv_label_create(buttoType, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelIn, filament_menu.in); + lv_obj_align(labelIn, buttonIn, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(labelOut, filament_menu.out); + lv_obj_align(labelOut, buttonOut, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonIn); + lv_group_add_obj(g, buttonOut); + lv_group_add_obj(g, buttoType); + lv_group_add_obj(g, buttonBack); + } + #endif + + disp_filament_type(); + + tempText1 = lv_label_create(scr, NULL); + lv_obj_set_style(tempText1, &tft_style_label_rel); + disp_filament_temp(); +} + +void disp_filament_type() { + if (uiCfg.curSprayerChoose == 1) { + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin"); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin"); + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelType, preheat_menu.ext2); + lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } + else { + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin"); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin"); + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelType, preheat_menu.ext1); + lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void disp_filament_temp() { + char buf[20] = {0}; + + public_buf_l[0] = '\0'; + + if (uiCfg.curSprayerChoose < 1) + strcat(public_buf_l, preheat_menu.ext1); + else + strcat(public_buf_l, preheat_menu.ext2); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); + + strcat_P(public_buf_l, PSTR(": ")); + strcat(public_buf_l, buf); + lv_label_set_text(tempText1, public_buf_l); + lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50); +} + +void lv_clear_filament_change() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h new file mode 100644 index 000000000000..b0068f7f0f32 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h @@ -0,0 +1,36 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_filament_change(void); +extern void lv_clear_filament_change(); +extern void disp_filament_type(); +extern void disp_filament_temp(); + +//extern void disp_temp_ready_print(); +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp new file mode 100644 index 000000000000..06ab35f3f0e5 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp @@ -0,0 +1,329 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/planner.h" + +extern lv_group_t * g; +static lv_obj_t * scr; + +#define ID_FILAMENT_SET_RETURN 1 +#define ID_FILAMENT_SET_IN_LENGTH 2 +#define ID_FILAMENT_SET_IN_SPEED 3 +#define ID_FILAMENT_SET_OUT_LENGTH 4 +#define ID_FILAMENT_SET_OUT_SPEED 5 +#define ID_FILAMENT_SET_TEMP 6 +#define ID_FILAMENT_SET_DOWN 12 +#define ID_FILAMENT_SET_UP 13 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_FILAMENT_SET_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.para_ui_page = 0; + lv_clear_filament_settings(); + draw_return_ui(); + } + break; + case ID_FILAMENT_SET_IN_LENGTH: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = load_length; + lv_clear_filament_settings(); + lv_draw_number_key(); + } + break; + case ID_FILAMENT_SET_IN_SPEED: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = load_speed; + lv_clear_filament_settings(); + lv_draw_number_key(); + } + break; + case ID_FILAMENT_SET_OUT_LENGTH: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = unload_length; + lv_clear_filament_settings(); + lv_draw_number_key(); + } + break; + case ID_FILAMENT_SET_OUT_SPEED: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = unload_speed; + lv_clear_filament_settings(); + lv_draw_number_key(); + } + break; + case ID_FILAMENT_SET_TEMP: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = filament_temp; + lv_clear_filament_settings(); + lv_draw_number_key(); + } + break; + case ID_FILAMENT_SET_UP: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.para_ui_page = 0; + lv_clear_filament_settings(); + lv_draw_filament_settings(); + } + break; + case ID_FILAMENT_SET_DOWN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.para_ui_page = 1; + lv_clear_filament_settings(); + lv_draw_filament_settings(); + } + break; + } +} + +void lv_draw_filament_settings(void) { + lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL; + lv_obj_t *labelInLengthText = NULL, *buttonInLengthValue = NULL, *labelInLengthValue = NULL; + lv_obj_t *labelInSpeedText = NULL, *buttonInSpeedValue = NULL, *labelInSpeedValue = NULL; + lv_obj_t *labelOutLengthText = NULL, *buttonOutLengthValue = NULL, *labelOutLengthValue = NULL; + lv_obj_t *labelOutSpeedText = NULL, *buttonOutSpeedValue = NULL, *labelOutSpeedValue = NULL; + lv_obj_t *labelTemperText = NULL, *buttonTemperValue = NULL, *labelTemperValue = NULL; + lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENT_SETTINGS_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENT_SETTINGS_UI; + } + disp_state = FILAMENT_SETTINGS_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, machine_menu.FilamentConfTitle); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + if (uiCfg.para_ui_page != 1) { + labelInLengthText = lv_label_create(scr, NULL); + lv_obj_set_style(labelInLengthText, &tft_style_label_rel); + lv_obj_set_pos(labelInLengthText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelInLengthText, machine_menu.InLength); + + buttonInLengthValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonInLengthValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonInLengthValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonInLengthValue, event_handler, ID_FILAMENT_SET_IN_LENGTH, NULL, 0); + lv_btn_set_style(buttonInLengthValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonInLengthValue, LV_BTN_STYLE_PR, &style_para_value); + labelInLengthValue = lv_label_create(buttonInLengthValue, NULL); + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1, line_points[0]); + + labelInSpeedText = lv_label_create(scr, NULL); + lv_obj_set_style(labelInSpeedText, &tft_style_label_rel); + lv_obj_set_pos(labelInSpeedText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelInSpeedText, machine_menu.InSpeed); + + buttonInSpeedValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonInSpeedValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonInSpeedValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonInSpeedValue, event_handler, ID_FILAMENT_SET_IN_SPEED, NULL, 0); + lv_btn_set_style(buttonInSpeedValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonInSpeedValue, LV_BTN_STYLE_PR, &style_para_value); + labelInSpeedValue = lv_label_create(buttonInSpeedValue, NULL); + + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2, line_points[1]); + + labelOutLengthText = lv_label_create(scr, NULL); + lv_obj_set_style(labelOutLengthText, &tft_style_label_rel); + lv_obj_set_pos(labelOutLengthText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 6); + lv_label_set_text(labelOutLengthText, machine_menu.OutLength); + + buttonOutLengthValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonOutLengthValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonOutLengthValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonOutLengthValue, event_handler, ID_FILAMENT_SET_OUT_LENGTH, NULL, 0); + lv_btn_set_style(buttonOutLengthValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonOutLengthValue, LV_BTN_STYLE_PR, &style_para_value); + labelOutLengthValue = lv_label_create(buttonOutLengthValue, NULL); + + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3, line_points[2]); + + labelOutSpeedText = lv_label_create(scr, NULL); + lv_obj_set_style(labelOutSpeedText, &tft_style_label_rel); + lv_obj_set_pos(labelOutSpeedText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelOutSpeedText, machine_menu.OutSpeed); + + buttonOutSpeedValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonOutSpeedValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonOutSpeedValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonOutSpeedValue, event_handler, ID_FILAMENT_SET_OUT_SPEED, NULL, 0); + lv_btn_set_style(buttonOutSpeedValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonOutSpeedValue, LV_BTN_STYLE_PR, &style_para_value); + labelOutSpeedValue = lv_label_create(buttonOutSpeedValue, NULL); + + line4 = lv_line_create(scr, NULL); + lv_ex_line(line4, line_points[3]); + + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FILAMENT_SET_DOWN, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonInLengthValue); + lv_group_add_obj(g, buttonInSpeedValue); + lv_group_add_obj(g, buttonOutLengthValue); + lv_group_add_obj(g, buttonOutSpeedValue); + lv_group_add_obj(g, buttonTurnPage); + } + #endif + } + else { + labelTemperText = lv_label_create(scr, NULL); + lv_obj_set_style(labelTemperText, &tft_style_label_rel); + lv_obj_set_pos(labelTemperText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelTemperText, machine_menu.FilamentTemperature); + + buttonTemperValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonTemperValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonTemperValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonTemperValue, event_handler, ID_FILAMENT_SET_TEMP, NULL, 0); + lv_btn_set_style(buttonTemperValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonTemperValue, LV_BTN_STYLE_PR, &style_para_value); + labelTemperValue = lv_label_create(buttonTemperValue, NULL); + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1, line_points[0]); + + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FILAMENT_SET_UP, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonTemperValue); + lv_group_add_obj(g, buttonTurnPage); + } + #endif + } + + lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); + lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + labelTurnPage = lv_label_create(buttonTurnPage, NULL); + + buttonBack = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FILAMENT_SET_RETURN, NULL, 0); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + label_Back = lv_label_create(buttonBack, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + + if (gCfgItems.multiple_language != 0) { + if (uiCfg.para_ui_page != 1) { + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length); + lv_label_set_text(labelInLengthValue, public_buf_l); + lv_obj_align(labelInLengthValue, buttonInLengthValue, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_speed); + lv_label_set_text(labelInSpeedValue, public_buf_l); + lv_obj_align(labelInSpeedValue, buttonInSpeedValue, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_length); + lv_label_set_text(labelOutLengthValue, public_buf_l); + lv_obj_align(labelOutLengthValue, buttonOutLengthValue, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_speed); + lv_label_set_text(labelOutSpeedValue, public_buf_l); + lv_obj_align(labelOutSpeedValue, buttonOutSpeedValue, LV_ALIGN_CENTER, 0, 0); + + lv_label_set_text(labelTurnPage, machine_menu.next); + lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); + } + else { + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper); + lv_label_set_text(labelTemperValue, public_buf_l); + lv_obj_align(labelTemperValue, buttonTemperValue, LV_ALIGN_CENTER, 0, 0); + + lv_label_set_text(labelTurnPage, machine_menu.previous); + lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); + } + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); + } +} + +void lv_clear_filament_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h new file mode 100644 index 000000000000..a5ae54289534 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_filament_settings(void); +extern void lv_clear_filament_settings(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp index 595d1078c76a..22e05f0e00e5 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp @@ -34,6 +34,7 @@ #include "draw_ui.h" #include "../../../../gcode/queue.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_H_ALL 1 @@ -92,7 +93,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { if (event == LV_EVENT_CLICKED) { } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_home(); lv_draw_tool(); } break; @@ -125,128 +126,93 @@ void lv_draw_home(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - - /*Create an Image button*/ - //buttonWifi = lv_imgbtn_create(scr, NULL); - buttonHomeAll = lv_imgbtn_create(scr, NULL); - buttonHomeX = lv_imgbtn_create(scr, NULL); + // Create image buttons + //buttonWifi = lv_imgbtn_create(scr, NULL); + buttonHomeAll = lv_imgbtn_create(scr, NULL); + buttonHomeX = lv_imgbtn_create(scr, NULL); //buttonContinue = lv_imgbtn_create(scr, NULL); - buttonHomeY = lv_imgbtn_create(scr, NULL); - buttonHomeZ = lv_imgbtn_create(scr, NULL); - buttonBack = lv_imgbtn_create(scr, NULL); - buttonOffAll = lv_imgbtn_create(scr, NULL); - buttonOffXY = lv_imgbtn_create(scr, NULL); - - //lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,"bmp_Wifi.bin",0); - //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, &bmp_pic); - //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, &bmp_pic); - //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre); - //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel); - //lv_obj_clear_protect(buttonWifi, LV_PROTECT_FOLLOW); + buttonHomeY = lv_imgbtn_create(scr, NULL); + buttonHomeZ = lv_imgbtn_create(scr, NULL); + buttonOffAll = lv_imgbtn_create(scr, NULL); + buttonOffXY = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + #if 1 - lv_obj_set_event_cb_mks(buttonHomeAll, event_handler,ID_H_ALL,"bmp_zero.bin",0); - lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonHomeAll, event_handler,ID_H_ALL, NULL,0); + lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_REL, "F:/bmp_zeroAll.bin"); + lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_PR, "F:/bmp_zeroAll.bin"); lv_imgbtn_set_style(buttonHomeAll, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonHomeAll, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonHomeX, event_handler, ID_H_X, "bmp_zeroX.bin", 0); - lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonHomeX, event_handler, ID_H_X, NULL, 0); + lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_REL, "F:/bmp_zeroX.bin"); + lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_PR, "F:/bmp_zeroX.bin"); lv_imgbtn_set_style(buttonHomeX, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonHomeX, LV_BTN_STATE_REL, &tft_style_label_rel); - //lv_obj_set_event_cb_mks(buttonContinue, event_handler,ID_S_CONTINUE,"bmp_Breakpoint.bin",0); - //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_REL, &bmp_pic); - //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_PR, &bmp_pic); - //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_label_pre); - //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonHomeY, event_handler, ID_H_Y, "bmp_zeroY.bin", 0); - lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonHomeY, event_handler, ID_H_Y, NULL, 0); + lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_REL, "F:/bmp_zeroY.bin"); + lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_PR, "F:/bmp_zeroY.bin"); lv_imgbtn_set_style(buttonHomeY, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonHomeY, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonHomeZ, event_handler, ID_H_Z, "bmp_zeroZ.bin", 0); - lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonHomeZ, event_handler, ID_H_Z, NULL, 0); + lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_REL, "F:/bmp_zeroZ.bin"); + lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_PR, "F:/bmp_zeroZ.bin"); lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonOffAll, event_handler,ID_H_OFF_ALL,"bmp_function1.bin",0); - lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonOffAll, event_handler,ID_H_OFF_ALL, NULL,0); + lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, "F:/bmp_function1.bin"); + lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, "F:/bmp_function1.bin"); lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonOffXY, event_handler,ID_H_OFF_XY,"bmp_function1.bin",0); - lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonOffXY, event_handler,ID_H_OFF_XY, NULL,0); + lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, "F:/bmp_function1.bin"); + lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, "F:/bmp_function1.bin"); lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_H_RETURN,"bmp_return.bin",0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_H_RETURN, NULL,0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); #endif - /*lv_obj_set_pos(buttonWifi, INTERVAL_V, titleHeight); - lv_obj_set_pos(buttonFan, BTN_X_PIXEL+INTERVAL_V*2, titleHeight); - lv_obj_set_pos(buttonAbout, BTN_X_PIXEL*2+INTERVAL_V*3, titleHeight); - lv_obj_set_pos(buttonContinue, BTN_X_PIXEL*3+INTERVAL_V*4, titleHeight); - lv_obj_set_pos(buMotorOff, INTERVAL_V, BTN_Y_PIXEL+INTERVAL_H+titleHeight); - lv_obj_set_pos(buttonLanguage, BTN_X_PIXEL+INTERVAL_V*2, BTN_Y_PIXEL+INTERVAL_H+titleHeight); - lv_obj_set_pos(buttonBack, BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);*/ - - //lv_obj_set_pos(buttonWifi, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonHomeAll, INTERVAL_V, titleHeight); lv_obj_set_pos(buttonHomeX, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); lv_obj_set_pos(buttonHomeY, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); - //lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight); lv_obj_set_pos(buttonHomeZ, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); - lv_obj_set_pos(buttonHomeAll, INTERVAL_V, titleHeight); lv_obj_set_pos(buttonOffAll, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonOffXY, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ - //lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF); + // Create labels on the image buttons lv_btn_set_layout(buttonHomeAll, LV_LAYOUT_OFF); lv_btn_set_layout(buttonHomeX, LV_LAYOUT_OFF); - //lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF); lv_btn_set_layout(buttonHomeY, LV_LAYOUT_OFF); lv_btn_set_layout(buttonHomeZ, LV_LAYOUT_OFF); lv_btn_set_layout(buttonOffAll, LV_LAYOUT_OFF); lv_btn_set_layout(buttonOffXY, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - //lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL); - lv_obj_t * labelHomeAll = lv_label_create(buttonHomeAll, NULL); - lv_obj_t * labelHomeX = lv_label_create(buttonHomeX, NULL); - //lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL); - lv_obj_t * labelHomeY = lv_label_create(buttonHomeY, NULL); - lv_obj_t * labelHomeZ = lv_label_create(buttonHomeZ, NULL); - lv_obj_t * labelOffAll = lv_label_create(buttonOffAll, NULL); - lv_obj_t * labelOffXY = lv_label_create(buttonOffXY, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); - + lv_obj_t *labelHomeAll = lv_label_create(buttonHomeAll, NULL); + lv_obj_t *labelHomeX = lv_label_create(buttonHomeX, NULL); + lv_obj_t *labelHomeY = lv_label_create(buttonHomeY, NULL); + lv_obj_t *labelHomeZ = lv_label_create(buttonHomeZ, NULL); + lv_obj_t *labelOffAll = lv_label_create(buttonOffAll, NULL); + lv_obj_t *labelOffXY = lv_label_create(buttonOffXY, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { - //lv_label_set_text(labelWifi, set_menu.wifi); - //lv_obj_align(labelWifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); - lv_label_set_text(labelHomeAll, home_menu.home_all); lv_obj_align(labelHomeAll, buttonHomeAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_label_set_text(labelHomeX, home_menu.home_x); lv_obj_align(labelHomeX, buttonHomeX, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - //lv_label_set_text(label_Continue, set_menu.breakpoint); - //lv_obj_align(label_Continue, buttonContinue, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); - lv_label_set_text(labelHomeY, home_menu.home_y); lv_obj_align(labelHomeY, buttonHomeY, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -262,8 +228,25 @@ void lv_draw_home(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonHomeAll); + lv_group_add_obj(g, buttonHomeX); + lv_group_add_obj(g, buttonHomeY); + lv_group_add_obj(g, buttonHomeZ); + lv_group_add_obj(g, buttonOffAll); + lv_group_add_obj(g, buttonOffXY); + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_home() { lv_obj_del(scr); } +void lv_clear_home() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp new file mode 100644 index 000000000000..d22eeb157e18 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp @@ -0,0 +1,262 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/planner.h" +#include "../../../../module/probe.h" + +#if USE_SENSORLESS +#include "../../../../module/stepper/indirection.h" +#include "../../../../feature/tmc_util.h" + +extern lv_group_t * g; +static lv_obj_t * scr; + +#define ID_SENSITIVITY_RETURN 1 +#define ID_SENSITIVITY_X 2 +#define ID_SENSITIVITY_Y 3 +#define ID_SENSITIVITY_Z 4 +#define ID_SENSITIVITY_Z2 5 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_SENSITIVITY_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_homing_sensitivity_settings(); + draw_return_ui(); + } + break; + case ID_SENSITIVITY_X: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = x_sensitivity; + lv_clear_homing_sensitivity_settings(); + lv_draw_number_key(); + } + break; + case ID_SENSITIVITY_Y: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = y_sensitivity; + lv_clear_homing_sensitivity_settings(); + lv_draw_number_key(); + } + break; + case ID_SENSITIVITY_Z: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = z_sensitivity; + lv_clear_homing_sensitivity_settings(); + lv_draw_number_key(); + } + break; + #if Z2_SENSORLESS + case ID_SENSITIVITY_Z2: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = z2_sensitivity; + lv_clear_homing_sensitivity_settings(); + lv_draw_number_key(); + } + break; + #endif + } +} + +void lv_draw_homing_sensitivity_settings(void) { + lv_obj_t *buttonBack = NULL, *label_Back = NULL; + lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; + lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; + lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; + lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL; + #if Z2_SENSORLESS + lv_obj_t *labelZ2Text = NULL, *buttonZ2Value = NULL, *labelZ2Value = NULL; + lv_obj_t * line4 = NULL; + #endif + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != HOMING_SENSITIVITY_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = HOMING_SENSITIVITY_UI; + } + disp_state = HOMING_SENSITIVITY_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, machine_menu.HomingSensitivityConfTitle); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + labelXText = lv_label_create(scr, NULL); + lv_obj_set_style(labelXText, &tft_style_label_rel); + lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelXText, machine_menu.X_Sensitivity); + + buttonXValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_SENSITIVITY_X, NULL, 0); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); + labelXValue = lv_label_create(buttonXValue, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXValue); + #endif + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1, line_points[0]); + + labelYText = lv_label_create(scr, NULL); + lv_obj_set_style(labelYText, &tft_style_label_rel); + lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelYText, machine_menu.Y_Sensitivity); + + buttonYValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_SENSITIVITY_Y, NULL, 0); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); + labelYValue = lv_label_create(buttonYValue, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYValue); + #endif + + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2, line_points[1]); + + labelZText = lv_label_create(scr, NULL); + lv_obj_set_style(labelZText, &tft_style_label_rel); + lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelZText, machine_menu.Z_Sensitivity); + + buttonZValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_SENSITIVITY_Z, NULL, 0); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); + labelZValue = lv_label_create(buttonZValue, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable == true) lv_group_add_obj(g, buttonZValue); + #endif + + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3, line_points[2]); + + #if Z2_SENSORLESS + labelZ2Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelZ2Text, &tft_style_label_rel); + lv_obj_set_pos(labelZ2Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelZ2Text, machine_menu.Z2_Sensitivity); + + buttonZ2Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonZ2Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonZ2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonZ2Value, event_handler, ID_SENSITIVITY_Z2, NULL, 0); + lv_btn_set_style(buttonZ2Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZ2Value, LV_BTN_STYLE_PR, &style_para_value); + labelZ2Value = lv_label_create(buttonZ2Value, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZ2Value); + #endif + + line4 = lv_line_create(scr, NULL); + lv_ex_line(line4, line_points[3]); + #endif + + buttonBack = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_SENSITIVITY_RETURN, NULL, 0); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + label_Back = lv_label_create(buttonBack, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + + if (gCfgItems.multiple_language != 0) { + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0)); + lv_label_set_text(labelXValue, public_buf_l); + lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0)); + lv_label_set_text(labelYValue, public_buf_l); + lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0)); + lv_label_set_text(labelZValue, public_buf_l); + lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0); + + #if Z2_SENSORLESS + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0)); + lv_label_set_text(labelZ2Value, public_buf_l); + lv_obj_align(labelZ2Value, buttonZ2Value, LV_ALIGN_CENTER, 0, 0); + #endif + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); + } +} + +void lv_clear_homing_sensitivity_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // USE_SENSORLESS + +#endif // HAS_TFT_LVGL_UI && USE_SENSORLESS diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h new file mode 100644 index 000000000000..0c554702b1c6 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_homing_sensitivity_settings(void); +extern void lv_clear_homing_sensitivity_settings(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp index a552762cf3eb..8c359233e6ea 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp @@ -29,6 +29,7 @@ #include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_JERK_RETURN 1 @@ -93,10 +94,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { void lv_draw_jerk_settings(void) { lv_obj_t *buttonBack = NULL, *label_Back = NULL; - lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; - lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; - lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; - lv_obj_t *buttonEText = NULL, *labelEText = NULL, *buttonEValue = NULL, *labelEValue = NULL; + lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; + lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; + lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; + lv_obj_t *labelEText = NULL, *buttonEValue = NULL, *labelEValue = NULL; lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != JERK_UI) { disp_state_stack._disp_index++; @@ -117,109 +118,89 @@ void lv_draw_jerk_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - // LV_IMG_DECLARE(bmp_para_arrow); - LV_IMG_DECLARE(bmp_para_bank); + labelXText = lv_label_create(scr, NULL); + lv_obj_set_style(labelXText, &tft_style_label_rel); + lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelXText, machine_menu.X_Jerk); - buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonXText, event_handler); - lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF); - labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/ - - buttonXValue = lv_imgbtn_create(scr, NULL); + buttonXValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_JERK_X, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_JERK_X, NULL, 0); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); labelXValue = lv_label_create(buttonXValue, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonYText, event_handler); - lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF); - labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/ + labelYText = lv_label_create(scr, NULL); + lv_obj_set_style(labelYText, &tft_style_label_rel); + lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelYText, machine_menu.Y_Jerk); - buttonYValue = lv_imgbtn_create(scr, NULL); + buttonYValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_JERK_Y, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_JERK_Y, NULL, 0); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); labelYValue = lv_label_create(buttonYValue, NULL); line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); - buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ - lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonZText, event_handler); - lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF); - labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/ + labelZText = lv_label_create(scr, NULL); + lv_obj_set_style(labelZText, &tft_style_label_rel); + lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelZText, machine_menu.Z_Jerk); - buttonZValue = lv_imgbtn_create(scr, NULL); + buttonZValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_JERK_Z, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_JERK_Z, NULL, 0); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); labelZValue = lv_label_create(buttonZValue, NULL); line3 = lv_line_create(scr, NULL); lv_ex_line(line3, line_points[2]); - buttonEText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonEText, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/ - lv_obj_set_size(buttonEText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonEText, event_handler); - lv_btn_set_style(buttonEText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonEText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonEText, LV_LAYOUT_OFF); - labelEText = lv_label_create(buttonEText, NULL); /*Add a label to the button*/ + labelEText = lv_label_create(scr, NULL); + lv_obj_set_style(labelEText, &tft_style_label_rel); + lv_obj_set_pos(labelEText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelEText, machine_menu.E_Jerk); - buttonEValue = lv_imgbtn_create(scr, NULL); + buttonEValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonEValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonEValue, event_handler, ID_JERK_E, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonEValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonEValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonEValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonEValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonEValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonEValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonEValue, event_handler, ID_JERK_E, NULL, 0); + lv_btn_set_style(buttonEValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonEValue, LV_BTN_STYLE_PR, &style_para_value); labelEValue = lv_label_create(buttonEValue, NULL); line4 = lv_line_create(scr, NULL); lv_ex_line(line4, line_points[3]); - buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_JERK_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + buttonBack = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_JERK_RETURN, NULL, 0); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); - lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); label_Back = lv_label_create(buttonBack, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable == true) { + lv_group_add_obj(g, buttonXValue); + lv_group_add_obj(g, buttonYValue); + lv_group_add_obj(g, buttonZValue); + lv_group_add_obj(g, buttonEValue); + lv_group_add_obj(g, buttonBack); + } + #endif + if (gCfgItems.multiple_language != 0) { ZERO(public_buf_l); sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]); @@ -241,23 +222,16 @@ void lv_draw_jerk_settings(void) { lv_label_set_text(labelEValue, public_buf_l); lv_obj_align(labelEValue, buttonEValue, LV_ALIGN_CENTER, 0, 0); - lv_label_set_text(labelXText, machine_menu.X_Jerk); - lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelYText, machine_menu.Y_Jerk); - lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelZText, machine_menu.Z_Jerk); - lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelEText, machine_menu.E_Jerk); - lv_obj_align(labelEText, buttonEText, LV_ALIGN_IN_LEFT_MID, 0, 0); - lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); } } -void lv_clear_jerk_settings() { lv_obj_del(scr); } +void lv_clear_jerk_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI && HAS_CLASSIC_JERK diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp new file mode 100644 index 000000000000..f126ffe1dd42 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp @@ -0,0 +1,286 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../../Configuration.h" +#include "../../../../MarlinCore.h" + +extern lv_group_t * g; +static lv_obj_t * scr; + +#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG) + +static const char * kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n", + "ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", LV_SYMBOL_NEW_LINE, "\n", + "_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n", + LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""}; + +static const lv_btnm_ctrl_t kb_ctrl_lc_map[] = { + LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, + LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2}; + +static const char * kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n", + "abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", LV_SYMBOL_NEW_LINE, "\n", + "_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n", + LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""}; + +static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = { + LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, + LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2}; + +static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n", + "abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n", + "\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n", + LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""}; + +static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2, + LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2}; + +static const lv_btnm_ctrl_t kb_ctrl_num_map[] = { + 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2, + 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2, + 1, 1, 1, 2, + 1, 1, 1, 1, 1}; + +static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) { + //LV_ASSERT_OBJ(kb, LV_OBJX_NAME); + + if (event != LV_EVENT_VALUE_CHANGED) return; + + lv_kb_ext_t * ext = (lv_kb_ext_t * )lv_obj_get_ext_attr(kb); + const uint16_t btn_id = lv_btnm_get_active_btn(kb); + if (btn_id == LV_BTNM_BTN_NONE) return; + if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_HIDDEN | LV_BTNM_CTRL_INACTIVE)) return; + if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return; + + const char * txt = lv_btnm_get_active_btn_text(kb); + if (txt == NULL) return; + + // Do the corresponding action according to the text of the button + if (strcmp(txt, "abc") == 0) { + lv_btnm_set_map(kb, kb_map_lc); + lv_btnm_set_ctrl_map(kb, kb_ctrl_lc_map); + return; + } + else if (strcmp(txt, "ABC") == 0) { + lv_btnm_set_map(kb, kb_map_uc); + lv_btnm_set_ctrl_map(kb, kb_ctrl_uc_map); + return; + } + else if (strcmp(txt, "1#") == 0) { + lv_btnm_set_map(kb, kb_map_spec); + lv_btnm_set_ctrl_map(kb, kb_ctrl_spec_map); + return; + } + else if (strcmp(txt, LV_SYMBOL_CLOSE) == 0) { + if (kb->event_cb != lv_kb_def_event_cb) { + //lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, NULL); + //if (res != LV_RES_OK) return; + lv_clear_keyboard(); + draw_return_ui(); + } + else { + lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ + lv_obj_del(kb); + return; + } + return; + } + else if (strcmp(txt, LV_SYMBOL_OK) == 0) { + if (kb->event_cb != lv_kb_def_event_cb) { + //lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, NULL); + //if (res != LV_RES_OK) return; + const char * ret_ta_txt = lv_ta_get_text(ext->ta); + switch (keyboard_value) { + #if ENABLED(USE_WIFI_FUNCTION) + case wifiName: + memcpy(uiCfg.wifi_name,ret_ta_txt,sizeof(uiCfg.wifi_name)); + lv_clear_keyboard(); + draw_return_ui(); + break; + case wifiPassWord: + memcpy(uiCfg.wifi_key,ret_ta_txt,sizeof(uiCfg.wifi_name)); + lv_clear_keyboard(); + draw_return_ui(); + break; + case wifiConfig: + memset((void *)uiCfg.wifi_name, 0, sizeof(uiCfg.wifi_name)); + memcpy((void *)uiCfg.wifi_name, wifi_list.wifiName[wifi_list.nameIndex], 32); + + memset((void *)uiCfg.wifi_key, 0, sizeof(uiCfg.wifi_key)); + memcpy((void *)uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_key)); + + gCfgItems.wifi_mode_sel = STA_MODEL; + + package_to_wifi(WIFI_PARA_SET, (char *)0, 0); + + memset(public_buf_l,0,sizeof(public_buf_l)); + + public_buf_l[0] = 0xA5; + public_buf_l[1] = 0x09; + public_buf_l[2] = 0x01; + public_buf_l[3] = 0x00; + public_buf_l[4] = 0x01; + public_buf_l[5] = 0xFC; + public_buf_l[6] = 0x00; + raw_send_to_wifi(public_buf_l, 6); + + last_disp_state = KEY_BOARD_UI; + lv_clear_keyboard(); + wifi_tips_type = TIPS_TYPE_JOINING; + lv_draw_wifi_tips(); + break; + #endif // USE_WIFI_FUNCTION + case gcodeCommand: + uint8_t buf[100]; + strncpy((char *)buf,ret_ta_txt,sizeof(buf)); + update_gcode_command(AUTO_LEVELING_COMMAND_ADDR,buf); + lv_clear_keyboard(); + draw_return_ui(); + break; + default: break; + } + } + else { + lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ + } + return; + } + + /*Add the characters to the text area if set*/ + if (ext->ta == NULL) return; + + if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0) + lv_ta_add_char(ext->ta, '\n'); + else if (strcmp(txt, LV_SYMBOL_LEFT) == 0) + lv_ta_cursor_left(ext->ta); + else if (strcmp(txt, LV_SYMBOL_RIGHT) == 0) + lv_ta_cursor_right(ext->ta); + else if (strcmp(txt, LV_SYMBOL_BACKSPACE) == 0) + lv_ta_del_char(ext->ta); + else if (strcmp(txt, "+/-") == 0) { + uint16_t cur = lv_ta_get_cursor_pos(ext->ta); + const char * ta_txt = lv_ta_get_text(ext->ta); + if (ta_txt[0] == '-') { + lv_ta_set_cursor_pos(ext->ta, 1); + lv_ta_del_char(ext->ta); + lv_ta_add_char(ext->ta, '+'); + lv_ta_set_cursor_pos(ext->ta, cur); + } + else if (ta_txt[0] == '+') { + lv_ta_set_cursor_pos(ext->ta, 1); + lv_ta_del_char(ext->ta); + lv_ta_add_char(ext->ta, '-'); + lv_ta_set_cursor_pos(ext->ta, cur); + } + else { + lv_ta_set_cursor_pos(ext->ta, 0); + lv_ta_add_char(ext->ta, '-'); + lv_ta_set_cursor_pos(ext->ta, cur + 1); + } + } + else { + lv_ta_add_text(ext->ta, txt); + } +} + +void lv_draw_keyboard() { + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != KEY_BOARD_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = KEY_BOARD_UI; + } + disp_state = KEY_BOARD_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + /*Create styles for the keyboard*/ + static lv_style_t rel_style, pr_style; + + lv_style_copy(&rel_style, &lv_style_btn_rel); + rel_style.body.radius = 0; + rel_style.body.border.width = 1; + rel_style.body.main_color = lv_color_make(0xa9, 0x62, 0x1d); + rel_style.body.grad_color = lv_color_make(0xa7, 0x59, 0x0e); + + lv_style_copy(&pr_style, &lv_style_btn_pr); + pr_style.body.radius = 0; + pr_style.body.border.width = 1; + pr_style.body.main_color = lv_color_make(0x72, 0x42, 0x15); + pr_style.body.grad_color = lv_color_make(0x6a, 0x3a, 0x0c); + + /*Create a keyboard and apply the styles*/ + lv_obj_t *kb = lv_kb_create(scr, NULL); + lv_obj_set_event_cb(kb, lv_kb_event_cb); + lv_kb_set_cursor_manage(kb, true); + lv_kb_set_style(kb, LV_KB_STYLE_BG, &lv_style_transp_tight); + lv_kb_set_style(kb, LV_KB_STYLE_BTN_REL, &rel_style); + lv_kb_set_style(kb, LV_KB_STYLE_BTN_PR, &pr_style); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + //lv_group_add_obj(g, kb); + //lv_group_set_editing(g, true); + } + #endif + + /*Create a text area. The keyboard will write here*/ + lv_obj_t *ta = lv_ta_create(scr, NULL); + lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); + if (keyboard_value == gcodeCommand) { + get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m); + public_buf_m[sizeof(public_buf_m)-1] = 0; + lv_ta_set_text(ta, public_buf_m); + } + else { + lv_ta_set_text(ta, ""); + } + + /*Assign the text area to the keyboard*/ + lv_kb_set_ta(kb, ta); +} + +void lv_clear_keyboard() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { /* lv_group_remove_all_objs(g); */ } + #endif + lv_obj_del(scr); +} + + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h new file mode 100644 index 000000000000..0013dc4030ea --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_keyboard(); +extern void lv_clear_keyboard(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp index 9029f6868c02..3e4ad06477cd 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp @@ -49,6 +49,7 @@ static void disp_language(uint8_t language, uint8_t state); +extern lv_group_t * g; static lv_obj_t * scr; static lv_obj_t *buttonCN, *buttonT_CN, *buttonEN, *buttonRU; static lv_obj_t *buttonES, *buttonFR, *buttonIT, *buttonBack; @@ -61,9 +62,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { disp_language(gCfgItems.language, UNSELECTED); - lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_simplified_cn_sel.bin", 0); + lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, "F:/bmp_simplified_cn_sel.bin"); + lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, "F:/bmp_simplified_cn_sel.bin"); + lv_obj_refresh_ext_draw_pad(buttonCN); gCfgItems.language = LANG_SIMPLE_CHINESE; - gCfg_to_spiFlah(); + update_spi_flash(); disp_language_init(); } break; @@ -73,9 +76,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { disp_language(gCfgItems.language, UNSELECTED); - lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_traditional_cn_sel.bin", 0); + lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, "F:/bmp_traditional_cn_sel.bin"); + lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, "F:/bmp_traditional_cn_sel.bin"); + lv_obj_refresh_ext_draw_pad(buttonT_CN); gCfgItems.language = LANG_COMPLEX_CHINESE; - gCfg_to_spiFlah(); + update_spi_flash(); disp_language_init(); } break; @@ -85,9 +90,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { disp_language(gCfgItems.language, UNSELECTED); - lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, "bmp_english_sel.bin", 0); + lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, "F:/bmp_english_sel.bin"); + lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, "F:/bmp_english_sel.bin"); + lv_obj_refresh_ext_draw_pad(buttonEN); gCfgItems.language = LANG_ENGLISH; - gCfg_to_spiFlah(); + update_spi_flash(); disp_language_init(); } break; @@ -97,9 +104,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { disp_language(gCfgItems.language, UNSELECTED); - lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, "bmp_russian_sel.bin", 0); + lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, "F:/bmp_russian_sel.bin"); + lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, "F:/bmp_russian_sel.bin"); + lv_obj_refresh_ext_draw_pad(buttonRU); gCfgItems.language = LANG_RUSSIAN; - gCfg_to_spiFlah(); + update_spi_flash(); disp_language_init(); } break; @@ -109,9 +118,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { disp_language(gCfgItems.language, UNSELECTED); - lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, "bmp_spanish_sel.bin", 0); + lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, "F:/bmp_spanish_sel.bin"); + lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, "F:/bmp_spanish_sel.bin"); + lv_obj_refresh_ext_draw_pad(buttonES); gCfgItems.language = LANG_SPANISH; - gCfg_to_spiFlah(); + update_spi_flash(); disp_language_init(); } break; @@ -121,9 +132,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { disp_language(gCfgItems.language, UNSELECTED); - lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, "bmp_french_sel.bin", 0); + lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, "F:/bmp_french_sel.bin"); + lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, "F:/bmp_french_sel.bin"); + lv_obj_refresh_ext_draw_pad(buttonFR); gCfgItems.language = LANG_FRENCH; - gCfg_to_spiFlah(); + update_spi_flash(); disp_language_init(); } break; @@ -133,9 +146,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { disp_language(gCfgItems.language, UNSELECTED); - lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_FR, "bmp_italy_sel.bin", 0); + lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, "F:/bmp_italy_sel.bin"); + lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, "F:/bmp_italy_sel.bin"); + lv_obj_refresh_ext_draw_pad(buttonIT); gCfgItems.language = LANG_ITALY; - gCfg_to_spiFlah(); + update_spi_flash(); disp_language_init(); } break; @@ -154,8 +169,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { buttonFR = NULL; buttonIT = NULL; buttonBack = NULL; - - lv_obj_del(scr); + lv_clear_language(); lv_draw_set(); } break; @@ -172,42 +186,42 @@ static void disp_language(uint8_t language, uint8_t state) { switch (language) { case LANG_SIMPLE_CHINESE: id = ID_CN; - strcpy_P(public_buf_l, PSTR("bmp_simplified_cn")); + strcpy_P(public_buf_l, PSTR("F:/bmp_simplified_cn")); obj = buttonCN; break; case LANG_COMPLEX_CHINESE: id = ID_T_CN; - strcpy_P(public_buf_l, PSTR("bmp_traditional_cn")); + strcpy_P(public_buf_l, PSTR("F:/bmp_traditional_cn")); obj = buttonT_CN; break; case LANG_ENGLISH: id = ID_EN; - strcpy_P(public_buf_l, PSTR("bmp_english")); + strcpy_P(public_buf_l, PSTR("F:/bmp_english")); obj = buttonEN; break; case LANG_RUSSIAN: id = ID_RU; - strcpy_P(public_buf_l, PSTR("bmp_russian")); + strcpy_P(public_buf_l, PSTR("F:/bmp_russian")); obj = buttonRU; break; case LANG_SPANISH: id = ID_ES; - strcpy_P(public_buf_l, PSTR("bmp_spanish")); + strcpy_P(public_buf_l, PSTR("F:/bmp_spanish")); obj = buttonES; break; case LANG_FRENCH: id = ID_FR; - strcpy_P(public_buf_l, PSTR("bmp_french")); + strcpy_P(public_buf_l, PSTR("F:/bmp_french")); obj = buttonFR; break; case LANG_ITALY: id = ID_IT; - strcpy_P(public_buf_l, PSTR("bmp_italy")); + strcpy_P(public_buf_l, PSTR("F:/bmp_italy")); obj = buttonIT; break; default: id = ID_CN; - strcpy_P(public_buf_l, PSTR("bmp_simplified_cn")); + strcpy_P(public_buf_l, PSTR("F:/bmp_simplified_cn")); obj = buttonCN; break; } @@ -216,7 +230,9 @@ static void disp_language(uint8_t language, uint8_t state) { strcat_P(public_buf_l, PSTR(".bin")); - lv_obj_set_event_cb_mks(obj, event_handler, id, public_buf_l, 0); + lv_obj_set_event_cb_mks(obj, event_handler, id, NULL, 0); + lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, public_buf_l); + lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, public_buf_l); if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj); } @@ -244,8 +260,6 @@ void lv_draw_language(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - // Create image buttons buttonCN = lv_imgbtn_create(scr, NULL); buttonT_CN = lv_imgbtn_create(scr, NULL); @@ -256,52 +270,53 @@ void lv_draw_language(void) { buttonIT = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_simplified_cn.bin", 0); - lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, NULL, 0); + lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, "F:/bmp_simplified_cn.bin"); + lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, "F:/bmp_simplified_cn.bin"); lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_REL, &tft_style_label_rel); lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW); + #if 1 - lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_traditional_cn.bin", 0); - lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, NULL, 0); + lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, "F:/bmp_traditional_cn.bin"); + lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, "F:/bmp_traditional_cn.bin"); lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, "bmp_english.bin", 0); - lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, NULL, 0); + lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, "F:/bmp_english.bin"); + lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, "F:/bmp_english.bin"); lv_imgbtn_set_style(buttonEN, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonEN, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, "bmp_russian.bin", 0); - lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, NULL, 0); + lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, "F:/bmp_russian.bin"); + lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, "F:/bmp_russian.bin"); lv_imgbtn_set_style(buttonRU, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonRU, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, "bmp_spanish.bin", 0); - lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, NULL, 0); + lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, "F:/bmp_spanish.bin"); + lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, "F:/bmp_spanish.bin"); lv_imgbtn_set_style(buttonES, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonES, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, "bmp_french.bin", 0); - lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, NULL, 0); + lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, "F:/bmp_french.bin"); + lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, "F:/bmp_french.bin"); lv_imgbtn_set_style(buttonFR, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonFR, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_IT, "bmp_italy.bin", 0); - lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_IT, NULL, 0); + lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, "F:/bmp_italy.bin"); + lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, "F:/bmp_italy.bin"); lv_imgbtn_set_style(buttonIT, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonIT, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_L_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_L_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); @@ -362,8 +377,25 @@ void lv_draw_language(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonCN); + lv_group_add_obj(g, buttonT_CN); + lv_group_add_obj(g, buttonEN); + lv_group_add_obj(g, buttonRU); + lv_group_add_obj(g, buttonES); + lv_group_add_obj(g, buttonFR); + lv_group_add_obj(g, buttonIT); + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_language() { lv_obj_del(scr); } +void lv_clear_language() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp new file mode 100644 index 000000000000..0e0283d32a40 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp @@ -0,0 +1,261 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../MarlinCore.h" + +extern lv_group_t * g; +static lv_obj_t * scr; + +#define ID_LEVEL_RETURN 1 +#define ID_LEVEL_POSITION 2 +#define ID_LEVEL_POSITION_ARROW 3 +#define ID_LEVEL_COMMAND 4 +#define ID_LEVEL_COMMAND_ARROW 5 +#define ID_LEVEL_ZOFFSET 6 +#define ID_LEVEL_ZOFFSET_ARROW 7 + + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_LEVEL_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_level_settings(); + draw_return_ui(); + } + break; + case ID_LEVEL_POSITION: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_level_settings(); + lv_draw_manual_level_pos_settings(); + } + break; + case ID_LEVEL_POSITION_ARROW: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_level_settings(); + lv_draw_manual_level_pos_settings(); + } + break; + case ID_LEVEL_COMMAND: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + keyboard_value = gcodeCommand; + lv_clear_level_settings(); + lv_draw_keyboard(); + } + break; + case ID_LEVEL_COMMAND_ARROW: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + keyboard_value = gcodeCommand; + lv_clear_level_settings(); + lv_draw_keyboard(); + } + break; + #if HAS_BED_PROBE + case ID_LEVEL_ZOFFSET: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_level_settings(); + lv_draw_auto_level_offset_settings(); + } + break; + case ID_LEVEL_ZOFFSET_ARROW: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_level_settings(); + lv_draw_auto_level_offset_settings(); + } + break; + #endif + } +} + +void lv_draw_level_settings(void) { + lv_obj_t *buttonBack, *label_Back; + lv_obj_t *buttonPosition, *labelPosition, *buttonPositionNarrow; + lv_obj_t *buttonCommand, *labelCommand, *buttonCommandNarrow; + #if HAS_BED_PROBE + lv_obj_t *buttonZoffset, *labelZoffset, *buttonZoffsetNarrow; + lv_obj_t * line3; + #endif + lv_obj_t * line1, * line2; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_PARA_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_PARA_UI; + } + disp_state = LEVELING_PARA_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, machine_menu.LevelingParaConfTitle); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + + buttonPosition = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonPosition, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ + lv_obj_set_size(buttonPosition, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + lv_obj_set_event_cb_mks(buttonPosition, event_handler, ID_LEVEL_POSITION, NULL, 0); + lv_btn_set_style(buttonPosition, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ + lv_btn_set_style(buttonPosition, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_layout(buttonPosition, LV_LAYOUT_OFF); + labelPosition = lv_label_create(buttonPosition, NULL); /*Add a label to the button*/ + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPosition); + #endif + + buttonPositionNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonPositionNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonPositionNarrow, event_handler, ID_LEVEL_POSITION_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonPositionNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonPositionNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonPositionNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonPositionNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonPositionNarrow, LV_LAYOUT_OFF); + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1, line_points[0]); + + buttonCommand = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonCommand, PARA_UI_POS_X, PARA_UI_POS_Y * 2); + lv_obj_set_size(buttonCommand, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); + lv_obj_set_event_cb_mks(buttonCommand, event_handler, ID_LEVEL_COMMAND, NULL, 0); + lv_btn_set_style(buttonCommand, LV_BTN_STYLE_REL, &tft_style_label_rel); + lv_btn_set_style(buttonCommand, LV_BTN_STYLE_PR, &tft_style_label_pre); + lv_btn_set_layout(buttonCommand, LV_LAYOUT_OFF); + labelCommand = lv_label_create(buttonCommand, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonCommand); + #endif + + buttonCommandNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonCommandNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonCommandNarrow, event_handler, ID_LEVEL_COMMAND_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonCommandNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonCommandNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonCommandNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonCommandNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonCommandNarrow, LV_LAYOUT_OFF); + + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2, line_points[1]); + + #if HAS_BED_PROBE + + buttonZoffset = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonZoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ + lv_obj_set_size(buttonZoffset, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + lv_obj_set_event_cb_mks(buttonZoffset, event_handler, ID_LEVEL_ZOFFSET, NULL, 0); + lv_btn_set_style(buttonZoffset, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ + lv_btn_set_style(buttonZoffset, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_layout(buttonZoffset, LV_LAYOUT_OFF); + labelZoffset = lv_label_create(buttonZoffset, NULL); /*Add a label to the button*/ + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZoffset); + #endif + + buttonZoffsetNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonZoffsetNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonZoffsetNarrow, event_handler, ID_LEVEL_ZOFFSET_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonZoffsetNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonZoffsetNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonZoffsetNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonZoffsetNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonZoffsetNarrow, LV_LAYOUT_OFF); + + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3, line_points[2]); + + #endif // HAS_BED_PROBE + + buttonBack = lv_imgbtn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_LEVEL_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language != 0) { + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); + + lv_label_set_text(labelPosition, machine_menu.LevelingManuPosConf); + lv_obj_align(labelPosition, buttonPosition, LV_ALIGN_IN_LEFT_MID, 0, 0); + + lv_label_set_text(labelCommand, machine_menu.LevelingAutoCommandConf); + lv_obj_align(labelCommand, buttonCommand, LV_ALIGN_IN_LEFT_MID, 0, 0); + #if HAS_BED_PROBE + lv_label_set_text(labelZoffset, machine_menu.LevelingAutoZoffsetConf); + lv_obj_align(labelZoffset, buttonZoffset, LV_ALIGN_IN_LEFT_MID, 0, 0); + #endif + } + +} + +void lv_clear_level_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h new file mode 100644 index 000000000000..ce290172b6e5 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_level_settings(void); +extern void lv_clear_level_settings(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp index d441f2ac51b8..9f03793c24f7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp @@ -28,6 +28,7 @@ #include "../../../../MarlinCore.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_PARA_RETURN 1 @@ -35,8 +36,10 @@ static lv_obj_t * scr; #define ID_PARA_MACHINE_ARROW 3 #define ID_PARA_MOTOR 4 #define ID_PARA_MOTOR_ARROW 5 -#define ID_PARA_ADVANCE 6 -#define ID_PARA_ADVANCE_ARROW 7 +#define ID_PARA_LEVEL 6 +#define ID_PARA_LEVEL_ARROW 7 +#define ID_PARA_ADVANCE 8 +#define ID_PARA_ADVANCE_ARROW 9 static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { @@ -85,6 +88,24 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { lv_draw_motor_settings(); } break; + case ID_PARA_LEVEL: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_machine_para(); + lv_draw_level_settings(); + } + break; + case ID_PARA_LEVEL_ARROW: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_machine_para(); + lv_draw_level_settings(); + } + break; case ID_PARA_ADVANCE: if (event == LV_EVENT_CLICKED) { @@ -110,8 +131,9 @@ void lv_draw_machine_para(void) { lv_obj_t *buttonBack, *label_Back; lv_obj_t *buttonMachine, *labelMachine, *buttonMachineNarrow; lv_obj_t *buttonMotor, *labelMotor, *buttonMotorNarrow; + lv_obj_t *buttonLevel, *labelLevel, *buttonLevelNarrow; lv_obj_t *buttonAdvance, *labelAdvance, *buttonAdvanceNarrow; - lv_obj_t * line1, * line2, * line3; + lv_obj_t * line1, * line2, * line3, * line4; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) { disp_state_stack._disp_index++; disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI; @@ -131,9 +153,6 @@ void lv_draw_machine_para(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - LV_IMG_DECLARE(bmp_para_arrow); - buttonMachine = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_set_pos(buttonMachine, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ lv_obj_set_size(buttonMachine, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ @@ -146,9 +165,9 @@ void lv_draw_machine_para(void) { buttonMachineNarrow = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonMachineNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonMachineNarrow, event_handler, ID_PARA_MACHINE_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_event_cb_mks(buttonMachineNarrow, event_handler, ID_PARA_MACHINE_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonMachineNarrow, LV_LAYOUT_OFF); @@ -168,9 +187,9 @@ void lv_draw_machine_para(void) { buttonMotorNarrow = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonMotorNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonMotorNarrow, event_handler, ID_PARA_MOTOR_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_event_cb_mks(buttonMotorNarrow, event_handler, ID_PARA_MOTOR_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonMotorNarrow, LV_LAYOUT_OFF); @@ -178,8 +197,30 @@ void lv_draw_machine_para(void) { line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); + buttonLevel = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonLevel, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ + lv_obj_set_size(buttonLevel, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + //lv_obj_set_event_cb(buttonMotor, event_handler); + lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_PARA_LEVEL, NULL, 0); + lv_btn_set_style(buttonLevel, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ + lv_btn_set_style(buttonLevel, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF); + labelLevel = lv_label_create(buttonLevel, NULL); /*Add a label to the button*/ + + buttonLevelNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonLevelNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonLevelNarrow, event_handler, ID_PARA_LEVEL_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonLevelNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonLevelNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonLevelNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonLevelNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonLevelNarrow, LV_LAYOUT_OFF); + + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3, line_points[2]); + buttonAdvance = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonAdvance, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ + lv_obj_set_pos(buttonAdvance, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/ lv_obj_set_size(buttonAdvance, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ //lv_obj_set_event_cb(buttonMotor, event_handler); lv_obj_set_event_cb_mks(buttonAdvance, event_handler, ID_PARA_ADVANCE, NULL, 0); @@ -189,44 +230,61 @@ void lv_draw_machine_para(void) { labelAdvance = lv_label_create(buttonAdvance, NULL); /*Add a label to the button*/ buttonAdvanceNarrow = lv_imgbtn_create(scr, NULL); - lv_obj_set_pos(buttonAdvanceNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonAdvanceNarrow, event_handler, ID_PARA_ADVANCE_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_pos(buttonAdvanceNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 4 + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonAdvanceNarrow, event_handler, ID_PARA_ADVANCE_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonAdvanceNarrow, LV_LAYOUT_OFF); - line3 = lv_line_create(scr, NULL); - lv_ex_line(line3, line_points[2]); + line4 = lv_line_create(scr, NULL); + lv_ex_line(line4, line_points[3]); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PARA_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PARA_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(label_Back, common_menu.text_back); - lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, -2); lv_label_set_text(labelMachine, MachinePara_menu.MachineSetting); - lv_obj_align(labelMachine, buttonMachine, LV_ALIGN_IN_LEFT_MID, 0, 0); + lv_obj_align(labelMachine, buttonMachine, LV_ALIGN_IN_LEFT_MID, 0, -3); lv_label_set_text(labelMotor, MachinePara_menu.MotorSetting); - lv_obj_align(labelMotor, buttonMotor, LV_ALIGN_IN_LEFT_MID, 0, 0); + lv_obj_align(labelMotor, buttonMotor, LV_ALIGN_IN_LEFT_MID, 0, -3); + + lv_label_set_text(labelLevel, MachinePara_menu.leveling); + lv_obj_align(labelLevel, buttonLevel, LV_ALIGN_IN_LEFT_MID, 0, -3); lv_label_set_text(labelAdvance, MachinePara_menu.AdvanceSetting); - lv_obj_align(labelAdvance, buttonAdvance, LV_ALIGN_IN_LEFT_MID, 0, 0); + lv_obj_align(labelAdvance, buttonAdvance, LV_ALIGN_IN_LEFT_MID, 0, -3); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonMachine); + lv_group_add_obj(g, buttonMotor); + lv_group_add_obj(g, buttonLevel); + lv_group_add_obj(g, buttonAdvance); + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_machine_para() { lv_obj_del(scr); } +void lv_clear_machine_para() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp index 88a66c6599e1..0cf5bbaf7fba 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp @@ -28,6 +28,7 @@ #include "../../../../MarlinCore.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_MACHINE_RETURN 1 @@ -138,24 +139,21 @@ void lv_draw_machine_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - LV_IMG_DECLARE(bmp_para_arrow); - - buttonAcceleration = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonAcceleration, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + buttonAcceleration = lv_btn_create(scr, NULL); // Add a button the current screen + lv_obj_set_pos(buttonAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y); // Set its position + lv_obj_set_size(buttonAcceleration, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); // Set its size //lv_obj_set_event_cb(buttonMachine, event_handler); lv_obj_set_event_cb_mks(buttonAcceleration, event_handler, ID_MACHINE_ACCELERATION, NULL, 0); - lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_REL, &tft_style_label_rel); // Set the button's released style + lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_PR, &tft_style_label_pre); // Set the button's pressed style lv_btn_set_layout(buttonAcceleration, LV_LAYOUT_OFF); - labelAcceleration = lv_label_create(buttonAcceleration, NULL); /*Add a label to the button*/ + labelAcceleration = lv_label_create(buttonAcceleration, NULL); // Add a label to the button buttonAccelerationNarrow = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonAccelerationNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonAccelerationNarrow, event_handler, ID_MACHINE_ACCELERATION_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_event_cb_mks(buttonAccelerationNarrow, event_handler, ID_MACHINE_ACCELERATION_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonAccelerationNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonAccelerationNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonAccelerationNarrow, LV_LAYOUT_OFF); @@ -163,21 +161,21 @@ void lv_draw_machine_settings(void) { line1 = lv_line_create(lv_scr_act(), NULL); lv_ex_line(line1, line_points[0]); - buttonMaxFeedrate = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonMaxFeedrate, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonMaxFeedrate, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + buttonMaxFeedrate = lv_btn_create(scr, NULL); // Add a button the current screen + lv_obj_set_pos(buttonMaxFeedrate, PARA_UI_POS_X, PARA_UI_POS_Y * 2); // Set its position + lv_obj_set_size(buttonMaxFeedrate, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); // Set its size //lv_obj_set_event_cb(buttonMachine, event_handler); lv_obj_set_event_cb_mks(buttonMaxFeedrate, event_handler, ID_MACHINE_FEEDRATE, NULL, 0); - lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_REL, &tft_style_label_rel); // Set the button's released style + lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_PR, &tft_style_label_pre); // Set the button's pressed style lv_btn_set_layout(buttonMaxFeedrate, LV_LAYOUT_OFF); - labelMaxFeedrate = lv_label_create(buttonMaxFeedrate, NULL); /*Add a label to the button*/ + labelMaxFeedrate = lv_label_create(buttonMaxFeedrate, NULL); // Add a label to the button buttonMaxFeedrateNarrow = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonMaxFeedrateNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonMaxFeedrateNarrow, event_handler, ID_MACHINE_FEEDRATE_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_event_cb_mks(buttonMaxFeedrateNarrow, event_handler, ID_MACHINE_FEEDRATE_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonMaxFeedrateNarrow, LV_LAYOUT_OFF); @@ -186,21 +184,21 @@ void lv_draw_machine_settings(void) { lv_ex_line(line2, line_points[1]); #if HAS_CLASSIC_JERK - buttonJerk = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonJerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ - lv_obj_set_size(buttonJerk, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + buttonJerk = lv_btn_create(scr, NULL); // Add a button the current screen + lv_obj_set_pos(buttonJerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3); // Set its position + lv_obj_set_size(buttonJerk, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); // Set its size //lv_obj_set_event_cb(buttonMotor, event_handler); lv_obj_set_event_cb_mks(buttonJerk, event_handler, ID_MACHINE_JERK, NULL, 0); - lv_btn_set_style(buttonJerk, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonJerk, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_style(buttonJerk, LV_BTN_STYLE_REL, &tft_style_label_rel); // Set the button's released style + lv_btn_set_style(buttonJerk, LV_BTN_STYLE_PR, &tft_style_label_pre); // Set the button's pressed style lv_btn_set_layout(buttonJerk, LV_LAYOUT_OFF); - labelJerk = lv_label_create(buttonJerk, NULL); /*Add a label to the button*/ + labelJerk = lv_label_create(buttonJerk, NULL); // Add a label to the button buttonJerkNarrow = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonJerkNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonJerkNarrow, event_handler, ID_MACHINE_JERK_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_event_cb_mks(buttonJerkNarrow, event_handler, ID_MACHINE_JERK_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonJerkNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonJerkNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonJerkNarrow, LV_LAYOUT_OFF); @@ -210,9 +208,9 @@ void lv_draw_machine_settings(void) { #endif buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MACHINE_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MACHINE_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); @@ -234,8 +232,23 @@ void lv_draw_machine_settings(void) { lv_obj_align(labelJerk, buttonJerk, LV_ALIGN_IN_LEFT_MID, 0, 0); #endif } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonAcceleration); + lv_group_add_obj(g, buttonMaxFeedrate); + #if HAS_CLASSIC_JERK + lv_group_add_obj(g, buttonJerk); + #endif + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_machine_settings() { lv_obj_del(scr); } +void lv_clear_machine_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp index 6530b1554c47..3d68019b3527 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp @@ -32,7 +32,7 @@ #include "draw_ui.h" #include "../../../../gcode/queue.h" -//static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn; +extern lv_group_t * g; static lv_obj_t * scr; #define ID_M_POINT1 1 @@ -59,7 +59,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { queue.enqueue_now_P(PSTR("G1 Z10")); ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MIN_POS + 30, Y_MIN_POS + 30); + sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G1 Z0")); } @@ -79,7 +79,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { queue.enqueue_now_P(PSTR("G1 Z10")); ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MAX_POS - 30, Y_MIN_POS + 30); + sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[1][0], (int)gCfgItems.levelingPos[1][1]); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G1 Z0")); } @@ -99,7 +99,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { queue.enqueue_now_P(PSTR("G1 Z10")); ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MAX_POS - 30, Y_MAX_POS - 30); + sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[2][0], (int)gCfgItems.levelingPos[2][1]); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G1 Z0")); } @@ -120,7 +120,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { queue.enqueue_now_P(PSTR("G1 Z10")); ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MIN_POS + 30, Y_MAX_POS - 30); + sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[3][0], (int)gCfgItems.levelingPos[3][1]); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G1 Z0")); } @@ -140,7 +140,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { queue.enqueue_now_P(PSTR("G1 Z10")); ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_BED_SIZE / 2, Y_BED_SIZE / 2); + sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[4][0], (int)gCfgItems.levelingPos[4][1]); queue.enqueue_one_now(public_buf_l); queue.enqueue_now_P(PSTR("G1 Z0")); } @@ -159,7 +159,6 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } } - void lv_draw_manualLevel(void) { lv_obj_t *buttonPoint1, *buttonPoint2, *buttonPoint3, *buttonPoint4, *buttonPoint5; lv_obj_t *buttonBack; @@ -185,8 +184,6 @@ void lv_draw_manualLevel(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - // Create an Image button buttonPoint1 = lv_imgbtn_create(scr, NULL); buttonPoint2 = lv_imgbtn_create(scr, NULL); @@ -195,40 +192,41 @@ void lv_draw_manualLevel(void) { buttonPoint5 = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonPoint1, event_handler, ID_M_POINT1, "bmp_leveling1.bin", 0); - lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonPoint1, event_handler, ID_M_POINT1, NULL, 0); + lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_REL, "F:/bmp_leveling1.bin"); + lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_PR, "F:/bmp_leveling1.bin"); lv_imgbtn_set_style(buttonPoint1, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPoint1, LV_BTN_STATE_REL, &tft_style_label_rel); lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW); + #if 1 - lv_obj_set_event_cb_mks(buttonPoint2, event_handler, ID_M_POINT2, "bmp_leveling2.bin", 0); - lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonPoint2, event_handler, ID_M_POINT2, NULL, 0); + lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_REL, "F:/bmp_leveling2.bin"); + lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_PR, "F:/bmp_leveling2.bin"); lv_imgbtn_set_style(buttonPoint2, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPoint2, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonPoint3, event_handler, ID_M_POINT3, "bmp_leveling3.bin", 0); - lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonPoint3, event_handler, ID_M_POINT3, NULL, 0); + lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_REL, "F:/bmp_leveling3.bin"); + lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_PR, "F:/bmp_leveling3.bin"); lv_imgbtn_set_style(buttonPoint3, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPoint3, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonPoint4, event_handler, ID_M_POINT4, "bmp_leveling4.bin", 0); - lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonPoint4, event_handler, ID_M_POINT4, NULL, 0); + lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_REL, "F:/bmp_leveling4.bin"); + lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_PR, "F:/bmp_leveling4.bin"); lv_imgbtn_set_style(buttonPoint4, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPoint4, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonPoint5, event_handler, ID_M_POINT5, "bmp_leveling5.bin", 0); - lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonPoint5, event_handler, ID_M_POINT5, NULL, 0); + lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_REL, "F:/bmp_leveling5.bin"); + lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_PR, "F:/bmp_leveling5.bin"); lv_imgbtn_set_style(buttonPoint5, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPoint5, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); #endif @@ -274,8 +272,23 @@ void lv_draw_manualLevel(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonPoint1); + lv_group_add_obj(g, buttonPoint2); + lv_group_add_obj(g, buttonPoint3); + lv_group_add_obj(g, buttonPoint4); + lv_group_add_obj(g, buttonPoint5); + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_manualLevel() { lv_obj_del(scr); } +void lv_clear_manualLevel() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp new file mode 100644 index 000000000000..9b7200b5a97d --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp @@ -0,0 +1,459 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#include "../../../../MarlinCore.h" +#include "../../../../module/planner.h" + +extern lv_group_t * g; +static lv_obj_t * scr; + +#define ID_MANUAL_POS_RETURN 1 +#define ID_MANUAL_POS_X1 2 +#define ID_MANUAL_POS_Y1 3 +#define ID_MANUAL_POS_X2 4 +#define ID_MANUAL_POS_Y2 5 +#define ID_MANUAL_POS_X3 6 +#define ID_MANUAL_POS_Y3 7 +#define ID_MANUAL_POS_X4 8 +#define ID_MANUAL_POS_Y4 9 +#define ID_MANUAL_POS_X5 10 +#define ID_MANUAL_POS_Y5 11 +#define ID_MANUAL_POS_DOWN 12 +#define ID_MANUAL_POS_UP 13 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_MANUAL_POS_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.para_ui_page = 0; + lv_clear_manual_level_pos_settings(); + draw_return_ui(); + } + break; + case ID_MANUAL_POS_X1: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_x1; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_Y1: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_y1; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_X2: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_x2; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_Y2: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_y2; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_X3: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_x3; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_Y3: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_y3; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_X4: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_x4; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_Y4: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_y4; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_X5: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_y5; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_Y5: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = level_pos_y5; + lv_clear_manual_level_pos_settings(); + lv_draw_number_key(); + } + break; + case ID_MANUAL_POS_UP: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.para_ui_page = 0; + lv_clear_manual_level_pos_settings(); + lv_draw_manual_level_pos_settings(); + } + break; + case ID_MANUAL_POS_DOWN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.para_ui_page = 1; + lv_clear_manual_level_pos_settings(); + lv_draw_manual_level_pos_settings(); + } + break; + } +} + +void lv_draw_manual_level_pos_settings(void) { + lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL; + lv_obj_t *labelPoint1Text = NULL, *buttonX1Value = NULL, *labelX1Value = NULL; + lv_obj_t *buttonY1Value = NULL, *labelY1Value = NULL; + lv_obj_t *labelPoint2Text = NULL, *buttonX2Value = NULL, *labelX2Value = NULL; + lv_obj_t *buttonY2Value = NULL, *labelY2Value = NULL; + lv_obj_t *labelPoint3Text = NULL, *buttonX3Value = NULL, *labelX3Value = NULL; + lv_obj_t *buttonY3Value = NULL, *labelY3Value = NULL; + lv_obj_t *labelPoint4Text = NULL, *buttonX4Value = NULL, *labelX4Value = NULL; + lv_obj_t *buttonY4Value = NULL, *labelY4Value = NULL; + lv_obj_t *labelPoint5Text = NULL, *buttonX5Value = NULL, *labelX5Value = NULL; + lv_obj_t *buttonY5Value = NULL, *labelY5Value = NULL; + lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MANUAL_LEVELING_POSIGION_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = MANUAL_LEVELING_POSIGION_UI; + } + disp_state = MANUAL_LEVELING_POSIGION_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); + lv_label_set_text(title, machine_menu.LevelingParaConfTitle); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + if (uiCfg.para_ui_page != 1) { + labelPoint1Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelPoint1Text, &tft_style_label_rel); + lv_obj_set_pos(labelPoint1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelPoint1Text, leveling_menu.position1); + + buttonX1Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonX1Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonX1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonX1Value, event_handler, ID_MANUAL_POS_X1, NULL, 0); + lv_btn_set_style(buttonX1Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonX1Value, LV_BTN_STYLE_PR, &style_para_value); + labelX1Value = lv_label_create(buttonX1Value, NULL); + + buttonY1Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonY1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonY1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonY1Value, event_handler, ID_MANUAL_POS_Y1, NULL, 0); + lv_btn_set_style(buttonY1Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonY1Value, LV_BTN_STYLE_PR, &style_para_value); + labelY1Value = lv_label_create(buttonY1Value, NULL); + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1, line_points[0]); + + labelPoint2Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelPoint2Text, &tft_style_label_rel); + lv_obj_set_pos(labelPoint2Text, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelPoint2Text, leveling_menu.position2); + + buttonX2Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonX2Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonX2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonX2Value, event_handler, ID_MANUAL_POS_X2, NULL, 0); + lv_btn_set_style(buttonX2Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonX2Value, LV_BTN_STYLE_PR, &style_para_value); + labelX2Value = lv_label_create(buttonX2Value, NULL); + + buttonY2Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonY2Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonY2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonY2Value, event_handler, ID_MANUAL_POS_Y2, NULL, 0); + lv_btn_set_style(buttonY2Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonY2Value, LV_BTN_STYLE_PR, &style_para_value); + labelY2Value = lv_label_create(buttonY2Value, NULL); + + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2, line_points[1]); + + labelPoint3Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelPoint3Text, &tft_style_label_rel); + lv_obj_set_pos(labelPoint3Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelPoint3Text, leveling_menu.position3); + + buttonX3Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonX3Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonX3Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonX3Value, event_handler, ID_MANUAL_POS_X3, NULL, 0); + lv_btn_set_style(buttonX3Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonX3Value, LV_BTN_STYLE_PR, &style_para_value); + labelX3Value = lv_label_create(buttonX3Value, NULL); + + buttonY3Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonY3Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonY3Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonY3Value, event_handler, ID_MANUAL_POS_Y3, NULL, 0); + lv_btn_set_style(buttonY3Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonY3Value, LV_BTN_STYLE_PR, &style_para_value); + labelY3Value = lv_label_create(buttonY3Value, NULL); + + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3, line_points[2]); + + labelPoint4Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelPoint4Text, &tft_style_label_rel); + lv_obj_set_pos(labelPoint4Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelPoint4Text, leveling_menu.position4); + + buttonX4Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonX4Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonX4Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonX4Value, event_handler, ID_MANUAL_POS_X4, NULL, 0); + lv_btn_set_style(buttonX4Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonX4Value, LV_BTN_STYLE_PR, &style_para_value); + labelX4Value = lv_label_create(buttonX4Value, NULL); + + buttonY4Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonY4Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonY4Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonY4Value, event_handler, ID_MANUAL_POS_Y4, NULL, 0); + lv_btn_set_style(buttonY4Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonY4Value, LV_BTN_STYLE_PR, &style_para_value); + labelY4Value = lv_label_create(buttonY4Value, NULL); + + line4 = lv_line_create(scr, NULL); + lv_ex_line(line4, line_points[3]); + + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_DOWN, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonX1Value); + lv_group_add_obj(g, buttonY1Value); + lv_group_add_obj(g, buttonX2Value); + lv_group_add_obj(g, buttonY2Value); + lv_group_add_obj(g, buttonX3Value); + lv_group_add_obj(g, buttonY3Value); + lv_group_add_obj(g, buttonX4Value); + lv_group_add_obj(g, buttonY4Value); + lv_group_add_obj(g, buttonTurnPage); + } + #endif + } + else { + labelPoint5Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelPoint5Text, &tft_style_label_rel); + lv_obj_set_pos(labelPoint5Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelPoint5Text, leveling_menu.position5); + + buttonX5Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonX5Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonX5Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonX5Value, event_handler, ID_MANUAL_POS_X5, NULL, 0); + lv_btn_set_style(buttonX5Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonX5Value, LV_BTN_STYLE_PR, &style_para_value); + labelX5Value = lv_label_create(buttonX5Value, NULL); + + buttonY5Value = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonY5Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); + lv_obj_set_size(buttonY5Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonY5Value, event_handler, ID_MANUAL_POS_Y5, NULL, 0); + lv_btn_set_style(buttonY5Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonY5Value, LV_BTN_STYLE_PR, &style_para_value); + labelY5Value = lv_label_create(buttonY5Value, NULL); + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1, line_points[0]); + + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_UP, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonX5Value); + lv_group_add_obj(g, buttonY5Value); + lv_group_add_obj(g, buttonTurnPage); + } + #endif + } + + lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); + lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + labelTurnPage = lv_label_create(buttonTurnPage, NULL); + + buttonBack = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_POS_RETURN, NULL, 0); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + label_Back = lv_label_create(buttonBack, NULL); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + + if (gCfgItems.multiple_language != 0) { + if (uiCfg.para_ui_page != 1) { + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]); + lv_label_set_text(labelX1Value, public_buf_l); + lv_obj_align(labelX1Value, buttonX1Value, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][1]); + lv_label_set_text(labelY1Value, public_buf_l); + lv_obj_align(labelY1Value, buttonY1Value, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][0]); + lv_label_set_text(labelX2Value, public_buf_l); + lv_obj_align(labelX2Value, buttonX2Value, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][1]); + lv_label_set_text(labelY2Value, public_buf_l); + lv_obj_align(labelY2Value, buttonY2Value, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][0]); + lv_label_set_text(labelX3Value, public_buf_l); + lv_obj_align(labelX3Value, buttonX3Value, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][1]); + lv_label_set_text(labelY3Value, public_buf_l); + lv_obj_align(labelY3Value, buttonY3Value, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][0]); + lv_label_set_text(labelX4Value, public_buf_l); + lv_obj_align(labelX4Value, buttonX4Value, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][1]); + lv_label_set_text(labelY4Value, public_buf_l); + lv_obj_align(labelY4Value, buttonY4Value, LV_ALIGN_CENTER, 0, 0); + + lv_label_set_text(labelTurnPage, machine_menu.next); + lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); + } + else { + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][0]); + lv_label_set_text(labelX5Value, public_buf_l); + lv_obj_align(labelX5Value, buttonX5Value, LV_ALIGN_CENTER, 0, 0); + + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][1]); + lv_label_set_text(labelY5Value, public_buf_l); + lv_obj_align(labelY5Value, buttonY5Value, LV_ALIGN_CENTER, 0, 0); + + lv_label_set_text(labelTurnPage, machine_menu.previous); + lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); + } + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); + } +} + +void lv_clear_manual_level_pos_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h new file mode 100644 index 000000000000..8e89ecf559fc --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_manual_level_pos_settings(void); +extern void lv_clear_manual_level_pos_settings(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp index c78c6f5bb8d4..e82124f7056c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp @@ -29,6 +29,7 @@ #include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_FEED_RETURN 1 @@ -127,11 +128,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { void lv_draw_max_feedrate_settings(void) { lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL; - lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; - lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; - lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; - lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL; - lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL; + lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; + lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; + lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; + lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL; + lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL; lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MAXFEEDRATE_UI) { disp_state_stack._disp_index++; @@ -152,166 +153,139 @@ void lv_draw_max_feedrate_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - // LV_IMG_DECLARE(bmp_para_arrow); - LV_IMG_DECLARE(bmp_para_bank); - if (uiCfg.para_ui_page != 1) { - buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonXText, event_handler); - lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF); - labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/ - - buttonXValue = lv_imgbtn_create(scr, NULL); + labelXText = lv_label_create(scr, NULL); + lv_obj_set_style(labelXText, &tft_style_label_rel); + lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelXText, machine_menu.XMaxFeedRate); + + buttonXValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_FEED_X, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel); + lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_FEED_X, NULL, 0); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF); labelXValue = lv_label_create(buttonXValue, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonYText, event_handler); - lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF); - labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/ + labelYText = lv_label_create(scr, NULL); + lv_obj_set_style(labelYText, &tft_style_label_rel); + lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelYText, machine_menu.YMaxFeedRate); - buttonYValue = lv_imgbtn_create(scr, NULL); + buttonYValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_FEED_Y, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel); + lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_FEED_Y, NULL, 0); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF); labelYValue = lv_label_create(buttonYValue, NULL); line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); - buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ - lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonZText, event_handler); - lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF); - labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/ + labelZText = lv_label_create(scr, NULL); + lv_obj_set_style(labelZText, &tft_style_label_rel); + lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelZText, machine_menu.ZMaxFeedRate); - buttonZValue = lv_imgbtn_create(scr, NULL); + buttonZValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_FEED_Z, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel); + lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_FEED_Z, NULL, 0); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF); labelZValue = lv_label_create(buttonZValue, NULL); line3 = lv_line_create(scr, NULL); lv_ex_line(line3, line_points[2]); - buttonE0Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/ - lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonE0Text, event_handler); - lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF); - labelE0Text = lv_label_create(buttonE0Text, NULL); /*Add a label to the button*/ + labelE0Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelE0Text, &tft_style_label_rel); + lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelE0Text, machine_menu.E0MaxFeedRate); - buttonE0Value = lv_imgbtn_create(scr, NULL); + buttonE0Value = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_FEED_E0, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel); + lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_FEED_E0, NULL, 0); + lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value); lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF); labelE0Value = lv_label_create(buttonE0Value, NULL); line4 = lv_line_create(scr, NULL); lv_ex_line(line4, line_points[3]); - buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_DOWN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_DOWN, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonXValue); + lv_group_add_obj(g, buttonYValue); + lv_group_add_obj(g, buttonZValue); + lv_group_add_obj(g, buttonE0Value); + lv_group_add_obj(g, buttonTurnPage); + } + #endif } else { - buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonE1Text, event_handler); - lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF); - labelE1Text = lv_label_create(buttonE1Text, NULL); /*Add a label to the button*/ - - buttonE1Value = lv_imgbtn_create(scr, NULL); + labelE1Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelE1Text, &tft_style_label_rel); + lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelE1Text, machine_menu.E1MaxFeedRate); + + buttonE1Value = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_FEED_E1, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel); + lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_FEED_E1, NULL, 0); + lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value); lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF); labelE1Value = lv_label_create(buttonE1Value, NULL); + line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_UP, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_UP, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonE1Value); + lv_group_add_obj(g, buttonTurnPage); + } + #endif } lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); - lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF); + lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); labelTurnPage = lv_label_create(buttonTurnPage, NULL); - - buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FEED_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); - + buttonBack = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FEED_RETURN, NULL, 0); lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); - lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); label_Back = lv_label_create(buttonBack, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif if (gCfgItems.multiple_language != 0) { if (uiCfg.para_ui_page != 1) { - lv_label_set_text(labelXText, machine_menu.XMaxFeedRate); - lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelYText, machine_menu.YMaxFeedRate); - lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelZText, machine_menu.ZMaxFeedRate); - lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelE0Text, machine_menu.E0MaxFeedRate); - lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0); lv_label_set_text(labelTurnPage, machine_menu.next); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); @@ -337,9 +311,6 @@ void lv_draw_max_feedrate_settings(void) { lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0); } else { - lv_label_set_text(labelE1Text, machine_menu.E1MaxFeedRate); - lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0); - lv_label_set_text(labelTurnPage, machine_menu.previous); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); @@ -354,6 +325,11 @@ void lv_draw_max_feedrate_settings(void) { } } -void lv_clear_max_feedrate_settings() { lv_obj_del(scr); } +void lv_clear_max_feedrate_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp index 7da477bd51f3..f6568df14314 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp @@ -28,6 +28,7 @@ #include "../../../../MarlinCore.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_MOTOR_RETURN 1 @@ -37,6 +38,8 @@ static lv_obj_t * scr; #define ID_MOTOR_TMC_CURRENT_ARROW 5 #define ID_MOTOR_STEP_MODE 6 #define ID_MOTOR_STEP_MODE_ARROW 7 +#define ID_HOME_SENSE 8 +#define ID_HOME_SENSE_ARROW 9 static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { @@ -67,6 +70,26 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { lv_draw_step_settings(); } break; + #if USE_SENSORLESS + case ID_HOME_SENSE: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_motor_settings(); + lv_draw_homing_sensitivity_settings(); + } + break; + case ID_HOME_SENSE_ARROW: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_motor_settings(); + lv_draw_homing_sensitivity_settings(); + } + break; + #endif #if HAS_TRINAMIC_CONFIG case ID_MOTOR_TMC_CURRENT: if (event == LV_EVENT_CLICKED) { @@ -113,15 +136,27 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { void lv_draw_motor_settings(void) { lv_obj_t *buttonBack, *label_Back; lv_obj_t *buttonSteps, *labelSteps, *buttonStepsNarrow; + lv_obj_t * line1; + #if USE_SENSORLESS + lv_obj_t *buttonSensitivity, *labelSensitivity, *buttonSensitivityNarrow; + lv_obj_t * line2; + #endif #if HAS_TRINAMIC_CONFIG + #if USE_SENSORLESS + lv_obj_t * line3; + #else + lv_obj_t * line2; + #endif lv_obj_t *buttonTMCcurrent, *labelTMCcurrent, *buttonTMCcurrentNarrow; - lv_obj_t * line2; #if HAS_STEALTHCHOP + #if USE_SENSORLESS + lv_obj_t * line4; + #else + lv_obj_t * line3; + #endif lv_obj_t *buttonStepMode, *labelStepMode, *buttonStepModeNarrow; - lv_obj_t * line3; #endif #endif - lv_obj_t * line1; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOTOR_SETTINGS_UI) { disp_state_stack._disp_index++; disp_state_stack._disp_state[disp_state_stack._disp_index] = MOTOR_SETTINGS_UI; @@ -141,9 +176,6 @@ void lv_draw_motor_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - LV_IMG_DECLARE(bmp_para_arrow); - buttonSteps = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_set_pos(buttonSteps, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ lv_obj_set_size(buttonSteps, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ @@ -154,20 +186,54 @@ void lv_draw_motor_settings(void) { lv_btn_set_layout(buttonSteps, LV_LAYOUT_OFF); labelSteps = lv_label_create(buttonSteps, NULL); /*Add a label to the button*/ + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonSteps); + #endif + buttonStepsNarrow = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonStepsNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonStepsNarrow, event_handler, ID_MOTOR_STEPS_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_event_cb_mks(buttonStepsNarrow, event_handler, ID_MOTOR_STEPS_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonStepsNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonStepsNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonStepsNarrow, LV_LAYOUT_OFF); - line1 = lv_line_create(lv_scr_act(), NULL); + line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); + + #if USE_SENSORLESS + buttonSensitivity = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonSensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ + lv_obj_set_size(buttonSensitivity, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ + //lv_obj_set_event_cb(buttonMachine, event_handler); + lv_obj_set_event_cb_mks(buttonSensitivity, event_handler, ID_HOME_SENSE, NULL, 0); + lv_btn_set_style(buttonSensitivity, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ + lv_btn_set_style(buttonSensitivity, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_layout(buttonSensitivity, LV_LAYOUT_OFF); + labelSensitivity = lv_label_create(buttonSensitivity, NULL); /*Add a label to the button*/ + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonSensitivity); + #endif + + buttonSensitivityNarrow = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonSensitivityNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonSensitivityNarrow, event_handler, ID_HOME_SENSE_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonSensitivityNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonSensitivityNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); + lv_imgbtn_set_style(buttonSensitivityNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonSensitivityNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonSensitivityNarrow, LV_LAYOUT_OFF); + + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2, line_points[1]); + #endif + + #if HAS_TRINAMIC_CONFIG buttonTMCcurrent = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonTMCcurrent, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ + lv_obj_set_pos(buttonTMCcurrent, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 3, PARA_UI_POS_Y * 2)); lv_obj_set_size(buttonTMCcurrent, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ //lv_obj_set_event_cb(buttonMachine, event_handler); lv_obj_set_event_cb_mks(buttonTMCcurrent, event_handler, ID_MOTOR_TMC_CURRENT, NULL, 0); @@ -175,61 +241,86 @@ void lv_draw_motor_settings(void) { lv_btn_set_style(buttonTMCcurrent, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ lv_btn_set_layout(buttonTMCcurrent, LV_LAYOUT_OFF); labelTMCcurrent = lv_label_create(buttonTMCcurrent, NULL); /*Add a label to the button*/ + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTMCcurrent); + #endif buttonTMCcurrentNarrow = lv_imgbtn_create(scr, NULL); - lv_obj_set_pos(buttonTMCcurrentNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonTMCcurrentNarrow, event_handler, ID_MOTOR_TMC_CURRENT_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_pos(buttonTMCcurrentNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 3, PARA_UI_POS_Y * 2) + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonTMCcurrentNarrow, event_handler, ID_MOTOR_TMC_CURRENT_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonTMCcurrentNarrow, LV_LAYOUT_OFF); - - line2 = lv_line_create(lv_scr_act(), NULL); - lv_ex_line(line2, line_points[1]); + #if USE_SENSORLESS + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3, line_points[2]); + #else + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2, line_points[1]); + #endif #if HAS_STEALTHCHOP buttonStepMode = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonStepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ + lv_obj_set_pos(buttonStepMode, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 4, PARA_UI_POS_Y * 3)); lv_obj_set_size(buttonStepMode, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - //lv_obj_set_event_cb(buttonMachine, event_handler); lv_obj_set_event_cb_mks(buttonStepMode, event_handler, ID_MOTOR_STEP_MODE, NULL, 0); lv_btn_set_style(buttonStepMode, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ lv_btn_set_style(buttonStepMode, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ lv_btn_set_layout(buttonStepMode, LV_LAYOUT_OFF); labelStepMode = lv_label_create(buttonStepMode, NULL); /*Add a label to the button*/ + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonStepMode); + #endif + buttonStepModeNarrow = lv_imgbtn_create(scr, NULL); - lv_obj_set_pos(buttonStepModeNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V); - lv_obj_set_event_cb_mks(buttonStepModeNarrow, event_handler, ID_MOTOR_STEP_MODE_ARROW, "bmp_arrow.bin", 0); - lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_REL, &bmp_para_arrow); - lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_PR, &bmp_para_arrow); + lv_obj_set_pos(buttonStepModeNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 4, PARA_UI_POS_Y * 3) + PARA_UI_ARROW_V); + lv_obj_set_event_cb_mks(buttonStepModeNarrow, event_handler, ID_MOTOR_STEP_MODE_ARROW, NULL, 0); + lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); + lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); lv_imgbtn_set_style(buttonStepModeNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonStepModeNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonStepModeNarrow, LV_LAYOUT_OFF); - line3 = lv_line_create(lv_scr_act(), NULL); - lv_ex_line(line3, line_points[2]); - #endif + #if USE_SENSORLESS + line4 = lv_line_create(scr, NULL); + lv_ex_line(line4, line_points[3]); + #else + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3, line_points[2]); + #endif + + #endif // HAS_STEALTHCHOP + #endif // HAS_TRINAMIC_CONFIG buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MOTOR_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MOTOR_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); label_Back = lv_label_create(buttonBack, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + if (gCfgItems.multiple_language != 0) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); lv_label_set_text(labelSteps, machine_menu.StepsConf); lv_obj_align(labelSteps, buttonSteps, LV_ALIGN_IN_LEFT_MID, 0, 0); + + #if USE_SENSORLESS + lv_label_set_text(labelSensitivity, machine_menu.HomingSensitivityConf); + lv_obj_align(labelSensitivity, buttonSensitivity, LV_ALIGN_IN_LEFT_MID, 0, 0); + #endif #if HAS_TRINAMIC_CONFIG lv_label_set_text(labelTMCcurrent, machine_menu.TMCcurrentConf); lv_obj_align(labelTMCcurrent, buttonTMCcurrent, LV_ALIGN_IN_LEFT_MID, 0, 0); @@ -242,6 +333,11 @@ void lv_draw_motor_settings(void) { } -void lv_clear_motor_settings() { lv_obj_del(scr); } +void lv_clear_motor_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp index 24abadb57c9a..a6c0c0551aba 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp @@ -32,6 +32,7 @@ #include "draw_ui.h" #include "../../../../gcode/queue.h" +extern lv_group_t * g; static lv_obj_t * scr; static lv_obj_t *labelV, *buttonV; @@ -179,8 +180,6 @@ void lv_draw_move_motor(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - // Create an Image button buttonXI = lv_imgbtn_create(scr, NULL); buttonXD = lv_imgbtn_create(scr, NULL); @@ -191,55 +190,56 @@ void lv_draw_move_motor(void) { buttonV = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_M_X_P, "bmp_xAdd.bin", 0); - lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_M_X_P, NULL, 0); + lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, "F:/bmp_xAdd.bin"); + lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, "F:/bmp_xAdd.bin"); lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_REL, &tft_style_label_rel); lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW); + #if 1 - lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_M_X_N, "bmp_xDec.bin", 0); - lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_M_X_N, NULL, 0); + lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, "F:/bmp_xDec.bin"); + lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, "F:/bmp_xDec.bin"); lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_M_Y_P, "bmp_yAdd.bin", 0); - lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_M_Y_P, NULL, 0); + lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, "F:/bmp_yAdd.bin"); + lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, "F:/bmp_yAdd.bin"); lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_M_Y_N, "bmp_yDec.bin", 0); - lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_M_Y_N, NULL, 0); + lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, "F:/bmp_yDec.bin"); + lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, "F:/bmp_yDec.bin"); lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_M_Z_P, "bmp_zAdd.bin", 0); - lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_M_Z_P, NULL, 0); + lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, "F:/bmp_zAdd.bin"); + lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, "F:/bmp_zAdd.bin"); lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_M_Z_N, "bmp_zDec.bin", 0); - lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_M_Z_N, NULL, 0); + lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, "F:/bmp_zDec.bin"); + lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, "F:/bmp_zDec.bin"); lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_REL, &tft_style_label_rel); //lv_obj_set_event_cb_mks(buttonV, event_handler,ID_T_MORE,"bmp_More.bin",0); - lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, NULL, 0); lv_imgbtn_set_style(buttonV, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonV, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_M_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_M_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); #endif // if 1 + lv_obj_set_pos(buttonXI, INTERVAL_V, titleHeight); lv_obj_set_pos(buttonYI, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); lv_obj_set_pos(buttonZI, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); @@ -290,6 +290,18 @@ void lv_draw_move_motor(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonXI); + lv_group_add_obj(g, buttonXD); + lv_group_add_obj(g, buttonYI); + lv_group_add_obj(g, buttonYD); + lv_group_add_obj(g, buttonZI); + lv_group_add_obj(g, buttonZD); + lv_group_add_obj(g, buttonV); + lv_group_add_obj(g, buttonBack); + } + #endif disp_move_dist(); } @@ -297,12 +309,18 @@ void lv_draw_move_motor(void) { void disp_move_dist() { // char buf[30] = {0}; - if ((int)(10 * uiCfg.move_dist) == 1) - lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move0_1.bin", 0); - else if ((int)(10 * uiCfg.move_dist) == 10) - lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move1.bin", 0); - else if ((int)(10 * uiCfg.move_dist) == 100) - lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move10.bin", 0); + if ((int)(10 * uiCfg.move_dist) == 1) { + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move0_1.bin"); + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move0_1.bin"); + } + else if ((int)(10 * uiCfg.move_dist) == 10) { + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move1.bin"); + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move1.bin"); + } + else if ((int)(10 * uiCfg.move_dist) == 100) { + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move10.bin"); + lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move10.bin"); + } if (gCfgItems.multiple_language != 0) { if ((int)(10 * uiCfg.move_dist) == 1) { lv_label_set_text(labelV, move_menu.step_01mm); @@ -319,6 +337,11 @@ void disp_move_dist() { } } -void lv_clear_move_motor() { lv_obj_del(scr); } +void lv_clear_move_motor() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp index 2fe32b04c934..4842776304d7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp @@ -47,6 +47,11 @@ #include "../../../../feature/tmc_util.h" #endif +#if HAS_BED_PROBE + #include "../../../../module/probe.h" +#endif + +extern lv_group_t * g; static lv_obj_t * scr; static lv_obj_t *buttonValue = NULL; static lv_obj_t *labelValue = NULL; @@ -77,113 +82,92 @@ static void disp_key_value() { float milliamps; #endif + ZERO(public_buf_m); + switch (value) { case PrintAcceleration: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.acceleration); break; case RetractAcceleration: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.retract_acceleration); break; case TravelAcceleration: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.travel_acceleration); break; case XAcceleration: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]); break; case YAcceleration: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); break; case ZAcceleration: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); break; case E0Acceleration: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]); break; case E1Acceleration: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]); break; case XMaxFeedRate: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]); break; case YMaxFeedRate: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]); break; case ZMaxFeedRate: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]); break; case E0MaxFeedRate: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]); break; case E1MaxFeedRate: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]); break; case XJerk: #if HAS_CLASSIC_JERK - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[X_AXIS]); #endif break; case YJerk: #if HAS_CLASSIC_JERK - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[Y_AXIS]); #endif break; case ZJerk: #if HAS_CLASSIC_JERK - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[Z_AXIS]); #endif break; case EJerk: #if HAS_CLASSIC_JERK - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[E_AXIS]); #endif break; case Xstep: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]); break; case Ystep: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Y_AXIS]); break; case Zstep: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Z_AXIS]); break; case E0step: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]); break; case E1step: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]); break; case Xcurrent: #if AXIS_IS_TMC(X) - ZERO(public_buf_m); milliamps = stepperX.getMilliamps(); sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); #endif @@ -191,7 +175,6 @@ static void disp_key_value() { case Ycurrent: #if AXIS_IS_TMC(Y) - ZERO(public_buf_m); milliamps = stepperY.getMilliamps(); sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); #endif @@ -199,7 +182,6 @@ static void disp_key_value() { case Zcurrent: #if AXIS_IS_TMC(Z) - ZERO(public_buf_m); milliamps = stepperZ.getMilliamps(); sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); #endif @@ -207,7 +189,6 @@ static void disp_key_value() { case E0current: #if AXIS_IS_TMC(E0) - ZERO(public_buf_m); milliamps = stepperE0.getMilliamps(); sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); #endif @@ -215,24 +196,100 @@ static void disp_key_value() { case E1current: #if AXIS_IS_TMC(E1) - ZERO(public_buf_m); milliamps = stepperE1.getMilliamps(); sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); #endif break; case pause_pos_x: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosX); break; case pause_pos_y: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosY); break; case pause_pos_z: - ZERO(public_buf_m); sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosZ); break; + case level_pos_x1: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[0][0]); + break; + case level_pos_y1: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[0][1]); + break; + case level_pos_x2: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[1][0]); + break; + case level_pos_y2: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[1][1]); + break; + case level_pos_x3: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[2][0]); + break; + case level_pos_y3: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[2][1]); + break; + case level_pos_x4: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[3][0]); + break; + case level_pos_y4: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[3][1]); + break; + case level_pos_x5: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[4][0]); + break; + case level_pos_y5: + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[4][1]); + break; + #if HAS_BED_PROBE + case x_offset: + #if HAS_PROBE_XY_OFFSET + sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.x); + #endif + break; + case y_offset: + #if HAS_PROBE_XY_OFFSET + sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.y); + #endif + break; + case z_offset: + sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.z); + break; + #endif + case load_length: + sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_load_length); + break; + case load_speed: + sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_load_speed); + break; + case unload_length: + sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_length); + break; + case unload_speed: + sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_speed); + break; + case filament_temp: + sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temper); + break; + case x_sensitivity: + #if X_SENSORLESS + sprintf_P(public_buf_m, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0)); + #endif + break; + case y_sensitivity: + #if Y_SENSORLESS + sprintf_P(public_buf_m, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0)); + #endif + break; + case z_sensitivity: + #if Z_SENSORLESS + sprintf_P(public_buf_m, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0)); + #endif + break; + case z2_sensitivity: + #if Z2_SENSORLESS + sprintf_P(public_buf_m, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0)); + #endif + break; } ZERO(key_value); strcpy(key_value, public_buf_m); @@ -313,18 +370,23 @@ static void set_value_confirm() { break; case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); + planner.refresh_positioning(); break; case Ystep: planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); + planner.refresh_positioning(); break; case Zstep: planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); + planner.refresh_positioning(); break; case E0step: planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value); + planner.refresh_positioning(); break; case E1step: planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); + planner.refresh_positioning(); break; case Xcurrent: #if AXIS_IS_TMC(X) @@ -368,6 +430,114 @@ static void set_value_confirm() { gCfgItems.pausePosZ = atof(key_value); update_spi_flash(); break; + case level_pos_x1: + gCfgItems.levelingPos[0][0] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_y1: + gCfgItems.levelingPos[0][1] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_x2: + gCfgItems.levelingPos[1][0] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_y2: + gCfgItems.levelingPos[1][1] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_x3: + gCfgItems.levelingPos[2][0] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_y3: + gCfgItems.levelingPos[2][1] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_x4: + gCfgItems.levelingPos[3][0] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_y4: + gCfgItems.levelingPos[3][1] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_x5: + gCfgItems.levelingPos[4][0] = atoi(key_value); + update_spi_flash(); + break; + case level_pos_y5: + gCfgItems.levelingPos[4][1] = atoi(key_value); + update_spi_flash(); + break; + #if HAS_BED_PROBE + case x_offset: + #if HAS_PROBE_XY_OFFSET + float x; + x = atof(key_value); + if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE)) + probe.offset.x = x; + #endif + break; + case y_offset: + #if HAS_PROBE_XY_OFFSET + float y; + y = atof(key_value); + if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE)) + probe.offset.y = y; + #endif + break; + case z_offset: + float z; + z = atof(key_value); + if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) + probe.offset.z = z; + break; + #endif + case load_length: + gCfgItems.filamentchange_load_length = atoi(key_value); + uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5); + update_spi_flash(); + break; + case load_speed: + gCfgItems.filamentchange_load_speed = atoi(key_value); + uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5); + update_spi_flash(); + break; + case unload_length: + gCfgItems.filamentchange_unload_length = atoi(key_value); + uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5); + update_spi_flash(); + break; + case unload_speed: + gCfgItems.filamentchange_unload_speed = atoi(key_value); + uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5); + update_spi_flash(); + break; + case filament_temp: + gCfgItems.filament_limit_temper = atoi(key_value); + update_spi_flash(); + break; + case x_sensitivity: + #if X_SENSORLESS + stepperX.homing_threshold(atoi(key_value)); + #endif + break; + case y_sensitivity: + #if Y_SENSORLESS + stepperY.homing_threshold(atoi(key_value)); + #endif + break; + case z_sensitivity: + #if Z_SENSORLESS + stepperZ.homing_threshold(atoi(key_value)); + #endif + break; + case z2_sensitivity: + #if Z2_SENSORLESS + stepperZ2.homing_threshold(atoi(key_value)); + #endif + break; } gcode.process_subcommands_now_P(PSTR("M500")); } @@ -604,15 +774,13 @@ void lv_draw_number_key(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - //LV_IMG_DECLARE(bmp_pic); - buttonValue = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_set_pos(buttonValue, 92, 40); /*Set its position*/ lv_obj_set_size(buttonValue, 296, 40); lv_obj_set_event_cb_mks(buttonValue, event_handler, ID_NUM_KEY1, NULL, 0); lv_btn_set_style(buttonValue, LV_BTN_STYLE_REL, &style_num_text); /*Set the button's released style*/ lv_btn_set_style(buttonValue, LV_BTN_STYLE_PR, &style_num_text); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonValue, LV_LAYOUT_OFF); + //lv_btn_set_layout(buttonValue, LV_LAYOUT_OFF); labelValue = lv_label_create(buttonValue, NULL); /*Add a label to the button*/ NumberKey_1 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ @@ -621,7 +789,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_1, event_handler, ID_NUM_KEY1, NULL, 0); lv_btn_set_style(NumberKey_1, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_1, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_1, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_1, LV_LAYOUT_OFF); labelKey_1 = lv_label_create(NumberKey_1, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_1, machine_menu.key_1); lv_obj_align(labelKey_1, NumberKey_1, LV_ALIGN_CENTER, 0, 0); @@ -632,7 +800,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_2, event_handler, ID_NUM_KEY2, NULL, 0); lv_btn_set_style(NumberKey_2, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_2, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_2, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_2, LV_LAYOUT_OFF); labelKey_2 = lv_label_create(NumberKey_2, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_2, machine_menu.key_2); lv_obj_align(labelKey_2, NumberKey_2, LV_ALIGN_CENTER, 0, 0); @@ -643,7 +811,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_3, event_handler, ID_NUM_KEY3, NULL, 0); lv_btn_set_style(NumberKey_3, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_3, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_3, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_3, LV_LAYOUT_OFF); labelKey_3 = lv_label_create(NumberKey_3, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_3, machine_menu.key_3); lv_obj_align(labelKey_3, NumberKey_3, LV_ALIGN_CENTER, 0, 0); @@ -654,7 +822,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_4, event_handler, ID_NUM_KEY4, NULL, 0); lv_btn_set_style(NumberKey_4, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_4, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_4, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_4, LV_LAYOUT_OFF); labelKey_4 = lv_label_create(NumberKey_4, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_4, machine_menu.key_4); lv_obj_align(labelKey_4, NumberKey_4, LV_ALIGN_CENTER, 0, 0); @@ -665,7 +833,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_5, event_handler, ID_NUM_KEY5, NULL, 0); lv_btn_set_style(NumberKey_5, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_5, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_5, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_5, LV_LAYOUT_OFF); labelKey_5 = lv_label_create(NumberKey_5, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_5, machine_menu.key_5); lv_obj_align(labelKey_5, NumberKey_5, LV_ALIGN_CENTER, 0, 0); @@ -676,7 +844,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_6, event_handler, ID_NUM_KEY6, NULL, 0); lv_btn_set_style(NumberKey_6, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_6, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_6, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_6, LV_LAYOUT_OFF); labelKey_6 = lv_label_create(NumberKey_6, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_6, machine_menu.key_6); lv_obj_align(labelKey_6, NumberKey_6, LV_ALIGN_CENTER, 0, 0); @@ -687,7 +855,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_7, event_handler, ID_NUM_KEY7, NULL, 0); lv_btn_set_style(NumberKey_7, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_7, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_7, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_7, LV_LAYOUT_OFF); labelKey_7 = lv_label_create(NumberKey_7, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_7, machine_menu.key_7); lv_obj_align(labelKey_7, NumberKey_7, LV_ALIGN_CENTER, 0, 0); @@ -698,7 +866,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_8, event_handler, ID_NUM_KEY8, NULL, 0); lv_btn_set_style(NumberKey_8, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_8, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_8, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_8, LV_LAYOUT_OFF); labelKey_8 = lv_label_create(NumberKey_8, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_8, machine_menu.key_8); lv_obj_align(labelKey_8, NumberKey_8, LV_ALIGN_CENTER, 0, 0); @@ -709,7 +877,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_9, event_handler, ID_NUM_KEY9, NULL, 0); lv_btn_set_style(NumberKey_9, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_9, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_9, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_9, LV_LAYOUT_OFF); labelKey_9 = lv_label_create(NumberKey_9, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_9, machine_menu.key_9); lv_obj_align(labelKey_9, NumberKey_9, LV_ALIGN_CENTER, 0, 0); @@ -720,7 +888,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(NumberKey_0, event_handler, ID_NUM_KEY0, NULL, 0); lv_btn_set_style(NumberKey_0, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(NumberKey_0, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(NumberKey_0, LV_LAYOUT_OFF); + //lv_btn_set_layout(NumberKey_0, LV_LAYOUT_OFF); labelKey_0 = lv_label_create(NumberKey_0, NULL); /*Add a label to the button*/ lv_label_set_text(labelKey_0, machine_menu.key_0); lv_obj_align(labelKey_0, NumberKey_0, LV_ALIGN_CENTER, 0, 0); @@ -731,7 +899,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(KeyBack, event_handler, ID_NUM_BACK, NULL, 0); lv_btn_set_style(KeyBack, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(KeyBack, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(KeyBack, LV_LAYOUT_OFF); + //lv_btn_set_layout(KeyBack, LV_LAYOUT_OFF); labelKeyBack = lv_label_create(KeyBack, NULL); /*Add a label to the button*/ lv_label_set_text(labelKeyBack, machine_menu.key_back); lv_obj_align(labelKeyBack, KeyBack, LV_ALIGN_CENTER, 0, 0); @@ -742,7 +910,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(KeyReset, event_handler, ID_NUM_RESET, NULL, 0); lv_btn_set_style(KeyReset, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(KeyReset, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(KeyReset, LV_LAYOUT_OFF); + //lv_btn_set_layout(KeyReset, LV_LAYOUT_OFF); labelKeyReset = lv_label_create(KeyReset, NULL); /*Add a label to the button*/ lv_label_set_text(labelKeyReset, machine_menu.key_reset); lv_obj_align(labelKeyReset, KeyReset, LV_ALIGN_CENTER, 0, 0); @@ -753,7 +921,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(KeyConfirm, event_handler, ID_NUM_CONFIRM, NULL, 0); lv_btn_set_style(KeyConfirm, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(KeyConfirm, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(KeyConfirm, LV_LAYOUT_OFF); + //lv_btn_set_layout(KeyConfirm, LV_LAYOUT_OFF); labelKeyConfirm = lv_label_create(KeyConfirm, NULL); /*Add a label to the button*/ lv_label_set_text(labelKeyConfirm, machine_menu.key_confirm); lv_obj_align(labelKeyConfirm, KeyConfirm, LV_ALIGN_CENTER, 0, 0); @@ -764,7 +932,7 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(KeyPoint, event_handler, ID_NUM_POINT, NULL, 0); lv_btn_set_style(KeyPoint, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(KeyPoint, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(KeyPoint, LV_LAYOUT_OFF); + //lv_btn_set_layout(KeyPoint, LV_LAYOUT_OFF); labelKeyPoint = lv_label_create(KeyPoint, NULL); /*Add a label to the button*/ lv_label_set_text(labelKeyPoint, machine_menu.key_point); lv_obj_align(labelKeyPoint, KeyPoint, LV_ALIGN_CENTER, 0, 0); @@ -775,14 +943,39 @@ void lv_draw_number_key(void) { lv_obj_set_event_cb_mks(Minus, event_handler, ID_NUM_NAGETIVE, NULL, 0); lv_btn_set_style(Minus, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/ lv_btn_set_style(Minus, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/ - lv_btn_set_layout(Minus, LV_LAYOUT_OFF); + //lv_btn_set_layout(Minus, LV_LAYOUT_OFF); labelMinus = lv_label_create(Minus, NULL); /*Add a label to the button*/ lv_label_set_text(labelMinus, machine_menu.negative); lv_obj_align(labelMinus, Minus, LV_ALIGN_CENTER, 0, 0); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, NumberKey_1); + lv_group_add_obj(g, NumberKey_2); + lv_group_add_obj(g, NumberKey_3); + lv_group_add_obj(g, KeyBack); + lv_group_add_obj(g, NumberKey_4); + lv_group_add_obj(g, NumberKey_5); + lv_group_add_obj(g, NumberKey_6); + lv_group_add_obj(g, KeyReset); + lv_group_add_obj(g, NumberKey_7); + lv_group_add_obj(g, NumberKey_8); + lv_group_add_obj(g, NumberKey_9); + lv_group_add_obj(g, NumberKey_0); + lv_group_add_obj(g, Minus); + lv_group_add_obj(g, KeyPoint); + lv_group_add_obj(g, KeyConfirm); + } + #endif + disp_key_value(); } -void lv_clear_number_key() { lv_obj_del(scr); } +void lv_clear_number_key() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp index ad8cad03e0c3..4a4a0ee1305b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp @@ -31,7 +31,11 @@ //#include "../lvgl/src/lv_core/lv_refr.h" #include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" +#include "../../../../module/motion.h" +#include "../../../../sd/cardreader.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_O_PRE_HEAT 1 @@ -42,10 +46,13 @@ static lv_obj_t * scr; #define ID_O_RETURN 6 #define ID_O_FAN 7 #define ID_O_POWER_OFF 8 +#define ID_O_BABY_STEP 9 static lv_obj_t *label_PowerOff; static lv_obj_t *buttonPowerOff; +extern feedRate_t feedrate_mm_s; + static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_O_PRE_HEAT: @@ -80,6 +87,20 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { + #if HAS_MULTI_EXTRUDER + uiCfg.curSprayerChoose_bak = active_extruder; + #endif + if (uiCfg.print_state == WORKING) { + #if ENABLED(SDSUPPORT) + card.pauseSDPrint(); + stop_print_time(); + uiCfg.print_state = PAUSING; + #endif + } + uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s; + uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[active_extruder].target; + lv_clear_operation(); + lv_draw_filament_change(); } break; case ID_O_FAN: @@ -116,7 +137,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { else if (event == LV_EVENT_RELEASED) { if (gCfgItems.finish_power_off == 1) { gCfgItems.finish_power_off = 0; - lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_manual_off.bin", 0); // didn't find bmp_Mamual... + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin"); + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin"); lv_label_set_text(label_PowerOff, printing_more_menu.manual); lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_obj_refresh_ext_draw_pad(label_PowerOff); @@ -124,7 +146,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else { gCfgItems.finish_power_off = 1; - lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_auto_off.bin", 0); + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_auto_off.bin"); + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_auto_off.bin"); lv_label_set_text(label_PowerOff, printing_more_menu.auto_close); lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_obj_refresh_ext_draw_pad(label_PowerOff); @@ -132,16 +155,26 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } } break; - + case ID_O_BABY_STEP: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_operation(); + lv_draw_baby_stepping(); + } + break; } } void lv_draw_operation(void) { - lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonSpeed; - lv_obj_t *buttonBack, *buttonFan; - lv_obj_t *labelPreHeat, *labelExtrusion; - lv_obj_t *label_Back, *label_Speed, *label_Fan; + lv_obj_t *buttonPreHeat = NULL, *buttonExtrusion = NULL, *buttonSpeed = NULL; + lv_obj_t *buttonBack = NULL, *buttonFan = NULL; + lv_obj_t *labelPreHeat = NULL, *labelExtrusion = NULL; + lv_obj_t *label_Back = NULL, *label_Speed = NULL, *label_Fan = NULL; lv_obj_t *buttonMove = NULL, *label_Move = NULL; + lv_obj_t *buttonBabyStep = NULL, *label_BabyStep = NULL; + lv_obj_t *buttonFilament = NULL, *label_Filament = NULL; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != OPERATE_UI) { disp_state_stack._disp_index++; @@ -162,143 +195,188 @@ void lv_draw_operation(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - - /*Create an Image button*/ - buttonPreHeat = lv_imgbtn_create(scr, NULL); - buttonExtrusion = lv_imgbtn_create(scr, NULL); - buttonFan = lv_imgbtn_create(scr, NULL); - buttonSpeed = lv_imgbtn_create(scr, NULL); - + // Create image buttons + buttonPreHeat = lv_imgbtn_create(scr, NULL); + buttonFilament = lv_imgbtn_create(scr, NULL); + buttonFan = lv_imgbtn_create(scr, NULL); + buttonPowerOff = lv_imgbtn_create(scr, NULL); if (uiCfg.print_state != WORKING) { - //buttonFilament = lv_imgbtn_create(scr, NULL); - //} else { - buttonMove = lv_imgbtn_create(scr, NULL); + buttonExtrusion = lv_imgbtn_create(scr, NULL); + buttonMove = lv_imgbtn_create(scr, NULL); } + else { + buttonSpeed = lv_imgbtn_create(scr, NULL); + buttonBabyStep = lv_imgbtn_create(scr, NULL); + } + buttonBack = lv_imgbtn_create(scr, NULL); - buttonPowerOff = lv_imgbtn_create(scr, NULL); - buttonBack = lv_imgbtn_create(scr, NULL); - - lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_O_PRE_HEAT, "bmp_temp.bin", 0); - lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_O_PRE_HEAT, NULL, 0); + lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, "F:/bmp_temp.bin"); + lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, "F:/bmp_temp.bin"); lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_clear_protect(buttonPreHeat, LV_PROTECT_FOLLOW); + + lv_obj_set_event_cb_mks(buttonFilament, event_handler, ID_O_FILAMENT, NULL, 0); + lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, "F:/bmp_filamentchange.bin"); + lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, "F:/bmp_filamentchange.bin"); + lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel); + #if 1 - lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_O_EXTRUCT, "bmp_extrude_opr.bin", 0); - lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_O_FAN, "bmp_fan.bin", 0); - lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_O_FAN, NULL, 0); + lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, "F:/bmp_fan.bin"); + lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, "F:/bmp_fan.bin"); lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_O_SPEED, "bmp_speed.bin", 0); - lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel); + if (gCfgItems.finish_power_off == 1) { + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_auto_off.bin"); + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_auto_off.bin"); + } + else { + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin"); + lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin"); + } + lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, NULL, 0); + lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_REL, &tft_style_label_rel); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonPreHeat); + lv_group_add_obj(g, buttonFilament); + lv_group_add_obj(g, buttonFan); + lv_group_add_obj(g, buttonPowerOff); + } + #endif if (uiCfg.print_state != WORKING) { - /* - lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_O_FILAMENT,"bmp_Filamentchange.bin",0); - lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel); - } else { - */ - lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_O_MOV, "bmp_move_opr.bin", 0); - lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_O_EXTRUCT, NULL, 0); + lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, "F:/bmp_extrude_opr.bin"); + lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, "F:/bmp_extrude_opr.bin"); + lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_O_MOV, NULL, 0); + lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, "F:/bmp_move_opr.bin"); + lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, "F:/bmp_move_opr.bin"); lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonExtrusion); + lv_group_add_obj(g, buttonMove); + } + #endif + } + else { + lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_O_SPEED, NULL, 0); + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed.bin"); + lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed.bin"); + lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonBabyStep, event_handler, ID_O_BABY_STEP, NULL, 0); + lv_imgbtn_set_src(buttonBabyStep, LV_BTN_STATE_REL, "F:/bmp_mov.bin"); + lv_imgbtn_set_src(buttonBabyStep, LV_BTN_STATE_PR, "F:/bmp_mov.bin"); + lv_imgbtn_set_style(buttonBabyStep, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBabyStep, LV_BTN_STATE_REL, &tft_style_label_rel); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonSpeed); + lv_group_add_obj(g, buttonBabyStep); + } + #endif } - if (gCfgItems.finish_power_off == 1) - lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_auto_off.bin", 0); - else - lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_manual_off.bin", 0); - lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_O_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_O_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); #endif // if 1 - lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight); - lv_obj_set_pos(buttonExtrusion, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonFilament, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); lv_obj_set_pos(buttonFan, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); - lv_obj_set_pos(buttonSpeed, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + lv_obj_set_pos(buttonPowerOff, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); if (uiCfg.print_state != WORKING) { /* lv_obj_set_pos(buttonFilament,INTERVAL_V,BTN_Y_PIXEL+INTERVAL_H+titleHeight); } else { */ - lv_obj_set_pos(buttonMove, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - lv_obj_set_pos(buttonPowerOff, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonExtrusion, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonMove, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); } else { - lv_obj_set_pos(buttonPowerOff, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonSpeed, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + lv_obj_set_pos(buttonBabyStep, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); } + lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + // Create labels on the image buttons lv_btn_set_layout(buttonPreHeat, LV_LAYOUT_OFF); - lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF); lv_btn_set_layout(buttonFan, LV_LAYOUT_OFF); - lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonPowerOff, LV_LAYOUT_OFF); if (uiCfg.print_state != WORKING) { /* lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF); } else { */ + lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF); lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF); } - lv_btn_set_layout(buttonPowerOff, LV_LAYOUT_OFF); + else { + lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBabyStep, LV_LAYOUT_OFF); + } + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); labelPreHeat = lv_label_create(buttonPreHeat, NULL); - labelExtrusion = lv_label_create(buttonExtrusion, NULL); - + label_Filament = lv_label_create(buttonFilament, NULL); label_Fan = lv_label_create(buttonFan, NULL); - label_Speed = lv_label_create(buttonSpeed, NULL); + label_PowerOff = lv_label_create(buttonPowerOff, NULL); if (uiCfg.print_state != WORKING) { /* label_Filament = lv_label_create(buttonFilament, NULL); } else { */ - label_Move = lv_label_create(buttonMove, NULL); + labelExtrusion = lv_label_create(buttonExtrusion, NULL); + label_Move = lv_label_create(buttonMove, NULL); + } + else { + label_Speed = lv_label_create(buttonSpeed, NULL); + label_BabyStep = lv_label_create(buttonBabyStep, NULL); } - label_PowerOff = lv_label_create(buttonPowerOff, NULL); - label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelPreHeat, operation_menu.temp); lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - lv_label_set_text(labelExtrusion, operation_menu.extr); - lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + lv_label_set_text(label_Filament, operation_menu.filament); + lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_label_set_text(label_Fan, operation_menu.fan); lv_obj_align(label_Fan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - lv_label_set_text(label_Speed, operation_menu.speed); - lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + if (gCfgItems.finish_power_off == 1) + lv_label_set_text(label_PowerOff, printing_more_menu.auto_close); + else + lv_label_set_text(label_PowerOff, printing_more_menu.manual); + lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); if (uiCfg.print_state != WORKING) { /* @@ -306,21 +384,30 @@ void lv_draw_operation(void) { lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); } else { */ + lv_label_set_text(labelExtrusion, operation_menu.extr); + lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + lv_label_set_text(label_Move, operation_menu.move); lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + else { + lv_label_set_text(label_Speed, operation_menu.speed); + lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - if (gCfgItems.finish_power_off == 1) - lv_label_set_text(label_PowerOff, printing_more_menu.auto_close); - else - lv_label_set_text(label_PowerOff, printing_more_menu.manual); - lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + lv_label_set_text(label_BabyStep, operation_menu.babystep); + lv_obj_align(label_BabyStep, buttonBabyStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } } -void lv_clear_operation() { lv_obj_del(scr); } +void lv_clear_operation() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp index 56caf812b1f9..9b99971f4f96 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp @@ -29,6 +29,7 @@ #include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_PAUSE_RETURN 1 @@ -82,9 +83,9 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { void lv_draw_pause_position(void) { lv_obj_t *buttonBack = NULL, *label_Back = NULL; - lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; - lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; - lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; + lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; + lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; + lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PAUSE_POS_UI) { @@ -106,85 +107,60 @@ void lv_draw_pause_position(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - // LV_IMG_DECLARE(bmp_para_arrow); - LV_IMG_DECLARE(bmp_para_bank); + labelXText = lv_label_create(scr, NULL); + lv_obj_set_style(labelXText, &tft_style_label_rel); + lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelXText, machine_menu.xPos); - buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonXText, event_handler); - lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF); - labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/ - - buttonXValue = lv_imgbtn_create(scr, NULL); + buttonXValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_PAUSE_X, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); + lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_PAUSE_X, NULL, 0); labelXValue = lv_label_create(buttonXValue, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonYText, event_handler); - lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF); - labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/ + labelYText = lv_label_create(scr, NULL); + lv_obj_set_style(labelYText, &tft_style_label_rel); + lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelYText, machine_menu.yPos); - buttonYValue = lv_imgbtn_create(scr, NULL); + buttonYValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_PAUSE_Y, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_PAUSE_Y, NULL, 0); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); labelYValue = lv_label_create(buttonYValue, NULL); line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); - buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ - lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonZText, event_handler); - lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF); - labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/ + labelZText = lv_label_create(scr, NULL); + lv_obj_set_style(labelZText, &tft_style_label_rel); + lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelZText, machine_menu.zPos); - buttonZValue = lv_imgbtn_create(scr, NULL); + buttonZValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_PAUSE_Z, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_PAUSE_Z, NULL, 0); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); labelZValue = lv_label_create(buttonZValue, NULL); line3 = lv_line_create(scr, NULL); lv_ex_line(line3, line_points[2]); - buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PAUSE_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); - + buttonBack = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); - lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PAUSE_RETURN, NULL, 0); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { @@ -203,20 +179,24 @@ void lv_draw_pause_position(void) { lv_label_set_text(labelZValue, public_buf_l); lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0); - lv_label_set_text(labelXText, machine_menu.xPos); - lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelYText, machine_menu.yPos); - lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelZText, machine_menu.zPos); - lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0); - lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonXValue); + lv_group_add_obj(g, buttonYValue); + lv_group_add_obj(g, buttonZValue); + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_pause_position() { lv_obj_del(scr); } +void lv_clear_pause_position() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp index ff7641ddfda3..f58a47b341b6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -34,9 +34,10 @@ #include "../../../../module/temperature.h" static lv_obj_t * scr; +extern lv_group_t* g; static lv_obj_t *buttoType, *buttonStep; -static lv_obj_t * labelType; -static lv_obj_t * labelStep; +static lv_obj_t *labelType; +static lv_obj_t *labelStep; static lv_obj_t * tempText1; #define ID_P_ADD 1 @@ -58,23 +59,22 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { if (uiCfg.curSprayerChoose == 0) { if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); } } #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); } #endif + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); } #if HAS_HEATED_BED else { thermalManager.temp_bed.target += uiCfg.stepHeat; if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) { thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1); - thermalManager.start_watching_bed(); } + thermalManager.start_watching_bed(); } #endif disp_desire_temp(); @@ -88,23 +88,21 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { if (uiCfg.curTempType == 0) { if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat; - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); } else { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0; - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); } + thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); } #if HAS_HEATED_BED else { if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat) { thermalManager.temp_bed.target -= uiCfg.stepHeat; - thermalManager.start_watching_bed(); } else { thermalManager.temp_bed.target = (float)0; - thermalManager.start_watching_bed(); } + thermalManager.start_watching_bed(); } #endif disp_desire_temp(); @@ -212,9 +210,7 @@ void lv_draw_preHeat(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - - /*Create an Image button*/ + // Create image buttons buttonAdd = lv_imgbtn_create(scr, NULL); buttonDec = lv_imgbtn_create(scr, NULL); buttoType = lv_imgbtn_create(scr, NULL); @@ -222,40 +218,37 @@ void lv_draw_preHeat(void) { buttonOff = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_P_ADD, "bmp_Add.bin", 0); - lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_P_ADD, NULL, 0); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin"); + lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin"); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel); lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); + #if 1 - lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_P_DEC, "bmp_Dec.bin", 0); - lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_P_DEC, NULL, 0); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin"); + lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin"); lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, NULL, 0); lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, NULL, 0); lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonOff, event_handler, ID_P_OFF, "bmp_speed0.bin", 0); - lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonOff, event_handler, ID_P_OFF, NULL, 0); + lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, "F:/bmp_speed0.bin"); + lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, "F:/bmp_speed0.bin"); lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); #endif @@ -295,6 +288,16 @@ void lv_draw_preHeat(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonAdd); + lv_group_add_obj(g, buttonDec); + lv_group_add_obj(g, buttoType); + lv_group_add_obj(g, buttonStep); + lv_group_add_obj(g, buttonOff); + lv_group_add_obj(g, buttonBack); + } + #endif disp_temp_type(); disp_step_heat(); @@ -307,14 +310,16 @@ void lv_draw_preHeat(void) { void disp_temp_type() { if (uiCfg.curTempType == 0) { if (uiCfg.curSprayerChoose == 1) { - lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_extru2.bin", 0); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin"); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin"); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelType, preheat_menu.ext2); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } } else { - lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_extru1.bin", 0); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin"); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin"); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelType, preheat_menu.ext1); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -323,7 +328,8 @@ void disp_temp_type() { } else { - lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_bed.bin", 0); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_bed.bin"); + lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_bed.bin"); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelType, preheat_menu.hotbed); lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -356,12 +362,18 @@ void disp_desire_temp() { } void disp_step_heat() { - if (uiCfg.stepHeat == 1) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step1_degree.bin", 0); - else if (uiCfg.stepHeat == 5) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step5_degree.bin", 0); - else if (uiCfg.stepHeat == 10) - lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step10_degree.bin", 0); + if (uiCfg.stepHeat == 1) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_degree.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_degree.bin"); + } + else if (uiCfg.stepHeat == 5) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_degree.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_degree.bin"); + } + else if (uiCfg.stepHeat == 10) { + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_degree.bin"); + lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_degree.bin"); + } if (gCfgItems.multiple_language != 0) { if (uiCfg.stepHeat == 1) { @@ -379,6 +391,11 @@ void disp_step_heat() { } } -void lv_clear_preHeat() { lv_obj_del(scr); } +void lv_clear_preHeat() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp index 13a92269f8a0..add0f0394b3f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp @@ -33,6 +33,7 @@ #include "../../../../sd/cardreader.h" static lv_obj_t * scr; +extern lv_group_t* g; static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack, *buttonGcode[FILE_BTN_CNT], *labelPageUp[FILE_BTN_CNT], *buttonText[FILE_BTN_CNT]; @@ -132,11 +133,6 @@ uint8_t have_pre_pic(char *path) { return 0; } -LV_IMG_DECLARE(bmp_pic_117x92); -LV_IMG_DECLARE(bmp_pic_100x100); -LV_IMG_DECLARE(bmp_pic); -LV_IMG_DECLARE(bmp_pic_100x40); - static void event_handler(lv_obj_t * obj, lv_event_t event) { uint8_t i, file_count = 0; //switch (obj->mks_obj_id) @@ -157,7 +153,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { #endif if (file_count != 0) { dir_offset[curDirLever].curPage--; - lv_obj_del(scr); + lv_clear_print_file(); disp_gcode_icon(file_count); } } @@ -175,7 +171,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { #endif if (file_count != 0) { dir_offset[curDirLever].curPage++; - lv_obj_del(scr); + lv_clear_print_file(); disp_gcode_icon(file_count); } if (file_count < FILE_NUM) @@ -202,12 +198,12 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { #if ENABLED(SDSUPPORT) file_count = search_file(); #endif - lv_obj_del(scr); + lv_clear_print_file(); disp_gcode_icon(file_count); } } else { - lv_obj_del(scr); + lv_clear_print_file(); lv_draw_ready_print(); } } @@ -227,12 +223,12 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { #if ENABLED(SDSUPPORT) file_count = search_file(); #endif - lv_obj_del(scr); + lv_clear_print_file(); disp_gcode_icon(file_count); } else { sel_id = i; - lv_obj_del(scr); + lv_clear_print_file(); lv_draw_dialog(DIALOG_TYPE_PRINT_FILE); } break; @@ -269,9 +265,9 @@ void lv_draw_print_file(void) { #endif disp_gcode_icon(file_count); - //lv_obj_t * labelPageUp = lv_label_create(buttonPageUp, NULL); - //lv_obj_t * labelPageDown = lv_label_create(buttonPageDown, NULL); - //lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + //lv_obj_t *labelPageUp = lv_label_create(buttonPageUp, NULL); + //lv_obj_t *labelPageDown = lv_label_create(buttonPageDown, NULL); + //lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); /* if (gCfgItems.multiple_language != 0) { @@ -286,7 +282,7 @@ void lv_draw_print_file(void) { } */ } - +static char test_public_buf_l[40]; void disp_gcode_icon(uint8_t file_num) { uint8_t i; @@ -310,23 +306,22 @@ void disp_gcode_icon(uint8_t file_num) { buttonPageDown = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonPageUp, event_handler, ID_P_UP, "bmp_pageUp.bin", 0); - lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_REL, &bmp_pic_117x92); - lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_PR, &bmp_pic_117x92); + lv_obj_set_event_cb_mks(buttonPageUp, event_handler, ID_P_UP, NULL, 0); + lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_REL, "F:/bmp_pageUp.bin"); + lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_PR, "F:/bmp_pageUp.bin"); lv_imgbtn_set_style(buttonPageUp, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPageUp, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_clear_protect(buttonPageUp, LV_PROTECT_FOLLOW); #if 1 - lv_obj_set_event_cb_mks(buttonPageDown, event_handler, ID_P_DOWN, "bmp_pageDown.bin", 0); - lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_REL, &bmp_pic_117x92); - lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_PR, &bmp_pic_117x92); + lv_obj_set_event_cb_mks(buttonPageDown, event_handler, ID_P_DOWN, NULL, 0); + lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_REL, "F:/bmp_pageDown.bin"); + lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_PR, "F:/bmp_pageDown.bin"); lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_back.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic_117x92); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic_117x92); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); #endif @@ -365,9 +360,9 @@ void disp_gcode_icon(uint8_t file_num) { cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m); if (list_file.IsFolder[i] == 1) { - lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "bmp_dir.bin", 0); - lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, "F:/bmp_dir.bin"); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, "F:/bmp_dir.bin"); if (i < 3) lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight); else @@ -380,9 +375,17 @@ void disp_gcode_icon(uint8_t file_num) { } else { if (have_pre_pic((char *)list_file.file_name[i])) { - lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1); - lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic_100x100); - lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic_100x100); + + //lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1); + + ZERO(test_public_buf_l); + strcat(test_public_buf_l,"S:"); + strcat(test_public_buf_l,list_file.file_name[i]); + char *temp = strstr(test_public_buf_l,".GCO"); + if (temp) { strcpy(temp,".bin"); } + lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, test_public_buf_l); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, test_public_buf_l); if (i < 3) { lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET); buttonText[i] = lv_btn_create(scr, NULL); @@ -395,8 +398,6 @@ void disp_gcode_icon(uint8_t file_num) { lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW); lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF); //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL,0); - //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_REL, &bmp_pic_100x40); - //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_PR, &bmp_pic_100x40); lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET + 100); lv_obj_set_size(buttonText[i], 100, 40); } @@ -412,8 +413,6 @@ void disp_gcode_icon(uint8_t file_num) { lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW); lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF); //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL,0); - //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_REL, &bmp_pic_100x40); - //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_PR, &bmp_pic_100x40); lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET + 100); lv_obj_set_size(buttonText[i], 100, 40); } @@ -423,9 +422,9 @@ void disp_gcode_icon(uint8_t file_num) { lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0); } else { - lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "bmp_file.bin", 0); - lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, "F:/bmp_file.bin"); + lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, "F:/bmp_file.bin"); if (i < 3) lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight); else @@ -437,15 +436,26 @@ void disp_gcode_icon(uint8_t file_num) { lv_obj_align(labelPageUp[i], buttonGcode[i], LV_ALIGN_IN_BOTTOM_MID, 0, -5); } } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonGcode[i]); + #endif + #else // !TFT35 #endif // !TFT35 } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonPageUp); + lv_group_add_obj(g, buttonPageDown); + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_open_gcode_file(char *path) { +uint32_t lv_open_gcode_file(char *path) { #if ENABLED(SDSUPPORT) uint32_t *ps4; - int pre_sread_cnt; + uint32_t pre_sread_cnt = 0; char *cur_name; cur_name = strrchr(path, '/'); @@ -458,10 +468,10 @@ void lv_open_gcode_file(char *path) { pre_sread_cnt = (uint32_t)ps4 - (uint32_t)((uint32_t *)(&public_buf[0])); card.setIndex(pre_sread_cnt); } + return pre_sread_cnt; #endif // SDSUPPORT } - int ascii2dec_test(char *ascii) { int result = 0; if (ascii == 0) return 0; @@ -534,6 +544,10 @@ void lv_gcode_file_read(uint8_t *data_buf) { void lv_close_gcode_file() {TERN_(SDSUPPORT, card.closefile());} +void lv_gcode_file_seek(uint32_t pos) { + card.setIndex(pos); +} + void cutFileName(char *path, int len, int bytePerLine, char *outStr) { #if _LFN_UNICODE TCHAR *tmpFile; @@ -616,6 +630,11 @@ void cutFileName(char *path, int len, int bytePerLine, char *outStr) { #endif } -void lv_clear_print_file() { lv_obj_del(scr); } +void lv_clear_print_file() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h index 226e4f668e93..083b3d9acf07 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h @@ -52,12 +52,13 @@ extern LIST_FILE list_file; extern void disp_gcode_icon(uint8_t file_num); extern void lv_draw_print_file(void); -extern void lv_open_gcode_file(char *path); +extern uint32_t lv_open_gcode_file(char *path); extern void lv_gcode_file_read(uint8_t *data_buf); extern void lv_close_gcode_file(); extern void cutFileName(char *path, int len, int bytePerLine, char *outStr); extern int ascii2dec_test(char *ascii); extern void lv_clear_print_file(); +extern void lv_gcode_file_seek(uint32_t pos); //extern void disp_temp_ready_print(); #ifdef __cplusplus diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index e5a7bb18d999..a81b5b851bb3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -35,6 +35,7 @@ #include "../../../../module/motion.h" #include "../../../../sd/cardreader.h" #include "../../../../gcode/queue.h" +#include "../../../../gcode/gcode.h" #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../../feature/powerloss.h" @@ -43,10 +44,11 @@ #include "../../../ultralcd.h" #endif +extern lv_group_t * g; static lv_obj_t * scr; -static lv_obj_t * labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime; -static lv_obj_t * labelPause, * labelStop, * labelOperat; -static lv_obj_t * bar1; +static lv_obj_t *labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime; +static lv_obj_t *labelPause, * labelStop, * labelOperat; +static lv_obj_t * bar1, *bar1ValueText; static lv_obj_t * buttonPause, *buttonOperat, *buttonStop; #if HAS_HEATED_BED @@ -57,8 +59,6 @@ static lv_obj_t * buttonPause, *buttonOperat, *buttonStop; #define ID_STOP 2 #define ID_OPTION 3 -lv_style_t lv_bar_style_indic; - uint8_t once_flag = 0; extern uint32_t To_pre_view; extern uint8_t flash_preview_begin; @@ -82,21 +82,23 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { stop_print_time(); uiCfg.print_state = PAUSING; #endif - lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0); + lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_resume.bin"); + lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_resume.bin"); lv_label_set_text(labelPause, printing_menu.resume); lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0); } else if (uiCfg.print_state == PAUSED) { uiCfg.print_state = RESUMING; - // if (IS_SD_PAUSED())queue.inject_P(PSTR("M24"));// queue.inject_P(M24_STR); - lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0); + lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, "F:/bmp_pause.bin"); + lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, "F:/bmp_pause.bin"); lv_label_set_text(labelPause, printing_menu.pause); lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0); } #if ENABLED(POWER_LOSS_RECOVERY) else if (uiCfg.print_state == REPRINTING) { uiCfg.print_state = REPRINTED; - lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0); + lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, "F:/bmp_pause.bin"); + lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, "F:/bmp_pause.bin"); lv_label_set_text(labelPause, printing_menu.pause); lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0); // recovery.resume(); @@ -115,7 +117,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { if (gcode_preview_over != 1) { - lv_obj_del(scr); + lv_clear_printing(); lv_draw_dialog(DIALOG_TYPE_STOP); } } @@ -126,7 +128,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { if (gcode_preview_over != 1) { - lv_obj_del(scr); + lv_clear_printing(); lv_draw_operation(); } } @@ -159,88 +161,71 @@ void lv_draw_printing(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic_150x80); - LV_IMG_DECLARE(bmp_pic_45x45); - - /*Create an Image button*/ - buttonExt1 = lv_imgbtn_create(scr, NULL); - if (EXTRUDERS == 2) - buttonExt2 = lv_imgbtn_create(scr, NULL); - + // Create image buttons + buttonExt1 = lv_img_create(scr, NULL); + #if HAS_MULTI_EXTRUDER + buttonExt2 = lv_img_create(scr, NULL); + #endif #if HAS_HEATED_BED - buttonBedstate = lv_imgbtn_create(scr, NULL); + buttonBedstate = lv_img_create(scr, NULL); #endif - - buttonFanstate = lv_imgbtn_create(scr, NULL); - buttonZpos = lv_imgbtn_create(scr, NULL); + buttonFanstate = lv_img_create(scr, NULL); + buttonTime = lv_img_create(scr, NULL); + buttonZpos = lv_img_create(scr, NULL); buttonPause = lv_imgbtn_create(scr, NULL); buttonStop = lv_imgbtn_create(scr, NULL); buttonOperat = lv_imgbtn_create(scr, NULL); - buttonTime = lv_imgbtn_create(scr, NULL); - - lv_obj_set_event_cb_mks(buttonExt1, event_handler, 0, "bmp_ext1_state.bin", 0); - lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_REL, &bmp_pic_45x45); - lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_PR, &bmp_pic_45x45); - lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_clear_protect(buttonExt1, LV_PROTECT_FOLLOW); + + lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin"); #if 1 - if (EXTRUDERS == 2) { - lv_obj_set_event_cb_mks(buttonExt2, event_handler, 0, "bmp_ext2_state.bin", 0); - lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_REL, &bmp_pic_45x45); - lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_PR, &bmp_pic_45x45); - lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_REL, &tft_style_label_rel); - } + #if HAS_MULTI_EXTRUDER + lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin"); + #endif #if HAS_HEATED_BED - lv_obj_set_event_cb_mks(buttonBedstate, event_handler, 0, "bmp_bed_state.bin", 0); - lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_REL, &bmp_pic_45x45); - lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_PR, &bmp_pic_45x45); - lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin"); #endif - lv_obj_set_event_cb_mks(buttonFanstate, event_handler, 0, "bmp_fan_state.bin", 0); - lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_REL, &bmp_pic_45x45); - lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_PR, &bmp_pic_45x45); - lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonTime, event_handler, 0, "bmp_time_state.bin", 0); - lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_REL, &bmp_pic_45x45); - lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_PR, &bmp_pic_45x45); - lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonZpos, event_handler, 0, "bmp_zpos_state.bin", 0); - lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_REL, &bmp_pic_45x45); - lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_PR, &bmp_pic_45x45); - lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_REL, &tft_style_label_rel); - - if (uiCfg.print_state == WORKING) - lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_pause.bin", 0); - else - lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0); - - lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, &bmp_pic_150x80); - lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, &bmp_pic_150x80); + lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin"); + + lv_img_set_src(buttonTime, "F:/bmp_time_state.bin"); + + lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin"); + + if (uiCfg.print_state == WORKING) { + lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_pause.bin"); + lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_pause.bin"); + } + else { + lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_resume.bin"); + lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_resume.bin"); + } + + lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, NULL, 0); lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, "bmp_stop.bin", 0); - lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, &bmp_pic_150x80); - lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, &bmp_pic_150x80); + lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, NULL, 0); + lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, "F:/bmp_stop.bin"); + lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, "F:/bmp_stop.bin"); lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, "bmp_operate.bin", 0); - lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, &bmp_pic_150x80); - lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, &bmp_pic_150x80); + lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, NULL, 0); + lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, "F:/bmp_operate.bin"); + lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, "F:/bmp_operate.bin"); lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_REL, &tft_style_label_rel); + #endif // if 1 + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonPause); + lv_group_add_obj(g, buttonStop); + lv_group_add_obj(g, buttonOperat); + } + #endif + lv_obj_set_pos(buttonExt1, 205, 136); #if HAS_MULTI_EXTRUDER @@ -258,17 +243,19 @@ void lv_draw_printing(void) { lv_obj_set_pos(buttonStop, 165, 240); lv_obj_set_pos(buttonOperat, 325, 240); - /*Create a label on the Image button*/ - lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF); - if (EXTRUDERS == 2) - lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF); + // Create labels on the image buttons + //lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF); + //#if HAS_MULTI_EXTRUDER + //lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF); + //#endif - #if HAS_HEATED_BED - lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF); - #endif + //#if HAS_HEATED_BED + //lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF); + //#endif - lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF); - lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF); + //lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF); + //lv_btn_set_layout(buttonTime, LV_LAYOUT_OFF); + //lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF); lv_btn_set_layout(buttonPause, LV_LAYOUT_OFF); lv_btn_set_layout(buttonStop, LV_LAYOUT_OFF); lv_btn_set_layout(buttonOperat, LV_LAYOUT_OFF); @@ -293,23 +280,20 @@ void lv_draw_printing(void) { lv_obj_set_style(labelFan, &tft_style_label_rel); lv_obj_set_pos(labelFan, 395, 196); - labelZpos = lv_label_create(scr, NULL); - lv_obj_set_style(labelZpos, &tft_style_label_rel); - lv_obj_set_pos(labelZpos, 395, 96); - labelTime = lv_label_create(scr, NULL); lv_obj_set_style(labelTime, &tft_style_label_rel); lv_obj_set_pos(labelTime, 250, 96); + labelZpos = lv_label_create(scr, NULL); + lv_obj_set_style(labelZpos, &tft_style_label_rel); + lv_obj_set_pos(labelZpos, 395, 96); + labelPause = lv_label_create(buttonPause, NULL); labelStop = lv_label_create(buttonStop, NULL); labelOperat = lv_label_create(buttonOperat, NULL); if (gCfgItems.multiple_language != 0) { - if (uiCfg.print_state == WORKING) - lv_label_set_text(labelPause, printing_menu.pause); - else - lv_label_set_text(labelPause, printing_menu.resume); + lv_label_set_text(labelPause, uiCfg.print_state == WORKING ? printing_menu.pause : printing_menu.resume); lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 20, 0); lv_label_set_text(labelStop, printing_menu.stop); @@ -319,20 +303,15 @@ void lv_draw_printing(void) { lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0); } - lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color); - lv_bar_style_indic.text.color = lv_color_hex3(0xADF); - lv_bar_style_indic.image.color = lv_color_hex3(0xADF); - lv_bar_style_indic.line.color = lv_color_hex3(0xADF); - lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF); - lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF); - lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF); - bar1 = lv_bar_create(scr, NULL); lv_obj_set_pos(bar1, 205, 36); lv_obj_set_size(bar1, 270, 40); lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic); lv_bar_set_anim_time(bar1, 1000); lv_bar_set_value(bar1, 0, LV_ANIM_ON); + bar1ValueText = lv_label_create(bar1, NULL); + lv_label_set_text(bar1ValueText,"0%"); + lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0); disp_ext_temp(); disp_bed_temp(); @@ -419,6 +398,10 @@ void setProBarRate() { if (disp_state == PRINTING_UI) { lv_bar_set_value(bar1, rate, LV_ANIM_ON); + ZERO(public_buf_l); + sprintf_P(public_buf_l, "%d%%", rate); + lv_label_set_text(bar1ValueText,public_buf_l); + lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0); if (marlin_state == MF_SD_COMPLETE) { if (once_flag == 0) { @@ -432,14 +415,22 @@ void setProBarRate() { once_flag = 1; #if HAS_SUICIDE - if (gCfgItems.finish_power_off == 1) - suicide(); + if (gCfgItems.finish_power_off == 1) { + gcode.process_subcommands_now_P(PSTR("M1001")); + queue.inject_P(PSTR("M81")); + marlin_state = MF_RUNNING; + } #endif } } } } -void lv_clear_printing() { lv_obj_del(scr); } +void lv_clear_printing() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 38750d608d0d..54ffdca64a44 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -42,6 +42,7 @@ #include //static lv_obj_t *buttonPrint,*buttonTool,*buttonSet; +extern lv_group_t* g; static lv_obj_t * scr; #if ENABLED(MKS_TEST) uint8_t curent_disp_ui = 0; @@ -59,7 +60,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_ready_print(); lv_draw_tool(); } break; @@ -68,7 +69,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_ready_print(); lv_draw_set(); } break; @@ -77,7 +78,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_ready_print(); lv_draw_print_file(); } break; @@ -111,7 +112,7 @@ void disp_det_error() { lv_obj_t *e1, *e2, *e3, *bed; void mks_disp_test() { char buf[30] = {0}; - //lv_obj_t * label_tool2 = lv_label_create(scr, NULL); + //lv_obj_t *label_tool2 = lv_label_create(scr, NULL); //lv_obj_set_pos(label_tool,20,50); ZERO(buf); sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius); @@ -132,7 +133,6 @@ void mks_disp_test() { #endif } -extern unsigned char bmp_public_buf[17 * 1024]; void lv_draw_ready_print(void) { char buf[30] = {0}; lv_obj_t *buttonPrint, *buttonTool, *buttonSet; @@ -151,9 +151,7 @@ void lv_draw_ready_print(void) { //lv_obj_set_hidden(scr,true); lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - - if (mks_test_flag == 0x1e) { + if (mks_test_flag == 0x1E) { //lv_obj_t * title = lv_label_create(scr, NULL); //lv_obj_set_style(title, &tft_style_label_rel); //lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); @@ -164,26 +162,10 @@ void lv_draw_ready_print(void) { buttonTool = lv_imgbtn_create(scr, NULL); //buttonSet = lv_imgbtn_create(scr, NULL); - //lv_obj_set_event_cb_mks(buttonPrint, event_handler,ID_PRINT,"bmp_printing.bin",0); - //lv_imgbtn_set_src_mks(buttonPrint, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_printing.bin"); - //lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, &bmp_pic); - //lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, &bmp_pic); - //lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_PR, &tft_style_label_pre); - //lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_REL, &tft_style_label_rel); - //lv_obj_clear_protect(buttonPrint, LV_PROTECT_FOLLOW); - #if 1 - //lv_obj_set_event_cb_mks(buttonSet, event_handler,ID_SET,"bmp_set.bin",0); - //lv_imgbtn_set_src_mks(buttonSet, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_set.bin"); - //lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, &bmp_pic); - //lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, &bmp_pic); - //lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre); - //lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, "bmp_tool.bin", 0); - //lv_imgbtn_set_src_mks(buttonTool, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_tool.bin"); - lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, NULL, 0); + lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, "F:/bmp_tool.bin"); + lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, "F:/bmp_tool.bin"); lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel); #endif @@ -266,56 +248,37 @@ void lv_draw_ready_print(void) { } else { - //lv_obj_t * title = lv_label_create(scr, NULL); - //lv_obj_set_style(title, &tft_style_label_rel); - //lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); - //lv_label_set_text(title, creat_title_text()); + // Create an Image button + buttonTool = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonTool, 20, 90); + lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, NULL, 0); + lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, "F:/bmp_tool.bin"); + lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, "F:/bmp_tool.bin"); + lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_obj_t *label_tool = lv_label_create(buttonTool, NULL); + lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF); - /*Create an Image button*/ - buttonPrint = lv_imgbtn_create(scr, NULL); - buttonTool = lv_imgbtn_create(scr, NULL); - buttonSet = lv_imgbtn_create(scr, NULL); + buttonSet = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonSet, 180, 90); + lv_obj_set_event_cb_mks(buttonSet, event_handler, ID_SET, NULL, 0); + lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, "F:/bmp_set.bin"); + lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, "F:/bmp_set.bin"); + lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_obj_t *label_set = lv_label_create(buttonSet, NULL); + lv_btn_set_layout(buttonSet, LV_LAYOUT_OFF); - lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, "bmp_printing.bin", 0); - //lv_imgbtn_set_src_mks(buttonPrint, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_printing.bin"); - lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, &bmp_pic); + buttonPrint = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonPrint, 340, 90); + lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, NULL, 0); + lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, "F:/bmp_printing.bin"); + lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, "F:/bmp_printing.bin"); lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_clear_protect(buttonPrint, LV_PROTECT_FOLLOW); - - #if 1 - lv_obj_set_event_cb_mks(buttonSet, event_handler, ID_SET, "bmp_set.bin", 0); - //lv_imgbtn_set_src_mks(buttonSet, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_set.bin"); - lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, "bmp_tool.bin", 0); - //lv_imgbtn_set_src_mks(buttonTool, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_tool.bin"); - lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel); - #endif - - lv_obj_set_pos(buttonTool, 20, 90); - lv_obj_set_pos(buttonSet, 180, 90); - lv_obj_set_pos(buttonPrint, 340, 90); - - //lv_obj_set_pos(buttonTool,SIMPLE_FIRST_PAGE_GRAP+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2); - //lv_obj_set_pos(buttonSet,BTN_X_PIXEL+SIMPLE_FIRST_PAGE_GRAP*2+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2); - //lv_obj_set_pos(buttonPrint,BTN_X_PIXEL*2+SIMPLE_FIRST_PAGE_GRAP*3+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2); - - /*Create a label on the Image button*/ + lv_obj_t *label_print = lv_label_create(buttonPrint, NULL); lv_btn_set_layout(buttonPrint, LV_LAYOUT_OFF); - lv_btn_set_layout(buttonSet, LV_LAYOUT_OFF); - lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF); - lv_obj_t * label_print = lv_label_create(buttonPrint, NULL); - lv_obj_t * label_set = lv_label_create(buttonSet, NULL); - lv_obj_t * label_tool = lv_label_create(buttonTool, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(label_print, main_menu.print); lv_obj_align(label_print, buttonPrint, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -323,14 +286,25 @@ void lv_draw_ready_print(void) { lv_label_set_text(label_set, main_menu.set); lv_obj_align(label_set, buttonSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - //lv_label_set_style(label_tool,LV_BTN_STATE_PR,&tft_style_label_pre); - //lv_label_set_style(label_tool,LV_BTN_STATE_REL,&tft_style_label_rel); lv_label_set_text(label_tool, main_menu.tool); lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable == true) { + lv_group_add_obj(g, buttonTool); + lv_group_add_obj(g, buttonSet); + lv_group_add_obj(g, buttonPrint); + } + #endif } } -void lv_clear_ready_print() { lv_obj_del(scr); } +void lv_clear_ready_print() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable == true) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp index eebb9fcf1c43..6c10713d8a9c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp @@ -36,6 +36,7 @@ #include "pic_manager.h" static lv_obj_t * scr; +extern lv_group_t* g; #define ID_S_WIFI 1 #define ID_S_FAN 2 @@ -48,20 +49,17 @@ static lv_obj_t * scr; #define ID_S_RETURN 9 static void event_handler(lv_obj_t * obj, lv_event_t event) { + #if ENABLED(USE_WIFI_FUNCTION) + char buf[6] = { 0 }; + #endif switch (obj->mks_obj_id) { - case ID_S_WIFI: - if (event == LV_EVENT_CLICKED) { - // nothing to do - } - else if (event == LV_EVENT_RELEASED) { - } - break; + case ID_S_FAN: if (event == LV_EVENT_CLICKED) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_set(); lv_draw_fan(); } break; @@ -70,7 +68,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_set(); lv_draw_about(); } break; @@ -94,7 +92,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_set(); lv_draw_language(); } break; @@ -103,7 +101,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_set(); lv_draw_machine_para(); } break; @@ -112,7 +110,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_set(); lv_draw_eeprom_settings(); } break; @@ -121,11 +119,50 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { // nothing to do } else if (event == LV_EVENT_RELEASED) { - lv_obj_del(scr); + lv_clear_set(); lv_draw_ready_print(); } break; - + #if ENABLED(USE_WIFI_FUNCTION) + case ID_S_WIFI: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + if (gCfgItems.wifi_mode_sel == STA_MODEL) { + if (wifi_link_state == WIFI_CONNECTED) { + last_disp_state = SET_UI; + lv_clear_set(); + lv_draw_wifi(); + } + else { + if (uiCfg.command_send == 1) { + buf[0] = 0xA5; + buf[1] = 0x07; + buf[2] = 0x00; + buf[3] = 0x00; + buf[4] = 0xFC; + raw_send_to_wifi(buf, 5); + + last_disp_state = SET_UI; + lv_clear_set(); + lv_draw_wifi_list(); + } + else { + last_disp_state = SET_UI; + lv_clear_set(); + lv_draw_dialog(WIFI_ENABLE_TIPS); + } + } + } + else { + last_disp_state = SET_UI; + lv_clear_set(); + lv_draw_wifi(); + } + } + break; + #endif } } @@ -137,6 +174,9 @@ void lv_draw_set(void) { #endif lv_obj_t *buttonMachinePara; lv_obj_t *buttonEepromSet; + #if ENABLED(USE_WIFI_FUNCTION) + lv_obj_t *buttonWifi; + #endif if (disp_state_stack._disp_state[disp_state_stack._disp_index] != SET_UI) { disp_state_stack._disp_index++; @@ -159,79 +199,81 @@ void lv_draw_set(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - - /*Create an Image button*/ - //buttonWifi = lv_imgbtn_create(scr, NULL); - buttonFan = lv_imgbtn_create(scr, NULL); - buttonAbout = lv_imgbtn_create(scr, NULL); - //buttonContinue = lv_imgbtn_create(scr, NULL); - buMotorOff = lv_imgbtn_create(scr, NULL); + // Create image buttons + buttonEepromSet = lv_imgbtn_create(scr, NULL); + //buttonWifi = lv_imgbtn_create(scr, NULL); + buttonFan = lv_imgbtn_create(scr, NULL); + buttonAbout = lv_imgbtn_create(scr, NULL); + //buttonContinue = lv_imgbtn_create(scr, NULL); + buMotorOff = lv_imgbtn_create(scr, NULL); + buttonMachinePara = lv_imgbtn_create(scr, NULL); #if HAS_LANG_SELECT_SCREEN - buttonLanguage = lv_imgbtn_create(scr, NULL); + buttonLanguage = lv_imgbtn_create(scr, NULL); + #endif + #if ENABLED(USE_WIFI_FUNCTION) + buttonWifi = lv_imgbtn_create(scr, NULL); #endif - buttonMachinePara = lv_imgbtn_create(scr, NULL); - buttonEepromSet = lv_imgbtn_create(scr, NULL); buttonBack = lv_imgbtn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonEepromSet, event_handler, ID_S_EEPROM_SET, NULL, 0); + lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_REL, "F:/bmp_eeprom_settings.bin"); + lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_PR, "F:/bmp_eeprom_settings.bin"); + lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_REL, &tft_style_label_rel); - //lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,"bmp_Wifi.bin",0); - //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, &bmp_pic); - //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, &bmp_pic); - //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre); - //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel); - //lv_obj_clear_protect(buttonWifi, LV_PROTECT_FOLLOW); #if 1 - lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_S_FAN, "bmp_fan.bin", 0); - lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_S_FAN, NULL, 0); + lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, "F:/bmp_fan.bin"); + lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, "F:/bmp_fan.bin"); lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonAbout, event_handler, ID_S_ABOUT, "bmp_about.bin", 0); - lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonAbout, event_handler, ID_S_ABOUT, NULL, 0); + lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_REL, "F:/bmp_about.bin"); + lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_PR, "F:/bmp_about.bin"); lv_imgbtn_set_style(buttonAbout, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonAbout, LV_BTN_STATE_REL, &tft_style_label_rel); - //lv_obj_set_event_cb_mks(buttonContinue, event_handler,ID_S_CONTINUE,"bmp_Breakpoint.bin",0); - //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_REL, &bmp_pic); - //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_PR, &bmp_pic); - //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_label_pre); - //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, NULL, 0); + #if HAS_SUICIDE - lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_Mamual.bin", 0); + lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin"); + lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin"); #else - lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_function1.bin", 0); + lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, "F:/bmp_function1.bin"); + lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, "F:/bmp_function1.bin"); #endif - lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, &bmp_pic); lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_obj_set_event_cb_mks(buttonMachinePara, event_handler, ID_S_MACHINE_PARA, NULL, 0); + lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_REL, "F:/bmp_machine_para.bin"); + lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_PR, "F:/bmp_machine_para.bin"); + lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_REL, &tft_style_label_rel); + #if HAS_LANG_SELECT_SCREEN - lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, "bmp_language.bin", 0); - lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, NULL, 0); + lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, "F:/bmp_language.bin"); + lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, "F:/bmp_language.bin"); lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_REL, &tft_style_label_rel); #endif - lv_obj_set_event_cb_mks(buttonMachinePara, event_handler, ID_S_MACHINE_PARA, "bmp_machine_para.bin", 0); - lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonEepromSet, event_handler, ID_S_EEPROM_SET, "bmp_eeprom_settings.bin", 0); - lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_S_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); + #if ENABLED(USE_WIFI_FUNCTION) + lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,NULL,0); + lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, "F:/bmp_wifi.bin"); + lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, "F:/bmp_wifi.bin"); + lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel); + #endif + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_S_RETURN,NULL , 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + #endif // if 1 /*lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight); @@ -243,45 +285,56 @@ void lv_draw_set(void) { lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);*/ //lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight); + lv_obj_set_pos(buttonEepromSet, INTERVAL_V, titleHeight); lv_obj_set_pos(buttonFan, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); lv_obj_set_pos(buttonAbout, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); //lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight); lv_obj_set_pos(buMotorOff, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); + + lv_obj_set_pos(buttonMachinePara, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); #if HAS_LANG_SELECT_SCREEN - lv_obj_set_pos(buttonLanguage, INTERVAL_V, titleHeight); + lv_obj_set_pos(buttonLanguage, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); + #endif + #if ENABLED(USE_WIFI_FUNCTION) + lv_obj_set_pos(buttonWifi,BTN_X_PIXEL*2+INTERVAL_V*3,BTN_Y_PIXEL+INTERVAL_H+titleHeight); #endif - lv_obj_set_pos(buttonMachinePara, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - lv_obj_set_pos(buttonEepromSet, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - /*Create a label on the Image button*/ + /// Create labels on the buttons //lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonEepromSet, LV_LAYOUT_OFF); lv_btn_set_layout(buttonFan, LV_LAYOUT_OFF); lv_btn_set_layout(buttonAbout, LV_LAYOUT_OFF); //lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF); lv_btn_set_layout(buMotorOff, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonMachinePara, LV_LAYOUT_OFF); #if HAS_LANG_SELECT_SCREEN lv_btn_set_layout(buttonLanguage, LV_LAYOUT_OFF); #endif - lv_btn_set_layout(buttonMachinePara, LV_LAYOUT_OFF); - lv_btn_set_layout(buttonEepromSet, LV_LAYOUT_OFF); + #if ENABLED(USE_WIFI_FUNCTION) + lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF); + #endif lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - //lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL); - lv_obj_t * labelFan = lv_label_create(buttonFan, NULL); - lv_obj_t * label_About = lv_label_create(buttonAbout, NULL); - //lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL); - lv_obj_t * label_MotorOff = lv_label_create(buMotorOff, NULL); + //lv_obj_t *labelWifi= lv_label_create(buttonWifi, NULL); + lv_obj_t *label_EepromSet = lv_label_create(buttonEepromSet, NULL); + lv_obj_t *labelFan = lv_label_create(buttonFan, NULL); + lv_obj_t *label_About = lv_label_create(buttonAbout, NULL); + //lv_obj_t *label_Continue = lv_label_create(buttonContinue, NULL); + lv_obj_t *label_MotorOff = lv_label_create(buMotorOff, NULL); + lv_obj_t *label_MachinePara = lv_label_create(buttonMachinePara, NULL); #if HAS_LANG_SELECT_SCREEN - lv_obj_t * label_Language = lv_label_create(buttonLanguage, NULL); + lv_obj_t *label_Language = lv_label_create(buttonLanguage, NULL); #endif - lv_obj_t * label_MachinePara = lv_label_create(buttonMachinePara, NULL); - lv_obj_t * label_EepromSet = lv_label_create(buttonEepromSet, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + #if ENABLED(USE_WIFI_FUNCTION) + lv_obj_t *label_Wifi = lv_label_create(buttonWifi, NULL); + #endif + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { - //lv_label_set_text(labelWifi, set_menu.wifi); - //lv_obj_align(labelWifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_EepromSet, set_menu.eepromSet); + lv_obj_align(label_EepromSet, buttonEepromSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_label_set_text(labelFan, set_menu.fan); lv_obj_align(labelFan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -291,28 +344,46 @@ void lv_draw_set(void) { //lv_label_set_text(label_Continue, set_menu.breakpoint); //lv_obj_align(label_Continue, buttonContinue, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); - #if HAS_SUICIDE - lv_label_set_text(label_MotorOff, set_menu.shutdown); - #else - lv_label_set_text(label_MotorOff, set_menu.motoroff); - #endif + lv_label_set_text(label_MotorOff, set_menu.TERN(HAS_SUICIDE, shutdown, motoroff)); lv_obj_align(label_MotorOff, buMotorOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + lv_label_set_text(label_MachinePara, set_menu.machine_para); + lv_obj_align(label_MachinePara, buttonMachinePara, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + #if HAS_LANG_SELECT_SCREEN lv_label_set_text(label_Language, set_menu.language); lv_obj_align(label_Language, buttonLanguage, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); #endif - lv_label_set_text(label_MachinePara, set_menu.machine_para); - lv_obj_align(label_MachinePara, buttonMachinePara, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - lv_label_set_text(label_EepromSet, set_menu.eepromSet); - lv_obj_align(label_EepromSet, buttonEepromSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + #if ENABLED(USE_WIFI_FUNCTION) + lv_label_set_text(label_Wifi, set_menu.wifi); + lv_obj_align(label_Wifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + #endif lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonEepromSet); + lv_group_add_obj(g, buttonFan); + lv_group_add_obj(g, buttonAbout); + lv_group_add_obj(g, buMotorOff); + lv_group_add_obj(g, buttonMachinePara); + lv_group_add_obj(g, buttonLanguage); + #if ENABLED(USE_WIFI_FUNCTION) + lv_group_add_obj(g, buttonWifi); + #endif + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_set() { lv_obj_del(scr); } +void lv_clear_set() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp index 434c2f85795a..baad23f9aed7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp @@ -29,6 +29,7 @@ #include "../../../../MarlinCore.h" #include "../../../../module/planner.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_STEP_RETURN 1 @@ -127,11 +128,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { void lv_draw_step_settings(void) { lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL; - lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; - lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; - lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; - lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL; - lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL; + lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; + lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; + lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; + lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL; + lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL; lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != STEPS_UI) { disp_state_stack._disp_index++; @@ -152,166 +153,133 @@ void lv_draw_step_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - // LV_IMG_DECLARE(bmp_para_arrow); - LV_IMG_DECLARE(bmp_para_bank); - if (uiCfg.para_ui_page != 1) { - buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonXText, event_handler); - lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF); - labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/ - - buttonXValue = lv_imgbtn_create(scr, NULL); + labelXText = lv_label_create(scr, NULL); + lv_obj_set_style(labelXText, &tft_style_label_rel); + lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelXText, machine_menu.X_Steps); + + buttonXValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_STEP_X, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_STEP_X, NULL, 0); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); labelXValue = lv_label_create(buttonXValue, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonYText, event_handler); - lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF); - labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/ + labelYText = lv_label_create(scr, NULL); + lv_obj_set_style(labelYText, &tft_style_label_rel); + lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelYText, machine_menu.Y_Steps); - buttonYValue = lv_imgbtn_create(scr, NULL); + buttonYValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_STEP_Y, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_STEP_Y, NULL, 0); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); labelYValue = lv_label_create(buttonYValue, NULL); line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); - buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ - lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonZText, event_handler); - lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF); - labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/ + labelZText = lv_label_create(scr, NULL); + lv_obj_set_style(labelZText, &tft_style_label_rel); + lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelZText, machine_menu.Z_Steps); - buttonZValue = lv_imgbtn_create(scr, NULL); + buttonZValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_STEP_Z, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_STEP_Z, NULL, 0); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); labelZValue = lv_label_create(buttonZValue, NULL); line3 = lv_line_create(scr, NULL); lv_ex_line(line3, line_points[2]); - buttonE0Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/ - lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonE0Text, event_handler); - lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF); - labelE0Text = lv_label_create(buttonE0Text, NULL); /*Add a label to the button*/ + labelE0Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelE0Text, &tft_style_label_rel); + lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelE0Text, machine_menu.E0_Steps); - buttonE0Value = lv_imgbtn_create(scr, NULL); + buttonE0Value = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_STEP_E0, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF); + lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_STEP_E0, NULL, 0); + lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value); labelE0Value = lv_label_create(buttonE0Value, NULL); line4 = lv_line_create(scr, NULL); lv_ex_line(line4, line_points[3]); - buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_DOWN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_DOWN, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonXValue); + lv_group_add_obj(g, buttonYValue); + lv_group_add_obj(g, buttonZValue); + lv_group_add_obj(g, buttonE0Value); + lv_group_add_obj(g, buttonTurnPage); + } + #endif } else { - buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonE1Text, event_handler); - lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF); - labelE1Text = lv_label_create(buttonE1Text, NULL); /*Add a label to the button*/ - - buttonE1Value = lv_imgbtn_create(scr, NULL); + labelE1Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelE1Text, &tft_style_label_rel); + lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelE1Text, machine_menu.E1_Steps); + + buttonE1Value = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_STEP_E1, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF); + lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_STEP_E1, NULL, 0); + lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value); labelE1Value = lv_label_create(buttonE1Value, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_UP, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_UP, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonE1Value); + lv_group_add_obj(g, buttonTurnPage); + } + #endif } lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); - lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF); + lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); labelTurnPage = lv_label_create(buttonTurnPage, NULL); - buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_STEP_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); - + buttonBack = lv_btn_create(scr, NULL); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); - lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_STEP_RETURN, NULL, 0); label_Back = lv_label_create(buttonBack, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif if (gCfgItems.multiple_language != 0) { if (uiCfg.para_ui_page != 1) { - lv_label_set_text(labelXText, machine_menu.X_Steps); - lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelYText, machine_menu.Y_Steps); - lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelZText, machine_menu.Z_Steps); - lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelE0Text, machine_menu.E0_Steps); - lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0); - lv_label_set_text(labelTurnPage, machine_menu.next); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); @@ -336,9 +304,6 @@ void lv_draw_step_settings(void) { lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0); } else { - lv_label_set_text(labelE1Text, machine_menu.E1_Steps); - lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0); - lv_label_set_text(labelTurnPage, machine_menu.previous); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); @@ -353,6 +318,11 @@ void lv_draw_step_settings(void) { } } -void lv_clear_step_settings() { lv_obj_del(scr); } +void lv_clear_step_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp index 24650ee9309f..10aa7badff7e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp @@ -31,6 +31,7 @@ #include "../../../../module/stepper/indirection.h" #include "../../../../feature/tmc_util.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_TMC_CURRENT_RETURN 1 @@ -54,94 +55,105 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { draw_return_ui(); } break; - case ID_TMC_CURRENT_X: + #if AXIS_IS_TMC(X) + case ID_TMC_CURRENT_X: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = Xcurrent; + lv_clear_tmc_current_settings(); + lv_draw_number_key(); + } + break; + #endif + + #if AXIS_IS_TMC(Y) + case ID_TMC_CURRENT_Y: if (event == LV_EVENT_CLICKED) { } else if (event == LV_EVENT_RELEASED) { - value = Xcurrent; + value = Ycurrent; lv_clear_tmc_current_settings(); lv_draw_number_key(); } break; - case ID_TMC_CURRENT_Y: + #endif + + #if AXIS_IS_TMC(Z) + case ID_TMC_CURRENT_Z: if (event == LV_EVENT_CLICKED) { } else if (event == LV_EVENT_RELEASED) { - value = Ycurrent; + value = Zcurrent; lv_clear_tmc_current_settings(); lv_draw_number_key(); } break; - case ID_TMC_CURRENT_Z: + #endif + + #if AXIS_IS_TMC(E0) + case ID_TMC_CURRENT_E0: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = E0current; + lv_clear_tmc_current_settings(); + lv_draw_number_key(); + } + break; + #endif + + #if AXIS_IS_TMC(E1) + case ID_TMC_CURRENT_E1: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + value = E1current; + lv_clear_tmc_current_settings(); + lv_draw_number_key(); + } + break; + #endif + case ID_TMC_CURRENT_UP: if (event == LV_EVENT_CLICKED) { } else if (event == LV_EVENT_RELEASED) { - value = Zcurrent; + uiCfg.para_ui_page = 0; lv_clear_tmc_current_settings(); - lv_draw_number_key(); + lv_draw_tmc_current_settings(); } break; - case ID_TMC_CURRENT_E0: + case ID_TMC_CURRENT_DOWN: if (event == LV_EVENT_CLICKED) { } else if (event == LV_EVENT_RELEASED) { - value = E0current; + uiCfg.para_ui_page = 1; lv_clear_tmc_current_settings(); - lv_draw_number_key(); + lv_draw_tmc_current_settings(); } break; - #if AXIS_IS_TMC(E1) - case ID_TMC_CURRENT_E1: - if (event == LV_EVENT_CLICKED) { - - } - else if (event == LV_EVENT_RELEASED) { - value = E1current; - lv_clear_tmc_current_settings(); - lv_draw_number_key(); - } - break; - - case ID_TMC_CURRENT_UP: - if (event == LV_EVENT_CLICKED) { - - } - else if (event == LV_EVENT_RELEASED) { - uiCfg.para_ui_page = 0; - lv_clear_tmc_current_settings(); - lv_draw_tmc_current_settings(); - } - break; - case ID_TMC_CURRENT_DOWN: - if (event == LV_EVENT_CLICKED) { - - } - else if (event == LV_EVENT_RELEASED) { - uiCfg.para_ui_page = 1; - lv_clear_tmc_current_settings(); - lv_draw_tmc_current_settings(); - } - break; - #endif } } void lv_draw_tmc_current_settings(void) { lv_obj_t *buttonBack = NULL, *label_Back = NULL; - lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; - lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; - lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; - lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL; + lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; + lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; + lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; + lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL; lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; - #if AXIS_IS_TMC(E1) + //#if AXIS_IS_TMC(E1) lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL; - lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL; - #endif + lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL; + //#endif float milliamps; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_CURRENT_UI) { @@ -163,217 +175,201 @@ void lv_draw_tmc_current_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - // LV_IMG_DECLARE(bmp_para_arrow); - LV_IMG_DECLARE(bmp_para_bank); - if (uiCfg.para_ui_page != 1) { - buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonXText, event_handler); - lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF); - labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/ - - buttonXValue = lv_imgbtn_create(scr, NULL); + labelXText = lv_label_create(scr, NULL); + lv_obj_set_style(labelXText, &tft_style_label_rel); + lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelXText, machine_menu.X_Current); + + buttonXValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_TMC_CURRENT_X, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_TMC_CURRENT_X, NULL, 0); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); labelXValue = lv_label_create(buttonXValue, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/ - lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonYText, event_handler); - lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF); - labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/ + labelYText = lv_label_create(scr, NULL); + lv_obj_set_style(labelYText, &tft_style_label_rel); + lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + lv_label_set_text(labelYText, machine_menu.Y_Current); - buttonYValue = lv_imgbtn_create(scr, NULL); + buttonYValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_TMC_CURRENT_Y, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_TMC_CURRENT_Y, NULL, 0); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); labelYValue = lv_label_create(buttonYValue, NULL); line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); - buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ - lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonZText, event_handler); - lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF); - labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/ + labelZText = lv_label_create(scr, NULL); + lv_obj_set_style(labelZText, &tft_style_label_rel); + lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + lv_label_set_text(labelZText, machine_menu.Z_Current); - buttonZValue = lv_imgbtn_create(scr, NULL); + buttonZValue = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_TMC_CURRENT_Z, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF); + lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_TMC_CURRENT_Z, NULL, 0); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); labelZValue = lv_label_create(buttonZValue, NULL); line3 = lv_line_create(scr, NULL); lv_ex_line(line3, line_points[2]); - buttonE0Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/ - lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonE0Text, event_handler); - lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF); - labelE0Text = lv_label_create(buttonE0Text, NULL); /*Add a label to the button*/ + labelE0Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelE0Text, &tft_style_label_rel); + lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelE0Text, machine_menu.E0_Current); - buttonE0Value = lv_imgbtn_create(scr, NULL); + buttonE0Value = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_TMC_CURRENT_E0, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF); + lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_TMC_CURRENT_E0, NULL, 0); + lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value); labelE0Value = lv_label_create(buttonE0Value, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonXValue); + lv_group_add_obj(g, buttonYValue); + lv_group_add_obj(g, buttonZValue); + lv_group_add_obj(g, buttonE0Value); + } + #endif + line4 = lv_line_create(scr, NULL); lv_ex_line(line4, line_points[3]); - #if AXIS_IS_TMC(E1) - buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_DOWN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); - #endif + //#if AXIS_IS_TMC(E1) + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_DOWN, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage); + #endif + //#endif } else { - #if AXIS_IS_TMC(E1) - buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ - lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ - lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ - lv_obj_set_event_cb(buttonE1Text, event_handler); - lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ - lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ - lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF); - labelE1Text = lv_label_create(buttonE1Text, NULL); /*Add a label to the button*/ - - buttonE1Value = lv_imgbtn_create(scr, NULL); + //#if AXIS_IS_TMC(E1) + labelE1Text = lv_label_create(scr, NULL); + lv_obj_set_style(labelE1Text, &tft_style_label_rel); + lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelE1Text, machine_menu.E1_Current); + + buttonE1Value = lv_btn_create(scr, NULL); lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V); - lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_TMC_CURRENT_E1, "bmp_value_blank.bin", 0); - lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank); - lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank); - lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre); - lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel); - lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF); + lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_TMC_CURRENT_E1, NULL, 0); + lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value); labelE1Value = lv_label_create(buttonE1Value, NULL); line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); - buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_UP, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); - #endif + buttonTurnPage = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_UP, NULL, 0); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonE1Value); + lv_group_add_obj(g, buttonTurnPage); + } + #endif + //#endif } - #if AXIS_IS_TMC(E1) + //#if AXIS_IS_TMC(E1) lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); - lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF); + lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); labelTurnPage = lv_label_create(buttonTurnPage, NULL); - #endif + //#endif - buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_CURRENT_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + buttonBack = lv_btn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_CURRENT_RETURN, NULL, 0); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back); + lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); - lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { if (uiCfg.para_ui_page != 1) { - lv_label_set_text(labelXText, machine_menu.X_Current); - lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelYText, machine_menu.Y_Current); - lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelZText, machine_menu.Z_Current); - lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0); - - lv_label_set_text(labelE0Text, machine_menu.E0_Current); - lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0); - #if AXIS_IS_TMC(E1) + //#if AXIS_IS_TMC(E1) lv_label_set_text(labelTurnPage, machine_menu.next); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); - #endif + //#endif #if AXIS_IS_TMC(X) milliamps = stepperX.getMilliamps(); - ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); - lv_label_set_text(labelXValue, public_buf_l); - lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0); + #else + milliamps = -1; #endif + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + lv_label_set_text(labelXValue, public_buf_l); + lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0); + #if AXIS_IS_TMC(Y) milliamps = stepperY.getMilliamps(); - ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); - lv_label_set_text(labelYValue, public_buf_l); - lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0); + #else + milliamps = -1; #endif + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + lv_label_set_text(labelYValue, public_buf_l); + lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0); + #if AXIS_IS_TMC(Z) milliamps = stepperZ.getMilliamps(); - ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); - lv_label_set_text(labelZValue, public_buf_l); - lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0); + #else + milliamps = -1; #endif + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + lv_label_set_text(labelZValue, public_buf_l); + lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0); + #if AXIS_IS_TMC(E0) milliamps = stepperE0.getMilliamps(); - ZERO(public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); - lv_label_set_text(labelE0Value, public_buf_l); - lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0); + #else + milliamps = -1; #endif + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + lv_label_set_text(labelE0Value, public_buf_l); + lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0); } else { - #if AXIS_IS_TMC(E1) - lv_label_set_text(labelE1Text, machine_menu.E1_Current); - lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0); - + //#if AXIS_IS_TMC(E1) lv_label_set_text(labelTurnPage, machine_menu.previous); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); - - milliamps = stepperE1.getMilliamps(); + #if AXIS_IS_TMC(E1) + milliamps = stepperE1.getMilliamps(); + #else + milliamps = -1; + #endif ZERO(public_buf_l); sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); lv_label_set_text(labelE1Value, public_buf_l); lv_obj_align(labelE1Value, buttonE1Value, LV_ALIGN_CENTER, 0, 0); - #endif + //#endif } lv_label_set_text(label_Back, common_menu.text_back); @@ -381,6 +377,11 @@ void lv_draw_tmc_current_settings(void) { } } -void lv_clear_tmc_current_settings() { lv_obj_del(scr); } +void lv_clear_tmc_current_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI && HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp index b0d40fde28db..3e014a781cf0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp @@ -33,6 +33,7 @@ #include "../../../../gcode/gcode.h" #include "../../../../module/planner.h" +extern lv_group_t * g; static lv_obj_t * scr; #define ID_TMC_MODE_RETURN 1 @@ -47,9 +48,9 @@ static lv_obj_t * scr; static lv_obj_t *labelXState = NULL, *labelYState = NULL, *labelZState = NULL, *labelE0State = NULL; static lv_obj_t *buttonXState = NULL, *buttonYState = NULL, *buttonZState = NULL, *buttonE0State = NULL; -#if AXIS_HAS_STEALTHCHOP(E1) +//#if AXIS_HAS_STEALTHCHOP(E1) static lv_obj_t *labelE1State = NULL, *buttonE1State = NULL; -#endif +//#endif static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { @@ -63,136 +64,158 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { draw_return_ui(); } break; - case ID_TMC_MODE_X: - if (event == LV_EVENT_CLICKED) { - } - else if (event == LV_EVENT_RELEASED) { - if (stepperX.stored.stealthChop_enabled == true) { - stepperX.stored.stealthChop_enabled = false; - stepperX.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_disable.bin", 0); - lv_label_set_text(labelXState, machine_menu.disable); - //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); - // gcode.process_subcommands_now_P(PSTR("M500")); - } - else { - stepperX.stored.stealthChop_enabled = true; - stepperX.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_enable.bin", 0); - lv_label_set_text(labelXState, machine_menu.enable); - // gcode.process_subcommands_now_P(PSTR("M500")); - } - gcode.process_subcommands_now_P(PSTR("M500")); - } - break; - case ID_TMC_MODE_Y: - if (event == LV_EVENT_CLICKED) { + #if AXIS_HAS_STEALTHCHOP(X) + case ID_TMC_MODE_X: + if (event == LV_EVENT_CLICKED) { - } - else if (event == LV_EVENT_RELEASED) { - if (stepperY.stored.stealthChop_enabled == true) { - stepperY.stored.stealthChop_enabled = false; - stepperY.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_disable.bin", 0); - lv_label_set_text(labelYState, machine_menu.disable); - //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); } - else { - stepperY.stored.stealthChop_enabled = true; - stepperY.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_enable.bin", 0); - lv_label_set_text(labelYState, machine_menu.enable); + else if (event == LV_EVENT_RELEASED) { + if (stepperX.stored.stealthChop_enabled) { + stepperX.stored.stealthChop_enabled = false; + stepperX.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + lv_label_set_text(labelXState, machine_menu.disable); + //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); + // gcode.process_subcommands_now_P(PSTR("M500")); + } + else { + stepperX.stored.stealthChop_enabled = true; + stepperX.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + lv_label_set_text(labelXState, machine_menu.enable); + // gcode.process_subcommands_now_P(PSTR("M500")); + } + gcode.process_subcommands_now_P(PSTR("M500")); } - gcode.process_subcommands_now_P(PSTR("M500")); - } - break; - case ID_TMC_MODE_Z: - if (event == LV_EVENT_CLICKED) { + break; + #endif // if AXIS_HAS_STEALTHCHOP(X) - } - else if (event == LV_EVENT_RELEASED) { - if (stepperZ.stored.stealthChop_enabled == true) { - stepperZ.stored.stealthChop_enabled = false; - stepperZ.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_disable.bin", 0); - lv_label_set_text(labelZState, machine_menu.disable); - //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); - } - else { - stepperZ.stored.stealthChop_enabled = true; - stepperZ.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_enable.bin", 0); - lv_label_set_text(labelZState, machine_menu.enable); - } - gcode.process_subcommands_now_P(PSTR("M500")); - } - break; - case ID_TMC_MODE_E0: - if (event == LV_EVENT_CLICKED) { + #if AXIS_HAS_STEALTHCHOP(Y) + case ID_TMC_MODE_Y: + if (event == LV_EVENT_CLICKED) { - } - else if (event == LV_EVENT_RELEASED) { - if (stepperE0.stored.stealthChop_enabled == true) { - stepperE0.stored.stealthChop_enabled = false; - stepperE0.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_disable.bin", 0); - lv_label_set_text(labelE0State, machine_menu.disable); - //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); } - else { - stepperE0.stored.stealthChop_enabled = true; - stepperE0.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_enable.bin", 0); - lv_label_set_text(labelE0State, machine_menu.enable); + else if (event == LV_EVENT_RELEASED) { + if (stepperY.stored.stealthChop_enabled) { + stepperY.stored.stealthChop_enabled = false; + stepperY.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + lv_label_set_text(labelYState, machine_menu.disable); + //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); + } + else { + stepperY.stored.stealthChop_enabled = true; + stepperY.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + lv_label_set_text(labelYState, machine_menu.enable); + } + gcode.process_subcommands_now_P(PSTR("M500")); } - gcode.process_subcommands_now_P(PSTR("M500")); - } - break; - #if AXIS_HAS_STEALTHCHOP(E1) - case ID_TMC_MODE_E1: - if (event == LV_EVENT_CLICKED) { + break; + #endif // if AXIS_HAS_STEALTHCHOP(Y) + #if AXIS_HAS_STEALTHCHOP(Z) + case ID_TMC_MODE_Z: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + if (stepperZ.stored.stealthChop_enabled) { + stepperZ.stored.stealthChop_enabled = false; + stepperZ.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + lv_label_set_text(labelZState, machine_menu.disable); + //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); } - else if (event == LV_EVENT_RELEASED) { - if (stepperE1.stored.stealthChop_enabled == true) { - stepperE1.stored.stealthChop_enabled = false; - stepperE1.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_disable.bin", 0); - lv_label_set_text(labelE1State, machine_menu.disable); - //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); - } - else { - stepperE1.stored.stealthChop_enabled = true; - stepperE1.refresh_stepping_mode(); - lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_enable.bin", 0); - lv_label_set_text(labelE1State, machine_menu.enable); - } - gcode.process_subcommands_now_P(PSTR("M500")); + else { + stepperZ.stored.stealthChop_enabled = true; + stepperZ.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + lv_label_set_text(labelZState, machine_menu.enable); } - break; + gcode.process_subcommands_now_P(PSTR("M500")); + } + break; + #endif // if AXIS_HAS_STEALTHCHOP(Z) - case ID_TMC_MODE_UP: - if (event == LV_EVENT_CLICKED) { + #if AXIS_HAS_STEALTHCHOP(E0) + case ID_TMC_MODE_E0: + if (event == LV_EVENT_CLICKED) { + } + else if (event == LV_EVENT_RELEASED) { + if (stepperE0.stored.stealthChop_enabled) { + stepperE0.stored.stealthChop_enabled = false; + stepperE0.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + lv_label_set_text(labelE0State, machine_menu.disable); + //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); } - else if (event == LV_EVENT_RELEASED) { - uiCfg.para_ui_page = 0; - lv_clear_tmc_step_mode_settings(); - lv_draw_tmc_step_mode_settings(); + else { + stepperE0.stored.stealthChop_enabled = true; + stepperE0.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + lv_label_set_text(labelE0State, machine_menu.enable); } - break; - case ID_TMC_MODE_DOWN: - if (event == LV_EVENT_CLICKED) { + gcode.process_subcommands_now_P(PSTR("M500")); + } + break; + #endif // if AXIS_HAS_STEALTHCHOP(E0) + + #if AXIS_HAS_STEALTHCHOP(E1) + case ID_TMC_MODE_E1: + if (event == LV_EVENT_CLICKED) { + } + else if (event == LV_EVENT_RELEASED) { + if (stepperE1.stored.stealthChop_enabled) { + stepperE1.stored.stealthChop_enabled = false; + stepperE1.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + lv_label_set_text(labelE1State, machine_menu.disable); + //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0); } - else if (event == LV_EVENT_RELEASED) { - uiCfg.para_ui_page = 1; - lv_clear_tmc_step_mode_settings(); - lv_draw_tmc_step_mode_settings(); + else { + stepperE1.stored.stealthChop_enabled = true; + stepperE1.refresh_stepping_mode(); + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + lv_label_set_text(labelE1State, machine_menu.enable); } - break; - #endif // if AXIS_HAS_STEALTHCHOP(E1) + gcode.process_subcommands_now_P(PSTR("M500")); + } + break; + #endif // if AXIS_HAS_STEALTHCHOP(E1) + case ID_TMC_MODE_UP: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.para_ui_page = 0; + lv_clear_tmc_step_mode_settings(); + lv_draw_tmc_step_mode_settings(); + } + break; + case ID_TMC_MODE_DOWN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.para_ui_page = 1; + lv_clear_tmc_step_mode_settings(); + lv_draw_tmc_step_mode_settings(); + } + break; } } @@ -204,10 +227,10 @@ void lv_draw_tmc_step_mode_settings(void) { lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL; lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; - #if AXIS_HAS_STEALTHCHOP(E1) + //#if AXIS_HAS_STEALTHCHOP(E1) lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL; lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL; - #endif + //#endif labelXState = NULL; @@ -218,10 +241,10 @@ void lv_draw_tmc_step_mode_settings(void) { buttonZState = NULL; labelE0State = NULL; buttonE0State = NULL; - #if AXIS_HAS_STEALTHCHOP(E1) + //#if AXIS_HAS_STEALTHCHOP(E1) labelE1State = NULL; buttonE1State = NULL; - #endif + //#endif if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_MODE_UI) { disp_state_stack._disp_index++; @@ -242,10 +265,6 @@ void lv_draw_tmc_step_mode_settings(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_para_back); - LV_IMG_DECLARE(bmp_para_state); - // LV_IMG_DECLARE(bmp_para_bank); - if (uiCfg.para_ui_page != 1) { buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ @@ -258,16 +277,28 @@ void lv_draw_tmc_step_mode_settings(void) { buttonXState = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonXState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V); - if (stepperX.get_stealthChop_status()) - lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_enable.bin", 0); - else - lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_disable.bin", 0); - lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, &bmp_para_state); - lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, &bmp_para_state); + #if AXIS_HAS_STEALTHCHOP(X) + if (stepperX.get_stealthChop_status()) { + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + } + else { + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + } + #else + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + #endif + lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, NULL, 0); + lv_imgbtn_set_style(buttonXState, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonXState, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonXState, LV_LAYOUT_OFF); labelXState = lv_label_create(buttonXState, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXState); + #endif line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); @@ -283,16 +314,28 @@ void lv_draw_tmc_step_mode_settings(void) { buttonYState = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonYState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_STATE_V); - if (stepperY.get_stealthChop_status()) - lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_enable.bin", 0); - else - lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_disable.bin", 0); - lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, &bmp_para_state); - lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, &bmp_para_state); + #if AXIS_HAS_STEALTHCHOP(Y) + if (stepperY.get_stealthChop_status()) { + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + } + else { + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + } + #else + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + #endif + lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, NULL, 0); + lv_imgbtn_set_style(buttonYState, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonYState, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonYState, LV_LAYOUT_OFF); labelYState = lv_label_create(buttonYState, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYState); + #endif line2 = lv_line_create(scr, NULL); lv_ex_line(line2, line_points[1]); @@ -308,16 +351,27 @@ void lv_draw_tmc_step_mode_settings(void) { buttonZState = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonZState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_STATE_V); - if (stepperZ.get_stealthChop_status()) - lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_enable.bin", 0); - else - lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_disable.bin", 0); - lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, &bmp_para_state); - lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, &bmp_para_state); + #if AXIS_HAS_STEALTHCHOP(Z) + if (stepperZ.get_stealthChop_status()) { + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + } + else { + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + } + #else + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + #endif + lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, NULL, 0); lv_imgbtn_set_style(buttonZState, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonZState, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonZState, LV_LAYOUT_OFF); labelZState = lv_label_create(buttonZState, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZState); + #endif line3 = lv_line_create(scr, NULL); lv_ex_line(line3, line_points[2]); @@ -333,31 +387,48 @@ void lv_draw_tmc_step_mode_settings(void) { buttonE0State = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonE0State, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V); - if (stepperE0.get_stealthChop_status()) - lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_enable.bin", 0); - else - lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_disable.bin", 0); - lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, &bmp_para_state); - lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, &bmp_para_state); + #if AXIS_HAS_STEALTHCHOP(E0) + if (stepperE0.get_stealthChop_status()) { + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + } + else { + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + } + #else + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + #endif + + lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, NULL, 0); + lv_imgbtn_set_style(buttonE0State, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonE0State, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonE0State, LV_LAYOUT_OFF); labelE0State = lv_label_create(buttonE0State, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonE0State); + #endif + line4 = lv_line_create(scr, NULL); lv_ex_line(line4, line_points[3]); - #if AXIS_HAS_STEALTHCHOP(E1) + //#if AXIS_HAS_STEALTHCHOP(E1) buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_DOWN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_DOWN, NULL, 0); + lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); - #endif + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage); + #endif + //#endif } else { - #if AXIS_HAS_STEALTHCHOP(E1) + //#if AXIS_HAS_STEALTHCHOP(E1) buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ @@ -369,40 +440,54 @@ void lv_draw_tmc_step_mode_settings(void) { buttonE1State = lv_imgbtn_create(scr, NULL); lv_obj_set_pos(buttonE1State, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V); - if (stepperE1.get_stealthChop_status()) - lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_enable.bin", 0); - else - lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_disable.bin", 0); - lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, &bmp_para_state); - lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, &bmp_para_state); + #if AXIS_HAS_STEALTHCHOP(E1) + if (stepperE1.get_stealthChop_status()) { + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + } + else { + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + } + #else + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + #endif + lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, NULL, 0); lv_imgbtn_set_style(buttonE1State, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonE1State, LV_BTN_STATE_REL, &tft_style_label_rel); lv_btn_set_layout(buttonE1State, LV_LAYOUT_OFF); labelE1State = lv_label_create(buttonE1State, NULL); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonE1State); + #endif line1 = lv_line_create(scr, NULL); lv_ex_line(line1, line_points[0]); buttonTurnPage = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_UP, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back); + lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_UP, NULL, 0); + lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel); - #endif + //#endif } - #if AXIS_HAS_STEALTHCHOP(E1) + //#if AXIS_HAS_STEALTHCHOP(E1) lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF); labelTurnPage = lv_label_create(buttonTurnPage, NULL); - #endif + //#endif buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_MODE_RETURN, "bmp_back70x40.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_MODE_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); @@ -422,50 +507,68 @@ void lv_draw_tmc_step_mode_settings(void) { lv_label_set_text(labelE0Text, machine_menu.E0_StepMode); lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0); + #if AXIS_HAS_STEALTHCHOP(X) if (stepperX.get_stealthChop_status()) lv_label_set_text(labelXState, machine_menu.enable); else lv_label_set_text(labelXState, machine_menu.disable); + #else + lv_label_set_text(labelXState, machine_menu.disable); + #endif lv_obj_align(labelXState, buttonXState, LV_ALIGN_CENTER, 0, 0); + #if AXIS_HAS_STEALTHCHOP(Y) if (stepperY.get_stealthChop_status()) lv_label_set_text(labelYState, machine_menu.enable); else lv_label_set_text(labelYState, machine_menu.disable); + #else + lv_label_set_text(labelYState, machine_menu.disable); + #endif lv_obj_align(labelYState, buttonYState, LV_ALIGN_CENTER, 0, 0); + #if AXIS_HAS_STEALTHCHOP(Z) if (stepperZ.get_stealthChop_status()) lv_label_set_text(labelZState, machine_menu.enable); else lv_label_set_text(labelZState, machine_menu.disable); + #else + lv_label_set_text(labelZState, machine_menu.disable); + #endif lv_obj_align(labelZState, buttonZState, LV_ALIGN_CENTER, 0, 0); + #if AXIS_HAS_STEALTHCHOP(E0) if (stepperE0.get_stealthChop_status()) lv_label_set_text(labelE0State, machine_menu.enable); else lv_label_set_text(labelE0State, machine_menu.disable); + #else + lv_label_set_text(labelE0State, machine_menu.disable); + #endif lv_obj_align(labelE0State, buttonE0State, LV_ALIGN_CENTER, 0, 0); - #if AXIS_HAS_STEALTHCHOP(E1) + //#if AXIS_HAS_STEALTHCHOP(E1) lv_label_set_text(labelTurnPage, machine_menu.next); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); - #endif + //#endif } else { - #if AXIS_HAS_STEALTHCHOP(E1) + //#if AXIS_HAS_STEALTHCHOP(E1) lv_label_set_text(labelE1Text, machine_menu.E1_StepMode); lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0); - + #if AXIS_HAS_STEALTHCHOP(E1) if (stepperE1.get_stealthChop_status()) lv_label_set_text(labelE1State, machine_menu.enable); else lv_label_set_text(labelE1State, machine_menu.disable); + #else + lv_label_set_text(labelE1State, machine_menu.disable); + #endif lv_obj_align(labelE1State, buttonE1State, LV_ALIGN_CENTER, 0, 0); lv_label_set_text(labelTurnPage, machine_menu.previous); lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); - - #endif + //#endif } lv_label_set_text(label_Back, common_menu.text_back); @@ -473,6 +576,11 @@ void lv_draw_tmc_step_mode_settings(void) { } } -void lv_clear_tmc_step_mode_settings() { lv_obj_del(scr); } +void lv_clear_tmc_step_mode_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI && HAS_STEALTHCHOP diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp index a2d0937e4767..3681b1b2d601 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -32,8 +32,9 @@ #include "../../../../MarlinCore.h" #include "../../../../gcode/queue.h" +#include "../../../../module/temperature.h" -// static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn; +extern lv_group_t * g; static lv_obj_t * scr; #define ID_T_PRE_HEAT 1 @@ -45,6 +46,10 @@ static lv_obj_t * scr; #define ID_T_MORE 7 #define ID_T_RETURN 8 +#if ENABLED(MKS_TEST) + extern uint8_t curent_disp_ui; +#endif + static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_T_PRE_HEAT: @@ -89,8 +94,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - queue.enqueue_one_P(PSTR("G28")); - queue.enqueue_one_P(PSTR("G29")); + //queue.enqueue_one_P(PSTR("G28")); + //queue.enqueue_one_P(PSTR("G29")); + get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m); + public_buf_m[sizeof(public_buf_m)-1] = 0; + queue.inject_P(PSTR(public_buf_m)); #else uiCfg.leveling_first_time = 1; lv_clear_tool(); @@ -98,7 +106,16 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { #endif } break; - case ID_T_FILAMENT: break; + case ID_T_FILAMENT: + if (event == LV_EVENT_CLICKED) { + // nothing to do + } + else if (event == LV_EVENT_RELEASED) { + uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target; + lv_clear_tool(); + lv_draw_filament_change(); + } + break; case ID_T_MORE: break; case ID_T_RETURN: if (event == LV_EVENT_CLICKED) { @@ -106,7 +123,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { } else if (event == LV_EVENT_RELEASED) { TERN_(MKS_TEST, curent_disp_ui = 1); - lv_obj_del(scr); + lv_clear_tool(); lv_draw_ready_print(); } break; @@ -115,6 +132,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { void lv_draw_tool(void) { lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonMove, *buttonHome, *buttonLevel; + lv_obj_t *buttonFilament; lv_obj_t *buttonBack; if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TOOL_UI) { @@ -138,75 +156,64 @@ void lv_draw_tool(void) { lv_refr_now(lv_refr_get_disp_refreshing()); - LV_IMG_DECLARE(bmp_pic); - // Create image buttons buttonPreHeat = lv_imgbtn_create(scr, NULL); buttonExtrusion = lv_imgbtn_create(scr, NULL); buttonMove = lv_imgbtn_create(scr, NULL); buttonHome = lv_imgbtn_create(scr, NULL); buttonLevel = lv_imgbtn_create(scr, NULL); - // buttonFilament = lv_imgbtn_create(scr, NULL); - // buttonMore = lv_imgbtn_create(scr, NULL); - buttonBack = lv_imgbtn_create(scr, NULL); + buttonFilament = lv_imgbtn_create(scr, NULL); + //buttonMore = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); - lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_T_PRE_HEAT, "bmp_preHeat.bin", 0); - lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, &bmp_pic); + lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_T_PRE_HEAT, NULL, 0); + lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, "F:/bmp_preHeat.bin"); + lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, "F:/bmp_preHeat.bin"); lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_REL, &tft_style_label_rel); - lv_obj_clear_protect(buttonPreHeat, LV_PROTECT_FOLLOW); - - #if 1 - lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_T_EXTRUCT, "bmp_extruct.bin", 0); - lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_T_MOV, "bmp_mov.bin", 0); - lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonHome, event_handler, ID_T_HOME, "bmp_zero.bin", 0); - lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_T_LEVELING, "bmp_leveling.bin", 0); - lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_REL, &tft_style_label_rel); - - //lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_T_FILAMENT,"bmp_Filamentchange.bin",0); - //lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, &bmp_pic); - //lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, &bmp_pic); - //lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre); - //lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel); - - //lv_obj_set_event_cb_mks(buttonMore, event_handler,ID_T_MORE,"bmp_More.bin",0); - //lv_imgbtn_set_src(buttonMore, LV_BTN_STATE_REL, &bmp_pic); - //lv_imgbtn_set_src(buttonMore, LV_BTN_STATE_PR, &bmp_pic); - //lv_imgbtn_set_style(buttonMore, LV_BTN_STATE_PR, &tft_style_label_pre); - //lv_imgbtn_set_style(buttonMore, LV_BTN_STATE_REL, &tft_style_label_rel); - - lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_T_RETURN, "bmp_return.bin", 0); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic); - lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); - lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); - #endif // if 1 + + lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_T_EXTRUCT, NULL, 0); + lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, "F:/bmp_extruct.bin"); + lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, "F:/bmp_extruct.bin"); + lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_T_MOV, NULL, 0); + lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, "F:/bmp_mov.bin"); + lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, "F:/bmp_mov.bin"); + lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonHome, event_handler, ID_T_HOME, NULL, 0); + lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_REL, "F:/bmp_zero.bin"); + lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_PR, "F:/bmp_zero.bin"); + lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_T_LEVELING, NULL, 0); + lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_REL, "F:/bmp_leveling.bin"); + lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_PR, "F:/bmp_leveling.bin"); + lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_T_FILAMENT,NULL,0); + lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, "F:/bmp_filamentchange.bin"); + lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, "F:/bmp_filamentchange.bin"); + lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_T_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight); lv_obj_set_pos(buttonExtrusion, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); lv_obj_set_pos(buttonMove, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); lv_obj_set_pos(buttonHome, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); lv_obj_set_pos(buttonLevel, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); - //lv_obj_set_pos(buttonFilament,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight); + lv_obj_set_pos(buttonFilament,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight); //lv_obj_set_pos(buttonMore,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight); lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); @@ -216,18 +223,18 @@ void lv_draw_tool(void) { lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF); lv_btn_set_layout(buttonHome, LV_LAYOUT_OFF); lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF); - //lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF); //lv_btn_set_layout(buttonMore, LV_LAYOUT_OFF); lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); - lv_obj_t * labelPreHeat = lv_label_create(buttonPreHeat, NULL); - lv_obj_t * labelExtrusion = lv_label_create(buttonExtrusion, NULL); - lv_obj_t * label_Move = lv_label_create(buttonMove, NULL); - lv_obj_t * label_Home = lv_label_create(buttonHome, NULL); - lv_obj_t * label_Level = lv_label_create(buttonLevel, NULL); - //lv_obj_t * label_Filament = lv_label_create(buttonFilament, NULL); - //lv_obj_t * label_More = lv_label_create(buttonMore, NULL); - lv_obj_t * label_Back = lv_label_create(buttonBack, NULL); + lv_obj_t *labelPreHeat = lv_label_create(buttonPreHeat, NULL); + lv_obj_t *labelExtrusion = lv_label_create(buttonExtrusion, NULL); + lv_obj_t *label_Move = lv_label_create(buttonMove, NULL); + lv_obj_t *label_Home = lv_label_create(buttonHome, NULL); + lv_obj_t *label_Level = lv_label_create(buttonLevel, NULL); + lv_obj_t *label_Filament = lv_label_create(buttonFilament, NULL); + //lv_obj_t *label_More = lv_label_create(buttonMore, NULL); + lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); if (gCfgItems.multiple_language != 0) { lv_label_set_text(labelPreHeat, tool_menu.preheat); @@ -242,17 +249,11 @@ void lv_draw_tool(void) { lv_label_set_text(label_Home, tool_menu.home); lv_obj_align(label_Home, buttonHome, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - /* - if (gCfgItems.leveling_mode != 2) { - lv_label_set_text(label_Level, gCfgItems.leveling_mode == 1 ? tool_menu.autoleveling : tool_menu.leveling); - lv_obj_align(label_Level, buttonLevel, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - } - */ lv_label_set_text(label_Level, tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling)); lv_obj_align(label_Level, buttonLevel, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - //lv_label_set_text(label_Filament, tool_menu.filament); - //lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + lv_label_set_text(label_Filament, tool_menu.filament); + lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); //lv_label_set_text(label_More, tool_menu.more); //lv_obj_align(label_More, buttonMore, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -260,8 +261,24 @@ void lv_draw_tool(void) { lv_label_set_text(label_Back, common_menu.text_back); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonPreHeat); + lv_group_add_obj(g, buttonExtrusion); + lv_group_add_obj(g, buttonMove); + lv_group_add_obj(g, buttonHome); + lv_group_add_obj(g, buttonLevel); + lv_group_add_obj(g, buttonFilament); + lv_group_add_obj(g, buttonBack); + } + #endif } -void lv_clear_tool() { lv_obj_del(scr); } +void lv_clear_tool() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp index 6bdea3fd2101..922f6a2dc71c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -55,7 +55,8 @@ DISP_STATE_STACK disp_state_stack; DISP_STATE disp_state = MAIN_UI; DISP_STATE last_disp_state; PRINT_TIME print_time; -value_state value; +num_key_value_state value; +keyboard_value_state keyboard_value; uint32_t To_pre_view; uint8_t gcode_preview_over; @@ -73,6 +74,14 @@ extern uint8_t bmp_public_buf[17 * 1024]; extern void LCD_IO_WriteData(uint16_t RegValue); +static const char custom_gcode_command[][100] = { + "G28\nG29\nM500", + "G28", + "G28", + "G28", + "G28" +}; + lv_point_t line_points[4][2] = { {{PARA_UI_POS_X, PARA_UI_POS_Y + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y + PARA_UI_SIZE_Y}}, {{PARA_UI_POS_X, PARA_UI_POS_Y*2 + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y*2 + PARA_UI_SIZE_Y}}, @@ -108,22 +117,58 @@ void gCfgItems_init() { #elif LCD_LANGUAGE == pt gCfgItems.language = LANG_PORTUGUESE; #endif - gCfgItems.leveling_mode = 0; - gCfgItems.from_flash_pic = 0; - gCfgItems.curFilesize = 0; - gCfgItems.finish_power_off = 0; - gCfgItems.pause_reprint = 0; - gCfgItems.pausePosX = -1; - gCfgItems.pausePosY = -1; - gCfgItems.pausePosZ = 5; + gCfgItems.leveling_mode = 0; + gCfgItems.from_flash_pic = 0; + gCfgItems.curFilesize = 0; + gCfgItems.finish_power_off = 0; + gCfgItems.pause_reprint = 0; + gCfgItems.pausePosX = -1; + gCfgItems.pausePosY = -1; + gCfgItems.pausePosZ = 5; + gCfgItems.levelingPos[0][0] = X_MIN_POS + 30; + gCfgItems.levelingPos[0][1] = Y_MIN_POS + 30; + gCfgItems.levelingPos[1][0] = X_MAX_POS - 30; + gCfgItems.levelingPos[1][1] = Y_MIN_POS + 30; + gCfgItems.levelingPos[2][0] = X_MAX_POS - 30; + gCfgItems.levelingPos[2][1] = Y_MAX_POS - 30; + gCfgItems.levelingPos[3][0] = X_MIN_POS + 30; + gCfgItems.levelingPos[3][1] = Y_MAX_POS - 30; + gCfgItems.levelingPos[4][0] = X_BED_SIZE / 2; + gCfgItems.levelingPos[4][1] = Y_BED_SIZE / 2; + gCfgItems.cloud_enable = true; + #if ENABLED(USE_WIFI_FUNCTION) + gCfgItems.wifi_mode_sel = STA_MODEL; + gCfgItems.fileSysType = FILE_SYS_SD; + gCfgItems.wifi_type = ESP_WIFI; + #endif + gCfgItems.filamentchange_load_length = 200; + gCfgItems.filamentchange_load_speed = 1000; + gCfgItems.filamentchange_unload_length = 200; + gCfgItems.filamentchange_unload_speed = 1000; + gCfgItems.filament_limit_temper = 200; + + gCfgItems.encoder_enable = true; + W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems.spi_flash_flag, VAR_INF_ADDR, sizeof(gCfgItems.spi_flash_flag)); - if (gCfgItems.spi_flash_flag == GCFG_FLAG_VALUE) { + if (gCfgItems.spi_flash_flag == FLASH_INF_VALID_FLAG) { W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); } else { - gCfgItems.spi_flash_flag = GCFG_FLAG_VALUE; + gCfgItems.spi_flash_flag = FLASH_INF_VALID_FLAG; W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); + //init gcode command + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[0], AUTO_LEVELING_COMMAND_ADDR, 100); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[1], OTHERS_COMMAND_ADDR_1, 100); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[2], OTHERS_COMMAND_ADDR_2, 100); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[3], OTHERS_COMMAND_ADDR_3, 100); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[4], OTHERS_COMMAND_ADDR_4, 100); + } + + const byte rot = TERN0(GRAPHICAL_TFT_ROTATE_180, 0xEE); + if (gCfgItems.disp_rotation_180 != rot) { + gCfgItems.disp_rotation_180 = rot; + update_spi_flash(); } uiCfg.F[0] = 'N'; @@ -134,11 +179,6 @@ void gCfgItems_init() { W25QXX.SPI_FLASH_BufferWrite(uiCfg.F,REFLSHE_FLGA_ADD,4); } -void gCfg_to_spiFlah() { - W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); - W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); -} - void ui_cfg_init() { uiCfg.curTempType = 0; uiCfg.curSprayerChoose = 0; @@ -150,12 +190,81 @@ void ui_cfg_init() { uiCfg.move_dist = 1; uiCfg.moveSpeed = 3000; uiCfg.stepPrintSpeed = 10; + uiCfg.command_send = 0; + uiCfg.dialogType = 0; + uiCfg.filament_heat_completed_load = 0; + uiCfg.filament_rate = 0; + uiCfg.filament_loading_completed = 0; + uiCfg.filament_unloading_completed = 0; + uiCfg.filament_loading_time_flg = 0; + uiCfg.filament_loading_time_cnt = 0; + uiCfg.filament_unloading_time_flg = 0; + uiCfg.filament_unloading_time_cnt = 0; + + #if ENABLED(USE_WIFI_FUNCTION) + memset(&wifiPara, 0, sizeof(wifiPara)); + memset(&ipPara, 0, sizeof(ipPara)); + strcpy(wifiPara.ap_name, WIFI_AP_NAME); + strcpy(wifiPara.keyCode, WIFI_KEY_CODE); + //client + strcpy(ipPara.ip_addr, IP_ADDR); + strcpy(ipPara.mask, IP_MASK); + strcpy(ipPara.gate, IP_GATE); + strcpy(ipPara.dns, IP_DNS); + + ipPara.dhcp_flag = IP_DHCP_FLAG; + + //AP + strcpy(ipPara.dhcpd_ip, AP_IP_ADDR); + strcpy(ipPara.dhcpd_mask, AP_IP_MASK); + strcpy(ipPara.dhcpd_gate, AP_IP_GATE); + strcpy(ipPara.dhcpd_dns, AP_IP_DNS); + strcpy(ipPara.start_ip_addr, IP_START_IP); + strcpy(ipPara.end_ip_addr, IP_END_IP); + + ipPara.dhcpd_flag = AP_IP_DHCP_FLAG; + + strcpy((char*)uiCfg.cloud_hostUrl, "baizhongyun.cn"); + uiCfg.cloud_port = 10086; + #endif + + uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0 / gCfgItems.filamentchange_load_speed) + 0.5); + uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0 / gCfgItems.filamentchange_unload_speed) + 0.5); } void update_spi_flash() { + uint8_t command_buf[512]; + + W25QXX.init(SPI_QUARTER_SPEED); + //read back the gcode command befor erase spi flash + W25QXX.SPI_FLASH_BufferRead((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf)); + W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf)); +} + +void update_gcode_command(int addr,uint8_t *s) { + uint8_t command_buf[512]; + W25QXX.init(SPI_QUARTER_SPEED); + //read back the gcode command befor erase spi flash + W25QXX.SPI_FLASH_BufferRead((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf)); W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); + switch (addr) { + case AUTO_LEVELING_COMMAND_ADDR: memcpy(&command_buf[0*100], s, 100); break; + case OTHERS_COMMAND_ADDR_1: memcpy(&command_buf[1*100], s, 100); break; + case OTHERS_COMMAND_ADDR_2: memcpy(&command_buf[2*100], s, 100); break; + case OTHERS_COMMAND_ADDR_3: memcpy(&command_buf[3*100], s, 100); break; + case OTHERS_COMMAND_ADDR_4: memcpy(&command_buf[4*100], s, 100); break; + default: break; + } + W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf)); +} + +void get_gcode_command(int addr,uint8_t *d) { + W25QXX.init(SPI_QUARTER_SPEED); + W25QXX.SPI_FLASH_BufferRead((uint8_t *)d, addr, 100); } lv_style_t tft_style_scr; @@ -169,6 +278,13 @@ lv_style_t style_num_key_pre; lv_style_t style_num_key_rel; lv_style_t style_num_text; +lv_style_t style_sel_text; + +lv_style_t style_para_value; +lv_style_t style_para_back; + +lv_style_t lv_bar_style_indic; + void tft_style_init() { lv_style_copy(&tft_style_scr, &lv_style_scr); tft_style_scr.body.main_color = LV_COLOR_BACKGROUND; @@ -197,12 +313,13 @@ void tft_style_init() { tft_style_label_rel.text.letter_space = 0; tft_style_label_pre.text.line_space = -5; tft_style_label_rel.text.line_space = -5; + lv_style_copy(&style_para_value_pre, &lv_style_scr); lv_style_copy(&style_para_value_rel, &lv_style_scr); style_para_value_pre.body.main_color = LV_COLOR_BACKGROUND; style_para_value_pre.body.grad_color = LV_COLOR_BACKGROUND; - style_para_value_pre.text.color = LV_COLOR_BLACK; - style_para_value_pre.text.sel_color = LV_COLOR_BLACK; + style_para_value_pre.text.color = LV_COLOR_TEXT; + style_para_value_pre.text.sel_color = LV_COLOR_TEXT; style_para_value_rel.body.main_color = LV_COLOR_BACKGROUND; style_para_value_rel.body.grad_color = LV_COLOR_BACKGROUND; style_para_value_rel.text.color = LV_COLOR_BLACK; @@ -215,6 +332,7 @@ void tft_style_init() { style_para_value_rel.text.letter_space = 0; style_para_value_pre.text.line_space = -5; style_para_value_rel.text.line_space = -5; + lv_style_copy(&style_num_key_pre, &lv_style_scr); lv_style_copy(&style_num_key_rel, &lv_style_scr); style_num_key_pre.body.main_color = LV_COLOR_KEY_BACKGROUND; @@ -250,10 +368,48 @@ void tft_style_init() { style_num_text.text.letter_space = 0; style_num_text.text.line_space = -5; + lv_style_copy(&style_sel_text, &lv_style_scr); + style_sel_text.body.main_color = LV_COLOR_BACKGROUND; + style_sel_text.body.grad_color = LV_COLOR_BACKGROUND; + style_sel_text.text.color = LV_COLOR_YELLOW; + style_sel_text.text.sel_color = LV_COLOR_YELLOW; + style_sel_text.text.font = &gb2312_puhui32; + style_sel_text.line.width = 0; + style_sel_text.text.letter_space = 0; + style_sel_text.text.line_space = -5; lv_style_copy(&style_line, &lv_style_plain); style_line.line.color = LV_COLOR_MAKE(0x49, 0x54, 0xff); style_line.line.width = 1; style_line.line.rounded = 1; + + lv_style_copy(&style_para_value, &lv_style_plain); + style_para_value.body.border.color = LV_COLOR_BACKGROUND; + style_para_value.body.border.width = 1; + style_para_value.body.main_color = LV_COLOR_WHITE; + style_para_value.body.grad_color = LV_COLOR_WHITE; + style_para_value.body.shadow.width = 0; + style_para_value.body.radius = 3; + style_para_value.text.color = LV_COLOR_BLACK; + style_para_value.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22); + + lv_style_copy(&style_para_back, &lv_style_plain); + style_para_back.body.border.color = LV_COLOR_BACKGROUND; + style_para_back.body.border.width = 1; + style_para_back.body.main_color = TFT_LV_PARA_BACK_BODY_COLOR; + style_para_back.body.grad_color = TFT_LV_PARA_BACK_BODY_COLOR; + style_para_back.body.shadow.width = 0; + style_para_back.body.radius = 3; + style_para_back.text.color = LV_COLOR_WHITE; + style_para_back.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22); + + lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color); + lv_bar_style_indic.text.color = lv_color_hex3(0xADF); + lv_bar_style_indic.image.color = lv_color_hex3(0xADF); + lv_bar_style_indic.line.color = lv_color_hex3(0xADF); + lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF); + lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF); + lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF); + } #define MAX_TITLE_LEN 28 @@ -360,15 +516,14 @@ char *getDispText(int index) { case BIND_UI: strcpy(public_buf_l, cloud_menu.title); break; - case ZOFFSET_UI: - strcpy(public_buf_l, zoffset_menu.title); - break; case TOOL_UI: strcpy(public_buf_l, tool_menu.title); break; case WIFI_LIST_UI: - //strcpy(public_buf_l, list_menu.title); - break; + #if ENABLED(USE_WIFI_FUNCTION) + strcpy(public_buf_l, list_menu.title); + break; + #endif case MACHINE_PARA_UI: strcpy(public_buf_l, MachinePara_menu.title); break; @@ -503,7 +658,7 @@ char *creat_title_text() { #if ENABLED(TFT_LVGL_UI_SPI) SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1); #else - ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1); + LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1); LCD_WriteRAM_Prepare(); #endif @@ -582,10 +737,10 @@ char *creat_title_text() { //saved_feedrate_percentage = feedrate_percentage; planner.flow_percentage[0] = 100; planner.e_factor[0] = planner.flow_percentage[0] * 0.01; - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER planner.flow_percentage[1] = 100; planner.e_factor[1] = planner.flow_percentage[1] * 0.01; - } + #endif card.startFileprint(); TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); once_flag = 0; @@ -615,7 +770,7 @@ char *creat_title_text() { #if ENABLED(TFT_LVGL_UI_SPI) SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1); #else - ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1); + LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1); LCD_WriteRAM_Prepare(); #endif @@ -714,10 +869,10 @@ char *creat_title_text() { //saved_feedrate_percentage = feedrate_percentage; planner.flow_percentage[0] = 100; planner.e_factor[0] = planner.flow_percentage[0] * 0.01; - if (EXTRUDERS == 2) { + #if HAS_MULTI_EXTRUDER planner.flow_percentage[1] = 100; planner.e_factor[1] = planner.flow_percentage[1] * 0.01; - } + #endif card.startFileprint(); TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); once_flag = 0; @@ -733,17 +888,17 @@ char *creat_title_text() { void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) { int index; int y_off = 0; - + W25QXX.init(SPI_QUARTER_SPEED); for (index = 0; index < 10; index++) { // 200*200 #if HAS_BAK_VIEW_IN_FLASH if (sel == 1) { flash_view_Read(bmp_public_buf, 8000); // 20k } else { - default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 20k + default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k } #else - default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 20k + default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k #endif #if ENABLED(TFT_LVGL_UI_SPI) @@ -754,7 +909,7 @@ char *creat_title_text() { uint16_t temp_p; int i = 0; uint16_t *p_index; - ili9320_SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200 + LCD_setWindowArea(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200 LCD_WriteRAM_Prepare(); @@ -904,29 +1059,28 @@ void GUI_RefreshPage() { */ break; - case WIFI_UI: - /* - if (wifi_refresh_flg == 1) { - disp_wifi_state(); - wifi_refresh_flg = 0; - } - */ - break; + #if ENABLED(USE_WIFI_FUNCTION) + case WIFI_UI: + if (temperature_change_frequency == 1) { + disp_wifi_state(); + temperature_change_frequency = 0; + } + break; + #endif + case BIND_UI: /*refresh_bind_ui();*/ break; case FILAMENTCHANGE_UI: - /* if (temperature_change_frequency) { temperature_change_frequency = 0; - disp_filament_sprayer_temp(); + disp_filament_temp(); } - */ break; case DIALOG_UI: - /*filament_dialog_handle(); - wifi_scan_handle();*/ + filament_dialog_handle(); + TERN_(USE_WIFI_FUNCTION, wifi_scan_handle()); break; case MESHLEVELING_UI: /*disp_zpos();*/ @@ -934,66 +1088,68 @@ void GUI_RefreshPage() { case HARDWARE_TEST_UI: break; case WIFI_LIST_UI: - /* - if (wifi_refresh_flg == 1) { - disp_wifi_list(); - wifi_refresh_flg = 0; - } - */ + #if ENABLED(USE_WIFI_FUNCTION) + if (printing_rate_update_flag == 1) { + disp_wifi_list(); + printing_rate_update_flag = 0; + } + #endif break; case KEY_BOARD_UI: /*update_password_disp(); update_join_state_disp();*/ break; - case TIPS_UI: - /* - switch (tips_type) { - case TIPS_TYPE_JOINING: - if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex]) == 0) { - tips_disp.timer = TIPS_TIMER_STOP; - tips_disp.timer_count = 0; - Clear_Tips(); - tips_type = TIPS_TYPE_WIFI_CONECTED; - draw_Tips(); - } - if (tips_disp.timer_count >= 30) { - tips_disp.timer = TIPS_TIMER_STOP; - tips_disp.timer_count = 0; - Clear_Tips(); - tips_type = TIPS_TYPE_TAILED_JOIN; - draw_Tips(); - } - break; - case TIPS_TYPE_TAILED_JOIN: - if (tips_disp.timer_count >= 3) { - tips_disp.timer = TIPS_TIMER_STOP; - tips_disp.timer_count = 0; - last_disp_state = TIPS_UI; - Clear_Tips(); - draw_Wifi_list(); - } - break; - case TIPS_TYPE_WIFI_CONECTED: - if (tips_disp.timer_count >= 3) { - tips_disp.timer = TIPS_TIMER_STOP; - tips_disp.timer_count = 0; - - last_disp_state = TIPS_UI; - Clear_Tips(); - draw_Wifi(); - } - break; - default: break; - } - */ - break; + #if ENABLED(USE_WIFI_FUNCTION) + case WIFI_TIPS_UI: + switch (wifi_tips_type) { + case TIPS_TYPE_JOINING: + if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName,(const char *)wifi_list.wifiName[wifi_list.nameIndex]) == 0) { + tips_disp.timer = TIPS_TIMER_STOP; + tips_disp.timer_count = 0; + + lv_clear_wifi_tips(); + wifi_tips_type = TIPS_TYPE_WIFI_CONECTED; + lv_draw_wifi_tips(); + + } + if (tips_disp.timer_count >= 30 * 1000) { + tips_disp.timer = TIPS_TIMER_STOP; + tips_disp.timer_count = 0; + lv_clear_wifi_tips(); + wifi_tips_type = TIPS_TYPE_TAILED_JOIN; + lv_draw_wifi_tips(); + } + break; + case TIPS_TYPE_TAILED_JOIN: + if (tips_disp.timer_count >= 3 * 1000) { + tips_disp.timer = TIPS_TIMER_STOP; + tips_disp.timer_count = 0; + + last_disp_state = WIFI_TIPS_UI; + lv_clear_wifi_tips(); + lv_draw_wifi_list(); + } + break; + case TIPS_TYPE_WIFI_CONECTED: + if (tips_disp.timer_count >= 3 * 1000) { + tips_disp.timer = TIPS_TIMER_STOP; + tips_disp.timer_count = 0; + + last_disp_state = WIFI_TIPS_UI; + lv_clear_wifi_tips(); + lv_draw_wifi(); + } + break; + default: break; + } + break; + #endif + case BABY_STEP_UI: - /* if (temperature_change_frequency == 1) { temperature_change_frequency = 0; disp_z_offset_value(); } - */ break; default: break; } @@ -1060,9 +1216,11 @@ void clear_cur_ui() { case DISK_UI: //Clear_Disk(); break; - case WIFI_UI: - //Clear_Wifi(); - break; + #if ENABLED(USE_WIFI_FUNCTION) + case WIFI_UI: + lv_clear_wifi(); + break; + #endif case MORE_UI: //Clear_more(); break; @@ -1078,15 +1236,20 @@ void clear_cur_ui() { case PRINT_MORE_UI: //Clear_Printmore(); break; + case FILAMENTCHANGE_UI: + lv_clear_filament_change(); + break; case LEVELING_UI: lv_clear_manualLevel(); break; case BIND_UI: //Clear_Bind(); break; - case ZOFFSET_UI: - //Clear_Zoffset(); - break; + #if HAS_BED_PROBE + case NOZZLE_PROBE_OFFSET_UI: + lv_clear_auto_level_offset_settings(); + break; + #endif case TOOL_UI: lv_clear_tool(); break; @@ -1096,15 +1259,19 @@ void clear_cur_ui() { case HARDWARE_TEST_UI: //Clear_Hardwaretest(); break; - case WIFI_LIST_UI: - //Clear_Wifi_list(); - break; + #if ENABLED(USE_WIFI_FUNCTION) + case WIFI_LIST_UI: + lv_clear_wifi_list(); + break; + #endif case KEY_BOARD_UI: - //Clear_Keyboard(); - break; - case TIPS_UI: - //Clear_Tips(); + lv_clear_keyboard(); break; + #if ENABLED(USE_WIFI_FUNCTION) + case WIFI_TIPS_UI: + lv_clear_wifi_tips(); + break; + #endif case MACHINE_PARA_UI: lv_clear_machine_para(); break; @@ -1130,19 +1297,19 @@ void clear_cur_ui() { //Clear_EndstopType(); break; case FILAMENT_SETTINGS_UI: - //Clear_FilamentSettings(); + lv_clear_filament_settings(); break; case LEVELING_SETTIGNS_UI: //Clear_LevelingSettings(); break; case LEVELING_PARA_UI: - //Clear_LevelingPara(); + lv_clear_level_settings(); break; case DELTA_LEVELING_PARA_UI: //Clear_DeltaLevelPara(); break; - case XYZ_LEVELING_PARA_UI: - //Clear_XYZLevelPara(); + case MANUAL_LEVELING_POSIGION_UI: + lv_clear_manual_level_pos_settings(); break; case MAXFEEDRATE_UI: lv_clear_max_feedrate_settings(); @@ -1183,7 +1350,7 @@ void clear_cur_ui() { lv_clear_number_key(); break; case BABY_STEP_UI: - //Clear_babyStep(); + lv_clear_baby_stepping(); break; case PAUSE_POS_UI: lv_clear_pause_position(); @@ -1201,8 +1368,22 @@ void clear_cur_ui() { lv_clear_tmc_step_mode_settings(); break; #endif - default: + #if ENABLED(USE_WIFI_FUNCTION) + case WIFI_SETTINGS_UI: + lv_clear_wifi_settings(); break; + #endif + #if USE_SENSORLESS + case HOMING_SENSITIVITY_UI: + lv_clear_homing_sensitivity_settings(); + break; + #endif + #if HAS_ROTARY_ENCODER + case ENCODER_SETTINGS_UI: + lv_clear_encoder_settings(); + break; + #endif + default: break; } //GUI_Clear(); } @@ -1267,21 +1448,17 @@ void draw_return_ui() { lv_draw_about(); break; - #if tan_mask - case LOG_UI: - //draw_Connect(); - break; - #endif - case CALIBRATE_UI: //draw_calibrate(); break; case DISK_UI: //draw_Disk(); break; - case WIFI_UI: - //draw_Wifi(); - break; + #if ENABLED(USE_WIFI_FUNCTION) + case WIFI_UI: + lv_draw_wifi(); + break; + #endif case MORE_UI: //draw_More(); break; @@ -1289,7 +1466,7 @@ void draw_return_ui() { //draw_printmore(); break; case FILAMENTCHANGE_UI: - //draw_FilamentChange(); + lv_draw_filament_change(); break; case LEVELING_UI: lv_draw_manualLevel(); @@ -1297,13 +1474,11 @@ void draw_return_ui() { case BIND_UI: //draw_bind(); break; - - #if tan_mask - case ZOFFSET_UI: - //draw_Zoffset(); - break; - #endif - + #if HAS_BED_PROBE + case NOZZLE_PROBE_OFFSET_UI: + lv_draw_auto_level_offset_settings(); + break; + #endif case TOOL_UI: lv_draw_tool(); break; @@ -1314,13 +1489,17 @@ void draw_return_ui() { //draw_Hardwaretest(); break; case WIFI_LIST_UI: - //draw_Wifi_list(); + #if ENABLED(USE_WIFI_FUNCTION) + lv_draw_wifi_list(); + #endif break; case KEY_BOARD_UI: - //draw_Keyboard(); + lv_draw_keyboard(); break; - case TIPS_UI: - //draw_Tips(); + case WIFI_TIPS_UI: + #if ENABLED(USE_WIFI_FUNCTION) + lv_draw_wifi_tips(); + #endif break; case MACHINE_PARA_UI: lv_draw_machine_para(); @@ -1347,19 +1526,19 @@ void draw_return_ui() { //draw_EndstopType(); break; case FILAMENT_SETTINGS_UI: - //draw_FilamentSettings(); + lv_draw_filament_settings(); break; case LEVELING_SETTIGNS_UI: //draw_LevelingSettings(); break; case LEVELING_PARA_UI: - //draw_LevelingPara(); + lv_draw_level_settings(); break; case DELTA_LEVELING_PARA_UI: //draw_DeltaLevelPara(); break; - case XYZ_LEVELING_PARA_UI: - //draw_XYZLevelPara(); + case MANUAL_LEVELING_POSIGION_UI: + lv_draw_manual_level_pos_settings(); break; case MAXFEEDRATE_UI: lv_draw_max_feedrate_settings(); @@ -1400,10 +1579,10 @@ void draw_return_ui() { lv_draw_number_key(); break; case DIALOG_UI: - //draw_dialog(DialogType); + //draw_dialog(uiCfg.dialogType); break; case BABY_STEP_UI: - //draw_babyStep(); + lv_draw_baby_stepping(); break; case PAUSE_POS_UI: lv_draw_pause_position(); @@ -1421,6 +1600,21 @@ void draw_return_ui() { lv_draw_tmc_step_mode_settings(); break; #endif + #if ENABLED(USE_WIFI_FUNCTION) + case WIFI_SETTINGS_UI: + lv_draw_wifi_settings(); + break; + #endif + #if USE_SENSORLESS + case HOMING_SENSITIVITY_UI: + lv_draw_homing_sensitivity_settings(); + break; + #endif + #if HAS_ROTARY_ENCODER + case ENCODER_SETTINGS_UI: + lv_draw_encoder_settings(); + break; + #endif default: break; } } @@ -1440,8 +1634,8 @@ void draw_return_ui() { #endif void lv_ex_line(lv_obj_t * line, lv_point_t *points) { - /*Copy the previous line and apply the new style*/ - lv_line_set_points(line, points, 2); /*Set the points*/ + // Copy the previous line and apply the new style + lv_line_set_points(line, points, 2); // Set the points lv_line_set_style(line, LV_LINE_STYLE_MAIN, &style_line); lv_obj_align(line, NULL, LV_ALIGN_IN_TOP_MID, 0, 0); } @@ -1450,18 +1644,29 @@ extern volatile uint32_t systick_uptime_millis; void print_time_count() { if ((systick_uptime_millis % 1000) == 0) - if (print_time.start == 1) print_time.seconds++; + if (print_time.start == 1) print_time.seconds++; } void LV_TASK_HANDLER() { //lv_tick_inc(1); lv_task_handler(); if (mks_test_flag == 0x1e) mks_hardware_test(); + #if HAS_GCODE_PREVIEW disp_pre_gcode(2, 36); #endif + GUI_RefreshPage(); + + #if ENABLED(USE_WIFI_FUNCTION) + get_wifi_commands(); + #endif + //sd_detection(); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_update_encoder(); + #endif } #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h index 8cd4670ffa8d..09e39d8412eb 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -34,7 +34,11 @@ #undef LV_COLOR_BACKGROUND #define LV_COLOR_BACKGROUND LV_COLOR_MAKE(0x1A, 0x1A, 0x1A) // LV_COLOR_MAKE(0x00, 0x00, 0x00) +#define TFT_LV_PARA_BACK_BODY_COLOR LV_COLOR_MAKE(0x4A, 0x52, 0xFF) + +#include "tft_lvgl_configuration.h" #include "tft_multi_language.h" +#include "pic_manager.h" #include "draw_ready_print.h" #include "draw_language.h" #include "draw_set.h" @@ -66,8 +70,33 @@ #include "draw_eeprom_settings.h" #include "draw_max_feedrate_settings.h" #include "draw_tmc_step_mode_settings.h" +#include "draw_level_settings.h" +#include "draw_manual_level_pos_settings.h" +#include "draw_auto_level_offset_settings.h" +#include "draw_filament_change.h" +#include "draw_filament_settings.h" +#include "draw_homing_sensitivity_settings.h" +#include "draw_baby_stepping.h" +#include "draw_keyboard.h" +#include "draw_encoder_settings.h" + +#if ENABLED(USE_WIFI_FUNCTION) + #include "wifiSerial.h" + #include "wifi_module.h" + #include "wifi_upload.h" + #include "draw_wifi_settings.h" + #include "draw_wifi.h" + #include "draw_wifi_list.h" + #include "draw_wifi_tips.h" +#endif #include "../../inc/MarlinConfigPre.h" +#define FILE_SYS_USB 0 +#define FILE_SYS_SD 1 + +#define TICK_CYCLE 1 + +#define PARA_SEL_ICON_TEXT_COLOR LV_COLOR_MAKE(0x4a, 0x52, 0xff); #define TFT35 @@ -100,30 +129,38 @@ #define PREVIEW_LITTLE_PIC_SIZE 40910 // 400*100+9*101+1 #define PREVIEW_SIZE 202720 // (PREVIEW_LITTLE_PIC_SIZE+800*200+201*9+1) - #define GCFG_FLAG_VALUE 0xEE - // machine parameter ui - #define PARA_UI_POS_X 10 - #define PARA_UI_POS_Y 50 + #define PARA_UI_POS_X 10 + #define PARA_UI_POS_Y 50 - #define PARA_UI_SIZE_X 450 - #define PARA_UI_SIZE_Y 40 + #define PARA_UI_SIZE_X 450 + #define PARA_UI_SIZE_Y 40 #define PARA_UI_ARROW_V 12 - #define PARA_UI_BACL_POS_X 400 - #define PARA_UI_BACL_POS_Y 270 + #define PARA_UI_BACL_POS_X 400 + #define PARA_UI_BACL_POS_Y 270 - #define PARA_UI_TURN_PAGE_POS_X 320 - #define PARA_UI_TURN_PAGE_POS_Y 270 + #define PARA_UI_TURN_PAGE_POS_X 320 + #define PARA_UI_TURN_PAGE_POS_Y 270 - #define PARA_UI_VALUE_SIZE_X 370 - #define PARA_UI_VALUE_POS_X 400 + #define PARA_UI_VALUE_SIZE_X 370 + #define PARA_UI_VALUE_POS_X 400 #define PARA_UI_VALUE_V 5 - #define PARA_UI_STATE_POS_X 380 + #define PARA_UI_STATE_POS_X 380 #define PARA_UI_STATE_V 2 + #define PARA_UI_VALUE_SIZE_X_2 200 + #define PARA_UI_VALUE_POS_X_2 320 + #define PARA_UI_VALUE_V_2 5 + + #define PARA_UI_VALUE_BTN_X_SIZE 70 + #define PARA_UI_VALUE_BTN_Y_SIZE 28 + + #define PARA_UI_BACK_BTN_X_SIZE 70 + #define PARA_UI_BACK_BTN_Y_SIZE 40 + #else // ifdef TFT35 #define TFT_WIDTH 320 @@ -135,13 +172,25 @@ extern char public_buf_m[100]; extern char public_buf_l[30]; typedef struct { - uint8_t spi_flash_flag; + uint32_t spi_flash_flag; + uint8_t disp_rotation_180; uint8_t multiple_language; uint8_t language; uint8_t leveling_mode; uint8_t from_flash_pic; uint8_t finish_power_off; uint8_t pause_reprint; + uint8_t wifi_mode_sel; + uint8_t fileSysType; + uint8_t wifi_type; + bool cloud_enable; + bool encoder_enable; + int levelingPos[5][2]; + int filamentchange_load_length; + int filamentchange_load_speed; + int filamentchange_unload_length; + int filamentchange_unload_speed; + int filament_limit_temper; float pausePosX; float pausePosY; float pausePosZ; @@ -153,15 +202,42 @@ typedef struct { curSprayerChoose : 3, stepHeat : 4; uint8_t leveling_first_time : 1, - para_ui_page : 1; + para_ui_page:1, + configWifi:1, + command_send:1, + filament_load_heat_flg:1, + filament_heat_completed_load:1, + filament_unload_heat_flg:1, + filament_heat_completed_unload:1; + uint8_t filament_loading_completed:1, + filament_unloading_completed:1, + filament_loading_time_flg:1, + filament_unloading_time_flg:1, + curSprayerChoose_bak:4; + uint8_t wifi_name[32]; + uint8_t wifi_key[64]; + uint8_t cloud_hostUrl[96]; uint8_t extruStep; uint8_t extruSpeed; uint8_t print_state; uint8_t stepPrintSpeed; uint8_t waitEndMoves; + uint8_t dialogType; + uint8_t F[4]; + uint8_t filament_rate; uint16_t moveSpeed; + uint16_t cloud_port; + uint16_t moveSpeed_bak; + uint32_t totalSend; + uint32_t filament_loading_time; + uint32_t filament_unloading_time; + uint32_t filament_loading_time_cnt; + uint32_t filament_unloading_time_cnt; float move_dist; - uint8_t F[4]; + float desireSprayerTempBak; + float current_x_position_bak; + float current_y_position_bak; + float current_e_position_bak; } UI_CFG; typedef enum { @@ -196,12 +272,14 @@ typedef enum { LEVELING_UI, MESHLEVELING_UI, BIND_UI, - ZOFFSET_UI, + #if HAS_BED_PROBE + NOZZLE_PROBE_OFFSET_UI, + #endif TOOL_UI, HARDWARE_TEST_UI, WIFI_LIST_UI, KEY_BOARD_UI, - TIPS_UI, + WIFI_TIPS_UI, MACHINE_PARA_UI, MACHINE_SETTINGS_UI, TEMPERATURE_SETTINGS_UI, @@ -214,7 +292,7 @@ typedef enum { LEVELING_SETTIGNS_UI, LEVELING_PARA_UI, DELTA_LEVELING_PARA_UI, - XYZ_LEVELING_PARA_UI, + MANUAL_LEVELING_POSIGION_UI, MAXFEEDRATE_UI, STEPS_UI, ACCELERATION_UI, @@ -232,7 +310,10 @@ typedef enum { PAUSE_POS_UI, TMC_CURRENT_UI, TMC_MODE_UI, - EEPROM_SETTINGS_UI + EEPROM_SETTINGS_UI, + WIFI_SETTINGS_UI, + HOMING_SENSITIVITY_UI, + ENCODER_SETTINGS_UI } DISP_STATE; typedef struct { @@ -285,10 +366,45 @@ typedef enum { pause_pos_x, pause_pos_y, - pause_pos_z + pause_pos_z, + + level_pos_x1, + level_pos_y1, + level_pos_x2, + level_pos_y2, + level_pos_x3, + level_pos_y3, + level_pos_x4, + level_pos_y4, + level_pos_x5, + level_pos_y5 + #if HAS_BED_PROBE + , + x_offset, + y_offset, + z_offset + #endif + , + load_length, + load_speed, + unload_length, + unload_speed, + filament_temp, + + x_sensitivity, + y_sensitivity, + z_sensitivity, + z2_sensitivity +} num_key_value_state; +extern num_key_value_state value; -}value_state; -extern value_state value; +typedef enum { + wifiName, + wifiPassWord, + wifiConfig, + gcodeCommand +} keyboard_value_state; +extern keyboard_value_state keyboard_value; extern CFG_ITMES gCfgItems; extern UI_CFG uiCfg; @@ -305,6 +421,10 @@ extern lv_style_t style_para_value_rel; extern lv_style_t style_num_key_pre; extern lv_style_t style_num_key_rel; extern lv_style_t style_num_text; +extern lv_style_t style_sel_text; +extern lv_style_t style_para_value; +extern lv_style_t style_para_back; +extern lv_style_t lv_bar_style_indic; extern lv_point_t line_points[4][2]; @@ -314,6 +434,8 @@ extern void tft_style_init(); extern char *creat_title_text(void); extern void preview_gcode_prehandle(char *path); extern void update_spi_flash(); +extern void update_gcode_command(int addr,uint8_t *s); +extern void get_gcode_command(int addr,uint8_t *d); #if HAS_GCODE_PREVIEW extern void disp_pre_gcode(int xpos_pixel, int ypos_pixel); #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp new file mode 100644 index 000000000000..9cf4555b25fe --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp @@ -0,0 +1,222 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#if ENABLED(USE_WIFI_FUNCTION) + +#include "../../../../../Configuration.h" +#include "../../../../module/temperature.h" + +extern lv_group_t * g; +static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text; + +#define ID_W_RETURN 1 +#define ID_W_CLOUD 2 +#define ID_W_RECONNECT 3 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_W_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + lv_draw_set(); + } + break; + case ID_W_CLOUD: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + //clear_cur_ui(); + //draw_return_ui(); + } + break; + case ID_W_RECONNECT: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + lv_draw_wifi_list(); + } + break; + } +} + +void lv_draw_wifi(void) { + lv_obj_t *buttonBack=NULL,*label_Back=NULL; + lv_obj_t *buttonCloud=NULL,*label_Cloud=NULL; + lv_obj_t *buttonReconnect=NULL,*label_Reconnect=NULL; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_UI; + } + disp_state = WIFI_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + // Create an Image button + buttonBack = lv_imgbtn_create(scr, NULL); + if (gCfgItems.wifi_mode_sel == STA_MODEL) { + //buttonCloud = lv_imgbtn_create(scr, NULL); + buttonReconnect = lv_imgbtn_create(scr, NULL); + } + + lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_W_RETURN, NULL,0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); + #endif + + lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + if (gCfgItems.wifi_mode_sel == STA_MODEL) { + + lv_obj_set_event_cb_mks(buttonReconnect, event_handler,ID_W_RECONNECT, NULL,0); + lv_imgbtn_set_src(buttonReconnect, LV_BTN_STATE_REL, "F:/bmp_wifi.bin"); + lv_imgbtn_set_src(buttonReconnect, LV_BTN_STATE_PR, "F:/bmp_wifi.bin"); + lv_imgbtn_set_style(buttonReconnect, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonReconnect, LV_BTN_STATE_REL, &tft_style_label_rel); + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonReconnect); + #endif + + lv_obj_set_pos(buttonReconnect,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight); + lv_btn_set_layout(buttonReconnect, LV_LAYOUT_OFF); + } + + label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.wifi_mode_sel == STA_MODEL) { + //label_Cloud = lv_label_create(buttonCloud, NULL); + label_Reconnect = lv_label_create(buttonReconnect, NULL); + } + + if (gCfgItems.multiple_language !=0) { + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + + if (gCfgItems.wifi_mode_sel == STA_MODEL) { + //lv_label_set_text(label_Cloud, common_menu.text_back); + //lv_obj_align(label_Cloud, buttonCloud, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + + lv_label_set_text(label_Reconnect, wifi_menu.reconnect); + lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); + } + } + + wifi_ip_text = lv_label_create(scr, NULL); + lv_obj_set_style(wifi_ip_text, &tft_style_label_rel); + + wifi_name_text = lv_label_create(scr, NULL); + lv_obj_set_style(wifi_name_text, &tft_style_label_rel); + + wifi_key_text = lv_label_create(scr, NULL); + lv_obj_set_style(wifi_key_text, &tft_style_label_rel); + + wifi_state_text = lv_label_create(scr, NULL); + lv_obj_set_style(wifi_state_text, &tft_style_label_rel); + + disp_wifi_state(); +} + +void disp_wifi_state() { + memset(public_buf_m, 0, sizeof(public_buf_m)); + strcpy(public_buf_m,wifi_menu.ip); + strcat(public_buf_m,ipPara.ip_addr); + lv_label_set_text(wifi_ip_text, public_buf_m); + lv_obj_align(wifi_ip_text, NULL, LV_ALIGN_CENTER,0, -100); + + memset(public_buf_m, 0, sizeof(public_buf_m)); + strcpy(public_buf_m,wifi_menu.wifi); + strcat(public_buf_m,wifiPara.ap_name); + lv_label_set_text(wifi_name_text, public_buf_m); + lv_obj_align(wifi_name_text, NULL, LV_ALIGN_CENTER,0, -70); + + if (wifiPara.mode == AP_MODEL) { + memset(public_buf_m, 0, sizeof(public_buf_m)); + strcpy(public_buf_m,wifi_menu.key); + strcat(public_buf_m,wifiPara.keyCode); + lv_label_set_text(wifi_key_text, public_buf_m); + lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER,0, -40); + + memset(public_buf_m, 0, sizeof(public_buf_m)); + strcpy(public_buf_m,wifi_menu.state_ap); + if (wifi_link_state == WIFI_CONNECTED) + strcat(public_buf_m,wifi_menu.connected); + else if (wifi_link_state == WIFI_NOT_CONFIG) + strcat(public_buf_m,wifi_menu.disconnected); + else + strcat(public_buf_m,wifi_menu.exception); + lv_label_set_text(wifi_state_text, public_buf_m); + lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER,0, -10); + } + else { + ZERO(public_buf_m); + strcpy(public_buf_m, wifi_menu.state_sta); + if (wifi_link_state == WIFI_CONNECTED) + strcat(public_buf_m, wifi_menu.connected); + else if (wifi_link_state == WIFI_NOT_CONFIG) + strcat(public_buf_m, wifi_menu.disconnected); + else + strcat(public_buf_m, wifi_menu.exception); + lv_label_set_text(wifi_state_text, public_buf_m); + lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER,0, -40); + + lv_label_set_text(wifi_key_text, ""); + lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER,0, -10); + } +} + +void lv_clear_wifi() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // USE_WIFI_FUNCTION +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h new file mode 100644 index 000000000000..966a84d3b19b --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h @@ -0,0 +1,38 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + + +extern void lv_draw_wifi(void); +extern void lv_clear_wifi(); +extern void disp_wifi_state(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif + + + diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp new file mode 100644 index 000000000000..14fd63f85282 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp @@ -0,0 +1,235 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#if ENABLED(USE_WIFI_FUNCTION) + +#include "../../../../../Configuration.h" +#include "../../../../module/temperature.h" + +#define NAME_BTN_X 330 +#define NAME_BTN_Y 48 + +#define MARK_BTN_X 0 +#define MARK_BTN_Y 68 + +WIFI_LIST wifi_list; +list_menu_def list_menu; + +extern lv_group_t * g; +static lv_obj_t * scr; +static lv_obj_t *buttonWifiN[NUMBER_OF_PAGE]; +static lv_obj_t *lableWifiText[NUMBER_OF_PAGE]; +static lv_obj_t *lablePageText; + +#define ID_WL_RETURN 11 +#define ID_WL_DOWN 12 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + if (obj->mks_obj_id == ID_WL_RETURN) { + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + clear_cur_ui(); + lv_draw_set(); + } + } + else if (obj->mks_obj_id == ID_WL_DOWN) { + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + if (wifi_list.getNameNum > 0) { + if ((wifi_list.nameIndex + NUMBER_OF_PAGE) >= wifi_list.getNameNum) { + wifi_list.nameIndex = 0; + wifi_list.currentWifipage = 1; + } + else { + wifi_list.nameIndex += NUMBER_OF_PAGE; + wifi_list.currentWifipage++; + } + disp_wifi_list(); + } + } + } + else { + for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) { + if (obj->mks_obj_id == i + 1) { + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + if (wifi_list.getNameNum != 0) { + const bool do_wifi = wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex + i]) == 0; + wifi_list.nameIndex += i; + last_disp_state = WIFI_LIST_UI; + lv_clear_wifi_list(); + if (do_wifi) + lv_draw_wifi(); + else { + keyboard_value = wifiConfig; + lv_draw_keyboard(); + } + } + } + } + } + } +} + +void lv_draw_wifi_list(void) { + lv_obj_t *buttonBack = NULL, *buttonDown = NULL; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_LIST_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_LIST_UI; + } + disp_state = WIFI_LIST_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); + lv_label_set_text(title, creat_title_text()); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + buttonDown = lv_imgbtn_create(scr, NULL); + buttonBack = lv_imgbtn_create(scr, NULL); + + lv_obj_set_event_cb_mks(buttonDown, event_handler,ID_WL_DOWN,NULL,0); + lv_imgbtn_set_src(buttonDown, LV_BTN_STATE_REL, "F:/bmp_pageDown.bin"); + lv_imgbtn_set_src(buttonDown, LV_BTN_STATE_PR, "F:/bmp_pageDown.bin"); + lv_imgbtn_set_style(buttonDown, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonDown, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_WL_RETURN,NULL,0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back.bin"); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + + lv_obj_set_pos(buttonDown,OTHER_BTN_XPIEL*3+INTERVAL_V*4,titleHeight+OTHER_BTN_YPIEL+INTERVAL_H); + lv_obj_set_pos(buttonBack,OTHER_BTN_XPIEL*3+INTERVAL_V*4,titleHeight+OTHER_BTN_YPIEL*2+INTERVAL_H*2); + + lv_btn_set_layout(buttonDown, LV_LAYOUT_OFF); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + + for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) { + buttonWifiN[i] = lv_btn_create(scr, NULL); /*Add a button the current screen*/ + lv_obj_set_pos(buttonWifiN[i], 0,NAME_BTN_Y*i+10+titleHeight); /*Set its position*/ + lv_obj_set_size(buttonWifiN[i], NAME_BTN_X,NAME_BTN_Y); /*Set its size*/ + lv_obj_set_event_cb_mks(buttonWifiN[i], event_handler,(i+1),NULL,0); + lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ + lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ + lv_btn_set_layout(buttonWifiN[i], LV_LAYOUT_OFF); + lableWifiText[i] = lv_label_create(buttonWifiN[i], NULL); + #if HAS_ROTARY_ENCODER + uint8_t j = 0; + if (gCfgItems.encoder_enable) { + j = wifi_list.nameIndex + i; + if (j < wifi_list.getNameNum) lv_group_add_obj(g, buttonWifiN[i]); + } + #endif + } + + lablePageText = lv_label_create(scr, NULL); + lv_obj_set_style(lablePageText, &tft_style_label_rel); + + wifi_list.nameIndex = 0; + wifi_list.currentWifipage = 1; + + if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode == STA_MODEL) { + memset(wifi_list.wifiConnectedName, 0, sizeof(&wifi_list.wifiConnectedName)); + memcpy(wifi_list.wifiConnectedName, wifiPara.ap_name, sizeof(wifi_list.wifiConnectedName)); + } + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonDown); + lv_group_add_obj(g, buttonBack); + } + #endif + + disp_wifi_list(); +} + +void disp_wifi_list(void) { + int8_t tmpStr[WIFI_NAME_BUFFER_SIZE] = { 0 }; + uint8_t i, j; + + sprintf((char *)tmpStr, list_menu.file_pages, wifi_list.currentWifipage, wifi_list.getPage); + lv_label_set_text(lablePageText, (const char *)tmpStr); + lv_obj_align(lablePageText, NULL, LV_ALIGN_CENTER, 50, -100); + + for (i = 0; i < NUMBER_OF_PAGE; i++) { + memset(tmpStr, 0, sizeof(tmpStr)); + + j = wifi_list.nameIndex + i; + if (j >= wifi_list.getNameNum) { + lv_label_set_text(lableWifiText[i], (const char *)tmpStr); + lv_obj_align(lableWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0); + } + else { + lv_label_set_text(lableWifiText[i], (char const *)wifi_list.wifiName[j]); + lv_obj_align(lableWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0); + + if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[j]) == 0) { + lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &style_sel_text); + } + else { + lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &tft_style_label_rel); + } + } + } +} + +void wifi_scan_handle() { + if (uiCfg.dialogType != WIFI_ENABLE_TIPS || uiCfg.command_send != 1) return; + last_disp_state = DIALOG_UI; + lv_clear_dialog(); + if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode != AP_MODEL) + lv_draw_wifi(); + else + lv_draw_wifi_list(); +} + +void lv_clear_wifi_list() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // USE_WIFI_FUNCTION + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h new file mode 100644 index 000000000000..e2d9275ef918 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h @@ -0,0 +1,76 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_wifi_list(); +extern void lv_clear_wifi_list(); +extern void disp_wifi_list(void); +extern void cutWifiName(char *name, int len,char *outStr); +extern void wifi_scan_handle(); + +#define NUMBER_OF_PAGE 5 + +#define WIFI_TOTAL_NUMBER 20 +#define WIFI_NAME_BUFFER_SIZE 33 + +typedef struct { + int8_t getNameNum; + int8_t nameIndex; + int8_t currentWifipage; + int8_t getPage; + int8_t RSSI[WIFI_TOTAL_NUMBER]; + uint8_t wifiName[WIFI_TOTAL_NUMBER][WIFI_NAME_BUFFER_SIZE]; + uint8_t wifiConnectedName[WIFI_NAME_BUFFER_SIZE]; +} WIFI_LIST; +extern WIFI_LIST wifi_list; + +typedef struct list_menu_disp { + const char *title; + const char *file_pages; +} list_menu_def; +extern list_menu_def list_menu; + +typedef struct keyboard_menu_disp { + const char *title; + const char *apply; + const char *password; + const char *letter; + const char *digital; + const char *symbol; + const char *space; +} keyboard_menu_def; +extern keyboard_menu_def keyboard_menu; + +typedef struct tips_menu_disp { + const char *joining; + const char *failedJoin; + const char *wifiConected; +} tips_menu_def; +extern tips_menu_def tips_menu; + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp new file mode 100644 index 000000000000..86733470ddbb --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp @@ -0,0 +1,299 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#if ENABLED(USE_WIFI_FUNCTION) + +#include "../../../../../Configuration.h" +#include "../../../../module/planner.h" + +extern lv_group_t * g; +static lv_obj_t *scr, *labelModelValue = NULL, *buttonModelValue = NULL, *labelCloudValue = NULL; + +#define ID_WIFI_RETURN 1 +#define ID_WIFI_MODEL 2 +#define ID_WIFI_NAME 3 +#define ID_WIFI_PASSWORD 4 +#define ID_WIFI_CLOUD 5 +#define ID_WIFI_CONFIG 6 + +static void event_handler(lv_obj_t * obj, lv_event_t event) { + switch (obj->mks_obj_id) { + case ID_WIFI_RETURN: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_wifi_settings(); + draw_return_ui(); + } + break; + case ID_WIFI_MODEL: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + if (gCfgItems.wifi_mode_sel == AP_MODEL) { + gCfgItems.wifi_mode_sel = STA_MODEL; + lv_label_set_text(labelModelValue, WIFI_STA_TEXT); + lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); + update_spi_flash(); + } + else{ + gCfgItems.wifi_mode_sel = AP_MODEL; + lv_label_set_text(labelModelValue, WIFI_AP_TEXT); + lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); + update_spi_flash(); + } + } + break; + case ID_WIFI_NAME: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + keyboard_value=wifiName; + lv_clear_wifi_settings(); + lv_draw_keyboard(); + } + break; + case ID_WIFI_PASSWORD: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + keyboard_value=wifiPassWord; + lv_clear_wifi_settings(); + lv_draw_keyboard(); + } + break; + case ID_WIFI_CLOUD: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + if (gCfgItems.cloud_enable) { + gCfgItems.cloud_enable = false; + lv_obj_set_event_cb_mks(obj, event_handler,ID_WIFI_CLOUD,"bmp_disable.bin",0); + lv_label_set_text(labelCloudValue, machine_menu.disable); + update_spi_flash(); + } + else { + gCfgItems.cloud_enable = true; + lv_obj_set_event_cb_mks(obj, event_handler,ID_WIFI_CLOUD,"bmp_enable.bin",0); + lv_label_set_text(labelCloudValue, machine_menu.enable); + update_spi_flash(); + } + } + break; + case ID_WIFI_CONFIG: + if (event == LV_EVENT_CLICKED) { + + } + else if (event == LV_EVENT_RELEASED) { + lv_clear_wifi_settings(); + lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS); + } + break; + } +} + +void lv_draw_wifi_settings(void) { + lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonConfig = NULL, *labelConfig = NULL; + lv_obj_t *labelModelText = NULL; + lv_obj_t *labelNameText = NULL, *buttonNameValue = NULL, *labelNameValue = NULL; + lv_obj_t *labelPassWordText = NULL, *buttonPassWordValue = NULL, *labelPassWordValue = NULL; + lv_obj_t *labelCloudText = NULL, *buttonCloudValue = NULL; + lv_obj_t * line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL; + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_SETTINGS_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_SETTINGS_UI; + } + disp_state = WIFI_SETTINGS_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + + lv_obj_t * title = lv_label_create(scr, NULL); + lv_obj_set_style(title, &tft_style_label_rel); + lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); + lv_label_set_text(title, machine_menu.WifiConfTitle); + + lv_refr_now(lv_refr_get_disp_refreshing()); + + labelModelText = lv_label_create(scr, NULL); + lv_obj_set_style(labelModelText, &tft_style_label_rel); + lv_obj_set_pos(labelModelText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); + lv_label_set_text(labelModelText, machine_menu.wifiMode); + + buttonModelValue = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonModelValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y+PARA_UI_VALUE_V); + lv_obj_set_event_cb_mks(buttonModelValue, event_handler,ID_WIFI_MODEL, NULL,0); + lv_imgbtn_set_src(buttonModelValue, LV_BTN_STATE_REL, "F:/bmp_blank_sel.bin"); + lv_imgbtn_set_src(buttonModelValue, LV_BTN_STATE_PR, "F:/bmp_blank_sel.bin"); + lv_imgbtn_set_style(buttonModelValue, LV_BTN_STATE_PR, &style_para_value_pre); + lv_imgbtn_set_style(buttonModelValue, LV_BTN_STATE_REL, &style_para_value_pre); + lv_btn_set_layout(buttonModelValue, LV_LAYOUT_OFF); + labelModelValue = lv_label_create(buttonModelValue, NULL); + + line1 = lv_line_create(scr, NULL); + lv_ex_line(line1,line_points[0]); + + labelNameText = lv_label_create(scr, NULL); + lv_obj_set_style(labelNameText, &tft_style_label_rel); + lv_obj_set_pos(labelNameText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); + + buttonNameValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonNameValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y*2+PARA_UI_VALUE_V); + lv_obj_set_size(buttonNameValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonNameValue, event_handler,ID_WIFI_NAME, NULL,0); + lv_btn_set_style(buttonNameValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonNameValue, LV_BTN_STYLE_PR, &style_para_value); + labelNameValue = lv_label_create(buttonNameValue, NULL); + + line2 = lv_line_create(scr, NULL); + lv_ex_line(line2,line_points[1]); + + labelPassWordText = lv_label_create(scr, NULL); + lv_obj_set_style(labelPassWordText, &tft_style_label_rel); + lv_obj_set_pos(labelPassWordText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); + + buttonPassWordValue = lv_btn_create(scr, NULL); + lv_obj_set_pos(buttonPassWordValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y*3+PARA_UI_VALUE_V); + lv_obj_set_size(buttonPassWordValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); + lv_obj_set_event_cb_mks(buttonPassWordValue, event_handler,ID_WIFI_PASSWORD, NULL,0); + lv_btn_set_style(buttonPassWordValue, LV_BTN_STYLE_REL, &style_para_value); + lv_btn_set_style(buttonPassWordValue, LV_BTN_STYLE_PR, &style_para_value); + labelPassWordValue = lv_label_create(buttonPassWordValue, NULL); + + line3 = lv_line_create(scr, NULL); + lv_ex_line(line3,line_points[2]); + + labelCloudText = lv_label_create(scr, NULL); + lv_obj_set_style(labelCloudText, &tft_style_label_rel); + lv_obj_set_pos(labelCloudText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); + lv_label_set_text(labelCloudText, machine_menu.wifiCloud); + + buttonCloudValue = lv_imgbtn_create(scr, NULL); + lv_obj_set_pos(buttonCloudValue,PARA_UI_STATE_POS_X,PARA_UI_POS_Y*4+PARA_UI_STATE_V); + if (gCfgItems.cloud_enable) { + lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); + lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); + } + else { + lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); + lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); + } + lv_obj_set_event_cb_mks(buttonCloudValue, event_handler,ID_WIFI_CLOUD, NULL,0); + lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_btn_set_layout(buttonCloudValue, LV_LAYOUT_OFF); + labelCloudValue = lv_label_create(buttonCloudValue, NULL); + + line4 = lv_line_create(scr, NULL); + lv_ex_line(line4,line_points[3]); + + buttonConfig = lv_imgbtn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonConfig, event_handler,ID_WIFI_CONFIG, NULL,0); + lv_imgbtn_set_src(buttonConfig, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonConfig, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_style(buttonConfig, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonConfig, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_obj_set_pos(buttonConfig, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); + lv_btn_set_layout(buttonConfig, LV_LAYOUT_OFF); + labelConfig = lv_label_create(buttonConfig, NULL); + + buttonBack = lv_imgbtn_create(scr, NULL); + lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_WIFI_RETURN, NULL, 0); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); + lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); + lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); + lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); + label_Back = lv_label_create(buttonBack, NULL); + + if (gCfgItems.multiple_language !=0) { + if (gCfgItems.wifi_mode_sel == AP_MODEL) { + lv_label_set_text(labelModelValue, WIFI_AP_TEXT); + lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); + } + else { + lv_label_set_text(labelModelValue, WIFI_STA_TEXT); + lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); + } + memset(public_buf_m,0,sizeof(public_buf_m)); + strcat(public_buf_m,machine_menu.wifiName); + strcat(public_buf_m,(const char *)uiCfg.wifi_name); + lv_label_set_text(labelNameText,public_buf_m); + + lv_label_set_text(labelNameValue,machine_menu.wifiEdit); + lv_obj_align(labelNameValue, buttonNameValue, LV_ALIGN_CENTER,0, 0); + + memset(public_buf_m,0,sizeof(public_buf_m)); + strcat(public_buf_m,machine_menu.wifiPassWord); + strcat(public_buf_m,(const char *)uiCfg.wifi_key); + lv_label_set_text(labelPassWordText,public_buf_m); + + lv_label_set_text(labelPassWordValue,machine_menu.wifiEdit); + lv_obj_align(labelPassWordValue, buttonPassWordValue, LV_ALIGN_CENTER,0, 0); + + lv_label_set_text(labelCloudValue, gCfgItems.cloud_enable ? machine_menu.enable : machine_menu.disable); + lv_obj_align(labelCloudValue, buttonCloudValue, LV_ALIGN_CENTER,0, 0); + + lv_label_set_text(labelConfig,machine_menu.wifiConfig); + lv_obj_align(labelConfig, buttonConfig, LV_ALIGN_CENTER,0, 0); + + lv_label_set_text(label_Back, common_menu.text_back); + lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER,0, 0); + } + + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) { + lv_group_add_obj(g, buttonModelValue); + lv_group_add_obj(g, buttonNameValue); + lv_group_add_obj(g, buttonPassWordValue); + lv_group_add_obj(g, buttonCloudValue); + lv_group_add_obj(g, buttonConfig); + lv_group_add_obj(g, buttonBack); + } + #endif +} + +void lv_clear_wifi_settings() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // USE_WIFI_FUNCTION + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h new file mode 100644 index 000000000000..c0d6e0ccdd78 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h @@ -0,0 +1,36 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +#define WIFI_AP_TEXT "AP" +#define WIFI_STA_TEXT "STA" + +extern void lv_draw_wifi_settings(void); +extern void lv_clear_wifi_settings(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp new file mode 100644 index 000000000000..50fa0aaf99c7 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp @@ -0,0 +1,85 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "lv_conf.h" +#include "draw_ui.h" + +#if ENABLED(USE_WIFI_FUNCTION) + +#include "../../../../../Configuration.h" +#include "../../../../module/temperature.h" + +static lv_obj_t * scr; + +TIPS_TYPE wifi_tips_type; +TIPS_DISP tips_disp; +tips_menu_def tips_menu; + +void lv_draw_wifi_tips(void) { + static lv_obj_t * text_tips,*wifi_name; + + if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_TIPS_UI) { + disp_state_stack._disp_index++; + disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_TIPS_UI; + } + disp_state = WIFI_TIPS_UI; + + scr = lv_obj_create(NULL, NULL); + + lv_obj_set_style(scr, &tft_style_scr); + lv_scr_load(scr); + lv_obj_clean(scr); + lv_refr_now(lv_refr_get_disp_refreshing()); + + text_tips = lv_label_create(scr, NULL); + lv_obj_set_style(text_tips, &tft_style_label_rel); + + wifi_name = lv_label_create(scr, NULL); + lv_obj_set_style(wifi_name, &tft_style_label_rel); + + if (wifi_tips_type == TIPS_TYPE_JOINING) { + lv_label_set_text(text_tips, tips_menu.joining); + lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60); + } + else if (wifi_tips_type == TIPS_TYPE_TAILED_JOIN) { + lv_label_set_text(text_tips, tips_menu.failedJoin); + lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60); + } + else if (wifi_tips_type == TIPS_TYPE_WIFI_CONECTED) { + lv_label_set_text(text_tips, tips_menu.wifiConected); + lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60); + } + + lv_label_set_text(wifi_name, (const char *)wifi_list.wifiName[wifi_list.nameIndex]); + lv_obj_align(wifi_name, NULL, LV_ALIGN_CENTER,0, -20); + + tips_disp.timer = TIPS_TIMER_START; + tips_disp.timer_count = 0; +} + +void lv_clear_wifi_tips() { lv_obj_del(scr); } + +#endif // USE_WIFI_FUNCTION +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h new file mode 100644 index 000000000000..4f81f00a434d --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h @@ -0,0 +1,51 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + + +extern void lv_draw_wifi_tips(void); +extern void lv_clear_wifi_tips(); + +typedef enum { + TIPS_TYPE_JOINING, + TIPS_TYPE_TAILED_JOIN, + TIPS_TYPE_WIFI_CONECTED +} TIPS_TYPE; +extern TIPS_TYPE wifi_tips_type; + +typedef struct { + unsigned char timer; + unsigned int timer_count; +} TIPS_DISP; +extern TIPS_DISP tips_disp; + +#define TIPS_TIMER_START 1 +#define TIPS_TIMER_STOP 0 + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif + diff --git a/Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp b/Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp new file mode 100644 index 000000000000..cf64571292bf --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp @@ -0,0 +1,69 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "draw_ui.h" + +#if ENABLED(USE_WIFI_FUNCTION) + +#include "wifiSerial.h" + +#include +#include +#include +#include +#include + +#include "../../../../inc/MarlinConfig.h" + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH); +#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); + +void __irq_usart1(void) { + WIFISERIAL.wifi_usart_irq(USART1_BASE); + if (wifi_link_state == WIFI_TRANS_FILE) { + if (WIFISERIAL.available() == (400)) WIFI_IO1_SET(); + if (WIFISERIAL.wifi_rb_is_full()) { + if (esp_state == TRANSFER_IDLE) esp_state = TRANSFERING; + if (storeRcvData(UART_RX_BUFFER_SIZE)) { + if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); + } + else { + WIFI_IO1_SET(); + esp_state = TRANSFER_STORE; + } + } + } +} + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif + +#endif // USE_WIFI_FUNCTION +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp b/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp index 297ba723de8f..743863d1f702 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp @@ -38,7 +38,10 @@ #include "../../../../module/temperature.h" #include "../../../../sd/cardreader.h" -uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta; +uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det3_sta; +#if PIN_EXISTS(MT_DET_2) + uint8_t mt_det2_sta; +#endif uint8_t endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta; void test_gpio_readlevel_L() { #if ENABLED(MKS_TEST) @@ -46,15 +49,17 @@ void test_gpio_readlevel_L() { WRITE(WIFI_IO0_PIN, HIGH); itest = 10000; while (itest--); - pw_det_sta = (READ(POWER_LOSS_PIN) == 0); - pw_off_sta = (READ(PS_ON_PIN) == 0); + pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 0); + pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 0); mt_det_sta = (READ(MT_DET_1_PIN) == 0); - mt_det2_sta = (READ(MT_DET_2_PIN) == 0); + #if PIN_EXISTS(MT_DET_2) + mt_det2_sta = (READ(MT_DET_2_PIN) == 0); + #endif //mt_det3_sta = (READ(FIL_RUNOUT_3_PIN) == 0); endstopx1_sta = (READ(X_MIN_PIN) == 0); - endstopx2_sta = (READ(X_MAX_PIN) == 0); + //endstopx2_sta = (READ(X_MAX_PIN) == 0); endstopy1_sta = (READ(Y_MIN_PIN) == 0); - endstopy2_sta = (READ(Y_MAX_PIN) == 0); + //endstopy2_sta = (READ(Y_MAX_PIN) == 0); endstopz1_sta = (READ(Z_MIN_PIN) == 0); endstopz2_sta = (READ(Z_MAX_PIN) == 0); #endif @@ -66,15 +71,17 @@ void test_gpio_readlevel_H() { WRITE(WIFI_IO0_PIN, LOW); itest = 10000; while (itest--); - pw_det_sta = (READ(POWER_LOSS_PIN) == 1); - pw_off_sta = (READ(PS_ON_PIN) == 1); + pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 1); + pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 1); mt_det_sta = (READ(MT_DET_1_PIN) == 1); - mt_det2_sta = (READ(MT_DET_2_PIN) == 1); + #if PIN_EXISTS(MT_DET_2) + mt_det2_sta = (READ(MT_DET_2_PIN) == 1); + #endif //mt_det3_sta = (READ(MT_DET_3_PIN) == 1); endstopx1_sta = (READ(X_MIN_PIN) == 1); - endstopx2_sta = (READ(X_MAX_PIN) == 1); + //endstopx2_sta = (READ(X_MAX_PIN) == 1); endstopy1_sta = (READ(Y_MIN_PIN) == 1); - endstopy2_sta = (READ(Y_MAX_PIN) == 1); + //endstopy2_sta = (READ(Y_MAX_PIN) == 1); endstopz1_sta = (READ(Z_MIN_PIN) == 1); endstopz2_sta = (READ(Z_MAX_PIN) == 1); #endif @@ -83,20 +90,22 @@ void test_gpio_readlevel_H() { void init_test_gpio() { #ifdef MKS_TEST SET_INPUT_PULLUP(X_MIN_PIN); - SET_INPUT_PULLUP(X_MAX_PIN); + //SET_INPUT_PULLUP(X_MAX_PIN); SET_INPUT_PULLUP(Y_MIN_PIN); - SET_INPUT_PULLUP(Y_MAX_PIN); + //SET_INPUT_PULLUP(Y_MAX_PIN); SET_INPUT_PULLUP(Z_MIN_PIN); SET_INPUT_PULLUP(Z_MAX_PIN); SET_OUTPUT(WIFI_IO0_PIN); SET_INPUT_PULLUP(MT_DET_1_PIN); - SET_INPUT_PULLUP(MT_DET_2_PIN); + #if PIN_EXISTS(MT_DET_2) + SET_INPUT_PULLUP(MT_DET_2_PIN); + #endif //SET_INPUT_PULLUP(MT_DET_3_PIN); - SET_INPUT_PULLUP(POWER_LOSS_PIN); - SET_INPUT_PULLUP(PS_ON_PIN); + SET_INPUT_PULLUP(MKS_TEST_POWER_LOSS_PIN); + SET_INPUT_PULLUP(MKS_TEST_PS_ON_PIN); SET_INPUT_PULLUP(SERVO0_PIN); @@ -104,14 +113,28 @@ void init_test_gpio() { SET_OUTPUT(Y_ENABLE_PIN); SET_OUTPUT(Z_ENABLE_PIN); SET_OUTPUT(E0_ENABLE_PIN); - SET_OUTPUT(E1_ENABLE_PIN); + #if !MB(MKS_ROBIN_E3P) + SET_OUTPUT(E1_ENABLE_PIN); + #endif WRITE(X_ENABLE_PIN, LOW); WRITE(Y_ENABLE_PIN, LOW); WRITE(Z_ENABLE_PIN, LOW); WRITE(E0_ENABLE_PIN, LOW); - WRITE(E1_ENABLE_PIN, LOW); + #if !MB(MKS_ROBIN_E3P) + WRITE(E1_ENABLE_PIN, LOW); + #endif //WRITE(E2_ENABLE_PIN, LOW); + + #if MB(MKS_ROBIN_E3P) + SET_INPUT_PULLUP(PA1); + SET_INPUT_PULLUP(PA3); + SET_INPUT_PULLUP(PC2); + SET_INPUT_PULLUP(PD8); + SET_INPUT_PULLUP(PE5); + SET_INPUT_PULLUP(PE6); + SET_INPUT_PULLUP(PE7); + #endif #endif } @@ -124,22 +147,37 @@ void mks_test_beeper() { #endif } -void mks_gpio_test(){ +void mks_gpio_test() { #if ENABLED(MKS_TEST) init_test_gpio(); test_gpio_readlevel_L(); test_gpio_readlevel_H(); test_gpio_readlevel_L(); - if ((pw_det_sta == 1) && (mt_det_sta == 1) && (mt_det2_sta == 1)) // &&(mt_det3_sta == 1)) + if ((pw_det_sta == 1) + && (pw_off_sta == 1) + && (mt_det_sta == 1) + #if PIN_EXISTS(MT_DET_2) + && (mt_det2_sta == 1) + #endif + #if MB(MKS_ROBIN_E3P) + && (READ(PA1) == 0) + && (READ(PA3) == 0) + && (READ(PC2) == 0) + && (READ(PD8) == 0) + && (READ(PE5) == 0) + && (READ(PE6) == 0) + && (READ(PE7) == 0) + #endif + ) // &&(mt_det3_sta == 1)) disp_det_ok(); else disp_det_error(); if ( (endstopx1_sta == 1) - && (endstopx2_sta == 1) + //&& (endstopx2_sta == 1) && (endstopy1_sta == 1) - && (endstopy2_sta == 1) + //&& (endstopy2_sta == 1) && (endstopz1_sta == 1) && (endstopz2_sta == 1) ) @@ -149,18 +187,22 @@ void mks_gpio_test(){ #endif } -void mks_hardware_test(){ +void mks_hardware_test() { #if ENABLED(MKS_TEST) if (millis() % 2000 < 1000) { WRITE(X_DIR_PIN, LOW); WRITE(Y_DIR_PIN, LOW); WRITE(Z_DIR_PIN, LOW); WRITE(E0_DIR_PIN, LOW); - WRITE(E1_DIR_PIN, LOW); + #if !MB(MKS_ROBIN_E3P) + WRITE(E1_DIR_PIN, LOW); + #endif //WRITE(E2_DIR_PIN, LOW); thermalManager.fan_speed[0] = 255; //WRITE(HEATER_2_PIN, HIGH); // HE2 - WRITE(HEATER_1_PIN, HIGH); // HE1 + #if !MB(MKS_ROBIN_E3P) + WRITE(HEATER_1_PIN, HIGH); // HE1 + #endif WRITE(HEATER_0_PIN, HIGH); // HE0 WRITE(HEATER_BED_PIN, HIGH); // HOT-BED } @@ -169,11 +211,15 @@ void mks_hardware_test(){ WRITE(Y_DIR_PIN, HIGH); WRITE(Z_DIR_PIN, HIGH); WRITE(E0_DIR_PIN, HIGH); - WRITE(E1_DIR_PIN, HIGH); + #if !MB(MKS_ROBIN_E3P) + WRITE(E1_DIR_PIN, HIGH); + #endif //WRITE(E2_DIR_PIN, HIGH); thermalManager.fan_speed[0] = 0; //WRITE(HEATER_2_PIN, LOW); // HE2 - WRITE(HEATER_1_PIN, LOW); // HE1 + #if !MB(MKS_ROBIN_E3P) + WRITE(HEATER_1_PIN, LOW); // HE1 + #endif WRITE(HEATER_0_PIN, LOW); // HE0 WRITE(HEATER_BED_PIN, LOW); // HOT-BED } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp index 447303a88782..e629915309bb 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp @@ -24,6 +24,7 @@ #if HAS_TFT_LVGL_UI #include "string.h" +#include "draw_ui.h" #include "pic_manager.h" #include "draw_ready_print.h" #include "mks_hardware_test.h" @@ -41,59 +42,61 @@ extern unsigned char bmp_public_buf[17 * 1024]; extern char *createFilename(char * const buffer, const dir_t &p); #endif -static char assets[][LONG_FILENAME_LENGTH] = { +static const char assets[][LONG_FILENAME_LENGTH] = { //homing screen - "bmp_Zero.bin", + "bmp_zeroAll.bin", + "bmp_zero.bin", "bmp_zeroX.bin", "bmp_zeroY.bin", "bmp_zeroZ.bin", "bmp_manual_off.bin", //tool screen - "bmp_PreHeat.bin", - "bmp_Extruct.bin", - "bmp_Mov.bin", + "bmp_preHeat.bin", + "bmp_extruct.bin", + "bmp_mov.bin", // "bmp_Zero.bin", - "bmp_Leveling.bin", + "bmp_leveling.bin", + "bmp_filamentchange.bin", //fan screen "bmp_Add.bin", "bmp_Dec.bin", - "bmp_Speed255.bin", - "bmp_Speed127.bin", - "bmp_Speed0.bin", + "bmp_speed255.bin", + "bmp_speed127.bin", + "bmp_speed0.bin", //preheat screen // "bmp_Add.bin", // "bmp_Dec.bin", - "bmp_Speed0.bin", + "bmp_speed0.bin", // "bmp_Extru2.bin", // "bmp_Extru1.bin", - "bmp_Bed.bin", - "bmp_Step1_degree.bin", - "bmp_Step5_degree.bin", - "bmp_Step10_degree.bin", + "bmp_bed.bin", + "bmp_step1_degree.bin", + "bmp_step5_degree.bin", + "bmp_step10_degree.bin", //extrusion screen - "bmp_In.bin", - "bmp_Out.bin", - "bmp_Extru1.bin", - #if EXTRUDERS > 1 - "bmp_Extru2.bin", + "bmp_in.bin", + "bmp_out.bin", + "bmp_extru1.bin", + #if HAS_MULTI_EXTRUDER + "bmp_extru2.bin", #endif - "bmp_Speed_high.bin", - "bmp_Speed_slow.bin", - "bmp_Speed_normal.bin", - "bmp_Step1_mm.bin", - "bmp_Step5_mm.bin", - "bmp_Step10_mm.bin", + "bmp_speed_high.bin", + "bmp_speed_slow.bin", + "bmp_speed_normal.bin", + "bmp_step1_mm.bin", + "bmp_step5_mm.bin", + "bmp_step10_mm.bin", //select file screen "bmp_pageUp.bin", "bmp_pageDown.bin", - "bmp_Back.bin", //TODO: why two back buttons? Why not just one? (return / back) - "bmp_Dir.bin", - "bmp_File.bin", + "bmp_back.bin", //TODO: why two back buttons? Why not just one? (return / back) + "bmp_dir.bin", + "bmp_file.bin", //move motor screen //TODO: 6 equal icons, just in diffenct rotation... it may be optimized too @@ -103,68 +106,69 @@ static char assets[][LONG_FILENAME_LENGTH] = { "bmp_yDec.bin", "bmp_zAdd.bin", "bmp_zDec.bin", - "bmp_Step_move0_1.bin", - "bmp_Step_move1.bin", - "bmp_Step_move10.bin", + "bmp_step_move0_1.bin", + "bmp_step_move1.bin", + "bmp_step_move10.bin", //operation screen "bmp_auto_off.bin", - "bmp_Speed.bin", + "bmp_speed.bin", //"bmp_Mamual.bin", //TODO: didn't find it.. changed to bmp_manual_off.bin - "bmp_Fan.bin", - //"bmp_PreHeat.bin", - //"bmp_Extruct.bin", - // "bmp_Mov.bin", + "bmp_fan.bin", + "bmp_temp.bin", + "bmp_extrude_opr.bin", + "bmp_move_opr.bin", //change speed screen - "bmp_Step1_percent.bin", - "bmp_Step5_percent.bin", - "bmp_Step10_percent.bin", + "bmp_step1_percent.bin", + "bmp_step5_percent.bin", + "bmp_step10_percent.bin", "bmp_extruct_sel.bin", "bmp_mov_changespeed.bin", // "bmp_extrude_opr.bin", equal to "bmp_Extruct.bin" "bmp_mov_sel.bin", + "bmp_speed_extruct.bin", //printing screen - "bmp_Pause.bin", - "bmp_Resume.bin", - "bmp_Stop.bin", - "bmp_Ext1_state.bin", - #if EXTRUDERS > 1 - "bmp_Ext2_state.bin", + "bmp_pause.bin", + "bmp_resume.bin", + "bmp_stop.bin", + "bmp_ext1_state.bin", + #if HAS_MULTI_EXTRUDER + "bmp_ext2_state.bin", #endif - "bmp_Bed_state.bin", - "bmp_Fan_state.bin", - "bmp_Time_state.bin", - "bmp_Zpos_state.bin", - "bmp_Operate.bin", + "bmp_bed_state.bin", + "bmp_fan_state.bin", + "bmp_time_state.bin", + "bmp_zpos_state.bin", + "bmp_operate.bin", //manual leval screen (only if disabled auto level) #if DISABLED(AUTO_BED_LEVELING_BILINEAR) - "bmp_Leveling1.bin", - "bmp_Leveling2.bin", - "bmp_Leveling3.bin", - "bmp_Leveling4.bin", - "bmp_Leveling5.bin", + "bmp_leveling1.bin", + "bmp_leveling2.bin", + "bmp_leveling3.bin", + "bmp_leveling4.bin", + "bmp_leveling5.bin", #endif //lang select screen #if HAS_LANG_SELECT_SCREEN - "bmp_Language.bin", + "bmp_language.bin", "bmp_simplified_cn.bin", "bmp_simplified_cn_sel.bin", "bmp_traditional_cn.bin", "bmp_traditional_cn_sel.bin", - "bmp_English.bin", - "bmp_English_sel.bin", - "bmp_Russian.bin", - "bmp_Russian_sel.bin", - "bmp_Spanish.bin", - "bmp_Spanish_sel.bin", - "bmp_French.bin", - "bmp_French_sel.bin", - "bmp_Italy.bin", - "bmp_Italy_sel.bin", + "bmp_english.bin", + "bmp_english_sel.bin", + "bmp_russian.bin", + "bmp_russian_sel.bin", + "bmp_spanish.bin", + "bmp_spanish_sel.bin", + "bmp_french.bin", + "bmp_french_sel.bin", + "bmp_italy.bin", + "bmp_italy_sel.bin", #endif // HAS_LANG_SELECT_SCREEN // gcode preview @@ -177,21 +181,15 @@ static char assets[][LONG_FILENAME_LENGTH] = { #endif // settings screen - "bmp_About.bin", + "bmp_about.bin", //"bmp_Language.bin", //"bmp_Fan.bin", //"bmp_manual_off.bin", //start screen "bmp_printing.bin", - "bmp_Set.bin", - "bmp_Tool.bin", - - #if ENABLED(HAS_STEALTHCHOP) - //"bmp_back70x40.bin", - "bmp_disable.bin", - "bmp_enable.bin", - #endif + "bmp_set.bin", + "bmp_tool.bin", // settings screen "bmp_eeprom_settings.bin", @@ -202,14 +200,27 @@ static char assets[][LONG_FILENAME_LENGTH] = { "bmp_arrow.bin", "bmp_back70x40.bin", "bmp_value_blank.bin", - "bmp_Return.bin" + "bmp_blank_sel.bin", + "bmp_disable.bin", + "bmp_enable.bin", + "bmp_return.bin", + + #if ENABLED(USE_WIFI_FUNCTION) + //wifi screen + "bmp_wifi.bin", + #endif + + //babystep screen + "bmp_baby_move0_01.bin", + "bmp_baby_move0_05.bin", + "bmp_baby_move0_1.bin" }; #if HAS_SPI_FLASH_FONT static char fonts[][LONG_FILENAME_LENGTH] = { "FontUNIGBK.bin" }; #endif -static uint8_t currentFlashPage = 0; +uint8_t currentFlashPage = 0; uint32_t lv_get_pic_addr(uint8_t *Pname) { uint8_t Pic_cnt; @@ -253,8 +264,13 @@ const char *bakPath = "_assets"; void spiFlashErase_PIC() { volatile uint32_t pic_sectorcnt = 0; W25QXX.init(SPI_QUARTER_SPEED); - for (pic_sectorcnt = 0; pic_sectorcnt < PIC_SIZE_xM * 1024 / 64; pic_sectorcnt++) - W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024); + //erase 0x001000 -64K + for (pic_sectorcnt = 0; pic_sectorcnt < (64 - 4) / 4; pic_sectorcnt++) { + W25QXX.SPI_FLASH_SectorErase(PICINFOADDR + pic_sectorcnt * 4 * 1024); + } + //erase 64K -- 6M + for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) + W25QXX.SPI_FLASH_BlockErase((pic_sectorcnt + 1) * 64 * 1024); } #if HAS_SPI_FLASH_FONT diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h index 24b2945d73e7..b1bd88a60d0c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h @@ -21,7 +21,7 @@ */ #pragma once -#include "../../../../inc/MarlinConfig.h" +#include "../../../../inc/MarlinConfigPre.h" #include "../../../../libs/W25Qxx.h" @@ -119,9 +119,18 @@ // Flash flag #define REFLSHE_FLGA_ADD (0X800000-32) -#define FLASH_INF_VALID_FLAG 0xAA558761 + // SD card information first addr #define VAR_INF_ADDR 0x000000 +#define FLASH_INF_VALID_FLAG 0x20200831 + +//Store some gcode commands, such as auto leveling commands +#define GCODE_COMMAND_ADDR VAR_INF_ADDR + 3*1024 +#define AUTO_LEVELING_COMMAND_ADDR GCODE_COMMAND_ADDR +#define OTHERS_COMMAND_ADDR_1 AUTO_LEVELING_COMMAND_ADDR + 100 +#define OTHERS_COMMAND_ADDR_2 OTHERS_COMMAND_ADDR_1 + 100 +#define OTHERS_COMMAND_ADDR_3 OTHERS_COMMAND_ADDR_2 + 100 +#define OTHERS_COMMAND_ADDR_4 OTHERS_COMMAND_ADDR_3 + 100 #ifdef __cplusplus extern "C" { /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp index 2d03373a7f4f..0e4526734ca1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp @@ -53,6 +53,11 @@ void printer_state_polling() { planner.synchronize(); gcode.process_subcommands_now_P(PSTR("M25")); + + //save the positon + uiCfg.current_x_position_bak = current_position.x; + uiCfg.current_y_position_bak = current_position.y; + if (gCfgItems.pausePosZ != (float)-1) { gcode.process_subcommands_now_P(PSTR("G91")); ZERO(public_buf_l); @@ -66,6 +71,7 @@ void printer_state_polling() { gcode.process_subcommands_now(public_buf_l); } uiCfg.print_state = PAUSED; + uiCfg.current_e_position_bak = current_position.e; // #if ENABLED(POWER_LOSS_RECOVERY) // if (recovery.enabled) recovery.save(true); @@ -83,7 +89,19 @@ void printer_state_polling() { if (uiCfg.print_state == RESUMING) { if (IS_SD_PAUSED()) { - gcode.process_subcommands_now_P(PSTR("M24\nG91\nG1 Z-5\nG90")); + if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) { + ZERO(public_buf_m); + sprintf_P(public_buf_m, PSTR("G1 X%.1f Y%.1f"), uiCfg.current_x_position_bak, uiCfg.current_y_position_bak); + gcode.process_subcommands_now(public_buf_m); + } + if (gCfgItems.pausePosZ != (float)-1) { + gcode.process_subcommands_now_P(PSTR("G91")); + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ); + gcode.process_subcommands_now(public_buf_l); + gcode.process_subcommands_now_P(PSTR("G90")); + } + gcode.process_subcommands_now_P(PSTR("M24")); uiCfg.print_state = WORKING; start_print_time(); @@ -108,11 +126,25 @@ void printer_state_polling() { } #endif - if (gCfgItems.pause_reprint == 1) { - gcode.process_subcommands_now_P(PSTR("G91\nG1 Z-5\nG90")); - } recovery.resume(); - + #if 0 + // Move back to the saved XY + char str_1[16], str_2[16]; + ZERO(public_buf_m); + sprintf_P(public_buf_m, PSTR("G1 X%s Y%s F2000"), + dtostrf(recovery.info.current_position.x, 1, 3, str_1), + dtostrf(recovery.info.current_position.y, 1, 3, str_2) + ); + gcode.process_subcommands_now(public_buf_m); + + if ((gCfgItems.pause_reprint) == 1 && (gCfgItems.pausePosZ != (float)-1)) { + gcode.process_subcommands_now_P(PSTR("G91")); + ZERO(public_buf_l); + sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ); + gcode.process_subcommands_now(public_buf_l); + gcode.process_subcommands_now_P(PSTR("G90")); + } + #endif uiCfg.print_state = WORKING; start_print_time(); @@ -123,6 +155,8 @@ void printer_state_polling() { if (uiCfg.print_state == WORKING) filament_check(); + + TERN_(USE_WIFI_FUNCTION, wifi_looping()); } void filament_pin_setup() { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h index 54e06f582648..fa8d5a52a496 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h @@ -46,8 +46,8 @@ #define MACHINE_PARA_TITLE_EN "Config" #define MACHINE_TYPE_CNOFIG_EN "Machine settings" -#define TEMPERATURE_CONFIG_EN "Temperature settings" #define MOTOR_CONFIG_EN "Motor settings" +#define MACHINE_LEVELING_CONFIG_EN "Leveling settings" #define ADVANCE_CONFIG_EN "Adavance settings" #define MACHINE_CONFIG_TITLE_EN "Machine Settings" @@ -56,7 +56,6 @@ #define MACHINE_HOMEDIR_EN "Home direction" #define MACHINE_ENDSTOP_TYPE_EN "Endstop type" #define MACHINE_FILAMENT_CONFIG_EN "Filament settings" -#define MACHINE_LEVELING_CONFIG_EN "Leveling settings" #define MACHINE_TYPE_CONFIG_TITLE_EN "Machine Settings>Machine type" #define MACHINE_TYPE_XYZ_EN "XYZ Machine" @@ -91,18 +90,18 @@ #define ENDSTOP_OPENED_EN "Open" #define ENDSTOP_CLOSED_EN "Close" -#define FILAMENT_CONF_TITLE_EN "Filament settings" -#define FILAMENT_IN_TEMPERATURE_EN "Load temperature" +#define FILAMENT_CONF_TITLE_EN "Machine Settings>Filament settings" #define FILAMENT_IN_LENGTH_EN "Load length" #define FILAMENT_IN_SPEED_EN "Load speed" -#define FILAMENT_OUT_TEMPERATURE_EN "Unload temperature" +#define FILAMENT_TEMPERATURE_EN "Filament temperature" #define FILAMENT_OUT_LENGTH_EN "Unload length" #define FILAMENT_OUT_SPEED_EN "Unload speed" -#define LEVELING_CONF_TITLE_EN "Leveling settings" +#define LEVELING_CONF_TITLE_EN "Machine Settings>Leveling settings" #define LEVELING_PARA_CONF_EN "Leveling settings" -#define LEVELING_DELTA_EN "delta machine leveling" -#define LEVELING_XYZ_EN "Manual leveling coordinate settings" +#define LEVELING_MANUAL_POS_EN "Manual leveling coordinate settings" +#define LEVELING_AUTO_COMMAND_EN "AutoLeveling command settings" +#define LEVELING_AUTO_ZOFFSET_EN "Nozzle-to-probe offsets settings" #define LEVELING_PARA_CONF_TITLE_EN "leveling setting" #define AUTO_LEVELING_ENABLE_EN "Enable auto leveling" @@ -226,6 +225,9 @@ #define HAVE_UPS_EN "Has UPS power supply" #define Z2_AND_Z2ENDSTOP_CONF_EN "Z2 Settings" #define ENABLE_PINS_CONF_EN "Enable pins level settings" +#define WIFI_SETTINGS_EN "Wi-Fi parameter settings" +#define HOMING_SENSITIVITY_CONF_EN "Homing sensitivity settings" +#define ENCODER_SETTINGS_EN "Rotary encoder settings" #define Z2_AND_Z2ENDSTOP_CONF_TITLE_EN "Z2 Settings" #define Z2_ENABLE_EN "Z2 Enable" @@ -243,6 +245,29 @@ #define PAUSE_POSITION_Y_EN "Y axis position (Absolute position,-1 invalid)" #define PAUSE_POSITION_Z_EN "Z axis position (Relative position,-1 invalid)" +#define WIFI_SETTINGS_TITLE_EN "Machine Settings>Wi-Fi Parameter" +#define WIFI_SETTINGS_MODE_EN "Wi-Fi Mode" +#define WIFI_SETTINGS_NAME_EN "Wi-Fi Name: " +#define WIFI_SETTINGS_PASSWORD_EN "Wi-Fi Password: " +#define WIFI_SETTINGS_CLOUD_EN "Do you use cloud services?" +#define WIFI_SETTINGS_CONFIG_EN "Config" +#define WIFI_SETTINGS_EDIT_EN "Edit" +#define WIFI_CONFIG_TIPS_EN "Wi-Fi configuration?" + +#define OFFSET_TITLE_EN "Machine Settings>Offset" +#define OFFSET_X_EN "X offset" +#define OFFSET_Y_EN "Y offset" +#define OFFSET_Z_EN "Z offset" + +#define HOMING_SENSITIVITY_CONF_TITLE_EN "Machine Settings>Sensitivity" +#define X_SENSITIVITY_EN "X Axis Sensitivity" +#define Y_SENSITIVITY_EN "Y Axis Sensitivity" +#define Z_SENSITIVITY_EN "Z Axis Sensitivity" +#define Z2_SENSITIVITY_EN "Z2 Axis Sensitivity" + +#define ENCODER_CONF_TITLE_EN "Machine Settings>Rotary encoder settings" +#define ENCODER_CONF_TEXT_EN "Is the encoder function used?" + #define TOOL_TEXT_EN "Tool" #define PREHEAT_TEXT_EN "Preheat" #define MOVE_TEXT_EN "Move" @@ -429,10 +454,6 @@ #define STEP_5PERCENT_EN "5%" #define STEP_10PERCENT_EN "10%" -#define ZOFFSET_EN "Z Offset" -#define ZOFFSET_INC_EN "Add" -#define ZOFFSET_DEC_EN "Dec" - #define TITLE_READYPRINT_EN "ReadyPrint" #define TITLE_PREHEAT_EN "Preheat" #define TITLE_MOVE_EN "Move" @@ -455,7 +476,6 @@ #define TITLE_CLOUD_TEXT_EN "Cloud" #define TITLE_DIALOG_CONFIRM_EN "Confirm" #define TITLE_FILESYS_EN "FileSys" -#define TITLE_ZOFFSET_EN "Z Offset" #define AUTO_SHUTDOWN_EN "Auto" #define MANUAL_SHUTDOWN_EN "Manual" @@ -494,11 +514,9 @@ #define TEXT_WIFI_SYMBOL_EN "#+=" #define TEXT_WIFI_PASSWORD_EN "Password" -#define TEXT_WIFI_POINT_BOLD_EN "`" - -#define TEXT_WIFI_JOINING_EN "Joining\nNetwork..." -#define TEXT_WIFI_FAILED_JOIN_EN "Failed to\nJoin Wi-Fi" -#define TEXT_WIFI_WIFI_CONECTED_EN "Wi-Fi\nConnected" +#define TEXT_WIFI_JOINING_EN "Joining Network..." +#define TEXT_WIFI_FAILED_JOIN_EN "Failed to Join Wi-Fi" +#define TEXT_WIFI_WIFI_CONECTED_EN "Wi-Fi Connected" #define TEXT_BUTTON_DISCONECTED_EN "Disconnect" #define TEXT_WIFI_FORGET_EN "Forget Network" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h index 3fe95654b1a4..6944d6b23518 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h @@ -208,10 +208,6 @@ #define STEP_5PERCENT_FR "5%" #define STEP_10PERCENT_FR "10%" -#define ZOFFSET_FR "Z Offset" -#define ZOFFSET_INC_FR "Ajouter" -#define ZOFFSET_DEC_FR "Réduire" - #define TITLE_READYPRINT_FR "Prête" #define TITLE_PREHEAT_FR "Préchauffe" #define TITLE_MOVE_FR "Déplace" @@ -234,7 +230,6 @@ #define TITLE_CLOUD_TEXT_FR "Cloud" #define TITLE_DIALOG_CONFIRM_FR "Confirm" #define TITLE_FILESYS_FR "FileSys" -#define TITLE_ZOFFSET_FR "Z Offset" #define DIALOG_CLOSE_MACHINE_FR "Closing machine......" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h index aef6cfaf9609..f64ca4df79df 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h @@ -205,10 +205,6 @@ #define STEP_5PERCENT_IT "5%" #define STEP_10PERCENT_IT "10%" -#define ZOFFSET_IT "Z Offset" -#define ZOFFSET_INC_IT "Add" -#define ZOFFSET_DEC_IT "Dec" - #define TITLE_READYPRINT_IT "Pronto" #define TITLE_PREHEAT_IT "Preris" #define TITLE_MOVE_IT "Muovi" @@ -231,7 +227,6 @@ #define TITLE_CLOUD_TEXT_IT "Cloud" #define TITLE_DIALOG_CONFIRM_IT "Confirm" #define TITLE_FILESYS_IT "FileSys" -#define TITLE_ZOFFSET_IT "Z Offset" #define AUTO_SHUTDOWN_IT "Auto" #define MANUAL_SHUTDOWN_IT "Manuale" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h index 2ec39ab01646..9f695b376b59 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h @@ -205,10 +205,6 @@ #define STEP_5PERCENT_RU "5%" #define STEP_10PERCENT_RU "10%" -#define ZOFFSET_RU "Z Offset" -#define ZOFFSET_INC_RU "добавить" -#define ZOFFSET_DEC_RU "уменьшить" - #define TITLE_READYPRINT_RU "готов к" #define TITLE_PREHEAT_RU "движение" #define TITLE_MOVE_RU "движение" @@ -232,7 +228,6 @@ #define TITLE_CLOUD_TEXT_RU "Cloud" #define TITLE_DIALOG_CONFIRM_RU "Confirm" #define TITLE_FILESYS_RU "FileSys" -#define TITLE_ZOFFSET_RU "Z Offset" #define AUTO_SHUTDOWN_RU "авто-откл" #define MANUAL_SHUTDOWN_RU "ручн-откл" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h index ea481c89a24e..118992777048 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h @@ -31,8 +31,8 @@ #define MACHINE_PARA_TITLE_CN "机器参数" #define MACHINE_TYPE_CNOFIG_CN "机器设置" -#define TEMPERATURE_CONFIG_CN "温度设置" #define MOTOR_CONFIG_CN "电机设置" +#define MACHINE_LEVELING_CONFIG_CN "调平设置" #define ADVANCE_CONFIG_CN "高级设置" #define MACHINE_CONFIG_TITLE_CN "机器参数>机器配置" @@ -41,7 +41,6 @@ #define MACHINE_HOMEDIR_CN "归零方向" #define MACHINE_ENDSTOP_TYPE_CN "限位开关类型" #define MACHINE_FILAMENT_CONFIG_CN "换料设置" -#define MACHINE_LEVELING_CONFIG_CN "调平设置" #define MACHINE_TYPE_CONFIG_TITLE_CN "机器参数>机型选择" #define MACHINE_TYPE_XYZ_CN "XYZ机型" @@ -77,17 +76,17 @@ #define ENDSTOP_CLOSED_CN "常闭" #define FILAMENT_CONF_TITLE_CN "换料设置" -#define FILAMENT_IN_TEMPERATURE_CN "进料温度" #define FILAMENT_IN_LENGTH_CN "进料长度" #define FILAMENT_IN_SPEED_CN "进料速度" -#define FILAMENT_OUT_TEMPERATURE_CN "退料温度" +#define FILAMENT_TEMPERATURE_CN "换料温度" #define FILAMENT_OUT_LENGTH_CN "退料长度" #define FILAMENT_OUT_SPEED_CN "退料速度" -#define LEVELING_CONF_TITLE_CN "调平设置" +#define LEVELING_CONF_TITLE_CN "机器参数>调平设置" #define LEVELING_PARA_CONF_CN "调平设置" -#define LEVELING_DELTA_CN "delta机型设置" -#define LEVELING_XYZ_CN "手动调平坐标设置" +#define LEVELING_MANUAL_POS_CN "手动调平坐标设置" +#define LEVELING_AUTO_COMMAND_CN "自动调平指令设置" +#define LEVELING_AUTO_ZOFFSET_CN "挤出头与调平开关偏移设置" #define LEVELING_PARA_CONF_TITLE_CN "调平参数" #define AUTO_LEVELING_ENABLE_CN "自动调平" @@ -146,6 +145,7 @@ #define TMC_STEP_MODE_CN "TMC 驱动模式设置" #define MOTORDIRCONF_CN "电机方向设置" #define HOMEFEEDRATECONF_CN "归零速度设置" +#define HOMING_SENSITIVITY_CONF_CN "无限位回零灵敏度调节" #define MAXFEEDRATE_CONF_TITLE_CN "机器参数>最大速度" #define X_MAXFEEDRATE_CN "X轴最大速度" @@ -211,6 +211,8 @@ #define HAVE_UPS_CN "机器配备UPS电源" #define Z2_AND_Z2ENDSTOP_CONF_CN "双Z轴双限位功能设置" #define ENABLE_PINS_CONF_CN "电机使能脚电平设置" +#define WIFI_SETTINGS_CN "Wi-Fi参数设置" +#define ENCODER_SETTINGS_CN "旋钮设置" #define Z2_AND_Z2ENDSTOP_CONF_TITLE_CN "双z双限位设置" #define Z2_ENABLE_CN "启用Z2轴" @@ -223,10 +225,33 @@ #define Z_ENABLE_PINS_INVERT_CN "Z轴电机使能电平" #define E_ENABLE_PINS_INVERT_CN "E轴电机使能电平" -#define PAUSE_POSITION_CN "打印暂停位置设置" -#define PAUSE_POSITION_X_CN "X轴暂停位置(绝对位置,-1无效)" -#define PAUSE_POSITION_Y_CN "Y轴暂停位置(绝对位置,-1无效)" -#define PAUSE_POSITION_Z_CN "Z轴暂停位置(相对位置,-1无效)" +#define PAUSE_POSITION_CN "打印暂停位置设置" +#define PAUSE_POSITION_X_CN "X轴暂停位置(绝对位置,-1无效)" +#define PAUSE_POSITION_Y_CN "Y轴暂停位置(绝对位置,-1无效)" +#define PAUSE_POSITION_Z_CN "Z轴暂停位置(相对位置,-1无效)" +#define WIFI_SETTINGS_TITLE_CN "机器参数>Wi-Fi设置" +#define WIFI_SETTINGS_MODE_CN "Wi-Fi 模式" +#define WIFI_SETTINGS_NAME_CN "Wi-Fi 名称: " +#define WIFI_SETTINGS_PASSWORD_CN "Wi-Fi 密码: " +#define WIFI_SETTINGS_CLOUD_CN "是否使用云服务?" +#define WIFI_SETTINGS_CONFIG_CN "配置" +#define WIFI_SETTINGS_EDIT_CN "编辑" +#define WIFI_CONFIG_TIPS_CN "进行Wi-Fi配置?" + +#define OFFSET_TITLE_CN "机器参数>偏移设置" +#define OFFSET_X_CN "X轴与调平开关偏移" +#define OFFSET_Y_CN "Y轴与调平开关偏移" +#define OFFSET_Z_CN "Z轴与调平开关偏移" + +#define HOMING_SENSITIVITY_CONF_TITLE_CN "机器参数>灵敏度调节" +#define X_SENSITIVITY_CN "X轴灵敏度" +#define Y_SENSITIVITY_CN "Y轴灵敏度" +#define Z_SENSITIVITY_CN "Z轴灵敏度" +#define Z2_SENSITIVITY_CN "Z2轴灵敏度" + +#define ENCODER_CONF_TITLE_CN "机器参数>旋钮设置" +#define ENCODER_CONF_TEXT_CN "是否使用旋钮功能?" + #define TOOL_TEXT_CN "工具" #define PREHEAT_TEXT_CN "预热" #define MOVE_TEXT_CN "移动" @@ -395,10 +420,6 @@ #define STEP_5PERCENT_CN "5%" #define STEP_10PERCENT_CN "10%" -#define ZOFFSET_CN "Z Offset" -#define ZOFFSET_INC_CN "增加" -#define ZOFFSET_DEC_CN "减少" - #define TITLE_READYPRINT_CN "准备打印" #define TITLE_PREHEAT_CN "预热" #define TITLE_MOVE_CN "移动" @@ -421,7 +442,6 @@ #define TITLE_CLOUD_TEXT_CN "云服务" #define TITLE_DIALOG_CONFIRM_CN "确认" #define TITLE_FILESYS_CN "文件系统" -#define TITLE_ZOFFSET_CN "Z Offset" #define AUTO_SHUTDOWN_CN "自动关机" #define MANUAL_SHUTDOWN_CN "手动关机" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h index 289874c6baf1..2babbaba93c4 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h @@ -206,10 +206,6 @@ #define STEP_5PERCENT_SP "5%" #define STEP_10PERCENT_SP "10%" -#define ZOFFSET_SP "Z Offset" -#define ZOFFSET_INC_SP "Más" -#define ZOFFSET_DEC_SP "Menos" - #define TITLE_READYPRINT_SP "Inicio" #define TITLE_PREHEAT_SP "Precalentar" #define TITLE_MOVE_SP "Mover" @@ -233,7 +229,6 @@ #define TITLE_CLOUD_TEXT_SP "Cloud" #define TITLE_DIALOG_CONFIRM_SP "Confirmar" #define TITLE_FILESYS_SP "Puerto" -#define TITLE_ZOFFSET_SP "Z Offset" #define AUTO_SHUTDOWN_SP "Auto" #define MANUAL_SHUTDOWN_SP "manual" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h index 19bd511d9a38..d956e14aadf1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h @@ -31,8 +31,8 @@ #define MACHINE_PARA_TITLE_T_CN "機器參數" #define MACHINE_TYPE_CNOFIG_T_CN "機器設置" -#define TEMPERATURE_CONFIG_T_CN "溫度設置" #define MOTOR_CONFIG_T_CN "電機設置" +#define MACHINE_LEVELING_CONFIG_T_CN "調平設置" #define ADVANCE_CONFIG_T_CN "高級設置" #define MACHINE_CONFIG_TITLE_T_CN "機器參數>機器配置" @@ -41,7 +41,6 @@ #define MACHINE_HOMEDIR_T_CN "歸零方向" #define MACHINE_ENDSTOP_TYPE_T_CN "限位開關類型" #define MACHINE_FILAMENT_CONFIG_T_CN "換料設置" -#define MACHINE_LEVELING_CONFIG_T_CN "調平設置" #define MACHINE_TYPE_CONFIG_TITLE_T_CN "機器參數>機型選擇" #define MACHINE_TYPE_XYZ_T_CN "XYZ機型" @@ -77,17 +76,17 @@ #define ENDSTOP_CLOSED_T_CN "常閉" #define FILAMENT_CONF_TITLE_T_CN "換料設置" -#define FILAMENT_IN_TEMPERATURE_T_CN "進料溫度" #define FILAMENT_IN_LENGTH_T_CN "進料長度" #define FILAMENT_IN_SPEED_T_CN "進料速度" -#define FILAMENT_OUT_TEMPERATURE_T_CN "退料溫度" +#define FILAMENT_TEMPERATURE_T_CN "換料溫度" #define FILAMENT_OUT_LENGTH_T_CN "退料長度" #define FILAMENT_OUT_SPEED_T_CN "退料速度" -#define LEVELING_CONF_TITLE_T_CN "調平設置" +#define LEVELING_CONF_TITLE_T_CN "機器參數>調平設置" #define LEVELING_PARA_CONF_T_CN "調平設置" -#define LEVELING_DELTA_T_CN "delta機型設置" -#define LEVELING_XYZ_T_CN "手動調平坐標設置" +#define LEVELING_MANUAL_POS_T_CN "手動調平坐標設置" +#define LEVELING_AUTO_COMMAND_T_CN "自動調平指令設置" +#define LEVELING_AUTO_ZOFFSET_T_CN "擠出頭與調平開關偏移設置" #define LEVELING_PARA_CONF_TITLE_T_CN "調平參數" #define AUTO_LEVELING_ENABLE_T_CN "自動調平" @@ -146,6 +145,7 @@ #define TMC_STEP_MODE_T_CN "TMC 驅動模式設置" #define MOTORDIRCONF_T_CN "電機方向設置" #define HOMEFEEDRATECONF_T_CN "歸零速度設置" +#define HOMING_SENSITIVITY_CONF_T_CN "無限位回零靈敏度調節" #define MAXFEEDRATE_CONF_TITLE_T_CN "機器參數>最大速度" #define X_MAXFEEDRATE_T_CN "X軸最大速度" @@ -211,6 +211,8 @@ #define HAVE_UPS_T_CN "機器配備UPS電壓" #define Z2_AND_Z2ENDSTOP_CONF_T_CN "雙z軸雙限位功能設置" #define ENABLE_PINS_CONF_T_CN "電機使能腳電平設置" +#define WIFI_SETTINGS_T_CN "Wi-Fi參數設置" +#define ENCODER_SETTINGS_T_CN "旋鈕設置" #define Z2_AND_Z2ENDSTOP_CONF_TITLE_T_CN "雙z軸雙限位設置" #define Z2_ENABLE_T_CN "啟用Z2軸" @@ -223,10 +225,32 @@ #define Z_ENABLE_PINS_INVERT_T_CN "Z軸電機使能電平" #define E_ENABLE_PINS_INVERT_T_CN "E軸電機使能電平" -#define PAUSE_POSITION_T_CN "打印暫停位置設置" -#define PAUSE_POSITION_X_T_CN "X軸暫停位置(絕對位置,-1無效)" -#define PAUSE_POSITION_Y_T_CN "Y軸暫停位置(絕對位置,-1無效)" -#define PAUSE_POSITION_Z_T_CN "Z軸暫停位置(相對位置,-1無效)" +#define PAUSE_POSITION_T_CN "打印暫停位置設置" +#define PAUSE_POSITION_X_T_CN "X軸暫停位置(絕對位置,-1無效)" +#define PAUSE_POSITION_Y_T_CN "Y軸暫停位置(絕對位置,-1無效)" +#define PAUSE_POSITION_Z_T_CN "Z軸暫停位置(相對位置,-1無效)" +#define WIFI_SETTINGS_TITLE_T_CN "機器參數>Wi-Fi設置" +#define WIFI_SETTINGS_MODE_T_CN "Wi-Fi 模式" +#define WIFI_SETTINGS_NAME_T_CN "Wi-Fi 名稱: " +#define WIFI_SETTINGS_PASSWORD_T_CN "Wi-Fi 密碼: " +#define WIFI_SETTINGS_CLOUD_T_CN "是否使用雲服務?" +#define WIFI_SETTINGS_CONFIG_T_CN "配置" +#define WIFI_SETTINGS_EDIT_T_CN "編輯" +#define WIFI_CONFIG_TIPS_T_CN "進行Wi-Fi配置?" + +#define OFFSET_TITLE_T_CN "機器參數>偏移設置" +#define OFFSET_X_T_CN "X軸與調平開關偏移" +#define OFFSET_Y_T_CN "Y軸與調平開關偏移" +#define OFFSET_Z_T_CN "Z軸與調平開關偏移" + +#define HOMING_SENSITIVITY_CONF_TITLE_T_CN "機器參數>靈敏度調節" +#define X_SENSITIVITY_T_CN "X軸靈敏度" +#define Y_SENSITIVITY_T_CN "Y軸靈敏度" +#define Z_SENSITIVITY_T_CN "Z軸靈敏度" +#define Z2_SENSITIVITY_T_CN "Z2軸靈敏度" + +#define ENCODER_CONF_TITLE_T_CN "機器參數>旋鈕設置" +#define ENCODER_CONF_TEXT_T_CN "是否使用旋鈕功能?" #define TOOL_TEXT_T_CN "工具" #define PREHEAT_TEXT_T_CN "預熱" @@ -398,10 +422,6 @@ #define STEP_5PERCENT_T_CN "5%%" #define STEP_10PERCENT_T_CN "10%%" -#define ZOFFSET_T_CN "Z Offset" -#define ZOFFSET_INC_T_CN "增加" -#define ZOFFSET_DEC_T_CN "減少" - #define TITLE_READYPRINT_T_CN "準備打印" #define TITLE_PREHEAT_T_CN "預熱" #define TITLE_MOVE_T_CN "移動" @@ -424,7 +444,6 @@ #define TITLE_CLOUD_TEXT_T_CN "雲服務" #define TITLE_DIALOG_CONFIRM_T_CN "確認" #define TITLE_FILESYS_T_CN "文件系統" -#define TITLE_ZOFFSET_T_CN "Z Offset" #define AUTO_SHUTDOWN_T_CN "自動關機" #define MANUAL_SHUTDOWN_T_CN "手動關機" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp index 23072d27c750..af292db7d599 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp @@ -35,14 +35,18 @@ #include "tft_lvgl_configuration.h" #include "draw_ready_print.h" + #include "pic_manager.h" #include "mks_hardware_test.h" #include "draw_ui.h" +#include "SPIFlashStorage.h" #include +#include "../../../../MarlinCore.h" #include "../../../../inc/MarlinConfig.h" #include HAL_PATH(../../HAL, tft/xpt2046.h) +#include "../../../ultralcd.h" XPT2046 touch; #if ENABLED(POWER_LOSS_RECOVERY) @@ -63,6 +67,7 @@ XPT2046 touch; #endif static lv_disp_buf_t disp_buf; +lv_group_t* g; #if ENABLED(SDSUPPORT) extern void UpdateAssets(); #endif @@ -89,306 +94,349 @@ extern uint8_t sel_id; extern uint8_t gcode_preview_over, flash_preview_begin, default_preview_flg; +uint8_t bmp_public_buf[17 * 1024]; + void SysTick_Callback() { lv_tick_inc(1); print_time_count(); -} - -#if DISABLED(TFT_LVGL_UI_SPI) - -extern void LCD_IO_Init(uint8_t cs, uint8_t rs); -extern void LCD_IO_WriteData(uint16_t RegValue); -extern void LCD_IO_WriteReg(uint16_t Reg); - -extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count); -void tft_set_cursor(uint16_t x, uint16_t y) { - LCD_IO_WriteReg(0x002A); - LCD_IO_WriteData(x >> 8); - LCD_IO_WriteData(x & 0x00FF); - LCD_IO_WriteData(x >> 8); - LCD_IO_WriteData(x & 0x00FF); - //ILI9488_WriteData(0x01); - //ILI9488_WriteData(0xDF); - LCD_IO_WriteReg(0x002B); - LCD_IO_WriteData(y >> 8); - LCD_IO_WriteData(y & 0x00FF); - LCD_IO_WriteData(y >> 8); - LCD_IO_WriteData(y & 0x00FF); - //ILI9488_WriteData(0x01); - //ILI9488_WriteData(0x3F); -} - -void LCD_WriteRAM_Prepare(void) { - #if 0 - switch (DeviceCode) { - case 0x9325: case 0x9328: case 0x8989: { - ClrCs - LCD->LCD_REG = R34; - SetCs - } break; - default: LCD_WrtReg(0x002C); + #if ENABLED(USE_WIFI_FUNCTION) + if (tips_disp.timer == TIPS_TIMER_START) { + tips_disp.timer_count++; } - #else - LCD_IO_WriteReg(0x002C); #endif + if (uiCfg.filament_loading_time_flg == 1) { + uiCfg.filament_loading_time_cnt++; + uiCfg.filament_rate = (uint32_t)(((uiCfg.filament_loading_time_cnt / (uiCfg.filament_loading_time * 1000.0)) * 100.0) + 0.5); + if (uiCfg.filament_loading_time_cnt >= (uiCfg.filament_loading_time * 1000)) { + uiCfg.filament_loading_time_cnt = 0; + uiCfg.filament_loading_time_flg = 0; + uiCfg.filament_loading_completed = 1; + } + } + if (uiCfg.filament_unloading_time_flg == 1) { + uiCfg.filament_unloading_time_cnt++; + uiCfg.filament_rate = (uint32_t)(((uiCfg.filament_unloading_time_cnt / (uiCfg.filament_unloading_time * 1000.0)) * 100.0) + 0.5); + if (uiCfg.filament_unloading_time_cnt >= (uiCfg.filament_unloading_time * 1000)) { + uiCfg.filament_unloading_time_cnt = 0; + uiCfg.filament_unloading_time_flg = 0; + uiCfg.filament_unloading_completed = 1; + uiCfg.filament_rate = 100; + } + } } -void tft_set_point(uint16_t x, uint16_t y, uint16_t point) { - //if (DeviceCode == 0x9488) { - if (x > (TFT_WIDTH) || y > (TFT_HEIGHT)) return; - //} - tft_set_cursor(x, y); - - LCD_WriteRAM_Prepare(); - //LCD_WriteRAM(point); - LCD_IO_WriteData(point); -} - -void LCD_WriteReg(uint16_t LCD_Reg, uint16_t LCD_RegValue) { - /* Write 16-bit Index, then Write Reg */ - ClrCs - LCD_IO_WriteReg(LCD_Reg); - /* Write 16-bit Reg */ - LCD_IO_WriteData(LCD_RegValue); - SetCs -} +#if DISABLED(TFT_LVGL_UI_SPI) -void ili9320_SetWindows(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh) { - uint16_t s_h, s_l, e_h, e_l; - uint16_t xEnd, yEnd; - xEnd = StartX + width; - yEnd = StartY + heigh - 1; - if (DeviceCode == 0x8989) { - /*LCD_WriteReg(0x0044, (StartX & 0xFF) | (xEnd << 8)); - LCD_WriteReg(0x0045, StartY); - LCD_WriteReg(0x0046, yEnd);*/ - LCD_WriteReg(0x0044, (StartY & 0xFF) | (yEnd << 8)); - LCD_WriteReg(0x0045, StartX); - LCD_WriteReg(0x0046, xEnd); - } - else if (DeviceCode == 0x9488) { - s_h = (StartX >> 8) & 0x00ff; - s_l = StartX & 0x00ff; - e_h = ((StartX + width - 1) >> 8) & 0x00ff; - e_l = (StartX + width - 1) & 0x00ff; + extern void LCD_IO_Init(uint8_t cs, uint8_t rs); + extern void LCD_IO_WriteData(uint16_t RegValue); + extern void LCD_IO_WriteReg(uint16_t Reg); + extern void LCD_IO_WriteMultiple(uint16_t color, uint32_t count); + void tft_set_cursor(uint16_t x, uint16_t y) { LCD_IO_WriteReg(0x002A); - LCD_IO_WriteData(s_h); - LCD_IO_WriteData(s_l); - LCD_IO_WriteData(e_h); - LCD_IO_WriteData(e_l); - - s_h = (StartY >> 8) & 0x00ff; - s_l = StartY & 0x00ff; - e_h = ((StartY + heigh - 1) >> 8) & 0x00ff; - e_l = (StartY + heigh - 1) & 0x00ff; - + LCD_IO_WriteData(x >> 8); + LCD_IO_WriteData(x & 0x00FF); + LCD_IO_WriteData(x >> 8); + LCD_IO_WriteData(x & 0x00FF); + //ILI9488_WriteData(0x01); + //ILI9488_WriteData(0xDF); LCD_IO_WriteReg(0x002B); - LCD_IO_WriteData(s_h); - LCD_IO_WriteData(s_l); - LCD_IO_WriteData(e_h); - LCD_IO_WriteData(e_l); + LCD_IO_WriteData(y >> 8); + LCD_IO_WriteData(y & 0x00FF); + LCD_IO_WriteData(y >> 8); + LCD_IO_WriteData(y & 0x00FF); + //ILI9488_WriteData(0x01); + //ILI9488_WriteData(0x3F); } - else if ((DeviceCode == 0x9325) || (DeviceCode == 0x9328) || (DeviceCode == 0x1505)) { - /* LCD_WriteReg(0x0050, StartX); - LCD_WriteReg(0x0052, StartY); - LCD_WriteReg(0x0051, xEnd); - LCD_WriteReg(0x0053, yEnd);*/ - LCD_WriteReg(0x0050, StartY); // Specify the start/end positions of the window address in the horizontal direction by an address unit - LCD_WriteReg(0x0051, yEnd); // Specify the start positions of the window address in the vertical direction by an address unit - LCD_WriteReg(0x0052, (TFT_HEIGHT) - xEnd); - LCD_WriteReg(0x0053, (TFT_HEIGHT) - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit + void LCD_WriteRAM_Prepare(void) { + #if 0 + switch (DeviceCode) { + case 0x9325: case 0x9328: case 0x8989: { + ClrCs + LCD->LCD_REG = R34; + SetCs + } break; + default: LCD_WrtReg(0x002C); + } + #else + LCD_IO_WriteReg(0x002C); + #endif } - else { - s_h = (StartX >> 8) & 0xFF; - s_l = StartX & 0xFF; - e_h = ((StartX + width - 1) >> 8) & 0xFF; - e_l = (StartX + width - 1) & 0xFF; - - LCD_IO_WriteReg(0x2A); - LCD_IO_WriteData(s_h); - LCD_IO_WriteData(s_l); - LCD_IO_WriteData(e_h); - LCD_IO_WriteData(e_l); - - s_h = (StartY >> 8) & 0xFF; - s_l = StartY & 0xFF; - e_h = ((StartY + heigh - 1) >> 8) & 0xFF; - e_l = (StartY + heigh - 1) & 0xFF; - - LCD_IO_WriteReg(0x2B); - LCD_IO_WriteData(s_h); - LCD_IO_WriteData(s_l); - LCD_IO_WriteData(e_h); - LCD_IO_WriteData(e_l); - } -} -void LCD_Clear(uint16_t Color) { - uint32_t index = 0; - unsigned int count; + void tft_set_point(uint16_t x, uint16_t y, uint16_t point) { + //if (DeviceCode == 0x9488) { + if (x > (TFT_WIDTH) || y > (TFT_HEIGHT)) return; + //} + tft_set_cursor(x, y); - if (DeviceCode == 0x9488) { - tft_set_cursor(0, 0); - ili9320_SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT); LCD_WriteRAM_Prepare(); - #ifdef LCD_USE_DMA_FSMC - LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT)); - #else - //index = (TFT_HEIGHT) / 2 * (TFT_WIDTH); - for (index = 0; index < (TFT_HEIGHT) * (TFT_WIDTH); index++) - LCD_IO_WriteData(Color); - #endif - //LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT)); - //while(index --) LCD_IO_WriteData(Color); - } - else if (DeviceCode == 0x5761) { - LCD_IO_WriteReg(0x002a); - LCD_IO_WriteData(0); - LCD_IO_WriteData(0); - LCD_IO_WriteData(HDP >> 8); - LCD_IO_WriteData(HDP & 0x00ff); - LCD_IO_WriteReg(0x002b); - LCD_IO_WriteData(0); - LCD_IO_WriteData(0); - LCD_IO_WriteData(VDP >> 8); - LCD_IO_WriteData(VDP & 0x00ff); - LCD_IO_WriteReg(0x002c); - LCD_IO_WriteReg(0x002c); - for (count = 0; count < (HDP + 1) * (VDP + 1); count++) - LCD_IO_WriteData(Color); - } - else { - tft_set_cursor(0, 0); - LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ - for (index = 0; index < 76800; index++) - LCD_IO_WriteData(Color); + //LCD_WriteRAM(point); + LCD_IO_WriteData(point); } -} - -#include HAL_PATH(../../HAL, tft/tft_fsmc.h) -extern TFT_IO tftio; -void init_tft() { - uint16_t i; - TERN_(HAS_LCD_CONTRAST, refresh_contrast()); + void LCD_WriteReg(uint16_t LCD_Reg, uint16_t LCD_RegValue) { + /* Write 16-bit Index, then Write Reg */ + ClrCs + LCD_IO_WriteReg(LCD_Reg); + /* Write 16-bit Reg */ + LCD_IO_WriteData(LCD_RegValue); + SetCs + } - #ifdef LCD_USE_DMA_FSMC - dma_init(FSMC_DMA_DEV); - dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); - dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM); - #endif + void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh) { + uint16_t s_h, s_l, e_h, e_l; + uint16_t xEnd, yEnd; + xEnd = StartX + width; + yEnd = StartY + heigh - 1; + if (DeviceCode == 0x8989) { + /*LCD_WriteReg(0x0044, (StartX & 0xFF) | (xEnd << 8)); + LCD_WriteReg(0x0045, StartY); + LCD_WriteReg(0x0046, yEnd);*/ + LCD_WriteReg(0x0044, (StartY & 0xFF) | (yEnd << 8)); + LCD_WriteReg(0x0045, StartX); + LCD_WriteReg(0x0046, xEnd); + } + else if (DeviceCode == 0x9488) { + s_h = (StartX >> 8) & 0x00ff; + s_l = StartX & 0x00ff; + e_h = ((StartX + width - 1) >> 8) & 0x00ff; + e_l = (StartX + width - 1) & 0x00ff; + + LCD_IO_WriteReg(0x002A); + LCD_IO_WriteData(s_h); + LCD_IO_WriteData(s_l); + LCD_IO_WriteData(e_h); + LCD_IO_WriteData(e_l); + + s_h = (StartY >> 8) & 0x00ff; + s_l = StartY & 0x00ff; + e_h = ((StartY + heigh - 1) >> 8) & 0x00ff; + e_l = (StartY + heigh - 1) & 0x00ff; + + LCD_IO_WriteReg(0x002B); + LCD_IO_WriteData(s_h); + LCD_IO_WriteData(s_l); + LCD_IO_WriteData(e_h); + LCD_IO_WriteData(e_l); + } + else if ((DeviceCode == 0x9325) || (DeviceCode == 0x9328) || (DeviceCode == 0x1505)) { + /* LCD_WriteReg(0x0050, StartX); + LCD_WriteReg(0x0052, StartY); + LCD_WriteReg(0x0051, xEnd); + LCD_WriteReg(0x0053, yEnd);*/ + LCD_WriteReg(0x0050, StartY); // Specify the start/end positions of the window address in the horizontal direction by an address unit + LCD_WriteReg(0x0051, yEnd); // Specify the start positions of the window address in the vertical direction by an address unit + LCD_WriteReg(0x0052, (TFT_HEIGHT) - xEnd); + LCD_WriteReg(0x0053, (TFT_HEIGHT) - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit - LCD_IO_Init(FSMC_CS_PIN, FSMC_RS_PIN); - - _delay_ms(5); - - DeviceCode = tftio.GetID() & 0xFFFF; - // Chitu and others - if (DeviceCode == 0x8066) DeviceCode = 0x9488; - - if (DeviceCode == 0x9488) { - LCD_IO_WriteReg(0x00E0); - LCD_IO_WriteData(0x0000); - LCD_IO_WriteData(0x0007); - LCD_IO_WriteData(0x000f); - LCD_IO_WriteData(0x000D); - LCD_IO_WriteData(0x001B); - LCD_IO_WriteData(0x000A); - LCD_IO_WriteData(0x003c); - LCD_IO_WriteData(0x0078); - LCD_IO_WriteData(0x004A); - LCD_IO_WriteData(0x0007); - LCD_IO_WriteData(0x000E); - LCD_IO_WriteData(0x0009); - LCD_IO_WriteData(0x001B); - LCD_IO_WriteData(0x001e); - LCD_IO_WriteData(0x000f); - - LCD_IO_WriteReg(0x00E1); - LCD_IO_WriteData(0x0000); - LCD_IO_WriteData(0x0022); - LCD_IO_WriteData(0x0024); - LCD_IO_WriteData(0x0006); - LCD_IO_WriteData(0x0012); - LCD_IO_WriteData(0x0007); - LCD_IO_WriteData(0x0036); - LCD_IO_WriteData(0x0047); - LCD_IO_WriteData(0x0047); - LCD_IO_WriteData(0x0006); - LCD_IO_WriteData(0x000a); - LCD_IO_WriteData(0x0007); - LCD_IO_WriteData(0x0030); - LCD_IO_WriteData(0x0037); - LCD_IO_WriteData(0x000f); - - LCD_IO_WriteReg(0x00C0); - LCD_IO_WriteData(0x0010); - LCD_IO_WriteData(0x0010); - - LCD_IO_WriteReg(0x00C1); - LCD_IO_WriteData(0x0041); - - LCD_IO_WriteReg(0x00C5); - LCD_IO_WriteData(0x0000); - LCD_IO_WriteData(0x0022); - LCD_IO_WriteData(0x0080); - - LCD_IO_WriteReg(0x0036); - //ILI9488_WriteData(0x0068); - //if (gCfgItems.overturn_180 != 0xEE) { - LCD_IO_WriteData(0x0068); - //} - //else { - //ILI9488_WriteData(0x00A8); - //} + } + else { + s_h = (StartX >> 8) & 0xFF; + s_l = StartX & 0xFF; + e_h = ((StartX + width - 1) >> 8) & 0xFF; + e_l = (StartX + width - 1) & 0xFF; + + LCD_IO_WriteReg(0x2A); + LCD_IO_WriteData(s_h); + LCD_IO_WriteData(s_l); + LCD_IO_WriteData(e_h); + LCD_IO_WriteData(e_l); + + s_h = (StartY >> 8) & 0xFF; + s_l = StartY & 0xFF; + e_h = ((StartY + heigh - 1) >> 8) & 0xFF; + e_l = (StartY + heigh - 1) & 0xFF; + + LCD_IO_WriteReg(0x2B); + LCD_IO_WriteData(s_h); + LCD_IO_WriteData(s_l); + LCD_IO_WriteData(e_h); + LCD_IO_WriteData(e_l); + } + } - LCD_IO_WriteReg(0x003A); //Interface Mode Control - LCD_IO_WriteData(0x0055); + void LCD_Clear(uint16_t Color) { + uint32_t index = 0; + unsigned int count; - LCD_IO_WriteReg(0x00B0); //Interface Mode Control - LCD_IO_WriteData(0x0000); - LCD_IO_WriteReg(0x00B1); //Frame rate 70HZ - LCD_IO_WriteData(0x00B0); - LCD_IO_WriteData(0x0011); - LCD_IO_WriteReg(0x00B4); - LCD_IO_WriteData(0x0002); - LCD_IO_WriteReg(0x00B6); //RGB/MCU Interface Control - LCD_IO_WriteData(0x0002); - LCD_IO_WriteData(0x0042); + if (DeviceCode == 0x9488) { + tft_set_cursor(0, 0); + LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT); + LCD_WriteRAM_Prepare(); + #ifdef LCD_USE_DMA_FSMC + LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT)); + #else + //index = (TFT_HEIGHT) / 2 * (TFT_WIDTH); + for (index = 0; index < (TFT_HEIGHT) * (TFT_WIDTH); index++) + LCD_IO_WriteData(Color); + #endif + //LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT)); + //while(index --) LCD_IO_WriteData(Color); + } + else if (DeviceCode == 0x5761) { + LCD_IO_WriteReg(0x002a); + LCD_IO_WriteData(0); + LCD_IO_WriteData(0); + LCD_IO_WriteData(HDP >> 8); + LCD_IO_WriteData(HDP & 0x00ff); + LCD_IO_WriteReg(0x002b); + LCD_IO_WriteData(0); + LCD_IO_WriteData(0); + LCD_IO_WriteData(VDP >> 8); + LCD_IO_WriteData(VDP & 0x00ff); + LCD_IO_WriteReg(0x002c); + LCD_IO_WriteReg(0x002c); + for (count = 0; count < (HDP + 1) * (VDP + 1); count++) + LCD_IO_WriteData(Color); + } + else { + tft_set_cursor(0, 0); + LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ + for (index = 0; index < 76800; index++) + LCD_IO_WriteData(Color); + } + } - LCD_IO_WriteReg(0x00B7); - LCD_IO_WriteData(0x00C6); + #include HAL_PATH(../../HAL, tft/tft_fsmc.h) + extern TFT_IO tftio; + void fsmc_tft_init() { + uint16_t i; - //WriteComm(0xBE); - //WriteData(0x00); - //WriteData(0x04); + TERN_(HAS_LCD_CONTRAST, refresh_contrast()); - LCD_IO_WriteReg(0x00E9); - LCD_IO_WriteData(0x0000); + #ifdef LCD_USE_DMA_FSMC + dma_init(FSMC_DMA_DEV); + dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + dma_set_priority(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, DMA_PRIORITY_MEDIUM); + #endif - LCD_IO_WriteReg(0x00F7); - LCD_IO_WriteData(0x00A9); - LCD_IO_WriteData(0x0051); - LCD_IO_WriteData(0x002C); - LCD_IO_WriteData(0x0082); + LCD_IO_Init(FSMC_CS_PIN, FSMC_RS_PIN); + + _delay_ms(5); + + DeviceCode = tftio.GetID() & 0xFFFF; + // Chitu and others + if (DeviceCode == 0x8066) DeviceCode = 0x9488; + + if (DeviceCode == 0x9488) { + LCD_IO_WriteReg(0x00E0); + LCD_IO_WriteData(0x0000); + LCD_IO_WriteData(0x0007); + LCD_IO_WriteData(0x000f); + LCD_IO_WriteData(0x000D); + LCD_IO_WriteData(0x001B); + LCD_IO_WriteData(0x000A); + LCD_IO_WriteData(0x003c); + LCD_IO_WriteData(0x0078); + LCD_IO_WriteData(0x004A); + LCD_IO_WriteData(0x0007); + LCD_IO_WriteData(0x000E); + LCD_IO_WriteData(0x0009); + LCD_IO_WriteData(0x001B); + LCD_IO_WriteData(0x001e); + LCD_IO_WriteData(0x000f); + + LCD_IO_WriteReg(0x00E1); + LCD_IO_WriteData(0x0000); + LCD_IO_WriteData(0x0022); + LCD_IO_WriteData(0x0024); + LCD_IO_WriteData(0x0006); + LCD_IO_WriteData(0x0012); + LCD_IO_WriteData(0x0007); + LCD_IO_WriteData(0x0036); + LCD_IO_WriteData(0x0047); + LCD_IO_WriteData(0x0047); + LCD_IO_WriteData(0x0006); + LCD_IO_WriteData(0x000a); + LCD_IO_WriteData(0x0007); + LCD_IO_WriteData(0x0030); + LCD_IO_WriteData(0x0037); + LCD_IO_WriteData(0x000f); + + LCD_IO_WriteReg(0x00C0); + LCD_IO_WriteData(0x0010); + LCD_IO_WriteData(0x0010); + + LCD_IO_WriteReg(0x00C1); + LCD_IO_WriteData(0x0041); + + LCD_IO_WriteReg(0x00C5); + LCD_IO_WriteData(0x0000); + LCD_IO_WriteData(0x0022); + LCD_IO_WriteData(0x0080); + + LCD_IO_WriteReg(0x0036); + LCD_IO_WriteData(TERN(GRAPHICAL_TFT_ROTATE_180, 0xE8, 0x0068)); + + LCD_IO_WriteReg(0x003A); //Interface Mode Control + LCD_IO_WriteData(0x0055); + + LCD_IO_WriteReg(0x00B0); //Interface Mode Control + LCD_IO_WriteData(0x0000); + LCD_IO_WriteReg(0x00B1); //Frame rate 70HZ + LCD_IO_WriteData(0x00B0); + LCD_IO_WriteData(0x0011); + LCD_IO_WriteReg(0x00B4); + LCD_IO_WriteData(0x0002); + LCD_IO_WriteReg(0x00B6); //RGB/MCU Interface Control + LCD_IO_WriteData(0x0002); + LCD_IO_WriteData(0x0042); + + LCD_IO_WriteReg(0x00B7); + LCD_IO_WriteData(0x00C6); + + //WriteComm(0xBE); + //WriteData(0x00); + //WriteData(0x04); + + LCD_IO_WriteReg(0x00E9); + LCD_IO_WriteData(0x0000); + + LCD_IO_WriteReg(0x00F7); + LCD_IO_WriteData(0x00A9); + LCD_IO_WriteData(0x0051); + LCD_IO_WriteData(0x002C); + LCD_IO_WriteData(0x0082); + + LCD_IO_WriteReg(0x0011); + for (i = 0; i < 65535; i++) { /* do nothing */ } + LCD_IO_WriteReg(0x0029); + + LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT); + + OUT_WRITE(LCD_BACKLIGHT_PIN, LOW); + LCD_Clear(0x0000); + + lcd_draw_logo(); + + OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH); + delay(2000); + } + } - LCD_IO_WriteReg(0x0011); - for (i = 0; i < 65535; i++); - LCD_IO_WriteReg(0x0029); + extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length); - ili9320_SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT); - LCD_Clear(0x0000); + void lcd_draw_logo() { + LCD_setWindowArea(0, 0, TFT_WIDTH, TFT_HEIGHT); + LCD_WriteRAM_Prepare(); - OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH); + for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) { + Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2); + #ifdef LCD_USE_DMA_FSMC + LCD_IO_WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH); + #else + int index = 0;,x_off = 0; + for (x_off = 0; x_off < TFT_WIDTH; x_off++) { + LCD_IO_WriteData((uint16_t)bmp_public_buf[index]); + index += 2; + } + #endif + } } -} #endif // !TFT_LVGL_UI_SPI -extern uint8_t bmp_public_buf[17 * 1024]; - void tft_lvgl_init() { //uint16_t test_id=0; @@ -404,16 +452,15 @@ void tft_lvgl_init() { SPI_TFT.spi_init(SPI_FULL_SPEED); SPI_TFT.LCD_init(); #else - init_tft(); + fsmc_tft_init(); #endif + //spi_flash_read_test(); #if ENABLED(SDSUPPORT) UpdateAssets(); #endif mks_test_get(); - //spi_flash_read_test(); - touch.Init(); lv_init(); @@ -432,6 +479,36 @@ void tft_lvgl_init() { indev_drv.read_cb = my_touchpad_read; /*Set your driver function*/ lv_indev_drv_register(&indev_drv); /*Finally register the driver*/ + #if HAS_ROTARY_ENCODER + g = lv_group_create(); + lv_indev_drv_t enc_drv; + lv_indev_drv_init(&enc_drv); + enc_drv.type = LV_INDEV_TYPE_ENCODER; + enc_drv.read_cb = my_mousewheel_read; + lv_indev_t * enc_indev = lv_indev_drv_register(&enc_drv); + lv_indev_set_group(enc_indev, g); + #endif + + lv_fs_drv_t spi_flash_drv; + lv_fs_drv_init(&spi_flash_drv); + spi_flash_drv.letter = 'F'; + spi_flash_drv.open_cb = spi_flash_open_cb; + spi_flash_drv.close_cb = spi_flash_close_cb; + spi_flash_drv.read_cb = spi_flash_read_cb; + spi_flash_drv.seek_cb = spi_flash_seek_cb; + spi_flash_drv.tell_cb = spi_flash_tell_cb; + lv_fs_drv_register(&spi_flash_drv); + + lv_fs_drv_t sd_drv; + lv_fs_drv_init(&sd_drv); + sd_drv.letter = 'S'; + sd_drv.open_cb = sd_open_cb; + sd_drv.close_cb = sd_close_cb; + sd_drv.read_cb = sd_read_cb; + sd_drv.seek_cb = sd_seek_cb; + sd_drv.tell_cb = sd_tell_cb; + lv_fs_drv_register(&sd_drv); + systick_attach_callback(SysTick_Callback); #if HAS_SPI_FLASH_FONT @@ -442,7 +519,10 @@ void tft_lvgl_init() { filament_pin_setup(); + lv_encoder_pin_init(); + #if ENABLED(POWER_LOSS_RECOVERY) + recovery.load(); if (recovery.valid()) { if (gCfgItems.from_flash_pic == 1) flash_preview_begin = 1; @@ -486,16 +566,16 @@ void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * co #if 1 uint16_t i, width, height; - uint16_t clr_temp; + //uint16_t clr_temp; width = area->x2 - area->x1 + 1; height = area->y2 - area->y1 + 1; - ili9320_SetWindows((uint16_t)area->x1, (uint16_t)area->y1, width, height); + LCD_setWindowArea((uint16_t)area->x1, (uint16_t)area->y1, width, height); LCD_WriteRAM_Prepare(); for (i = 0; i < width * height - 2; i++) { - clr_temp = (uint16_t)(((uint16_t)color_p->ch.red << 11) - | ((uint16_t)color_p->ch.green << 5) - | ((uint16_t)color_p->ch.blue)); - LCD_IO_WriteData(clr_temp); + //clr_temp = (uint16_t)(((uint16_t)color_p->ch.red << 11) + //| ((uint16_t)color_p->ch.green << 5) + //| ((uint16_t)color_p->ch.blue)); + LCD_IO_WriteData(color_p->full); color_p++; } @@ -507,8 +587,6 @@ void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * co #define TICK_CYCLE 1 -static int32_t touch_time1 = 0; - unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) { return TICK_CYCLE * (lastTick <= curTick ? (curTick - lastTick) : (0xFFFFFFFF - lastTick + curTick)); } @@ -522,15 +600,17 @@ static bool get_point(int16_t *x, int16_t *y) { } #if ENABLED(GRAPHICAL_TFT_ROTATE_180) - x = (TFT_WIDTH) - x; - y = (TFT_HEIGHT) - y; + *x = int16_t((TFT_WIDTH) - (int)(*x)); + *y = int16_t((TFT_HEIGHT) - (int)(*y)); #endif return is_touched; } -static int16_t last_x = 0, last_y = 0; bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) { + static int16_t last_x = 0, last_y = 0; + static uint8_t last_touch_state = LV_INDEV_STATE_REL; + static int32_t touch_time1 = 0; uint32_t tmpTime, diffTime = 0; tmpTime = millis(); @@ -540,9 +620,10 @@ bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) { //if (data->state == LV_INDEV_STATE_PR) ADS7843_Rd_Addata((u16 *)&last_x, (u16 *)&last_y); //touchpad_get_xy(&last_x, &last_y); /*Save the pressed coordinates and the state*/ - if (diffTime > 10) { + if (diffTime > 20) { if (get_point(&last_x, &last_y)) { + if (last_touch_state == LV_INDEV_STATE_PR) return false; data->state = LV_INDEV_STATE_PR; // Set the coordinates (if released use the last-pressed coordinates) @@ -551,9 +632,13 @@ bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) { data->point.y = last_y; last_x = last_y = 0; + last_touch_state = LV_INDEV_STATE_PR; + } + else { + if (last_touch_state == LV_INDEV_STATE_PR) + data->state = LV_INDEV_STATE_REL; + last_touch_state = LV_INDEV_STATE_REL; } - else - data->state = LV_INDEV_STATE_REL; touch_time1 = tmpTime; } @@ -561,4 +646,233 @@ bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) { return false; // Return `false` since no data is buffering or left to read } +int16_t enc_diff = 0; +lv_indev_state_t state = LV_INDEV_STATE_REL; + +bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) { + (void) indev_drv; /*Unused*/ + + data->state = state; + data->enc_diff = enc_diff; + enc_diff = 0; + + return false; /*No more data to read so return false*/ +} + +extern uint8_t currentFlashPage; + +//spi_flash +uint32_t pic_read_base_addr = 0, pic_read_addr_offset = 0; +lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) { + static char last_path_name[30]; + if (strcasecmp(last_path_name,path) != 0) { + pic_read_base_addr = lv_get_pic_addr((uint8_t *)path); + ZERO(last_path_name); + strcpy(last_path_name,path); + } + else { + W25QXX.init(SPI_QUARTER_SPEED); + currentFlashPage = 0; + } + pic_read_addr_offset = pic_read_base_addr; + return LV_FS_RES_OK; +} + +lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p) { + lv_fs_res_t res = LV_FS_RES_OK; + /* Add your code here*/ + pic_read_addr_offset = pic_read_base_addr; + return res; +} + +lv_fs_res_t spi_flash_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br) { + lv_pic_test((uint8_t *)buf, pic_read_addr_offset, btr); + *br = btr; + return LV_FS_RES_OK; +} + +lv_fs_res_t spi_flash_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos) { + #if HAS_SPI_FLASH_COMPRESSION + if (pos == 4) { + uint8_t bmp_header[4]; + SPIFlash.beginRead(pic_read_base_addr); + SPIFlash.readData(bmp_header, 4); + currentFlashPage = 1; + } + pic_read_addr_offset = pic_read_base_addr; + #else + pic_read_addr_offset = pic_read_base_addr + pos; + #endif + return LV_FS_RES_OK; +} + +lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) { + *pos_p = pic_read_addr_offset - pic_read_base_addr; + return LV_FS_RES_OK; +} + +//sd +char *cur_namefff; +uint32_t sd_read_base_addr = 0,sd_read_addr_offset = 0; +lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) { + //cur_namefff = strrchr(path, '/'); + char name_buf[100]; + ZERO(name_buf); + strcat(name_buf,"/"); + strcat(name_buf,path); + char *temp = strstr(name_buf,".bin"); + if (temp) { strcpy(temp,".GCO"); } + sd_read_base_addr = lv_open_gcode_file((char *)name_buf); + sd_read_addr_offset = sd_read_base_addr; + return LV_FS_RES_OK; +} + +lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p) { + /* Add your code here*/ + lv_close_gcode_file(); + return LV_FS_RES_OK; +} + +lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br) { + if (btr == 200) { + lv_gcode_file_read((uint8_t *)buf); + //pic_read_addr_offset += 208; + *br = 200; + } + else if (btr == 4) { + uint8_t header_pic[4] = { 0x04, 0x90, 0x81, 0x0C }; + memcpy(buf, header_pic, 4); + //pic_read_addr_offset += 4; + *br = 4; + } + return LV_FS_RES_OK; +} + +lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos) { + sd_read_addr_offset = sd_read_base_addr + (pos - 4) / 200 * 409; + lv_gcode_file_seek(sd_read_addr_offset); + return LV_FS_RES_OK; +} + +lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) { + if (sd_read_addr_offset) *pos_p = 0; + else *pos_p = (sd_read_addr_offset - sd_read_base_addr) / 409 * 200 + 4; + return LV_FS_RES_OK; +} + +void lv_encoder_pin_init() { + #if 1 // HAS_DIGITAL_BUTTONS + + #if BUTTON_EXISTS(EN1) + SET_INPUT_PULLUP(BTN_EN1); + #endif + #if BUTTON_EXISTS(EN2) + SET_INPUT_PULLUP(BTN_EN2); + #endif + #if BUTTON_EXISTS(ENC) + SET_INPUT_PULLUP(BTN_ENC); + #endif + + #if BUTTON_EXISTS(BACK) + SET_INPUT_PULLUP(BTN_BACK); + #endif + + #if BUTTON_EXISTS(UP) + SET_INPUT(BTN_UP); + #endif + #if BUTTON_EXISTS(DWN) + SET_INPUT(BTN_DWN); + #endif + #if BUTTON_EXISTS(LFT) + SET_INPUT(BTN_LFT); + #endif + #if BUTTON_EXISTS(RT) + SET_INPUT(BTN_RT); + #endif + + #endif // HAS_DIGITAL_BUTTONS +} + +#if 1 // HAS_ENCODER_ACTION + + //static const int8_t encoderDirection = 1; + //static int16_t enc_Direction; + void lv_update_encoder() { + static uint8_t buttons; + static uint32_t encoder_time1; + uint32_t tmpTime, diffTime = 0; + tmpTime = millis(); + diffTime = getTickDiff(tmpTime, encoder_time1); + if (diffTime > 50) { + + #if ANY_BUTTON(EN1, EN2, ENC, BACK) + + uint8_t newbutton = 0; + + #if BUTTON_EXISTS(EN1) + if (BUTTON_PRESSED(EN1)) newbutton |= EN_A; + #endif + #if BUTTON_EXISTS(EN2) + if (BUTTON_PRESSED(EN2)) newbutton |= EN_B; + #endif + #if BUTTON_EXISTS(ENC) + if (BUTTON_PRESSED(ENC)) newbutton |= EN_C; + #endif + #if BUTTON_EXISTS(BACK) + if (BUTTON_PRESSED(BACK)) newbutton |= EN_D; + #endif + + #else + + constexpr uint8_t newbutton = 0; + + #endif + + buttons = newbutton; + + #if HAS_ENCODER_WHEEL + static uint8_t lastEncoderBits; + + #define encrot0 0 + #define encrot1 1 + #define encrot2 2 + + // Manage encoder rotation + //#define ENCODER_SPIN(_E1, _E2) switch (lastEncoderBits) { case _E1: enc_Direction += encoderDirection; break; case _E2: enc_Direction -= encoderDirection; } + + uint8_t enc = 0; + if (buttons & EN_A) enc |= B01; + if (buttons & EN_B) enc |= B10; + if (enc != lastEncoderBits) { + switch (enc) { + case encrot1: + if (lastEncoderBits == encrot0) { + enc_diff--; + encoder_time1 = tmpTime; + } + break; + case encrot2: + if (lastEncoderBits == encrot0) { + enc_diff++; + encoder_time1 = tmpTime; + } + break; + } + lastEncoderBits = enc; + } + static uint8_t last_button_state = LV_INDEV_STATE_REL; + const uint8_t enc_c = (buttons & EN_C) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; + if (enc_c != last_button_state) { + state = enc_c ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; + + last_button_state = enc_c; + } + + #endif // HAS_ENCODER_WHEEL + + } // next_button_update_ms + } + +#endif // HAS_ENCODER_ACTION + #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h index 1b33d6e6bfb3..7e24f948fd09 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h @@ -22,25 +22,44 @@ #pragma once /** - * @file tft_lvgl_configuration.h - * @date 2020-02-21 - * */ + * @file lcd/extui/lib/mks_ui/tft_lvgl_configuration.h + * @date 2020-02-21 + */ -//#ifdef __cplusplus -//extern "C" { -//#endif +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif #include -void tft_lvgl_init(); -void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p); -bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data); +//#define GRAPHICAL_TFT_ROTATE_180 +#define USE_WIFI_FUNCTION 0 + +extern void tft_lvgl_init(); +extern void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p); +extern bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data); +extern bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); + +extern void LCD_Clear(uint16_t Color); +extern void tft_set_point(uint16_t x, uint16_t y, uint16_t point); +extern void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh); +extern void LCD_WriteRAM_Prepare(void); +extern void lcd_draw_logo(); +extern void lv_encoder_pin_init(); +extern void lv_update_encoder(); + +extern lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode); +extern lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p); +extern lv_fs_res_t spi_flash_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br); +extern lv_fs_res_t spi_flash_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos); +extern lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); -void LCD_Clear(uint16_t Color); -void tft_set_point(uint16_t x, uint16_t y, uint16_t point); -void ili9320_SetWindows(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh); -void LCD_WriteRAM_Prepare(void); +extern lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode); +extern lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p); +extern lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br); +extern lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos); +extern lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); -//#ifdef __cplusplus -//} /* extern "C" */ -//#endif +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp b/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp index 1ea47cef2dd4..e230195eabac 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp @@ -54,11 +54,8 @@ dialog_menu_def dialog_menu; language_menu_def language_menu; print_file_dialog_menu_def print_file_dialog_menu; filesys_menu_def filesys_menu; -zoffset_menu_def zoffset_menu; tool_menu_def tool_menu; MachinePara_menu_def MachinePara_menu; -MachineSettings_menu_def MachineSettings_menu; -TemperatureSettings_menu_def TemperatureSettings_menu; pause_msg_def pause_msg_menu; eeprom_def eeprom_menu; @@ -67,8 +64,8 @@ void machine_setting_disp() { if (gCfgItems.language == LANG_SIMPLE_CHINESE) { MachinePara_menu.title = MACHINE_PARA_TITLE_CN; MachinePara_menu.MachineSetting = MACHINE_TYPE_CNOFIG_CN; - MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_CN; MachinePara_menu.MotorSetting = MOTOR_CONFIG_CN; + MachinePara_menu.leveling = MACHINE_LEVELING_CONFIG_CN; MachinePara_menu.AdvanceSetting = ADVANCE_CONFIG_CN; machine_menu.default_value = DEFAULT_CN; @@ -81,7 +78,6 @@ void machine_setting_disp() { machine_menu.HomeDir = MACHINE_HOMEDIR_CN; machine_menu.EndStopType = MACHINE_ENDSTOP_TYPE_CN; machine_menu.FilamentConf = MACHINE_FILAMENT_CONFIG_CN; - machine_menu.LevelingConf = MACHINE_LEVELING_CONFIG_CN; machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_CN; machine_menu.xyz = MACHINE_TYPE_XYZ_CN; @@ -116,18 +112,18 @@ void machine_setting_disp() { machine_menu.opened = ENDSTOP_OPENED_CN; machine_menu.closed = ENDSTOP_CLOSED_CN; - machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_CN; - machine_menu.InTemperature = FILAMENT_IN_TEMPERATURE_CN; - machine_menu.InLength = FILAMENT_IN_LENGTH_CN; - machine_menu.InSpeed = FILAMENT_IN_SPEED_CN; - machine_menu.OutTemperature = FILAMENT_OUT_TEMPERATURE_CN; - machine_menu.OutLength = FILAMENT_OUT_LENGTH_CN; - machine_menu.OutSpeed = FILAMENT_OUT_SPEED_CN; + machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_CN; + machine_menu.InLength = FILAMENT_IN_LENGTH_CN; + machine_menu.InSpeed = FILAMENT_IN_SPEED_CN; + machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_CN; + machine_menu.OutLength = FILAMENT_OUT_LENGTH_CN; + machine_menu.OutSpeed = FILAMENT_OUT_SPEED_CN; - machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_CN; - machine_menu.LevelingParaConf = LEVELING_PARA_CONF_CN; - machine_menu.DeltaLevelConf = LEVELING_DELTA_CN; - machine_menu.XYZLevelconf = LEVELING_XYZ_CN; + machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_CN; + machine_menu.LevelingParaConf = LEVELING_PARA_CONF_CN; + machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_CN; + machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_CN; + machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_CN; machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_CN; machine_menu.AutoLevelEnable = AUTO_LEVELING_ENABLE_CN; @@ -177,16 +173,19 @@ void machine_setting_disp() { machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_CN; machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_CN; - machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_CN; - machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_CN; - machine_menu.AccelerationConf = ACCELERATION_CONF_CN; - machine_menu.JerkConf = JERKCONF_CN; - machine_menu.StepsConf = STEPSCONF_CN; - machine_menu.TMCcurrentConf = TMC_CURRENT_CN; - machine_menu.TMCStepModeConf = TMC_STEP_MODE_CN; - machine_menu.MotorDirConf = MOTORDIRCONF_CN; - machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_CN; - machine_menu.PausePosition = PAUSE_POSITION_CN; + machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_CN; + machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_CN; + machine_menu.AccelerationConf = ACCELERATION_CONF_CN; + machine_menu.JerkConf = JERKCONF_CN; + machine_menu.StepsConf = STEPSCONF_CN; + machine_menu.TMCcurrentConf = TMC_CURRENT_CN; + machine_menu.TMCStepModeConf = TMC_STEP_MODE_CN; + machine_menu.MotorDirConf = MOTORDIRCONF_CN; + machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_CN; + machine_menu.PausePosition = PAUSE_POSITION_CN; + machine_menu.WifiSettings = WIFI_SETTINGS_CN; + machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_CN; + machine_menu.EncoderSettings = ENCODER_SETTINGS_CN; machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_CN; machine_menu.XMaxFeedRate = X_MAXFEEDRATE_CN; @@ -268,16 +267,38 @@ void machine_setting_disp() { machine_menu.key_reset = KEY_REST_CN; machine_menu.key_confirm = KEY_CONFIRM_CN; - machine_menu.PausePosText = PAUSE_POSITION_CN; - machine_menu.xPos = PAUSE_POSITION_X_CN; - machine_menu.yPos = PAUSE_POSITION_Y_CN; - machine_menu.zPos = PAUSE_POSITION_Z_CN; + machine_menu.PausePosText = PAUSE_POSITION_CN; + machine_menu.xPos = PAUSE_POSITION_X_CN; + machine_menu.yPos = PAUSE_POSITION_Y_CN; + machine_menu.zPos = PAUSE_POSITION_Z_CN; + machine_menu.WifiConfTitle = WIFI_SETTINGS_TITLE_CN; + machine_menu.wifiMode = WIFI_SETTINGS_MODE_CN; + machine_menu.wifiName = WIFI_SETTINGS_NAME_CN; + machine_menu.wifiPassWord = WIFI_SETTINGS_PASSWORD_CN; + machine_menu.wifiCloud = WIFI_SETTINGS_CLOUD_CN; + machine_menu.wifiConfig = WIFI_SETTINGS_CONFIG_CN; + machine_menu.wifiEdit = WIFI_SETTINGS_EDIT_CN; + machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_CN; + + machine_menu.OffsetConfTitle = OFFSET_TITLE_CN; + machine_menu.Xoffset = OFFSET_X_CN; + machine_menu.Yoffset = OFFSET_Y_CN; + machine_menu.Zoffset = OFFSET_Z_CN; + + machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_CN; + machine_menu.X_Sensitivity = X_SENSITIVITY_CN; + machine_menu.Y_Sensitivity = Y_SENSITIVITY_CN; + machine_menu.Z_Sensitivity = Z_SENSITIVITY_CN; + machine_menu.Z2_Sensitivity = Z2_SENSITIVITY_CN; + + machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_CN; + machine_menu.EncoderConfText = ENCODER_CONF_TEXT_CN; } else if (gCfgItems.language == LANG_COMPLEX_CHINESE) { MachinePara_menu.title = MACHINE_PARA_TITLE_T_CN; MachinePara_menu.MachineSetting = MACHINE_TYPE_CNOFIG_T_CN; - MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_T_CN; MachinePara_menu.MotorSetting = MOTOR_CONFIG_T_CN; + MachinePara_menu.leveling = MACHINE_LEVELING_CONFIG_T_CN; MachinePara_menu.AdvanceSetting = ADVANCE_CONFIG_T_CN; machine_menu.default_value = DEFAULT_T_CN; @@ -290,7 +311,6 @@ void machine_setting_disp() { machine_menu.HomeDir = MACHINE_HOMEDIR_T_CN; machine_menu.EndStopType = MACHINE_ENDSTOP_TYPE_T_CN; machine_menu.FilamentConf = MACHINE_FILAMENT_CONFIG_T_CN; - machine_menu.LevelingConf = MACHINE_LEVELING_CONFIG_T_CN; machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_T_CN; machine_menu.xyz = MACHINE_TYPE_XYZ_T_CN; @@ -325,18 +345,18 @@ void machine_setting_disp() { machine_menu.opened = ENDSTOP_OPENED_T_CN; machine_menu.closed = ENDSTOP_CLOSED_T_CN; - machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_T_CN; - machine_menu.InTemperature = FILAMENT_IN_TEMPERATURE_T_CN; - machine_menu.InLength = FILAMENT_IN_LENGTH_T_CN; - machine_menu.InSpeed = FILAMENT_IN_SPEED_T_CN; - machine_menu.OutTemperature = FILAMENT_OUT_TEMPERATURE_T_CN; - machine_menu.OutLength = FILAMENT_OUT_LENGTH_T_CN; - machine_menu.OutSpeed = FILAMENT_OUT_SPEED_T_CN; + machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_T_CN; + machine_menu.InLength = FILAMENT_IN_LENGTH_T_CN; + machine_menu.InSpeed = FILAMENT_IN_SPEED_T_CN; + machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_T_CN; + machine_menu.OutLength = FILAMENT_OUT_LENGTH_T_CN; + machine_menu.OutSpeed = FILAMENT_OUT_SPEED_T_CN; - machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_T_CN; - machine_menu.LevelingParaConf = LEVELING_PARA_CONF_T_CN; - machine_menu.DeltaLevelConf = LEVELING_DELTA_T_CN; - machine_menu.XYZLevelconf = LEVELING_XYZ_T_CN; + machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_T_CN; + machine_menu.LevelingParaConf = LEVELING_PARA_CONF_T_CN; + machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_T_CN; + machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_T_CN; + machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_T_CN; machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_T_CN; machine_menu.AutoLevelEnable = AUTO_LEVELING_ENABLE_T_CN; @@ -386,16 +406,19 @@ void machine_setting_disp() { machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_T_CN; machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_T_CN; - machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_T_CN; - machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_T_CN; - machine_menu.AccelerationConf = ACCELERATION_CONF_T_CN; - machine_menu.JerkConf = JERKCONF_T_CN; - machine_menu.StepsConf = STEPSCONF_T_CN; - machine_menu.TMCcurrentConf = TMC_CURRENT_T_CN; - machine_menu.TMCStepModeConf = TMC_STEP_MODE_T_CN; - machine_menu.MotorDirConf = MOTORDIRCONF_T_CN; - machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_T_CN; - machine_menu.PausePosition = PAUSE_POSITION_T_CN; + machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_T_CN; + machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_T_CN; + machine_menu.AccelerationConf = ACCELERATION_CONF_T_CN; + machine_menu.JerkConf = JERKCONF_T_CN; + machine_menu.StepsConf = STEPSCONF_T_CN; + machine_menu.TMCcurrentConf = TMC_CURRENT_T_CN; + machine_menu.TMCStepModeConf = TMC_STEP_MODE_T_CN; + machine_menu.MotorDirConf = MOTORDIRCONF_T_CN; + machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_T_CN; + machine_menu.PausePosition = PAUSE_POSITION_T_CN; + machine_menu.WifiSettings = WIFI_SETTINGS_T_CN; + machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_T_CN; + machine_menu.EncoderSettings = ENCODER_SETTINGS_T_CN; machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_T_CN; machine_menu.XMaxFeedRate = X_MAXFEEDRATE_T_CN; @@ -484,12 +507,34 @@ void machine_setting_disp() { machine_menu.yPos = PAUSE_POSITION_Y_T_CN; machine_menu.zPos = PAUSE_POSITION_Z_T_CN; + machine_menu.WifiConfTitle = WIFI_SETTINGS_TITLE_T_CN; + machine_menu.wifiMode = WIFI_SETTINGS_MODE_T_CN; + machine_menu.wifiName = WIFI_SETTINGS_NAME_T_CN; + machine_menu.wifiPassWord = WIFI_SETTINGS_PASSWORD_T_CN; + machine_menu.wifiCloud = WIFI_SETTINGS_CLOUD_T_CN; + machine_menu.wifiConfig = WIFI_SETTINGS_CONFIG_T_CN; + machine_menu.wifiEdit = WIFI_SETTINGS_EDIT_T_CN; + machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_T_CN; + + machine_menu.OffsetConfTitle = OFFSET_TITLE_T_CN; + machine_menu.Xoffset = OFFSET_X_T_CN; + machine_menu.Yoffset = OFFSET_Y_T_CN; + machine_menu.Zoffset = OFFSET_Z_T_CN; + + machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_T_CN; + machine_menu.X_Sensitivity = X_SENSITIVITY_T_CN; + machine_menu.Y_Sensitivity = Y_SENSITIVITY_T_CN; + machine_menu.Z_Sensitivity = Z_SENSITIVITY_T_CN; + machine_menu.Z2_Sensitivity = Z2_SENSITIVITY_T_CN; + + machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_T_CN; + machine_menu.EncoderConfText = ENCODER_CONF_TEXT_T_CN; } else { MachinePara_menu.title = MACHINE_PARA_TITLE_EN; MachinePara_menu.MachineSetting = MACHINE_TYPE_CNOFIG_EN; - MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_EN; MachinePara_menu.MotorSetting = MOTOR_CONFIG_EN; + MachinePara_menu.leveling = MACHINE_LEVELING_CONFIG_EN; MachinePara_menu.AdvanceSetting = ADVANCE_CONFIG_EN; machine_menu.default_value = DEFAULT_EN; @@ -502,7 +547,6 @@ void machine_setting_disp() { machine_menu.HomeDir = MACHINE_HOMEDIR_EN; machine_menu.EndStopType = MACHINE_ENDSTOP_TYPE_EN; machine_menu.FilamentConf = MACHINE_FILAMENT_CONFIG_EN; - machine_menu.LevelingConf = MACHINE_LEVELING_CONFIG_EN; machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_EN; machine_menu.xyz = MACHINE_TYPE_XYZ_EN; @@ -537,18 +581,18 @@ void machine_setting_disp() { machine_menu.opened = ENDSTOP_OPENED_EN; machine_menu.closed = ENDSTOP_CLOSED_EN; - machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_EN; - machine_menu.InTemperature = FILAMENT_IN_TEMPERATURE_EN; - machine_menu.InLength = FILAMENT_IN_LENGTH_EN; - machine_menu.InSpeed = FILAMENT_IN_SPEED_EN; - machine_menu.OutTemperature = FILAMENT_OUT_TEMPERATURE_EN; - machine_menu.OutLength = FILAMENT_OUT_LENGTH_EN; - machine_menu.OutSpeed = FILAMENT_OUT_SPEED_EN; + machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_EN; + machine_menu.InLength = FILAMENT_IN_LENGTH_EN; + machine_menu.InSpeed = FILAMENT_IN_SPEED_EN; + machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_EN; + machine_menu.OutLength = FILAMENT_OUT_LENGTH_EN; + machine_menu.OutSpeed = FILAMENT_OUT_SPEED_EN; - machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_EN; - machine_menu.LevelingParaConf = LEVELING_PARA_CONF_EN; - machine_menu.DeltaLevelConf = LEVELING_DELTA_EN; - machine_menu.XYZLevelconf = LEVELING_XYZ_EN; + machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_EN; + machine_menu.LevelingParaConf = LEVELING_PARA_CONF_EN; + machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_EN; + machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_EN; + machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_EN; machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_EN; machine_menu.AutoLevelEnable = AUTO_LEVELING_ENABLE_EN; @@ -598,16 +642,19 @@ void machine_setting_disp() { machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_EN; machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_EN; - machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_EN; - machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_EN; - machine_menu.AccelerationConf = ACCELERATION_CONF_EN; - machine_menu.JerkConf = JERKCONF_EN; - machine_menu.StepsConf = STEPSCONF_EN; - machine_menu.TMCcurrentConf = TMC_CURRENT_EN; - machine_menu.TMCStepModeConf = TMC_STEP_MODE_EN; - machine_menu.MotorDirConf = MOTORDIRCONF_EN; - machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_EN; - machine_menu.PausePosition = PAUSE_POSITION_EN; + machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_EN; + machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_EN; + machine_menu.AccelerationConf = ACCELERATION_CONF_EN; + machine_menu.JerkConf = JERKCONF_EN; + machine_menu.StepsConf = STEPSCONF_EN; + machine_menu.TMCcurrentConf = TMC_CURRENT_EN; + machine_menu.TMCStepModeConf = TMC_STEP_MODE_EN; + machine_menu.MotorDirConf = MOTORDIRCONF_EN; + machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_EN; + machine_menu.PausePosition = PAUSE_POSITION_EN; + machine_menu.WifiSettings = WIFI_SETTINGS_EN; + machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_EN; + machine_menu.EncoderSettings = ENCODER_SETTINGS_EN; machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_EN; machine_menu.XMaxFeedRate = X_MAXFEEDRATE_EN; @@ -692,10 +739,32 @@ void machine_setting_disp() { machine_menu.high_level = MOTOR_EN_HIGH_LEVEL_EN; machine_menu.low_level = MOTOR_EN_LOW_LEVEL_EN; - machine_menu.PausePosText = PAUSE_POSITION_EN; - machine_menu.xPos = PAUSE_POSITION_X_EN; - machine_menu.yPos = PAUSE_POSITION_Y_EN; - machine_menu.zPos = PAUSE_POSITION_Z_EN; + machine_menu.PausePosText = PAUSE_POSITION_EN; + machine_menu.xPos = PAUSE_POSITION_X_EN; + machine_menu.yPos = PAUSE_POSITION_Y_EN; + machine_menu.zPos = PAUSE_POSITION_Z_EN; + machine_menu.WifiConfTitle = WIFI_SETTINGS_TITLE_EN; + machine_menu.wifiMode = WIFI_SETTINGS_MODE_EN; + machine_menu.wifiName = WIFI_SETTINGS_NAME_EN; + machine_menu.wifiPassWord = WIFI_SETTINGS_PASSWORD_EN; + machine_menu.wifiCloud = WIFI_SETTINGS_CLOUD_EN; + machine_menu.wifiConfig = WIFI_SETTINGS_CONFIG_EN; + machine_menu.wifiEdit = WIFI_SETTINGS_EDIT_EN; + machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_EN; + + machine_menu.OffsetConfTitle = OFFSET_TITLE_EN; + machine_menu.Xoffset = OFFSET_X_EN; + machine_menu.Yoffset = OFFSET_Y_EN; + machine_menu.Zoffset = OFFSET_Z_EN; + + machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_EN; + machine_menu.X_Sensitivity = X_SENSITIVITY_EN; + machine_menu.Y_Sensitivity = Y_SENSITIVITY_EN; + machine_menu.Z_Sensitivity = Z_SENSITIVITY_EN; + machine_menu.Z2_Sensitivity = Z2_SENSITIVITY_EN; + + machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_EN; + machine_menu.EncoderConfText = ENCODER_CONF_TEXT_EN; } } @@ -771,10 +840,6 @@ void disp_language_init() { filament_menu.stat_temp = TEXT_VALUE; - zoffset_menu.step001 = ZOFFSET_STEP001; - zoffset_menu.step01 = ZOFFSET_STEP01; - zoffset_menu.step1 = ZOFFSET_STEP1; - machine_menu.key_0 = KEYBOARD_KEY0_EN; machine_menu.key_1 = KEYBOARD_KEY1_EN; machine_menu.key_2 = KEYBOARD_KEY2_EN; @@ -788,22 +853,15 @@ void disp_language_init() { machine_menu.key_point = KEYBOARD_KEY_POINT_EN; machine_menu.negative = KEYBOARD_KEY_NEGATIVE_EN; // wifi-list - #if 0 - list_menu.title = TEXT_WIFI_MENU_TITLE_EN; - list_menu.file_pages = FILE_PAGES_EN; - // keyboard - keyboard_menu.apply = MANUAL_IP_APPLY_EN; - keyboard_menu.password = TEXT_WIFI_PASSWORD_EN; - keyboard_menu.space = TEXT_WIFI_SAPCE_EN; - keyboard_menu.letter = TEXT_WIFI_LETTER_EN; - keyboard_menu.digital = TEXT_WIFI_DIGITAL_EN; - keyboard_menu.symbol = TEXT_WIFI_SYMBOL_EN; + #if ENABLED(USE_WIFI_FUNCTION) + list_menu.title = TEXT_WIFI_MENU_TITLE_EN; + list_menu.file_pages = FILE_PAGES_EN; + // tips - tips_menu.pointBold = TEXT_WIFI_POINT_BOLD_EN; tips_menu.joining = TEXT_WIFI_JOINING_EN; tips_menu.failedJoin = TEXT_WIFI_FAILED_JOIN_EN; tips_menu.wifiConected = TEXT_WIFI_WIFI_CONECTED_EN; - #endif + #endif //USE_WIFI_FUNCTION machine_setting_disp(); operation_menu.babystep = TEXT_BABY_STEP_EN; @@ -904,7 +962,6 @@ void disp_language_init() { filesys_menu.usb_sys = U_DISK_TEXT_CN; // more_menu.title = TITLE_MORE_CN; - more_menu.zoffset = ZOFFSET_CN; // WIFI wifi_menu.title = WIFI_TEXT; // wifi_menu.key = WIFI_KEY_TEXT_CN; @@ -1016,11 +1073,6 @@ void disp_language_init() { print_file_dialog_menu.reprint = DIALOG_REPRINT_CN; print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_CN; - // ZOFFSET - zoffset_menu.title = TITLE_ZOFFSET_CN; - zoffset_menu.inc = ZOFFSET_INC_CN; - zoffset_menu.dec = ZOFFSET_DEC_CN; - pause_msg_menu.pausing = MESSAGE_PAUSING_CN; pause_msg_menu.changing = MESSAGE_CHANGING_CN; pause_msg_menu.unload = MESSAGE_UNLOAD_CN; @@ -1092,7 +1144,6 @@ void disp_language_init() { preheat_menu.step_10c = TEXT_10C_T_CN; // move_menu.title = MOVE_TEXT_T_CN; - more_menu.zoffset = ZOFFSET_T_CN; // home_menu.title = TITLE_HOME_T_CN; home_menu.stopmove = HOME_STOPMOVE_T_CN; @@ -1249,10 +1300,6 @@ void disp_language_init() { print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_T_CN; print_file_dialog_menu.reprint = DIALOG_REPRINT_T_CN; print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_T_CN; - // ZOFFSET - zoffset_menu.title = TITLE_ZOFFSET_T_CN; - zoffset_menu.inc = ZOFFSET_INC_T_CN; - zoffset_menu.dec = ZOFFSET_DEC_T_CN; pause_msg_menu.pausing = MESSAGE_PAUSING_T_CN; pause_msg_menu.changing = MESSAGE_CHANGING_T_CN; @@ -1359,7 +1406,6 @@ void disp_language_init() { set_menu.machine_para = MACHINE_PARA_EN; set_menu.eepromSet = EEPROM_SETTINGS_EN; more_menu.title = TITLE_MORE_EN; - more_menu.zoffset = ZOFFSET_EN; // filesys_menu.title = TITLE_FILESYS_EN; filesys_menu.sd_sys = SD_CARD_TEXT_EN; @@ -1469,10 +1515,6 @@ void disp_language_init() { print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_EN; print_file_dialog_menu.reprint = DIALOG_REPRINT_EN; print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_EN; - // ZOFFSET - zoffset_menu.title = TITLE_ZOFFSET_EN; - zoffset_menu.inc = ZOFFSET_INC_EN; - zoffset_menu.dec = ZOFFSET_DEC_EN; pause_msg_menu.pausing = MESSAGE_PAUSING_EN; pause_msg_menu.changing = MESSAGE_CHANGING_EN; @@ -1579,7 +1621,6 @@ void disp_language_init() { set_menu.machine_para = MACHINE_PARA_RU; set_menu.eepromSet = EEPROM_SETTINGS_RU; more_menu.title = TITLE_MORE_RU; - more_menu.zoffset = ZOFFSET_RU; // filesys_menu.title = TITLE_FILESYS_RU; filesys_menu.sd_sys = SD_CARD_TEXT_RU; @@ -1689,10 +1730,6 @@ void disp_language_init() { print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_RU; print_file_dialog_menu.reprint = DIALOG_REPRINT_RU; print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_RU; - // ZOFFSET - zoffset_menu.title = TITLE_ZOFFSET_RU; - zoffset_menu.inc = ZOFFSET_INC_RU; - zoffset_menu.dec = ZOFFSET_DEC_RU; pause_msg_menu.pausing = MESSAGE_PAUSING_RU; pause_msg_menu.changing = MESSAGE_CHANGING_RU; @@ -1803,7 +1840,6 @@ void disp_language_init() { set_menu.machine_para = MACHINE_PARA_SP; set_menu.eepromSet = EEPROM_SETTINGS_SP; more_menu.title = TITLE_MORE_SP; - more_menu.zoffset = ZOFFSET_SP; // filesys_menu.title = TITLE_FILESYS_SP; filesys_menu.sd_sys = SD_CARD_TEXT_SP; @@ -1914,10 +1950,6 @@ void disp_language_init() { print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_SP; print_file_dialog_menu.reprint = DIALOG_REPRINT_SP; print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_SP; - // ZOFFSET - zoffset_menu.title = TITLE_ZOFFSET_SP; - zoffset_menu.inc = ZOFFSET_INC_SP; - zoffset_menu.dec = ZOFFSET_DEC_SP; pause_msg_menu.pausing = MESSAGE_PAUSING_SP; pause_msg_menu.changing = MESSAGE_CHANGING_SP; @@ -2025,7 +2057,6 @@ void disp_language_init() { set_menu.machine_para = MACHINE_PARA_FR; set_menu.eepromSet = EEPROM_SETTINGS_FR; more_menu.title = TITLE_MORE_FR; - more_menu.zoffset = ZOFFSET_FR; // filesys_menu.title = TITLE_FILESYS_FR; filesys_menu.sd_sys = SD_CARD_TEXT_FR; @@ -2137,10 +2168,6 @@ void disp_language_init() { print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_FR; print_file_dialog_menu.reprint = DIALOG_REPRINT_FR; print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_FR; - // ZOFFSET - zoffset_menu.title = TITLE_ZOFFSET_FR; - zoffset_menu.inc = ZOFFSET_INC_FR; - zoffset_menu.dec = ZOFFSET_DEC_FR; pause_msg_menu.pausing = MESSAGE_PAUSING_FR; pause_msg_menu.changing = MESSAGE_CHANGING_FR; @@ -2249,7 +2276,6 @@ void disp_language_init() { set_menu.machine_para = MACHINE_PARA_IT; set_menu.eepromSet = EEPROM_SETTINGS_IT; more_menu.title = TITLE_MORE_IT; - more_menu.zoffset = ZOFFSET_IT; // filesys_menu.title = TITLE_FILESYS_IT; filesys_menu.sd_sys = SD_CARD_TEXT_IT; @@ -2358,10 +2384,6 @@ void disp_language_init() { print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_IT; print_file_dialog_menu.reprint = DIALOG_REPRINT_IT; print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_IT; - // ZOFFSET - zoffset_menu.title = TITLE_ZOFFSET_IT; - zoffset_menu.inc = ZOFFSET_INC_IT; - zoffset_menu.dec = ZOFFSET_DEC_IT; pause_msg_menu.pausing = MESSAGE_PAUSING_IT; pause_msg_menu.changing = MESSAGE_CHANGING_IT; @@ -2472,7 +2494,6 @@ void disp_language_init() { set_menu.eepromSet = EEPROM_SETTINGS_EN; // more_menu.title = TITLE_MORE_EN; - more_menu.zoffset = ZOFFSET_EN; // filesys_menu.title = TITLE_FILESYS_EN; filesys_menu.sd_sys = SD_CARD_TEXT_EN; @@ -2582,10 +2603,6 @@ void disp_language_init() { print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_EN; print_file_dialog_menu.reprint = DIALOG_REPRINT_EN; print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_EN; - // ZOFFSET - zoffset_menu.title = TITLE_ZOFFSET_EN; - zoffset_menu.inc = ZOFFSET_INC_EN; - zoffset_menu.dec = ZOFFSET_DEC_EN; pause_msg_menu.pausing = MESSAGE_PAUSING_EN; pause_msg_menu.changing = MESSAGE_CHANGING_EN; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h index 585100935688..675fd41f168e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h @@ -60,7 +60,6 @@ typedef struct machine_common_disp{ const char *HomeDir; const char *EndStopType; const char *FilamentConf; - const char *LevelingConf; const char *MachineTypeConfTitle; const char *xyz; @@ -96,17 +95,17 @@ typedef struct machine_common_disp{ const char *closed; const char *FilamentConfTitle; - const char *InTemperature; const char *InLength; const char *InSpeed; - const char *OutTemperature; + const char *FilamentTemperature; const char *OutLength; const char *OutSpeed; const char *LevelingParaConfTitle; const char *LevelingParaConf; - const char *DeltaLevelConf; - const char *XYZLevelconf; + const char *LevelingManuPosConf; + const char *LevelingAutoCommandConf; + const char *LevelingAutoZoffsetConf; const char *LevelingSubConfTitle; const char *AutoLevelEnable; @@ -165,6 +164,7 @@ typedef struct machine_common_disp{ const char *HomeFeedRateConf; const char *TMCcurrentConf; const char *TMCStepModeConf; + const char *HomingSensitivityConf; const char *MaxFeedRateConfTitle; const char *XMaxFeedRate; @@ -210,6 +210,12 @@ typedef struct machine_common_disp{ const char *E0_StepMode; const char *E1_StepMode; + const char *HomingSensitivityConfTitle; + const char *X_Sensitivity; + const char *Y_Sensitivity; + const char *Z_Sensitivity; + const char *Z2_Sensitivity; + const char *MotorDirConfTitle; const char *X_MotorDir; const char *Y_MotorDir; @@ -231,6 +237,8 @@ typedef struct machine_common_disp{ const char *Z2andZ2Endstop; const char *EnablePinsInvert; const char *PausePosition; + const char *WifiSettings; + const char *EncoderSettings; const char *Z2ConfTitle; const char *Z2Enable; @@ -266,6 +274,23 @@ typedef struct machine_common_disp{ const char *yPos; const char *zPos; + const char *WifiConfTitle; + const char *wifiMode; + const char *wifiName; + const char *wifiPassWord; + const char *wifiCloud; + const char *wifiConfig; + const char *wifiEdit; + const char *wifiConfigTips; + + const char *OffsetConfTitle; + const char *Xoffset; + const char *Yoffset; + const char *Zoffset; + + const char *EncoderConfTitle; + const char *EncoderConfText; + } machine_common_def; extern machine_common_def machine_menu; @@ -435,7 +460,6 @@ extern filesys_menu_def filesys_menu; typedef struct more_menu_disp { const char *title; - const char *zoffset; const char *back; } more_menu_def; @@ -661,18 +685,6 @@ typedef struct print_file_dialog_disp { extern print_file_dialog_menu_def print_file_dialog_menu; -typedef struct zoffset_menu_disp { - const char *title; - const char *inc; - const char *dec; - const char *step001; - const char *step01; - const char *step1; - const char *back; -} zoffset_menu_def; - -extern zoffset_menu_def zoffset_menu; - typedef struct tool_menu_disp { const char *title; const char *preheat; @@ -691,37 +703,13 @@ extern tool_menu_def tool_menu; typedef struct MachinePara_menu_disp { const char *title; const char *MachineSetting; - const char *TemperatureSetting; const char *MotorSetting; + const char *leveling; const char *AdvanceSetting; - //const char *back; } MachinePara_menu_def; extern MachinePara_menu_def MachinePara_menu; -typedef struct MachineSettings_menu_disp { - const char *title; - const char *Machine; - const char *Stroke; - const char *HomeDir; - const char *EndStopType; - const char *filamet; - const char *leveling; - const char *back; -} MachineSettings_menu_def; - -extern MachineSettings_menu_def MachineSettings_menu; - -typedef struct TemperatureSettings_menu_disp { - const char *title; - const char *nozzle; - const char *hotbed; - const char *preheat; - const char *back; -} TemperatureSettings_menu_def; - -extern TemperatureSettings_menu_def TemperatureSettings_menu; - typedef struct pause_msg_disp { const char *pausing; const char *changing; @@ -842,6 +830,7 @@ extern eeprom_def eeprom_menu; #define DIALOG_UPLOAD_SPEED_EN "Speed" #define DIALOG_UPDATE_WIFI_FIRMWARE_EN "Updating wifi model firmware" #define DIALOG_UPDATE_WIFI_WEB_EN "Updating wifi model web data" +#define DIALOG_UPDATE_NO_DEVICE_EN "please check \nwether memory device insert!" #define ZOFFSET_STEP001 "0.01mm" #define ZOFFSET_STEP01 "0.1mm" diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp new file mode 100644 index 000000000000..01c86ad7cb47 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp @@ -0,0 +1,120 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "draw_ui.h" +#include "wifiSerial.h" + +#if ENABLED(USE_WIFI_FUNCTION) + +#include +#include +#include +#include +#include + +#include "../../../../MarlinCore.h" + +DEFINE_WFSERIAL(WifiSerial1, 1); + +WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) { + this->usart_device = usart_device; + this->tx_pin = tx_pin; + this->rx_pin = rx_pin; +} + +/** + * Set up / tear down + */ +#if STM32_MCU_SERIES == STM32_SERIES_F1 + /* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict + * on this GPIO bit. */ + static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) { + if (dev != nullptr) timer_set_mode(dev, ch, TIMER_DISABLED); + } +#elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4 + #define disable_timer_if_necessary(dev, ch) ((void)0) +#else + #warning "Unsupported STM32 series; timer conflicts are possible" +#endif + +void WifiSerial::begin(uint32 baud) { begin(baud, SERIAL_8N1); } + +/** + * Roger Clark. + * Note. The config parameter is not currently used. This is a work in progress. + * Code needs to be written to set the config of the hardware serial control register in question. + */ + +void WifiSerial::begin(uint32 baud, uint8_t config) { + //ASSERT(baud <= this->usart_device->max_baud); // Roger Clark. Assert doesn't do anything useful, we may as well save the space in flash and ram etc + + if (baud > this->usart_device->max_baud) return; + + const stm32_pin_info *txi = &PIN_MAP[this->tx_pin], + *rxi = &PIN_MAP[this->rx_pin]; + + disable_timer_if_necessary(txi->timer_device, txi->timer_channel); + + usart_init(this->usart_device); + + // Reinitialize the receive buffer, mks_esp8266 fixed data frame length is 1k bytes + rb_init(this->usart_device->rb, WIFI_RX_BUF_SIZE, wifiRxBuf); + + usart_config_gpios_async(this->usart_device, + rxi->gpio_device, rxi->gpio_bit, + txi->gpio_device, txi->gpio_bit, + config); + usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud); + usart_enable(this->usart_device); +} + +void WifiSerial::end(void) { + usart_disable(this->usart_device); +} + +int WifiSerial::available(void) { + return usart_data_available(this->usart_device); +} + +// +// I/O +// + +int WifiSerial::read(void) { + if (usart_data_available(usart_device) <= 0) return -1; + return usart_getc(usart_device); +} + +int WifiSerial::write(unsigned char ch) { + usart_putc(this->usart_device, ch); + return 1; +} + +int WifiSerial::wifi_rb_is_full(void) { + return rb_is_full(this->usart_device->rb); +} + +#endif // USE_WIFI_FUNCTION +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h new file mode 100644 index 000000000000..9d3946fee79b --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h @@ -0,0 +1,102 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#include "tft_lvgl_configuration.h" + +#if ENABLED(USE_WIFI_FUNCTION) + +#if SERIAL_PORT_2 != -1 + #error "SERIAL_PORT_2 must be set to -1 with HAS_TFT_LVGL_UI and USE_WIFI_FUNCTION." +#endif + +#define WIFI_BAUDRATE 115200 +#define WIFI_UPLOAD_BAUDRATE 1958400 +#define USART_SAFE_INSERT + +#define WIFI_RX_BUF_SIZE (1024+1) + +#include +#include +#include +#include +#include +#include + +#define DEFINE_WFSERIAL(name, n)\ + WifiSerial name(USART##n, \ + BOARD_USART##n##_TX_PIN, \ + BOARD_USART##n##_RX_PIN) + +class WifiSerial { + public: + uint8 wifiRxBuf[WIFI_RX_BUF_SIZE]; + + public: + WifiSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin); + + /* Set up/tear down */ + void begin(uint32 baud); + void begin(uint32 baud,uint8_t config); + void end(); + int available(void); + int read(void); + int write(uint8_t); + inline void wifi_usart_irq(usart_reg_map *regs) { + /* Handling RXNEIE and TXEIE interrupts. + * RXNE signifies availability of a byte in DR. + * + * See table 198 (sec 27.4, p809) in STM document RM0008 rev 15. + * We enable RXNEIE. + */ + if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) { + #ifdef USART_SAFE_INSERT + /* If the buffer is full and the user defines USART_SAFE_INSERT, + * ignore new bytes. */ + rb_safe_insert(this->usart_device->rb, (uint8)regs->DR); + #else + /* By default, push bytes around in the ring buffer. */ + rb_push_insert(this->usart_device->rb, (uint8)regs->DR); + #endif + } + /* TXE signifies readiness to send a byte to DR. */ + if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) { + if (!rb_is_empty(this->usart_device->wb)) + regs->DR=rb_remove(this->usart_device->wb); + else + regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE + } + } + + int wifi_rb_is_full(void); + + private: + struct usart_dev *usart_device; + uint8 tx_pin; + uint8 rx_pin; +}; + +extern WifiSerial WifiSerial1; + +#define WIFISERIAL WifiSerial1 + +#endif // USE_WIFI_FUNCTION diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp new file mode 100644 index 000000000000..5c025f13f986 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -0,0 +1,1927 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "draw_ui.h" +#include "wifi_module.h" +#include "wifi_upload.h" + +#if ENABLED(USE_WIFI_FUNCTION) + +#include "../../../../MarlinCore.h" +#include "../../../../module/temperature.h" +#include "../../../../gcode/queue.h" +#include "../../../../gcode/gcode.h" +#include "../../../../lcd/ultralcd.h" +#include "../../../../sd/cardreader.h" +#include "../../../../module/planner.h" +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../../../feature/powerloss.h" +#endif +#if ENABLED(PARK_HEAD_ON_PAUSE) + #include "../../../../feature/pause.h" +#endif + +#define WIFI_SET() WRITE(WIFI_RESET_PIN, HIGH); +#define WIFI_RESET() WRITE(WIFI_RESET_PIN, LOW); +#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH); +#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); + +extern uint8_t Explore_Disk (char* path , uint8_t recu_level); + +extern uint8_t commands_in_queue; +extern uint8_t sel_id; + +int usartFifoAvailable(SZ_USART_FIFO *fifo); +int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len); +int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len); +extern unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick); + +volatile SZ_USART_FIFO WifiRxFifo; + +#define WAIT_ESP_TRANS_TIMEOUT_TICK 10500 + +int cfg_cloud_flag = 0; + +extern PRINT_TIME print_time; + +char wifi_firm_ver[20] = {0}; +WIFI_GCODE_BUFFER espGcodeFifo; +extern uint8_t pause_resum; + +uint8_t wifi_connect_flg = 0; +extern volatile uint8_t get_temp_flag; + + +#define WIFI_MODE 2 +#define WIFI_AP_MODE 3 + +int upload_result = 0; + +uint32_t upload_time = 0; +uint32_t upload_size = 0; + +volatile WIFI_STATE wifi_link_state; +WIFI_PARA wifiPara; +IP_PARA ipPara; +CLOUD_PARA cloud_para; + +char wifi_check_time = 0; + +extern uint8_t gCurDir[100]; + +extern uint32_t wifi_loop_cycle; + +volatile TRANSFER_STATE esp_state; + +uint8_t left_to_send = 0; +uint8_t left_to_save[96] = {0}; + +volatile WIFI_DMA_RCV_FIFO wifiDmaRcvFifo; + +volatile WIFI_TRANS_ERROR wifiTransError; + +static bool need_ok_later = false; + +extern volatile WIFI_STATE wifi_link_state; +extern WIFI_PARA wifiPara; +extern IP_PARA ipPara; +extern CLOUD_PARA cloud_para; + +extern uint8_t once_flag; +extern uint8_t flash_preview_begin; +extern uint8_t default_preview_flg; +extern uint8_t gcode_preview_over; + +extern uint8_t bmp_public_buf[17 * 1024]; + +uint32_t getWifiTick() { + return millis(); +} + +uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) { + if (lastTick <= curTick) { + return (curTick - lastTick) * TICK_CYCLE; + } + else { + return (0xffffffff - lastTick + curTick) * TICK_CYCLE; + } +} + +void wifi_delay(int n) { + uint32_t begin = getWifiTick(); + uint32_t end = begin; + + while (getWifiTickDiff(begin, end) < (uint32_t)n) { + end = getWifiTick(); + } +} + +void wifi_reset() { + uint32_t start, now; + start = getWifiTick(); + now = start; + WIFI_RESET(); + while (getWifiTickDiff(start, now) < 500) { + now = getWifiTick(); + } + WIFI_SET(); + +} + +void mount_file_sys(uint8_t disk_type) { + if (disk_type == FILE_SYS_SD) { + card.mount(); + } + else if (disk_type == FILE_SYS_USB) { + + } +} + +static void dma_init() { + #if 0 + __HAL_RCC_DMA1_CLK_ENABLE(); + + //HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); + HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 4, 0); + HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn); + + hdma_usart1_rx.Instance = DMA1_Channel5; + //hdma_usart1_rx.Init.Channel = DMA_CHANNEL_4; + hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE; + hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_usart1_rx.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_usart1_rx.Init.Mode = DMA_NORMAL; + hdma_usart1_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH; + if (HAL_DMA_Init((DMA_HandleTypeDef *)&hdma_usart1_rx) != HAL_OK) { + Error_Handler(); + } + + + HAL_DMA_Start_IT((DMA_HandleTypeDef *)&hdma_usart1_rx, + (uint32_t)&huart1.Instance->DR, + (uint32_t)(&WifiRxFifo.uartTxBuffer[0]), + UART_RX_BUFFER_SIZE); + + //HAL_UART_Receive_DMA(&huart1,(uint8_t*)&WifiRxFifo.uartTxBuffer[0], UART_RX_BUFFER_SIZE); + + /* Enable the DMA transfer for the receiver request by setting the DMAR bit + in the UART CR3 register */ + SET_BIT(huart1.Instance->CR3, USART_CR3_DMAR); + + #endif + for (uint8_t i = 0; i < TRANS_RCV_FIFO_BLOCK_NUM; i++) { + wifiDmaRcvFifo.bufferAddr[i] = &bmp_public_buf[1024 * i]; + wifiDmaRcvFifo.state[i] = udisk_buf_empty; + } + + memset(wifiDmaRcvFifo.bufferAddr[0], 0, 1024 * TRANS_RCV_FIFO_BLOCK_NUM); + wifiDmaRcvFifo.read_cur = 0; + wifiDmaRcvFifo.write_cur = 0; + +} + +static void wifi_deInit() { + #if 0 + HAL_DMA_Abort((DMA_HandleTypeDef *)&hdma_usart1_rx); + HAL_DMA_DeInit((DMA_HandleTypeDef *)&hdma_usart1_rx); + __HAL_DMA_DISABLE((DMA_HandleTypeDef *)&hdma_usart1_rx); + #endif +} + +extern uint8_t mksUsart1Rx; + +void esp_port_begin(uint8_t interrupt) { + WifiRxFifo.uart_read_point = 0; + WifiRxFifo.uart_write_point = 0; + #if 0 + NVIC_InitTypeDef NVIC_InitStructure; + + USART_InitTypeDef USART_InitStructure; + GPIO_InitTypeDef GPIO_InitStruct; + + WifiRxFifo.uart_read_point = 0; + WifiRxFifo.uart_write_point = 0; + memset((uint8_t*)WifiRxFifo.uartTxBuffer, 0, sizeof(WifiRxFifo.uartTxBuffer)); + + if (interrupt) { + #if TAN + wifi_deInit (); + + //SZ_STM32_COMInit(COM1, 115200); + __HAL_UART_ENABLE_IT(USART1, USART_IT_RXNE); + + USART_InitStructure.USART_BaudRate = 115200; //���ڵIJ����ʣ�����115200 ��ߴ�4.5Mbits/s + USART_InitStructure.USART_WordLength = USART_WordLength_8b; //�����ֳ���(8λ��9λ) + USART_InitStructure.USART_StopBits = USART_StopBits_1; //�����õ�ֹͣλ-֧��1��2��ֹͣλ + USART_InitStructure.USART_Parity = USART_Parity_No; //����żУ�� + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //��Ӳ�������� + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //˫��ģʽ��ʹ�ܷ��ͺͽ��� + + __HAL_RCC_USART1_CLK_ENABLE(); + + GPIO_InitStruct.Pin = TFT_WIFI_TX_Pin|TFT_WIFI_RX_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF7_USART1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pin = TFT_WIFI_RX_Pin; + HAL_GPIO_Init(GPIOA,&GPIO_InitStruct); + + USART_Init(USART1, &USART_InitStructure); + + NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; + // NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + // NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + + NVIC_Init(&NVIC_InitStructure); + #else + HAL_UART_DeInit(&huart1); + MX_USART1_UART_Init(3); + //__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE); + HAL_UART_Receive_IT(&huart1,&mksUsart1Rx,1); + #endif + } + else{ + #if 0 + NVIC_DisableIRQ(SZ_STM32_COM1_IRQn); + + USART_Cmd(SZ_STM32_COM1, DISABLE); + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, DISABLE); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); + + SZ_STM32_COMInit(COM1, 1958400); + + USART_Cmd(SZ_STM32_COM1, ENABLE); + + wifi_delay(10); + + dma_init(); + #endif + HAL_UART_DeInit(&huart1); + MX_USART1_UART_Init(5); + //dma1_5_IRQ_sel = 1; + dma_init(); + } + #endif + if (interrupt) { + #if ENABLED(USE_WIFI_FUNCTION) + WIFISERIAL.end(); + for (uint16_t i = 0; i < 65535; i++); + WIFISERIAL.begin(WIFI_BAUDRATE); + uint32_t serial_connect_timeout = millis() + 1000UL; + while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + //for(uint8_t i=0;i<100;i++)WIFISERIAL.write(0x33); + #endif + } + else { + #if ENABLED(USE_WIFI_FUNCTION) + WIFISERIAL.end(); + for (uint16_t i = 0; i < 65535; i++); + WIFISERIAL.begin(WIFI_UPLOAD_BAUDRATE); + uint32_t serial_connect_timeout = millis() + 1000UL; + while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + //for(uint16_t i=0;i<65535;i++);//WIFISERIAL.write(0x33); + #endif + dma_init(); + } +} + +#if ENABLED(USE_WIFI_FUNCTION) + +int raw_send_to_wifi(char *buf, int len) { + if (buf == 0 || len <= 0) return 0; + + for (int i = 0; i < len; i++) + WIFISERIAL.write(*(buf + i)); + + return len; +} + +#endif // USE_WIFI_FUNCTION + +void wifi_ret_ack() {} + +char buf_to_wifi[256]; +int index_to_wifi = 0; +int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len) { + char wifi_ret_head = 0xa5; + char wifi_ret_tail = 0xfc; + + if (type == WIFI_PARA_SET) { + int data_offset = 4; + int apLen = strlen((const char *)uiCfg.wifi_name); + int keyLen = strlen((const char *)uiCfg.wifi_key); + + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + + buf_to_wifi[data_offset] = gCfgItems.wifi_mode_sel; + buf_to_wifi[data_offset + 1] = apLen; + strncpy(&buf_to_wifi[data_offset + 2], (const char *)uiCfg.wifi_name, apLen); + buf_to_wifi[data_offset + apLen + 2] = keyLen; + strncpy(&buf_to_wifi[data_offset + apLen + 3], (const char *)uiCfg.wifi_key, keyLen); + buf_to_wifi[data_offset + apLen + keyLen + 3] = wifi_ret_tail; + + index_to_wifi = apLen + keyLen + 3; + + buf_to_wifi[0] = wifi_ret_head; + buf_to_wifi[1] = type; + buf_to_wifi[2] = index_to_wifi & 0xff; + buf_to_wifi[3] = (index_to_wifi >> 8) & 0xff; + + raw_send_to_wifi(buf_to_wifi, 5 + index_to_wifi); + + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + + } + else if (type == WIFI_TRANS_INF) { + if (len > (int)(sizeof(buf_to_wifi) - index_to_wifi - 5)) { + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + return 0; + } + + if (len > 0) { + memcpy(&buf_to_wifi[4 + index_to_wifi], buf, len); + index_to_wifi += len; + + if (index_to_wifi < 1) + return 0; + + if (buf_to_wifi[index_to_wifi + 3] == '\n') { + //mask "wait" "busy" "X:" + if (((buf_to_wifi[4] == 'w') && (buf_to_wifi[5] == 'a') && (buf_to_wifi[6] == 'i') && (buf_to_wifi[7] == 't') ) + || ((buf_to_wifi[4] == 'b') && (buf_to_wifi[5] == 'u') && (buf_to_wifi[6] == 's') && (buf_to_wifi[7] == 'y') ) + || ((buf_to_wifi[4] == 'X') && (buf_to_wifi[5] == ':') ) + ) { + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + return 0; + } + + buf_to_wifi[0] = wifi_ret_head; + buf_to_wifi[1] = type; + buf_to_wifi[2] = index_to_wifi & 0xff; + buf_to_wifi[3] = (index_to_wifi >> 8) & 0xff; + buf_to_wifi[4 + index_to_wifi] = wifi_ret_tail; + + raw_send_to_wifi(buf_to_wifi, 5 + index_to_wifi); + + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + } + } + } + else if (type == WIFI_EXCEP_INF) { + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + + buf_to_wifi[0] = wifi_ret_head; + buf_to_wifi[1] = type; + buf_to_wifi[2] = 1; + buf_to_wifi[3] = 0; + buf_to_wifi[4] = *buf; + buf_to_wifi[5] = wifi_ret_tail; + + raw_send_to_wifi(buf_to_wifi, 6); + + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + } + else if (type == WIFI_CLOUD_CFG) { + int data_offset = 4; + int urlLen = strlen((const char *)uiCfg.cloud_hostUrl); + + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + + if (gCfgItems.cloud_enable == true) + buf_to_wifi[data_offset] = 0x0a; + else + buf_to_wifi[data_offset] = 0x05; + + buf_to_wifi[data_offset + 1] = urlLen; + strncpy(&buf_to_wifi[data_offset + 2], (const char *)uiCfg.cloud_hostUrl, urlLen); + buf_to_wifi[data_offset + urlLen + 2] = uiCfg.cloud_port & 0xff; + buf_to_wifi[data_offset + urlLen + 3] = (uiCfg.cloud_port >> 8) & 0xff; + buf_to_wifi[data_offset + urlLen + 4] = wifi_ret_tail; + + index_to_wifi = urlLen + 4; + + buf_to_wifi[0] = wifi_ret_head; + buf_to_wifi[1] = type; + buf_to_wifi[2] = index_to_wifi & 0xff; + buf_to_wifi[3] = (index_to_wifi >> 8) & 0xff; + + raw_send_to_wifi(buf_to_wifi, 5 + index_to_wifi); + + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + } + else if (type == WIFI_CLOUD_UNBIND) { + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + + buf_to_wifi[0] = wifi_ret_head; + buf_to_wifi[1] = type; + buf_to_wifi[2] = 0; + buf_to_wifi[3] = 0; + buf_to_wifi[4] = wifi_ret_tail; + + raw_send_to_wifi(buf_to_wifi, 5); + + memset(buf_to_wifi, 0, sizeof(buf_to_wifi)); + index_to_wifi = 0; + } +} + + +int send_to_wifi(char *buf, int len) { return package_to_wifi(WIFI_TRANS_INF, buf, len); } + +void set_cur_file_sys(int fileType) { + gCfgItems.fileSysType = fileType; +} + +void get_file_list(char *path) { + if ( path == 0) { + return; + } + + if (gCfgItems.fileSysType == FILE_SYS_SD) { + #if ENABLED(SDSUPPORT) + card.mount(); + #endif + } + else if (gCfgItems.fileSysType == FILE_SYS_USB) { + //udisk + } + Explore_Disk(path, 0); +} + +char wait_ip_back_flag = 0; + +typedef struct { + char write_buf[513]; + int write_index; + uint8_t saveFileName[30]; + uint32_t fileLen; + uint32_t tick_begin; + uint32_t tick_end; +} FILE_WRITER; + +FILE_WRITER file_writer; + +int32_t lastFragment = 0; + +char lastBinaryCmd[50] = {0}; + +int total_write = 0; +char binary_head[2] = {0, 0}; +unsigned char binary_data_len = 0; + +int write_to_file(char *buf, int len) { + int i; + int res; + + for (i = 0; i < len; i++) { + file_writer.write_buf[file_writer.write_index++] = buf[i]; + if (file_writer.write_index >= 512) { + res = card.write(file_writer.write_buf, file_writer.write_index); + if (res == -1) { + return -1; + } + memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + file_writer.write_index = 0; + } + } + return 0; +} + +#define ESP_PROTOC_HEAD (uint8_t)0xa5 +#define ESP_PROTOC_TAIL (uint8_t)0xfc + +#define ESP_TYPE_NET (uint8_t)0x0 +#define ESP_TYPE_GCODE (uint8_t)0x1 +#define ESP_TYPE_FILE_FIRST (uint8_t)0x2 +#define ESP_TYPE_FILE_FRAGMENT (uint8_t)0x3 + +#define ESP_TYPE_WIFI_LIST (uint8_t)0x4 + +uint8_t esp_msg_buf[UART_RX_BUFFER_SIZE] = {0}; +uint16_t esp_msg_index = 0; + +typedef struct { + uint8_t head; + uint8_t type; + uint16_t dataLen; + uint8_t *data; + uint8_t tail; +} ESP_PROTOC_FRAME; + + +static int cut_msg_head(uint8_t *msg, uint16_t msgLen, uint16_t cutLen) { + if (msgLen < cutLen) return 0; + + else if (msgLen == cutLen) { + memset(msg, 0, msgLen); + return 0; + } + + for (int i = 0; i < (msgLen - cutLen); i++) + msg[i] = msg[cutLen + i]; + + memset(&msg[msgLen - cutLen], 0, cutLen); + + return msgLen - cutLen; +} + + +uint8_t Explore_Disk (char* path , uint8_t recu_level) { + char tmp[200]; + char Fstream[200]; + + if (path == 0)return 0; + + const uint8_t fileCnt = card.get_num_Files(); + + for (uint8_t i = 0; i < fileCnt; i++) { + const uint16_t nr = + #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA) + fileCnt - 1 - + #endif + i; + + #if ENABLED(SDCARD_SORT_ALPHA) + card.getfilename_sorted(nr); + #else + card.getfilename_sorted(nr); + #endif + memset(tmp, 0, sizeof(tmp)); + //if (card.longFilename[0] == 0) + strcpy(tmp, card.filename); + //else + //strcpy(tmp, card.longFilename); + + memset(Fstream, 0, sizeof(Fstream)); + strcpy(Fstream, tmp); + + if (card.flag.filenameIsDir && (recu_level <= 10)) { + strcat(Fstream, ".DIR\r\n"); + send_to_wifi(Fstream, strlen(Fstream)); + } + else { + strcat(Fstream, "\r\n"); + send_to_wifi(Fstream, strlen(Fstream)); + } + } + + return fileCnt; +} + +static void wifi_gcode_exec(uint8_t *cmd_line) { + int8_t tempBuf[100] = {0}; + uint8_t *tmpStr = 0; + int cmd_value; + volatile int print_rate; + if ((strstr((char *)&cmd_line[0], "\n") != 0) && ((strstr((char *)&cmd_line[0], "G") != 0) || (strstr((char *)&cmd_line[0], "M") != 0) || (strstr((char *)&cmd_line[0], "T") != 0) )) { + + tmpStr = (uint8_t *)strstr((char *)&cmd_line[0], "\n"); + if (tmpStr) { + *tmpStr = '\0'; + } + tmpStr = (uint8_t *)strstr((char *)&cmd_line[0], "\r"); + if (tmpStr) { + *tmpStr = '\0'; + } + tmpStr = (uint8_t *)strstr((char *)&cmd_line[0], "*"); + if (tmpStr) { + *tmpStr = '\0'; + } + tmpStr = (uint8_t *)strstr((char *)&cmd_line[0], "M"); + if ( tmpStr) { + cmd_value = atoi((char *)(tmpStr + 1)); + tmpStr = (uint8_t *)strstr((char *)tmpStr, " "); + + switch (cmd_value) { + + case 20: //print sd / udisk file + if (uiCfg.print_state == IDLE) { + int index = 0; + + if (tmpStr == 0) { + gCfgItems.fileSysType = FILE_SYS_SD; + send_to_wifi((char *)"Begin file list\r\n", strlen("Begin file list\r\n")); + + get_file_list((char *)"0:/"); + + send_to_wifi((char *)"End file list\r\n", strlen("End file list\r\n")); + + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + break; + } + + while (tmpStr[index] == ' ') + index++; + + if (gCfgItems.wifi_type == ESP_WIFI) { + char *path = (char *)tempBuf; + + if (strlen((char *)&tmpStr[index]) < 80) { + send_to_wifi((char *)"Begin file list\r\n", strlen("Begin file list\r\n")); + + if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) { + gCfgItems.fileSysType = FILE_SYS_SD; + + } + else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) { + gCfgItems.fileSysType = FILE_SYS_USB; + } + strcpy((char *)path, (char *)&tmpStr[index]); + get_file_list(path); + send_to_wifi((char *)"End file list\r\n", strlen("End file list\r\n")); + } + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + } + } + break; + + case 21: + /*init sd card*/ + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + break; + + case 23: + /*select the file*/ + if (uiCfg.print_state == IDLE) { + int index = 0; + while (tmpStr[index] == ' ') + index++; + + if (strstr((char *)&tmpStr[index], ".g") || strstr((char *)&tmpStr[index], ".G")) { + if (strlen((char *)&tmpStr[index]) < 80) { + memset(list_file.file_name[sel_id], 0, sizeof(list_file.file_name[sel_id])); + + if (gCfgItems.wifi_type == ESP_WIFI) { + if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) { + gCfgItems.fileSysType = FILE_SYS_SD; + + } + else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) { + gCfgItems.fileSysType = FILE_SYS_USB; + } + else { + if (tmpStr[index] != '/') + strcat((char *)list_file.file_name[0], "/"); + } + strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]); + + } + else { + strcpy(list_file.file_name[sel_id], (char *)&tmpStr[index]); + } + + char *cur_name=strrchr(list_file.file_name[sel_id],'/'); + + card.openFileRead(cur_name); + + if (card.isFileOpen()) { + send_to_wifi((char *)"File selected\r\n", strlen("File selected\r\n")); + + } + else { + send_to_wifi((char *)"file.open failed\r\n", strlen("file.open failed\r\n")); + strcpy(list_file.file_name[sel_id], "notValid"); + } + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + + } + + + } + } + break; + + case 24: + if (strcmp(list_file.file_name[sel_id], "notValid") != 0) { + if (uiCfg.print_state == IDLE) { + clear_cur_ui(); + reset_print_time(); + start_print_time(); + preview_gcode_prehandle(list_file.file_name[sel_id]); + uiCfg.print_state = WORKING; + lv_draw_printing(); + + if (gcode_preview_over != 1) { + #if ENABLED(SDSUPPORT) + char *cur_name; + cur_name=strrchr(list_file.file_name[sel_id],'/'); + + SdFile file; + SdFile *curDir; + card.endFilePrint(); + const char * const fname = card.diveToFile(true, curDir, cur_name); + if (!fname) return; + if (file.open(curDir, fname, O_READ)) { + gCfgItems.curFilesize = file.fileSize(); + file.close(); + update_spi_flash(); + } + card.openFileRead(cur_name); + if (card.isFileOpen()) { + feedrate_percentage = 100; + //saved_feedrate_percentage = feedrate_percentage; + planner.flow_percentage[0] = 100; + planner.e_factor[0]= planner.flow_percentage[0]*0.01; + if (EXTRUDERS==2) { + planner.flow_percentage[1] = 100; + planner.e_factor[1]= planner.flow_percentage[1]*0.01; + } + card.startFileprint(); + #if ENABLED(POWER_LOSS_RECOVERY) + recovery.prepare(); + #endif + once_flag = 0; + } + #endif + + } + } + else if (uiCfg.print_state == PAUSED) { + uiCfg.print_state = RESUMING; + clear_cur_ui(); + start_print_time(); + + if (gCfgItems.from_flash_pic==1) + flash_preview_begin = 1; + else + default_preview_flg = 1; + lv_draw_printing(); + } + else if (uiCfg.print_state == REPRINTING) { + uiCfg.print_state = REPRINTED; + clear_cur_ui(); + start_print_time(); + if (gCfgItems.from_flash_pic==1) + flash_preview_begin = 1; + else + default_preview_flg = 1; + lv_draw_printing(); + } + } + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + break; + + case 25: + /*pause print file*/ + if (uiCfg.print_state == WORKING) { + stop_print_time(); + + clear_cur_ui(); + + #if ENABLED(SDSUPPORT) + card.pauseSDPrint(); + uiCfg.print_state = PAUSING; + #endif + if (gCfgItems.from_flash_pic==1) + flash_preview_begin = 1; + else + default_preview_flg = 1; + lv_draw_printing(); + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + } + break; + + case 26: + /*stop print file*/ + if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED) || (uiCfg.print_state == REPRINTING)) { + stop_print_time(); + + clear_cur_ui(); + #if ENABLED(SDSUPPORT) + uiCfg.print_state = IDLE; + card.flag.abort_sd_printing = true; + #endif + + lv_draw_ready_print(); + + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + } + break; + + case 27: + /*report print rate*/ + if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) { + print_rate = uiCfg.totalSend; + + memset((char *)tempBuf, 0, sizeof(tempBuf)); + + sprintf((char *)tempBuf, "M27 %d\r\n", print_rate); + + send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); + + } + + break; + + case 28: + /*begin to transfer file to filesys*/ + if (uiCfg.print_state == IDLE) { + + int index = 0; + while (tmpStr[index] == ' ') + index++; + + if (strstr((char *)&tmpStr[index], ".g") || strstr((char *)&tmpStr[index], ".G")) { + strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); + + if (gCfgItems.fileSysType == FILE_SYS_SD) { + memset(tempBuf, 0, sizeof(tempBuf)); + sprintf((char *)tempBuf, "%s", file_writer.saveFileName); + } + else if (gCfgItems.fileSysType == FILE_SYS_USB) { + memset(tempBuf, 0, sizeof(tempBuf)); + sprintf((char *)tempBuf, "%s", (char *)file_writer.saveFileName); + } + mount_file_sys(gCfgItems.fileSysType); + + #if ENABLED(SDSUPPORT) + char *cur_name=strrchr(list_file.file_name[sel_id],'/'); + card.openFileWrite(cur_name); + if (card.isFileOpen()) { + memset(file_writer.saveFileName, 0, sizeof(file_writer.saveFileName)); + strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); + memset(tempBuf, 0, sizeof(tempBuf)); + sprintf((char *)tempBuf, "Writing to file: %s\r\n", (char *)file_writer.saveFileName); + wifi_ret_ack(); + send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); + + total_write = 0; + wifi_link_state = WIFI_WAIT_TRANS_START; + + } + else{ + wifi_link_state = WIFI_CONNECTED; + clear_cur_ui(); + lv_draw_dialog(DIALOG_TRANSFER_NO_DEVICE); + } + #endif + + } + + } + break; + case 105: + case 991: + memset(tempBuf, 0, sizeof(tempBuf)); + if (cmd_value == 105) { + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + sprintf((char *)tempBuf,"T:%.1f /%.1f B:%.1f /%.1f T0:%.1f /%.1f T1:%.1f /%.1f @:0 B@:0\r\n", + + (float)thermalManager.temp_hotend[0].celsius,(float)thermalManager.temp_hotend[0].target, + #if HAS_HEATED_BED + (float)thermalManager.temp_bed.celsius,(float)thermalManager.temp_bed.target, + #else + (float)0,(float)0, + #endif + (float)thermalManager.temp_hotend[0].celsius,(float)thermalManager.temp_hotend[0].target, + #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER + (float)thermalManager.temp_hotend[1].celsius,(float)thermalManager.temp_hotend[1].target + #else + (float)0,(float)0 + #endif + ); + } + else { + sprintf((char *)tempBuf,"T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n", + + (int)thermalManager.temp_hotend[0].celsius,(int)thermalManager.temp_hotend[0].target, + #if HAS_HEATED_BED + (int)thermalManager.temp_bed.celsius,(int)thermalManager.temp_bed.target, + #else + 0,0, + #endif + (int)thermalManager.temp_hotend[0].celsius,(int)thermalManager.temp_hotend[0].target, + #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER + (int)thermalManager.temp_hotend[1].celsius,(int)thermalManager.temp_hotend[1].target + #else + 0,0 + #endif + ); + } + + send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); + + queue.enqueue_one_P(PSTR("M105")); + + break; + case 992: + if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { + memset(tempBuf,0,sizeof(tempBuf)); + sprintf((char *)tempBuf, "M992 %d%d:%d%d:%d%d\r\n", print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10); + wifi_ret_ack(); + send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); + } + + break; + case 994: + if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { + memset(tempBuf,0,sizeof(tempBuf)); + if (strlen((char *)list_file.file_name[sel_id]) > (100-1)) { + return; + } + sprintf((char *)tempBuf, "M994 %s;%d\n", list_file.file_name[sel_id],(int)gCfgItems.curFilesize); + wifi_ret_ack(); + send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); + } + break; + case 997: + if (uiCfg.print_state == IDLE) { + wifi_ret_ack(); + send_to_wifi((char *)"M997 IDLE\r\n", strlen("M997 IDLE\r\n")); + } + else if (uiCfg.print_state == WORKING) { + wifi_ret_ack(); + send_to_wifi((char *)"M997 PRINTING\r\n", strlen("M997 PRINTING\r\n")); + } + else if (uiCfg.print_state == PAUSED) { + wifi_ret_ack(); + send_to_wifi((char *)"M997 PAUSE\r\n", strlen("M997 PAUSE\r\n")); + } + else if (uiCfg.print_state == REPRINTING) { + wifi_ret_ack(); + send_to_wifi((char *)"M997 PAUSE\r\n", strlen("M997 PAUSE\r\n")); + } + if (uiCfg.command_send == 0) get_wifi_list_command_send(); + break; + + case 998: + if (uiCfg.print_state == IDLE) { + if (atoi((char *)tmpStr) == 0) { + set_cur_file_sys(0); + } + else if (atoi((char *)tmpStr) == 1) { + set_cur_file_sys(1); + } + wifi_ret_ack(); + } + break; + + case 115: + memset(tempBuf,0,sizeof(tempBuf)); + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + send_to_wifi((char *)"FIRMWARE_NAME:Robin_nano\r\n", strlen("FIRMWARE_NAME:Robin_nano\r\n")); + break; + + default: + strcat((char *)cmd_line, "\n"); + + uint32_t left; + + if (espGcodeFifo.wait_tick> 5) { + + if (espGcodeFifo.r > espGcodeFifo.w) + left = espGcodeFifo.r - espGcodeFifo.w - 1; + else + left = WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; + if (left >= strlen((const char *)cmd_line)) { + uint32_t index = 0; + while (index < strlen((const char *)cmd_line)) { + espGcodeFifo.Buffer[espGcodeFifo.w] = cmd_line[index] ; + espGcodeFifo.w = (espGcodeFifo.w + 1) % WIFI_GCODE_BUFFER_SIZE; + index++; + } + if (left - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + else + need_ok_later = true; + + } + + } + break; + + } + } + else{ + strcat((char *)cmd_line, "\n"); + uint32_t left_g; + + if (espGcodeFifo.wait_tick > 5) { + + if (espGcodeFifo.r > espGcodeFifo.w) + left_g = espGcodeFifo.r - espGcodeFifo.w - 1; + else + left_g = WIFI_GCODE_BUFFER_SIZE + espGcodeFifo.r - espGcodeFifo.w - 1; + if (left_g >= strlen((const char *)cmd_line)) { + uint32_t index = 0; + while (index < strlen((const char *)cmd_line)) { + espGcodeFifo.Buffer[espGcodeFifo.w] = cmd_line[index] ; + espGcodeFifo.w = (espGcodeFifo.w + 1) % WIFI_GCODE_BUFFER_SIZE; + index++; + } + if (left_g - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + else + need_ok_later = true; + + } + } + } + } +} + +static int32_t charAtArray(const uint8_t *_array, uint32_t _arrayLen, uint8_t _char) { + for (uint32_t i = 0; i < _arrayLen; i++) + if (*(_array + i) == _char) return i; + return -1; +} + +void get_wifi_list_command_send() { + char buf[6] = {0}; + buf[0] = 0xA5; + buf[1] = 0x07; + buf[2] = 0x00; + buf[3] = 0x00; + buf[4] = 0xFC; + raw_send_to_wifi(buf, 5); +} + +static void net_msg_handle(uint8_t * msg, uint16_t msgLen) { + int wifiNameLen, wifiKeyLen, hostLen, id_len, ver_len; + + if (msgLen <= 0) return; + //ip + sprintf(ipPara.ip_addr, "%d.%d.%d.%d", msg[0], msg[1], msg[2], msg[3]); + + //port + //connect state + if (msg[6] == 0x0A) + wifi_link_state = WIFI_CONNECTED; + else if (msg[6] == 0x0E) + wifi_link_state = WIFI_EXCEPTION; + else + wifi_link_state = WIFI_NOT_CONFIG; + + //mode + wifiPara.mode = msg[7]; + + + //wifi name + wifiNameLen = msg[8]; + wifiKeyLen = msg[9 + wifiNameLen]; + if (wifiNameLen < 32) { + memset(wifiPara.ap_name, 0, sizeof(wifiPara.ap_name)); + memcpy(wifiPara.ap_name, &msg[9], wifiNameLen); + + memset(&wifi_list.wifiConnectedName,0,sizeof(wifi_list.wifiConnectedName)); + memcpy(&wifi_list.wifiConnectedName,&msg[9],wifiNameLen); + + //wifi key + if (wifiKeyLen < 64) { + memset(wifiPara.keyCode, 0, sizeof(wifiPara.keyCode)); + memcpy(wifiPara.keyCode, &msg[10 + wifiNameLen], wifiKeyLen); + } + } + + + cloud_para.state =msg[10 + wifiNameLen + wifiKeyLen]; + hostLen = msg[11 + wifiNameLen + wifiKeyLen]; + if (cloud_para.state) { + if (hostLen < 96) { + memset(cloud_para.hostUrl, 0, sizeof(cloud_para.hostUrl)); + memcpy(cloud_para.hostUrl, &msg[12 + wifiNameLen + wifiKeyLen], hostLen); + } + cloud_para.port = msg[12 + wifiNameLen + wifiKeyLen + hostLen] + (msg[13 + wifiNameLen + wifiKeyLen + hostLen] << 8); + + } + + // id + id_len = msg[14 + wifiNameLen + wifiKeyLen + hostLen]; + if (id_len == 20) { + memset(cloud_para.id, 0, sizeof(cloud_para.id)); + memcpy(cloud_para.id, (const char *)&msg[15 + wifiNameLen + wifiKeyLen + hostLen], id_len); + } + ver_len = msg[15 + wifiNameLen + wifiKeyLen + hostLen + id_len]; + if (ver_len < 20) { + memset(wifi_firm_ver, 0, sizeof(wifi_firm_ver)); + memcpy(wifi_firm_ver, (const char *)&msg[16 + wifiNameLen + wifiKeyLen + hostLen + id_len], ver_len); + } + + if (uiCfg.configWifi == 1) { + if ((wifiPara.mode != gCfgItems.wifi_mode_sel) + || (strncmp(wifiPara.ap_name, (const char *)uiCfg.wifi_name, 32) != 0) + || (strncmp(wifiPara.keyCode, (const char *)uiCfg.wifi_key, 64) != 0)) { + package_to_wifi(WIFI_PARA_SET, (char *)0, 0); + } + else uiCfg.configWifi = 0; + } + if (cfg_cloud_flag == 1) { + if (((cloud_para.state >> 4) != (char)gCfgItems.cloud_enable) + || (strncmp(cloud_para.hostUrl, (const char *)uiCfg.cloud_hostUrl, 96) != 0) + || (cloud_para.port != uiCfg.cloud_port)) { + package_to_wifi(WIFI_CLOUD_CFG, (char *)0, 0); + } + else cfg_cloud_flag = 0; + } +} + +static void wifi_list_msg_handle(uint8_t * msg, uint16_t msgLen) { + int wifiNameLen,wifiMsgIdex=1; + int8_t wifi_name_is_same=0; + int8_t i,j; + int8_t wifi_name_num=0; + uint8_t *str=0; + int8_t valid_name_num; + + if (msgLen <= 0) + return; + if (disp_state == KEY_BOARD_UI) + return; + + wifi_list.getNameNum = msg[0]; + + if (wifi_list.getNameNum < 20) { + uiCfg.command_send = 1; + + memset(wifi_list.wifiName,0,sizeof(wifi_list.wifiName)); + + wifi_name_num = wifi_list.getNameNum; + + valid_name_num=0; + str = wifi_list.wifiName[valid_name_num]; + + if (wifi_list.getNameNum > 0) wifi_list.currentWifipage = 1; + + for (i = 0; i 0x80) { + wifi_name_is_same = 1; + //break; + } + //} + } + if (wifi_name_is_same == 1) { + wifi_name_is_same = 0; + wifiMsgIdex += wifiNameLen; + //wifi_list.RSSI[i] = msg[wifiMsgIdex]; + wifiMsgIdex += 1; + wifi_name_num--; + //i--; + continue; + } + if (i < WIFI_TOTAL_NUMBER-1) { + str = wifi_list.wifiName[++valid_name_num]; + } + } + wifiMsgIdex += wifiNameLen; + wifi_list.RSSI[i] = msg[wifiMsgIdex]; + wifiMsgIdex += 1; + } + wifi_list.getNameNum = wifi_name_num; + if (wifi_list.getNameNum % NUMBER_OF_PAGE == 0) { + wifi_list.getPage = wifi_list.getNameNum/NUMBER_OF_PAGE; + } + else { + wifi_list.getPage = wifi_list.getNameNum/NUMBER_OF_PAGE + 1; + } + wifi_list.nameIndex = 0; + if (disp_state == WIFI_LIST_UI) + disp_wifi_list(); + } +} + +static void gcode_msg_handle(uint8_t * msg, uint16_t msgLen) { + uint8_t gcodeBuf[100] = {0}; + char *index_s; + char *index_e; + + if (msgLen <= 0) + return; + + index_s = (char *)msg; + index_e = (char *)strstr((char *)msg, "\n"); + if (*msg == 'N') { + index_s = (char *)strstr((char *)msg, " "); + while ((*index_s) == ' ') { + index_s++; + } + } + while ((index_e != 0) && ((int)index_s < (int)index_e)) { + if ((int)(index_e - index_s) < (int)sizeof(gcodeBuf)) { + memset(gcodeBuf, 0, sizeof(gcodeBuf)); + + memcpy(gcodeBuf, index_s, index_e - index_s + 1); + + wifi_gcode_exec(gcodeBuf); + } + while ((*index_e == '\r') || (*index_e == '\n')) + index_e++; + + index_s = index_e; + index_e = (char *)strstr(index_s, "\n"); + } +} + +void utf8_2_unicode(uint8_t *source,uint8_t Len) { + uint8_t i=0,char_i=0,char_byte_num=0; + uint16_t u16_h,u16_m,u16_l,u16_value; + uint8_t FileName_unicode[30]; + + memset(FileName_unicode, 0, sizeof(FileName_unicode)); + + while (1) { + char_byte_num = source[i] & 0xF0; + if (source[i] < 0X80) { + //ASCII --1byte + FileName_unicode[char_i] = source[i]; + i += 1; + char_i += 1; + } + else if (char_byte_num == 0XC0 || char_byte_num == 0XD0) { + //--2byte + + u16_h = (((uint16_t)source[i] <<8) & 0x1f00) >> 2; + u16_l = ((uint16_t)source[i+1] & 0x003f); + u16_value = (u16_h | u16_l); + FileName_unicode[char_i] = (uint8_t)((u16_value & 0xff00) >> 8); + FileName_unicode[char_i + 1] = (uint8_t)(u16_value & 0x00ff); + i += 2; + char_i += 2; + } + else if (char_byte_num == 0XE0) { + //--3byte + u16_h = (((uint16_t)source[i] <<8 ) & 0x0f00) << 4; + u16_m = (((uint16_t)source[i+1] << 8) & 0x3f00) >> 2; + u16_l = ((uint16_t)source[i+2] & 0x003f); + u16_value = (u16_h | u16_m | u16_l); + FileName_unicode[char_i] = (uint8_t)((u16_value & 0xff00) >> 8); + FileName_unicode[char_i + 1] = (uint8_t)(u16_value & 0x00ff); + i += 3; + char_i += 2; + } + else if (char_byte_num == 0XF0) { + //--4byte + i += 4; + //char_i += 3; + } + else { + break; + } + if (i >= Len || i >= 255)break; + } + memcpy(source, FileName_unicode, sizeof(FileName_unicode)); +} + +char saveFilePath[50]; + +static bool longName2DosName(const char* longName, uint8_t* dosName) { + uint8_t i = 11; + while (i--) dosName[i] = '\0'; + while (*longName) { + uint8_t c = *longName++; + if (c == '.') { // For a dot... + if (i == 0) return false; + else { strcat((char *)dosName,".GCO"); return dosName[0] != '\0'; } + } + else { + // Fail for illegal characters + PGM_P p = PSTR("|<>^+=?/[];,*\"\\"); + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; + if (c < 0x21 || c == 0x7F) return false; // Check size, non-printable characters + dosName[i++] = (c < 'a' || c > 'z') ? (c) : (c + ('A' - 'a')); // Uppercase required for 8.3 name + } + if (i >= 5) strcat((char *)dosName,"~1.GCO"); + } + return dosName[0] != '\0'; // Return true if any name was set +} + +static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { + uint8_t fileNameLen = *msg; + + if (msgLen != fileNameLen + 5) return; + + file_writer.fileLen = *((uint32_t *)(msg + 1)); + memset(file_writer.saveFileName, 0, sizeof(file_writer.saveFileName)); + + memcpy(file_writer.saveFileName, msg + 5, fileNameLen); + + utf8_2_unicode(file_writer.saveFileName,fileNameLen); + + memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + + if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath)) + return; + + memset(saveFilePath, 0, sizeof(saveFilePath)); + + if (gCfgItems.fileSysType == FILE_SYS_SD) { + //sprintf((char *)saveFilePath, "/%s", file_writer.saveFileName); + card.mount(); + + //ZERO(list_file.long_name[sel_id]); + //memcpy(list_file.long_name[sel_id],file_writer.saveFileName,sizeof(list_file.long_name[sel_id])); + } + else if (gCfgItems.fileSysType == FILE_SYS_USB) { + + } + file_writer.write_index = 0; + lastFragment = -1; + + wifiTransError.flag = 0; + wifiTransError.start_tick = 0; + wifiTransError.now_tick = 0; + + TERN_(SDSUPPORT, card.closefile()); + + wifi_delay(1000); + + #if ENABLED(SDSUPPORT) + + uint8_t dosName[FILENAME_LENGTH]; + + if (!longName2DosName((const char *)file_writer.saveFileName,dosName)) { + clear_cur_ui(); + upload_result = 2; + wifiTransError.flag = 1; + wifiTransError.start_tick = getWifiTick(); + lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); + return; + } + sprintf((char *)saveFilePath, "/%s", dosName); + + ZERO(list_file.long_name[sel_id]); + memcpy(list_file.long_name[sel_id],dosName,sizeof(dosName)); + + char *cur_name=strrchr((const char *)saveFilePath,'/'); + + SdFile file; + SdFile *curDir; + card.endFilePrint(); + const char * const fname = card.diveToFile(true, curDir, cur_name); + if (!fname) return; + if (file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { + gCfgItems.curFilesize = file.fileSize(); + } + else { + clear_cur_ui(); + upload_result = 2; + wifiTransError.flag = 1; + wifiTransError.start_tick = getWifiTick(); + lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); + return; + } + #endif + + wifi_link_state = WIFI_TRANS_FILE; + + upload_result = 1; + + clear_cur_ui(); + lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); + + lv_task_handler(); + + file_writer.tick_begin = getWifiTick(); +} + +#define FRAG_MASK _BV32(31) + +static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) { + uint32_t frag = *((uint32_t *)msg); + + if ((frag & FRAG_MASK) != (uint32_t)(lastFragment + 1)) { + memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + file_writer.write_index = 0; + wifi_link_state = WIFI_CONNECTED; + upload_result = 2; + } + else { + if (write_to_file((char *)msg + 4, msgLen - 4) < 0) { + memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + file_writer.write_index = 0; + wifi_link_state = WIFI_CONNECTED; + upload_result = 2; + return; + } + lastFragment = frag; + + if ((frag & (~FRAG_MASK))) { + int res = card.write(file_writer.write_buf, file_writer.write_index); + if (res == -1) { + memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + file_writer.write_index = 0; + wifi_link_state = WIFI_CONNECTED; + upload_result = 2; + return; + } + memset(file_writer.write_buf, 0, sizeof(file_writer.write_buf)); + file_writer.write_index = 0; + file_writer.tick_end = getWifiTick(); + upload_time = getWifiTickDiff(file_writer.tick_begin, file_writer.tick_end) / 1000; + upload_size = gCfgItems.curFilesize; + wifi_link_state = WIFI_CONNECTED; + upload_result = 3; + } + + } +} + +void esp_data_parser(char *cmdRxBuf, int len) { + int32_t head_pos; + int32_t tail_pos; + uint16_t cpyLen; + int16_t leftLen = len; + bool loop_again = false; + + ESP_PROTOC_FRAME esp_frame; + + while (leftLen > 0 || loop_again) { + loop_again = false; + + if (esp_msg_index != 0) { + head_pos = 0; + cpyLen = (leftLen < (int16_t)((sizeof(esp_msg_buf) - esp_msg_index)) ? leftLen : sizeof(esp_msg_buf) - esp_msg_index); + + memcpy(&esp_msg_buf[esp_msg_index], cmdRxBuf + len - leftLen, cpyLen); + + esp_msg_index += cpyLen; + + leftLen = leftLen - cpyLen; + tail_pos = charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL); + + if (tail_pos == -1) { + if (esp_msg_index >= sizeof(esp_msg_buf)) { + memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + esp_msg_index = 0; + } + return; + } + } + else { + head_pos = charAtArray((uint8_t const *)&cmdRxBuf[len - leftLen], leftLen, ESP_PROTOC_HEAD); + if (head_pos == -1) return; + + memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + memcpy(esp_msg_buf, &cmdRxBuf[len - leftLen + head_pos], leftLen - head_pos); + + esp_msg_index = leftLen - head_pos; + + leftLen = 0; + head_pos = 0; + tail_pos = charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL); + if (tail_pos == -1) { + if (esp_msg_index >= sizeof(esp_msg_buf)) { + memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + esp_msg_index = 0; + } + return; + } + } + + esp_frame.type = esp_msg_buf[1]; + if ((esp_frame.type != ESP_TYPE_NET) && (esp_frame.type != ESP_TYPE_GCODE) + && (esp_frame.type != ESP_TYPE_FILE_FIRST) && (esp_frame.type != ESP_TYPE_FILE_FRAGMENT) + &&(esp_frame.type != ESP_TYPE_WIFI_LIST)) { + memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + esp_msg_index = 0; + return; + } + + esp_frame.dataLen = esp_msg_buf[2] + (esp_msg_buf[3] << 8); + + if ((int)(4 + esp_frame.dataLen) > (int)(sizeof(esp_msg_buf))) { + memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + esp_msg_index = 0; + return; + } + + if (esp_msg_buf[4 + esp_frame.dataLen] != ESP_PROTOC_TAIL) { + if (esp_msg_index >= sizeof(esp_msg_buf)) { + memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + esp_msg_index = 0; + } + return; + } + + esp_frame.data = &esp_msg_buf[4]; + switch (esp_frame.type) { + case ESP_TYPE_NET: + net_msg_handle(esp_frame.data, esp_frame.dataLen); + break; + case ESP_TYPE_GCODE: + gcode_msg_handle(esp_frame.data, esp_frame.dataLen); + break; + case ESP_TYPE_FILE_FIRST: + file_first_msg_handle(esp_frame.data, esp_frame.dataLen); + break; + case ESP_TYPE_FILE_FRAGMENT: + file_fragment_msg_handle(esp_frame.data, esp_frame.dataLen); + break; + case ESP_TYPE_WIFI_LIST: + wifi_list_msg_handle(esp_frame.data, esp_frame.dataLen); + break; + default: break; + } + + esp_msg_index = cut_msg_head(esp_msg_buf, esp_msg_index, esp_frame.dataLen + 5); + if (esp_msg_index > 0) { + if (charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_HEAD) == -1) { + memset(esp_msg_buf, 0, sizeof(esp_msg_buf)); + esp_msg_index = 0; + return; + } + + if ((charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_HEAD) != -1) && (charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL) != -1)) + loop_again = true; + } + } +} + +int32_t tick_net_time1, tick_net_time2; + +int storeRcvData(int32_t len) { + unsigned char tmpW = wifiDmaRcvFifo.write_cur; + if (len <= UDISKBUFLEN && wifiDmaRcvFifo.state[tmpW] == udisk_buf_empty) { + for (uint16_t i = 0; i < len; i++) + wifiDmaRcvFifo.bufferAddr[tmpW][i] = WIFISERIAL.read(); + wifiDmaRcvFifo.state[tmpW] = udisk_buf_full; + wifiDmaRcvFifo.write_cur = (tmpW + 1) % TRANS_RCV_FIFO_BLOCK_NUM; + return 1; + } + return 0; +} + +int32_t readWifiFifo(uint8_t *retBuf, uint32_t bufLen) { + unsigned char tmpR = wifiDmaRcvFifo.read_cur; + if (bufLen >= UDISKBUFLEN && wifiDmaRcvFifo.state[tmpR] == udisk_buf_full) { + memcpy(retBuf, (unsigned char *)wifiDmaRcvFifo.bufferAddr[tmpR], UDISKBUFLEN); + wifiDmaRcvFifo.state[tmpR] = udisk_buf_empty; + wifiDmaRcvFifo.read_cur = (tmpR + 1) % TRANS_RCV_FIFO_BLOCK_NUM; + return UDISKBUFLEN; + } + return 0; +} + +void stopEspTransfer() { + if (wifi_link_state == WIFI_TRANS_FILE) + wifi_link_state = WIFI_CONNECTED; + + TERN_(SDSUPPORT, card.closefile()); + + if (upload_result != 3) { + wifiTransError.flag = 1; + wifiTransError.start_tick = getWifiTick(); + card.removeFile((const char *)saveFilePath); + } + else { + } + wifi_delay(200); + WIFI_IO1_SET(); + //exchangeFlashMode(1); //change spi flash to use dma mode + esp_port_begin(1); + if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); +} + +void wifi_rcv_handle() { + int32_t len = 0; + uint8_t ucStr[(UART_RX_BUFFER_SIZE) + 1] = {0}; + int8_t getDataF = 0; + + if (wifi_link_state == WIFI_TRANS_FILE) { + #if 0 + if (WIFISERIAL.available() == UART_RX_BUFFER_SIZE) { + for (uint16_t i=0;i 0) { + esp_data_parser((char *)ucStr, len); + if (wifi_link_state == WIFI_CONNECTED) { + clear_cur_ui(); + lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); + stopEspTransfer(); + } + getDataF = 1; + } + if (esp_state == TRANSFER_STORE) { + if (storeRcvData(UART_RX_BUFFER_SIZE)) { + esp_state = TRANSFERING; + //esp_dma_pre(); + if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); + } + else + WIFI_IO1_SET(); + } + } + else { + //len = readUsartFifo((SZ_USART_FIFO *)&WifiRxFifo, (int8_t *)ucStr, UART_RX_BUFFER_SIZE); + len = readWifiBuf((int8_t *)ucStr, UART_RX_BUFFER_SIZE); + if (len > 0) { + esp_data_parser((char *)ucStr, len); + + if (wifi_link_state == WIFI_TRANS_FILE) { + //exchangeFlashMode(0); //change spi flash not use dma mode + wifi_delay(10); + esp_port_begin(0); + wifi_delay(10); + tick_net_time1 = 0; + } + if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); + getDataF = 1; + } + if (need_ok_later && (queue.length < BUFSIZE)) { + need_ok_later = false; + send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); + } + } + + if (getDataF == 1) { + tick_net_time1 = getWifiTick(); + } + else { + tick_net_time2 = getWifiTick(); + + if (wifi_link_state == WIFI_TRANS_FILE) { + if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 4500)) { + wifi_link_state = WIFI_CONNECTED; + upload_result = 2; + clear_cur_ui(); + stopEspTransfer(); + lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); + } + } + + if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 10000)) + wifi_link_state = WIFI_NOT_CONFIG; + + if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 120000)) { + wifi_link_state = WIFI_NOT_CONFIG; + wifi_reset(); + tick_net_time1 = getWifiTick(); + } + } + + if (wifiTransError.flag == 0x1) { + wifiTransError.now_tick = getWifiTick(); + if (getWifiTickDiff(wifiTransError.start_tick, wifiTransError.now_tick) > WAIT_ESP_TRANS_TIMEOUT_TICK) { + wifiTransError.flag = 0; + WIFI_IO1_RESET(); + } + } +} + +void wifi_looping() { + do { wifi_rcv_handle(); } while (wifi_link_state == WIFI_TRANS_FILE); +} + +void mks_esp_wifi_init() { + wifi_link_state = WIFI_NOT_CONFIG; + + SET_OUTPUT(WIFI_RESET_PIN); + WIFI_SET(); + SET_OUTPUT(WIFI_IO1_PIN); + SET_INPUT_PULLUP(WIFI_IO0_PIN); + WIFI_IO1_SET(); + + esp_state = TRANSFER_IDLE; + esp_port_begin(1); + + wifi_reset(); + + #if 0 + res = f_open(&esp_upload.uploadFile, ESP_FIRMWARE_FILE, FA_OPEN_EXISTING | FA_READ); + + if (res == FR_OK) { + f_close(&esp_upload.uploadFile); + + wifi_delay(2000); + + if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) { + return; + } + + clear_cur_ui(); + + draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMARE); + + if (wifi_upload(0) >= 0) { + + f_unlink("1:/MKS_WIFI_CUR"); + f_rename(ESP_FIRMWARE_FILE,"/MKS_WIFI_CUR"); + } + draw_return_ui(); + + update_flag = 1; + } + if (update_flag == 0) { + res = f_open(&esp_upload.uploadFile, ESP_WEB_FIRMWARE_FILE, FA_OPEN_EXISTING | FA_READ); + + if (res == FR_OK) { + f_close(&esp_upload.uploadFile); + + wifi_delay(2000); + + if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) { + return; + } + + clear_cur_ui(); + + draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMARE); + if (wifi_upload(1) >= 0) { + + f_unlink("1:/MKS_WIFI_CUR"); + f_rename(ESP_WEB_FIRMWARE_FILE,"/MKS_WIFI_CUR"); + } + draw_return_ui(); + update_flag = 1; + } + + } + if (update_flag == 0) { + res = f_open(&esp_upload.uploadFile, ESP_WEB_FILE, FA_OPEN_EXISTING | FA_READ); + if (res == FR_OK) { + f_close(&esp_upload.uploadFile); + + wifi_delay(2000); + + if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) { + return; + } + + clear_cur_ui(); + + draw_dialog(DIALOG_TYPE_UPDATE_ESP_DATA); + + if (wifi_upload(2) >= 0) { + + f_unlink("1:/MKS_WEB_CONTROL_CUR"); + f_rename(ESP_WEB_FILE,"/MKS_WEB_CONTROL_CUR"); + } + draw_return_ui(); + } + } + #endif + wifiPara.decodeType = WIFI_DECODE_TYPE; + wifiPara.baud = 115200; + wifi_link_state = WIFI_NOT_CONFIG; +} + +#define BUF_INC_POINTER(p) ((p + 1 == UART_FIFO_BUFFER_SIZE) ? 0 : (p + 1)) + +int usartFifoAvailable(SZ_USART_FIFO *fifo) { + int diff = fifo->uart_write_point - fifo->uart_read_point; + if (diff < 0) diff += UART_FIFO_BUFFER_SIZE; + return diff; +} + +int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len) { + int i = 0 ; + while (i < len && fifo->uart_read_point != fifo->uart_write_point) { + buf[i++] = fifo->uartTxBuffer[fifo->uart_read_point]; + fifo->uart_read_point = BUF_INC_POINTER(fifo->uart_read_point); + } + return i; +} + +int writeUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len) { + if (buf == 0 || len <= 0) return -1; + + int i = 0 ; + while (i < len && fifo->uart_read_point != BUF_INC_POINTER(fifo->uart_write_point)) { + fifo->uartTxBuffer[fifo->uart_write_point] = buf[i++]; + fifo->uart_write_point = BUF_INC_POINTER(fifo->uart_write_point); + } + return i; +} + +void get_wifi_commands() { + static char wifi_line_buffer[MAX_CMD_SIZE]; + static bool wifi_comment_mode = false; + static int wifi_read_count = 0; + + if (espGcodeFifo.wait_tick > 5) { + while ((queue.length < BUFSIZE) && (espGcodeFifo.r != espGcodeFifo.w)) { + + espGcodeFifo.wait_tick = 0; + + char wifi_char = espGcodeFifo.Buffer[espGcodeFifo.r]; + + espGcodeFifo.r = (espGcodeFifo.r + 1) % WIFI_GCODE_BUFFER_SIZE; + + /** + * If the character ends the line + */ + if (wifi_char == '\n' || wifi_char == '\r') { + + wifi_comment_mode = false; // end of line == end of comment + + if (!wifi_read_count) continue; // skip empty lines + + wifi_line_buffer[wifi_read_count] = 0; // terminate string + wifi_read_count = 0; //reset buffer + + char* command = wifi_line_buffer; + while (*command == ' ') command++; // skip any leading spaces + + // Movement commands alert when stopped + if (IsStopped()) { + char* gpos = strchr(command, 'G'); + if (gpos) { + switch (strtol(gpos + 1, nullptr, 10)) { + case 0 ... 1: + #if ENABLED(ARC_SUPPORT) + case 2 ... 3: + #endif + #if ENABLED(BEZIER_CURVE_SUPPORT) + case 5: + #endif + SERIAL_ECHOLNPGM(STR_ERR_STOPPED); + LCD_MESSAGEPGM(MSG_STOPPED); + break; + } + } + } + + #if DISABLED(EMERGENCY_PARSER) + // Process critical commands early + if (strcmp(command, "M108") == 0) { + wait_for_heatup = false; + TERN_(HAS_LCD_MENU, wait_for_user = false); + } + if (strcmp(command, "M112") == 0) kill(M112_KILL_STR, nullptr, true); + if (strcmp(command, "M410") == 0) quickstop_stepper(); + #endif + + // Add the command to the queue + queue.enqueue_one_P(wifi_line_buffer); + } + else if (wifi_read_count >= MAX_CMD_SIZE - 1) { + + } + else { // it's not a newline, carriage return or escape char + if (wifi_char == ';') wifi_comment_mode = true; + if (!wifi_comment_mode) wifi_line_buffer[wifi_read_count++] = wifi_char; + } + } + }// queue has space, serial has data + else { + espGcodeFifo.wait_tick++; + } +} + +int readWifiBuf(int8_t *buf, int32_t len) { + int i = 0; + while (i < len && WIFISERIAL.available()) + buf[i++] = WIFISERIAL.read(); + return i; +} + +#endif // USE_WIFI_FUNCTION +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h new file mode 100644 index 000000000000..0b402a3adb10 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h @@ -0,0 +1,202 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +#include "../../inc/MarlinConfigPre.h" + +#include +#include +#include + +#define UART_RX_BUFFER_SIZE 1024 +#define UART_FIFO_BUFFER_SIZE 1024 + +#define ESP_WIFI 0x02 + +#define AP_MODEL 0x01 +#define STA_MODEL 0x02 + +#define WIFI_DECODE_TYPE 1 + +#define IP_DHCP_FLAG 1 + +#define WIFI_AP_NAME "TP-LINK_MKS" +#define WIFI_KEY_CODE "makerbase" + +#define IP_ADDR "192.168.3.100" +#define IP_MASK "255.255.255.0" +#define IP_GATE "192.168.3.1" +#define IP_DNS "192.168.3.1" + +#define AP_IP_DHCP_FLAG 1 +#define AP_IP_ADDR "192.168.3.100" +#define AP_IP_MASK "255.255.255.0" +#define AP_IP_GATE "192.168.3.1" +#define AP_IP_DNS "192.168.3.1" +#define IP_START_IP "192.168.3.1" +#define IP_END_IP "192.168.3.255" + +#define UDISKBUFLEN 1024 + +typedef enum{ + udisk_buf_empty = 0, + udisk_buf_full, +} UDISK_DATA_BUFFER_STATE; + +#define TRANS_RCV_FIFO_BLOCK_NUM 8 + +typedef struct { + unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM]; + unsigned char *p; + UDISK_DATA_BUFFER_STATE state[TRANS_RCV_FIFO_BLOCK_NUM]; + unsigned char read_cur; + unsigned char write_cur; +} WIFI_DMA_RCV_FIFO; + +typedef struct { + uint8_t flag; // 0x0: no error; 0x01: error + uint32_t start_tick; //error start time + uint32_t now_tick; +} WIFI_TRANS_ERROR; + +extern volatile WIFI_TRANS_ERROR wifiTransError; + +typedef struct { + char ap_name[32]; //wifi-name + char keyCode[64]; //wifi password + int decodeType; + int baud; + int mode; +} WIFI_PARA; + +typedef struct { + char state; + char hostUrl[96]; + int port; + char id[21]; +} CLOUD_PARA; + +typedef struct { + char dhcp_flag; + char ip_addr[16]; + char mask[16]; + char gate[16]; + char dns[16]; + + char dhcpd_flag; + char dhcpd_ip[16]; + char dhcpd_mask[16]; + char dhcpd_gate[16]; + char dhcpd_dns[16]; + char start_ip_addr[16]; + char end_ip_addr[16]; +} IP_PARA; + +typedef enum { + WIFI_NOT_CONFIG, + WIFI_CONFIG_MODE, + WIFI_CONFIG_DHCP, + WIFI_CONFIG_AP, + WIFI_CONFIG_IP_INF, + WIFI_CONFIG_DNS, + WIFI_CONFIG_TCP, + WIFI_CONFIG_SERVER, + WIFI_CONFIG_REMOTE_PORT, + WIFI_CONFIG_BAUD, + WIFI_CONFIG_COMMINT, + WIFI_CONFIG_OK, + WIFI_GET_IP_OK, + WIFI_RECONN, + WIFI_CONNECTED, + WIFI_WAIT_TRANS_START, + WIFI_TRANS_FILE, + WIFI_CONFIG_DHCPD, + WIFI_COFIG_DHCPD_IP, + WIFI_COFIG_DHCPD_DNS, + WIFI_EXCEPTION, +} WIFI_STATE; + +typedef enum { + TRANSFER_IDLE, + TRANSFERING, + TRANSFER_STORE, +} TRANSFER_STATE; +extern volatile TRANSFER_STATE esp_state; + +typedef struct { + char buf[20][80]; + int rd_index; + int wt_index; +} QUEUE; + +typedef enum { + WIFI_PARA_SET, // 0x0:net parameter + WIFI_PRINT_INF, // 0x1:print message + WIFI_TRANS_INF, // 0x2:Pass through information + WIFI_EXCEP_INF, // 0x3:Exception information + WIFI_CLOUD_CFG, // 0x4:cloud config + WIFI_CLOUD_UNBIND, // 0x5:Unbind ID +} WIFI_RET_TYPE; + +typedef struct { + uint32_t uart_read_point; + uint32_t uart_write_point; + uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE]; +} SZ_USART_FIFO; + +#define WIFI_GCODE_BUFFER_LEAST_SIZE 96 +#define WIFI_GCODE_BUFFER_SIZE (WIFI_GCODE_BUFFER_LEAST_SIZE * 3) +typedef struct { + uint8_t wait_tick; + uint8_t Buffer[WIFI_GCODE_BUFFER_SIZE]; + uint32_t r; + uint32_t w; +} WIFI_GCODE_BUFFER; + +extern volatile WIFI_STATE wifi_link_state; +extern WIFI_PARA wifiPara; +extern IP_PARA ipPara; +extern CLOUD_PARA cloud_para; + +extern WIFI_GCODE_BUFFER espGcodeFifo; + +extern uint32_t getWifiTick(); +extern uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick); + +extern void mks_esp_wifi_init(); +extern int cfg_cloud_flag; +extern int send_to_wifi(char *buf, int len); +extern void wifi_looping(); +extern int raw_send_to_wifi(char *buf, int len); +extern int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len); +extern void get_wifi_list_command_send(); +extern void get_wifi_commands(); +extern int readWifiBuf(int8_t *buf, int32_t len); +extern int storeRcvData(int32_t len); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp new file mode 100644 index 000000000000..132838c8a951 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp @@ -0,0 +1,847 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if HAS_TFT_LVGL_UI + +#include "draw_ui.h" +#include "wifi_module.h" +#include "wifi_upload.h" + +#include "../../../../MarlinCore.h" + +#define WIFI_SET() WRITE(WIFI_RESET_PIN, HIGH); +#define WIFI_RESET() WRITE(WIFI_RESET_PIN, LOW); +#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH); +#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); + +extern SZ_USART_FIFO WifiRxFifo; + +extern int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len); +extern int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len); +extern void esp_port_begin(uint8_t interrupt); +extern int usartFifoAvailable(SZ_USART_FIFO *fifo); +extern void wifi_delay(int n); + +#define ARRAY_SIZE(a) sizeof(a) / sizeof((a)[0]) + +//typedef signed char bool; + +// ESP8266 command codes +const uint8_t ESP_FLASH_BEGIN = 0x02; +const uint8_t ESP_FLASH_DATA = 0x03; +const uint8_t ESP_FLASH_END = 0x04; +const uint8_t ESP_MEM_BEGIN = 0x05; +const uint8_t ESP_MEM_END = 0x06; +const uint8_t ESP_MEM_DATA = 0x07; +const uint8_t ESP_SYNC = 0x08; +const uint8_t ESP_WRITE_REG = 0x09; +const uint8_t ESP_READ_REG = 0x0a; + +// MAC address storage locations +const uint32_t ESP_OTP_MAC0 = 0x3ff00050; +const uint32_t ESP_OTP_MAC1 = 0x3ff00054; +const uint32_t ESP_OTP_MAC2 = 0x3ff00058; +const uint32_t ESP_OTP_MAC3 = 0x3ff0005c; + +const size_t EspFlashBlockSize = 0x0400; // 1K byte blocks + +const uint8_t ESP_IMAGE_MAGIC = 0xe9; +const uint8_t ESP_CHECKSUM_MAGIC = 0xef; + +const uint32_t ESP_ERASE_CHIP_ADDR = 0x40004984; // &SPIEraseChip +const uint32_t ESP_SEND_PACKET_ADDR = 0x40003c80; // &send_packet +const uint32_t ESP_SPI_READ_ADDR = 0x40004b1c; // &SPIRead +const uint32_t ESP_UNKNOWN_ADDR = 0x40001121; // not used +const uint32_t ESP_USER_DATA_RAM_ADDR = 0x3ffe8000; // &user data ram +const uint32_t ESP_IRAM_ADDR = 0x40100000; // instruction RAM +const uint32_t ESP_FLASH_ADDR = 0x40200000; // address of start of Flash +//const uint32_t ESP_FLASH_READ_STUB_BEGIN = IRAM_ADDR + 0x18; + +UPLOAD_STRUCT esp_upload; + +static const unsigned int retriesPerReset = 3; +static const uint32_t connectAttemptInterval = 50; +static const unsigned int percentToReportIncrement = 5; // how often we report % complete +static const uint32_t defaultTimeout = 500; +static const uint32_t eraseTimeout = 15000; +static const uint32_t blockWriteTimeout = 200; +static const uint32_t blockWriteInterval = 15; // 15ms is long enough, 10ms is mostly too short + +// Messages corresponding to result codes, should make sense when followed by " error" +const char *resultMessages[] = { + "no", + "timeout", + "comm write", + "connect", + "bad reply", + "file read", + "empty file", + "response header", + "slip frame", + "slip state", + "slip data" +}; + +// A note on baud rates. +// The ESP8266 supports 921600, 460800, 230400, 115200, 74880 and some lower baud rates. +// 921600b is not reliable because even though it sometimes succeeds in connecting, we get a bad response during uploading after a few blocks. +// Probably our UART ISR cannot receive bytes fast enough, perhaps because of the latency of the system tick ISR. +// 460800b doesn't always manage to connect, but if it does then uploading appears to be reliable. +// 230400b always manages to connect. +static const uint32_t uploadBaudRates[] = { 460800, 230400, 115200, 74880 }; + + + +signed char IsReady() { + return esp_upload.state == upload_idle; +} + + + + + +void uploadPort_write(const uint8_t *buf, size_t len) { + #if 0 + int i; + + for(i = 0; i < len; i++) { + while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); + + USART_SendData(USART1, *(buf + i)); + } + #endif +} + +char uploadPort_read() { + uint8_t retChar; + if (readUsartFifo(&WifiRxFifo, (int8_t *)&retChar, 1) == 1) + return retChar; + else + return 0; + +} + +int uploadPort_available() { + return usartFifoAvailable(&WifiRxFifo); +} + + +void uploadPort_begin() { + esp_port_begin(1); +} + +void uploadPort_close() { + + //WIFI_COM.end(); + //WIFI_COM.begin(115200, true); + + esp_port_begin(0); + +} + + +void flushInput() { + while (uploadPort_available() != 0) { + (void)uploadPort_read(); + //IWDG_ReloadCounter(); + } +} + +// Extract 1-4 bytes of a value in little-endian order from a buffer beginning at a specified offset +uint32_t getData(unsigned byteCnt, const uint8_t *buf, int ofst) { + uint32_t val = 0; + + if (buf && byteCnt) { + unsigned int shiftCnt = 0; + if (byteCnt > 4) + byteCnt = 4; + do{ + val |= (uint32_t)buf[ofst++] << shiftCnt; + shiftCnt += 8; + } while (--byteCnt); + } + return(val); +} + +// Put 1-4 bytes of a value in little-endian order into a buffer beginning at a specified offset. +void putData(uint32_t val, unsigned byteCnt, uint8_t *buf, int ofst) { + if (buf && byteCnt) { + if (byteCnt > 4) { + byteCnt = 4; + } + do { + buf[ofst++] = (uint8_t)(val & 0xff); + val >>= 8; + } while (--byteCnt); + } +} + +// Read a byte optionally performing SLIP decoding. The return values are: +// +// 2 - an escaped byte was read successfully +// 1 - a non-escaped byte was read successfully +// 0 - no data was available +// -1 - the value 0xc0 was encountered (shouldn't happen) +// -2 - a SLIP escape byte was found but the following byte wasn't available +// -3 - a SLIP escape byte was followed by an invalid byte +int ReadByte(uint8_t *data, signed char slipDecode) { + if (uploadPort_available() == 0) { + return(0); + } + + // at least one byte is available + *data = uploadPort_read(); + if (!slipDecode) { + return(1); + } + + if (*data == 0xc0) { + // this shouldn't happen + return(-1); + } + + // if not the SLIP escape, we're done + if (*data != 0xdb) { + return(1); + } + + // SLIP escape, check availability of subsequent byte + if (uploadPort_available() == 0) { + return(-2); + } + + // process the escaped byte + *data = uploadPort_read(); + if (*data == 0xdc) { + *data = 0xc0; + return(2); + } + + if (*data == 0xdd) { + *data = 0xdb; + return(2); + } + // invalid + return(-3); +} +// When we write a sync packet, there must be no gaps between most of the characters. +// So use this function, which does a block write to the UART buffer in the latest CoreNG. +void _writePacketRaw(const uint8_t *buf, size_t len) { + uploadPort_write(buf, len); +} + +// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written. +void WriteByteRaw(uint8_t b) { + uploadPort_write((const uint8_t *)&b, 1); +} + +// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written. +void WriteByteSlip(uint8_t b) { + if (b == 0xC0) { + WriteByteRaw(0xDB); + WriteByteRaw(0xDC); + } + else if (b == 0xDB) { + WriteByteRaw(0xDB); + WriteByteRaw(0xDD); + } + else { + uploadPort_write((const uint8_t *)&b, 1); + } +} + +// Wait for a data packet to be returned. If the body of the packet is +// non-zero length, return an allocated buffer indirectly containing the +// data and return the data length. Note that if the pointer for returning +// the data buffer is NULL, the response is expected to be two bytes of zero. +// +// If an error occurs, return a negative value. Otherwise, return the number +// of bytes in the response (or zero if the response was not the standard "two bytes of zero"). +EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t msTimeout) { + typedef enum { + begin = 0, + header, + body, + end, + done + } PacketState; + + uint8_t resp, opRet; + + const size_t headerLength = 8; + + uint32_t startTime = getWifiTick(); + uint8_t hdr[headerLength]; + uint16_t hdrIdx = 0; + + uint16_t bodyIdx = 0; + uint8_t respBuf[2]; + + // wait for the response + uint16_t needBytes = 1; + + PacketState state = begin; + + *bodyLen = 0; + + + while (state != done) { + uint8_t c; + EspUploadResult stat; + + //IWDG_ReloadCounter(); + + if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout) { + return(timeout); + } + + if (uploadPort_available() < needBytes) { + // insufficient data available + // preferably, return to Spin() here + continue; + } + + // sufficient bytes have been received for the current state, process them + switch(state) { + case begin: // expecting frame start + c = uploadPort_read(); + if (c != (uint8_t)0xc0) { + break; + } + state = header; + needBytes = 2; + + break; + case end: // expecting frame end + c = uploadPort_read(); + if (c != (uint8_t)0xc0) { + return slipFrame; + } + state = done; + + break; + + case header: // reading an 8-byte header + case body: // reading the response body + { + int rslt; + // retrieve a byte with SLIP decoding + rslt = ReadByte(&c, 1); + if (rslt != 1 && rslt != 2) { + // some error occurred + stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame; + return stat; + } + else if (state == header) { + //store the header byte + hdr[hdrIdx++] = c; + if (hdrIdx >= headerLength) { + // get the body length, prepare a buffer for it + *bodyLen = (uint16_t)getData(2, hdr, 2); + + // extract the value, if requested + if (valp != 0) { + *valp = getData(4, hdr, 4); + } + + if (*bodyLen != 0) { + state = body; + } + else { + needBytes = 1; + state = end; + } + } + } + else { + // Store the response body byte, check for completion + if (bodyIdx < ARRAY_SIZE(respBuf)) { + respBuf[bodyIdx] = c; + } + ++bodyIdx; + if (bodyIdx >= *bodyLen) { + needBytes = 1; + state = end; + } + } + } + break; + + default: // this shouldn't happen + return slipState; + } + } + + // Extract elements from the header + resp = (uint8_t)getData(1, hdr, 0); + opRet = (uint8_t)getData(1, hdr, 1); + // Sync packets often provoke a response with a zero opcode instead of ESP_SYNC + if (resp != 0x01 || opRet != op) { +//debug//printf("resp %02x %02x\n", resp, opRet); + return respHeader; + } + + return success; +} + +// Send a block of data performing SLIP encoding of the content. +void _writePacket(const uint8_t *data, size_t len) { + unsigned char outBuf[2048] = {0}; + unsigned int outIndex = 0; + while (len != 0) { + if (*data == 0xC0) { + outBuf[outIndex++] = 0xDB; + outBuf[outIndex++] = 0xDC; + } + else if (*data == 0xDB) { + outBuf[outIndex++] = 0xDB; + outBuf[outIndex++] = 0xDD; + } + else { + outBuf[outIndex++] = *data; + + } + data++; + --len; + } + uploadPort_write((const uint8_t *)outBuf, outIndex); +} + +// Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block. +// A SLIP packet begins and ends with 0xc0. The data encapsulated has the bytes +// 0xc0 and 0xdb replaced by the two-byte sequences {0xdb, 0xdc} and {0xdb, 0xdd} respectively. + +void writePacket(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) { + + WriteByteRaw(0xc0); // send the packet start character + _writePacket(hdr, hdrLen); // send the header + _writePacket(data, dataLen); // send the data block + WriteByteRaw(0xc0); // send the packet end character +} + +// Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block. +// This is like writePacket except that it does a fast block write for both the header and the main data with no SLIP encoding. Used to send sync commands. +void writePacketRaw(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) { + WriteByteRaw(0xc0); // send the packet start character + _writePacketRaw(hdr, hdrLen); // send the header + _writePacketRaw(data, dataLen); // send the data block in raw mode + WriteByteRaw(0xc0); // send the packet end character +} + +// Send a command to the attached device together with the supplied data, if any. +// The data is supplied via a list of one or more segments. +void sendCommand(uint8_t op, uint32_t checkVal, const uint8_t *data, size_t dataLen) { + // populate the header + uint8_t hdr[8]; + putData(0, 1, hdr, 0); + putData(op, 1, hdr, 1); + putData(dataLen, 2, hdr, 2); + putData(checkVal, 4, hdr, 4); + + // send the packet + //flushInput(); + if (op == ESP_SYNC) { + writePacketRaw(hdr, sizeof(hdr), data, dataLen); + } + else { + writePacket(hdr, sizeof(hdr), data, dataLen); + } +} + +// Send a command to the attached device together with the supplied data, if any, and get the response +EspUploadResult doCommand(uint8_t op, const uint8_t *data, size_t dataLen, uint32_t checkVal, uint32_t *valp, uint32_t msTimeout) { + size_t bodyLen; + EspUploadResult stat; + + sendCommand(op, checkVal, data, dataLen); + + stat = readPacket(op, valp, &bodyLen, msTimeout); + if (stat == success && bodyLen != 2) { + stat = badReply; + } + + return stat; +} + +// Send a synchronising packet to the serial port in an attempt to induce +// the ESP8266 to auto-baud lock on the baud rate. +EspUploadResult Sync(uint16_t timeout) { + uint8_t buf[36]; + EspUploadResult stat; + int i ; + + // compose the data for the sync attempt + memset(buf, 0x55, sizeof(buf)); + buf[0] = 0x07; + buf[1] = 0x07; + buf[2] = 0x12; + buf[3] = 0x20; + + stat = doCommand(ESP_SYNC, buf, sizeof(buf), 0, 0, timeout); + + // If we got a response other than sync, discard it and wait for a sync response. This happens at higher baud rates. + for (i = 0; i < 10 && stat == respHeader; ++i) { + size_t bodyLen; + stat = readPacket(ESP_SYNC, 0, &bodyLen, timeout); + } + + if (stat == success) { + // Read and discard additional replies + for (;;) { + size_t bodyLen; + EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout); + if (rc != success || bodyLen != 2) { + break; + } + } + } + //DEBUG + //else debug//printf("stat=%d\n", (int)stat); + return stat; +} + +// Send a command to the device to begin the Flash process. +EspUploadResult flashBegin(uint32_t addr, uint32_t size) { + // determine the number of blocks represented by the size + uint32_t blkCnt; + uint8_t buf[16]; + uint32_t timeout; + + blkCnt = (size + EspFlashBlockSize - 1) / EspFlashBlockSize; + + // ensure that the address is on a block boundary + addr &= ~(EspFlashBlockSize - 1); + + // begin the Flash process + putData(size, 4, buf, 0); + putData(blkCnt, 4, buf, 4); + putData(EspFlashBlockSize, 4, buf, 8); + putData(addr, 4, buf, 12); + + timeout = (size != 0) ? eraseTimeout : defaultTimeout; + return doCommand(ESP_FLASH_BEGIN, buf, sizeof(buf), 0, 0, timeout); +} + +// Send a command to the device to terminate the Flash process +EspUploadResult flashFinish(signed char reboot) { + uint8_t buf[4]; + putData(reboot ? 0 : 1, 4, buf, 0); + return doCommand(ESP_FLASH_END, buf, sizeof(buf), 0, 0, defaultTimeout); +} + +// Compute the checksum of a block of data +uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) { + if (data != NULL) { + while (dataLen--) { + cksum ^= (uint16_t)*data++; + } + } + return(cksum); +} + +EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) { + #if 0 + const uint32_t blkSize = EspFlashBlockSize; + int i; + + // Allocate a data buffer for the combined header and block data + const uint16_t hdrOfst = 0; + const uint16_t dataOfst = 16; + const uint16_t blkBufSize = dataOfst + blkSize; + uint32_t blkBuf32[blkBufSize/4]; + uint8_t * const blkBuf = (uint8_t*)(blkBuf32); + uint32_t cnt; + uint16_t cksum; + EspUploadResult stat; + + // Prepare the header for the block + putData(blkSize, 4, blkBuf, hdrOfst + 0); + putData(esp_upload.uploadBlockNumber, 4, blkBuf, hdrOfst + 4); + putData(0, 4, blkBuf, hdrOfst + 8); + putData(0, 4, blkBuf, hdrOfst + 12); + + // Get the data for the block + f_read(&esp_upload.uploadFile, blkBuf + dataOfst, blkSize, &cnt );//->Read(reinterpret_cast(blkBuf + dataOfst), blkSize); + if (cnt != blkSize) { + if (f_tell(&esp_upload.uploadFile) == esp_upload.fileSize) { + // partial last block, fill the remainder + memset(blkBuf + dataOfst + cnt, 0xff, blkSize - cnt); + } + else { + return fileRead; + } + } + + // Patch the flash parameters into the first block if it is loaded at address 0 + if (esp_upload.uploadBlockNumber == 0 && esp_upload.uploadAddress == 0 && blkBuf[dataOfst] == ESP_IMAGE_MAGIC && flashParmMask != 0) { + // update the Flash parameters + uint32_t flashParm = getData(2, blkBuf + dataOfst + 2, 0) & ~(uint32_t)flashParmMask; + putData(flashParm | flashParmVal, 2, blkBuf + dataOfst + 2, 0); + } + + // Calculate the block checksum + cksum = checksum(blkBuf + dataOfst, blkSize, ESP_CHECKSUM_MAGIC); + + for (i = 0; i < 3; i++) { + if ((stat = doCommand(ESP_FLASH_DATA, blkBuf, blkBufSize, cksum, 0, blockWriteTimeout)) == success) { + break; + } + } + + //printf("Upload %d\%\n", ftell(&esp_upload.uploadFile) * 100 / esp_upload.fileSize); + + return stat; + #endif +} + +void upload_spin() { + #if 0 + switch (esp_upload.state) { + case resetting: + + if (esp_upload.connectAttemptNumber == 9) { + // Time to give up + //Network::ResetWiFi(); + esp_upload.uploadResult = connected; + esp_upload.state = done; + } + else{ + + // Reset the serial port at the new baud rate. Also reset the ESP8266. + // const uint32_t baud = uploadBaudRates[esp_upload.connectAttemptNumber/esp_upload.retriesPerBaudRate]; + if (esp_upload.connectAttemptNumber % esp_upload.retriesPerBaudRate == 0) { + } + // uploadPort.begin(baud); + // uploadPort_close(); + + + uploadPort_begin(); + + wifi_delay(2000); + + flushInput(); + + esp_upload.lastAttemptTime = esp_upload.lastResetTime = getWifiTick(); + esp_upload.state = connecting; + } + + break; + + case connecting: + if ((getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= connectAttemptInterval) && (getWifiTickDiff(esp_upload.lastResetTime, getWifiTick()) >= 500)) { + // Attempt to establish a connection to the ESP8266. + EspUploadResult res = Sync(5000); + esp_upload.lastAttemptTime = getWifiTick(); + if (res == success) { + // Successful connection +// //MessageF(" success on attempt %d\n", (connectAttemptNumber % retriesPerBaudRate) + 1); + //printf("connect success\n"); + esp_upload.state = erasing; + } + else { + // This attempt failed + esp_upload.connectAttemptNumber++; + if (esp_upload.connectAttemptNumber % retriesPerReset == 0) { + esp_upload.state = resetting; // try a reset and a lower baud rate + } + } + } + break; + + case erasing: + if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= blockWriteInterval) { + uint32_t eraseSize; + const uint32_t sectorsPerBlock = 16; + const uint32_t sectorSize = 4096; + const uint32_t numSectors = (esp_upload.fileSize + sectorSize - 1)/sectorSize; + const uint32_t startSector = esp_upload.uploadAddress/sectorSize; + uint32_t headSectors = sectorsPerBlock - (startSector % sectorsPerBlock); + + if (numSectors < headSectors) { + headSectors = numSectors; + } + eraseSize = (numSectors < 2 * headSectors) + ? (numSectors + 1) / 2 * sectorSize + : (numSectors - headSectors) * sectorSize; + + //MessageF("Erasing %u bytes...\n", fileSize); + esp_upload.uploadResult = flashBegin(esp_upload.uploadAddress, eraseSize); + if (esp_upload.uploadResult == success) { + //MessageF("Uploading file...\n"); + esp_upload.uploadBlockNumber = 0; + esp_upload.uploadNextPercentToReport = percentToReportIncrement; + esp_upload.lastAttemptTime = getWifiTick(); + esp_upload.state = uploading; + } + else { + //MessageF("Erase failed\n"); + esp_upload.state = done; + } + } + break; + + case uploading: + // The ESP needs several milliseconds to recover from one packet before it will accept another + if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= 15) { + unsigned int percentComplete; + const uint32_t blkCnt = (esp_upload.fileSize + EspFlashBlockSize - 1) / EspFlashBlockSize; + if (esp_upload.uploadBlockNumber < blkCnt) { + esp_upload.uploadResult = flashWriteBlock(0, 0); + esp_upload.lastAttemptTime = getWifiTick(); + if (esp_upload.uploadResult != success) { + //MessageF("Flash block upload failed\n"); + esp_upload.state = done; + } + percentComplete = (100 * esp_upload.uploadBlockNumber)/blkCnt; + ++esp_upload.uploadBlockNumber; + if (percentComplete >= esp_upload.uploadNextPercentToReport) { + //MessageF("%u%% complete\n", percentComplete); + esp_upload.uploadNextPercentToReport += percentToReportIncrement; + } + } + else { + esp_upload.state = done; + } + } + break; + + case done: + f_close(&esp_upload.uploadFile); + //uploadPort.end(); + //uploadPort_close(); + + //WIFI_COM.begin(115200, true); + //wifi_init(); + + if (esp_upload.uploadResult == success) { + //printf("upload successfully\n"); + } + else { + //printf("upload failed\n"); + } + esp_upload.state = upload_idle;//idle; + break; + + default: + break; + } + #endif +} + +// Try to upload the given file at the given address +void SendUpdateFile(const char *file, uint32_t address) { + #if 0 + FRESULT res = f_open(&esp_upload.uploadFile, file, FA_OPEN_EXISTING | FA_READ); + + if (res != FR_OK) return; + + esp_upload.fileSize = f_size(&esp_upload.uploadFile); + if (esp_upload.fileSize == 0) { + f_close(&esp_upload.uploadFile); + return; + } + f_lseek(&esp_upload.uploadFile, 0); + + esp_upload.uploadAddress = address; + esp_upload.connectAttemptNumber = 0; + esp_upload.state = resetting; + #endif +} + +static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000; + +void ResetWiFiForUpload(int begin_or_end) { + #if 0 + uint32_t start, now; + + GPIO_InitTypeDef GPIO_InitStructure; + + #if V1_0_V1_1 + GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStructure.Pin = GPIO_Pin_8; + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; + HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); + #else + GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStructure.Pin = GPIO_Pin_13; + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; + HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); + #endif + start = getWifiTick(); + now = start; + + if (begin_or_end == 0) { + #if V1_0_V1_1 + HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_RESET); //update mode + #else + HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_RESET); //update mode + #endif + } + else { + #if V1_0_V1_1 + #if V1_0_V1_1 + HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_SET); //boot mode + GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStructure.Pin = GPIO_Pin_8; + GPIO_InitStructure.Mode = GPIO_MODE_INPUT; + HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); + #endif + #else + HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_SET); //boot mode + GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStructure.Pin = GPIO_Pin_13; + GPIO_InitStructure.Mode = GPIO_MODE_INPUT; + HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); + #endif + } + WIFI_RESET(); + while (getWifiTickDiff(start, now) < 500) now = getWifiTick(); + WIFI_SET(); + #endif +} + +int32_t wifi_upload(int type) { + esp_upload.retriesPerBaudRate = 9; + + ResetWiFiForUpload(0); + + if (type == 0) + SendUpdateFile(ESP_FIRMWARE_FILE, FirmwareAddress); + else if (type == 1) + SendUpdateFile(ESP_WEB_FIRMWARE_FILE, FirmwareAddress); + else if (type == 2) + SendUpdateFile(ESP_WEB_FILE, WebFilesAddress); + else + return -1; + + while (esp_upload.state != upload_idle) { + upload_spin(); + //IWDG_ReloadCounter(); + } + + ResetWiFiForUpload(1); + + return esp_upload.uploadResult == success ? 0 : -1; +} + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h new file mode 100644 index 000000000000..d942a2c84f80 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h @@ -0,0 +1,74 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +#define ESP_FIRMWARE_FILE "1:/MksWifi.bin" +#define ESP_WEB_FIRMWARE_FILE "1:/MksWifi_Web.bin" +#define ESP_WEB_FILE "1:/MksWifi_WebView.bin" + +typedef enum { + upload_idle, + resetting, + connecting, + erasing, + uploading, + done +} UploadState; + +typedef enum { + success = 0, + timeout, + connected, + badReply, + fileRead, + emptyFile, + respHeader, + slipFrame, + slipState, + slipData, +} EspUploadResult; + +typedef struct { + //FIL uploadFile; + uint32_t fileSize; + + uint32_t uploadAddress; + UploadState state; + uint32_t retriesPerBaudRate; + uint32_t connectAttemptNumber; + uint32_t lastAttemptTime; + uint32_t lastResetTime; + uint32_t uploadBlockNumber; + uint32_t uploadNextPercentToReport; + EspUploadResult uploadResult; +} UPLOAD_STRUCT; + +extern UPLOAD_STRUCT esp_upload; +int32_t wifi_upload(int type); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index f83142444a49..da38192d8ea3 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -253,6 +253,13 @@ class Stepper { static bool initialized; #endif + // Last-moved extruder, as set when the last movement was fetched from planner + #if HAS_MULTI_EXTRUDER + static uint8_t last_moved_extruder; + #else + static constexpr uint8_t last_moved_extruder = 0; + #endif + private: static block_t* current_block; // A pointer to the block currently being traced @@ -262,13 +269,6 @@ class Stepper { static bool abort_current_block; // Signals to the stepper that current block should be aborted - // Last-moved extruder, as set when the last movement was fetched from planner - #if HAS_MULTI_EXTRUDER - static uint8_t last_moved_extruder; - #else - static constexpr uint8_t last_moved_extruder = 0; - #endif - #if ENABLED(X_DUAL_ENDSTOPS) static bool locked_X_motor, locked_X2_motor; #endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index d07d36339934..3908a243ce15 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -526,6 +526,8 @@ #include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3 #elif MB(MKS_ROBIN_E3D) #include "stm32f1/pins_MKS_ROBIN_E3D.h" // STM32F1 env:mks_robin_e3 +#elif MB(MKS_ROBIN_E3P) + #include "stm32f1/pins_MKS_ROBIN_E3P.h" // STM32F1 env:mks_robin_e3p #elif MB(BTT_SKR_MINI_V1_1) #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB #elif MB(BTT_SKR_MINI_E3_V1_0) diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h new file mode 100644 index 000000000000..3f4dee0f6895 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -0,0 +1,377 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +/** + * MKS Robin nano (STM32F130VET6) board pin assignments + */ + +#ifndef __STM32F1__ + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" +#elif HOTENDS > 1 || E_STEPPERS > 1 + #error "MKS Robin e3p supports up to 1 hotends / E-steppers. Comment out this line to continue." +#elif HAS_FSMC_TFT + #error "MKS Robin e3p doesn't support FSMC-based TFT displays." +#endif + +#define BOARD_INFO_NAME "MKS Robin e3p" + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// + +#define DISABLE_DEBUG + +// +// EEPROM +// +//#define FLASH_EEPROM_EMULATION +//#define SDCARD_EEPROM_EMULATION + +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #define I2C_EEPROM // EEPROM on I2C-0 + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// +// Note: MKS Robin board is using SPI2 interface. +// +//#define SPI_MODULE 2 +#define ENABLE_SPI2 + +// +// Limit Switches +// +#define X_DIAG_PIN PA15 +#define Y_DIAG_PIN PA12 +#define Z_DIAG_PIN PA11 +#define E0_DIAG_PIN PC4 + +#define X_STOP_PIN PA15 +#define Y_STOP_PIN PA12 +#define Z_MIN_PIN PA11 +#define Z_MAX_PIN PC4 + +// +// Steppers +// +#define X_ENABLE_PIN PE4 +#define X_STEP_PIN PE3 +#define X_DIR_PIN PE2 +#ifndef X_CS_PIN + #define X_CS_PIN PD5 +#endif + +#define Y_ENABLE_PIN PE1 +#define Y_STEP_PIN PE0 +#define Y_DIR_PIN PB9 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD7 +#endif + +#define Z_ENABLE_PIN PB8 +#define Z_STEP_PIN PB5 +#define Z_DIR_PIN PB4 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD4 +#endif + +#define E0_ENABLE_PIN PB3 +#define E0_STEP_PIN PD6 +#define E0_DIR_PIN PD3 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD9 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PD14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PD1 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PD0 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + + #define X_SERIAL_TX_PIN PD5 + #define X_SERIAL_RX_PIN PD5 + + #define Y_SERIAL_TX_PIN PD7 + #define Y_SERIAL_RX_PIN PD7 + + #define Z_SERIAL_TX_PIN PD4 + #define Z_SERIAL_RX_PIN PD4 + + #define E0_SERIAL_TX_PIN PD9 + #define E0_SERIAL_RX_PIN PD9 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif // TMC2208 || TMC2209 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC1 // TH1 +#define TEMP_BED_PIN PC0 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC3 // HEATER1 +#define HEATER_BED_PIN PA0 // HOT BED + +#define FAN_PIN PB1 // FAN + +// +// Misc. Functions +// +#if HAS_TFT_LVGL_UI + //#define MKSPWC + #ifdef MKSPWC + #define SUICIDE_PIN PB2 // Enable MKSPWC SUICIDE PIN + #define SUICIDE_PIN_INVERTING false // Enable MKSPWC PIN STATE + #define KILL_PIN PA2 // Enable MKSPWC DET PIN + #define KILL_PIN_STATE true // Enable MKSPWC PIN STATE + #endif + + #define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN + #define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE + + #define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN + + #if ENABLED(MKS_TEST) + #define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET + #define MKS_TEST_PS_ON_PIN PB0 // PW_OFF + #endif +#else + //#define POWER_LOSS_PIN PA2 // PW_DET + //#define PS_ON_PIN PB2 // PW_OFF + #define FIL_RUNOUT_PIN PA4 +#endif + +#define SERVO0_PIN PA8 // Enable BLTOUCH + +//#define LED_PIN PB2 + +// +// SD Card +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define SDIO_SUPPORT +#define SDIO_CLOCK 4500000 // 4.5 MHz +#define SD_DETECT_PIN PD12 +#define ONBOARD_SD_CS_PIN PC11 + +// +// LCD / Controller +// +#ifndef BEEPER_PIN + #define BEEPER_PIN PC5 +#endif + +/** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'LCD_RESET_PIN' + * to let the bootloader init the screen. + */ + +#if HAS_SPI_TFT + + // Shared SPI TFT + + #define LCD_BACKLIGHT_PIN PD13 + + #define TOUCH_CS_PIN PE14 // SPI1_NSS + #define TOUCH_SCK_PIN PA5 // SPI1_SCK + #define TOUCH_MISO_PIN PA6 // SPI1_MISO + #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI + + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 + #define BTN_ENC PE13 + + #define TFT_CS_PIN PD11 + #define TFT_SCK_PIN PA5 + #define TFT_MISO_PIN PA6 + #define TFT_MOSI_PIN PA7 + #define TFT_DC_PIN PD10 + #define TFT_RST_PIN PC6 + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN PC6 + #define TFT_BACKLIGHT_PIN PD13 + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + + #ifndef TFT_WIDTH + #define TFT_WIDTH 480 + #endif + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 320 + #endif + + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI + +#endif + +#if ENABLED(TFT_LVGL_UI_SPI) + + // LVGL + + #define XPT2046_X_CALIBRATION -17253 + #define XPT2046_Y_CALIBRATION 11579 + #define XPT2046_X_OFFSET 514 + #define XPT2046_Y_OFFSET -24 + +#elif ENABLED(SPI_GRAPHICAL_TFT) + + // Emulated DOGM SPI + + #ifndef XPT2046_X_CALIBRATION + #define XPT2046_X_CALIBRATION -11386 + #endif + #ifndef XPT2046_Y_CALIBRATION + #define XPT2046_Y_CALIBRATION 8684 + #endif + #ifndef XPT2046_X_OFFSET + #define XPT2046_X_OFFSET 339 + #endif + #ifndef XPT2046_Y_OFFSET + #define XPT2046_Y_OFFSET -18 + #endif + + #ifndef GRAPHICAL_TFT_UPSCALE + #define GRAPHICAL_TFT_UPSCALE 3 + #endif + #ifndef TFT_PIXEL_OFFSET_Y + #define TFT_PIXEL_OFFSET_Y 32 + #endif + + #define BTN_ENC PE13 + #define BTN_EN1 PE8 + #define BTN_EN2 PE11 + + #define LCD_PINS_ENABLE PD13 + #define LCD_PINS_RS PC6 + +#elif ENABLED(TFT_480x320_SPI) + #define XPT2046_X_CALIBRATION -17253 + #define XPT2046_Y_CALIBRATION 11579 + #define XPT2046_X_OFFSET 514 + #define XPT2046_Y_OFFSET -24 + + #define TFT_DRIVER ST7796 + #define TFT_BUFFER_SIZE 14400 + +#endif + +#if HAS_SPI_LCD && !HAS_SPI_TFT + + // NON TFT Displays + + #if ENABLED(MKS_MINI_12864) + + // MKS MINI12864 and MKS LCD12864B + // If using MKS LCD12864A (Need to remove RPK2 resistor) + + #define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN -1 + #define DOGLCD_A0 PD11 + #define DOGLCD_CS PE15 + #define DOGLCD_SCK PA5 + #define DOGLCD_MOSI PA7 + + // Required for MKS_MINI_12864 with this board + #define MKS_LCD12864B + #undef SHOW_BOOTSCREEN + + #else // !MKS_MINI_12864 + + #define LCD_PINS_D4 PE14 + #if ENABLED(ULTIPANEL) + #define LCD_PINS_D5 PE15 + #define LCD_PINS_D6 PD11 + #define LCD_PINS_D7 PD10 + #endif + + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(125) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(125) + #endif + + #endif // !MKS_MINI_12864 + +#endif // HAS_SPI_LCD && !HAS_SPI_TFT + +#define HAS_SPI_FLASH 1 +#define SPI_FLASH_SIZE 0x1000000 // 16MB +#if HAS_SPI_FLASH + #define W25QXX_CS_PIN PB12 + #define W25QXX_MOSI_PIN PB15 + #define W25QXX_MISO_PIN PB14 + #define W25QXX_SCK_PIN PB13 +#endif + +#if ENABLED(SPEAKER) && BEEPER_PIN == PC5 + #error "MKS Robin nano default BEEPER_PIN is not a SPEAKER." +#endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index c3e8be74e8c2..88333e9b9f7a 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -58,10 +58,6 @@ #define Z_MIN_PIN PA11 #define Z_MAX_PIN PC4 -#ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN PA4 // MT_DET -#endif - // // Steppers // @@ -123,25 +119,33 @@ // // Misc. Functions // -#define POWER_LOSS_PIN PA2 // PW_DET -#define PS_ON_PIN PA3 // PW_OFF +#if HAS_TFT_LVGL_UI + //#define MKSPWC + #ifdef MKSPWC + #define SUICIDE_PIN PB2 // Enable MKSPWC SUICIDE PIN + #define SUICIDE_PIN_INVERTING false // Enable MKSPWC PIN STATE + #define KILL_PIN PA2 // Enable MKSPWC DET PIN + #define KILL_PIN_STATE true // Enable MKSPWC PIN STATE + #endif -//#define SUICIDE_PIN PB2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY -//#define SUICIDE_PIN_INVERTING false + #define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN + #define MT_DET_2_PIN PE6 // LVGL UI FILAMENT RUNOUT2 PIN + #define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE -//#define KILL_PIN PA2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY -//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY + #define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PA5 // MKS ESP WIFI RESET PIN +#else + //#define POWER_LOSS_PIN PA2 // PW_DET + //#define PS_ON_PIN PB2 // PW_OFF + #define FIL_RUNOUT_PIN PA4 + #define FIL_RUNOUT2_PIN PE6 +#endif -#define SERVO0_PIN PA8 // Enable BLTOUCH support ROBIN NANO v1.2 ONLY +#define SERVO0_PIN PA8 // Enable BLTOUCH support //#define LED_PIN PB2 -#define MT_DET_1_PIN PA4 -#define MT_DET_2_PIN PE6 -#define MT_DET_PIN_INVERTING false - -#define WIFI_IO0_PIN PC13 - // // SD Card // diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index f9652f39348b..01415d7bf0e2 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -192,32 +192,38 @@ // // Misc. Functions // -#define POWER_LOSS_PIN PA2 // PW_DET -#define PS_ON_PIN PA3 // PW_OFF - -//#define SUICIDE_PIN PB2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY -//#define SUICIDE_PIN_INVERTING false +#if HAS_TFT_LVGL_UI + //#define MKSPWC + #ifdef MKSPWC + #define SUICIDE_PIN PB2 // Enable MKSPWC SUICIDE PIN + #define SUICIDE_PIN_INVERTING false // Enable MKSPWC PIN STATE + #define KILL_PIN PA2 // Enable MKSPWC DET PIN + #define KILL_PIN_STATE true // Enable MKSPWC PIN STATE + #endif -//#define KILL_PIN PA2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY -//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY + #define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN + #define MT_DET_2_PIN PE6 // LVGL UI FILAMENT RUNOUT2 PIN + #define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE + + #define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN + + #if ENABLED(MKS_TEST) + #define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET + #define MKS_TEST_PS_ON_PIN PB2 // PW_OFF + #endif +#else + //#define POWER_LOSS_PIN PA2 // PW_DET + //#define PS_ON_PIN PB2 // PW_OFF + #define FIL_RUNOUT_PIN PA4 + #define FIL_RUNOUT2_PIN PE6 +#endif -#define SERVO0_PIN PA8 // Enable BLTOUCH support ROBIN NANO v1.2 ONLY +#define SERVO0_PIN PA8 // Enable BLTOUCH //#define LED_PIN PB2 -#define MT_DET_1_PIN PA4 -#define MT_DET_2_PIN PE6 -#define MT_DET_PIN_INVERTING false - -#ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN MT_DET_1_PIN -#endif -#ifndef FIL_RUNOUT2_PIN - #define FIL_RUNOUT2_PIN MT_DET_2_PIN -#endif - -#define WIFI_IO0_PIN PC13 - // // SD Card // diff --git a/buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld b/buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld new file mode 100644 index 000000000000..d8a138ca2e25 --- /dev/null +++ b/buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld @@ -0,0 +1,14 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40 + rom (rx) : ORIGIN = 0x08007000, LENGTH = 512K - 28K - 4K +} + +/* Provide memory region aliases for common.inc */ +REGION_ALIAS("REGION_TEXT", rom); +REGION_ALIAS("REGION_DATA", ram); +REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", rom); + +/* Let common.inc handle the real work. */ +INCLUDE common.inc diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py new file mode 100644 index 000000000000..2aab14bab788 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py @@ -0,0 +1,40 @@ +import os +Import("env") + +# Relocate firmware from 0x08000000 to 0x08007000 +for define in env['CPPDEFINES']: + if define[0] == "VECT_TAB_ADDR": + env['CPPDEFINES'].remove(define) +env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) + +custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld") +for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,-T" in flag: + env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script + elif flag == "-T": + env["LINKFLAGS"][i + 1] = custom_ld_script + + +# Encrypt ${PROGNAME}.bin and save it as 'mks_robin_e3p.bin' +def encrypt(source, target, env): + import sys + + key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] + + firmware = open(target[0].path, "rb") + robin = open(target[0].dir.path +'/Robin_e3p.bin', "wb") + length = os.path.getsize(target[0].path) + position = 0 + try: + while position < length: + byte = firmware.read(1) + if position >= 320 and position < 31040: + byte = chr(ord(byte) ^ key[position & 31]) + if sys.version_info[0] > 2: + byte = bytes(byte, 'latin1') + robin.write(byte) + position += 1 + finally: + firmware.close() + robin.close() +env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); diff --git a/platformio.ini b/platformio.ini index bf43936df682..c1b6f2c24d70 100644 --- a/platformio.ini +++ b/platformio.ini @@ -191,7 +191,7 @@ lib_deps = # Feature Dependencies # [features] -HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/MKS-LittlevGL/archive/master.zip +HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip src_filter=+ extra_scripts=download_mks_assets.py HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.1 @@ -955,6 +955,22 @@ extra_scripts = ${common.extra_scripts} build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 +# +# MKS Robin E3p (STM32F103VET6) +# - LVGL UI +# +[env:mks_robin_e3p] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103VE +platform_packages = tool-stm32duino +extra_scripts = ${common.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +build_flags = ${common_stm32f1.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 +debug_tool = jlink +upload_protocol = jlink + # # MKS Robin Lite/Lite2 (STM32F103RCT6) # From 0251eb85b2f2429dc3b1a7dd9bb3ed48472c8cbe Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Mon, 21 Sep 2020 05:29:34 +0200 Subject: [PATCH 28/63] Optional menu item for Assisted Tramming (#19447) --- Marlin/Configuration_adv.h | 5 +++-- Marlin/src/lcd/menu/menu_motion.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 23d39b4d0ad7..65cbd21a947b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -773,7 +773,6 @@ // //#define ASSISTED_TRAMMING #if ENABLED(ASSISTED_TRAMMING) - // Define positions for probing points, use the hotend as reference not the sensor. #define TRAMMING_POINT_XY { { 20, 20 }, { 200, 20 }, { 200, 200 }, { 20, 200 } } @@ -786,6 +785,9 @@ // Enable to restore leveling setup after operation #define RESTORE_LEVELING_AFTER_G35 + // Add a menu item for Assisted Tramming + //#define ASSISTED_TRAMMING_MENU_ITEM + /** * Screw thread: * M3: 30 = Clockwise, 31 = Counter-Clockwise @@ -793,7 +795,6 @@ * M5: 50 = Clockwise, 51 = Counter-Clockwise */ #define TRAMMING_SCREW_THREAD 30 - #endif // @section motion diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 77ab643cd652..9fea0597db5c 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -348,7 +348,7 @@ void menu_motion() { // // Assisted Bed Tramming // - #if ENABLED(ASSISTED_TRAMMING) + #if ENABLED(ASSISTED_TRAMMING_MENU_ITEM) GCODES_ITEM(MSG_ASSISTED_TRAMMING, PSTR("G35")); #endif From fb48cd0ab47f3ed981d4c74814e850ff7dcd13ba Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sun, 20 Sep 2020 20:30:20 -0700 Subject: [PATCH 29/63] Replace Serial with Serial1 in pins files (#19459) --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 2 +- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 2 +- Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h | 2 +- Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h | 2 +- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 2 +- Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h | 2 +- Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index fb1218068eb3..a38be0bef765 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -151,7 +151,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index 49c4dffa04ed..ce1372ed7a94 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -174,7 +174,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index 23558b2e0474..59d6a06cf423 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -153,7 +153,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h index d112cc5d5080..2d09fe1feae5 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -163,7 +163,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 01415d7bf0e2..d911ab2b517b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -132,7 +132,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index c00466677a25..9b3817df8c7b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -125,7 +125,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 55d1a37aa7f7..8cc1ca5e98b2 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -171,7 +171,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 9e6a43c36b9a..b45914284adf 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -178,7 +178,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h index fe6e559bdb8e..ab277d43722a 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h @@ -57,7 +57,7 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial + //#define X_HARDWARE_SERIAL Serial1 //#define X2_HARDWARE_SERIAL Serial1 //#define Y_HARDWARE_SERIAL Serial1 //#define Y2_HARDWARE_SERIAL Serial1 From 1bfc51ad5c79d19ad68cf7ae7b1175fc29741256 Mon Sep 17 00:00:00 2001 From: Chris Pepper Date: Mon, 21 Sep 2020 16:19:09 +0100 Subject: [PATCH 30/63] Update pins_ANET_10.h --- Marlin/src/pins/sanguino/pins_ANET_10.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/sanguino/pins_ANET_10.h b/Marlin/src/pins/sanguino/pins_ANET_10.h index 6830192f319b..d1ac131c0384 100644 --- a/Marlin/src/pins/sanguino/pins_ANET_10.h +++ b/Marlin/src/pins/sanguino/pins_ANET_10.h @@ -163,7 +163,7 @@ #define LCD_PINS_D6 16 #define LCD_PINS_D7 17 #define ADC_KEYPAD_PIN 1 - #elif EITHER(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) // Pin definitions for the Anet A6 Full Graphics display and the RepRapDiscount Full Graphics // display using an adapter board // https://go.aisler.net/benlye/anet-lcd-adapter/pcb // See below for alternative pin definitions for use with https://www.thingiverse.com/thing:2103748 From 47aa61c0ec4a4fe511bd7c629ce18d5ea8007da8 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 22 Sep 2020 00:13:24 +0000 Subject: [PATCH 31/63] [cron] Bump distribution date (2020-09-22) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index c1b57d136716..ac6ba4f22c40 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-21" + #define STRING_DISTRIBUTION_DATE "2020-09-22" #endif /** From 225487f9db7d1a7aaf6886a283c7758a9ae2181e Mon Sep 17 00:00:00 2001 From: riodoro1 Date: Tue, 22 Sep 2020 22:08:14 +0200 Subject: [PATCH 32/63] Fix up K8800 pins (#19476) --- Marlin/src/pins/ramps/pins_K8800.h | 61 ++++++++++++++++++------------ 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/Marlin/src/pins/ramps/pins_K8800.h b/Marlin/src/pins/ramps/pins_K8800.h index 2783f69896a5..64e3c2566082 100644 --- a/Marlin/src/pins/ramps/pins_K8800.h +++ b/Marlin/src/pins/ramps/pins_K8800.h @@ -39,8 +39,13 @@ // #define X_STOP_PIN 3 #define Y_STOP_PIN 14 -#define Z_MIN_PIN 68 // Used for bed leveling -#define Z_MAX_PIN 66 +#define Z_STOP_PIN 66 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 68 +#endif + +#define FIL_RUNOUT_PIN 69 // PK7 // // Steppers @@ -61,10 +66,6 @@ #define E0_DIR_PIN 28 #define E0_ENABLE_PIN 24 -#define E1_STEP_PIN 32 -#define E1_DIR_PIN 34 -#define E1_ENABLE_PIN 30 - // // Temperature Sensors // @@ -80,30 +81,42 @@ // // Misc. Functions // -#define SDSS 25 - -#define FIL_RUNOUT_PIN 69 // PK7 #define KILL_PIN 20 // PD1 +#define CASE_LIGHT_PIN 7 // -// LCD / Controller +// SD Card // +#define SDSS 25 #define SD_DETECT_PIN 21 // PD0 -#define LCD_SDSS 53 + +// +// LCD / Controller +// #define BEEPER_PIN 6 -#define DOGLCD_CS 29 -#define DOGLCD_A0 27 +#if HAS_SPI_LCD -#define LCD_PINS_RS 27 -#define LCD_PINS_ENABLE 29 -#define LCD_PINS_D4 37 -#define LCD_PINS_D5 35 -#define LCD_PINS_D6 33 -#define LCD_PINS_D7 31 + #define LCD_SDSS 53 -#if ENABLED(NEWPANEL) - #define BTN_EN1 17 - #define BTN_EN2 16 - #define BTN_ENC 23 -#endif + #define DOGLCD_CS 29 + #define DOGLCD_A0 27 + + #define LCD_PINS_RS 27 + #define LCD_PINS_ENABLE 29 + #define LCD_PINS_D4 37 + #define LCD_PINS_D5 35 + #define LCD_PINS_D6 33 + #define LCD_PINS_D7 31 + + #define LCD_CONTRAST_MIN 0 + #define LCD_CONTRAST_MAX 100 + #define DEFAULT_LCD_CONTRAST 30 + + #if ENABLED(NEWPANEL) + #define BTN_EN1 17 + #define BTN_EN2 16 + #define BTN_ENC 23 + #endif + +#endif // HAS_SPI_LCD From 79dc8a22976934e0c29495c16626650b87dba4d9 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Tue, 22 Sep 2020 17:44:17 -0300 Subject: [PATCH 33/63] Define ::softSPI (#19419) --- Marlin/src/module/temperature.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d2145bcc804a..f589140895b6 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1567,6 +1567,7 @@ void Temperature::updateTemperaturesFromRawValues() { } #if MAX6675_SEPARATE_SPI + template SoftSPI SPIclass::softSPI; SPIclass max6675_spi; #endif From 63e7ae793b9c56f69e5a3f4227ba1eb9164d712e Mon Sep 17 00:00:00 2001 From: makerbase <4164049@qq.com> Date: Wed, 23 Sep 2020 04:57:17 +0800 Subject: [PATCH 34/63] MKS SGEN L V2 adaptable heaters/fans (#19462) --- Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h index 2d09fe1feae5..b6f11a133daf 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -207,20 +207,20 @@ // #define HEATER_BED_PIN P2_05 #define HEATER_0_PIN P2_07 -#if HOTENDS == 1 - #ifndef FAN1_PIN - #define FAN1_PIN P2_06 - #endif -#else +#if HAS_MULTI_HOTEND #ifndef HEATER_1_PIN #define HEATER_1_PIN P2_06 #endif +#else + #ifndef FAN2_PIN + #define FAN2_PIN P2_06 // HE1 for FAN3 + #endif #endif #ifndef FAN_PIN - #define FAN_PIN P2_04 + #define FAN_PIN P2_04 // FAN1 #endif -#ifndef FAN2_PIN - #define FAN2_PIN P1_04 +#ifndef FAN1_PIN + #define FAN1_PIN P1_04 // FAN2 #endif // From d051c2adbd0b9c1bc91eee3628fd7c690d9f69ad Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 22 Sep 2020 15:36:59 -0700 Subject: [PATCH 35/63] Update board/teensy comment (#19456) --- .github/workflows/test-builds.yml | 1 + Marlin/src/core/boards.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index 35cd920adff8..b2287837998b 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -41,6 +41,7 @@ jobs: - mega2560 - teensy31 - teensy35 + - teensy41 - SAMD51_grandcentral_m4 # Extended AVR Environments diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 293c6a523076..e27448b0220b 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -359,8 +359,8 @@ #define BOARD_THE_BORG 5000 // THE-BORG (Power outputs: Hotend0, Hotend1, Bed, Fan) #define BOARD_REMRAM_V1 5001 // RemRam v1 -#define BOARD_TEENSY41 5002 // Teensy4.0 and Teensy4.1 -#define BOARD_T41U5XBB 5003 // T41U5XBB Teensy4.1 breakout board +#define BOARD_TEENSY41 5002 // Teensy 4.1 +#define BOARD_T41U5XBB 5003 // T41U5XBB Teensy 4.1 breakout board // // Espressif ESP32 WiFi From a87c517da5f0190cd3f892c9e72763bb1349b99c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Sep 2020 17:51:59 -0500 Subject: [PATCH 36/63] Fix Teensy 4.1 include --- Marlin/src/pins/pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 3908a243ce15..861810d95bb4 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -623,7 +623,7 @@ #include "stm32f7/pins_THE_BORG.h" // STM32F7 env:STM32F7 #elif MB(REMRAM_V1) #include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:STM32F7 -#elif MB(TEENSY40_41) +#elif MB(TEENSY41) #include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41 #elif MB(T41U5XBB) #include "teensy4/pins_T41U5XBB.h" // Teensy-4.x env:teensy41 From fd8cd31504e9ff81cbda525a80e21c4f9c486771 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 23 Sep 2020 00:13:17 +0000 Subject: [PATCH 37/63] [cron] Bump distribution date (2020-09-23) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index ac6ba4f22c40..f002ce563b9f 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-22" + #define STRING_DISTRIBUTION_DATE "2020-09-23" #endif /** From 5f5f76956f11c7c58278fd449f6ad85e07cd6e10 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Sep 2020 19:58:06 -0500 Subject: [PATCH 38/63] Fix up tests, warnings --- Marlin/src/gcode/calibrate/M48.cpp | 4 ++-- Marlin/src/lcd/extui/ui_api.cpp | 2 +- buildroot/tests/teensy41-tests | 13 +++++++------ platformio.ini | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index aaf58eed1c78..88273b46e46e 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -192,8 +192,8 @@ void GcodeSuite::M48() { // Choose the next position as an offset to chosen test position const xy_pos_t noz_pos = test_position - probe.offset_xy; xy_pos_t next_pos = { - noz_pos.x + cos(RADIANS(angle)) * radius, - noz_pos.y + sin(RADIANS(angle)) * radius + noz_pos.x + float(cos(RADIANS(angle))) * radius, + noz_pos.y + float(sin(RADIANS(angle))) * radius }; #if ENABLED(DELTA) diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index afc9c6692e00..1270e3d649f7 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -705,7 +705,7 @@ namespace ExtUI { #if ENABLED(BABYSTEP_ZPROBE_OFFSET) // Make it so babystepping in Z adjusts the Z probe offset. - if (axis == Z && TERN1(HAS_MULTI_EXTRUDER, linked_nozzles || active_extruder == 0)) + if (axis == Z && TERN1(HAS_MULTI_EXTRUDER, (linked_nozzles || active_extruder == 0))) probe.offset.z += mm; #endif diff --git a/buildroot/tests/teensy41-tests b/buildroot/tests/teensy41-tests index 04baf029d9cc..8d32d131e91c 100644 --- a/buildroot/tests/teensy41-tests +++ b/buildroot/tests/teensy41-tests @@ -19,14 +19,15 @@ opt_set EXTRUDERS 2 opt_set TEMP_SENSOR_0 1 opt_set TEMP_SENSOR_1 5 opt_set TEMP_SENSOR_BED 1 -opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \ - FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \ +opt_enable EXTENSIBLE_UI LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \ + FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \ FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ - BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \ - PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \ + BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET \ + PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \ ADVANCED_PAUSE_FEATURE ARC_SUPPORT BEZIER_CURVE_SUPPORT EXPERIMENTAL_I2CBUS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES PARK_HEAD_ON_PAUSE \ PHOTO_GCODE PHOTO_POSITION PHOTO_SWITCH_POSITION PHOTO_SWITCH_MS PHOTO_DELAY_MS PHOTO_RETRACT_MM \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT +opt_add EXTUI_EXAMPLE opt_set I2C_SLAVE_ADDRESS 63 opt_set GRID_MAX_POINTS_X 16 exec_test $1 $2 "Teensy4.1 with many features" @@ -62,7 +63,7 @@ restore_configs opt_set MOTHERBOARD BOARD_TEENSY41 opt_set EXTRUDERS 2 opt_set TEMP_SENSOR_1 1 -opt_enable MAGNETIC_PARKING_EXTRUDER ULTIMAKERCONTROLLER +opt_enable MAGNETIC_PARKING_EXTRUDER exec_test $1 $2 "MAGNETIC_PARKING_EXTRUDER with LCD" # @@ -70,7 +71,7 @@ exec_test $1 $2 "MAGNETIC_PARKING_EXTRUDER with LCD" # restore_configs opt_set MOTHERBOARD BOARD_TEENSY41 -opt_enable MIXING_EXTRUDER DIRECT_MIXING_IN_G1 GRADIENT_MIX GRADIENT_VTOOL REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +opt_enable MIXING_EXTRUDER DIRECT_MIXING_IN_G1 GRADIENT_MIX GRADIENT_VTOOL opt_set MIXING_STEPPERS 2 exec_test $1 $2 "Mixing Extruder" diff --git a/platformio.ini b/platformio.ini index c1b6f2c24d70..c68daf2c7172 100644 --- a/platformio.ini +++ b/platformio.ini @@ -207,7 +207,7 @@ HAS_L64XX = Arduino-L6470@0.8.0 NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 src_filter=+ MAX6675_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 -HAS_GRAPHICAL_LCD = U8glib-HAL@0.4.1 +HAS_GRAPHICAL_LCD = U8glib-HAL@~0.4.1 src_filter=+ USES_LIQUIDCRYSTAL = LiquidCrystal@1.5.0 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 From 5d0429ee2a5b802d1000a406f9c02850403472af Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 22 Sep 2020 18:36:31 -0700 Subject: [PATCH 39/63] Catch a TMC address conflict early (#19458) --- Marlin/src/module/stepper/trinamic.cpp | 105 +++++++++++++++++++++++++ buildroot/bin/opt_set | 4 +- buildroot/tests/STM32F103RC_btt-tests | 7 +- buildroot/tests/esp32-tests | 4 + 4 files changed, 117 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index 3dda98698bb1..a4b1b240f79e 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -209,113 +209,145 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; #if AXIS_HAS_UART(X) #ifdef X_HARDWARE_SERIAL TMC_UART_DEFINE(HW, X, X); + #define X_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE(SW, X, X); + #define X_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(X2) #ifdef X2_HARDWARE_SERIAL TMC_UART_DEFINE(HW, X2, X); + #define X2_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE(SW, X2, X); + #define X2_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(Y) #ifdef Y_HARDWARE_SERIAL TMC_UART_DEFINE(HW, Y, Y); + #define Y_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE(SW, Y, Y); + #define Y_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(Y2) #ifdef Y2_HARDWARE_SERIAL TMC_UART_DEFINE(HW, Y2, Y); + #define Y2_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE(SW, Y2, Y); + #define Y2_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(Z) #ifdef Z_HARDWARE_SERIAL TMC_UART_DEFINE(HW, Z, Z); + #define Z_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE(SW, Z, Z); + #define Z_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(Z2) #ifdef Z2_HARDWARE_SERIAL TMC_UART_DEFINE(HW, Z2, Z); + #define Z2_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE(SW, Z2, Z); + #define Z2_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(Z3) #ifdef Z3_HARDWARE_SERIAL TMC_UART_DEFINE(HW, Z3, Z); + #define Z3_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE(SW, Z3, Z); + #define Z3_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(Z4) #ifdef Z4_HARDWARE_SERIAL TMC_UART_DEFINE(HW, Z4, Z); + #define Z4_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE(SW, Z4, Z); + #define Z4_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(E0) #ifdef E0_HARDWARE_SERIAL TMC_UART_DEFINE_E(HW, 0); + #define E0_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE_E(SW, 0); + #define E0_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(E1) #ifdef E1_HARDWARE_SERIAL TMC_UART_DEFINE_E(HW, 1); + #define E1_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE_E(SW, 1); + #define E1_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(E2) #ifdef E2_HARDWARE_SERIAL TMC_UART_DEFINE_E(HW, 2); + #define E2_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE_E(SW, 2); + #define E2_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(E3) #ifdef E3_HARDWARE_SERIAL TMC_UART_DEFINE_E(HW, 3); + #define E3_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE_E(SW, 3); + #define E3_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(E4) #ifdef E4_HARDWARE_SERIAL TMC_UART_DEFINE_E(HW, 4); + #define E4_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE_E(SW, 4); + #define E4_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(E5) #ifdef E5_HARDWARE_SERIAL TMC_UART_DEFINE_E(HW, 5); + #define E5_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE_E(SW, 5); + #define E5_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(E6) #ifdef E6_HARDWARE_SERIAL TMC_UART_DEFINE_E(HW, 6); + #define E6_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE_E(SW, 6); + #define E6_HAS_SW_SERIAL 1 #endif #endif #if AXIS_HAS_UART(E7) #ifdef E7_HARDWARE_SERIAL TMC_UART_DEFINE_E(HW, 7); + #define E7_HAS_HW_SERIAL 1 #else TMC_UART_DEFINE_E(SW, 7); + #define E7_HAS_SW_SERIAL 1 #endif #endif @@ -769,4 +801,77 @@ void reset_trinamic_drivers() { stepper.set_directions(); } +// TMC Slave Address Conflict Detection +// +// Conflict detection is performed in the following way. Similar methods are used for +// hardware and software serial, but the implementations are indepenent. +// +// 1. Populate a data structure with UART parameters and addresses for all possible axis. +// If an axis is not in use, populate it with recognizable placeholder data. +// 2. For each axis in use, static_assert using a constexpr function, which counts the +// number of matching/conflicting axis. If the value is not exactly 1, fail. + +#if ANY_AXIS_HAS(HW_SERIAL) + // Hardware serial names are compared as strings, since actually resolving them cannot occur in a constexpr. + // Using a fixed-length character array for the port name allows this to be constexpr compatible. + struct SanityHwSerialDetails { const char port[20]; uint32_t address; }; + #define TMC_HW_DETAIL_ARGS(A) TERN(A##_HAS_HW_SERIAL, STRINGIFY(A##_HARDWARE_SERIAL), ""), TERN0(A##_HAS_HW_SERIAL, A##_SLAVE_ADDRESS) + #define TMC_HW_DETAIL(A) {TMC_HW_DETAIL_ARGS(A)} + constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { + TMC_HW_DETAIL(X), TMC_HW_DETAIL(X2), + TMC_HW_DETAIL(Y), TMC_HW_DETAIL(Y2), + TMC_HW_DETAIL(Z), TMC_HW_DETAIL(Z2), TMC_HW_DETAIL(Z3), TMC_HW_DETAIL(Z4), + TMC_HW_DETAIL(E0), TMC_HW_DETAIL(E1), TMC_HW_DETAIL(E2), TMC_HW_DETAIL(E3), TMC_HW_DETAIL(E4), TMC_HW_DETAIL(E5), TMC_HW_DETAIL(E6), TMC_HW_DETAIL(E7) + }; + + // constexpr compatible string comparison + constexpr bool str_eq_ce(const char * a, const char * b) { + return *a == *b && (*a == '\0' || str_eq_ce(a+1,b+1)); + } + + constexpr bool sc_hw_done(size_t start, size_t end) { return start == end; } + constexpr bool sc_hw_skip(const char* port_name) { return !(*port_name); } + constexpr bool sc_hw_match(const char* port_name, uint32_t address, size_t start, size_t end) { + return !sc_hw_done(start, end) && !sc_hw_skip(port_name) && (address == sanity_tmc_hw_details[start].address && str_eq_ce(port_name, sanity_tmc_hw_details[start].port)); + } + constexpr int count_tmc_hw_serial_matches(const char* port_name, uint32_t address, size_t start, size_t end) { + return sc_hw_done(start, end) ? 0 : ((sc_hw_skip(port_name) ? 0 : (sc_hw_match(port_name, address, start, end) ? 1 : 0)) + count_tmc_hw_serial_matches(port_name, address, start + 1, end)); + } + + #define TMC_HWSERIAL_CONFLICT_MSG(A) STRINGIFY(A) "_SLAVE_ADDRESS conflicts with another driver using the same " STRINGIFY(A) "_HARDWARE_SERIAL" + #define SA_NO_TMC_HW_C(A) static_assert(1 >= count_tmc_hw_serial_matches(TMC_HW_DETAIL_ARGS(A), 0, COUNT(sanity_tmc_hw_details)), TMC_HWSERIAL_CONFLICT_MSG(A)); + SA_NO_TMC_HW_C(X);SA_NO_TMC_HW_C(X2); + SA_NO_TMC_HW_C(Y);SA_NO_TMC_HW_C(Y2); + SA_NO_TMC_HW_C(Z);SA_NO_TMC_HW_C(Z2);SA_NO_TMC_HW_C(Z3);SA_NO_TMC_HW_C(Z4); + SA_NO_TMC_HW_C(E0);SA_NO_TMC_HW_C(E1);SA_NO_TMC_HW_C(E2);SA_NO_TMC_HW_C(E3);SA_NO_TMC_HW_C(E4);SA_NO_TMC_HW_C(E5);SA_NO_TMC_HW_C(E6);SA_NO_TMC_HW_C(E7); +#endif + +#if ANY_AXIS_HAS(SW_SERIAL) + struct SanitySwSerialDetails { int32_t txpin; int32_t rxpin; uint32_t address; }; + #define TMC_SW_DETAIL_ARGS(A) TERN(A##_HAS_SW_SERIAL, A##_SERIAL_TX_PIN, -1), TERN(A##_HAS_SW_SERIAL, A##_SERIAL_RX_PIN, -1), TERN0(A##_HAS_SW_SERIAL, A##_SLAVE_ADDRESS) + #define TMC_SW_DETAIL(A) TMC_SW_DETAIL_ARGS(A) + constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = { + TMC_SW_DETAIL(X), TMC_SW_DETAIL(X2), + TMC_SW_DETAIL(Y), TMC_SW_DETAIL(Y2), + TMC_SW_DETAIL(Z), TMC_SW_DETAIL(Z2), TMC_SW_DETAIL(Z3), TMC_SW_DETAIL(Z4), + TMC_SW_DETAIL(E0), TMC_SW_DETAIL(E1), TMC_SW_DETAIL(E2), TMC_SW_DETAIL(E3), TMC_SW_DETAIL(E4), TMC_SW_DETAIL(E5), TMC_SW_DETAIL(E6), TMC_SW_DETAIL(E7) + }; + + constexpr bool sc_sw_done(size_t start, size_t end) { return start == end; } + constexpr bool sc_sw_skip(int32_t txpin) { return txpin < 0; } + constexpr bool sc_sw_match(int32_t txpin, int32_t rxpin, uint32_t address, size_t start, size_t end) { + return !sc_sw_done(start, end) && !sc_sw_skip(txpin) && (txpin == sanity_tmc_sw_details[start].txpin || rxpin == sanity_tmc_sw_details[start].rxpin) && (address == sanity_tmc_sw_details[start].address); + } + constexpr int count_tmc_sw_serial_matches(int32_t txpin, int32_t rxpin, uint32_t address, size_t start, size_t end) { + return sc_sw_done(start, end) ? 0 : ((sc_sw_skip(txpin) ? 0 : (sc_sw_match(txpin, rxpin, address, start, end) ? 1 : 0)) + count_tmc_sw_serial_matches(txpin, rxpin, address, start + 1, end)); + } + + #define TMC_SWSERIAL_CONFLICT_MSG(A) STRINGIFY(A) "_SLAVE_ADDRESS conflicts with another driver using the same " STRINGIFY(A) "_SERIAL_RX_PIN or " STRINGIFY(A) "_SERIAL_TX_PIN" + #define SA_NO_TMC_SW_C(A) static_assert(1 >= count_tmc_sw_serial_matches(TMC_SW_DETAIL_ARGS(A), 0, COUNT(sanity_tmc_sw_details)), TMC_SWSERIAL_CONFLICT_MSG(A)); + SA_NO_TMC_SW_C(X);SA_NO_TMC_SW_C(X2); + SA_NO_TMC_SW_C(Y);SA_NO_TMC_SW_C(Y2); + SA_NO_TMC_SW_C(Z);SA_NO_TMC_SW_C(Z2);SA_NO_TMC_SW_C(Z3);SA_NO_TMC_SW_C(Z4); + SA_NO_TMC_SW_C(E0);SA_NO_TMC_SW_C(E1);SA_NO_TMC_SW_C(E2);SA_NO_TMC_SW_C(E3);SA_NO_TMC_SW_C(E4);SA_NO_TMC_SW_C(E5);SA_NO_TMC_SW_C(E6);SA_NO_TMC_SW_C(E7); +#endif + #endif // HAS_TRINAMIC_CONFIG diff --git a/buildroot/bin/opt_set b/buildroot/bin/opt_set index f23a1d3d0764..a646e09ae789 100755 --- a/buildroot/bin/opt_set +++ b/buildroot/bin/opt_set @@ -6,7 +6,7 @@ set -e SED=$(which gsed || which sed) # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648 -eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define \b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || -eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define \b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || +eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || +eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || eval "echo '#define ${@}' >>Marlin/Configuration_adv.h" || (echo "ERROR: opt_set Can't set or add ${1}" >&2 && exit 9) diff --git a/buildroot/tests/STM32F103RC_btt-tests b/buildroot/tests/STM32F103RC_btt-tests index 8780eb535cf4..ad15ee723767 100644 --- a/buildroot/tests/STM32F103RC_btt-tests +++ b/buildroot/tests/STM32F103RC_btt-tests @@ -16,7 +16,12 @@ opt_set SERIAL_PORT_2 -1 opt_set X_DRIVER_TYPE TMC2209 opt_set Y_DRIVER_TYPE TMC2209 opt_set Z_DRIVER_TYPE TMC2209 -opt_set E_DRIVER_TYPE TMC2209 +opt_set E0_DRIVER_TYPE TMC2209 +opt_set X_SLAVE_ADDRESS 0 +opt_set Y_SLAVE_ADDRESS 1 +opt_set Z_SLAVE_ADDRESS 2 +opt_set E0_SLAVE_ADDRESS 3 + exec_test $1 $2 "BigTreeTech SKR Mini E3 1.0 - Basic Config with TMC2209 HW Serial" # clean up diff --git a/buildroot/tests/esp32-tests b/buildroot/tests/esp32-tests index 992b3ec5ff44..204e7aa708eb 100755 --- a/buildroot/tests/esp32-tests +++ b/buildroot/tests/esp32-tests @@ -30,6 +30,10 @@ opt_set X_HARDWARE_SERIAL Serial1 opt_set Y_HARDWARE_SERIAL Serial1 opt_set Z_HARDWARE_SERIAL Serial1 opt_set E0_HARDWARE_SERIAL Serial1 +opt_set X_SLAVE_ADDRESS 0 +opt_set Y_SLAVE_ADDRESS 1 +opt_set Z_SLAVE_ADDRESS 2 +opt_set E0_SLAVE_ADDRESS 3 opt_enable HOTEND_IDLE_TIMEOUT exec_test $1 $2 "ESP32, TMC HW Serial, Hotend Idle" From 362145f608aa1a68b0e924ab66f39606356585bd Mon Sep 17 00:00:00 2001 From: Marcio T Date: Tue, 22 Sep 2020 20:01:01 -0600 Subject: [PATCH 40/63] New Touch UI buttons (#19465) --- .../screens/leveling_menu.cpp | 43 +++++++++++-------- .../ftdi_eve_touch_ui/screens/tune_menu.cpp | 15 +++++-- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp index 74ab332fb4d7..763403d28722 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp @@ -35,27 +35,29 @@ using namespace ExtUI; using namespace Theme; #ifdef TOUCH_UI_PORTRAIT - #define GRID_ROWS 9 + #define GRID_ROWS 10 #define GRID_COLS 2 #define TITLE_POS BTN_POS(1,1), BTN_SIZE(2,1) #define LEVEL_BED_POS BTN_POS(1,2), BTN_SIZE(2,1) #define LEVEL_AXIS_POS BTN_POS(1,3), BTN_SIZE(2,1) - #define SHOW_MESH_POS BTN_POS(1,4), BTN_SIZE(2,1) - #define BLTOUCH_TITLE_POS BTN_POS(1,6), BTN_SIZE(2,1) - #define BLTOUCH_RESET_POS BTN_POS(1,7), BTN_SIZE(1,1) - #define BLTOUCH_TEST_POS BTN_POS(2,7), BTN_SIZE(1,1) - #define BACK_POS BTN_POS(1,9), BTN_SIZE(2,1) + #define Z_AUTO_ALIGN_POS BTN_POS(1,4), BTN_SIZE(2,1) + #define SHOW_MESH_POS BTN_POS(1,5), BTN_SIZE(2,1) + #define BLTOUCH_TITLE_POS BTN_POS(1,7), BTN_SIZE(2,1) + #define BLTOUCH_RESET_POS BTN_POS(1,8), BTN_SIZE(1,1) + #define BLTOUCH_TEST_POS BTN_POS(2,8), BTN_SIZE(1,1) + #define BACK_POS BTN_POS(1,10), BTN_SIZE(2,1) #else - #define GRID_ROWS 7 + #define GRID_ROWS 8 #define GRID_COLS 2 #define TITLE_POS BTN_POS(1,1), BTN_SIZE(2,1) #define LEVEL_BED_POS BTN_POS(1,2), BTN_SIZE(2,1) #define LEVEL_AXIS_POS BTN_POS(1,3), BTN_SIZE(2,1) - #define SHOW_MESH_POS BTN_POS(1,4), BTN_SIZE(2,1) - #define BLTOUCH_TITLE_POS BTN_POS(1,5), BTN_SIZE(2,1) - #define BLTOUCH_RESET_POS BTN_POS(1,6), BTN_SIZE(1,1) - #define BLTOUCH_TEST_POS BTN_POS(2,6), BTN_SIZE(1,1) - #define BACK_POS BTN_POS(1,7), BTN_SIZE(2,1) + #define Z_AUTO_ALIGN_POS BTN_POS(1,4), BTN_SIZE(2,1) + #define SHOW_MESH_POS BTN_POS(1,5), BTN_SIZE(2,1) + #define BLTOUCH_TITLE_POS BTN_POS(1,6), BTN_SIZE(2,1) + #define BLTOUCH_RESET_POS BTN_POS(1,7), BTN_SIZE(1,1) + #define BLTOUCH_TEST_POS BTN_POS(2,7), BTN_SIZE(1,1) + #define BACK_POS BTN_POS(1,8), BTN_SIZE(2,1) #endif void LevelingMenu::onRedraw(draw_mode_t what) { @@ -78,12 +80,14 @@ void LevelingMenu::onRedraw(draw_mode_t what) { #endif ) .tag(3).button(LEVEL_AXIS_POS, GET_TEXT_F(MSG_AUTOLEVEL_X_AXIS)) + .enabled(ENABLED(Z_STEPPER_AUTO_ALIGN)) + .tag(4).button(Z_AUTO_ALIGN_POS, GET_TEXT_F(MSG_AUTO_Z_ALIGN)) .enabled(ENABLED(HAS_MESH)) - .tag(4).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH)); + .tag(5).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH)); #if ENABLED(BLTOUCH) cmd.text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH)) - .tag(5).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET)) - .tag(6).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST)); + .tag(6).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET)) + .tag(7).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST)); #endif cmd.colors(action_btn) .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); @@ -103,12 +107,15 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) { #ifdef AXIS_LEVELING_COMMANDS case 3: SpinnerDialogBox::enqueueAndWait_P(F(AXIS_LEVELING_COMMANDS)); break; #endif + #if ENABLED(Z_STEPPER_AUTO_ALIGN) + case 4: SpinnerDialogBox::enqueueAndWait_P(F("G34")); break; + #endif #if HAS_MESH - case 4: GOTO_SCREEN(BedMeshScreen); break; + case 5: GOTO_SCREEN(BedMeshScreen); break; #endif #if ENABLED(BLTOUCH) - case 5: injectCommands_P(PSTR("M280 P0 S60")); break; - case 6: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; + case 6: injectCommands_P(PSTR("M280 P0 S60")); break; + case 7: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; #endif default: return false; } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/tune_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/tune_menu.cpp index 4e3fb7d17ef9..9fe2f1e9cbcb 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/tune_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/tune_menu.cpp @@ -37,7 +37,7 @@ void TuneMenu::onRedraw(draw_mode_t what) { } #ifdef TOUCH_UI_PORTRAIT - #define GRID_ROWS 8 + #define GRID_ROWS 9 #define GRID_COLS 2 #define TEMPERATURE_POS BTN_POS(1,1), BTN_SIZE(2,1) #define FIL_CHANGE_POS BTN_POS(1,2), BTN_SIZE(2,1) @@ -46,9 +46,10 @@ void TuneMenu::onRedraw(draw_mode_t what) { #define SPEED_POS BTN_POS(1,5), BTN_SIZE(2,1) #define PAUSE_POS BTN_POS(1,6), BTN_SIZE(2,1) #define STOP_POS BTN_POS(1,7), BTN_SIZE(2,1) - #define BACK_POS BTN_POS(1,8), BTN_SIZE(2,1) + #define CASE_LIGHT_POS BTN_POS(1,8), BTN_SIZE(2,1) + #define BACK_POS BTN_POS(1,9), BTN_SIZE(2,1) #else - #define GRID_ROWS 4 + #define GRID_ROWS 5 #define GRID_COLS 2 #define TEMPERATURE_POS BTN_POS(1,1), BTN_SIZE(1,1) #define NUDGE_NOZ_POS BTN_POS(2,1), BTN_SIZE(1,1) @@ -57,7 +58,8 @@ void TuneMenu::onRedraw(draw_mode_t what) { #define PAUSE_POS BTN_POS(1,3), BTN_SIZE(1,1) #define STOP_POS BTN_POS(2,3), BTN_SIZE(1,1) #define FILAMENT_POS BTN_POS(1,4), BTN_SIZE(1,1) - #define BACK_POS BTN_POS(2,4), BTN_SIZE(1,1) + #define CASE_LIGHT_POS BTN_POS(2,4), BTN_SIZE(1,1) + #define BACK_POS BTN_POS(1,5), BTN_SIZE(2,1) #endif if (what & FOREGROUND) { @@ -79,6 +81,8 @@ void TuneMenu::onRedraw(draw_mode_t what) { .button( PAUSE_POS, isPrintingFromMediaPaused() ? GET_TEXT_F(MSG_RESUME_PRINT) : GET_TEXT_F(MSG_PAUSE_PRINT)) .enabled(TERN0(SDSUPPORT, isPrintingFromMedia())) .tag(8).button( STOP_POS, GET_TEXT_F(MSG_STOP_PRINT)) + .enabled(ENABLED(CASE_LIGHT_ENABLE)) + .tag(10).button( CASE_LIGHT_POS, GET_TEXT_F(MSG_CASE_LIGHT)) .tag(1).colors(action_btn) .button( BACK_POS, GET_TEXT_F(MSG_BACK)); } @@ -111,6 +115,9 @@ bool TuneMenu::onTouchEnd(uint8_t tag) { #if EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR) case 9: GOTO_SCREEN(FilamentMenu); break; #endif + #if ENABLED(CASE_LIGHT_ENABLE) + case 10: GOTO_SCREEN(CaseLightScreen); break; + #endif default: return false; } From 90bc1993b6811623dd9d0de00251e0c63415cb49 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Wed, 23 Sep 2020 17:06:36 -0300 Subject: [PATCH 41/63] Include pins.h in dependencies script (#19468) --- Marlin/src/pins/esp32/pins_E4D.h | 2 +- Marlin/src/pins/esp32/pins_ESP32.h | 2 +- Marlin/src/pins/esp32/pins_MRR_ESPA.h | 2 +- Marlin/src/pins/esp32/pins_MRR_ESPE.h | 2 +- Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h | 2 +- Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h | 2 +- Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h | 2 +- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 4 ++++ Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h | 4 ++-- Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h | 2 +- Marlin/src/pins/lpc1768/pins_MKS_SBASE.h | 4 ++-- Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h | 2 +- Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h | 2 +- Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h | 2 +- Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h | 2 +- Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h | 2 +- .../src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h | 2 +- Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h | 2 +- Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h | 2 +- Marlin/src/pins/lpc1769/pins_MKS_SGEN.h | 2 +- Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h | 2 +- Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h | 2 +- Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h | 2 +- Marlin/src/pins/mega/pins_CHEAPTRONIC.h | 2 +- Marlin/src/pins/mega/pins_CHEAPTRONICv2.h | 2 +- Marlin/src/pins/mega/pins_CNCONTROLS_11.h | 2 +- Marlin/src/pins/mega/pins_CNCONTROLS_12.h | 2 +- Marlin/src/pins/mega/pins_CNCONTROLS_15.h | 2 +- Marlin/src/pins/mega/pins_EINSTART-S.h | 2 +- Marlin/src/pins/mega/pins_ELEFU_3.h | 2 +- Marlin/src/pins/mega/pins_GT2560_REV_A.h | 2 +- Marlin/src/pins/mega/pins_GT2560_V3.h | 2 +- Marlin/src/pins/mega/pins_HJC2560C_REV2.h | 2 +- Marlin/src/pins/mega/pins_INTAMSYS40.h | 2 +- Marlin/src/pins/mega/pins_LEAPFROG.h | 2 +- Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h | 2 +- Marlin/src/pins/mega/pins_MEGACONTROLLER.h | 2 +- Marlin/src/pins/mega/pins_MEGATRONICS.h | 2 +- Marlin/src/pins/mega/pins_MEGATRONICS_2.h | 2 +- Marlin/src/pins/mega/pins_MEGATRONICS_3.h | 2 +- Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h | 2 +- Marlin/src/pins/mega/pins_MINITRONICS.h | 2 +- Marlin/src/pins/mega/pins_OVERLORD.h | 2 +- Marlin/src/pins/mega/pins_PICA.h | 2 +- Marlin/src/pins/mega/pins_SILVER_GATE.h | 2 +- Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h | 2 +- Marlin/src/pins/pins.h | 7 +++++++ Marlin/src/pins/rambo/pins_EINSY_RAMBO.h | 2 +- Marlin/src/pins/rambo/pins_EINSY_RETRO.h | 2 +- Marlin/src/pins/rambo/pins_MINIRAMBO.h | 2 +- Marlin/src/pins/rambo/pins_RAMBO.h | 2 +- Marlin/src/pins/rambo/pins_SCOOVO_X9H.h | 2 +- Marlin/src/pins/ramps/pins_AZTEEG_X3.h | 2 +- Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h | 2 +- Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h | 2 +- Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h | 2 +- Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h | 2 +- Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h | 2 +- Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h | 2 +- Marlin/src/pins/ramps/pins_FYSETC_F6_13.h | 2 +- Marlin/src/pins/ramps/pins_K8800.h | 2 +- Marlin/src/pins/ramps/pins_RAMPS.h | 9 +++++---- Marlin/src/pins/ramps/pins_RAMPS_OLD.h | 2 +- Marlin/src/pins/ramps/pins_RAMPS_PLUS.h | 2 +- Marlin/src/pins/ramps/pins_RUMBA.h | 2 +- Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h | 2 +- Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h | 2 +- Marlin/src/pins/ramps/pins_TT_OSCAR.h | 2 +- Marlin/src/pins/ramps/pins_ULTIMAIN_2.h | 2 +- Marlin/src/pins/ramps/pins_ULTIMAKER.h | 2 +- Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h | 2 +- Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h | 2 +- Marlin/src/pins/sam/pins_ADSK.h | 2 +- Marlin/src/pins/sam/pins_ALLIGATOR_R2.h | 2 +- Marlin/src/pins/sam/pins_ARCHIM1.h | 2 +- Marlin/src/pins/sam/pins_ARCHIM2.h | 2 +- Marlin/src/pins/sam/pins_CNCONTROLS_15D.h | 2 +- Marlin/src/pins/sam/pins_DUE3DOM.h | 2 +- Marlin/src/pins/sam/pins_DUE3DOM_MINI.h | 2 +- Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h | 2 +- Marlin/src/pins/sam/pins_RADDS.h | 2 +- Marlin/src/pins/sam/pins_RAMPS4DUE.h | 2 +- Marlin/src/pins/sam/pins_RAMPS_DUO.h | 2 +- Marlin/src/pins/sam/pins_RAMPS_FD_V1.h | 2 +- Marlin/src/pins/sam/pins_RAMPS_SMART.h | 2 +- Marlin/src/pins/sam/pins_RURAMPS4D_11.h | 2 +- Marlin/src/pins/sam/pins_RURAMPS4D_13.h | 2 +- Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h | 2 +- Marlin/src/pins/samd/pins_RAMPS_144.h | 2 +- Marlin/src/pins/sanguino/pins_ANET_10.h | 2 +- Marlin/src/pins/sanguino/pins_GEN3_MONOLITHIC.h | 2 +- Marlin/src/pins/sanguino/pins_GEN3_PLUS.h | 2 +- Marlin/src/pins/sanguino/pins_GEN6.h | 2 +- Marlin/src/pins/sanguino/pins_GEN7_12.h | 2 +- Marlin/src/pins/sanguino/pins_GEN7_14.h | 2 +- Marlin/src/pins/sanguino/pins_GEN7_CUSTOM.h | 2 +- Marlin/src/pins/sanguino/pins_OMCA.h | 2 +- Marlin/src/pins/sanguino/pins_OMCA_A.h | 2 +- Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h | 2 +- Marlin/src/pins/sanguino/pins_SETHI.h | 2 +- Marlin/src/pins/sanguino/pins_ZMIB_V2.h | 2 +- Marlin/src/pins/stm32f0/pins_MALYAN_M200_V2.h | 2 +- Marlin/src/pins/stm32f0/pins_MALYAN_M300.h | 2 +- Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h | 2 +- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h | 2 +- Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h | 2 +- Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h | 2 +- Marlin/src/pins/stm32f1/pins_CHITU3D.h | 2 +- Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h | 2 +- Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h | 2 +- Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 2 +- Marlin/src/pins/stm32f1/pins_CREALITY_V427.h | 2 +- Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h | 2 +- Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h | 2 +- .../src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h | 2 +- Marlin/src/pins/stm32f1/pins_GTM32_MINI.h | 2 +- Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h | 2 +- Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h | 2 +- Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h | 2 +- Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h | 2 +- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 2 +- Marlin/src/pins/stm32f1/pins_MALYAN_M200.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h | 4 ++-- .../src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 4 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h | 2 +- Marlin/src/pins/stm32f1/pins_MORPHEUS.h | 2 +- Marlin/src/pins/stm32f1/pins_STM32F1R.h | 2 +- Marlin/src/pins/stm32f1/pins_STM3R_MINI.h | 2 +- Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h | 2 +- Marlin/src/pins/stm32f4/pins_ARMED.h | 2 +- Marlin/src/pins/stm32f4/pins_BEAST.h | 2 +- Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h | 2 +- Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h | 2 +- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 2 +- .../src/pins/stm32f4/pins_BTT_SKR_PRO_common.h | 2 +- Marlin/src/pins/stm32f4/pins_FLYF407ZG.h | 2 +- Marlin/src/pins/stm32f4/pins_FYSETC_S6.h | 2 +- Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h | 2 +- Marlin/src/pins/stm32f4/pins_LERDGE_K.h | 2 +- Marlin/src/pins/stm32f4/pins_LERDGE_S.h | 2 +- Marlin/src/pins/stm32f4/pins_LERDGE_X.h | 2 +- Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h | 2 +- Marlin/src/pins/stm32f4/pins_RUMBA32_common.h | 2 +- Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h | 2 +- Marlin/src/pins/stm32f4/pins_VAKE403D.h | 2 +- Marlin/src/pins/stm32f7/pins_REMRAM_V1.h | 2 +- Marlin/src/pins/stm32f7/pins_THE_BORG.h | 2 +- Marlin/src/pins/teensy2/pins_5DPRINT.h | 2 +- Marlin/src/pins/teensy2/pins_BRAINWAVE.h | 2 +- Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h | 2 +- Marlin/src/pins/teensy2/pins_PRINTRBOARD.h | 2 +- Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h | 2 +- Marlin/src/pins/teensy2/pins_SAV_MKI.h | 2 +- Marlin/src/pins/teensy2/pins_TEENSY2.h | 2 +- Marlin/src/pins/teensy2/pins_TEENSYLU.h | 2 +- Marlin/src/pins/teensy3/pins_TEENSY31_32.h | 2 +- Marlin/src/pins/teensy3/pins_TEENSY35_36.h | 2 +- Marlin/src/pins/teensy4/pins_T41U5XBB.h | 8 ++++---- Marlin/src/pins/teensy4/pins_TEENSY41.h | 16 ++++++++-------- .../scripts/common-dependencies-post.py | 16 ++++++++++++++++ .../PlatformIO/scripts/common-dependencies.h | 3 +++ .../PlatformIO/scripts/common-dependencies.py | 2 +- platformio.ini | 1 + 169 files changed, 213 insertions(+), 181 deletions(-) create mode 100644 buildroot/share/PlatformIO/scripts/common-dependencies-post.py diff --git a/Marlin/src/pins/esp32/pins_E4D.h b/Marlin/src/pins/esp32/pins_E4D.h index e66bb669f71c..7b5595444cf1 100644 --- a/Marlin/src/pins/esp32/pins_E4D.h +++ b/Marlin/src/pins/esp32/pins_E4D.h @@ -27,7 +27,7 @@ * for more info check https://atbox.tech/ and join to Facebook page E4d@box. */ -#ifndef ARDUINO_ARCH_ESP32 +#if NOT_TARGET(ARDUINO_ARCH_ESP32) #error "Oops! Select an ESP32 board in 'Tools > Board.'" #elif EXTRUDERS > 1 || E_STEPPERS > 1 #error "E4d@box only supports one E Stepper. Comment out this line to continue." diff --git a/Marlin/src/pins/esp32/pins_ESP32.h b/Marlin/src/pins/esp32/pins_ESP32.h index 5f793f1cf2e4..d54a92b9c4e5 100644 --- a/Marlin/src/pins/esp32/pins_ESP32.h +++ b/Marlin/src/pins/esp32/pins_ESP32.h @@ -25,7 +25,7 @@ * Espressif ESP32 (Tensilica Xtensa LX6) pin assignments */ -#ifndef ARDUINO_ARCH_ESP32 +#if NOT_TARGET(ARDUINO_ARCH_ESP32) "Oops! Select an ESP32 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPA.h b/Marlin/src/pins/esp32/pins_MRR_ESPA.h index 8a5b11ed71c6..0457b0afca53 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPA.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPA.h @@ -27,7 +27,7 @@ * Supports 4 stepper drivers, heated bed, single hotend. */ -#ifndef ARDUINO_ARCH_ESP32 +#if NOT_TARGET(ARDUINO_ARCH_ESP32) #error "Oops! Select an ESP32 board in 'Tools > Board.'" #elif EXTRUDERS > 1 || E_STEPPERS > 1 #error "MRR ESPA only supports one E Stepper. Comment out this line to continue." diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPE.h b/Marlin/src/pins/esp32/pins_MRR_ESPE.h index b38a88351d5a..459d00e3e7e2 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPE.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPE.h @@ -28,7 +28,7 @@ * single hotend, and LCD controller. */ -#ifndef ARDUINO_ARCH_ESP32 +#if NOT_TARGET(ARDUINO_ARCH_ESP32) #error "Oops! Select an ESP32 board in 'Tools > Board.'" #elif EXTRUDERS > 2 || E_STEPPERS > 2 #error "MRR ESPE only supports two E Steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h b/Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h index ffc149279c29..78e742667497 100644 --- a/Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h +++ b/Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h @@ -25,7 +25,7 @@ * AZSMZ MINI pin assignments */ -#ifndef MCU_LPC1768 +#if NOT_TARGET(MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h b/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h index 6ccfca1cac22..13e30b961c1e 100644 --- a/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h +++ b/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h @@ -30,7 +30,7 @@ * */ -#ifndef MCU_LPC1768 +#if NOT_TARGET(MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h b/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h index 20edcb07a76f..ed5fd530e04a 100644 --- a/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h +++ b/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h @@ -30,7 +30,7 @@ * */ -#ifndef MCU_LPC1768 +#if NOT_TARGET(MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index ce1372ed7a94..1846b16e4698 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -25,6 +25,10 @@ #define BOARD_INFO_NAME "BTT SKR V1.4" #endif +#ifndef BOARD_CUSTOM_BUILD_FLAGS + #define BOARD_CUSTOM_BUILD_FLAGS -DLPC_PINCFG_UART3_P4_28 +#endif + // // SD Connection // diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index bfae569cc422..9fade582e978 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -22,10 +22,10 @@ #pragma once #ifdef SKR_HAS_LPC1769 - #ifndef MCU_LPC1769 + #if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif -#elif !defined(MCU_LPC1768) +#elif NOT_TARGET(MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h index 6bba067cbef8..5132081a5591 100644 --- a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h +++ b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef MCU_LPC1768 +#if NOT_TARGET(MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index 54f3dfd95c16..7d0745aa2d1a 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -25,9 +25,9 @@ * MKS SBASE pin assignments */ -#if defined(MKS_HAS_LPC1769) && !defined(MCU_LPC1769) +#if defined(MKS_HAS_LPC1769) && NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." -#elif !defined(MKS_HAS_LPC1769) && !defined(MCU_LPC1768) +#elif NOT_TARGET(MKS_HAS_LPC1769, MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index 59d6a06cf423..c57c987a7560 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -25,7 +25,7 @@ * MKS SGEN-L pin assignments */ -#ifndef MCU_LPC1768 +#if NOT_TARGET(MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 32c9ad271187..7b87c95f84a8 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -36,7 +36,7 @@ // Numbers in parentheses () are the corresponding mega2560 pin numbers -#ifndef MCU_LPC1768 +#if NOT_TARGET(MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h b/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h index e717511c124f..f9b9db918d55 100644 --- a/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h +++ b/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h @@ -25,7 +25,7 @@ * Selena Compact pin assignments */ -#ifndef MCU_LPC1768 +#if NOT_TARGET(MCU_LPC1768) #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h index 83cf17eee9f9..adf9085262a0 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h @@ -25,7 +25,7 @@ * Azteeg X5 GT pin assignments */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index 8d5080b28033..d798e3873584 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -25,7 +25,7 @@ * Azteeg X5 MINI pin assignments */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h index 592f666e391e..99ff0fd25a14 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h @@ -25,7 +25,7 @@ * Azteeg X5 MINI pin assignments */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h b/Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h index d5c7d9868f97..0314c5049f82 100644 --- a/Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h @@ -25,7 +25,7 @@ * Cohesion3D Mini pin assignments */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h b/Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h index 387090288184..9dc870a35396 100644 --- a/Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h +++ b/Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h @@ -25,7 +25,7 @@ * Cohesion3D ReMix pin assignments */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h index c9f3ff7aae26..19c2d5032050 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h @@ -29,7 +29,7 @@ * */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h index b6f11a133daf..3df10a41d769 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -25,7 +25,7 @@ * MKS SGen pin assignments */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h index de148995cacb..696270b417ae 100644 --- a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h @@ -25,7 +25,7 @@ * Smoothieboard pin assignments */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h index 81f5b75016c3..75c899fe01d1 100644 --- a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h @@ -25,7 +25,7 @@ * TH3D EZBoard pin assignments */ -#ifndef MCU_LPC1769 +#if NOT_TARGET(MCU_LPC1769) #error "Oops! Make sure you have the LPC1769 environment selected in your IDE." #endif diff --git a/Marlin/src/pins/mega/pins_CHEAPTRONIC.h b/Marlin/src/pins/mega/pins_CHEAPTRONIC.h index 90d4340ba8f3..98427d9e592a 100644 --- a/Marlin/src/pins/mega/pins_CHEAPTRONIC.h +++ b/Marlin/src/pins/mega/pins_CHEAPTRONIC.h @@ -25,7 +25,7 @@ * Cheaptronic v1.0 pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h b/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h index 18bcc9e407e3..3a84f4395f3a 100644 --- a/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h +++ b/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h @@ -27,7 +27,7 @@ * www.reprapobchod.cz */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_11.h b/Marlin/src/pins/mega/pins_CNCONTROLS_11.h index 6f792ad5fa5c..675d4b7262f8 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_11.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_11.h @@ -25,7 +25,7 @@ * CartesioV11 pin assignments */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_12.h b/Marlin/src/pins/mega/pins_CNCONTROLS_12.h index 7040c2babb18..35426a453139 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_12.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_12.h @@ -25,7 +25,7 @@ * CartesioV12 pin assignments */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_15.h b/Marlin/src/pins/mega/pins_CNCONTROLS_15.h index 4af0d991e962..8bafbdf00058 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_15.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_15.h @@ -25,7 +25,7 @@ * CNControls V15 for HMS434 pin assignments */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_EINSTART-S.h b/Marlin/src/pins/mega/pins_EINSTART-S.h index eeaf0c419741..40d65c353e8c 100644 --- a/Marlin/src/pins/mega/pins_EINSTART-S.h +++ b/Marlin/src/pins/mega/pins_EINSTART-S.h @@ -26,7 +26,7 @@ * PCB Silkscreen: 3DPrinterCon_v3.5 */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_ELEFU_3.h b/Marlin/src/pins/mega/pins_ELEFU_3.h index 685611f78d22..af93c408a25a 100644 --- a/Marlin/src/pins/mega/pins_ELEFU_3.h +++ b/Marlin/src/pins/mega/pins_ELEFU_3.h @@ -25,7 +25,7 @@ * Elefu RA Board Pin Assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_A.h b/Marlin/src/pins/mega/pins_GT2560_REV_A.h index ebfdd24bb49a..2fb112f5afca 100644 --- a/Marlin/src/pins/mega/pins_GT2560_REV_A.h +++ b/Marlin/src/pins/mega/pins_GT2560_REV_A.h @@ -27,7 +27,7 @@ * Richard Smith */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_GT2560_V3.h b/Marlin/src/pins/mega/pins_GT2560_V3.h index 9b396d8db250..d71a19541914 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3.h @@ -25,7 +25,7 @@ * GT2560 RevB + GT2560 V3.0 + GT2560 V3.1 + GT2560 V4.0 pin assignment */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h index 2cbac0723c83..d21cd22e53bd 100644 --- a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h +++ b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h @@ -25,7 +25,7 @@ * HJC2560-C Rev2.x pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_INTAMSYS40.h b/Marlin/src/pins/mega/pins_INTAMSYS40.h index b6ff30a4fc23..3dc9c9a6bed3 100644 --- a/Marlin/src/pins/mega/pins_INTAMSYS40.h +++ b/Marlin/src/pins/mega/pins_INTAMSYS40.h @@ -27,7 +27,7 @@ * 2208 version exists and may or may not work */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_LEAPFROG.h b/Marlin/src/pins/mega/pins_LEAPFROG.h index 99872e1fb4e7..9e6802b24bd7 100644 --- a/Marlin/src/pins/mega/pins_LEAPFROG.h +++ b/Marlin/src/pins/mega/pins_LEAPFROG.h @@ -25,7 +25,7 @@ * Leapfrog Driver board pin assignments */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Mega 1280' or 'Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h b/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h index 61f5508cdc04..9c316aa75951 100644 --- a/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h +++ b/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h @@ -29,7 +29,7 @@ * printer models. As such this file is currently specific to the Xeed. */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_MEGACONTROLLER.h b/Marlin/src/pins/mega/pins_MEGACONTROLLER.h index 6b90b884c239..938ad82eff03 100644 --- a/Marlin/src/pins/mega/pins_MEGACONTROLLER.h +++ b/Marlin/src/pins/mega/pins_MEGACONTROLLER.h @@ -25,7 +25,7 @@ * Mega controller pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Mega Controller supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS.h b/Marlin/src/pins/mega/pins_MEGATRONICS.h index 2d98256fe71f..1c37b21ab707 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS.h @@ -25,7 +25,7 @@ * MegaTronics pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS_2.h b/Marlin/src/pins/mega/pins_MEGATRONICS_2.h index 481dc35fa3a1..9005ac2acfa1 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS_2.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS_2.h @@ -25,7 +25,7 @@ * MegaTronics v2.0 pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS_3.h b/Marlin/src/pins/mega/pins_MEGATRONICS_3.h index 093889674873..45ebd163a79f 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS_3.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS_3.h @@ -25,7 +25,7 @@ * MegaTronics v3.0 / v3.1 / v3.2 pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index 526c9bfc68b9..74a45eac017f 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -37,7 +37,7 @@ * number (B5) agrees with the schematic but B5 is assigned to logical pin 11. */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Mega 1280' or 'Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_MINITRONICS.h b/Marlin/src/pins/mega/pins_MINITRONICS.h index 138d4b443111..9cb4401da90c 100644 --- a/Marlin/src/pins/mega/pins_MINITRONICS.h +++ b/Marlin/src/pins/mega/pins_MINITRONICS.h @@ -32,7 +32,7 @@ * */ -#ifndef __AVR_ATmega1281__ +#if NOT_TARGET(__AVR_ATmega1281__) #error "Oops! Select 'Minitronics' in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Minitronics supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/mega/pins_OVERLORD.h b/Marlin/src/pins/mega/pins_OVERLORD.h index bbccc93561e8..9589fa585189 100644 --- a/Marlin/src/pins/mega/pins_OVERLORD.h +++ b/Marlin/src/pins/mega/pins_OVERLORD.h @@ -25,7 +25,7 @@ * Dreammaker Overlord v1.1 pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Overlord Controller supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/mega/pins_PICA.h b/Marlin/src/pins/mega/pins_PICA.h index 40ef3a610f7e..acaeefe17861 100644 --- a/Marlin/src/pins/mega/pins_PICA.h +++ b/Marlin/src/pins/mega/pins_PICA.h @@ -42,7 +42,7 @@ AD12 = 66; AD13 = 67; AD14 = 68; AD15 = 69; */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu." #endif diff --git a/Marlin/src/pins/mega/pins_SILVER_GATE.h b/Marlin/src/pins/mega/pins_SILVER_GATE.h index a67725d9bce6..e339b0472ac4 100644 --- a/Marlin/src/pins/mega/pins_SILVER_GATE.h +++ b/Marlin/src/pins/mega/pins_SILVER_GATE.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__AVR_ATmega1281__) && !defined(__AVR_ATmega2561__) +#if NOT_TARGET(__AVR_ATmega1281__, __AVR_ATmega2561__) #error "Oops! Select 'Silvergate' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h b/Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h index ba7f64768b0f..52e757c53408 100644 --- a/Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h +++ b/Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h @@ -25,7 +25,7 @@ * Wanhao 0ne+ pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 861810d95bb4..bf95c8731239 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -51,6 +51,13 @@ #define HAS_FREE_AUX2_PINS !(BOTH(ULTRA_LCD, NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, MINIPANEL, REPRAPWORLD_KEYPAD)) +// Test the target within the included pins file +#ifdef __MARLIN_PREBUILD__ + #define NOT_TARGET(V...) 0 +#else + #define NOT_TARGET(V...) NONE(V) +#endif + // // RAMPS 1.3 / 1.4 - ATmega1280, ATmega2560 // diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index e2a4940e8789..21e43bb3618b 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -25,7 +25,7 @@ * Einsy-Rambo pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino Mega 2560 or Rambo' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index 672c37241464..39ba3ddf04c5 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -25,7 +25,7 @@ * Einsy-Retro pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino Mega 2560 or Rambo' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/rambo/pins_MINIRAMBO.h b/Marlin/src/pins/rambo/pins_MINIRAMBO.h index 0c14d9f46b29..c41a6ac17966 100644 --- a/Marlin/src/pins/rambo/pins_MINIRAMBO.h +++ b/Marlin/src/pins/rambo/pins_MINIRAMBO.h @@ -25,7 +25,7 @@ * Mini-RAMBo pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'RAMBo' in 'Tools > Board' or the Mega2560 environment in PlatformIO." #endif diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 5abf1f2d90d0..2109eb615b2e 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -41,7 +41,7 @@ * Rambo pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h index bba628f30782..4af38e1de36b 100644 --- a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h +++ b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h @@ -25,7 +25,7 @@ * Rambo pin assignments MODIFIED FOR Scoovo X9H ************************************************/ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3.h index d142fb903e55..e919b30cf982 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3.h @@ -25,7 +25,7 @@ * AZTEEG_X3 Arduino Mega with RAMPS v1.4 pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Azteeg X3 supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h index 5eee450fc507..9ba6a0c1ac45 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h @@ -25,7 +25,7 @@ * AZTEEG_X3_PRO (Arduino Mega) pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 5 || E_STEPPERS > 5 #error "Azteeg X3 Pro supports up to 5 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h b/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h index 1420aaaa56d2..967fec7b47de 100644 --- a/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h +++ b/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h @@ -25,7 +25,7 @@ * bq ZUM Mega 3D board definition */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h b/Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h index de80851df00c..3fa738e32215 100644 --- a/Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h +++ b/Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h @@ -25,7 +25,7 @@ * Wanhao Duplicator i3 Plus pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h index f1e6e6727c75..0877d168d60f 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h @@ -25,7 +25,7 @@ * Formbot Raptor pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 3 || E_STEPPERS > 3 #error "Formbot supports up to 3 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h index 4a9b9e1d5964..362ff7ae438a 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h @@ -25,7 +25,7 @@ * Formbot pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Formbot supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h index a804df4ed394..0470fc47e98b 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -25,7 +25,7 @@ * Formbot pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Formbot supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h index ffaa72d988e7..3f7575497cb3 100644 --- a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h +++ b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h @@ -25,7 +25,7 @@ // FYSETC F6 1.3 (and 1.4) pin assignments // -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'FYSETC F6' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_K8800.h b/Marlin/src/pins/ramps/pins_K8800.h index 64e3c2566082..f526b9b2269f 100644 --- a/Marlin/src/pins/ramps/pins_K8800.h +++ b/Marlin/src/pins/ramps/pins_K8800.h @@ -25,7 +25,7 @@ * Velleman K8800 (Vertex) */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index e32c79afa9dd..b2d394e61d2c 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -51,12 +51,13 @@ #error "Oops! Set MOTHERBOARD to an STM32F1-based board when building for STM32F1." #endif -#if NONE(IS_RAMPS_SMART, IS_RAMPS_DUO, IS_RAMPS4DUE, TARGET_LPC1768) - #if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) - #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" - #endif +#if NOT_TARGET(IS_RAMPS_SMART, IS_RAMPS_DUO, IS_RAMPS4DUE, TARGET_LPC1768, __AVR_ATmega1280__, __AVR_ATmega2560__) + #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif +// Custom flags and defines for the build +//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ + #ifndef BOARD_INFO_NAME #define BOARD_INFO_NAME "RAMPS 1.4" #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS_OLD.h b/Marlin/src/pins/ramps/pins_RAMPS_OLD.h index d154b2fdd039..6d2dad231491 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_OLD.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_OLD.h @@ -25,7 +25,7 @@ * Arduino Mega with RAMPS v1.0, v1.1, v1.2 pin assignments */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h index bdd53abbc04d..19209f1e2363 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h @@ -38,7 +38,7 @@ * */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_RUMBA.h b/Marlin/src/pins/ramps/pins_RUMBA.h index 5b4f830328f6..5be2896e18c0 100644 --- a/Marlin/src/pins/ramps/pins_RUMBA.h +++ b/Marlin/src/pins/ramps/pins_RUMBA.h @@ -25,7 +25,7 @@ * RUMBA pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 3 || E_STEPPERS > 3 #error "RUMBA supports up to 3 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h index 98a20fb3fde1..e7a59a69dffe 100644 --- a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h +++ b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h @@ -25,7 +25,7 @@ * Tenlog pin assignments */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Tenlog supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h b/Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h index d02a063e8086..f342eff8aa6c 100644 --- a/Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h +++ b/Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h @@ -25,7 +25,7 @@ * Arduino Mega for Tronxy X5S-2E, etc. */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "TRONXY-V3-1.0 supports only 2 hotends/E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index ab3dc1a32b60..33b2a60d641e 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -20,7 +20,7 @@ * */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h index cbf9523eacc0..c6251ae8175c 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h @@ -33,7 +33,7 @@ * case light */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER.h b/Marlin/src/pins/ramps/pins_ULTIMAKER.h index f316fad7783b..2dfde42bac69 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER.h @@ -33,7 +33,7 @@ * case light */ -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h index a44baf26e4d0..c5bbd02bf5a9 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h @@ -60,7 +60,7 @@ //#define BOARD_REV_1_0 //#define BOARD_REV_1_5 -#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h b/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h index 4bf63f348f14..096d970871f2 100644 --- a/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h +++ b/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h @@ -25,7 +25,7 @@ * Z-Bolt X Series board – based on Arduino Mega2560 */ -#ifndef __AVR_ATmega2560__ +#if NOT_TARGET(__AVR_ATmega2560__) #error "Oops! Select 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #elif HOTENDS > 4 || E_STEPPERS > 4 #error "Z-Bolt X Series board supports up to 4 hotends / E-steppers." diff --git a/Marlin/src/pins/sam/pins_ADSK.h b/Marlin/src/pins/sam/pins_ADSK.h index 289fa462cc8e..c4d7c079407c 100644 --- a/Marlin/src/pins/sam/pins_ADSK.h +++ b/Marlin/src/pins/sam/pins_ADSK.h @@ -27,7 +27,7 @@ #define BOARD_INFO_NAME "ADSK" -#if !defined(__SAM3X8E__) && !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__SAM3X8E__, __AVR_ATmega1280__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino Due or Mega' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h index 4d08ed784d68..8d6906117dd1 100644 --- a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h +++ b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h @@ -26,7 +26,7 @@ * https://reprap.org/wiki/Alligator_Board */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_ARCHIM1.h b/Marlin/src/pins/sam/pins_ARCHIM1.h index 134049781aca..8c54cad3b6b8 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM1.h +++ b/Marlin/src/pins/sam/pins_ARCHIM1.h @@ -37,7 +37,7 @@ * https://github.com/ultimachine/Archim/wiki */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Archim' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_ARCHIM2.h b/Marlin/src/pins/sam/pins_ARCHIM2.h index b527b511835f..3223ac7a0ef4 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM2.h +++ b/Marlin/src/pins/sam/pins_ARCHIM2.h @@ -37,7 +37,7 @@ * https://github.com/ultimachine/Archim/wiki */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Archim' in 'Tools > Board.'" #elif DISABLED(TMC_USE_SW_SPI) #error "Archim2 requires Software SPI. Enable TMC_USE_SW_SPI in Configuration_adv.h." diff --git a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h index a2094bee4daf..fcd2bb4c67bf 100644 --- a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h +++ b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h @@ -24,7 +24,7 @@ * CNControls V15 for HMS434 with DUE pin assignments */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_DUE3DOM.h b/Marlin/src/pins/sam/pins_DUE3DOM.h index 260a2810f5e8..b7c01f843ae3 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM.h @@ -25,7 +25,7 @@ * DUE3DOM pin assignments */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h index 946cadcfa943..7f559f11903f 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h @@ -25,7 +25,7 @@ * DUE3DOM MINI pin assignments */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h b/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h index be6b0fb2ed86..2cfbecc08646 100644 --- a/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h +++ b/Marlin/src/pins/sam/pins_PRINTRBOARD_G2.h @@ -25,7 +25,7 @@ * PRINTRBOARD_G2 */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_RADDS.h b/Marlin/src/pins/sam/pins_RADDS.h index bbbfb2e55826..c82c7e9c5399 100644 --- a/Marlin/src/pins/sam/pins_RADDS.h +++ b/Marlin/src/pins/sam/pins_RADDS.h @@ -25,7 +25,7 @@ * RADDS */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_RAMPS4DUE.h b/Marlin/src/pins/sam/pins_RAMPS4DUE.h index 2bd894f9ae27..54548333b5fd 100644 --- a/Marlin/src/pins/sam/pins_RAMPS4DUE.h +++ b/Marlin/src/pins/sam/pins_RAMPS4DUE.h @@ -39,7 +39,7 @@ * A15 | NC */ -#if !defined(__SAM3X8E__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__SAM3X8E__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino Due' or 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_RAMPS_DUO.h b/Marlin/src/pins/sam/pins_RAMPS_DUO.h index 5f8864ab1468..94f1b50776a9 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_DUO.h +++ b/Marlin/src/pins/sam/pins_RAMPS_DUO.h @@ -43,7 +43,7 @@ * A15 | A11 */ -#if !defined(__SAM3X8E__) && !defined(__AVR_ATmega2560__) +#if NOT_TARGET(__SAM3X8E__, __AVR_ATmega2560__) #error "Oops! Select 'Arduino Due' or 'Arduino/Genuino Mega or Mega 2560' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h index eb9889607d37..5662590e269f 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h @@ -28,7 +28,7 @@ * Use 4k7 thermistor tables */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_RAMPS_SMART.h b/Marlin/src/pins/sam/pins_RAMPS_SMART.h index 06eee2d970eb..9b76ee290b96 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_SMART.h +++ b/Marlin/src/pins/sam/pins_RAMPS_SMART.h @@ -60,7 +60,7 @@ * (Search the web for "Arduino DUE Board Pinout" to see the correct header.) */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index 3ecd64aa8aee..524c14d198f8 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -32,7 +32,7 @@ * | */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index 2b52338d35ca..187473b3dd43 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -32,7 +32,7 @@ * | */ -#ifndef __SAM3X8E__ +#if NOT_TARGET(__SAM3X8E__) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h index 75b29629e90d..0b91ba61d6df 100644 --- a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h +++ b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h @@ -26,7 +26,7 @@ * https://reprapworld.com/documentation/datasheet_ultratronics10_05.pdf */ -#ifndef ARDUINO_ARCH_SAM +#if NOT_TARGET(ARDUINO_ARCH_SAM) #error "Oops! Select 'Arduino Due' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 93e758b3ae66..388ac1a3312e 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -25,7 +25,7 @@ * AGCM4 with RAMPS v1.4.4 pin assignments */ -#ifndef ARDUINO_GRAND_CENTRAL_M4 +#if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) #error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_ANET_10.h b/Marlin/src/pins/sanguino/pins_ANET_10.h index d1ac131c0384..3978198eef86 100644 --- a/Marlin/src/pins/sanguino/pins_ANET_10.h +++ b/Marlin/src/pins/sanguino/pins_ANET_10.h @@ -89,7 +89,7 @@ * Many thanks to Hans Raaf (@oderwat) for developing the Anet-specific software and supporting the Anet community. */ -#ifndef __AVR_ATmega1284P__ +#if NOT_TARGET(__AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'melzi' or 'melzi_optiboot.')" #endif diff --git a/Marlin/src/pins/sanguino/pins_GEN3_MONOLITHIC.h b/Marlin/src/pins/sanguino/pins_GEN3_MONOLITHIC.h index 901e326742ab..e927aac124db 100644 --- a/Marlin/src/pins/sanguino/pins_GEN3_MONOLITHIC.h +++ b/Marlin/src/pins/sanguino/pins_GEN3_MONOLITHIC.h @@ -50,7 +50,7 @@ * */ -#ifndef __AVR_ATmega644P__ +#if NOT_TARGET(__AVR_ATmega644P__) #error "Oops! Select 'Sanguino' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_GEN3_PLUS.h b/Marlin/src/pins/sanguino/pins_GEN3_PLUS.h index a28b4c039ca9..1961446e2274 100644 --- a/Marlin/src/pins/sanguino/pins_GEN3_PLUS.h +++ b/Marlin/src/pins/sanguino/pins_GEN3_PLUS.h @@ -50,7 +50,7 @@ * */ -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644P' or 'ATmega1284P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_GEN6.h b/Marlin/src/pins/sanguino/pins_GEN6.h index ad54f3cd76f3..98eb616892e6 100644 --- a/Marlin/src/pins/sanguino/pins_GEN6.h +++ b/Marlin/src/pins/sanguino/pins_GEN6.h @@ -52,7 +52,7 @@ * */ -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644P' or 'ATmega1284P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_GEN7_12.h b/Marlin/src/pins/sanguino/pins_GEN7_12.h index 75b75cdc6fd4..ed550624f789 100644 --- a/Marlin/src/pins/sanguino/pins_GEN7_12.h +++ b/Marlin/src/pins/sanguino/pins_GEN7_12.h @@ -52,7 +52,7 @@ * */ -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega644__, __AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644', 'ATmega644P', or 'ATmega1284P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_GEN7_14.h b/Marlin/src/pins/sanguino/pins_GEN7_14.h index af0d824151d5..752fe3074f07 100644 --- a/Marlin/src/pins/sanguino/pins_GEN7_14.h +++ b/Marlin/src/pins/sanguino/pins_GEN7_14.h @@ -52,7 +52,7 @@ * */ -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega644__, __AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644', 'ATmega644P', or 'ATmega1284P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_GEN7_CUSTOM.h b/Marlin/src/pins/sanguino/pins_GEN7_CUSTOM.h index 27ec622fcea7..1a19c33deac4 100644 --- a/Marlin/src/pins/sanguino/pins_GEN7_CUSTOM.h +++ b/Marlin/src/pins/sanguino/pins_GEN7_CUSTOM.h @@ -55,7 +55,7 @@ * */ -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega644__, __AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644', 'ATmega644P', or 'ATmega1284P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_OMCA.h b/Marlin/src/pins/sanguino/pins_OMCA.h index 8e4c6d2b641d..d9f43995d481 100644 --- a/Marlin/src/pins/sanguino/pins_OMCA.h +++ b/Marlin/src/pins/sanguino/pins_OMCA.h @@ -77,7 +77,7 @@ * */ -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega644__) #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega644' or 'ATmega644P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_OMCA_A.h b/Marlin/src/pins/sanguino/pins_OMCA_A.h index 922ef69b5e64..1b4c9b68b215 100644 --- a/Marlin/src/pins/sanguino/pins_OMCA_A.h +++ b/Marlin/src/pins/sanguino/pins_OMCA_A.h @@ -76,7 +76,7 @@ * */ -#ifndef __AVR_ATmega644__ +#if NOT_TARGET(__AVR_ATmega644__) #error "Oops! Select 'Sanguino' in 'Tools > Board' and ATmega644 in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h index 83c2d56d2b36..4b4fb1d70ed7 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h @@ -52,7 +52,7 @@ * */ -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644P' or 'ATmega1284P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_SETHI.h b/Marlin/src/pins/sanguino/pins_SETHI.h index 19fea9ff537c..e0a0604619ce 100644 --- a/Marlin/src/pins/sanguino/pins_SETHI.h +++ b/Marlin/src/pins/sanguino/pins_SETHI.h @@ -50,7 +50,7 @@ * */ -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega644__, __AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644', 'ATmega644P', or 'ATmega1284P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index 262199e310cf..838ffe38aa9a 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) +#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) #error "Oops! Select 'Sanguino' in 'Tools > Boards' and 'ATmega644P' or 'ATmega1284P' in 'Tools > Processor.'" #endif diff --git a/Marlin/src/pins/stm32f0/pins_MALYAN_M200_V2.h b/Marlin/src/pins/stm32f0/pins_MALYAN_M200_V2.h index 0e5bd58987eb..abdd088f9bd3 100644 --- a/Marlin/src/pins/stm32f0/pins_MALYAN_M200_V2.h +++ b/Marlin/src/pins/stm32f0/pins_MALYAN_M200_V2.h @@ -22,7 +22,7 @@ #pragma once -#ifndef STM32F0xx +#if NOT_TARGET(STM32F0xx) #error "Oops! Select an STM32F0 board in your IDE." #endif diff --git a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h index d6a83aca1a30..dfa413b63fad 100644 --- a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h +++ b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h @@ -22,7 +22,7 @@ #pragma once -#if NONE(__STM32F1__, STM32F1xx, STM32F0xx) +#if NOT_TARGET(__STM32F1__, STM32F1xx, STM32F0xx) #error "Oops! Select a 'Malyan M300' board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index cff34daf2f02..e4f8e614bbfa 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef TARGET_STM32F1 +#if NOT_TARGET(TARGET_STM32F1) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index 923b0fa4c1b2..85c5f646d98a 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef TARGET_STM32F1 +#if NOT_TARGET(TARGET_STM32F1) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index 4a12d5d32db0..09dff2ef30f5 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef TARGET_STM32F1 +#if NOT_TARGET(TARGET_STM32F1) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index 5254166fa576..420ffc631f23 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef TARGET_STM32F1 +#if NOT_TARGET(TARGET_STM32F1) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 #error "CCROBOT-ONLINE MEEB_3DP only supports 1 hotend / E-stepper. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index bf9a7d8e0543..2521359e53dd 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__STM32F1__) && !defined(__STM32F4__) +#if NOT_TARGET(__STM32F1__, __STM32F4__) #error "Oops! Select an STM32F1/4 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h index 54ff9a779a30..10c615e524f9 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__STM32F1__) && !defined(__STM32F4__) +#if NOT_TARGET(__STM32F1__, __STM32F4__) #error "Oops! Select an STM32F1/4 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h index a825db275c6a..f8f3225f3cd4 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__STM32F1__) && !defined(__STM32F4__) +#if NOT_TARGET(__STM32F1__, __STM32F4__) #error "Oops! Select an STM32F1/4 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index f122a2b7c2ba..c1f1e315dfec 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -24,7 +24,7 @@ * CREALITY (STM32F103) board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h index 9453a6d515b2..5b51ece07f08 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h @@ -24,7 +24,7 @@ * CREALITY v4.2.7 (STM32F103) board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index ca9364a570d9..b7db592e7809 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 1f5e70a15a28..24aa83d9482f 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h index f07320db404c..5e8bd11b4bd0 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH_V12.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h index fe6c0b1325c9..b6520d563c38 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h @@ -26,7 +26,7 @@ * Schematic: https://github.com/chepo92/Smartto/blob/master/circuit_diagram/Rostock301/Hardware_GTM32_PRO_VB.pdf */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h index 716de610a710..7dbee215a0d6 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h @@ -26,7 +26,7 @@ * Schematic: https://github.com/chepo92/Smartto/blob/master/circuit_diagram/Rostock301/Hardware_GTM32_PRO_VB.pdf */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index fe6c0b1325c9..b6520d563c38 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -26,7 +26,7 @@ * Schematic: https://github.com/chepo92/Smartto/blob/master/circuit_diagram/Rostock301/Hardware_GTM32_PRO_VB.pdf */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h index 1fc4fa94249e..7731ffb5e734 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h @@ -26,7 +26,7 @@ * Schematic: https://github.com/chepo92/Smartto/blob/master/circuit_diagram/Rostock301/Hardware_GTM32_PRO_VB.pdf */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index d474eb25f6a7..64948039baf9 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -28,7 +28,7 @@ * Pin assignments for 32-bit JGAurora A5S & A1 */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 #error "JGAurora 32-bit board only supports 1 hotend / E-stepper. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index d08045ec16d5..799477ac1023 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -22,7 +22,7 @@ * Longer3D LK1/LK2 & Alfawise U20/U30 (STM32F103VET6) board pin assignments */ -#if !defined(__STM32F1__) && !defined(STM32F1xx) +#if NOT_TARGET(__STM32F1__, STM32F1xx) #error "Oops! Select a STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 #error "Longer3D board only supports 1 hotend / E-stepper. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h index 39c52ab0d30e..d3c26c497d8f 100644 --- a/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h +++ b/Marlin/src/pins/stm32f1/pins_MALYAN_M200.h @@ -25,7 +25,7 @@ * MALYAN M200 pin assignments */ -#if NONE(__STM32F1__, STM32F1xx, STM32F0xx) +#if NOT_TARGET(__STM32F1__, STM32F1xx, STM32F0xx) #error "Oops! Select an STM32 board in your IDE." #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 1ab9165830e0..e39c8f234285 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -27,7 +27,7 @@ * https://github.com/makerbase-mks/MKS-Robin/tree/master/MKS%20Robin/Hardware */ -#if !defined(STM32F1) && !defined(STM32F1xx) +#if NOT_TARGET(STM32F1, STM32F1xx) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "MKS Robin supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index 3f4dee0f6895..19f3c3efdac8 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -25,7 +25,7 @@ * MKS Robin nano (STM32F130VET6) board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 #error "MKS Robin e3p supports up to 1 hotends / E-steppers. Comment out this line to continue." @@ -184,7 +184,7 @@ #define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN #define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE - + #define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN #define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN #define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h index 9461a828af01..f6a3b555c399 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -25,7 +25,7 @@ * MKS Robin E3 & E3D (STM32F103RCT6) common board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index 3cf0bce06d36..2bd417951f0a 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 #error "MKS Robin Lite supports only 1 hotend / E-stepper. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h index 6ce6c6010501..bcb731df71a6 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h @@ -25,7 +25,7 @@ * MKS Robin Lite 3 (STM32F103RCT6) board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "MKS Robin Lite3 supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index 19b04c9e7c6f..a7e6a6e22773 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -25,7 +25,7 @@ * MKS Robin mini (STM32F130VET6) board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 #error "MKS Robin mini only supports 1 hotend / E-stepper. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index 88333e9b9f7a..e705b7b5704d 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -25,7 +25,7 @@ * MKS Robin nano (STM32F130VET6) board pin assignments */ -#if !defined(STM32F1) && !defined(STM32F1xx) +#if NOT_TARGET(STM32F1, STM32F1xx) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "MKS Robin nano supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index d911ab2b517b..ccb07b35f88c 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -25,7 +25,7 @@ * MKS Robin nano (STM32F130VET6) board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "MKS Robin nano supports up to 2 hotends / E-steppers. Comment out this line to continue." @@ -204,7 +204,7 @@ #define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN #define MT_DET_2_PIN PE6 // LVGL UI FILAMENT RUNOUT2 PIN #define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE - + #define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN #define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN #define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index 9b3817df8c7b..2e74b6b15f2b 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -25,7 +25,7 @@ * MKS Robin pro (STM32F103ZET6) board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 3 || E_STEPPERS > 3 #error "MKS Robin pro supports up to 3 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_MORPHEUS.h b/Marlin/src/pins/stm32f1/pins_MORPHEUS.h index 1cd3780ec59d..28262eaa828c 100644 --- a/Marlin/src/pins/stm32f1/pins_MORPHEUS.h +++ b/Marlin/src/pins/stm32f1/pins_MORPHEUS.h @@ -30,7 +30,7 @@ * MORPHEUS Board pin assignments */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_STM32F1R.h b/Marlin/src/pins/stm32f1/pins_STM32F1R.h index 63fb383c9b52..79f53f02c2f8 100644 --- a/Marlin/src/pins/stm32f1/pins_STM32F1R.h +++ b/Marlin/src/pins/stm32f1/pins_STM32F1R.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h index c18642fb1df1..468ee5394aae 100644 --- a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__STM32F1__) && !defined(__STM32F4__) +#if NOT_TARGET(__STM32F1__, __STM32F4__) #error "Oops! Select an STM32F1/4 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h index 598db026fd94..4745641ea934 100644 --- a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h @@ -28,7 +28,7 @@ * https://github.com/MarlinFirmware/Marlin/files/3401484/x5sa-main_board-2.pdf */ -#ifndef __STM32F1__ +#if NOT_TARGET(__STM32F1__) #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Trigorilla Pro supports up to 2 hotends / E-steppers. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f4/pins_ARMED.h b/Marlin/src/pins/stm32f4/pins_ARMED.h index 696241693629..db57db14d549 100644 --- a/Marlin/src/pins/stm32f4/pins_ARMED.h +++ b/Marlin/src/pins/stm32f4/pins_ARMED.h @@ -24,7 +24,7 @@ #pragma once -#ifndef STM32F4 +#if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Arm'ed supports up to 2 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_BEAST.h b/Marlin/src/pins/stm32f4/pins_BEAST.h index 691b468c343a..d23442ccedbf 100644 --- a/Marlin/src/pins/stm32f4/pins_BEAST.h +++ b/Marlin/src/pins/stm32f4/pins_BEAST.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__STM32F1__) && !defined(__STM32F4__) +#if NOT_TARGET(__STM32F1__, __STM32F4__) #error "Oops! Select an STM32F1/4 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h index dc0dab1cd15d..b13d495542f8 100644 --- a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h +++ b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h @@ -27,7 +27,7 @@ * Shield - https://github.com/jmz52/Hardware */ -#if !defined(STM32F4) && !defined(STM32F4xx) +#if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "Black STM32F4VET6 supports up to 2 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 009b1b65f1e8..7843572e13a2 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef STM32F4 +#if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 #error "BIGTREE BTT002 V1.0 supports up to 1 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 8cc1ca5e98b2..ddca719e5322 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef STM32F4 +#if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 8 || E_STEPPERS > 8 #error "BIGTREE GTR V1.0 supports up to 8 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index b45914284adf..e9abd66795c0 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef STM32F4 +#if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index a3a5ccdff8dc..808751d7a53d 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(STM32F4) && !defined(STM32F4xx) +#if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 6 || E_STEPPERS > 6 #error "FLYF407ZG supports up to 6 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 9ffedc2ac477..a6d7f8a495ad 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef STM32F4 +#if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 3 || E_STEPPERS > 3 #error "RUMBA32 supports up to 3 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h b/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h index 44b2e6b27cbc..ae469365a996 100644 --- a/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h +++ b/Marlin/src/pins/stm32f4/pins_GENERIC_STM32F4.h @@ -25,7 +25,7 @@ * To build with Arduino IDE use "Discovery F407VG" * To build with PlatformIO use environment "STM32F4" */ -#if !defined(STM32F4) && !defined(STM32F4xx) +#if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "STM32F4 supports up to 2 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h index 0f0d3d048c71..48973688a058 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h @@ -18,7 +18,7 @@ */ #pragma once -#if !defined(STM32F4) && !defined(STM32F4xx) +#if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "LERDGE K supports up to 2 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h index 2e55782edb41..0600ed43389f 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h @@ -18,7 +18,7 @@ */ #pragma once -#if !defined(STM32F4) && !defined(STM32F4xx) +#if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "LERDGE S supports up to 2 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h index da2851c1316d..bed51ca660cf 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h @@ -18,7 +18,7 @@ */ #pragma once -#if !defined(STM32F4) && !defined(STM32F4xx) +#if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 1 || E_STEPPERS > 1 #error "LERDGE X supports only one hotend / E-steppers" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h index bb04cb82ecf3..c2f5f324ba28 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef STM32F4 +#if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "MKS_ROBIN2 supports up to 2 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h index 90f9e500133a..338fda1e53a1 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h @@ -26,7 +26,7 @@ * */ -#ifndef STM32F4 +#if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 3 || E_STEPPERS > 3 #error "RUMBA32 boards support up to 3 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h index a0bd38b6acdc..0278dd8434b6 100644 --- a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h +++ b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h @@ -40,7 +40,7 @@ #pragma once -#ifndef STM32F4 +#if NOT_TARGET(STM32F4) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f4/pins_VAKE403D.h b/Marlin/src/pins/stm32f4/pins_VAKE403D.h index 1ffe25b49927..6c826b068d24 100644 --- a/Marlin/src/pins/stm32f4/pins_VAKE403D.h +++ b/Marlin/src/pins/stm32f4/pins_VAKE403D.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(STM32F4) && !defined(STM32F4xx) +#if NOT_TARGET(STM32F4, STM32F4xx) #error "Oops! Select an STM32F4 board in 'Tools > Board.'" #elif HOTENDS > 2 || E_STEPPERS > 2 #error "STM32F4 supports up to 2 hotends / E-steppers." diff --git a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h index 6706d26f645d..c3dc004728d8 100644 --- a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h +++ b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef STM32F7xx +#if NOT_TARGET(STM32F7xx) #error "Oops! Select an STM32F7 board in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/stm32f7/pins_THE_BORG.h b/Marlin/src/pins/stm32f7/pins_THE_BORG.h index 756f495e4b2e..c050824a83da 100644 --- a/Marlin/src/pins/stm32f7/pins_THE_BORG.h +++ b/Marlin/src/pins/stm32f7/pins_THE_BORG.h @@ -21,7 +21,7 @@ */ #pragma once -#ifndef STM32F7 +#if NOT_TARGET(STM32F7) #error "Oops! Select an STM32F7 board in 'Tools > Board.'" #elif HOTENDS > 3 || E_STEPPERS > 3 #error "The-Borg supports up to 3 hotends / E-steppers." diff --git a/Marlin/src/pins/teensy2/pins_5DPRINT.h b/Marlin/src/pins/teensy2/pins_5DPRINT.h index 7ba1fbcf8db8..908e12e0bae2 100644 --- a/Marlin/src/pins/teensy2/pins_5DPRINT.h +++ b/Marlin/src/pins/teensy2/pins_5DPRINT.h @@ -68,7 +68,7 @@ * https://bitbucket.org/makible/5dprint-d8-controller-board */ -#ifndef __AVR_AT90USB1286__ +#if NOT_TARGET(__AVR_AT90USB1286__) #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy2/pins_BRAINWAVE.h b/Marlin/src/pins/teensy2/pins_BRAINWAVE.h index ce1b4e3bbf74..97d210a0f852 100644 --- a/Marlin/src/pins/teensy2/pins_BRAINWAVE.h +++ b/Marlin/src/pins/teensy2/pins_BRAINWAVE.h @@ -68,7 +68,7 @@ * 4. The programmer is no longer needed. Remove it. */ -#ifndef __AVR_AT90USB646__ +#if NOT_TARGET(__AVR_AT90USB646__) #error "Oops! Select 'AT90USB646_TEENSYPP' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h b/Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h index eeca39c14c9f..e41fcaab9442 100644 --- a/Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h +++ b/Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h @@ -75,7 +75,7 @@ * 4. The programmer is no longer needed. Remove it. */ -#ifndef __AVR_AT90USB1286__ +#if NOT_TARGET(__AVR_AT90USB1286__) #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h index 7d96bd12ff9c..ffecc03b4a25 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h @@ -62,7 +62,7 @@ * 4. The programmer is no longer needed. Remove it. */ -#ifndef __AVR_AT90USB1286__ +#if NOT_TARGET(__AVR_AT90USB1286__) #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 83b17b65606c..3fb8c7f2593b 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -63,7 +63,7 @@ * 4. The programmer is no longer needed. Remove it. */ -#ifndef __AVR_AT90USB1286__ +#if NOT_TARGET(__AVR_AT90USB1286__) #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy2/pins_SAV_MKI.h b/Marlin/src/pins/teensy2/pins_SAV_MKI.h index cdd9b634bdb7..4d083ecd12e2 100644 --- a/Marlin/src/pins/teensy2/pins_SAV_MKI.h +++ b/Marlin/src/pins/teensy2/pins_SAV_MKI.h @@ -62,7 +62,7 @@ * 4. The programmer is no longer needed. Remove it. */ -#ifndef __AVR_AT90USB1286__ +#if NOT_TARGET(__AVR_AT90USB1286__) #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy2/pins_TEENSY2.h b/Marlin/src/pins/teensy2/pins_TEENSY2.h index 9ef31e84ba07..4efd83d9bc5c 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSY2.h +++ b/Marlin/src/pins/teensy2/pins_TEENSY2.h @@ -107,7 +107,7 @@ * E DIR 35 a7 a3 31 Y DIR */ -#ifndef __AVR_AT90USB1286__ +#if NOT_TARGET(__AVR_AT90USB1286__) #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy2/pins_TEENSYLU.h b/Marlin/src/pins/teensy2/pins_TEENSYLU.h index c69a1c06a785..09bbeebdd8c3 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSYLU.h +++ b/Marlin/src/pins/teensy2/pins_TEENSYLU.h @@ -73,7 +73,7 @@ * The pin assignments in this file match the silkscreen. */ -#if !defined(__AVR_AT90USB1286__) && !defined(__AVR_AT90USB1286P__) +#if NOT_TARGET(__AVR_AT90USB1286__, __AVR_AT90USB1286P__) #error "Oops! Select 'Teensy++ 2.0' or 'Printrboard' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy3/pins_TEENSY31_32.h b/Marlin/src/pins/teensy3/pins_TEENSY31_32.h index 863137e9c877..18d158295afe 100644 --- a/Marlin/src/pins/teensy3/pins_TEENSY31_32.h +++ b/Marlin/src/pins/teensy3/pins_TEENSY31_32.h @@ -27,7 +27,7 @@ * https://www.pjrc.com/teensy/teensyduino.html */ -#if !IS_32BIT_TEENSY +#if NOT_TARGET(IS_32BIT_TEENSY) #error "Oops! Select 'Teensy 3.1' or 'Teensy 3.2' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy3/pins_TEENSY35_36.h b/Marlin/src/pins/teensy3/pins_TEENSY35_36.h index 02d8374f23ed..6de50f0991a6 100644 --- a/Marlin/src/pins/teensy3/pins_TEENSY35_36.h +++ b/Marlin/src/pins/teensy3/pins_TEENSY35_36.h @@ -27,7 +27,7 @@ * https://www.pjrc.com/teensy/teensyduino.html ****************************************************************************************/ -#if !IS_32BIT_TEENSY +#if NOT_TARGET(IS_32BIT_TEENSY) #error "Oops! Select 'Teensy 3.5' or 'Teensy 3.6' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/teensy4/pins_T41U5XBB.h b/Marlin/src/pins/teensy4/pins_T41U5XBB.h index 1541bfbd62e8..b985d0bd9cf8 100644 --- a/Marlin/src/pins/teensy4/pins_T41U5XBB.h +++ b/Marlin/src/pins/teensy4/pins_T41U5XBB.h @@ -27,7 +27,7 @@ * https://www.pjrc.com/teensy/teensyduino.html ****************************************************************************************/ -#if !IS_32BIT_TEENSY || !IS_TEENSY41 +#if NOT_TARGET(IS_32BIT_TEENSY) || NOT_TARGET(IS_TEENSY41) #error "Oops! Select 'Teensy 4.1' in 'Tools > Board.'" #else #define BOARD_INFO_NAME "Teensy4.1" @@ -42,7 +42,7 @@ GND |-----#####-----| VIN (3.65 TO 5.5V) RX1 CS1 RX1 PWM 0 | ##### | GND TX1 MISO1 TX1 PWM 1 | | 3.3V - STPX PWM 2 | | 23 A9 PWM + STPX PWM 2 | | 23 A9 PWM DIRX PWM 3 | | 22 A8 PWM LIMZ STPY PWM 4 | | 21 A7 RX5 LIMY DIRY PWM 5 | | 20 A6 TX5 LIMX @@ -58,13 +58,13 @@ SDA PWM 25 | | 40 A16 STENY STPB MOSI1 26 | | 39 A15 MISO1 STENZ DIRB SCK1 27 | * * * * * | 38 A14 STENA - LIMB RX7 PWM 28 | | 37 PWM STENB + LIMB RX7 PWM 28 | | 37 PWM STENB DOOR TX7 PWM 29 | | 36 PWM ST0 ST1 30 | | 35 TX8 ST3 AUX0 31 | SDCARD | 34 RX8 ST2 AUX1 32 |_______________| 33 PWM AUX2 - + */ // diff --git a/Marlin/src/pins/teensy4/pins_TEENSY41.h b/Marlin/src/pins/teensy4/pins_TEENSY41.h index 08a3f5e0d139..c06fdc83e801 100644 --- a/Marlin/src/pins/teensy4/pins_TEENSY41.h +++ b/Marlin/src/pins/teensy4/pins_TEENSY41.h @@ -27,7 +27,7 @@ * https://www.pjrc.com/teensy/teensyduino.html ****************************************************************************************/ -#if !IS_32BIT_TEENSY || !IS_TEENSY41 +#if NOT_TARGET(IS_32BIT_TEENSY) || NOT_TARGET(IS_TEENSY41) #error "Oops! Select 'Teensy 4.1' in 'Tools > Board.'" #else #define BOARD_INFO_NAME "Teensy4.1" @@ -44,27 +44,27 @@ X_DIR_PIN MISO1 TX1 PWM 1 | | 3.3V Y_STEP_PIN PWM 2 | | 23 A9 PWM SERVO1_PIN Y_DIR_PIN PWM 3 | | 22 A8 PWM SERVO0_PIN - Z_STEP_PIN PWM 4 | | 21 A7 RX5 + Z_STEP_PIN PWM 4 | | 21 A7 RX5 Z_DIR_PIN PWM 5 | | 20 A6 TX5 FILWIDTH_PIN - X_ENABLE_PIN PWM 6 | | 19 A5 PWM SCL0 + X_ENABLE_PIN PWM 6 | | 19 A5 PWM SCL0 Y_ENABLE_PIN RX2 PWM 7 | | 18 A4 PWM SDA0 HEATER_1_PIN - Z_ENABLE_PIN TX2 PWM 8 | | 17 A3 RX4 SDA1 + Z_ENABLE_PIN TX2 PWM 8 | | 17 A3 RX4 SDA1 E0_STEP_PIN PWM 9 | | 16 A2 TX4 SCL1 TEMP_0_PIN E0_DIR_PIN PWM 10 | | 15 A1 PWM RX3 TEMP_BED_PIN MOSI_PIN MOSI0 PWM 11 | | 14 A0 PWM TX3 TEMP_1_PIN MISO_PIN MISO0 PWM 12 | | 13 LED PWM SCK0 SCK_PIN 3.3V | | GND - Z_STOP_PIN PWM 24 | | 41 A17 - E0_ENABLE_PIN PWM 25 | | 40 A16 + Z_STOP_PIN PWM 24 | | 41 A17 + E0_ENABLE_PIN PWM 25 | | 40 A16 FAN_PIN MOSI1 26 | | 39 A15 MISO1 X_STOP_PIN Z-PROBE PWR SCK1 27 | * * * * * | 38 A14 Y_STOP_PIN - SOL1_PIN RX7 PWM 28 | | 37 PWM HEATER_0_PIN + SOL1_PIN RX7 PWM 28 | | 37 PWM HEATER_0_PIN FAN_PIN TX7 PWM 29 | | 36 PWM HEATER_BED_PIN X_CS_PIN 30 | | 35 TX8 E1_ENABLE_PIN y_CS_PIN 31 | SDCARD | 34 RX8 E1_DIR_PIN Z_CS_PIN 32 |_______________| 33 PWM E1_STEP_PIN - + */ // diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies-post.py b/buildroot/share/PlatformIO/scripts/common-dependencies-post.py new file mode 100644 index 000000000000..2b1b948119f0 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/common-dependencies-post.py @@ -0,0 +1,16 @@ +# +# common-dependencies-post.py +# Convenience script to add build flags for Marlin Enabled Features +# + +Import("env") +Import("projenv") + +def apply_board_build_flags(): + if not 'BOARD_CUSTOM_BUILD_FLAGS' in env['MARLIN_FEATURES']: + return + projenv.Append(CCFLAGS=env['MARLIN_FEATURES']['BOARD_CUSTOM_BUILD_FLAGS'].split()) + +# We need to add the board build flags in a post script +# so the platform build script doesn't overwrite the custom CCFLAGS +apply_board_build_flags() diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index e88e74e81d04..344dce9f13ab 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -149,3 +149,6 @@ #define HAS_MENU_UBL #endif #endif + +// Include pins for the current board. Platform tests will be skipped. No HAL-defined pins. +#include "../../../../Marlin/src/pins/pins.h" diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index def3bf40c225..6005855156a8 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -238,7 +238,7 @@ def load_marlin_features(): else: cmd += ['-D' + s] - cmd += ['-w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] + cmd += ['-D__MARLIN_PREBUILD__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] cmd = ' '.join(cmd) blab(cmd) define_list = subprocess.check_output(cmd, shell=True).splitlines() diff --git a/platformio.ini b/platformio.ini index c68daf2c7172..f8ec029de3eb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -184,6 +184,7 @@ default_src_filter = + - - + extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py + post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py build_flags = -fmax-errors=5 -g -D__MARLIN_FIRMWARE__ -fmerge-all-constants lib_deps = From 023cb54fae55b6d05a028257036c52cd2e3b89b1 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Wed, 23 Sep 2020 13:07:34 -0700 Subject: [PATCH 42/63] MKS Robin Mini uses ONBOARD_SPI_DEVICE (#19460) --- Marlin/src/HAL/STM32F1/onboard_sd.cpp | 16 ++++++++-------- Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h | 2 +- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h | 2 +- Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h | 2 +- Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h | 2 +- Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 2 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h | 1 + 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.cpp b/Marlin/src/HAL/STM32F1/onboard_sd.cpp index 099e2a06869f..0440db9438a4 100644 --- a/Marlin/src/HAL/STM32F1/onboard_sd.cpp +++ b/Marlin/src/HAL/STM32F1/onboard_sd.cpp @@ -21,23 +21,23 @@ #include "fastio.h" #if HAS_SHARED_MEDIA - #ifndef ON_BOARD_SPI_DEVICE - #define ON_BOARD_SPI_DEVICE SPI_DEVICE + #ifndef ONBOARD_SPI_DEVICE + #define ONBOARD_SPI_DEVICE SPI_DEVICE #endif #define ONBOARD_SD_SPI SPI #else - SPIClass OnBoardSPI(ON_BOARD_SPI_DEVICE); - #define ONBOARD_SD_SPI OnBoardSPI + SPIClass OnboardSPI(ONBOARD_SPI_DEVICE); + #define ONBOARD_SD_SPI OnboardSPI #endif -#if ON_BOARD_SPI_DEVICE == 1 +#if ONBOARD_SPI_DEVICE == 1 #define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_4 #else #define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2 #endif -#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) /* Set OnBoardSPI cs low */ -#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) /* Set OnBoardSPI cs high */ +#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) /* Set OnboardSPI cs low */ +#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) /* Set OnboardSPI cs high */ #define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX) #define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256) @@ -152,7 +152,7 @@ static int select() { /* 1:OK, 0:Timeout */ /*-----------------------------------------------------------------------*/ static void power_on() { /* Enable SSP module and attach it to I/O pads */ - ONBOARD_SD_SPI.setModule(ON_BOARD_SPI_DEVICE); + ONBOARD_SD_SPI.setModule(ONBOARD_SPI_DEVICE); ONBOARD_SD_SPI.begin(); ONBOARD_SD_SPI.setBitOrder(MSBFIRST); ONBOARD_SD_SPI.setDataMode(SPI_MODE0); diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index e4f8e614bbfa..f018a40c3ef3 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -288,5 +288,5 @@ #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." #endif -#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index 85c5f646d98a..4f03d3bbd717 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -236,5 +236,5 @@ #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." #endif -#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index 09dff2ef30f5..aaecc054421a 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -213,5 +213,5 @@ #define MOSI_PIN PA7 #define SS_PIN PA4 #endif -#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index 420ffc631f23..e67a6d3b1bc5 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -173,7 +173,7 @@ #define SS_PIN PA4 #endif -#define ON_BOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for SD-NAND #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index c1f1e315dfec..eb910dd8466e 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -150,7 +150,7 @@ // #define SD_DETECT_PIN PC7 #define SDCARD_CONNECTION ONBOARD -#define ON_BOARD_SPI_DEVICE 1 +#define ONBOARD_SPI_DEVICE 1 #define ONBOARD_SD_CS_PIN PA4 // SDSS #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index a7e6a6e22773..b159ae3f4c78 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -126,6 +126,7 @@ #define SDIO_SUPPORT #define SDIO_CLOCK 4500000 // 4.5 MHz #define SD_DETECT_PIN PD12 +#define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PC11 // From 93421f3a00eb85bb25a7a3ce32b5c1a367ff83d5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Sep 2020 15:33:54 -0500 Subject: [PATCH 43/63] Teensy pins cleanup --- Marlin/src/pins/teensy3/pins_TEENSY31_32.h | 11 +-- Marlin/src/pins/teensy3/pins_TEENSY35_36.h | 100 ++++++++++----------- Marlin/src/pins/teensy4/pins_T41U5XBB.h | 83 +++++++++-------- Marlin/src/pins/teensy4/pins_TEENSY41.h | 84 ++++++++--------- 4 files changed, 134 insertions(+), 144 deletions(-) diff --git a/Marlin/src/pins/teensy3/pins_TEENSY31_32.h b/Marlin/src/pins/teensy3/pins_TEENSY31_32.h index 18d158295afe..b98c78fde1d3 100644 --- a/Marlin/src/pins/teensy3/pins_TEENSY31_32.h +++ b/Marlin/src/pins/teensy3/pins_TEENSY31_32.h @@ -35,9 +35,6 @@ #define BOARD_INFO_NAME "Teensy3.2" #endif -#define AT90USB 1286 // Disable MarlinSerial etc. -#define USBCON //1286 // Disable MarlinSerial etc. - // // Limit Switches // @@ -92,20 +89,14 @@ // // Misc. Functions // - -//#define SDSS 16 // 8 #define LED_PIN 13 - //#define SOL1_PIN 28 +//#define SDSS 16 // 8 // // LCD / Controller // -//#define SCK_PIN 13 -//#define MISO_PIN 12 -//#define MOSI_PIN 11 - /* #if HAS_SPI_LCD #define LCD_PINS_RS 40 diff --git a/Marlin/src/pins/teensy3/pins_TEENSY35_36.h b/Marlin/src/pins/teensy3/pins_TEENSY35_36.h index 6de50f0991a6..961dc0cff03f 100644 --- a/Marlin/src/pins/teensy3/pins_TEENSY35_36.h +++ b/Marlin/src/pins/teensy3/pins_TEENSY35_36.h @@ -37,48 +37,44 @@ #define BOARD_INFO_NAME "Teensy3.6" #endif -#define AT90USB 1286 // Disable MarlinSerial etc. -#define USBCON //1286 // Disable MarlinSerial etc. -/* - - teemuatlut plan for Teensy3.5 and Teensy3.6: - USB - GND |-----#####-----| VIN 5V - X_STEP_PIN MOSI1 RX1 0 | ##### | Analog GND - X_DIR_PIN MISO1 TX1 1 | | 3.3V - Y_STEP_PIN PWM 2 | *NC AREF* | 23 A9 PWM - Y_DIR_PIN SCL2 CAN0TX PWM 3 | *A26 A10* | 22 A8 PWM - Z_STEP_PIN SDA2 CAN0RX PWM 4 | *A25 A11* | 21 A7 PWM CS0 MOSI1 RX1 - Z_DIR_PIN MISO1 TX1 PWM 5 | *GND * * 57 | 20 A6 PWM CS0 SCK1 FILWIDTH_PIN - X_ENABLE_PIN PWM 6 | *GND * * 56 | 19 A5 SCL0 E0_STEP_PIN - Y_ENABLE_PIN SCL0 MOSI0 RX3 PWM 7 | * * 55 | 18 A4 SDA0 E0_DIR_PIN - Z_ENABLE_PIN SDA0 MISO0 TX3 PWM 8 | * * 54 | 17 A3 SDA0 E0_ENABLE_PIN - CS0 RX2 PWM 9 | | 16 A2 SCL0 TEMP_0_PIN - CS0 TX2 PWM 10 | | 15 A1 CS0 TEMP_BED_PIN - X_STOP_PIN MOSI0 11 | | 14 A0 PWM CS0 TEMP_1_PIN - Y_STOP_PIN MISO0 12 | | 13 LED SCK0 LED_PIN - 3.3V | | GND - Z_STOP_PIN 24 | 40 * * 53 | A22 DAC1 -AUX2 25 | 41 * * 52 | A21 DAC0 -AUX2 FAN_PIN SCL2 TX1 26 | 42 * * 51 | 39 A20 MISO0 SDSS -AUX2 Z-PROBE PWR SCK0 RX1 27 | * * * * * | 38 A19 PWM SDA1 -AUX2 SOL1_PIN MOSI0 28 | 43 * * 50 | 37 A18 PWM SCL1 -D10 CONTROLLER_FAN_PIN CAN0TX PWM 29 | 44 * * 49 | 36 A17 PWM -D9 HEATER_0_PIN CAN0RX PWM 30 | 45 * * 48 | 35 A16 PWM E1_ENABLE_PIN -D8 HEATER_BED_PIN CS1 RX4 A12 31 | 46 * * 47 | 34 A15 PWM SDA0 RX5 E1_DIR_PIN - SCK1 TX4 A13 32 |__GND_*_*_3.3V_| 33 A14 PWM SCL0 TX5 E1_STEP_PIN - - Interior pins: - LCD_PINS_RS 40 * * 53 SCK2 - LCD_PINS_ENABLE 41 * * 52 MOSI2 - LCD_PINS_D4 42 * * 51 MISO2 - LCD_PINS_D5 CS2 43 * * 50 A24 - LCD_PINS_D6 MOSI2 44 * * 49 A23 - LCD_PINS_D7 MISO2 45 * * 48 TX6 SDA0 BTN_ENC - BTN_EN1 SCK2 46 * * 47 RX6 SCL0 BTN_EN2 - GND * * 3.3V - -*/ +/** + * Plan for Teensy 3.5 and Teensy 3.6: + * USB + * GND |-----#####-----| VIN 5V + * X_STEP_PIN MOSI1 RX1 0 | ##### | Analog GND + * X_DIR_PIN MISO1 TX1 1 | | 3.3V + * Y_STEP_PIN PWM 2 | *NC AREF* | 23 A9 PWM + * Y_DIR_PIN SCL2 CAN0TX PWM 3 | *A26 A10* | 22 A8 PWM + * Z_STEP_PIN SDA2 CAN0RX PWM 4 | *A25 A11* | 21 A7 PWM CS0 MOSI1 RX1 + * Z_DIR_PIN MISO1 TX1 PWM 5 | *GND * * 57 | 20 A6 PWM CS0 SCK1 FILWIDTH_PIN + * X_ENABLE_PIN PWM 6 | *GND * * 56 | 19 A5 SCL0 E0_STEP_PIN + * Y_ENABLE_PIN SCL0 MOSI0 RX3 PWM 7 | * * 55 | 18 A4 SDA0 E0_DIR_PIN + * Z_ENABLE_PIN SDA0 MISO0 TX3 PWM 8 | * * 54 | 17 A3 SDA0 E0_ENABLE_PIN + * CS0 RX2 PWM 9 | | 16 A2 SCL0 TEMP_0_PIN + * CS0 TX2 PWM 10 | | 15 A1 CS0 TEMP_BED_PIN + * X_STOP_PIN MOSI0 11 | | 14 A0 PWM CS0 TEMP_1_PIN + * Y_STOP_PIN MISO0 12 | | 13 LED SCK0 LED_PIN + * 3.3V | | GND + * Z_STOP_PIN 24 | 40 * * 53 | A22 DAC1 + * AUX2 25 | 41 * * 52 | A21 DAC0 + * AUX2 FAN_PIN SCL2 TX1 26 | 42 * * 51 | 39 A20 MISO0 SDSS + * AUX2 Z-PROBE PWR SCK0 RX1 27 | * * * * * | 38 A19 PWM SDA1 + * AUX2 SOL1_PIN MOSI0 28 | 43 * * 50 | 37 A18 PWM SCL1 + * D10 CONTROLLER_FAN_PIN CAN0TX PWM 29 | 44 * * 49 | 36 A17 PWM + * D9 HEATER_0_PIN CAN0RX PWM 30 | 45 * * 48 | 35 A16 PWM E1_ENABLE_PIN + * D8 HEATER_BED_PIN CS1 RX4 A12 31 | 46 * * 47 | 34 A15 PWM SDA0 RX5 E1_DIR_PIN + * SCK1 TX4 A13 32 |__GND_*_*_3.3V_| 33 A14 PWM SCL0 TX5 E1_STEP_PIN + * + * Interior pins: + * LCD_PINS_RS 40 * * 53 SCK2 + * LCD_PINS_ENABLE 41 * * 52 MOSI2 + * LCD_PINS_D4 42 * * 51 MISO2 + * LCD_PINS_D5 CS2 43 * * 50 A24 + * LCD_PINS_D6 MOSI2 44 * * 49 A23 + * LCD_PINS_D7 MISO2 45 * * 48 TX6 SDA0 BTN_ENC + * BTN_EN1 SCK2 46 * * 47 RX6 SCL0 BTN_EN2 + * GND * * 3.3V + */ // // Limit Switches @@ -121,24 +117,18 @@ D8 HEATER_BED_PIN CS1 RX4 A12 31 | 46 * * 47 | 34 A15 PWM #define TEMP_1_PIN 0 #define TEMP_BED_PIN 1 // Bed / Analog pin numbering -#define SDSS 39 // 8 +// +// Misc. Functions +// #define LED_PIN 13 #define PS_ON_PIN 1 -#define ALARM_PIN -1 - #define FILWIDTH_PIN 6 #define SOL1_PIN 28 -#if 0 -// Pretty sure this is obsolete! -// Please use Marlin 1.1.x pins files as reference for new pins files. -#ifndef SDSUPPORT - // these are defined in the SD library if building with SD support - #define SCK_PIN 13 - #define MISO_PIN 12 - #define MOSI_PIN 11 -#endif -#endif +// +// SD Card +// +#define SDSS 39 // 8 #if HAS_SPI_LCD #define LCD_PINS_RS 40 diff --git a/Marlin/src/pins/teensy4/pins_T41U5XBB.h b/Marlin/src/pins/teensy4/pins_T41U5XBB.h index b985d0bd9cf8..cb4c0ea879bf 100644 --- a/Marlin/src/pins/teensy4/pins_T41U5XBB.h +++ b/Marlin/src/pins/teensy4/pins_T41U5XBB.h @@ -33,39 +33,44 @@ #define BOARD_INFO_NAME "Teensy4.1" #endif -#define AT90USB 1286 // Disable MarlinSerial etc. -#define USBCON //1286 // Disable MarlinSerial etc. -/* - - plan for Teensy4.0 and Teensy4.1: - USB - GND |-----#####-----| VIN (3.65 TO 5.5V) - RX1 CS1 RX1 PWM 0 | ##### | GND - TX1 MISO1 TX1 PWM 1 | | 3.3V - STPX PWM 2 | | 23 A9 PWM - DIRX PWM 3 | | 22 A8 PWM LIMZ - STPY PWM 4 | | 21 A7 RX5 LIMY - DIRY PWM 5 | | 20 A6 TX5 LIMX - STPZ PWM 6 | | 19 A5 PWM SCL0 COOL - DIRZ RX2 PWM 7 | | 18 A4 PWM SDA0 MIST - STPA TX2 PWM 8 | | 17 A3 RX4 SDA1 CYST - DIRA PWM 9 | | 16 A2 TX4 SCL1 EHOLD - STEN PWM 10 | | 15 A1 PWM RX3 PRB - SPDI MOSI0 PWM 11 | | 14 A0 PWM TX3 PANIC - SPEN MISO0 PWM 12 | | 13 LED PWM SCK0 SPWM - 3.3V | | GND - SCL PWM 24 | | 41 A17 KPSTR - SDA PWM 25 | | 40 A16 STENY - STPB MOSI1 26 | | 39 A15 MISO1 STENZ - DIRB SCK1 27 | * * * * * | 38 A14 STENA - LIMB RX7 PWM 28 | | 37 PWM STENB - DOOR TX7 PWM 29 | | 36 PWM ST0 - ST1 30 | | 35 TX8 ST3 - AUX0 31 | SDCARD | 34 RX8 ST2 - AUX1 32 |_______________| 33 PWM AUX2 +/** + * Plan for Teensy 4.0 and Teensy 4.1: + * USB + * GND |-----#####-----| VIN (3.65 TO 5.5V) + * RX1 CS1 RX1 PWM 0 | ##### | GND + * TX1 MISO1 TX1 PWM 1 | | 3.3V + * STPX PWM 2 | | 23 A9 PWM + * DIRX PWM 3 | | 22 A8 PWM LIMZ + * STPY PWM 4 | | 21 A7 RX5 LIMY + * DIRY PWM 5 | | 20 A6 TX5 LIMX + * STPZ PWM 6 | | 19 A5 PWM SCL0 COOL + * DIRZ RX2 PWM 7 | | 18 A4 PWM SDA0 MIST + * STPA TX2 PWM 8 | | 17 A3 RX4 SDA1 CYST + * DIRA PWM 9 | | 16 A2 TX4 SCL1 EHOLD + * STEN PWM 10 | | 15 A1 PWM RX3 PRB + * SPDI MOSI0 PWM 11 | | 14 A0 PWM TX3 PANIC + * SPEN MISO0 PWM 12 | | 13 LED PWM SCK0 SPWM + * 3.3V | | GND + * SCL PWM 24 | | 41 A17 KPSTR + * SDA PWM 25 | | 40 A16 STENY + * STPB MOSI1 26 | | 39 A15 MISO1 STENZ + * DIRB SCK1 27 | * * * * * | 38 A14 STENA + * LIMB RX7 PWM 28 | | 37 PWM STENB + * DOOR TX7 PWM 29 | | 36 PWM ST0 + * ST1 30 | | 35 TX8 ST3 + * AUX0 31 | SDCARD | 34 RX8 ST2 + * AUX1 32 |_______________| 33 PWM AUX2 + */ +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif -*/ +// +// Servos +// +#define SERVO0_PIN 24 +#define SERVO1_PIN 25 // // Limit Switches @@ -100,20 +105,22 @@ #define E1_DIR_PIN 27 #define E1_ENABLE_PIN 37 +// +// Heaters / Fans +// #define HEATER_0_PIN 31 #define HEATER_1_PIN 32 #define HEATER_BED_PIN 33 +// +// Temperature Sensors +// #define TEMP_0_PIN 5 // Extruder / Analog pin numbering: 2 => A2 #define TEMP_1_PIN 4 #define TEMP_BED_PIN 15 // Bed / Analog pin numbering +// +// Misc. Functions +// #define LED_PIN 13 - #define SOL0_PIN 17 -#define SERVO0_PIN 24 -#define SERVO1_PIN 25 - -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION ONBOARD -#endif diff --git a/Marlin/src/pins/teensy4/pins_TEENSY41.h b/Marlin/src/pins/teensy4/pins_TEENSY41.h index c06fdc83e801..cc7341bc2326 100644 --- a/Marlin/src/pins/teensy4/pins_TEENSY41.h +++ b/Marlin/src/pins/teensy4/pins_TEENSY41.h @@ -33,39 +33,40 @@ #define BOARD_INFO_NAME "Teensy4.1" #endif -#define AT90USB 1286 // Disable MarlinSerial etc. -#define USBCON //1286 // Disable MarlinSerial etc. -/* - - plan for Teensy4.0 and Teensy4.1: - USB - GND |-----#####-----| VIN (3.65 TO 5.5V) - X_STEP_PIN CS1 RX1 PWM 0 | ##### | GND - X_DIR_PIN MISO1 TX1 PWM 1 | | 3.3V - Y_STEP_PIN PWM 2 | | 23 A9 PWM SERVO1_PIN - Y_DIR_PIN PWM 3 | | 22 A8 PWM SERVO0_PIN - Z_STEP_PIN PWM 4 | | 21 A7 RX5 - Z_DIR_PIN PWM 5 | | 20 A6 TX5 FILWIDTH_PIN - X_ENABLE_PIN PWM 6 | | 19 A5 PWM SCL0 - Y_ENABLE_PIN RX2 PWM 7 | | 18 A4 PWM SDA0 HEATER_1_PIN - Z_ENABLE_PIN TX2 PWM 8 | | 17 A3 RX4 SDA1 - E0_STEP_PIN PWM 9 | | 16 A2 TX4 SCL1 TEMP_0_PIN - E0_DIR_PIN PWM 10 | | 15 A1 PWM RX3 TEMP_BED_PIN - MOSI_PIN MOSI0 PWM 11 | | 14 A0 PWM TX3 TEMP_1_PIN - MISO_PIN MISO0 PWM 12 | | 13 LED PWM SCK0 SCK_PIN - 3.3V | | GND - Z_STOP_PIN PWM 24 | | 41 A17 - E0_ENABLE_PIN PWM 25 | | 40 A16 - FAN_PIN MOSI1 26 | | 39 A15 MISO1 X_STOP_PIN - Z-PROBE PWR SCK1 27 | * * * * * | 38 A14 Y_STOP_PIN - SOL1_PIN RX7 PWM 28 | | 37 PWM HEATER_0_PIN - FAN_PIN TX7 PWM 29 | | 36 PWM HEATER_BED_PIN - X_CS_PIN 30 | | 35 TX8 E1_ENABLE_PIN - y_CS_PIN 31 | SDCARD | 34 RX8 E1_DIR_PIN - Z_CS_PIN 32 |_______________| 33 PWM E1_STEP_PIN - +/** + * Plan for Teensy 4.0 and Teensy 4.1: + * USB + * GND |-----#####-----| VIN (3.65 TO 5.5V) + * X_STEP_PIN CS1 RX1 PWM 0 | ##### | GND + * X_DIR_PIN MISO1 TX1 PWM 1 | | 3.3V + * Y_STEP_PIN PWM 2 | | 23 A9 PWM SERVO1_PIN + * Y_DIR_PIN PWM 3 | | 22 A8 PWM SERVO0_PIN + * Z_STEP_PIN PWM 4 | | 21 A7 RX5 + * Z_DIR_PIN PWM 5 | | 20 A6 TX5 FILWIDTH_PIN + * X_ENABLE_PIN PWM 6 | | 19 A5 PWM SCL0 + * Y_ENABLE_PIN RX2 PWM 7 | | 18 A4 PWM SDA0 HEATER_1_PIN + * Z_ENABLE_PIN TX2 PWM 8 | | 17 A3 RX4 SDA1 + * E0_STEP_PIN PWM 9 | | 16 A2 TX4 SCL1 TEMP_0_PIN + * E0_DIR_PIN PWM 10 | | 15 A1 PWM RX3 TEMP_BED_PIN + * MOSI_PIN MOSI0 PWM 11 | | 14 A0 PWM TX3 TEMP_1_PIN + * MISO_PIN MISO0 PWM 12 | | 13 LED PWM SCK0 SCK_PIN + * 3.3V | | GND + * Z_STOP_PIN PWM 24 | | 41 A17 + * E0_ENABLE_PIN PWM 25 | | 40 A16 + * FAN_PIN MOSI1 26 | | 39 A15 MISO1 X_STOP_PIN + * Z-PROBE PWR SCK1 27 | * * * * * | 38 A14 Y_STOP_PIN + * SOL1_PIN RX7 PWM 28 | | 37 PWM HEATER_0_PIN + * FAN_PIN TX7 PWM 29 | | 36 PWM HEATER_BED_PIN + * X_CS_PIN 30 | | 35 TX8 E1_ENABLE_PIN + * y_CS_PIN 31 | SDCARD | 34 RX8 E1_DIR_PIN + * Z_CS_PIN 32 |_______________| 33 PWM E1_STEP_PIN + */ -*/ +// +// Servos +// +#define SERVO0_PIN 22 +#define SERVO1_PIN 23 // // Limit Switches @@ -100,6 +101,9 @@ #define E1_DIR_PIN 34 #define E1_ENABLE_PIN 35 +// +// Heaters / Fans +// #define HEATER_0_PIN 37 #define HEATER_1_PIN 18 #define HEATER_BED_PIN 36 @@ -107,22 +111,20 @@ #define FAN_PIN 29 #endif +// +// Temperature Sensors +// #define TEMP_0_PIN 2 // Extruder / Analog pin numbering: 2 => A2 #define TEMP_1_PIN 0 #define TEMP_BED_PIN 1 // Bed / Analog pin numbering +// +// Misc. Functions +// #define LED_PIN 13 +#define SOL0_PIN 28 //#define PS_ON_PIN 1 -//#define ALARM_PIN -1 - //#define FILWIDTH_PIN 6 // A6 -#define SOL0_PIN 28 -#define SERVO0_PIN 22 -#define SERVO1_PIN 23 - -//#define SCK_PIN 13 -//#define MISO_PIN 12 -//#define MOSI_PIN 11 #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD From e3d4e328f93a04020124082a8342a34956a79ce4 Mon Sep 17 00:00:00 2001 From: ellensp Date: Thu, 24 Sep 2020 08:44:15 +1200 Subject: [PATCH 44/63] Preserve brightness in EEPROM validate (#19485) Co-authored-by: Scott Lahteine --- Marlin/src/module/settings.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6608b4033265..0fc23099ccb8 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1804,10 +1804,11 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(lcd_contrast); - int16_t lcd_contrast; EEPROM_READ(lcd_contrast); - TERN_(HAS_LCD_CONTRAST, ui.set_contrast(lcd_contrast)); + if (!validating) { + TERN_(HAS_LCD_CONTRAST, ui.set_contrast(lcd_contrast)); + } } // From 6634bedb258eb3ee7f59c3351f8472d32b323af8 Mon Sep 17 00:00:00 2001 From: ellensp Date: Thu, 24 Sep 2020 09:03:07 +1200 Subject: [PATCH 45/63] Define UART pins for LPC debug based on LPC_PINCFG_UART (#19475) --- Marlin/src/HAL/AVR/fastio.h | 16 ++++--- Marlin/src/HAL/AVR/pinsDebug.h | 4 +- Marlin/src/pins/pinsDebug.h | 82 ++++++++++++++++++++++++---------- 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h index bd6935aaf0ce..dd0163466110 100644 --- a/Marlin/src/HAL/AVR/fastio.h +++ b/Marlin/src/HAL/AVR/fastio.h @@ -29,11 +29,17 @@ #include -#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__)) -#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)) -#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)) -#define AVR_ATmega2561_FAMILY (defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)) -#define AVR_ATmega328_FAMILY (defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)) +#if defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__) + #define AVR_AT90USB1286_FAMILY 1 +#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__) + #define AVR_ATmega1284_FAMILY 1 +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + #define AVR_ATmega2560_FAMILY 1 +#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) + #define AVR_ATmega2561_FAMILY 1 +#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) + #define AVR_ATmega328_FAMILY 1 +#endif /** * Include Ports and Functions diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index d73f520d1494..2cf740a5597a 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -26,7 +26,9 @@ #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS -#define AVR_ATmega2560_FAMILY_PLUS_70 MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H) +#if MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H) + #define AVR_ATmega2560_FAMILY_PLUS_70 1 +#endif #if AVR_AT90USB1286_FAMILY diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index 0766d818e75f..06a8144291ca 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -45,7 +45,7 @@ #line 46 // manually add pins that have names that are macros which don't play well with these macros -#if (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY || defined(ARDUINO_ARCH_SAM) || defined(TARGET_LPC1768)) +#if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768) #if SERIAL_PORT == 0 static const char RXD_NAME_0[] PROGMEM = { "RXD0" }; static const char TXD_NAME_0[] PROGMEM = { "TXD0" }; @@ -110,83 +110,119 @@ const PinInfo pin_array[] PROGMEM = { // manually add pins ... #if SERIAL_PORT == 0 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_0, 0, true }, { TXD_NAME_0, 1, true }, #elif AVR_ATmega1284_FAMILY { RXD_NAME_0, 8, true }, { TXD_NAME_0, 9, true }, - #elif defined(TARGET_LPC1768) + #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 { RXD_NAME_0, 3, true }, { TXD_NAME_0, 2, true }, #endif #elif SERIAL_PORT == 1 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_1, 19, true }, { TXD_NAME_1, 18, true }, #elif AVR_ATmega1284_FAMILY { RXD_NAME_1, 10, true }, { TXD_NAME_1, 11, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_1, 16, true }, - { TXD_NAME_1, 15, true }, + #ifdef LPC_PINCFG_UART1_P2_00 // TX P2_00 RX P2_01 + { RXD_NAME_1, 0x41, true }, + { TXD_NAME_1, 0x40, true }, + #else // TX P0_15 RX P0_16 + { RXD_NAME_1, 16, true }, + { TXD_NAME_1, 15, true }, + #endif #endif #elif SERIAL_PORT == 2 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_2, 11, true }, - { TXD_NAME_2, 10, true }, + #ifdef LPC_PINCFG_UART2_P2_08 // TX P2_08 RX P2_09 + { RXD_NAME_2, 0x49, true }, + { TXD_NAME_2, 0x48, true }, + #else // TX P0_10 RX P0_11 + { RXD_NAME_2, 11, true }, + { TXD_NAME_2, 10, true }, + #endif #endif #elif SERIAL_PORT == 3 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_3, 1, true }, - { TXD_NAME_3, 0, true }, + #ifdef LPC_PINCFG_UART3_P0_25 // TX P0_25 RX P0_26 + { RXD_NAME_3, 0x1A, true }, + { TXD_NAME_3, 0x19, true }, + #elif defined(LPC_PINCFG_UART3_P4_28) // TX P4_28 RX P4_29 + { RXD_NAME_3, 0x9D, true }, + { TXD_NAME_3, 0x9C, true }, + #else // TX P0_00 RX P0_01 + { RXD_NAME_3, 1, true }, + { TXD_NAME_3, 0, true }, + #endif #endif #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == 0 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_0, 0, true }, { TXD_NAME_0, 1, true }, #elif AVR_ATmega1284_FAMILY { RXD_NAME_0, 8, true }, { TXD_NAME_0, 9, true }, - #elif defined(TARGET_LPC1768) + #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 { RXD_NAME_0, 3, true }, { TXD_NAME_0, 2, true }, #endif #elif SERIAL_PORT_2 == 1 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_1, 19, true }, { TXD_NAME_1, 18, true }, #elif AVR_ATmega1284_FAMILY { RXD_NAME_1, 10, true }, { TXD_NAME_1, 11, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_1, 16, true }, - { TXD_NAME_1, 15, true }, + #ifdef LPC_PINCFG_UART1_P2_00 // TX P2_00 RX P2_01 + { RXD_NAME_1, 0x41, true }, + { TXD_NAME_1, 0x40, true }, + #else // TX P0_15 RX P0_16 + { RXD_NAME_1, 16, true }, + { TXD_NAME_1, 15, true }, + #endif #endif #elif SERIAL_PORT_2 == 2 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_2, 11, true }, - { TXD_NAME_2, 10, true }, + #ifdef LPC_PINCFG_UART2_P2_08 // TX P2_08 RX P2_09 + { RXD_NAME_2, 0x49, true }, + { TXD_NAME_2, 0x48, true }, + #else // TX P0_10 RX P0_11 + { RXD_NAME_2, 11, true }, + { TXD_NAME_2, 10, true }, + #endif #endif #elif SERIAL_PORT_2 == 3 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_3, 1, true }, - { TXD_NAME_3, 0, true }, + #ifdef LPC_PINCFG_UART3_P0_25 // TX P0_25 RX P0_26 + { RXD_NAME_3, 0x1A, true }, + { TXD_NAME_3, 0x19, true }, + #elif defined(LPC_PINCFG_UART3_P4_28) // TX P4_28 RX P4_29 + { RXD_NAME_3, 0x9D, true }, + { TXD_NAME_3, 0x9C, true }, + #else // TX P0_00 RX P0_01 + { RXD_NAME_3, 1, true }, + { TXD_NAME_3, 0, true }, + #endif #endif #endif #endif From ecc80138123751945b6470d4cd95b13f00456a90 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Sep 2020 17:40:00 -0500 Subject: [PATCH 46/63] Whitespace cleanup --- Marlin/src/lcd/dwin/dwin_lcd.h | 2 +- Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/colors.h | 2 +- Marlin/src/module/stepper/trinamic.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/dwin/dwin_lcd.h b/Marlin/src/lcd/dwin/dwin_lcd.h index 11409666d893..9ae6d076d502 100644 --- a/Marlin/src/lcd/dwin/dwin_lcd.h +++ b/Marlin/src/lcd/dwin/dwin_lcd.h @@ -205,7 +205,7 @@ void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, // picIDe: Icon ending ID // x/y: Upper-left point // interval: Display time interval, unit 10mS -void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, +void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval); // Animation Control diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/colors.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/colors.h index 84639b59e12c..4e2fde6ab333 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/colors.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/theme/colors.h @@ -127,7 +127,7 @@ namespace Theme { #if ENABLED(TOUCH_UI_COCOA_PRESS) constexpr uint32_t syringe_rgb = 0xFFFFFF; constexpr uint32_t fluid_rgb = accent_color_5; - #else + #else constexpr uint32_t syringe_rgb = accent_color_5; constexpr uint32_t fluid_rgb = accent_color_3; #endif diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index a4b1b240f79e..d5a861d71ba0 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -802,10 +802,10 @@ void reset_trinamic_drivers() { } // TMC Slave Address Conflict Detection -// +// // Conflict detection is performed in the following way. Similar methods are used for // hardware and software serial, but the implementations are indepenent. -// +// // 1. Populate a data structure with UART parameters and addresses for all possible axis. // If an axis is not in use, populate it with recognizable placeholder data. // 2. For each axis in use, static_assert using a constexpr function, which counts the @@ -815,7 +815,7 @@ void reset_trinamic_drivers() { // Hardware serial names are compared as strings, since actually resolving them cannot occur in a constexpr. // Using a fixed-length character array for the port name allows this to be constexpr compatible. struct SanityHwSerialDetails { const char port[20]; uint32_t address; }; - #define TMC_HW_DETAIL_ARGS(A) TERN(A##_HAS_HW_SERIAL, STRINGIFY(A##_HARDWARE_SERIAL), ""), TERN0(A##_HAS_HW_SERIAL, A##_SLAVE_ADDRESS) + #define TMC_HW_DETAIL_ARGS(A) TERN(A##_HAS_HW_SERIAL, STRINGIFY(A##_HARDWARE_SERIAL), ""), TERN0(A##_HAS_HW_SERIAL, A##_SLAVE_ADDRESS) #define TMC_HW_DETAIL(A) {TMC_HW_DETAIL_ARGS(A)} constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { TMC_HW_DETAIL(X), TMC_HW_DETAIL(X2), From 928d874deac6258659033e8c4ac03a7766eb3ca6 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 24 Sep 2020 00:13:39 +0000 Subject: [PATCH 47/63] [cron] Bump distribution date (2020-09-24) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index f002ce563b9f..a889bef80ef3 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-23" + #define STRING_DISTRIBUTION_DATE "2020-09-24" #endif /** From 4b928b2da8ae26bd4a949debe470a914e23545ca Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Sep 2020 19:45:33 -0500 Subject: [PATCH 48/63] HAL and serial cleanup Co-Authored-By: Jason Smith <20053467+sjasonsmith@users.noreply.github.com> --- Marlin/src/HAL/AVR/HAL.h | 21 +---- Marlin/src/HAL/AVR/MarlinSerial.cpp | 20 ++--- Marlin/src/HAL/AVR/MarlinSerial.h | 6 +- Marlin/src/HAL/DUE/HAL.h | 47 +++-------- Marlin/src/HAL/ESP32/HAL.h | 3 - Marlin/src/HAL/HAL.h | 6 ++ Marlin/src/HAL/LINUX/HAL.h | 1 - Marlin/src/HAL/LINUX/main.cpp | 2 +- Marlin/src/HAL/LPC1768/HAL.h | 47 +++-------- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 37 ++++++--- Marlin/src/HAL/SAMD51/HAL.h | 46 +++-------- Marlin/src/HAL/STM32/HAL.h | 81 ++++++------------- Marlin/src/HAL/STM32/pinsDebug_STM32GENERIC.h | 2 +- Marlin/src/HAL/STM32F1/HAL.h | 5 +- Marlin/src/HAL/STM32F1/MarlinSerial.h | 1 + Marlin/src/HAL/STM32F1/sdio.cpp | 2 +- Marlin/src/HAL/STM32_F4_F7/HAL.h | 61 +++----------- Marlin/src/HAL/TEENSY31_32/HAL.h | 14 ++-- Marlin/src/HAL/TEENSY35_36/HAL.h | 14 ++-- Marlin/src/HAL/TEENSY40_41/HAL.h | 51 +++--------- Marlin/src/MarlinCore.cpp | 18 ++--- Marlin/src/gcode/config/M575.cpp | 19 +---- Marlin/src/inc/SanityCheck.h | 40 +++++++-- Marlin/src/lcd/extui/malyan_lcd.cpp | 6 +- Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h | 8 +- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h | 8 +- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 8 +- Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h | 8 +- Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h | 16 ++-- .../pins/stm32f1/pins_MKS_ROBIN_E3_common.h | 8 +- .../src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 16 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h | 17 ++-- buildroot/tests/malyan_M300-tests | 1 + 33 files changed, 220 insertions(+), 420 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 609375e386e8..fcaaf75c4a9e 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -81,12 +81,7 @@ typedef int8_t pin_t; // Serial ports #ifdef USBCON - #if ENABLED(BLUETOOTH) - #define MYSERIAL0 bluetoothSerial - #else - #define MYSERIAL0 Serial - #endif - #define NUM_SERIAL 1 + #define MYSERIAL0 TERN(BLUETOOTH, bluetoothSerial, Serial) #else #if !WITHIN(SERIAL_PORT, -1, 3) #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." @@ -97,36 +92,22 @@ typedef int8_t pin_t; #ifdef SERIAL_PORT_2 #if !WITHIN(SERIAL_PORT_2, -1, 3) #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." - #elif SERIAL_PORT_2 == SERIAL_PORT - #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration." #endif #define MYSERIAL1 customizedSerial2 - #define NUM_SERIAL 2 - #else - #define NUM_SERIAL 1 #endif #endif #ifdef DGUS_SERIAL_PORT #if !WITHIN(DGUS_SERIAL_PORT, -1, 3) #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration." - #elif DGUS_SERIAL_PORT == SERIAL_PORT - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration." #endif #define DGUS_SERIAL internalDgusSerial - #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free #endif #ifdef ANYCUBIC_LCD_SERIAL_PORT #if !WITHIN(ANYCUBIC_LCD_SERIAL_PORT, -1, 3) #error "ANYCUBIC_LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." - #elif ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT - #error "ANYCUBIC_LCD_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT_2 - #error "ANYCUBIC_LCD_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration." #endif #define ANYCUBIC_LCD_SERIAL anycubicLcdSerial #endif diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index 3d44a3f59ffc..838627001d14 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -712,11 +712,11 @@ } // Hookup ISR handlers - ISR(SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)) { + ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _RX_vect)) { MarlinSerial>::store_rxd_char(); } - ISR(SERIAL_REGNAME(USART,SERIAL_PORT,_UDRE_vect)) { + ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _UDRE_vect)) { MarlinSerial>::_tx_udr_empty_irq(); } @@ -729,11 +729,11 @@ #ifdef SERIAL_PORT_2 // Hookup ISR handlers - ISR(SERIAL_REGNAME(USART,SERIAL_PORT_2,_RX_vect)) { + ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _RX_vect)) { MarlinSerial>::store_rxd_char(); } - ISR(SERIAL_REGNAME(USART,SERIAL_PORT_2,_UDRE_vect)) { + ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _UDRE_vect)) { MarlinSerial>::_tx_udr_empty_irq(); } @@ -749,11 +749,11 @@ #ifdef INTERNAL_SERIAL_PORT - ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_RX_vect)) { + ISR(SERIAL_REGNAME(USART, INTERNAL_SERIAL_PORT, _RX_vect)) { MarlinSerial>::store_rxd_char(); } - ISR(SERIAL_REGNAME(USART,INTERNAL_SERIAL_PORT,_UDRE_vect)) { + ISR(SERIAL_REGNAME(USART, INTERNAL_SERIAL_PORT, _UDRE_vect)) { MarlinSerial>::_tx_udr_empty_irq(); } @@ -776,11 +776,11 @@ return ret; } - ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_RX_vect)) { + ISR(SERIAL_REGNAME(USART, DGUS_SERIAL_PORT, _RX_vect)) { MarlinSerial>::store_rxd_char(); } - ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_UDRE_vect)) { + ISR(SERIAL_REGNAME(USART, DGUS_SERIAL_PORT, _UDRE_vect)) { MarlinSerial>::_tx_udr_empty_irq(); } @@ -794,11 +794,11 @@ #ifdef ANYCUBIC_LCD_SERIAL_PORT - ISR(SERIAL_REGNAME(USART,ANYCUBIC_LCD_SERIAL_PORT,_RX_vect)) { + ISR(SERIAL_REGNAME(USART, ANYCUBIC_LCD_SERIAL_PORT, _RX_vect)) { MarlinSerial>::store_rxd_char(); } - ISR(SERIAL_REGNAME(USART,ANYCUBIC_LCD_SERIAL_PORT,_UDRE_vect)) { + ISR(SERIAL_REGNAME(USART, ANYCUBIC_LCD_SERIAL_PORT, _UDRE_vect)) { MarlinSerial>::_tx_udr_empty_irq(); } diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index e8bfc5583a91..8dbed4d85be4 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -48,11 +48,11 @@ // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) - #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) + #define SERIAL_REGNAME(registerbase,number,suffix) _SERIAL_REGNAME(registerbase,number,suffix) #if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary - #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix + #define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##suffix #else - #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix + #define _SERIAL_REGNAME(registerbase,number,suffix) registerbase##number##suffix #endif // Registers used by MarlinSerial class (expanded depending on selected serial port) diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 31409c76dd56..974f1ccc1649 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -38,57 +38,34 @@ #include +#define _MSERIAL(X) Serial##X +#define MSERIAL(X) _MSERIAL(X) +#define Serial0 Serial + // Define MYSERIAL0/1 before MarlinSerial includes! #if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER) #define MYSERIAL0 customizedSerial1 -#elif SERIAL_PORT == 0 - #define MYSERIAL0 Serial -#elif SERIAL_PORT == 1 - #define MYSERIAL0 Serial1 -#elif SERIAL_PORT == 2 - #define MYSERIAL0 Serial2 -#elif SERIAL_PORT == 3 - #define MYSERIAL0 Serial3 +#elif WITHIN(SERIAL_PORT, 0, 3) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) #else #error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 - #if SERIAL_PORT_2 == SERIAL_PORT - #error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration." - #elif SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER) + #if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER) #define MYSERIAL1 customizedSerial2 - #elif SERIAL_PORT_2 == 0 - #define MYSERIAL1 Serial - #elif SERIAL_PORT_2 == 1 - #define MYSERIAL1 Serial1 - #elif SERIAL_PORT_2 == 2 - #define MYSERIAL1 Serial2 - #elif SERIAL_PORT_2 == 3 - #define MYSERIAL1 Serial3 + #elif WITHIN(SERIAL_PORT_2, 0, 3) + #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif - #define NUM_SERIAL 2 -#else - #define NUM_SERIAL 1 #endif #ifdef DGUS_SERIAL_PORT - #if DGUS_SERIAL_PORT == SERIAL_PORT - #error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration." - #elif DGUS_SERIAL_PORT == -1 + #if DGUS_SERIAL_PORT == -1 #define DGUS_SERIAL internalDgusSerial - #elif DGUS_SERIAL_PORT == 0 - #define DGUS_SERIAL Serial - #elif DGUS_SERIAL_PORT == 1 - #define DGUS_SERIAL Serial1 - #elif DGUS_SERIAL_PORT == 2 - #define DGUS_SERIAL Serial2 - #elif DGUS_SERIAL_PORT == 3 - #define DGUS_SERIAL Serial3 + #elif WITHIN(DGUS_SERIAL_PORT, 0, 3) + #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT) #else #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index c91f9efff0b9..5eb84fdc3021 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -58,9 +58,6 @@ extern portMUX_TYPE spinlock; #else #define MYSERIAL1 webSocketSerial #endif - #define NUM_SERIAL 2 -#else - #define NUM_SERIAL 1 #endif #define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index c7b7531442db..8b6a978d2103 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -25,6 +25,12 @@ #include HAL_PATH(.,HAL.h) +#ifdef SERIAL_PORT_2 + #define NUM_SERIAL 2 +#else + #define NUM_SERIAL 1 +#endif + #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) #ifndef I2C_ADDRESS diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index 96e121d9153e..778ba2db4d71 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -62,7 +62,6 @@ uint8_t _getc(); extern HalSerial usb_serial; #define MYSERIAL0 usb_serial -#define NUM_SERIAL 1 #define ST7920_DELAY_1 DELAY_NS(600) #define ST7920_DELAY_2 DELAY_NS(750) diff --git a/Marlin/src/HAL/LINUX/main.cpp b/Marlin/src/HAL/LINUX/main.cpp index 4eeef318e7e7..481f059030b7 100644 --- a/Marlin/src/HAL/LINUX/main.cpp +++ b/Marlin/src/HAL/LINUX/main.cpp @@ -107,7 +107,7 @@ int main() { std::thread write_serial (write_serial_thread); std::thread read_serial (read_serial_thread); - #if NUM_SERIAL > 0 + #ifdef MYSERIAL0 MYSERIAL0.begin(BAUDRATE); SERIAL_ECHOLNPGM("x86_64 Initialized"); SERIAL_FLUSHTX(); diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 0153bacf42dd..e9f05fcc617d 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -63,56 +63,33 @@ extern "C" volatile uint32_t _millis; #define ST7920_DELAY_3 DELAY_NS(750) #endif +#define _MSERIAL(X) MSerial##X +#define MSERIAL(X) _MSERIAL(X) +#define MSerial0 MSerial + #if SERIAL_PORT == -1 #define MYSERIAL0 UsbSerial -#elif SERIAL_PORT == 0 - #define MYSERIAL0 MSerial -#elif SERIAL_PORT == 1 - #define MYSERIAL0 MSerial1 -#elif SERIAL_PORT == 2 - #define MYSERIAL0 MSerial2 -#elif SERIAL_PORT == 3 - #define MYSERIAL0 MSerial3 +#elif WITHIN(SERIAL_PORT, 0, 3) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 - #if SERIAL_PORT_2 == SERIAL_PORT - #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration." - #elif SERIAL_PORT_2 == -1 + #if SERIAL_PORT_2 == -1 #define MYSERIAL1 UsbSerial - #elif SERIAL_PORT_2 == 0 - #define MYSERIAL1 MSerial - #elif SERIAL_PORT_2 == 1 - #define MYSERIAL1 MSerial1 - #elif SERIAL_PORT_2 == 2 - #define MYSERIAL1 MSerial2 - #elif SERIAL_PORT_2 == 3 - #define MYSERIAL1 MSerial3 + #elif WITHIN(SERIAL_PORT_2, 0, 3) + #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif - #define NUM_SERIAL 2 -#else - #define NUM_SERIAL 1 #endif #ifdef DGUS_SERIAL_PORT - #if DGUS_SERIAL_PORT == SERIAL_PORT - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration." - #elif DGUS_SERIAL_PORT == -1 + #if DGUS_SERIAL_PORT == -1 #define DGUS_SERIAL UsbSerial - #elif DGUS_SERIAL_PORT == 0 - #define DGUS_SERIAL MSerial - #elif DGUS_SERIAL_PORT == 1 - #define DGUS_SERIAL MSerial1 - #elif DGUS_SERIAL_PORT == 2 - #define DGUS_SERIAL MSerial2 - #elif DGUS_SERIAL_PORT == 3 - #define DGUS_SERIAL MSerial3 + #elif WITHIN(DGUS_SERIAL_PORT, 0, 3) + #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT) #else #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 3fc1dd801a45..2ca8a29da4c6 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -89,6 +89,9 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o * Serial2 | P0_10 | P0_11 | * Serial3 | P0_00 | P0_01 | */ +#define ANY_TX(N,V...) DO(IS_TX##N,||,V) +#define ANY_RX(N,V...) DO(IS_RX##N,||,V) + #if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0) #define IS_TX0(P) (P == P0_02) #define IS_RX0(P) (P == P0_03) @@ -106,48 +109,56 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1 #define IS_TX1(P) (P == P0_15) #define IS_RX1(P) (P == P0_16) + #define _IS_TX1_1 IS_TX1 + #define _IS_RX1_1 IS_RX1 #if IS_TX1(TMC_SW_SCK) #error "Serial port pins (1) conflict with other pins!" #elif HAS_SPI_LCD #if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1) #error "Serial port pins (1) conflict with Encoder Buttons!" - #elif IS_TX1(SCK_PIN) || IS_TX1(LCD_PINS_D4) || IS_TX1(DOGLCD_SCK) || IS_TX1(LCD_RESET_PIN) || IS_TX1(LCD_PINS_RS) || IS_TX1(SHIFT_CLK) \ - || IS_RX1(LCD_SDSS) || IS_RX1(LCD_PINS_RS) || IS_RX1(MISO_PIN) || IS_RX1(DOGLCD_A0) || IS_RX1(SS_PIN) || IS_RX1(LCD_SDSS) || IS_RX1(DOGLCD_CS) || IS_RX1(LCD_RESET_PIN) || IS_RX1(LCD_BACKLIGHT_PIN) + #elif ANY_TX(1, SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \ + || ANY_RX(1, LCD_SDSS, LCD_PINS_RS, MISO_PIN, DOGLCD_A0, SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN) #error "Serial port pins (1) conflict with LCD pins!" #endif #endif #undef IS_TX1 #undef IS_RX1 + #undef _IS_TX1_1 + #undef _IS_RX1_1 #endif #if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2 #define IS_TX2(P) (P == P0_10) #define IS_RX2(P) (P == P0_11) - #if IS_TX2(X2_ENABLE_PIN) || IS_RX2(X2_DIR_PIN) || IS_RX2(X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN)) + #define _IS_TX2_1 IS_TX2 + #define _IS_RX2_1 IS_RX2 + #if IS_TX2(X2_ENABLE_PIN) || ANY_RX(2, X2_DIR_PIN, X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN)) #error "Serial port pins (2) conflict with X2 pins!" - #elif IS_TX2(Y2_ENABLE_PIN) || IS_RX2(Y2_DIR_PIN) || IS_RX2(Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN)) + #elif IS_TX2(Y2_ENABLE_PIN) || ANY_RX(2, Y2_DIR_PIN, Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN)) #error "Serial port pins (2) conflict with Y2 pins!" - #elif IS_TX2(Z2_ENABLE_PIN) || IS_RX2(Z2_DIR_PIN) || IS_RX2(Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN)) + #elif IS_TX2(Z2_ENABLE_PIN) || ANY_RX(2, Z2_DIR_PIN, Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN)) #error "Serial port pins (2) conflict with Z2 pins!" - #elif IS_TX2(Z3_ENABLE_PIN) || IS_RX2(Z3_DIR_PIN) || IS_RX2(Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN)) + #elif IS_TX2(Z3_ENABLE_PIN) || ANY_RX(2, Z3_DIR_PIN, Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN)) #error "Serial port pins (2) conflict with Z3 pins!" - #elif IS_TX2(Z4_ENABLE_PIN) || IS_RX2(Z4_DIR_PIN) || IS_RX2(Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN)) + #elif IS_TX2(Z4_ENABLE_PIN) || ANY_RX(2, Z4_DIR_PIN, Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN)) #error "Serial port pins (2) conflict with Z4 pins!" - #elif IS_RX2(X_DIR_PIN) || IS_RX2(Y_DIR_PIN) + #elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN) #error "Serial port pins (2) conflict with other pins!" #elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN) #error "Serial port pins (2) conflict with Y endstop pin!" #elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN) #error "Serial port pins (2) conflict with probe pin!" - #elif IS_TX2(X_ENABLE_PIN) || IS_RX2(X_DIR_PIN) || IS_TX2(Y_ENABLE_PIN) || IS_RX2(Y_DIR_PIN) + #elif ANY_TX(2, X_ENABLE_PIN, Y_ENABLE_PIN) || ANY_RX(2, X_DIR_PIN, Y_DIR_PIN) #error "Serial port pins (2) conflict with X/Y stepper pins!" #elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN))) #error "Serial port pins (2) conflict with E1 stepper pins!" - #elif EXTRUDERS && (IS_RX2(E0_DIR_PIN) || IS_RX2(E0_STEP_PIN)) + #elif EXTRUDERS && ANY_RX(2, E0_DIR_PIN, E0_STEP_PIN) #error "Serial port pins (2) conflict with E stepper pins!" #endif #undef IS_TX2 #undef IS_RX2 + #undef _IS_TX2_1 + #undef _IS_RX2_1 #endif #if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3 @@ -155,8 +166,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #define PIN_IS_RX3(P) (P##_PIN == P0_01) #if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX) #error "Serial port pins (3) conflict with X endstop pins!" - #elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) \ - || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX) + #elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX) #error "Serial port pins (3) conflict with X/Y axis UART pins!" #elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP) #error "Serial port pins (3) conflict with X2 pins!" @@ -175,6 +185,9 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #undef PIN_IS_RX3 #endif +#undef ANY_TX +#undef ANY_RX + // // Flag any i2c pin conflicts // diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index ea0f694cdc02..b516cb769fb3 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -35,56 +35,32 @@ // MYSERIAL0 required before MarlinSerial includes! + #define _MSERIAL(X) Serial##X + #define MSERIAL(X) _MSERIAL(INCREMENT(X)) + #if SERIAL_PORT == -1 #define MYSERIAL0 Serial - #elif SERIAL_PORT == 0 - #define MYSERIAL0 Serial1 - #elif SERIAL_PORT == 1 - #define MYSERIAL0 Serial2 - #elif SERIAL_PORT == 2 - #define MYSERIAL0 Serial3 - #elif SERIAL_PORT == 3 - #define MYSERIAL0 Serial4 + #elif WITHIN(SERIAL_PORT, 0, 3) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 - #if SERIAL_PORT_2 == SERIAL_PORT - #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration." - #elif SERIAL_PORT_2 == -1 + #if SERIAL_PORT_2 == -1 #define MYSERIAL1 Serial - #elif SERIAL_PORT_2 == 0 - #define MYSERIAL1 Serial1 - #elif SERIAL_PORT_2 == 1 - #define MYSERIAL1 Serial2 - #elif SERIAL_PORT_2 == 2 - #define MYSERIAL1 Serial3 - #elif SERIAL_PORT_2 == 3 - #define MYSERIAL1 Serial4 + #elif WITHIN(SERIAL_PORT_2, 0, 3) + #define MYSERIAL0 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif - #define NUM_SERIAL 2 - #else - #define NUM_SERIAL 1 #endif #ifdef DGUS_SERIAL_PORT - #if DGUS_SERIAL_PORT == SERIAL_PORT - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration." - #elif DGUS_SERIAL_PORT == -1 + #if DGUS_SERIAL_PORT == -1 #define DGUS_SERIAL Serial - #elif DGUS_SERIAL_PORT == 0 - #define DGUS_SERIAL Serial1 - #elif DGUS_SERIAL_PORT == 1 - #define DGUS_SERIAL Serial2 - #elif DGUS_SERIAL_PORT == 2 - #define DGUS_SERIAL Serial3 - #elif DGUS_SERIAL_PORT == 2 - #define DGUS_SERIAL Serial4 + #elif WITHIN(DGUS_SERIAL_PORT, 0, 3) + #define MYSERIAL0 MSERIAL(DGUS_SERIAL_PORT) #else #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 08081331b736..9ec2d5c19e83 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -43,82 +43,47 @@ // ------------------------ // Defines // ------------------------ +#define _MSERIAL(X) MSerial##X +#define MSERIAL(X) _MSERIAL(X) -#if SERIAL_PORT == 0 - #error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." -#elif SERIAL_PORT == -1 +#if SERIAL_PORT == -1 #define MYSERIAL0 SerialUSB -#elif SERIAL_PORT == 1 - #define MYSERIAL0 MSerial1 -#elif SERIAL_PORT == 2 - #define MYSERIAL0 MSerial2 -#elif SERIAL_PORT == 3 - #define MYSERIAL0 MSerial3 -#elif SERIAL_PORT == 4 - #define MYSERIAL0 MSerial4 -#elif SERIAL_PORT == 5 - #define MYSERIAL0 MSerial5 -#elif SERIAL_PORT == 6 - #define MYSERIAL0 MSerial6 +#elif WITHIN(SERIAL_PORT, 1, 6) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) #else - #error "SERIAL_PORT must be from -1 to 6. Please update your configuration." + #error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." #endif #ifdef SERIAL_PORT_2 - #define NUM_SERIAL 2 - #if SERIAL_PORT_2 == 0 - #error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration." - #elif SERIAL_PORT_2 == SERIAL_PORT - #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration." - #elif SERIAL_PORT_2 == -1 + #if SERIAL_PORT_2 == -1 #define MYSERIAL1 SerialUSB - #elif SERIAL_PORT_2 == 1 - #define MYSERIAL1 MSerial1 - #elif SERIAL_PORT_2 == 2 - #define MYSERIAL1 MSerial2 - #elif SERIAL_PORT_2 == 3 - #define MYSERIAL1 MSerial3 - #elif SERIAL_PORT_2 == 4 - #define MYSERIAL1 MSerial4 - #elif SERIAL_PORT_2 == 5 - #define MYSERIAL1 MSerial5 - #elif SERIAL_PORT_2 == 6 - #define MYSERIAL1 MSerial6 + #elif WITHIN(SERIAL_PORT_2, 1, 6) + #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #else - #error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration." + #error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration." #endif -#else - #define NUM_SERIAL 1 #endif #if HAS_DGUS_LCD - #if DGUS_SERIAL_PORT == 0 - #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." - #elif DGUS_SERIAL_PORT == SERIAL_PORT - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration." - #elif DGUS_SERIAL_PORT == -1 + #if DGUS_SERIAL_PORT == -1 #define DGUS_SERIAL SerialUSB - #elif DGUS_SERIAL_PORT == 1 - #define DGUS_SERIAL MSerial1 - #elif DGUS_SERIAL_PORT == 2 - #define DGUS_SERIAL MSerial2 - #elif DGUS_SERIAL_PORT == 3 - #define DGUS_SERIAL MSerial3 - #elif DGUS_SERIAL_PORT == 4 - #define DGUS_SERIAL MSerial4 - #elif DGUS_SERIAL_PORT == 5 - #define DGUS_SERIAL MSerial5 - #elif DGUS_SERIAL_PORT == 6 - #define DGUS_SERIAL MSerial6 + #elif WITHIN(DGUS_SERIAL_PORT, 1, 6) + #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT) #else - #error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration." + #error "DGUS_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." #endif - #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite #endif +#if ENABLED(MALYAN_LCD) + #if LCD_SERIAL_PORT == -1 + #define LCD_SERIAL SerialUSB + #elif WITHIN(LCD_SERIAL_PORT, 1, 6) + #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) + #else + #error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." + #endif +#endif /** * TODO: review this to return 1 for pins that are not analog input diff --git a/Marlin/src/HAL/STM32/pinsDebug_STM32GENERIC.h b/Marlin/src/HAL/STM32/pinsDebug_STM32GENERIC.h index 5ff40debea5e..9069d9f7bd8a 100644 --- a/Marlin/src/HAL/STM32/pinsDebug_STM32GENERIC.h +++ b/Marlin/src/HAL/STM32/pinsDebug_STM32GENERIC.h @@ -98,7 +98,7 @@ static inline void pwm_details(const pin_t pin) { timer_dev * const tdev = PIN_MAP[pin].timer_device; const uint8_t channel = PIN_MAP[pin].timer_channel; const char num = ( - #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) + #if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY) tdev == &timer8 ? '8' : tdev == &timer5 ? '5' : #endif diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index f76d8c54a0e3..47414cb45e10 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -53,7 +53,7 @@ // ------------------------ #ifndef STM32_FLASH_SIZE - #if defined(MCU_STM32F103RE) || defined(MCU_STM32F103VE) + #if EITHER(MCU_STM32F103RE, MCU_STM32F103VE) #define STM32_FLASH_SIZE 512 #else #define STM32_FLASH_SIZE 256 @@ -106,9 +106,6 @@ #else #error "SERIAL_PORT_2 must be from -1 to 5. Please update your configuration." #endif - #define NUM_SERIAL 2 -#else - #define NUM_SERIAL 1 #endif #ifdef DGUS_SERIAL diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.h b/Marlin/src/HAL/STM32F1/MarlinSerial.h index eb0059bfbcae..b9248e50caff 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.h +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.h @@ -30,6 +30,7 @@ #include "../../feature/e_parser.h" #endif +// Increase priority of serial interrupts, to reduce overflow errors #define UART_IRQ_PRIO 1 class MarlinSerial : public HardwareSerial { diff --git a/Marlin/src/HAL/STM32F1/sdio.cpp b/Marlin/src/HAL/STM32F1/sdio.cpp index 0e9a3b2d0450..ffa6db1206ae 100644 --- a/Marlin/src/HAL/STM32F1/sdio.cpp +++ b/Marlin/src/HAL/STM32F1/sdio.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density -#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) +#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY) #include "sdio.h" diff --git a/Marlin/src/HAL/STM32_F4_F7/HAL.h b/Marlin/src/HAL/STM32_F4_F7/HAL.h index 5601400c5ac9..e132168205bb 100644 --- a/Marlin/src/HAL/STM32_F4_F7/HAL.h +++ b/Marlin/src/HAL/STM32_F4_F7/HAL.h @@ -46,24 +46,16 @@ // Serial override //extern HalSerial usb_serial; +#define _MSERIAL(X) SerialUART##X +#define MSERIAL(X) _MSERIAL(X) +#define SerialUART0 Serial1 + #if defined(STM32F4) && SERIAL_PORT == 0 #error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." #elif SERIAL_PORT == -1 #define MYSERIAL0 SerialUSB -#elif SERIAL_PORT == 0 - #define MYSERIAL0 Serial1 -#elif SERIAL_PORT == 1 - #define MYSERIAL0 SerialUART1 -#elif SERIAL_PORT == 2 - #define MYSERIAL0 SerialUART2 -#elif SERIAL_PORT == 3 - #define MYSERIAL0 SerialUART3 -#elif SERIAL_PORT == 4 - #define MYSERIAL0 SerialUART4 -#elif SERIAL_PORT == 5 - #define MYSERIAL0 SerialUART5 -#elif SERIAL_PORT == 6 - #define MYSERIAL0 SerialUART6 +#elif WITHIN(SERIAL_PORT, 0, 6) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be from -1 to 6. Please update your configuration." #endif @@ -71,55 +63,22 @@ #ifdef SERIAL_PORT_2 #if defined(STM32F4) && SERIAL_PORT_2 == 0 #error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration." - #elif SERIAL_PORT_2 == SERIAL_PORT - #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration." #elif SERIAL_PORT_2 == -1 #define MYSERIAL1 SerialUSB - #elif SERIAL_PORT_2 == 0 - #define MYSERIAL1 Serial1 - #elif SERIAL_PORT_2 == 1 - #define MYSERIAL1 SerialUART1 - #elif SERIAL_PORT_2 == 2 - #define MYSERIAL1 SerialUART2 - #elif SERIAL_PORT_2 == 3 - #define MYSERIAL1 SerialUART3 - #elif SERIAL_PORT_2 == 4 - #define MYSERIAL1 SerialUART4 - #elif SERIAL_PORT_2 == 5 - #define MYSERIAL1 SerialUART5 - #elif SERIAL_PORT_2 == 6 - #define MYSERIAL1 SerialUART6 + #elif WITHIN(SERIAL_PORT_2, 0, 6) + #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration." #endif - #define NUM_SERIAL 2 -#else - #define NUM_SERIAL 1 #endif #ifdef DGUS_SERIAL_PORT #if defined(STM32F4) && DGUS_SERIAL_PORT == 0 #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." - #elif DGUS_SERIAL_PORT == SERIAL_PORT - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration." #elif DGUS_SERIAL_PORT == -1 #define DGUS_SERIAL SerialUSB - #elif DGUS_SERIAL_PORT == 0 - #define DGUS_SERIAL Serial1 - #elif DGUS_SERIAL_PORT == 1 - #define DGUS_SERIAL SerialUART1 - #elif DGUS_SERIAL_PORT == 2 - #define DGUS_SERIAL SerialUART2 - #elif DGUS_SERIAL_PORT == 3 - #define DGUS_SERIAL SerialUART3 - #elif DGUS_SERIAL_PORT == 4 - #define DGUS_SERIAL SerialUART4 - #elif DGUS_SERIAL_PORT == 5 - #define DGUS_SERIAL SerialUART5 - #elif DGUS_SERIAL_PORT == 6 - #define DGUS_SERIAL SerialUART6 + #elif WITHIN(DGUS_SERIAL_PORT, 0, 6) + #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT) #else #error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration." #endif diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index ad095cba83cc..31ceb8b87c9a 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -49,18 +49,14 @@ #define IS_TEENSY32 1 #endif -#define NUM_SERIAL 1 +#define _MSERIAL(X) Serial##X +#define MSERIAL(X) _MSERIAL(X) +#define Serial0 Serial #if SERIAL_PORT == -1 #define MYSERIAL0 SerialUSB -#elif SERIAL_PORT == 0 - #define MYSERIAL0 Serial -#elif SERIAL_PORT == 1 - #define MYSERIAL0 Serial1 -#elif SERIAL_PORT == 2 - #define MYSERIAL0 Serial2 -#elif SERIAL_PORT == 3 - #define MYSERIAL0 Serial3 +#elif WITHIN(SERIAL_PORT, 0, 3) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) #endif #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 96be08d7b7ca..11f0fb941e93 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -54,18 +54,14 @@ #define IS_TEENSY36 1 #endif -#define NUM_SERIAL 1 +#define _MSERIAL(X) Serial##X +#define MSERIAL(X) _MSERIAL(X) +#define Serial0 Serial #if SERIAL_PORT == -1 #define MYSERIAL0 SerialUSB -#elif SERIAL_PORT == 0 - #define MYSERIAL0 Serial -#elif SERIAL_PORT == 1 - #define MYSERIAL0 Serial1 -#elif SERIAL_PORT == 2 - #define MYSERIAL0 Serial2 -#elif SERIAL_PORT == 3 - #define MYSERIAL0 Serial3 +#elif WITHIN(SERIAL_PORT, 0, 3) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) #endif #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 0626d4ee9cda..77f7af295668 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -50,59 +50,26 @@ #define IS_TEENSY41 1 #endif +#define _MSERIAL(X) Serial##X +#define MSERIAL(X) _MSERIAL(X) +#define Serial0 Serial + #if SERIAL_PORT == -1 #define MYSERIAL0 SerialUSB -#elif SERIAL_PORT == 0 - #define MYSERIAL0 Serial -#elif SERIAL_PORT == 1 - #define MYSERIAL0 Serial1 -#elif SERIAL_PORT == 2 - #define MYSERIAL0 Serial2 -#elif SERIAL_PORT == 3 - #define MYSERIAL0 Serial3 -#elif SERIAL_PORT == 4 - #define MYSERIAL0 Serial4 -#elif SERIAL_PORT == 5 - #define MYSERIAL0 Serial5 -#elif SERIAL_PORT == 6 - #define MYSERIAL0 Serial6 -#elif SERIAL_PORT == 7 - #define MYSERIAL0 Serial7 -#elif SERIAL_PORT == 8 - #define MYSERIAL0 Serial8 +#elif WITHIN(SERIAL_PORT, 0, 8) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) #else #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration." #endif #ifdef SERIAL_PORT_2 - #if SERIAL_PORT_2 == SERIAL_PORT - #error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration." - #elif SERIAL_PORT_2 == -1 + #if SERIAL_PORT_2 == -1 #define MYSERIAL1 usbSerial - #elif SERIAL_PORT_2 == 0 - #define MYSERIAL1 Serial - #elif SERIAL_PORT_2 == 1 - #define MYSERIAL1 Serial1 - #elif SERIAL_PORT_2 == 2 - #define MYSERIAL1 Serial2 - #elif SERIAL_PORT_2 == 3 - #define MYSERIAL1 Serial3 - #elif SERIAL_PORT_2 == 4 - #define MYSERIAL1 Serial4 - #elif SERIAL_PORT_2 == 5 - #define MYSERIAL1 Serial5 - #elif SERIAL_PORT_2 == 6 - #define MYSERIAL1 Serial6 - #elif SERIAL_PORT_2 == 7 - #define MYSERIAL1 Serial7 - #elif SERIAL_PORT_2 == 8 - #define MYSERIAL1 Serial8 + #elif WITHIN(SERIAL_PORT_2, 0, 8) + #define MYSERIAL0 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 8. Please update your configuration." #endif - #define NUM_SERIAL 2 -#else - #define NUM_SERIAL 1 #endif #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 22935c146073..e11439861bd4 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -912,17 +912,15 @@ void setup() { #endif #endif - #if NUM_SERIAL > 0 - MYSERIAL0.begin(BAUDRATE); - uint32_t serial_connect_timeout = millis() + 1000UL; - while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } - #if HAS_MULTI_SERIAL - MYSERIAL1.begin(BAUDRATE); - serial_connect_timeout = millis() + 1000UL; - while (!MYSERIAL1 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } - #endif - SERIAL_ECHO_MSG("start"); + MYSERIAL0.begin(BAUDRATE); + uint32_t serial_connect_timeout = millis() + 1000UL; + while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + #if HAS_MULTI_SERIAL + MYSERIAL1.begin(BAUDRATE); + serial_connect_timeout = millis() + 1000UL; + while (!MYSERIAL1 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #endif + SERIAL_ECHO_MSG("start"); #if BOTH(HAS_TFT_LVGL_UI, USE_WIFI_FUNCTION) mks_esp_wifi_init(); diff --git a/Marlin/src/gcode/config/M575.cpp b/Marlin/src/gcode/config/M575.cpp index 3aa5844653c2..44723b7f2fe6 100644 --- a/Marlin/src/gcode/config/M575.cpp +++ b/Marlin/src/gcode/config/M575.cpp @@ -53,23 +53,10 @@ void GcodeSuite::M575() { case 115200: case 250000: case 500000: case 1000000: { const int8_t port = parser.intval('P', -99); const bool set0 = (port == -99 || port == 0); - if (set0) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(" Serial " - #if HAS_MULTI_SERIAL - , '0', - #else - "0" - #endif - " baud rate set to ", baud - ); - } + if (set0) SERIAL_ECHO_MSG(" Serial ", '0', " baud rate set to ", baud); #if HAS_MULTI_SERIAL const bool set1 = (port == -99 || port == 1); - if (set1) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(" Serial ", '1', " baud rate set to ", baud); - } + if (set1) SERIAL_ECHO_MSG(" Serial ", '1', " baud rate set to ", baud); #endif SERIAL_FLUSH(); @@ -85,4 +72,4 @@ void GcodeSuite::M575() { } } -#endif // NUM_SERIAL > 0 && BAUD_RATE_GCODE +#endif // BAUD_RATE_GCODE diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8d68b33ece20..4c0b68e8aec0 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -582,12 +582,10 @@ #error "SERIAL_XON_XOFF and SERIAL_STATS_* features not supported on USB-native AVR devices." #endif -#if SERIAL_PORT > 7 - #error "Set SERIAL_PORT to the port on your board. Usually this is 0." -#endif - -#if defined(SERIAL_PORT_2) && NUM_SERIAL < 2 - #error "SERIAL_PORT_2 is not supported for your MOTHERBOARD. Disable it to continue." +#ifndef SERIAL_PORT + #error "SERIAL_PORT must be defined in Configuration.h" +#elif defined(SERIAL_PORT_2) && SERIAL_PORT_2 == SERIAL_PORT + #error "SERIAL_PORT_2 cannot be the same as SERIAL_PORT. Please update your configuration." #endif /** @@ -2280,6 +2278,36 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "Please enable only one LCD_SCREEN_ROT_* option: 0, 90, 180, or 270." #endif +/** + * Serial displays require a dedicated serial port + */ +#if HAS_DGUS_LCD + #ifndef DGUS_SERIAL_PORT + #error "The DGUS LCD requires DGUS_SERIAL_PORT to be defined in Configuration.h" + #elif DGUS_SERIAL_PORT == SERIAL_PORT + #error "DGUS_SERIAL_PORT cannot be the same as SERIAL_PORT. Please update your configuration." + #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 + #error "DGUS_SERIAL_PORT cannot be the same as SERIAL_PORT_2. Please update your configuration." + #endif +#elif ENABLED(MALYAN_LCD) + #ifndef LCD_SERIAL_PORT + #error "MALYAN_LCD requires LCD_SERIAL_PORT to be defined in Configuration.h" + #elif LCD_SERIAL_PORT == SERIAL_PORT + #error "LCD_SERIAL_PORT cannot be the same as SERIAL_PORT. Please update your configuration." + #elif defined(SERIAL_PORT_2) && LCD_SERIAL_PORT == SERIAL_PORT_2 + #error "LCD_SERIAL_PORT cannot be the same as SERIAL_PORT_2. Please update your configuration." + #endif +#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) + #ifndef ANYCUBIC_LCD_SERIAL_PORT + #error "The ANYCUBIC LCD requires ANYCUBIC_LCD_SERIAL_PORT to be defined in Configuration.h" + #elif ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT + #error "ANYCUBIC_LCD_SERIAL_PORT cannot be the same as SERIAL_PORT. Please update your configuration." + #elif defined(SERIAL_PORT_2) && ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT_2 + #error "ANYCUBIC_LCD_SERIAL_PORT cannot be the same as SERIAL_PORT_2. Please update your configuration." + #endif + #define ANYCUBIC_LCD_SERIAL anycubicLcdSerial +#endif + /** * FYSETC Mini 12864 RGB backlighting required */ diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index b5148065c7cc..ece1b142355c 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -45,7 +45,7 @@ #if ENABLED(MALYAN_LCD) -#define DEBUG_MALYAN_LCD +//#define DEBUG_MALYAN_LCD #include "ui_api.h" @@ -61,10 +61,6 @@ #define DEBUG_OUT ENABLED(DEBUG_MALYAN_LCD) #include "../../core/debug_out.h" -// On the Malyan M200, this will be Serial1. On a RAMPS board, -// it might not be. -#define LCD_SERIAL Serial1 - // This is based on longest sys command + a filename, plus some buffer // in case we encounter some data we don't recognize // There is no evidence a line will ever be this long, but better safe than sorry diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index f018a40c3ef3..a3cb987fff0b 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -117,10 +117,10 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial1 - //#define Y_HARDWARE_SERIAL Serial1 - //#define Z_HARDWARE_SERIAL Serial1 - //#define E0_HARDWARE_SERIAL Serial1 + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 // // Software serial diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h index b658f3d714b8..78751a6bac87 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h @@ -30,8 +30,8 @@ * Hardware serial communication ports. */ #if HAS_TMC_UART - #define X_HARDWARE_SERIAL Serial4 - #define Y_HARDWARE_SERIAL Serial4 - #define Z_HARDWARE_SERIAL Serial4 - #define E0_HARDWARE_SERIAL Serial4 + #define X_HARDWARE_SERIAL MSerial4 + #define Y_HARDWARE_SERIAL MSerial4 + #define Z_HARDWARE_SERIAL MSerial4 + #define E0_HARDWARE_SERIAL MSerial4 #endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index cb94f0bdcacd..0a0d857db3f4 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -52,8 +52,8 @@ * Hardware serial communication ports. */ #if HAS_TMC_UART - #define X_HARDWARE_SERIAL Serial4 - #define Y_HARDWARE_SERIAL Serial4 - #define Z_HARDWARE_SERIAL Serial4 - #define E0_HARDWARE_SERIAL Serial4 + #define X_HARDWARE_SERIAL MSerial4 + #define Y_HARDWARE_SERIAL MSerial4 + #define Z_HARDWARE_SERIAL MSerial4 + #define E0_HARDWARE_SERIAL MSerial4 #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index b7db592e7809..a04d6d261f8c 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -93,10 +93,10 @@ // // Hardware serial with switch // - #define X_HARDWARE_SERIAL Serial1 - #define Y_HARDWARE_SERIAL Serial1 - #define Z_HARDWARE_SERIAL Serial1 - #define E0_HARDWARE_SERIAL Serial1 + #define X_HARDWARE_SERIAL MSerial1 + #define Y_HARDWARE_SERIAL MSerial1 + #define Z_HARDWARE_SERIAL MSerial1 + #define E0_HARDWARE_SERIAL MSerial1 // The 4xTMC2209 module doesn't have a serial multiplexer and // needs to set *_SLAVE_ADDRESS in Configuration_adv.h for X,Y,Z,E0 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index e39c8f234285..48da17adc5a9 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -188,17 +188,11 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial1 - //#define X2_HARDWARE_SERIAL Serial1 - //#define Y_HARDWARE_SERIAL Serial1 - //#define Y2_HARDWARE_SERIAL Serial1 - //#define Z_HARDWARE_SERIAL Serial1 - //#define Z2_HARDWARE_SERIAL Serial1 - //#define E0_HARDWARE_SERIAL Serial1 - //#define E1_HARDWARE_SERIAL Serial1 - //#define E2_HARDWARE_SERIAL Serial1 - //#define E3_HARDWARE_SERIAL Serial1 - //#define E4_HARDWARE_SERIAL Serial1 + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + //#define E1_HARDWARE_SERIAL MSerial1 // Unused servo pins may be repurposed with SoftwareSerialM //#define X_SERIAL_TX_PIN PF8 // SERVO3_PIN -- XS2 - 6 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h index f6a3b555c399..bbacbf5585d3 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -83,10 +83,10 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial1 - //#define Y_HARDWARE_SERIAL Serial1 - //#define Z_HARDWARE_SERIAL Serial1 - //#define E0_HARDWARE_SERIAL Serial1 + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 // // Software serial diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index ccb07b35f88c..be3b130c858f 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -132,17 +132,11 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial1 - //#define X2_HARDWARE_SERIAL Serial1 - //#define Y_HARDWARE_SERIAL Serial1 - //#define Y2_HARDWARE_SERIAL Serial1 - //#define Z_HARDWARE_SERIAL Serial1 - //#define Z2_HARDWARE_SERIAL Serial1 - //#define E0_HARDWARE_SERIAL Serial1 - //#define E1_HARDWARE_SERIAL Serial1 - //#define E2_HARDWARE_SERIAL Serial1 - //#define E3_HARDWARE_SERIAL Serial1 - //#define E4_HARDWARE_SERIAL Serial1 + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + //#define E1_HARDWARE_SERIAL MSerial1 // // Software serial diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index 2e74b6b15f2b..e445b8169bb5 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -125,17 +125,12 @@ * Hardware serial communication ports. * If undefined software serial is used according to the pins below */ - //#define X_HARDWARE_SERIAL Serial1 - //#define X2_HARDWARE_SERIAL Serial1 - //#define Y_HARDWARE_SERIAL Serial1 - //#define Y2_HARDWARE_SERIAL Serial1 - //#define Z_HARDWARE_SERIAL Serial1 - //#define Z2_HARDWARE_SERIAL Serial1 - //#define E0_HARDWARE_SERIAL Serial1 - //#define E1_HARDWARE_SERIAL Serial1 - //#define E2_HARDWARE_SERIAL Serial1 - //#define E3_HARDWARE_SERIAL Serial1 - //#define E4_HARDWARE_SERIAL Serial1 + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + //#define E1_HARDWARE_SERIAL MSerial1 + //#define E2_HARDWARE_SERIAL MSerial1 // // Software serial diff --git a/buildroot/tests/malyan_M300-tests b/buildroot/tests/malyan_M300-tests index ada60d558429..1955accaa5f6 100755 --- a/buildroot/tests/malyan_M300-tests +++ b/buildroot/tests/malyan_M300-tests @@ -9,6 +9,7 @@ set -e restore_configs use_example_configs "delta/Malyan M300" opt_disable AUTO_BED_LEVELING_3POINT +opt_set LCD_SERIAL_PORT 1 exec_test $1 $2 "Malyan M300 (delta)" # cleanup From 568f292883d422bdd226d7faf2d2eba16a4a0ed9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Sep 2020 21:36:31 -0500 Subject: [PATCH 49/63] HAL/serial followup --- Marlin/src/HAL/AVR/HAL.h | 1 - Marlin/src/HAL/SAMD51/HAL.h | 2 +- Marlin/src/HAL/STM32F1/HAL.h | 2 +- Marlin/src/HAL/TEENSY40_41/HAL.h | 2 +- .../lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp | 6 +++++- Marlin/src/lcd/extui/malyan_lcd.cpp | 6 +++++- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index fcaaf75c4a9e..af7e14267936 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -86,7 +86,6 @@ typedef int8_t pin_t; #if !WITHIN(SERIAL_PORT, -1, 3) #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif - #define MYSERIAL0 customizedSerial1 #ifdef SERIAL_PORT_2 diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index b516cb769fb3..c72613e7729b 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -50,7 +50,7 @@ #if SERIAL_PORT_2 == -1 #define MYSERIAL1 Serial #elif WITHIN(SERIAL_PORT_2, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 47414cb45e10..0f3c3e14602c 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -108,7 +108,7 @@ #endif #endif -#ifdef DGUS_SERIAL +#ifdef DGUS_SERIAL_PORT #if DGUS_SERIAL_PORT == 0 #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." #elif DGUS_SERIAL_PORT == SERIAL_PORT diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 77f7af295668..b3b0144d134b 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -66,7 +66,7 @@ #if SERIAL_PORT_2 == -1 #define MYSERIAL1 usbSerial #elif WITHIN(SERIAL_PORT_2, 0, 8) - #define MYSERIAL0 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 8. Please update your configuration." #endif diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp index a7173b1ad2a7..16779c077317 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -113,7 +113,11 @@ static void sendLine_P(PGM_P str) { AnycubicTFTClass::AnycubicTFTClass() {} void AnycubicTFTClass::OnSetup() { - ANYCUBIC_LCD_SERIAL.begin(115200); + #ifndef LCD_BAUDRATE + #define LCD_BAUDRATE 115200 + #endif + LCD_SERIAL.begin(LCD_BAUDRATE); + SENDLINE_DBG_PGM("J17", "TFT Serial Debug: Main board reset... J17"); // J17 Main board reset ExtUI::delay_ms(10); diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index ece1b142355c..79a5fb961aa1 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -428,7 +428,11 @@ namespace ExtUI { * it and translate into ExtUI operations where possible. */ inbound_count = 0; - LCD_SERIAL.begin(500000); + + #ifndef LCD_BAUDRATE + #define LCD_BAUDRATE 500000 + #endif + LCD_SERIAL.begin(LCD_BAUDRATE); // Signal init write_to_lcd_P(PSTR("{SYS:STARTED}\r\n")); From b3223d7b412b0067e0f9c1ad7b672317098a973f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Sep 2020 21:36:39 -0500 Subject: [PATCH 50/63] Fix some pin inits --- .../lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp | 6 ++---- Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 16779c077317..486f2627783d 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -123,12 +123,10 @@ void AnycubicTFTClass::OnSetup() { // initialise the state of the key pins running on the tft #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) - pinMode(SD_DETECT_PIN, INPUT); - WRITE(SD_DETECT_PIN, HIGH); + SET_INPUT_PULLUP(SD_DETECT_PIN); #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) - pinMode(FIL_RUNOUT_PIN, INPUT); - WRITE(FIL_RUNOUT_PIN, HIGH); + SET_INPUT_PULLUP(FIL_RUNOUT_PIN); #endif mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp index 0e4526734ca1..2b6f5f89f6ee 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp @@ -161,13 +161,13 @@ void printer_state_polling() { void filament_pin_setup() { #if PIN_EXISTS(MT_DET_1) - pinMode(MT_DET_1_PIN, INPUT_PULLUP); + SET_INPUT_PULLUP(MT_DET_1_PIN); #endif #if PIN_EXISTS(MT_DET_2) - pinMode(MT_DET_2_PIN, INPUT_PULLUP); + SET_INPUT_PULLUP(MT_DET_2_PIN); #endif #if PIN_EXISTS(MT_DET_3) - pinMode(MT_DET_3_PIN, INPUT_PULLUP); + SET_INPUT_PULLUP(MT_DET_3_PIN); #endif } From 6bb6f7f28897ecd9e7e7391e2cd9d941627a041a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 25 Sep 2020 00:13:26 +0000 Subject: [PATCH 51/63] [cron] Bump distribution date (2020-09-25) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index a889bef80ef3..95ac6d405143 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-24" + #define STRING_DISTRIBUTION_DATE "2020-09-25" #endif /** From da6c8317a7e7483fcb823c06f9cf953a764eacb0 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Thu, 24 Sep 2020 18:28:48 -0700 Subject: [PATCH 52/63] Fix and improve STM32F1 serial (#19464) --- Marlin/Configuration.h | 5 +- Marlin/Configuration_adv.h | 10 +- Marlin/src/HAL/AVR/HAL.h | 17 +- Marlin/src/HAL/AVR/MarlinSerial.cpp | 1228 ++++++++--------- Marlin/src/HAL/AVR/MarlinSerial.h | 67 +- Marlin/src/HAL/DUE/HAL.h | 12 +- Marlin/src/HAL/DUE/MarlinSerial.h | 2 + Marlin/src/HAL/LINUX/include/serial.h | 1 + Marlin/src/HAL/LPC1768/HAL.h | 12 +- Marlin/src/HAL/LPC1768/MarlinSerial.cpp | 8 +- Marlin/src/HAL/LPC1768/MarlinSerial.h | 1 + Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 8 +- Marlin/src/HAL/LPC1768/usb_serial.cpp | 2 + Marlin/src/HAL/SAMD51/HAL.h | 12 +- Marlin/src/HAL/STM32/HAL.h | 16 +- Marlin/src/HAL/STM32/MarlinSerial.cpp | 4 +- Marlin/src/HAL/STM32/MarlinSerial.h | 4 + Marlin/src/HAL/STM32F1/HAL.h | 80 +- Marlin/src/HAL/STM32F1/MarlinSerial.cpp | 127 +- Marlin/src/HAL/STM32F1/MarlinSerial.h | 21 +- Marlin/src/HAL/STM32F1/msc_sd.h | 1 + Marlin/src/HAL/STM32_F4_F7/HAL.h | 16 +- Marlin/src/inc/Conditionals_adv.h | 34 + Marlin/src/inc/SanityCheck.h | 33 +- Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp | 25 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 18 +- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 62 +- buildroot/tests/mks_robin_pro-tests | 1 + 28 files changed, 947 insertions(+), 880 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2635bc750eb0..93e2a0229a71 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2165,6 +2165,9 @@ // Touch-screen LCD for Malyan M200/M300 printers // //#define MALYAN_LCD +#if ENABLED(MALYAN_LCD) + #define LCD_SERIAL_PORT 1 // Default is 1 for Malyan M200 +#endif // // Touch UI for FTDI EVE (FT800/FT810) displays @@ -2178,7 +2181,7 @@ //#define ANYCUBIC_LCD_I3MEGA //#define ANYCUBIC_LCD_CHIRON #if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) - #define ANYCUBIC_LCD_SERIAL_PORT 3 + #define LCD_SERIAL_PORT 3 // Default is 3 for Anycubic //#define ANYCUBIC_LCD_DEBUG #endif diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 65cbd21a947b..a8c9205538ad 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1404,8 +1404,8 @@ // Additional options for DGUS / DWIN displays // #if HAS_DGUS_LCD - #define DGUS_SERIAL_PORT 3 - #define DGUS_BAUDRATE 115200 + #define LCD_SERIAL_PORT 3 + #define LCD_BAUDRATE 115200 #define DGUS_RX_BUFFER_SIZE 128 #define DGUS_TX_BUFFER_SIZE 48 @@ -3419,10 +3419,10 @@ #if ENABLED(PRUSA_MMU2) // Serial port used for communication with MMU2. - // For AVR enable the UART port used for the MMU. (e.g., internalSerial) + // For AVR enable the UART port used for the MMU. (e.g., mmuSerial) // For 32-bit boards check your HAL for available serial ports. (e.g., Serial2) - #define INTERNAL_SERIAL_PORT 2 - #define MMU2_SERIAL internalSerial + #define MMU2_SERIAL_PORT 2 + #define MMU2_SERIAL mmuSerial // Use hardware reset for MMU if a pin is defined for it //#define MMU2_RST_PIN 23 diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index af7e14267936..41f1acd32f68 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -96,19 +96,14 @@ typedef int8_t pin_t; #endif #endif -#ifdef DGUS_SERIAL_PORT - #if !WITHIN(DGUS_SERIAL_PORT, -1, 3) - #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration." +#ifdef LCD_SERIAL_PORT + #if !WITHIN(LCD_SERIAL_PORT, -1, 3) + #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif - #define DGUS_SERIAL internalDgusSerial - #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free -#endif - -#ifdef ANYCUBIC_LCD_SERIAL_PORT - #if !WITHIN(ANYCUBIC_LCD_SERIAL_PORT, -1, 3) - #error "ANYCUBIC_LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #define LCD_SERIAL lcdSerial + #if HAS_DGUS_LCD + #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free() #endif - #define ANYCUBIC_LCD_SERIAL anycubicLcdSerial #endif // ------------------------ diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index 838627001d14..63599efd4132 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -40,407 +40,370 @@ #if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)) - #include "MarlinSerial.h" - #include "../../MarlinCore.h" +#include "MarlinSerial.h" +#include "../../MarlinCore.h" + +#if ENABLED(DIRECT_STEPPING) + #include "../../feature/direct_stepping.h" +#endif + +template typename MarlinSerial::ring_buffer_r MarlinSerial::rx_buffer = { 0, 0, { 0 } }; +template typename MarlinSerial::ring_buffer_t MarlinSerial::tx_buffer = { 0 }; +template bool MarlinSerial::_written = false; +template uint8_t MarlinSerial::xon_xoff_state = MarlinSerial::XON_XOFF_CHAR_SENT | MarlinSerial::XON_CHAR; +template uint8_t MarlinSerial::rx_dropped_bytes = 0; +template uint8_t MarlinSerial::rx_buffer_overruns = 0; +template uint8_t MarlinSerial::rx_framing_errors = 0; +template typename MarlinSerial::ring_buffer_pos_t MarlinSerial::rx_max_enqueued = 0; + +// A SW memory barrier, to ensure GCC does not overoptimize loops +#define sw_barrier() asm volatile("": : :"memory"); + +#include "../../feature/e_parser.h" + +// "Atomically" read the RX head index value without disabling interrupts: +// This MUST be called with RX interrupts enabled, and CAN'T be called +// from the RX ISR itself! +template +FORCE_INLINE typename MarlinSerial::ring_buffer_pos_t MarlinSerial::atomic_read_rx_head() { + if (Cfg::RX_SIZE > 256) { + // Keep reading until 2 consecutive reads return the same value, + // meaning there was no update in-between caused by an interrupt. + // This works because serial RX interrupts happen at a slower rate + // than successive reads of a variable, so 2 consecutive reads with + // the same value means no interrupt updated it. + ring_buffer_pos_t vold, vnew = rx_buffer.head; + sw_barrier(); + do { + vold = vnew; + vnew = rx_buffer.head; + sw_barrier(); + } while (vold != vnew); + return vnew; + } + else { + // With an 8bit index, reads are always atomic. No need for special handling + return rx_buffer.head; + } +} + +template +volatile bool MarlinSerial::rx_tail_value_not_stable = false; +template +volatile uint16_t MarlinSerial::rx_tail_value_backup = 0; + +// Set RX tail index, taking into account the RX ISR could interrupt +// the write to this variable in the middle - So a backup strategy +// is used to ensure reads of the correct values. +// -Must NOT be called from the RX ISR - +template +FORCE_INLINE void MarlinSerial::atomic_set_rx_tail(typename MarlinSerial::ring_buffer_pos_t value) { + if (Cfg::RX_SIZE > 256) { + // Store the new value in the backup + rx_tail_value_backup = value; + sw_barrier(); + // Flag we are about to change the true value + rx_tail_value_not_stable = true; + sw_barrier(); + // Store the new value + rx_buffer.tail = value; + sw_barrier(); + // Signal the new value is completely stored into the value + rx_tail_value_not_stable = false; + sw_barrier(); + } + else + rx_buffer.tail = value; +} + +// Get the RX tail index, taking into account the read could be +// interrupting in the middle of the update of that index value +// -Called from the RX ISR - +template +FORCE_INLINE typename MarlinSerial::ring_buffer_pos_t MarlinSerial::atomic_read_rx_tail() { + if (Cfg::RX_SIZE > 256) { + // If the true index is being modified, return the backup value + if (rx_tail_value_not_stable) return rx_tail_value_backup; + } + // The true index is stable, return it + return rx_buffer.tail; +} + +// (called with RX interrupts disabled) +template +FORCE_INLINE void MarlinSerial::store_rxd_char() { + + static EmergencyParser::State emergency_state; // = EP_RESET + + // This must read the R_UCSRA register before reading the received byte to detect error causes + if (Cfg::DROPPED_RX && B_DOR && !++rx_dropped_bytes) --rx_dropped_bytes; + if (Cfg::RX_OVERRUNS && B_DOR && !++rx_buffer_overruns) --rx_buffer_overruns; + if (Cfg::RX_FRAMING_ERRORS && B_FE && !++rx_framing_errors) --rx_framing_errors; + + // Read the character from the USART + uint8_t c = R_UDR; #if ENABLED(DIRECT_STEPPING) - #include "../../feature/direct_stepping.h" + if (page_manager.maybe_store_rxd_char(c)) return; #endif - template typename MarlinSerial::ring_buffer_r MarlinSerial::rx_buffer = { 0, 0, { 0 } }; - template typename MarlinSerial::ring_buffer_t MarlinSerial::tx_buffer = { 0 }; - template bool MarlinSerial::_written = false; - template uint8_t MarlinSerial::xon_xoff_state = MarlinSerial::XON_XOFF_CHAR_SENT | MarlinSerial::XON_CHAR; - template uint8_t MarlinSerial::rx_dropped_bytes = 0; - template uint8_t MarlinSerial::rx_buffer_overruns = 0; - template uint8_t MarlinSerial::rx_framing_errors = 0; - template typename MarlinSerial::ring_buffer_pos_t MarlinSerial::rx_max_enqueued = 0; - - // A SW memory barrier, to ensure GCC does not overoptimize loops - #define sw_barrier() asm volatile("": : :"memory"); - - #include "../../feature/e_parser.h" - - // "Atomically" read the RX head index value without disabling interrupts: - // This MUST be called with RX interrupts enabled, and CAN'T be called - // from the RX ISR itself! - template - FORCE_INLINE typename MarlinSerial::ring_buffer_pos_t MarlinSerial::atomic_read_rx_head() { - if (Cfg::RX_SIZE > 256) { - // Keep reading until 2 consecutive reads return the same value, - // meaning there was no update in-between caused by an interrupt. - // This works because serial RX interrupts happen at a slower rate - // than successive reads of a variable, so 2 consecutive reads with - // the same value means no interrupt updated it. - ring_buffer_pos_t vold, vnew = rx_buffer.head; - sw_barrier(); - do { - vold = vnew; - vnew = rx_buffer.head; - sw_barrier(); - } while (vold != vnew); - return vnew; - } - else { - // With an 8bit index, reads are always atomic. No need for special handling - return rx_buffer.head; - } - } + // Get the tail - Nothing can alter its value while this ISR is executing, but there's + // a chance that this ISR interrupted the main process while it was updating the index. + // The backup mechanism ensures the correct value is always returned. + const ring_buffer_pos_t t = atomic_read_rx_tail(); - template - volatile bool MarlinSerial::rx_tail_value_not_stable = false; - template - volatile uint16_t MarlinSerial::rx_tail_value_backup = 0; - - // Set RX tail index, taking into account the RX ISR could interrupt - // the write to this variable in the middle - So a backup strategy - // is used to ensure reads of the correct values. - // -Must NOT be called from the RX ISR - - template - FORCE_INLINE void MarlinSerial::atomic_set_rx_tail(typename MarlinSerial::ring_buffer_pos_t value) { - if (Cfg::RX_SIZE > 256) { - // Store the new value in the backup - rx_tail_value_backup = value; - sw_barrier(); - // Flag we are about to change the true value - rx_tail_value_not_stable = true; - sw_barrier(); - // Store the new value - rx_buffer.tail = value; - sw_barrier(); - // Signal the new value is completely stored into the value - rx_tail_value_not_stable = false; - sw_barrier(); - } - else - rx_buffer.tail = value; - } + // Get the head pointer - This ISR is the only one that modifies its value, so it's safe to read here + ring_buffer_pos_t h = rx_buffer.head; - // Get the RX tail index, taking into account the read could be - // interrupting in the middle of the update of that index value - // -Called from the RX ISR - - template - FORCE_INLINE typename MarlinSerial::ring_buffer_pos_t MarlinSerial::atomic_read_rx_tail() { - if (Cfg::RX_SIZE > 256) { - // If the true index is being modified, return the backup value - if (rx_tail_value_not_stable) return rx_tail_value_backup; - } - // The true index is stable, return it - return rx_buffer.tail; - } + // Get the next element + ring_buffer_pos_t i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - // (called with RX interrupts disabled) - template - FORCE_INLINE void MarlinSerial::store_rxd_char() { + if (Cfg::EMERGENCYPARSER) emergency_parser.update(emergency_state, c); + + // If the character is to be stored at the index just before the tail + // (such that the head would advance to the current tail), the RX FIFO is + // full, so don't write the character or advance the head. + if (i != t) { + rx_buffer.buffer[h] = c; + h = i; + } + else if (Cfg::DROPPED_RX && !++rx_dropped_bytes) + --rx_dropped_bytes; - static EmergencyParser::State emergency_state; // = EP_RESET + if (Cfg::MAX_RX_QUEUED) { + // Calculate count of bytes stored into the RX buffer + const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - // This must read the R_UCSRA register before reading the received byte to detect error causes - if (Cfg::DROPPED_RX && B_DOR && !++rx_dropped_bytes) --rx_dropped_bytes; - if (Cfg::RX_OVERRUNS && B_DOR && !++rx_buffer_overruns) --rx_buffer_overruns; - if (Cfg::RX_FRAMING_ERRORS && B_FE && !++rx_framing_errors) --rx_framing_errors; + // Keep track of the maximum count of enqueued bytes + NOLESS(rx_max_enqueued, rx_count); + } - // Read the character from the USART - uint8_t c = R_UDR; + if (Cfg::XONOFF) { + // If the last char that was sent was an XON + if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XON_CHAR) { - #if ENABLED(DIRECT_STEPPING) - if (page_manager.maybe_store_rxd_char(c)) return; - #endif + // Bytes stored into the RX buffer + const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - // Get the tail - Nothing can alter its value while this ISR is executing, but there's - // a chance that this ISR interrupted the main process while it was updating the index. - // The backup mechanism ensures the correct value is always returned. - const ring_buffer_pos_t t = atomic_read_rx_tail(); + // If over 12.5% of RX buffer capacity, send XOFF before running out of + // RX buffer space .. 325 bytes @ 250kbits/s needed to let the host react + // and stop sending bytes. This translates to 13mS propagation time. + if (rx_count >= (Cfg::RX_SIZE) / 8) { - // Get the head pointer - This ISR is the only one that modifies its value, so it's safe to read here - ring_buffer_pos_t h = rx_buffer.head; + // At this point, definitely no TX interrupt was executing, since the TX ISR can't be preempted. + // Don't enable the TX interrupt here as a means to trigger the XOFF char, because if it happens + // to be in the middle of trying to disable the RX interrupt in the main program, eventually the + // enabling of the TX interrupt could be undone. The ONLY reliable thing this can do to ensure + // the sending of the XOFF char is to send it HERE AND NOW. - // Get the next element - ring_buffer_pos_t i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); + // About to send the XOFF char + xon_xoff_state = XOFF_CHAR | XON_XOFF_CHAR_SENT; - if (Cfg::EMERGENCYPARSER) emergency_parser.update(emergency_state, c); + // Wait until the TX register becomes empty and send it - Here there could be a problem + // - While waiting for the TX register to empty, the RX register could receive a new + // character. This must also handle that situation! + while (!B_UDRE) { - // If the character is to be stored at the index just before the tail - // (such that the head would advance to the current tail), the RX FIFO is - // full, so don't write the character or advance the head. - if (i != t) { - rx_buffer.buffer[h] = c; - h = i; - } - else if (Cfg::DROPPED_RX && !++rx_dropped_bytes) - --rx_dropped_bytes; + if (B_RXC) { + // A char arrived while waiting for the TX buffer to be empty - Receive and process it! - if (Cfg::MAX_RX_QUEUED) { - // Calculate count of bytes stored into the RX buffer - const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); + i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - // Keep track of the maximum count of enqueued bytes - NOLESS(rx_max_enqueued, rx_count); - } + // Read the character from the USART + c = R_UDR; - if (Cfg::XONOFF) { - // If the last char that was sent was an XON - if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XON_CHAR) { - - // Bytes stored into the RX buffer - const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - - // If over 12.5% of RX buffer capacity, send XOFF before running out of - // RX buffer space .. 325 bytes @ 250kbits/s needed to let the host react - // and stop sending bytes. This translates to 13mS propagation time. - if (rx_count >= (Cfg::RX_SIZE) / 8) { - - // At this point, definitely no TX interrupt was executing, since the TX ISR can't be preempted. - // Don't enable the TX interrupt here as a means to trigger the XOFF char, because if it happens - // to be in the middle of trying to disable the RX interrupt in the main program, eventually the - // enabling of the TX interrupt could be undone. The ONLY reliable thing this can do to ensure - // the sending of the XOFF char is to send it HERE AND NOW. - - // About to send the XOFF char - xon_xoff_state = XOFF_CHAR | XON_XOFF_CHAR_SENT; - - // Wait until the TX register becomes empty and send it - Here there could be a problem - // - While waiting for the TX register to empty, the RX register could receive a new - // character. This must also handle that situation! - while (!B_UDRE) { - - if (B_RXC) { - // A char arrived while waiting for the TX buffer to be empty - Receive and process it! - - i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - - // Read the character from the USART - c = R_UDR; - - if (Cfg::EMERGENCYPARSER) emergency_parser.update(emergency_state, c); - - // If the character is to be stored at the index just before the tail - // (such that the head would advance to the current tail), the FIFO is - // full, so don't write the character or advance the head. - if (i != t) { - rx_buffer.buffer[h] = c; - h = i; - } - else if (Cfg::DROPPED_RX && !++rx_dropped_bytes) - --rx_dropped_bytes; - } - sw_barrier(); - } + if (Cfg::EMERGENCYPARSER) emergency_parser.update(emergency_state, c); - R_UDR = XOFF_CHAR; - - // Clear the TXC bit -- "can be cleared by writing a one to its bit - // location". This makes sure flush() won't return until the bytes - // actually got written - B_TXC = 1; - - // At this point there could be a race condition between the write() function - // and this sending of the XOFF char. This interrupt could happen between the - // wait to be empty TX buffer loop and the actual write of the character. Since - // the TX buffer is full because it's sending the XOFF char, the only way to be - // sure the write() function will succeed is to wait for the XOFF char to be - // completely sent. Since an extra character could be received during the wait - // it must also be handled! - while (!B_UDRE) { - - if (B_RXC) { - // A char arrived while waiting for the TX buffer to be empty - Receive and process it! - - i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - - // Read the character from the USART - c = R_UDR; - - if (Cfg::EMERGENCYPARSER) - emergency_parser.update(emergency_state, c); - - // If the character is to be stored at the index just before the tail - // (such that the head would advance to the current tail), the FIFO is - // full, so don't write the character or advance the head. - if (i != t) { - rx_buffer.buffer[h] = c; - h = i; - } - else if (Cfg::DROPPED_RX && !++rx_dropped_bytes) - --rx_dropped_bytes; + // If the character is to be stored at the index just before the tail + // (such that the head would advance to the current tail), the FIFO is + // full, so don't write the character or advance the head. + if (i != t) { + rx_buffer.buffer[h] = c; + h = i; } - sw_barrier(); + else if (Cfg::DROPPED_RX && !++rx_dropped_bytes) + --rx_dropped_bytes; } - - // At this point everything is ready. The write() function won't - // have any issues writing to the UART TX register if it needs to! + sw_barrier(); } - } - } - // Store the new head value - The main loop will retry until the value is stable - rx_buffer.head = h; - } + R_UDR = XOFF_CHAR; - // (called with TX irqs disabled) - template - FORCE_INLINE void MarlinSerial::_tx_udr_empty_irq() { - if (Cfg::TX_SIZE > 0) { - // Read positions - uint8_t t = tx_buffer.tail; - const uint8_t h = tx_buffer.head; + // Clear the TXC bit -- "can be cleared by writing a one to its bit + // location". This makes sure flush() won't return until the bytes + // actually got written + B_TXC = 1; - if (Cfg::XONOFF) { - // If an XON char is pending to be sent, do it now - if (xon_xoff_state == XON_CHAR) { + // At this point there could be a race condition between the write() function + // and this sending of the XOFF char. This interrupt could happen between the + // wait to be empty TX buffer loop and the actual write of the character. Since + // the TX buffer is full because it's sending the XOFF char, the only way to be + // sure the write() function will succeed is to wait for the XOFF char to be + // completely sent. Since an extra character could be received during the wait + // it must also be handled! + while (!B_UDRE) { - // Send the character - R_UDR = XON_CHAR; + if (B_RXC) { + // A char arrived while waiting for the TX buffer to be empty - Receive and process it! - // clear the TXC bit -- "can be cleared by writing a one to its bit - // location". This makes sure flush() won't return until the bytes - // actually got written - B_TXC = 1; + i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - // Remember we sent it. - xon_xoff_state = XON_CHAR | XON_XOFF_CHAR_SENT; + // Read the character from the USART + c = R_UDR; - // If nothing else to transmit, just disable TX interrupts. - if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed) + if (Cfg::EMERGENCYPARSER) + emergency_parser.update(emergency_state, c); - return; + // If the character is to be stored at the index just before the tail + // (such that the head would advance to the current tail), the FIFO is + // full, so don't write the character or advance the head. + if (i != t) { + rx_buffer.buffer[h] = c; + h = i; + } + else if (Cfg::DROPPED_RX && !++rx_dropped_bytes) + --rx_dropped_bytes; + } + sw_barrier(); } - } - // If nothing to transmit, just disable TX interrupts. This could - // happen as the result of the non atomicity of the disabling of RX - // interrupts that could end reenabling TX interrupts as a side effect. - if (h == t) { - B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed) - return; + // At this point everything is ready. The write() function won't + // have any issues writing to the UART TX register if it needs to! } - - // There is something to TX, Send the next byte - const uint8_t c = tx_buffer.buffer[t]; - t = (t + 1) & (Cfg::TX_SIZE - 1); - R_UDR = c; - tx_buffer.tail = t; - - // Clear the TXC bit (by writing a one to its bit location). - // Ensures flush() won't return until the bytes are actually written/ - B_TXC = 1; - - // Disable interrupts if there is nothing to transmit following this byte - if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed) - } - } - - // Public Methods - template - void MarlinSerial::begin(const long baud) { - uint16_t baud_setting; - bool useU2X = true; - - #if F_CPU == 16000000UL && SERIAL_PORT == 0 - // Hard-coded exception for compatibility with the bootloader shipped - // with the Duemilanove and previous boards, and the firmware on the - // 8U2 on the Uno and Mega 2560. - if (baud == 57600) useU2X = false; - #endif - - R_UCSRA = 0; - if (useU2X) { - B_U2X = 1; - baud_setting = (F_CPU / 4 / baud - 1) / 2; } - else - baud_setting = (F_CPU / 8 / baud - 1) / 2; - - // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register) - R_UBRRH = baud_setting >> 8; - R_UBRRL = baud_setting; - - B_RXEN = 1; - B_TXEN = 1; - B_RXCIE = 1; - if (Cfg::TX_SIZE > 0) B_UDRIE = 0; - _written = false; } - template - void MarlinSerial::end() { - B_RXEN = 0; - B_TXEN = 0; - B_RXCIE = 0; - B_UDRIE = 0; - } + // Store the new head value - The main loop will retry until the value is stable + rx_buffer.head = h; +} - template - int MarlinSerial::peek() { - const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail; - return h == t ? -1 : rx_buffer.buffer[t]; - } +// (called with TX irqs disabled) +template +FORCE_INLINE void MarlinSerial::_tx_udr_empty_irq() { + if (Cfg::TX_SIZE > 0) { + // Read positions + uint8_t t = tx_buffer.tail; + const uint8_t h = tx_buffer.head; - template - int MarlinSerial::read() { - const ring_buffer_pos_t h = atomic_read_rx_head(); + if (Cfg::XONOFF) { + // If an XON char is pending to be sent, do it now + if (xon_xoff_state == XON_CHAR) { - // Read the tail. Main thread owns it, so it is safe to directly read it - ring_buffer_pos_t t = rx_buffer.tail; + // Send the character + R_UDR = XON_CHAR; - // If nothing to read, return now - if (h == t) return -1; + // clear the TXC bit -- "can be cleared by writing a one to its bit + // location". This makes sure flush() won't return until the bytes + // actually got written + B_TXC = 1; - // Get the next char - const int v = rx_buffer.buffer[t]; - t = (ring_buffer_pos_t)(t + 1) & (Cfg::RX_SIZE - 1); + // Remember we sent it. + xon_xoff_state = XON_CHAR | XON_XOFF_CHAR_SENT; - // Advance tail - Making sure the RX ISR will always get an stable value, even - // if it interrupts the writing of the value of that variable in the middle. - atomic_set_rx_tail(t); + // If nothing else to transmit, just disable TX interrupts. + if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed) - if (Cfg::XONOFF) { - // If the XOFF char was sent, or about to be sent... - if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XOFF_CHAR) { - // Get count of bytes in the RX buffer - const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); - if (rx_count < (Cfg::RX_SIZE) / 10) { - if (Cfg::TX_SIZE > 0) { - // Signal we want an XON character to be sent. - xon_xoff_state = XON_CHAR; - // Enable TX ISR. Non atomic, but it will eventually enable them - B_UDRIE = 1; - } - else { - // If not using TX interrupts, we must send the XON char now - xon_xoff_state = XON_CHAR | XON_XOFF_CHAR_SENT; - while (!B_UDRE) sw_barrier(); - R_UDR = XON_CHAR; - } - } + return; } } - return v; - } + // If nothing to transmit, just disable TX interrupts. This could + // happen as the result of the non atomicity of the disabling of RX + // interrupts that could end reenabling TX interrupts as a side effect. + if (h == t) { + B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed) + return; + } - template - typename MarlinSerial::ring_buffer_pos_t MarlinSerial::available() { - const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail; - return (ring_buffer_pos_t)(Cfg::RX_SIZE + h - t) & (Cfg::RX_SIZE - 1); + // There is something to TX, Send the next byte + const uint8_t c = tx_buffer.buffer[t]; + t = (t + 1) & (Cfg::TX_SIZE - 1); + R_UDR = c; + tx_buffer.tail = t; + + // Clear the TXC bit (by writing a one to its bit location). + // Ensures flush() won't return until the bytes are actually written/ + B_TXC = 1; + + // Disable interrupts if there is nothing to transmit following this byte + if (h == t) B_UDRIE = 0; // (Non-atomic, could be reenabled by the main program, but eventually this will succeed) } +} - template - void MarlinSerial::flush() { +// Public Methods +template +void MarlinSerial::begin(const long baud) { + uint16_t baud_setting; + bool useU2X = true; - // Set the tail to the head: - // - Read the RX head index in a safe way. (See atomic_read_rx_head.) - // - Set the tail, making sure the RX ISR will always get a stable value, even - // if it interrupts the writing of the value of that variable in the middle. - atomic_set_rx_tail(atomic_read_rx_head()); + #if F_CPU == 16000000UL && SERIAL_PORT == 0 + // Hard-coded exception for compatibility with the bootloader shipped + // with the Duemilanove and previous boards, and the firmware on the + // 8U2 on the Uno and Mega 2560. + if (baud == 57600) useU2X = false; + #endif - if (Cfg::XONOFF) { - // If the XOFF char was sent, or about to be sent... - if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XOFF_CHAR) { + R_UCSRA = 0; + if (useU2X) { + B_U2X = 1; + baud_setting = (F_CPU / 4 / baud - 1) / 2; + } + else + baud_setting = (F_CPU / 8 / baud - 1) / 2; + + // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register) + R_UBRRH = baud_setting >> 8; + R_UBRRL = baud_setting; + + B_RXEN = 1; + B_TXEN = 1; + B_RXCIE = 1; + if (Cfg::TX_SIZE > 0) B_UDRIE = 0; + _written = false; +} + +template +void MarlinSerial::end() { + B_RXEN = 0; + B_TXEN = 0; + B_RXCIE = 0; + B_UDRIE = 0; +} + +template +int MarlinSerial::peek() { + const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail; + return h == t ? -1 : rx_buffer.buffer[t]; +} + +template +int MarlinSerial::read() { + const ring_buffer_pos_t h = atomic_read_rx_head(); + + // Read the tail. Main thread owns it, so it is safe to directly read it + ring_buffer_pos_t t = rx_buffer.tail; + + // If nothing to read, return now + if (h == t) return -1; + + // Get the next char + const int v = rx_buffer.buffer[t]; + t = (ring_buffer_pos_t)(t + 1) & (Cfg::RX_SIZE - 1); + + // Advance tail - Making sure the RX ISR will always get an stable value, even + // if it interrupts the writing of the value of that variable in the middle. + atomic_set_rx_tail(t); + + if (Cfg::XONOFF) { + // If the XOFF char was sent, or about to be sent... + if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XOFF_CHAR) { + // Get count of bytes in the RX buffer + const ring_buffer_pos_t rx_count = (ring_buffer_pos_t)(h - t) & (ring_buffer_pos_t)(Cfg::RX_SIZE - 1); + if (rx_count < (Cfg::RX_SIZE) / 10) { if (Cfg::TX_SIZE > 0) { // Signal we want an XON character to be sent. xon_xoff_state = XON_CHAR; - // Enable TX ISR. Non atomic, but it will eventually enable it. + // Enable TX ISR. Non atomic, but it will eventually enable them B_UDRIE = 1; } else { @@ -453,363 +416,384 @@ } } - template - void MarlinSerial::write(const uint8_t c) { - if (Cfg::TX_SIZE == 0) { - - _written = true; - while (!B_UDRE) sw_barrier(); - R_UDR = c; - - } - else { - - _written = true; - - // If the TX interrupts are disabled and the data register - // is empty, just write the byte to the data register and - // be done. This shortcut helps significantly improve the - // effective datarate at high (>500kbit/s) bitrates, where - // interrupt overhead becomes a slowdown. - // Yes, there is a race condition between the sending of the - // XOFF char at the RX ISR, but it is properly handled there - if (!B_UDRIE && B_UDRE) { - R_UDR = c; - - // clear the TXC bit -- "can be cleared by writing a one to its bit - // location". This makes sure flush() won't return until the bytes - // actually got written - B_TXC = 1; - return; - } - - const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); - - // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { - - // Make room by polling if it is possible to transmit, and do so! - while (i == tx_buffer.tail) { - - // If we can transmit another byte, do it. - if (B_UDRE) _tx_udr_empty_irq(); - - // Make sure compiler rereads tx_buffer.tail - sw_barrier(); - } + return v; +} + +template +typename MarlinSerial::ring_buffer_pos_t MarlinSerial::available() { + const ring_buffer_pos_t h = atomic_read_rx_head(), t = rx_buffer.tail; + return (ring_buffer_pos_t)(Cfg::RX_SIZE + h - t) & (Cfg::RX_SIZE - 1); +} + +template +void MarlinSerial::flush() { + + // Set the tail to the head: + // - Read the RX head index in a safe way. (See atomic_read_rx_head.) + // - Set the tail, making sure the RX ISR will always get a stable value, even + // if it interrupts the writing of the value of that variable in the middle. + atomic_set_rx_tail(atomic_read_rx_head()); + + if (Cfg::XONOFF) { + // If the XOFF char was sent, or about to be sent... + if ((xon_xoff_state & XON_XOFF_CHAR_MASK) == XOFF_CHAR) { + if (Cfg::TX_SIZE > 0) { + // Signal we want an XON character to be sent. + xon_xoff_state = XON_CHAR; + // Enable TX ISR. Non atomic, but it will eventually enable it. + B_UDRIE = 1; } else { - // Interrupts are enabled, just wait until there is space - while (i == tx_buffer.tail) sw_barrier(); + // If not using TX interrupts, we must send the XON char now + xon_xoff_state = XON_CHAR | XON_XOFF_CHAR_SENT; + while (!B_UDRE) sw_barrier(); + R_UDR = XON_CHAR; } - - // Store new char. head is always safe to move - tx_buffer.buffer[tx_buffer.head] = c; - tx_buffer.head = i; - - // Enable TX ISR - Non atomic, but it will eventually enable TX ISR - B_UDRIE = 1; } } +} - template - void MarlinSerial::flushTX() { +template +void MarlinSerial::write(const uint8_t c) { + if (Cfg::TX_SIZE == 0) { - if (Cfg::TX_SIZE == 0) { - // No bytes written, no need to flush. This special case is needed since there's - // no way to force the TXC (transmit complete) bit to 1 during initialization. - if (!_written) return; + _written = true; + while (!B_UDRE) sw_barrier(); + R_UDR = c; - // Wait until everything was transmitted - while (!B_TXC) sw_barrier(); + } + else { - // At this point nothing is queued anymore (DRIE is disabled) and - // the hardware finished transmission (TXC is set). + _written = true; - } - else { + // If the TX interrupts are disabled and the data register + // is empty, just write the byte to the data register and + // be done. This shortcut helps significantly improve the + // effective datarate at high (>500kbit/s) bitrates, where + // interrupt overhead becomes a slowdown. + // Yes, there is a race condition between the sending of the + // XOFF char at the RX ISR, but it is properly handled there + if (!B_UDRIE && B_UDRE) { + R_UDR = c; - // No bytes written, no need to flush. This special case is needed since there's - // no way to force the TXC (transmit complete) bit to 1 during initialization. - if (!_written) return; + // clear the TXC bit -- "can be cleared by writing a one to its bit + // location". This makes sure flush() won't return until the bytes + // actually got written + B_TXC = 1; + return; + } - // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); - // Wait until everything was transmitted - We must do polling, as interrupts are disabled - while (tx_buffer.head != tx_buffer.tail || !B_TXC) { + // If global interrupts are disabled (as the result of being called from an ISR)... + if (!ISRS_ENABLED()) { - // If there is more space, send an extra character - if (B_UDRE) _tx_udr_empty_irq(); + // Make room by polling if it is possible to transmit, and do so! + while (i == tx_buffer.tail) { - sw_barrier(); - } + // If we can transmit another byte, do it. + if (B_UDRE) _tx_udr_empty_irq(); + // Make sure compiler rereads tx_buffer.tail + sw_barrier(); } - else { - // Wait until everything was transmitted - while (tx_buffer.head != tx_buffer.tail || !B_TXC) sw_barrier(); - } - - // At this point nothing is queued anymore (DRIE is disabled) and - // the hardware finished transmission (TXC is set). } - } - - /** - * Imports from print.h - */ - - template - void MarlinSerial::print(char c, int base) { - print((long)c, base); - } - - template - void MarlinSerial::print(unsigned char b, int base) { - print((unsigned long)b, base); - } - - template - void MarlinSerial::print(int n, int base) { - print((long)n, base); - } - - template - void MarlinSerial::print(unsigned int n, int base) { - print((unsigned long)n, base); - } - - template - void MarlinSerial::print(long n, int base) { - if (base == 0) write(n); - else if (base == 10) { - if (n < 0) { print('-'); n = -n; } - printNumber(n, 10); + else { + // Interrupts are enabled, just wait until there is space + while (i == tx_buffer.tail) sw_barrier(); } - else - printNumber(n, base); - } - template - void MarlinSerial::print(unsigned long n, int base) { - if (base == 0) write(n); - else printNumber(n, base); - } + // Store new char. head is always safe to move + tx_buffer.buffer[tx_buffer.head] = c; + tx_buffer.head = i; - template - void MarlinSerial::print(double n, int digits) { - printFloat(n, digits); + // Enable TX ISR - Non atomic, but it will eventually enable TX ISR + B_UDRIE = 1; } +} - template - void MarlinSerial::println() { - print('\r'); - print('\n'); - } - - template - void MarlinSerial::println(const String& s) { - print(s); - println(); - } - - template - void MarlinSerial::println(const char c[]) { - print(c); - println(); - } +template +void MarlinSerial::flushTX() { - template - void MarlinSerial::println(char c, int base) { - print(c, base); - println(); - } + if (Cfg::TX_SIZE == 0) { + // No bytes written, no need to flush. This special case is needed since there's + // no way to force the TXC (transmit complete) bit to 1 during initialization. + if (!_written) return; - template - void MarlinSerial::println(unsigned char b, int base) { - print(b, base); - println(); - } + // Wait until everything was transmitted + while (!B_TXC) sw_barrier(); - template - void MarlinSerial::println(int n, int base) { - print(n, base); - println(); - } + // At this point nothing is queued anymore (DRIE is disabled) and + // the hardware finished transmission (TXC is set). - template - void MarlinSerial::println(unsigned int n, int base) { - print(n, base); - println(); } + else { - template - void MarlinSerial::println(long n, int base) { - print(n, base); - println(); - } + // No bytes written, no need to flush. This special case is needed since there's + // no way to force the TXC (transmit complete) bit to 1 during initialization. + if (!_written) return; - template - void MarlinSerial::println(unsigned long n, int base) { - print(n, base); - println(); - } + // If global interrupts are disabled (as the result of being called from an ISR)... + if (!ISRS_ENABLED()) { - template - void MarlinSerial::println(double n, int digits) { - print(n, digits); - println(); - } + // Wait until everything was transmitted - We must do polling, as interrupts are disabled + while (tx_buffer.head != tx_buffer.tail || !B_TXC) { - // Private Methods + // If there is more space, send an extra character + if (B_UDRE) _tx_udr_empty_irq(); - template - void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - if (n) { - unsigned char buf[8 * sizeof(long)]; // Enough space for base 2 - int8_t i = 0; - while (n) { - buf[i++] = n % base; - n /= base; + sw_barrier(); } - while (i--) - print((char)(buf[i] + (buf[i] < 10 ? '0' : 'A' - 10))); - } - else - print('0'); - } - template - void MarlinSerial::printFloat(double number, uint8_t digits) { - // Handle negative numbers - if (number < 0.0) { - print('-'); - number = -number; } - - // Round correctly so that print(1.999, 2) prints as "2.00" - double rounding = 0.5; - LOOP_L_N(i, digits) rounding *= 0.1; - number += rounding; - - // Extract the integer part of the number and print it - unsigned long int_part = (unsigned long)number; - double remainder = number - (double)int_part; - print(int_part); - - // Print the decimal point, but only if there are digits beyond - if (digits) { - print('.'); - // Extract digits from the remainder one at a time - while (digits--) { - remainder *= 10.0; - int toPrint = int(remainder); - print(toPrint); - remainder -= toPrint; - } + else { + // Wait until everything was transmitted + while (tx_buffer.head != tx_buffer.tail || !B_TXC) sw_barrier(); } - } - // Hookup ISR handlers - ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _RX_vect)) { - MarlinSerial>::store_rxd_char(); + // At this point nothing is queued anymore (DRIE is disabled) and + // the hardware finished transmission (TXC is set). } +} - ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _UDRE_vect)) { - MarlinSerial>::_tx_udr_empty_irq(); - } - - // Preinstantiate - template class MarlinSerial>; - - // Instantiate - MarlinSerial> customizedSerial1; - - #ifdef SERIAL_PORT_2 +/** + * Imports from print.h + */ - // Hookup ISR handlers - ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _RX_vect)) { - MarlinSerial>::store_rxd_char(); +template +void MarlinSerial::print(char c, int base) { + print((long)c, base); +} + +template +void MarlinSerial::print(unsigned char b, int base) { + print((unsigned long)b, base); +} + +template +void MarlinSerial::print(int n, int base) { + print((long)n, base); +} + +template +void MarlinSerial::print(unsigned int n, int base) { + print((unsigned long)n, base); +} + +template +void MarlinSerial::print(long n, int base) { + if (base == 0) write(n); + else if (base == 10) { + if (n < 0) { print('-'); n = -n; } + printNumber(n, 10); + } + else + printNumber(n, base); +} + +template +void MarlinSerial::print(unsigned long n, int base) { + if (base == 0) write(n); + else printNumber(n, base); +} + +template +void MarlinSerial::print(double n, int digits) { + printFloat(n, digits); +} + +template +void MarlinSerial::println() { + print('\r'); + print('\n'); +} + +template +void MarlinSerial::println(const String& s) { + print(s); + println(); +} + +template +void MarlinSerial::println(const char c[]) { + print(c); + println(); +} + +template +void MarlinSerial::println(char c, int base) { + print(c, base); + println(); +} + +template +void MarlinSerial::println(unsigned char b, int base) { + print(b, base); + println(); +} + +template +void MarlinSerial::println(int n, int base) { + print(n, base); + println(); +} + +template +void MarlinSerial::println(unsigned int n, int base) { + print(n, base); + println(); +} + +template +void MarlinSerial::println(long n, int base) { + print(n, base); + println(); +} + +template +void MarlinSerial::println(unsigned long n, int base) { + print(n, base); + println(); +} + +template +void MarlinSerial::println(double n, int digits) { + print(n, digits); + println(); +} + +// Private Methods + +template +void MarlinSerial::printNumber(unsigned long n, uint8_t base) { + if (n) { + unsigned char buf[8 * sizeof(long)]; // Enough space for base 2 + int8_t i = 0; + while (n) { + buf[i++] = n % base; + n /= base; } - - ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _UDRE_vect)) { - MarlinSerial>::_tx_udr_empty_irq(); + while (i--) + print((char)(buf[i] + (buf[i] < 10 ? '0' : 'A' - 10))); + } + else + print('0'); +} + +template +void MarlinSerial::printFloat(double number, uint8_t digits) { + // Handle negative numbers + if (number < 0.0) { + print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + LOOP_L_N(i, digits) rounding *= 0.1; + number += rounding; + + // Extract the integer part of the number and print it + unsigned long int_part = (unsigned long)number; + double remainder = number - (double)int_part; + print(int_part); + + // Print the decimal point, but only if there are digits beyond + if (digits) { + print('.'); + // Extract digits from the remainder one at a time + while (digits--) { + remainder *= 10.0; + int toPrint = int(remainder); + print(toPrint); + remainder -= toPrint; } + } +} - // Preinstantiate - template class MarlinSerial>; +// Hookup ISR handlers +ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _RX_vect)) { + MarlinSerial>::store_rxd_char(); +} - // Instantiate - MarlinSerial> customizedSerial2; +ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _UDRE_vect)) { + MarlinSerial>::_tx_udr_empty_irq(); +} - #endif +// Preinstantiate +template class MarlinSerial>; -#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H) +// Instantiate +MarlinSerial> customizedSerial1; -#ifdef INTERNAL_SERIAL_PORT +#ifdef SERIAL_PORT_2 - ISR(SERIAL_REGNAME(USART, INTERNAL_SERIAL_PORT, _RX_vect)) { - MarlinSerial>::store_rxd_char(); + // Hookup ISR handlers + ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _RX_vect)) { + MarlinSerial>::store_rxd_char(); } - ISR(SERIAL_REGNAME(USART, INTERNAL_SERIAL_PORT, _UDRE_vect)) { - MarlinSerial>::_tx_udr_empty_irq(); + ISR(SERIAL_REGNAME(USART, SERIAL_PORT_2, _UDRE_vect)) { + MarlinSerial>::_tx_udr_empty_irq(); } // Preinstantiate - template class MarlinSerial>; + template class MarlinSerial>; // Instantiate - MarlinSerial> internalSerial; + MarlinSerial> customizedSerial2; #endif -#ifdef DGUS_SERIAL_PORT - - template - typename MarlinSerial::ring_buffer_pos_t MarlinSerial::get_tx_buffer_free() { - const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send. - h = tx_buffer.head; // next pos for queue. - int ret = t - h - 1; - if (ret < 0) ret += Cfg::TX_SIZE + 1; - return ret; - } +#ifdef MMU2_SERIAL_PORT - ISR(SERIAL_REGNAME(USART, DGUS_SERIAL_PORT, _RX_vect)) { - MarlinSerial>::store_rxd_char(); + ISR(SERIAL_REGNAME(USART, MMU2_SERIAL_PORT, _RX_vect)) { + MarlinSerial>::store_rxd_char(); } - ISR(SERIAL_REGNAME(USART, DGUS_SERIAL_PORT, _UDRE_vect)) { - MarlinSerial>::_tx_udr_empty_irq(); + ISR(SERIAL_REGNAME(USART, MMU2_SERIAL_PORT, _UDRE_vect)) { + MarlinSerial>::_tx_udr_empty_irq(); } // Preinstantiate - template class MarlinSerial>; + template class MarlinSerial>; // Instantiate - MarlinSerial> internalDgusSerial; + MarlinSerial> mmuSerial; #endif -#ifdef ANYCUBIC_LCD_SERIAL_PORT +#ifdef LCD_SERIAL_PORT - ISR(SERIAL_REGNAME(USART, ANYCUBIC_LCD_SERIAL_PORT, _RX_vect)) { - MarlinSerial>::store_rxd_char(); + ISR(SERIAL_REGNAME(USART, LCD_SERIAL_PORT, _RX_vect)) { + MarlinSerial>::store_rxd_char(); } - ISR(SERIAL_REGNAME(USART, ANYCUBIC_LCD_SERIAL_PORT, _UDRE_vect)) { - MarlinSerial>::_tx_udr_empty_irq(); + ISR(SERIAL_REGNAME(USART, LCD_SERIAL_PORT, _UDRE_vect)) { + MarlinSerial>::_tx_udr_empty_irq(); } // Preinstantiate - template class MarlinSerial>; + template class MarlinSerial>; // Instantiate - MarlinSerial> anycubicLcdSerial; + MarlinSerial> lcdSerial; + + #if HAS_DGUS_LCD + template + typename MarlinSerial::ring_buffer_pos_t MarlinSerial::get_tx_buffer_free() { + const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send. + h = tx_buffer.head; // next pos for queue. + int ret = t - h - 1; + if (ret < 0) ret += Cfg::TX_SIZE + 1; + return ret; + } + #endif #endif +#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H) + // For AT90USB targets use the UART for BT interfacing #if defined(USBCON) && ENABLED(BLUETOOTH) HardwareSerial bluetoothSerial; diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 8dbed4d85be4..cb906e2b6572 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -217,10 +217,12 @@ static ring_buffer_pos_t available(); static void write(const uint8_t c); static void flushTX(); - #ifdef DGUS_SERIAL_PORT + #if HAS_DGUS_LCD static ring_buffer_pos_t get_tx_buffer_free(); #endif + static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } + FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; } @@ -278,55 +280,50 @@ #endif // !USBCON -#ifdef INTERNAL_SERIAL_PORT +#ifdef MMU2_SERIAL_PORT template - struct MarlinInternalSerialCfg { + struct MMU2SerialCfg { static constexpr int PORT = serial; - static constexpr unsigned int RX_SIZE = 32; - static constexpr unsigned int TX_SIZE = 32; static constexpr bool XONOFF = false; static constexpr bool EMERGENCYPARSER = false; static constexpr bool DROPPED_RX = false; - static constexpr bool RX_OVERRUNS = false; static constexpr bool RX_FRAMING_ERRORS = false; static constexpr bool MAX_RX_QUEUED = false; + static constexpr unsigned int RX_SIZE = 32; + static constexpr unsigned int TX_SIZE = 32; + static constexpr bool RX_OVERRUNS = false; }; - extern MarlinSerial> internalSerial; + extern MarlinSerial> mmuSerial; #endif -#ifdef DGUS_SERIAL_PORT - template - struct MarlinInternalSerialCfg { - static constexpr int PORT = serial; - static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE; - static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE; - static constexpr bool XONOFF = false; - static constexpr bool EMERGENCYPARSER = false; - static constexpr bool DROPPED_RX = false; - static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS); - static constexpr bool RX_FRAMING_ERRORS = false; - static constexpr bool MAX_RX_QUEUED = false; - }; - - extern MarlinSerial> internalDgusSerial; -#endif +#ifdef LCD_SERIAL_PORT -#ifdef ANYCUBIC_LCD_SERIAL_PORT template - struct AnycubicLcdSerialCfg { - static constexpr int PORT = serial; - static constexpr unsigned int RX_SIZE = 64; - static constexpr unsigned int TX_SIZE = 128; - static constexpr bool XONOFF = false; - static constexpr bool EMERGENCYPARSER = false; - static constexpr bool DROPPED_RX = false; - static constexpr bool RX_OVERRUNS = false; - static constexpr bool RX_FRAMING_ERRORS = false; - static constexpr bool MAX_RX_QUEUED = false; + struct LCDSerialCfg { + static constexpr int PORT = serial; + static constexpr bool XONOFF = false; + static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER); + static constexpr bool DROPPED_RX = false; + static constexpr bool RX_FRAMING_ERRORS = false; + static constexpr bool MAX_RX_QUEUED = false; + #if HAS_DGUS_LCD + static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE; + static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE; + static constexpr bool RX_OVERRUNS = ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS); + #elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) + static constexpr unsigned int RX_SIZE = 64; + static constexpr unsigned int TX_SIZE = 128; + static constexpr bool RX_OVERRUNS = false; + #else + static constexpr unsigned int RX_SIZE = 64; + static constexpr unsigned int TX_SIZE = 128; + static constexpr bool RX_OVERRUNS = false + #endif }; - extern MarlinSerial> anycubicLcdSerial; + extern MarlinSerial> lcdSerial; + #endif // Use the UART for Bluetooth in AT90USB configurations diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 974f1ccc1649..7a057fdae4fc 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -61,13 +61,13 @@ #endif #endif -#ifdef DGUS_SERIAL_PORT - #if DGUS_SERIAL_PORT == -1 - #define DGUS_SERIAL internalDgusSerial - #elif WITHIN(DGUS_SERIAL_PORT, 0, 3) - #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT) +#ifdef LCD_SERIAL_PORT + #if LCD_SERIAL_PORT == -1 + #define LCD_SERIAL lcdSerial + #elif WITHIN(LCD_SERIAL_PORT, 0, 3) + #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else - #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #endif diff --git a/Marlin/src/HAL/DUE/MarlinSerial.h b/Marlin/src/HAL/DUE/MarlinSerial.h index dfafa1514159..a194eba2f386 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.h +++ b/Marlin/src/HAL/DUE/MarlinSerial.h @@ -122,6 +122,8 @@ class MarlinSerial { static void write(const uint8_t c); static void flushTX(); + static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } + FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } FORCE_INLINE static uint8_t framing_errors() { return Cfg::RX_FRAMING_ERRORS ? rx_framing_errors : 0; } diff --git a/Marlin/src/HAL/LINUX/include/serial.h b/Marlin/src/HAL/LINUX/include/serial.h index 154e95aec262..94e0c758ee12 100644 --- a/Marlin/src/HAL/LINUX/include/serial.h +++ b/Marlin/src/HAL/LINUX/include/serial.h @@ -79,6 +79,7 @@ class HalSerial { #if ENABLED(EMERGENCY_PARSER) EmergencyParser::State emergency_state; + static inline bool emergency_parser_enabled() { return true; } #endif HalSerial() { host_connected = true; } diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index e9f05fcc617d..3118aed1b246 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -85,13 +85,13 @@ extern "C" volatile uint32_t _millis; #endif #endif -#ifdef DGUS_SERIAL_PORT - #if DGUS_SERIAL_PORT == -1 - #define DGUS_SERIAL UsbSerial - #elif WITHIN(DGUS_SERIAL_PORT, 0, 3) - #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT) +#ifdef LCD_SERIAL_PORT + #if LCD_SERIAL_PORT == -1 + #define LCD_SERIAL UsbSerial + #elif WITHIN(LCD_SERIAL_PORT, 0, 3) + #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else - #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #endif diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp index c3fb3bd0e4d2..5374e005d3da 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp @@ -24,28 +24,28 @@ #include "../../inc/MarlinConfigPre.h" #include "MarlinSerial.h" -#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0) +#if USING_SERIAL_0 MarlinSerial MSerial(LPC_UART0); extern "C" void UART0_IRQHandler() { MSerial.IRQHandler(); } #endif -#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1 +#if USING_SERIAL_1 MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1); extern "C" void UART1_IRQHandler() { MSerial1.IRQHandler(); } #endif -#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2 +#if USING_SERIAL_2 MarlinSerial MSerial2(LPC_UART2); extern "C" void UART2_IRQHandler() { MSerial2.IRQHandler(); } #endif -#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3 +#if USING_SERIAL_3 MarlinSerial MSerial3(LPC_UART3); extern "C" void UART3_IRQHandler() { MSerial3.IRQHandler(); diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.h b/Marlin/src/HAL/LPC1768/MarlinSerial.h index 98ce73d377a6..8d6b64378a0a 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.h +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.h @@ -57,6 +57,7 @@ class MarlinSerial : public HardwareSerial { } EmergencyParser::State emergency_state; + static inline bool emergency_parser_enabled() { return true; } #endif }; diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 2ca8a29da4c6..b6491368cd2a 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -92,7 +92,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #define ANY_TX(N,V...) DO(IS_TX##N,||,V) #define ANY_RX(N,V...) DO(IS_RX##N,||,V) -#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0) +#if USING_SERIAL_0 #define IS_TX0(P) (P == P0_02) #define IS_RX0(P) (P == P0_03) #if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI) @@ -106,7 +106,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #undef IS_RX0 #endif -#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1 +#if USING_SERIAL_1 #define IS_TX1(P) (P == P0_15) #define IS_RX1(P) (P == P0_16) #define _IS_TX1_1 IS_TX1 @@ -127,7 +127,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #undef _IS_RX1_1 #endif -#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2 +#if USING_SERIAL_2 #define IS_TX2(P) (P == P0_10) #define IS_RX2(P) (P == P0_11) #define _IS_TX2_1 IS_TX2 @@ -161,7 +161,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #undef _IS_RX2_1 #endif -#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3 +#if USING_SERIAL_3 #define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00) #define PIN_IS_RX3(P) (P##_PIN == P0_01) #if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX) diff --git a/Marlin/src/HAL/LPC1768/usb_serial.cpp b/Marlin/src/HAL/LPC1768/usb_serial.cpp index 63a570efdfa8..d225ce418860 100644 --- a/Marlin/src/HAL/LPC1768/usb_serial.cpp +++ b/Marlin/src/HAL/LPC1768/usb_serial.cpp @@ -26,7 +26,9 @@ #if ENABLED(EMERGENCY_PARSER) #include "../../feature/e_parser.h" + EmergencyParser::State emergency_state; + bool CDC_RecvCallback(const char buffer) { emergency_parser.update(emergency_state, buffer); return true; diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index c72613e7729b..7fd826a1b6a4 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -56,13 +56,13 @@ #endif #endif - #ifdef DGUS_SERIAL_PORT - #if DGUS_SERIAL_PORT == -1 - #define DGUS_SERIAL Serial - #elif WITHIN(DGUS_SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(DGUS_SERIAL_PORT) + #ifdef LCD_SERIAL_PORT + #if LCD_SERIAL_PORT == -1 + #define LCD_SERIAL Serial + #elif WITHIN(LCD_SERIAL_PORT, 0, 3) + #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else - #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #endif diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 9ec2d5c19e83..60ab45374a56 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -64,18 +64,7 @@ #endif #endif -#if HAS_DGUS_LCD - #if DGUS_SERIAL_PORT == -1 - #define DGUS_SERIAL SerialUSB - #elif WITHIN(DGUS_SERIAL_PORT, 1, 6) - #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT) - #else - #error "DGUS_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." - #endif - #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite -#endif - -#if ENABLED(MALYAN_LCD) +#ifdef LCD_SERIAL_PORT #if LCD_SERIAL_PORT == -1 #define LCD_SERIAL SerialUSB #elif WITHIN(LCD_SERIAL_PORT, 1, 6) @@ -83,6 +72,9 @@ #else #error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." #endif + #if HAS_DGUS_LCD + #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() + #endif #endif /** diff --git a/Marlin/src/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp index 2d799ea54db0..a146664366df 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp @@ -49,8 +49,8 @@ DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2) #endif -#if defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT >= 0 - DECLARE_SERIAL_PORT_EXP(DGUS_SERIAL_PORT) +#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0 + DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT) #endif void MarlinSerial::begin(unsigned long baud, uint8_t config) { diff --git a/Marlin/src/HAL/STM32/MarlinSerial.h b/Marlin/src/HAL/STM32/MarlinSerial.h index 5ab97ff3a993..3611cc78d7ce 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.h +++ b/Marlin/src/HAL/STM32/MarlinSerial.h @@ -35,6 +35,10 @@ class MarlinSerial : public HardwareSerial { #endif { } + #if ENABLED(EMERGENCY_PARSER) + static inline bool emergency_parser_enabled() { return true; } + #endif + void begin(unsigned long baud, uint8_t config); inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); } diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 0f3c3e14602c..5c03593eb088 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -68,71 +68,49 @@ #endif #endif -#if SERIAL_PORT == 0 - #error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." -#elif SERIAL_PORT == -1 +#define _MSERIAL(X) MSerial##X +#define MSERIAL(X) _MSERIAL(X) + +#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY) + #define NUM_UARTS 5 +#else + #define NUM_UARTS 3 +#endif + +#if SERIAL_PORT == -1 #define MYSERIAL0 UsbSerial -#elif SERIAL_PORT == 1 - #define MYSERIAL0 MSerial1 -#elif SERIAL_PORT == 2 - #define MYSERIAL0 MSerial2 -#elif SERIAL_PORT == 3 - #define MYSERIAL0 MSerial3 -#elif SERIAL_PORT == 4 - #define MYSERIAL0 MSerial4 -#elif SERIAL_PORT == 5 - #define MYSERIAL0 MSerial5 +#elif WITHIN(SERIAL_PORT, 1, NUM_UARTS) + #define MYSERIAL0 MSERIAL(SERIAL_PORT) +#elif NUM_UARTS == 5 + #error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." #else - #error "SERIAL_PORT must be from -1 to 5. Please update your configuration." + #error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 - #if SERIAL_PORT_2 == 0 - #error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration." - #elif SERIAL_PORT_2 == SERIAL_PORT - #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration." - #elif SERIAL_PORT_2 == -1 + #if SERIAL_PORT_2 == -1 #define MYSERIAL1 UsbSerial - #elif SERIAL_PORT_2 == 1 - #define MYSERIAL1 MSerial1 - #elif SERIAL_PORT_2 == 2 - #define MYSERIAL1 MSerial2 - #elif SERIAL_PORT_2 == 3 - #define MYSERIAL1 MSerial3 - #elif SERIAL_PORT_2 == 4 - #define MYSERIAL1 MSerial4 - #elif SERIAL_PORT_2 == 5 - #define MYSERIAL1 MSerial5 + #elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS) + #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #elif NUM_UARTS == 5 + #error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration." #else - #error "SERIAL_PORT_2 must be from -1 to 5. Please update your configuration." + #error "SERIAL_PORT_2 must be -1 or from 1 to 3. Please update your configuration." #endif #endif -#ifdef DGUS_SERIAL_PORT - #if DGUS_SERIAL_PORT == 0 - #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." - #elif DGUS_SERIAL_PORT == SERIAL_PORT - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 - #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration." - #elif DGUS_SERIAL_PORT == -1 - #define DGUS_SERIAL UsbSerial - #elif DGUS_SERIAL_PORT == 1 - #define DGUS_SERIAL MSerial1 - #elif DGUS_SERIAL_PORT == 2 - #define DGUS_SERIAL MSerial2 - #elif DGUS_SERIAL_PORT == 3 - #define DGUS_SERIAL MSerial3 - #elif DGUS_SERIAL_PORT == 4 - #define DGUS_SERIAL MSerial4 - #elif DGUS_SERIAL_PORT == 5 - #define DGUS_SERIAL MSerial5 +#ifdef LCD_SERIAL_PORT + #if LCD_SERIAL_PORT == -1 + #define LCD_SERIAL UsbSerial + #elif WITHIN(LCD_SERIAL_PORT, 1, NUM_UARTS) + #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) + #elif NUM_UARTS == 5 + #error "LCD_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." #else - #error "DGUS_SERIAL_PORT must be from -1 to 5. Please update your configuration." + #error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." #endif #endif - // Set interrupt grouping for this MCU void HAL_init(); #define HAL_IDLETASK 1 diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp index 9a48e901f42d..ebf11cb429fa 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp @@ -22,7 +22,7 @@ #ifdef __STM32F1__ -#include "../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfig.h" #include "MarlinSerial.h" #include @@ -53,7 +53,8 @@ static inline __always_inline void my_usart_irq(ring_buffer *rb, ring_buffer *wb rb_push_insert(rb, c); #endif #if ENABLED(EMERGENCY_PARSER) - emergency_parser.update(serial.emergency_state, c); + if (serial.emergency_parser_enabled()) + emergency_parser.update(serial.emergency_state, c); #endif } } @@ -73,40 +74,120 @@ static inline __always_inline void my_usart_irq(ring_buffer *rb, ring_buffer *wb } } -#define DEFINE_HWSERIAL_MARLIN(name, n) \ - MarlinSerial name(USART##n, \ - BOARD_USART##n##_TX_PIN, \ - BOARD_USART##n##_RX_PIN); \ - extern "C" void __irq_usart##n(void) { \ +// Not every MarlinSerial port should handle emergency parsing. +// It would not make sense to parse GCode from TMC responses, for example. +constexpr bool serial_handles_emergency(int port) { + return false + #ifdef SERIAL_PORT + || (SERIAL_PORT) == port + #endif + #ifdef SERIAL_PORT_2 + || (SERIAL_PORT_2) == port + #endif + #ifdef LCD_SERIAL_PORT + || (LCD_SERIAL_PORT) == port + #endif + ; +} + +#define DEFINE_HWSERIAL_MARLIN(name, n) \ + MarlinSerial name(USART##n, \ + BOARD_USART##n##_TX_PIN, \ + BOARD_USART##n##_RX_PIN, \ + serial_handles_emergency(n)); \ + extern "C" void __irq_usart##n(void) { \ my_usart_irq(USART##n->rb, USART##n->wb, USART##n##_BASE, MSerial##n); \ } #define DEFINE_HWSERIAL_UART_MARLIN(name, n) \ MarlinSerial name(UART##n, \ - BOARD_USART##n##_TX_PIN, \ - BOARD_USART##n##_RX_PIN); \ + BOARD_USART##n##_TX_PIN, \ + BOARD_USART##n##_RX_PIN, \ + serial_handles_emergency(n)); \ extern "C" void __irq_usart##n(void) { \ - my_usart_irq(USART##n->rb, USART##n->wb, USART##n##_BASE, MSerial##n); \ + my_usart_irq(UART##n->rb, UART##n->wb, UART##n##_BASE, MSerial##n); \ } -#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1 - DEFINE_HWSERIAL_MARLIN(MSerial1, 1); +// Instantiate all UARTs even if they are not needed +// This avoids a bunch of logic to figure out every serial +// port which may be in use on the system. +DEFINE_HWSERIAL_MARLIN(MSerial1, 1); +DEFINE_HWSERIAL_MARLIN(MSerial2, 2); +DEFINE_HWSERIAL_MARLIN(MSerial3, 3); +#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY) + DEFINE_HWSERIAL_UART_MARLIN(MSerial4, 4); + DEFINE_HWSERIAL_UART_MARLIN(MSerial5, 5); #endif -#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2 - DEFINE_HWSERIAL_MARLIN(MSerial2, 2); -#endif +// Check the type of each serial port by passing it to a template function. +// HardwareSerial is known to sometimes hang the controller when an error occurs, +// so this case will fail the static assert. All other classes are assumed to be ok. +template +constexpr bool IsSerialClassAllowed(const T&) { return true; } +constexpr bool IsSerialClassAllowed(const HardwareSerial&) { return false; } -#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3 - DEFINE_HWSERIAL_MARLIN(MSerial3, 3); -#endif +#define CHECK_CFG_SERIAL(A) static_assert(IsSerialClassAllowed(A), STRINGIFY(A) " is defined incorrectly"); +#define CHECK_AXIS_SERIAL(A) static_assert(IsSerialClassAllowed(A##_HARDWARE_SERIAL), STRINGIFY(A) "_HARDWARE_SERIAL must be defined in the form MSerial1, rather than Serial1"); -#if SERIAL_PORT == 4 || SERIAL_PORT_2 == 4 || DGUS_SERIAL_PORT == 4 - DEFINE_HWSERIAL_UART_MARLIN(MSerial4, 4); -#endif +// If you encounter this error, replace SerialX with MSerialX, for example MSerial3. -#if SERIAL_PORT == 5 || SERIAL_PORT_2 == 5 || DGUS_SERIAL_PORT == 5 - DEFINE_HWSERIAL_UART_MARLIN(MSerial5, 5); +// Non-TMC ports were already validated in HAL.h, so do not require verbose error messages. +#ifdef MYSERIAL0 + CHECK_CFG_SERIAL(MYSERIAL0); +#endif +#ifdef MYSERIAL1 + CHECK_CFG_SERIAL(MYSERIAL1); +#endif +#ifdef LCD_SERIAL + CHECK_CFG_SERIAL(LCD_SERIAL); +#endif +#if AXIS_HAS_HW_SERIAL(X) + CHECK_AXIS_SERIAL(X); +#endif +#if AXIS_HAS_HW_SERIAL(X2) + CHECK_AXIS_SERIAL(X2); +#endif +#if AXIS_HAS_HW_SERIAL(Y) + CHECK_AXIS_SERIAL(Y); +#endif +#if AXIS_HAS_HW_SERIAL(Y2) + CHECK_AXIS_SERIAL(Y2); +#endif +#if AXIS_HAS_HW_SERIAL(Z) + CHECK_AXIS_SERIAL(Z); +#endif +#if AXIS_HAS_HW_SERIAL(Z2) + CHECK_AXIS_SERIAL(Z2); +#endif +#if AXIS_HAS_HW_SERIAL(Z3) + CHECK_AXIS_SERIAL(Z3); +#endif +#if AXIS_HAS_HW_SERIAL(Z4) + CHECK_AXIS_SERIAL(Z4); +#endif +#if AXIS_HAS_HW_SERIAL(E0) + CHECK_AXIS_SERIAL(E0); +#endif +#if AXIS_HAS_HW_SERIAL(E1) + CHECK_AXIS_SERIAL(E1); +#endif +#if AXIS_HAS_HW_SERIAL(E2) + CHECK_AXIS_SERIAL(E2); +#endif +#if AXIS_HAS_HW_SERIAL(E3) + CHECK_AXIS_SERIAL(E3); +#endif +#if AXIS_HAS_HW_SERIAL(E4) + CHECK_AXIS_SERIAL(E4); +#endif +#if AXIS_HAS_HW_SERIAL(E5) + CHECK_AXIS_SERIAL(E5); +#endif +#if AXIS_HAS_HW_SERIAL(E6) + CHECK_AXIS_SERIAL(E6); +#endif +#if AXIS_HAS_HW_SERIAL(E7) + CHECK_AXIS_SERIAL(E7); #endif #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.h b/Marlin/src/HAL/STM32F1/MarlinSerial.h index b9248e50caff..6aa94b64fff7 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.h +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.h @@ -35,15 +35,22 @@ class MarlinSerial : public HardwareSerial { public: - MarlinSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) : + #if ENABLED(EMERGENCY_PARSER) + const bool ep_enabled; + EmergencyParser::State emergency_state; + inline bool emergency_parser_enabled() { return ep_enabled; } + #endif + + MarlinSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin, bool TERN_(EMERGENCY_PARSER, ep_capable)) : HardwareSerial(usart_device, tx_pin, rx_pin) #if ENABLED(EMERGENCY_PARSER) + , ep_enabled(ep_capable) , emergency_state(EmergencyParser::State::EP_RESET) #endif { } #ifdef UART_IRQ_PRIO - // shadow the parent methods to set irq priority after the begin + // Shadow the parent methods to set IRQ priority after begin() void begin(uint32 baud) { MarlinSerial::begin(baud, SERIAL_8N1); } @@ -53,14 +60,12 @@ class MarlinSerial : public HardwareSerial { nvic_irq_set_priority(c_dev()->irq_num, UART_IRQ_PRIO); } #endif - - #if ENABLED(EMERGENCY_PARSER) - EmergencyParser::State emergency_state; - #endif }; extern MarlinSerial MSerial1; extern MarlinSerial MSerial2; extern MarlinSerial MSerial3; -extern MarlinSerial MSerial4; -extern MarlinSerial MSerial5; +#if EITHER(STM32_HIGH_DENSITY, STM32_XL_DENSITY) + extern MarlinSerial MSerial4; + extern MarlinSerial MSerial5; +#endif diff --git a/Marlin/src/HAL/STM32F1/msc_sd.h b/Marlin/src/HAL/STM32F1/msc_sd.h index d9cdbe6bb3d1..1e4e4c44b1b5 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.h +++ b/Marlin/src/HAL/STM32F1/msc_sd.h @@ -32,6 +32,7 @@ class MarlinUSBCompositeSerial : public USBCompositeSerial { #if ENABLED(EMERGENCY_PARSER) EmergencyParser::State emergency_state; + inline bool emergency_parser_enabled() { return true; } #endif }; diff --git a/Marlin/src/HAL/STM32_F4_F7/HAL.h b/Marlin/src/HAL/STM32_F4_F7/HAL.h index e132168205bb..88e48f0fa09d 100644 --- a/Marlin/src/HAL/STM32_F4_F7/HAL.h +++ b/Marlin/src/HAL/STM32_F4_F7/HAL.h @@ -72,15 +72,15 @@ #endif #endif -#ifdef DGUS_SERIAL_PORT - #if defined(STM32F4) && DGUS_SERIAL_PORT == 0 - #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." - #elif DGUS_SERIAL_PORT == -1 - #define DGUS_SERIAL SerialUSB - #elif WITHIN(DGUS_SERIAL_PORT, 0, 6) - #define DGUS_SERIAL MSERIAL(DGUS_SERIAL_PORT) +#ifdef LCD_SERIAL_PORT + #if defined(STM32F4) && LCD_SERIAL_PORT == 0 + #error "LCD_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration." + #elif LCD_SERIAL_PORT == -1 + #define LCD_SERIAL SerialUSB + #elif WITHIN(LCD_SERIAL_PORT, 0, 6) + #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else - #error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration." + #error "LCD_SERIAL_PORT must be from -1 to 6. Please update your configuration." #endif #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 73e034d05f2f..d3f608e0a476 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -422,3 +422,37 @@ #if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) #define NEED_LSF 1 #endif + +// Flag the indexed serial ports that are in use +#define ANY_SERIAL_IS(N) (defined(SERIAL_PORT) && SERIAL_PORT == (N)) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N)) +#if ANY_SERIAL_IS(-1) + #define USING_SERIAL_DEFAULT +#endif +#if ANY_SERIAL_IS(0) + #define USING_SERIAL_0 1 +#endif +#if ANY_SERIAL_IS(1) + #define USING_SERIAL_1 1 +#endif +#if ANY_SERIAL_IS(2) + #define USING_SERIAL_2 1 +#endif +#if ANY_SERIAL_IS(3) + #define USING_SERIAL_3 1 +#endif +#if ANY_SERIAL_IS(4) + #define USING_SERIAL_4 1 +#endif +#if ANY_SERIAL_IS(5) + #define USING_SERIAL_5 1 +#endif +#if ANY_SERIAL_IS(6) + #define USING_SERIAL_6 1 +#endif +#if ANY_SERIAL_IS(7) + #define USING_SERIAL_7 1 +#endif +#if ANY_SERIAL_IS(8) + #define USING_SERIAL_8 1 +#endif +#undef ANY_SERIAL_IS diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 4c0b68e8aec0..27bafe00485e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -477,6 +477,10 @@ #error "HOME_USING_SPREADCYCLE is now obsolete. Please remove it from Configuration_adv.h." #elif defined(DGUS_LCD) #error "DGUS_LCD is now DGUS_LCD_UI_(ORIGIN|FYSETC|HIPRECY). Please update your configuration." +#elif defined(DGUS_SERIAL_PORT) + #error "DGUS_SERIAL_PORT is now LCD_SERIAL_PORT. Please update your configuration." +#elif defined(DGUS_BAUDRATE) + #error "DGUS_BAUDRATE is now LCD_BAUDRATE. Please update your configuration." #elif defined(X_DUAL_ENDSTOPS_ADJUSTMENT) #error "X_DUAL_ENDSTOPS_ADJUSTMENT is now X2_ENDSTOP_ADJUSTMENT. Please update Configuration_adv.h." #elif defined(Y_DUAL_ENDSTOPS_ADJUSTMENT) @@ -2281,31 +2285,20 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * Serial displays require a dedicated serial port */ -#if HAS_DGUS_LCD - #ifndef DGUS_SERIAL_PORT - #error "The DGUS LCD requires DGUS_SERIAL_PORT to be defined in Configuration.h" - #elif DGUS_SERIAL_PORT == SERIAL_PORT - #error "DGUS_SERIAL_PORT cannot be the same as SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2 - #error "DGUS_SERIAL_PORT cannot be the same as SERIAL_PORT_2. Please update your configuration." - #endif -#elif ENABLED(MALYAN_LCD) - #ifndef LCD_SERIAL_PORT - #error "MALYAN_LCD requires LCD_SERIAL_PORT to be defined in Configuration.h" - #elif LCD_SERIAL_PORT == SERIAL_PORT +#ifdef LCD_SERIAL_PORT + #if LCD_SERIAL_PORT == SERIAL_PORT #error "LCD_SERIAL_PORT cannot be the same as SERIAL_PORT. Please update your configuration." #elif defined(SERIAL_PORT_2) && LCD_SERIAL_PORT == SERIAL_PORT_2 #error "LCD_SERIAL_PORT cannot be the same as SERIAL_PORT_2. Please update your configuration." #endif -#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) - #ifndef ANYCUBIC_LCD_SERIAL_PORT - #error "The ANYCUBIC LCD requires ANYCUBIC_LCD_SERIAL_PORT to be defined in Configuration.h" - #elif ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT - #error "ANYCUBIC_LCD_SERIAL_PORT cannot be the same as SERIAL_PORT. Please update your configuration." - #elif defined(SERIAL_PORT_2) && ANYCUBIC_LCD_SERIAL_PORT == SERIAL_PORT_2 - #error "ANYCUBIC_LCD_SERIAL_PORT cannot be the same as SERIAL_PORT_2. Please update your configuration." +#else + #if HAS_DGUS_LCD + #error "The DGUS LCD requires LCD_SERIAL_PORT to be defined in Configuration.h" + #elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) + #error "The ANYCUBIC LCD requires LCD_SERIAL_PORT to be defined in Configuration.h" + #elif ENABLED(MALYAN_LCD) + #error "MALYAN_LCD requires LCD_SERIAL_PORT to be defined in Configuration.h" #endif - #define ANYCUBIC_LCD_SERIAL anycubicLcdSerial #endif /** diff --git a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp index 889a25b85950..4a8095b6e993 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp @@ -53,12 +53,12 @@ static bool is_printing_from_sd = false; static bool is_out_of_filament = false; static void sendNewLine(void) { - ANYCUBIC_LCD_SERIAL.write('\r'); - ANYCUBIC_LCD_SERIAL.write('\n'); + LCD_SERIAL.write('\r'); + LCD_SERIAL.write('\n'); } static void send(const char *str) { - ANYCUBIC_LCD_SERIAL.print(str); + LCD_SERIAL.print(str); } static void sendLine(const char *str) { @@ -68,7 +68,7 @@ static void sendLine(const char *str) { static void send_P(PGM_P str) { while (const char c = pgm_read_byte(str++)) - ANYCUBIC_LCD_SERIAL.write(c); + LCD_SERIAL.write(c); } static void sendLine_P(PGM_P str) { @@ -78,23 +78,23 @@ static void sendLine_P(PGM_P str) { static void sendValue_P(PGM_P prefix, int value) { send_P(prefix); - ANYCUBIC_LCD_SERIAL.print(value); + LCD_SERIAL.print(value); } static void sendValue_P(PGM_P prefix, float value) { send_P(prefix); - ANYCUBIC_LCD_SERIAL.print(value); + LCD_SERIAL.print(value); } static void sendValueLine_P(PGM_P prefix, int value) { send_P(prefix); - ANYCUBIC_LCD_SERIAL.print(value); + LCD_SERIAL.print(value); sendNewLine(); } static void sendValueLine_P(PGM_P prefix, float value) { send_P(prefix); - ANYCUBIC_LCD_SERIAL.print(value); + LCD_SERIAL.print(value); sendNewLine(); } @@ -426,8 +426,8 @@ namespace ExtUI { static char rxBuffer[RX_LEN_MAX+1]; static uint8_t rxLen = 0; - while (ANYCUBIC_LCD_SERIAL.available()) { - const char c = ANYCUBIC_LCD_SERIAL.read(); + while (LCD_SERIAL.available()) { + const char c = LCD_SERIAL.read(); switch (c) { case '\r': case '\n': if (rxLen > 0 && rxLen <= RX_LEN_MAX) { @@ -466,7 +466,10 @@ namespace ExtUI { } void onStartup() { - ANYCUBIC_LCD_SERIAL.begin(115200); + #ifndef LCD_BAUDRATE + #define LCD_BAUDRATE 115200 + #endif + LCD_SERIAL.begin(LCD_BAUDRATE); sendNewLine(); SENDLINE_PGM("J17"); // Reset delay_ms(10); diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 486f2627783d..c69fb8351a74 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -59,12 +59,12 @@ char *itostr2(const uint8_t &x) { } static void sendNewLine(void) { - ANYCUBIC_LCD_SERIAL.write('\r'); - ANYCUBIC_LCD_SERIAL.write('\n'); + LCD_SERIAL.write('\r'); + LCD_SERIAL.write('\n'); } static void send(const char *str) { - ANYCUBIC_LCD_SERIAL.print(str); + LCD_SERIAL.print(str); } static void sendLine(const char *str) { @@ -74,7 +74,7 @@ static void sendLine(const char *str) { static void send_P(PGM_P str) { while (const char c = pgm_read_byte(str++)) - ANYCUBIC_LCD_SERIAL.write(c); + LCD_SERIAL.write(c); } static void sendLine_P(PGM_P str) { @@ -576,8 +576,8 @@ void AnycubicTFTClass::OnPrintTimerStopped() { void AnycubicTFTClass::GetCommandFromTFT() { char *starpos = NULL; - while (ANYCUBIC_LCD_SERIAL.available() > 0 && TFTbuflen < TFTBUFSIZE) { - serial3_char = ANYCUBIC_LCD_SERIAL.read(); + while (LCD_SERIAL.available() > 0 && TFTbuflen < TFTBUFSIZE) { + serial3_char = LCD_SERIAL.read(); if (serial3_char == '\n' || serial3_char == '\r' || serial3_char == ':' || @@ -639,11 +639,11 @@ void AnycubicTFTClass::GetCommandFromTFT() { float yPostition = ExtUI::getAxisPosition_mm(ExtUI::Y); float zPostition = ExtUI::getAxisPosition_mm(ExtUI::Z); SEND_PGM("A5V X: "); - ANYCUBIC_LCD_SERIAL.print(xPostition); + LCD_SERIAL.print(xPostition); SEND_PGM(" Y: "); - ANYCUBIC_LCD_SERIAL.print(yPostition); + LCD_SERIAL.print(yPostition); SEND_PGM(" Z: "); - ANYCUBIC_LCD_SERIAL.print(zPostition); + LCD_SERIAL.print(zPostition); SENDLINE_PGM(""); } break; diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index b788587c9412..5181ba7cc454 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -59,23 +59,13 @@ constexpr uint8_t DGUS_CMD_READVAR = 0x83; bool dguslcd_local_debug; // = false; #endif -#define dgusserial DGUS_SERIAL - void DGUSDisplay::InitDisplay() { - dgusserial.begin(DGUS_BAUDRATE); - - if (true - #if ENABLED(POWER_LOSS_RECOVERY) - && !recovery.valid() - #endif - ) - RequestScreen( - #if ENABLED(SHOW_BOOTSCREEN) - DGUSLCD_SCREEN_BOOT - #else - DGUSLCD_SCREEN_MAIN - #endif - ); + #ifndef LCD_BAUDRATE + #define LCD_BAUDRATE 115200 + #endif + LCD_SERIAL.begin(LCD_BAUDRATE); + if (TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) + RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN)); } void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) { @@ -89,7 +79,7 @@ void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t values strend = true; x = ' '; } - dgusserial.write(x); + LCD_SERIAL.write(x); } } @@ -133,41 +123,41 @@ void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t val strend = true; x = ' '; } - dgusserial.write(x); + LCD_SERIAL.write(x); } } void DGUSDisplay::ProcessRx() { #if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS) - if (!dgusserial.available() && dgusserial.buffer_overruns()) { + if (!LCD_SERIAL.available() && LCD_SERIAL.buffer_overruns()) { // Overrun, but reset the flag only when the buffer is empty // We want to extract as many as valid datagrams possible... DEBUG_ECHOPGM("OVFL"); rx_datagram_state = DGUS_IDLE; - //dgusserial.reset_rx_overun(); - dgusserial.flush(); + //LCD_SERIAL.reset_rx_overun(); + LCD_SERIAL.flush(); } #endif uint8_t receivedbyte; - while (dgusserial.available()) { + while (LCD_SERIAL.available()) { switch (rx_datagram_state) { case DGUS_IDLE: // Waiting for the first header byte - receivedbyte = dgusserial.read(); + receivedbyte = LCD_SERIAL.read(); //DEBUG_ECHOPAIR("< ",x); if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN; break; case DGUS_HEADER1_SEEN: // Waiting for the second header byte - receivedbyte = dgusserial.read(); + receivedbyte = LCD_SERIAL.read(); //DEBUG_ECHOPAIR(" ",x); rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE; break; case DGUS_HEADER2_SEEN: // Waiting for the length byte - rx_datagram_len = dgusserial.read(); + rx_datagram_len = LCD_SERIAL.read(); DEBUG_ECHOPAIR(" (", rx_datagram_len, ") "); // Telegram min len is 3 (command and one word of payload) @@ -175,10 +165,10 @@ void DGUSDisplay::ProcessRx() { break; case DGUS_WAIT_TELEGRAM: // wait for complete datagram to arrive. - if (dgusserial.available() < rx_datagram_len) return; + if (LCD_SERIAL.available() < rx_datagram_len) return; Initialized = true; // We've talked to it, so we defined it as initialized. - uint8_t command = dgusserial.read(); + uint8_t command = LCD_SERIAL.read(); DEBUG_ECHOPAIR("# ", command); @@ -186,7 +176,7 @@ void DGUSDisplay::ProcessRx() { unsigned char tmp[rx_datagram_len - 1]; unsigned char *ptmp = tmp; while (readlen--) { - receivedbyte = dgusserial.read(); + receivedbyte = LCD_SERIAL.read(); DEBUG_ECHOPAIR(" ", receivedbyte); *ptmp++ = receivedbyte; } @@ -229,19 +219,19 @@ void DGUSDisplay::ProcessRx() { } } -size_t DGUSDisplay::GetFreeTxBuffer() { return DGUS_SERIAL_GET_TX_BUFFER_FREE(); } +size_t DGUSDisplay::GetFreeTxBuffer() { return SERIAL_GET_TX_BUFFER_FREE(); } void DGUSDisplay::WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen) { - dgusserial.write(DGUS_HEADER1); - dgusserial.write(DGUS_HEADER2); - dgusserial.write(payloadlen + 3); - dgusserial.write(cmd); - dgusserial.write(adr >> 8); - dgusserial.write(adr & 0xFF); + LCD_SERIAL.write(DGUS_HEADER1); + LCD_SERIAL.write(DGUS_HEADER2); + LCD_SERIAL.write(payloadlen + 3); + LCD_SERIAL.write(cmd); + LCD_SERIAL.write(adr >> 8); + LCD_SERIAL.write(adr & 0xFF); } void DGUSDisplay::WritePGM(const char str[], uint8_t len) { - while (len--) dgusserial.write(pgm_read_byte(str++)); + while (len--) LCD_SERIAL.write(pgm_read_byte(str++)); } void DGUSDisplay::loop() { diff --git a/buildroot/tests/mks_robin_pro-tests b/buildroot/tests/mks_robin_pro-tests index cfd36832fdef..7ae4670fedac 100644 --- a/buildroot/tests/mks_robin_pro-tests +++ b/buildroot/tests/mks_robin_pro-tests @@ -7,6 +7,7 @@ set -e use_example_configs Mks/Robin_Pro +opt_enable EMERGENCY_PARSER opt_set SDCARD_CONNECTION LCD opt_set X_DRIVER_TYPE TMC2209 opt_set Y_DRIVER_TYPE TMC2130 From 23faf902ab09019c90b626824e1ede652ded344d Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Thu, 24 Sep 2020 19:19:04 -0700 Subject: [PATCH 53/63] BigTreeTech SKR E3 Turbo (#19500) --- Marlin/src/MarlinCore.cpp | 53 ++++ Marlin/src/core/boards.h | 1 + .../src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h | 266 ++++++++++++++++++ Marlin/src/pins/pins.h | 2 + 4 files changed, 322 insertions(+) create mode 100644 Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index e11439861bd4..c6c6ef9b0db5 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -867,6 +867,57 @@ void stop() { } } +inline void tmc_standby_setup() { + #if PIN_EXISTS(X_STDBY) + SET_INPUT_PULLDOWN(X_STDBY_PIN); + #endif + #if PIN_EXISTS(X2_STDBY) + SET_INPUT_PULLDOWN(X2_STDBY_PIN); + #endif + #if PIN_EXISTS(Y_STDBY) + SET_INPUT_PULLDOWN(Y_STDBY_PIN); + #endif + #if PIN_EXISTS(Y2_STDBY) + SET_INPUT_PULLDOWN(Y2_STDBY_PIN); + #endif + #if PIN_EXISTS(Z_STDBY) + SET_INPUT_PULLDOWN(Z_STDBY_PIN); + #endif + #if PIN_EXISTS(Z2_STDBY) + SET_INPUT_PULLDOWN(Z2_STDBY_PIN); + #endif + #if PIN_EXISTS(Z3_STDBY) + SET_INPUT_PULLDOWN(Z3_STDBY_PIN); + #endif + #if PIN_EXISTS(Z4_STDBY) + SET_INPUT_PULLDOWN(Z4_STDBY_PIN); + #endif + #if PIN_EXISTS(E0_STDBY) + SET_INPUT_PULLDOWN(E0_STDBY_PIN); + #endif + #if PIN_EXISTS(E1_STDBY) + SET_INPUT_PULLDOWN(E1_STDBY_PIN); + #endif + #if PIN_EXISTS(E2_STDBY) + SET_INPUT_PULLDOWN(E2_STDBY_PIN); + #endif + #if PIN_EXISTS(E3_STDBY) + SET_INPUT_PULLDOWN(E3_STDBY_PIN); + #endif + #if PIN_EXISTS(E4_STDBY) + SET_INPUT_PULLDOWN(E4_STDBY_PIN); + #endif + #if PIN_EXISTS(E5_STDBY) + SET_INPUT_PULLDOWN(E5_STDBY_PIN); + #endif + #if PIN_EXISTS(E6_STDBY) + SET_INPUT_PULLDOWN(E6_STDBY_PIN); + #endif + #if PIN_EXISTS(E7_STDBY) + SET_INPUT_PULLDOWN(E7_STDBY_PIN); + #endif +} + /** * Marlin entry-point: Set up before the program loop * - Set up the kill pin, filament runout, power hold @@ -888,6 +939,8 @@ void stop() { */ void setup() { + tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable + #if ENABLED(MARLIN_DEV_MODE) auto log_current_ms = [&](PGM_P const msg) { SERIAL_ECHO_START(); diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index e27448b0220b..9e0451486e63 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -223,6 +223,7 @@ #define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed) #define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed) #define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed) +#define BOARD_BTT_SKR_E3_TURBO 2015 // BigTreeTech SKR E3 Turbo (Power outputs: Hotend0, Hotend1, Fan, Bed) // // LPC1769 ARM Cortex M3 diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h new file mode 100644 index 000000000000..143504f0e338 --- /dev/null +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -0,0 +1,266 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ +#pragma once + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR E3 Turbo" +#endif + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) + +// +// Servos +// +#define SERVO0_PIN P1_23 + +// +// TMC StallGuard DIAG pins +// +#define X_DIAG_PIN P1_29 // X-STOP +#define Y_DIAG_PIN P1_28 // Y-STOP +#define Z_DIAG_PIN P1_27 // Z-STOP +#define E0_DIAG_PIN P1_26 // E0DET +#define E1_DIAG_PIN P1_25 // E1DET + +// +// Limit Switches +#define X_STOP_PIN X_DIAG_PIN +#define Y_STOP_PIN Y_DIAG_PIN +#define Z_STOP_PIN Z_DIAG_PIN + +// +// Z Probe +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P1_22 +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN P1_26 // E0DET +#define FIL_RUNOUT2_PIN P1_25 // E1DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN P1_21 +#endif + +// LED driving pin +#define NEOPIXEL_PIN P1_24 + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN P1_20 // PWRDET +#endif + +// +// Steppers +// +#define X_STEP_PIN P1_04 +#define X_DIR_PIN P1_08 +#define X_ENABLE_PIN P1_00 +#ifndef X_CS_PIN + #define X_CS_PIN P1_01 +#endif + +#define Y_STEP_PIN P1_14 +#define Y_DIR_PIN P1_15 +#define Y_ENABLE_PIN P1_09 +#ifndef Y_CS_PIN + #define Y_CS_PIN P1_10 +#endif + +#define Z_STEP_PIN P4_29 +#define Z_DIR_PIN P4_28 +#define Z_ENABLE_PIN P1_16 +#ifndef Z_CS_PIN + #define Z_CS_PIN P1_17 +#endif + +#define E0_STEP_PIN P2_06 +#define E0_DIR_PIN P2_07 +#define E0_ENABLE_PIN P0_04 +#ifndef E0_CS_PIN + #define E0_CS_PIN P0_05 +#endif + +#define E1_STEP_PIN P2_11 +#define E1_DIR_PIN P2_12 +#define E1_ENABLE_PIN P0_21 +#ifndef E1_CS_PIN + #define E1_CS_PIN P0_22 +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + + // + // Software serial + // + #define X_SERIAL_TX_PIN P1_01 + #define X_SERIAL_RX_PIN P1_01 + + #define Y_SERIAL_TX_PIN P1_10 + #define Y_SERIAL_RX_PIN P1_10 + + #define Z_SERIAL_TX_PIN P1_17 + #define Z_SERIAL_RX_PIN P1_17 + + #define E0_SERIAL_TX_PIN P0_05 + #define E0_SERIAL_RX_PIN P0_05 + + #define E1_SERIAL_TX_PIN P0_22 + #define E1_SERIAL_RX_PIN P0_22 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// TMC Low Power Standby pins +// +#define X_STDBY_PIN P3_26 +#define Y_STDBY_PIN P3_25 +#define Z_STDBY_PIN P1_18 +#define E0_STDBY_PIN P1_19 +#define E1_STDBY_PIN P2_13 + +// +// Temperature Sensors +// +#define TEMP_0_PIN P0_24 +#define TEMP_1_PIN P0_23 +//#define TEMP_2_PIN P1_30 // Onboard thermistor +#define TEMP_BED_PIN P0_25 + +// +// Heaters / Fans +// +#define HEATER_0_PIN P2_03 // EXTRUDER 0 +#define HEATER_1_PIN P2_04 // EXTRUDER 1 +#define HEATER_BED_PIN P2_05 // BED +#define FAN_PIN P2_01 +#define FAN1_PIN P2_02 + +// +// USB connect control +// +//#define USB_CONNECT_PIN P0_29 +//#define USB_CONNECT_INVERTING false + +/** + * _____ + * 5V | 1 2 | GND + * (LCD_EN) P0_18 | 3 4 | P0_17 (LCD_RS) + * (LCD_D4) P0_15 | 5 6 P0_20 (BTN_EN2) + * RESET | 7 8 | P0_19 (BTN_EN1) + * (BTN_ENC) P0_16 | 9 10| P2_08 (BEEPER) + * ----- + * EXP + */ + +#define EXPA1_03_PIN P0_18 +#define EXPA1_04_PIN P0_17 +#define EXPA1_05_PIN P0_15 +#define EXPA1_06_PIN P0_20 +#define EXPA1_07_PIN -1 +#define EXPA1_08_PIN P0_19 +#define EXPA1_09_PIN P0_16 +#define EXPA1_10_PIN P2_08 + +#if HAS_SPI_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN EXPA1_10_PIN + + #define BTN_EN1 EXPA1_08_PIN + #define BTN_EN2 EXPA1_06_PIN + #define BTN_ENC EXPA1_09_PIN + + #define LCD_PINS_RS EXPA1_04_PIN + #define LCD_PINS_ENABLE EXPA1_03_PIN + #define LCD_PINS_D4 EXPA1_05_PIN + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_E3_TURBO.h' for details. Comment out this line to continue." + + #define LCD_PINS_RS EXPA1_05_PIN + #define LCD_PINS_ENABLE EXPA1_09_PIN + #define LCD_PINS_D4 EXPA1_04_PIN + #define LCD_PINS_D5 EXPA1_06_PIN + #define LCD_PINS_D6 EXPA1_08_PIN + #define LCD_PINS_D7 EXPA1_10_PIN + #define ADC_KEYPAD_PIN P1_23 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_EN1 EXPA1_08_PIN + #define BTN_EN2 EXPA1_06_PIN + #define BTN_ENC EXPA1_09_PIN + + #define DOGLCD_CS EXPA1_04_PIN + #define DOGLCD_A0 EXPA1_05_PIN + #define DOGLCD_SCK EXPA1_10_PIN + #define DOGLCD_MOSI EXPA1_03_PIN + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #else + + #error "Only ZONESTAR_LCD, MKS_MINI_12864, ENDER2_STOCKDISPLAY, and CR10_STOCKDISPLAY are currently supported on the BTT_SKR_E3_TURBO." + + #endif + +#endif // HAS_SPI_LCD + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN P2_00 + #define SCK_PIN P0_07 + #define MISO_PIN P0_08 + #define MOSI_PIN P0_09 + #define SS_PIN P0_06 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR E3 Turbo." +#endif + +#define ON_BOARD_SPI_DEVICE 1 // SPI1 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index bf95c8731239..0ccdadadde4c 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -421,6 +421,8 @@ #include "lpc1769/pins_BTT_SKR_V1_4_TURBO.h" // LPC1769 env:LPC1769 #elif MB(MKS_SGEN_L_V2) #include "lpc1769/pins_MKS_SGEN_L_V2.h" // LPC1769 env:LPC1769 +#elif MB(BTT_SKR_E3_TURBO) + #include "lpc1769/pins_BTT_SKR_E3_TURBO.h" // LPC1769 env:LPC1769 // // Due (ATSAM) boards From 7ce91c5ffe978ac9aa7b3d2d7c7670c480085bb1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Sep 2020 21:46:13 -0500 Subject: [PATCH 54/63] Sanity check old serial names --- Marlin/Configuration_adv.h | 2 +- Marlin/src/HAL/AVR/MarlinSerial.h | 2 +- Marlin/src/inc/SanityCheck.h | 8 ++++++++ Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a8c9205538ad..c5f56f18d054 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1409,7 +1409,7 @@ #define DGUS_RX_BUFFER_SIZE 128 #define DGUS_TX_BUFFER_SIZE 48 - //#define DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR) + //#define SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR) #define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index cb906e2b6572..8a0423d143d8 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -310,7 +310,7 @@ #if HAS_DGUS_LCD static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE; static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE; - static constexpr bool RX_OVERRUNS = ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS); + static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS); #elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) static constexpr unsigned int RX_SIZE = 64; static constexpr unsigned int TX_SIZE = 128; diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 27bafe00485e..1cb8bcd7e902 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -481,6 +481,14 @@ #error "DGUS_SERIAL_PORT is now LCD_SERIAL_PORT. Please update your configuration." #elif defined(DGUS_BAUDRATE) #error "DGUS_BAUDRATE is now LCD_BAUDRATE. Please update your configuration." +#elif defined(DGUS_STATS_RX_BUFFER_OVERRUNS) + #error "DGUS_STATS_RX_BUFFER_OVERRUNS is now STATS_RX_BUFFER_OVERRUNS. Please update your configuration." +#elif defined(DGUS_SERIAL_PORT) + #error "DGUS_SERIAL_PORT is now LCD_SERIAL_PORT. Please update your configuration." +#elif defined(ANYCUBIC_LCD_SERIAL_PORT) + #error "ANYCUBIC_LCD_SERIAL_PORT is now LCD_SERIAL_PORT. Please update your configuration." +#elif defined(INTERNAL_SERIAL_PORT) + #error "INTERNAL_SERIAL_PORT is now MMU2_SERIAL_PORT. Please update your configuration." #elif defined(X_DUAL_ENDSTOPS_ADJUSTMENT) #error "X_DUAL_ENDSTOPS_ADJUSTMENT is now X2_ENDSTOP_ADJUSTMENT. Please update Configuration_adv.h." #elif defined(Y_DUAL_ENDSTOPS_ADJUSTMENT) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index 5181ba7cc454..8577b76ce61f 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -129,7 +129,7 @@ void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t val void DGUSDisplay::ProcessRx() { - #if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS) + #if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS) if (!LCD_SERIAL.available() && LCD_SERIAL.buffer_overruns()) { // Overrun, but reset the flag only when the buffer is empty // We want to extract as many as valid datagrams possible... From 178a1da165162f59a8a4a98d038ac4d2eef6c674 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Fri, 25 Sep 2020 16:58:28 -0300 Subject: [PATCH 55/63] TFT: No timeout on Move Screen (#19426) --- Marlin/src/lcd/tft/ui_480x320.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index b5b332910bd6..ffc619e8dcaf 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -956,24 +956,17 @@ static void drawBtn(int x, int y, const char* label, int32_t data, MarlinImage i uint16_t width = Images[imgBtn52Rounded].width; uint16_t height = Images[imgBtn52Rounded].height; - tft.queue.sync(); //need sync to change font - if (!enabled) bgColor = COLOR_CONTROL_DISABLED; tft.canvas(x, y, width, height); tft.set_background(COLOR_BACKGROUND); tft.add_image(0, 0, imgBtn52Rounded, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); + // TODO: Make an add_text() taking a font arg if (label != NULL) { - tft.set_font(Helvetica12Bold); - tft_string.set_font(Helvetica12Bold); tft_string.set(label); tft_string.trim(); tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string); - - tft.queue.sync(); - tft_string.set_font(Helvetica18); - tft.set_font(Helvetica18); } else { tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); @@ -984,6 +977,7 @@ static void drawBtn(int x, int y, const char* label, int32_t data, MarlinImage i void MarlinUI::move_axis_screen() { // Reset + defer_status_screen(true); motionAxisState.blocked = false; touch.enable(); From f902e208a39da65f0f5447e1dc669ccf06260080 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 26 Sep 2020 00:13:15 +0000 Subject: [PATCH 56/63] [cron] Bump distribution date (2020-09-26) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 95ac6d405143..c0b1912b0af8 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-09-25" + #define STRING_DISTRIBUTION_DATE "2020-09-26" #endif /** From 61d96ce1c99cff048674126e1d75d607edfee6be Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Fri, 25 Sep 2020 21:45:01 -0300 Subject: [PATCH 57/63] Escape the M33 string arg (#19515) --- Marlin/src/gcode/parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 91a24d1dd0eb..b3172e7f6b42 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -247,7 +247,7 @@ void GCodeParser::parse(char *p) { #if ENABLED(EXPECTED_PRINTER_CHECK) case 16: #endif - case 23: case 28: case 30: case 117: case 118: case 928: + case 23: case 28: case 30: case 33: case 117: case 118: case 928: string_arg = unescape_string(p); return; default: break; From 7efd740950f16a22d3023f17d33b1996c1b0b7b6 Mon Sep 17 00:00:00 2001 From: ellensp Date: Sat, 26 Sep 2020 12:47:22 +1200 Subject: [PATCH 58/63] Fix MKS Robin undefined pins error (#19507) --- Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 48da17adc5a9..26a0c9260e03 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -126,12 +126,7 @@ #endif #define LED_PIN PB2 -#ifdef HAS_GRAPHICAL_TFT - #define TFT_RESET_PIN PF6 - #define TFT_BACKLIGHT_PIN PG11 - #define TFT_CS_PIN PG12 // NE4 - #define TFT_RS_PIN PF0 // A0 -#else +#if HAS_FSMC_TFT /** * Note: MKS Robin TFT screens use various TFT controllers * Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240) @@ -148,10 +143,17 @@ #define LCD_BACKLIGHT_PIN PG11 #define FSMC_CS_PIN PG12 // NE4 #define FSMC_RS_PIN PF0 // A0 + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT #define FSMC_DMA_DEV DMA2 #define FSMC_DMA_CHANNEL DMA_CH5 +#elif HAS_GRAPHICAL_TFT + #define TFT_RESET_PIN PF6 + #define TFT_BACKLIGHT_PIN PG11 + #define TFT_CS_PIN PG12 // NE4 + #define TFT_RS_PIN PF0 // A0 #endif #if NEED_TOUCH_PINS From 97e0d55073b0c240a2b2b0d0d7bf6401d96ff339 Mon Sep 17 00:00:00 2001 From: Luke Harrison Date: Sat, 26 Sep 2020 02:48:24 +0200 Subject: [PATCH 59/63] Fix SKR 1.4 thermistor pin comments (#19510) --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index 1846b16e4698..fb383ff5fff5 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -153,8 +153,8 @@ #define E1_CS_PIN P1_01 #endif -#define TEMP_1_PIN P0_23_A0 // A2 (T2) - (69) - TEMP_1_PIN -#define TEMP_BED_PIN P0_25_A2 // A0 (T0) - (67) - TEMP_BED_PIN +#define TEMP_1_PIN P0_23_A0 // A0 (T0) - (67) - TEMP_1_PIN +#define TEMP_BED_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_BED_PIN // // Software SPI pins for TMC2130 stepper drivers From ec4a0a3e0d999702222dbe914ec08a50fde3a706 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Fri, 25 Sep 2020 17:49:36 -0700 Subject: [PATCH 60/63] SKR E3 Turbo followup (#19513) --- Marlin/src/core/boards.h | 2 +- Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 9e0451486e63..beb348845dd2 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -223,7 +223,6 @@ #define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed) #define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed) #define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed) -#define BOARD_BTT_SKR_E3_TURBO 2015 // BigTreeTech SKR E3 Turbo (Power outputs: Hotend0, Hotend1, Fan, Bed) // // LPC1769 ARM Cortex M3 @@ -239,6 +238,7 @@ #define BOARD_TH3D_EZBOARD 2507 // TH3D EZBoard v1.0 #define BOARD_BTT_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO (Power outputs: Hotend0, Hotend1, Fan, Bed) #define BOARD_MKS_SGEN_L_V2 2509 // MKS SGEN_L V2 (Power outputs: Hotend0, Hotend1, Bed, Fan) +#define BOARD_BTT_SKR_E3_TURBO 2510 // BigTreeTech SKR E3 Turbo (Power outputs: Hotend0, Hotend1, Bed, Fan0, Fan1) // // SAM3X8E ARM Cortex M3 diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h index 143504f0e338..de987f95d2e4 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -173,12 +173,6 @@ #define FAN_PIN P2_01 #define FAN1_PIN P2_02 -// -// USB connect control -// -//#define USB_CONNECT_PIN P0_29 -//#define USB_CONNECT_INVERTING false - /** * _____ * 5V | 1 2 | GND From a7f5d38da7d6e57d5cfac9358eb13e57fac61db1 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Fri, 25 Sep 2020 21:58:45 -0300 Subject: [PATCH 61/63] Fix MBL "Click to continue" on Color UI touchscreen (#19514) --- Marlin/src/lcd/menu/menu_bed_leveling.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 6841561c1bf8..e19b04ccb517 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -36,6 +36,11 @@ #include "../../module/probe.h" #endif +#if HAS_GRAPHICAL_TFT + #include "../tft/touch.h" + #include "../tft/tft.h" +#endif + #if EITHER(PROBE_MANUALLY, MESH_BED_LEVELING) #include "../../module/motion.h" @@ -159,7 +164,11 @@ // Move to the first probe position // void _lcd_level_bed_homing_done() { - if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING)); + if (ui.should_draw()) { + MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING)); + // Color UI needs a control to detect a touch + TERN_(HAS_GRAPHICAL_TFT, touch.add_control(CLICK, 0, 0, TFT_WIDTH, TFT_HEIGHT)); + } if (ui.use_click()) { manual_probe_index = 0; _lcd_level_goto_next_point(); From 5cf2cf2be9dda751191d1d056d6807980857a060 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Fri, 25 Sep 2020 22:05:23 -0300 Subject: [PATCH 62/63] Allow ColorUI color customization (#19484) --- Marlin/src/lcd/tft/tft_color.h | 122 +++++++++++++++++++++++++-------- 1 file changed, 92 insertions(+), 30 deletions(-) diff --git a/Marlin/src/lcd/tft/tft_color.h b/Marlin/src/lcd/tft/tft_color.h index 14906a1bcf66..8e380b366b97 100644 --- a/Marlin/src/lcd/tft/tft_color.h +++ b/Marlin/src/lcd/tft/tft_color.h @@ -21,6 +21,8 @@ */ #pragma once +#include "../../inc/MarlinConfigPre.h" + #define RED(color) ((color >> 8) & 0xF8) #define GREEN(color) ((color >> 3) & 0xFC) #define BLUE(color) ((color << 3) & 0xF8) @@ -70,45 +72,105 @@ #ifndef COLOR_BACKGROUND #define COLOR_BACKGROUND 0x20AC // #1E156E #endif -#define COLOR_SELECTION_BG 0x9930 // #992380 -#define COLOR_WEBSITE_URL 0x03B7 +#ifndef COLOR_SELECTION_BG + #define COLOR_SELECTION_BG 0x9930 // #992380 +#endif +#ifndef COLOR_WEBSITE_URL + #define COLOR_WEBSITE_URL 0x03B7 +#endif -#define COLOR_INACTIVE COLOR_GREY -#define COLOR_COLD COLOR_AQUA -#define COLOR_HOTEND COLOR_SCARLET -#define COLOR_HEATED_BED COLOR_DARK_ORANGE -#define COLOR_CHAMBER COLOR_DARK_ORANGE -#define COLOR_FAN COLOR_AQUA +#ifndef COLOR_INACTIVE + #define COLOR_INACTIVE COLOR_GREY +#endif +#ifndef COLOR_COLD + #define COLOR_COLD COLOR_AQUA +#endif +#ifndef COLOR_HOTEND + #define COLOR_HOTEND COLOR_SCARLET +#endif +#ifndef COLOR_HEATED_BED + #define COLOR_HEATED_BED COLOR_DARK_ORANGE +#endif +#ifndef COLOR_CHAMBER + #define COLOR_CHAMBER COLOR_DARK_ORANGE +#endif +#ifndef COLOR_FAN + #define COLOR_FAN COLOR_AQUA +#endif -#define COLOR_AXIS_HOMED COLOR_WHITE -#define COLOR_AXIS_NOT_HOMED COLOR_YELLOW +#ifndef COLOR_AXIS_HOMED + #define COLOR_AXIS_HOMED COLOR_WHITE +#endif +#ifndef COLOR_AXIS_NOT_HOMED + #define COLOR_AXIS_NOT_HOMED COLOR_YELLOW +#endif -#define COLOR_RATE_100 COLOR_VIVID_GREEN -#define COLOR_RATE_ALTERED COLOR_YELLOW +#ifndef COLOR_RATE_100 + #define COLOR_RATE_100 COLOR_VIVID_GREEN +#endif +#ifndef COLOR_RATE_ALTERED + #define COLOR_RATE_ALTERED COLOR_YELLOW +#endif -#define COLOR_PRINT_TIME COLOR_AQUA +#ifndef COLOR_PRINT_TIME + #define COLOR_PRINT_TIME COLOR_AQUA +#endif -#define COLOR_PROGRESS_FRAME COLOR_WHITE -#define COLOR_PROGRESS_BAR COLOR_BLUE -#define COLOR_PROGRESS_BG COLOR_BLACK +#ifndef COLOR_PROGRESS_FRAME + #define COLOR_PROGRESS_FRAME COLOR_WHITE +#endif +#ifndef COLOR_PROGRESS_BAR + #define COLOR_PROGRESS_BAR COLOR_BLUE +#endif +#ifndef COLOR_PROGRESS_BG + #define COLOR_PROGRESS_BG COLOR_BLACK +#endif -#define COLOR_STATUS_MESSAGE COLOR_YELLOW +#ifndef COLOR_STATUS_MESSAGE + #define COLOR_STATUS_MESSAGE COLOR_YELLOW +#endif -#define COLOR_CONTROL_ENABLED COLOR_WHITE -#define COLOR_CONTROL_DISABLED COLOR_GREY -#define COLOR_CONTROL_CANCEL COLOR_SCARLET -#define COLOR_CONTROL_CONFIRM COLOR_VIVID_GREEN -#define COLOR_BUSY COLOR_SILVER +#ifndef COLOR_CONTROL_ENABLED + #define COLOR_CONTROL_ENABLED COLOR_WHITE +#endif +#ifndef COLOR_CONTROL_DISABLED + #define COLOR_CONTROL_DISABLED COLOR_GREY +#endif +#ifndef COLOR_CONTROL_CANCEL + #define COLOR_CONTROL_CANCEL COLOR_SCARLET +#endif +#ifndef COLOR_CONTROL_CONFIRM + #define COLOR_CONTROL_CONFIRM COLOR_VIVID_GREEN +#endif +#ifndef COLOR_BUSY + #define COLOR_BUSY COLOR_SILVER +#endif -#define COLOR_MENU_TEXT COLOR_YELLOW -#define COLOR_MENU_VALUE COLOR_WHITE +#ifndef COLOR_MENU_TEXT + #define COLOR_MENU_TEXT COLOR_YELLOW +#endif +#ifndef COLOR_MENU_VALUE + #define COLOR_MENU_VALUE COLOR_WHITE +#endif -#define COLOR_SLIDER COLOR_WHITE -#define COLOR_SLIDER_INACTIVE COLOR_GREY +#ifndef COLOR_SLIDER + #define COLOR_SLIDER COLOR_WHITE +#endif +#ifndef COLOR_SLIDER_INACTIVE + #define COLOR_SLIDER_INACTIVE COLOR_GREY +#endif -#define COLOR_UBL COLOR_WHITE +#ifndef COLOR_UBL + #define COLOR_UBL COLOR_WHITE +#endif -#define COLOR_TOUCH_CALIBRATION COLOR_WHITE +#ifndef COLOR_TOUCH_CALIBRATION + #define COLOR_TOUCH_CALIBRATION COLOR_WHITE +#endif -#define COLOR_KILL_SCREEN_BG COLOR_MAROON -#define COLOR_KILL_SCREEN_TEXT COLOR_WHITE +#ifndef COLOR_KILL_SCREEN_BG + #define COLOR_KILL_SCREEN_BG COLOR_MAROON +#endif +#ifndef COLOR_KILL_SCREEN_TEXT + #define COLOR_KILL_SCREEN_TEXT COLOR_WHITE +#endif From 88d7f4d7be744ecfecdb531cb48ae42a02403cef Mon Sep 17 00:00:00 2001 From: Trocololo Date: Sat, 26 Sep 2020 03:28:01 +0200 Subject: [PATCH 63/63] MMU2 S Mode spins the BMG gears during C0 (#19429) --- Marlin/src/feature/mmu2/mmu2.cpp | 67 +++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/Marlin/src/feature/mmu2/mmu2.cpp b/Marlin/src/feature/mmu2/mmu2.cpp index 35f2db45a907..31b179a3e5e9 100644 --- a/Marlin/src/feature/mmu2/mmu2.cpp +++ b/Marlin/src/feature/mmu2/mmu2.cpp @@ -54,6 +54,8 @@ MMU2 mmu2; #define MMU_CMD_TIMEOUT 45000UL // 45s timeout for mmu commands (except P0) #define MMU_P0_TIMEOUT 3000UL // Timeout for P0 command: 3seconds +#define MMU2_COMMAND(S) tx_str_P(PSTR(S "\n")) + #if ENABLED(MMU_EXTRUDER_SENSOR) uint8_t mmu_idl_sens = 0; static bool mmu_loading_flag = false; @@ -152,7 +154,7 @@ void MMU2::reset() { safe_delay(20); WRITE(MMU2_RST_PIN, HIGH); #else - tx_str_P(PSTR("X0\n")); // Send soft reset + MMU2_COMMAND("X0"); // Send soft reset #endif } @@ -175,9 +177,7 @@ void MMU2::mmu_loop() { DEBUG_ECHOLNPGM("MMU => 'start'"); DEBUG_ECHOLNPGM("MMU <= 'S1'"); - // send "read version" request - tx_str_P(PSTR("S1\n")); - + MMU2_COMMAND("S1"); // Read Version state = -2; } else if (millis() > 3000000) { @@ -192,7 +192,7 @@ void MMU2::mmu_loop() { DEBUG_ECHOLNPAIR("MMU => ", version, "\nMMU <= 'S2'"); - tx_str_P(PSTR("S2\n")); // read build number + MMU2_COMMAND("S2"); // Read Build Number state = -3; } break; @@ -208,13 +208,13 @@ void MMU2::mmu_loop() { #if ENABLED(MMU2_MODE_12V) DEBUG_ECHOLNPGM("MMU <= 'M1'"); - tx_str_P(PSTR("M1\n")); // switch to stealth mode + MMU2_COMMAND("M1"); // Stealth Mode state = -5; #else DEBUG_ECHOLNPGM("MMU <= 'P0'"); - tx_str_P(PSTR("P0\n")); // read finda + MMU2_COMMAND("P0"); // Read FINDA state = -4; #endif } @@ -228,7 +228,7 @@ void MMU2::mmu_loop() { DEBUG_ECHOLNPGM("MMU <= 'P0'"); - tx_str_P(PSTR("P0\n")); // read finda + MMU2_COMMAND("P0"); // Read FINDA state = -4; } break; @@ -266,14 +266,14 @@ void MMU2::mmu_loop() { else if (cmd == MMU_CMD_C0) { // continue loading DEBUG_ECHOLNPGM("MMU <= 'C0'"); - tx_str_P(PSTR("C0\n")); + MMU2_COMMAND("C0"); state = 3; // wait for response } else if (cmd == MMU_CMD_U0) { // unload current DEBUG_ECHOLNPGM("MMU <= 'U0'"); - tx_str_P(PSTR("U0\n")); + MMU2_COMMAND("U0"); state = 3; // wait for response } else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) { @@ -286,7 +286,7 @@ void MMU2::mmu_loop() { else if (cmd == MMU_CMD_R0) { // recover after eject DEBUG_ECHOLNPGM("MMU <= 'R0'"); - tx_str_P(PSTR("R0\n")); + MMU2_COMMAND("R0"); state = 3; // wait for response } else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) { @@ -303,8 +303,7 @@ void MMU2::mmu_loop() { cmd = MMU_CMD_NONE; } else if (ELAPSED(millis(), prev_P0_request + 300)) { - // read FINDA - tx_str_P(PSTR("P0\n")); + MMU2_COMMAND("P0"); // Read FINDA state = 2; // wait for response } @@ -332,19 +331,32 @@ void MMU2::mmu_loop() { #if ENABLED(MMU_EXTRUDER_SENSOR) if (mmu_idl_sens) { if (FILAMENT_PRESENT() && mmu_loading_flag) { - DEBUG_ECHOLNPGM("MMU <= 'A'\n"); - tx_str_P(PSTR("A\n")); // send 'abort' request + DEBUG_ECHOLNPGM("MMU <= 'A'"); + MMU2_COMMAND("A"); // send 'abort' request mmu_idl_sens = 0; - DEBUG_ECHOLNPGM("MMU IDLER_SENSOR = 0 - ABORT\n"); + DEBUG_ECHOLNPGM("MMU IDLER_SENSOR = 0 - ABORT"); } } #endif if (rx_ok()) { - DEBUG_ECHOLNPGM("MMU => 'ok'"); - ready = true; - state = 1; - last_cmd = MMU_CMD_NONE; + // response to C0 mmu command in PRUSA_MMU2_S_MODE + bool can_reset = true; + if (ENABLED(PRUSA_MMU2_S_MODE) && last_cmd == MMU_CMD_C0) { + if (!mmu2s_triggered) { + can_reset = false; + // MMU ok received but filament sensor not triggered, retrying... + DEBUG_ECHOLNPGM("MMU => 'ok' (filament not present in gears)"); + DEBUG_ECHOLNPGM("MMU <= 'C0' (keep trying)"); + MMU2_COMMAND("C0"); + } + } + if (can_reset) { + DEBUG_ECHOLNPGM("MMU => 'ok'"); + ready = true; + state = 1; + last_cmd = MMU_CMD_NONE; + } } else if (ELAPSED(millis(), prev_request + MMU_CMD_TIMEOUT)) { // resend request after timeout @@ -862,9 +874,18 @@ void MMU2::filament_runout() { void MMU2::check_filament() { const bool present = FILAMENT_PRESENT(); - if (present && !mmu2s_triggered) { - DEBUG_ECHOLNPGM("MMU <= 'A'"); - tx_str_P(PSTR("A\n")); + if (cmd == MMU_CMD_NONE && last_cmd == MMU_CMD_C0) { + if (present && !mmu2s_triggered) { + DEBUG_ECHOLNPGM("MMU <= 'A'"); + tx_str_P(PSTR("A\n")); + } + // Slowly spin the extruder during C0 + else { + while (planner.movesplanned() < 3) { + current_position.e += 0.25; + line_to_current_position(MMM_TO_MMS(120)); + } + } } mmu2s_triggered = present; }