From c91a91008cad53ca64806e0b8f6abb65341faa0c Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Sun, 31 Jan 2021 23:47:16 +0100 Subject: [PATCH 01/51] Remove extra G29 V newlines (#20955) --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 3f7b2d7d96..41d2a36359 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -742,7 +742,7 @@ if (do_ubl_mesh_map) display_map(g29_map_type); const int point_num = (GRID_MAX_POINTS) - count + 1; - SERIAL_ECHOLNPAIR("\nProbing mesh point ", point_num, "/", int(GRID_MAX_POINTS), ".\n"); + SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", int(GRID_MAX_POINTS), "."); TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS))); #if HAS_LCD_MENU From d49969ddf3651f0eb3aae081261c39d67a6dad5a Mon Sep 17 00:00:00 2001 From: zeleps <39417467+zeleps@users.noreply.github.com> Date: Mon, 1 Feb 2021 00:50:12 +0200 Subject: [PATCH 02/51] Init serial ports first (#20944) --- Marlin/src/MarlinCore.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 51e0efafd6..8692e9219e 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -886,6 +886,17 @@ void setup() { #endif #define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0) + MYSERIAL0.begin(BAUDRATE); + millis_t serial_connect_timeout = millis() + 1000UL; + while (!MYSERIAL0.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + + #if HAS_MULTI_SERIAL && !HAS_ETHERNET + MYSERIAL1.begin(BAUDRATE); + serial_connect_timeout = millis() + 1000UL; + while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + #endif + SERIAL_ECHOLNPGM("start"); + // Set up these pins early to prevent suicide #if HAS_KILL SETUP_LOG("KILL_PIN"); @@ -918,17 +929,6 @@ void setup() { #endif #endif - MYSERIAL0.begin(BAUDRATE); - millis_t serial_connect_timeout = millis() + 1000UL; - while (!MYSERIAL0.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } - - #if HAS_MULTI_SERIAL && !HAS_ETHERNET - MYSERIAL1.begin(BAUDRATE); - serial_connect_timeout = millis() + 1000UL; - while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } - #endif - SERIAL_ECHOLNPGM("start"); - #if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE) mks_esp_wifi_init(); WIFISERIAL.begin(WIFI_BAUDRATE); From 27366197f3380627af365b005702bbe16393a18a Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Mon, 1 Feb 2021 00:21:27 +0100 Subject: [PATCH 03/51] Serial refactor followup (#20932) --- Marlin/src/HAL/STM32/MarlinSerial.cpp | 2 +- Marlin/src/MarlinCore.cpp | 4 ++-- Marlin/src/core/serial_base.h | 27 ++++++++++++++++++------- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 2 +- Marlin/src/gcode/calibrate/M48.cpp | 4 ++-- Marlin/src/gcode/host/M115.cpp | 4 ++-- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/tool_change.cpp | 2 +- Marlin/src/sd/SdBaseFile.cpp | 2 +- 9 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Marlin/src/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp index c420ce40cf..cfb13f5bb5 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp @@ -81,7 +81,7 @@ void MarlinSerial::_rx_complete_irq(serial_t *obj) { } #if ENABLED(EMERGENCY_PARSER) - emergency_parser.update(emergency_state, c); + emergency_parser.update(static_cast(this)->emergency_state, c); #endif } } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 8692e9219e..16111936da 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -614,8 +614,8 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { */ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { #if ENABLED(MARLIN_DEV_MODE) - static uint8_t idle_depth = 0; - if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", int(idle_depth)); + static uint16_t idle_depth = 0; + if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth); #endif // Core Marlin activities diff --git a/Marlin/src/core/serial_base.h b/Marlin/src/core/serial_base.h index 220ccae831..f52fa11202 100644 --- a/Marlin/src/core/serial_base.h +++ b/Marlin/src/core/serial_base.h @@ -78,13 +78,22 @@ struct SerialBase { FORCE_INLINE void write(const char* str) { while (*str) write(*str++); } FORCE_INLINE void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); } FORCE_INLINE void print(const char* str) { write(str); } - NO_INLINE void print(char c, int base = 0) { print((long)c, base); } - NO_INLINE void print(unsigned char c, int base = 0) { print((unsigned long)c, base); } - NO_INLINE void print(int c, int base = DEC) { print((long)c, base); } - NO_INLINE void print(unsigned int c, int base = DEC) { print((unsigned long)c, base); } - void print(long c, int base = DEC) { if (!base) write(c); write((const uint8_t*)"-", c < 0); printNumber(c < 0 ? -c : c, base); } - void print(unsigned long c, int base = DEC) { printNumber(c, base); } - void print(double c, int digits = 2) { printFloat(c, digits); } + NO_INLINE void print(char c, int base = 0) { print((long)c, base); } + NO_INLINE void print(unsigned char c, int base = 0) { print((unsigned long)c, base); } + NO_INLINE void print(int c, int base = DEC) { print((long)c, base); } + NO_INLINE void print(unsigned int c, int base = DEC) { print((unsigned long)c, base); } + void print(unsigned long c, int base = DEC) { printNumber(c, base); } + void print(double c, int digits = 2) { printFloat(c, digits); } + void print(long c, int base = DEC) { + if (!base) { + write(c); + return; + } + if (base == DEC && c < 0) { + write((uint8_t)'-'); c = -c; + } + printNumber(c, base); + } NO_INLINE void println(const char s[]) { print(s); println(); } NO_INLINE void println(char c, int base = 0) { print(c, base); println(); } @@ -98,6 +107,10 @@ struct SerialBase { // Print a number with the given base void printNumber(unsigned long n, const uint8_t base) { + if (!base) { + write((uint8_t)n); + return; + } if (n) { unsigned char buf[8 * sizeof(long)]; // Enough space for base 2 int8_t i = 0; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index fba065fed9..b0640e5fa2 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -150,7 +150,7 @@ SERIAL_ECHO_SP(7); LOOP_L_N(i, GRID_MAX_POINTS_X) { if (i < 10) SERIAL_CHAR(' '); - SERIAL_ECHO(i); + SERIAL_ECHO((int)i); SERIAL_ECHO_SP(sp); } serial_delay(10); diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 529d5c75d9..97aea59221 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -240,8 +240,8 @@ void GcodeSuite::M48() { sigma = SQRT(dev_sum / (n + 1)); if (verbose_level > 1) { - SERIAL_ECHO(n + 1); - SERIAL_ECHOPAIR(" of ", int(n_samples)); + SERIAL_ECHO((int)(n + 1)); + SERIAL_ECHOPAIR(" of ", (int)n_samples); SERIAL_ECHOPAIR_F(": z: ", pz, 3); SERIAL_CHAR(' '); dev_report(verbose_level > 2, mean, sigma, min, max); diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 1b088e7d34..0501f3f60b 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -35,8 +35,8 @@ static void cap_line(PGM_P const name, bool ena=false) { SERIAL_ECHOPGM("Cap:"); serialprintPGM(name); - SERIAL_CHAR(':'); - SERIAL_ECHOLN(int(ena ? 1 : 0)); + SERIAL_CHAR(':', ena ? '1' : '0'); + SERIAL_EOL(); } #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e1fd00dcd6..c6ed3d3a48 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2062,7 +2062,7 @@ void Temperature::init() { switch (heater_id) { case H_BED: SERIAL_ECHOPGM("bed"); break; case H_CHAMBER: SERIAL_ECHOPGM("chamber"); break; - default: SERIAL_ECHO(heater_id); + default: SERIAL_ECHO((int)heater_id); } SERIAL_ECHOLNPAIR( " ; sizeof(running_temp):", sizeof(running_temp), diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 867ae5d927..4278e6be26 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -709,7 +709,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a #if EXTRUDERS inline void invalid_extruder_error(const uint8_t e) { SERIAL_ECHO_START(); - SERIAL_CHAR('T'); SERIAL_ECHO(int(e)); + SERIAL_CHAR('T'); SERIAL_ECHO((int)e); SERIAL_CHAR(' '); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER); } #endif diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 270053be3e..7693c52330 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -926,7 +926,7 @@ int SdBaseFile::peek() { // print uint8_t with width 2 static void print2u(const uint8_t v) { if (v < 10) SERIAL_CHAR('0'); - SERIAL_ECHO(int(v)); + SERIAL_ECHO((int)v); } /** From 07b4cc145bf6d84245b93f9f72fb0ac0f9d8d380 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Mon, 1 Feb 2021 01:11:50 +0100 Subject: [PATCH 04/51] Fix AutoReporter implementation (#20959) --- Marlin/src/libs/autoreport.h | 16 ++++++++-------- Marlin/src/module/temperature.cpp | 4 ++-- Marlin/src/module/temperature.h | 4 ++-- Marlin/src/sd/cardreader.cpp | 4 +--- Marlin/src/sd/cardreader.h | 9 ++------- buildroot/tests/LPC1768-tests | 5 +++-- buildroot/tests/mega2560-tests | 2 +- 7 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Marlin/src/libs/autoreport.h b/Marlin/src/libs/autoreport.h index 9bde9f29fb..2c0a043fbf 100644 --- a/Marlin/src/libs/autoreport.h +++ b/Marlin/src/libs/autoreport.h @@ -23,14 +23,14 @@ #include "../inc/MarlinConfig.h" -template -class AutoReporter { -public: +template +struct AutoReporter { millis_t next_report_ms; uint8_t report_interval; - - // Override this method - inline void auto_report() { } + #if HAS_MULTI_SERIAL + serial_index_t report_port_mask; + AutoReporter() : report_port_mask(SERIAL_ALL) {} + #endif inline void set_interval(uint8_t seconds, const uint8_t limit=60) { report_interval = _MIN(seconds, limit); @@ -42,8 +42,8 @@ public: const millis_t ms = millis(); if (ELAPSED(ms, next_report_ms)) { next_report_ms = ms + SEC_TO_MS(report_interval); - PORT_REDIRECT(AR_PORT_INDEX); - auto_report(); + TERN_(HAS_MULTI_SERIAL, PORT_REDIRECT(report_port_mask)); + Helper::report(); } } }; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index c6ed3d3a48..b5820e17bf 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3123,8 +3123,8 @@ void Temperature::tick() { } #if ENABLED(AUTO_REPORT_TEMPERATURES) - Temperature::AutoReportTemp Temperature::auto_reporter; - void Temperature::AutoReportTemp::auto_report() { + AutoReporter Temperature::auto_reporter; + void Temperature::AutoReportTemp::report() { print_heater_states(active_extruder); SERIAL_EOL(); } diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 1401e0d354..002e1cbf71 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -798,8 +798,8 @@ class Temperature { #endif ); #if ENABLED(AUTO_REPORT_TEMPERATURES) - class AutoReportTemp : public AutoReporter { void auto_report(); }; - static AutoReportTemp auto_reporter; + struct AutoReportTemp { static void report(); }; + static AutoReporter auto_reporter; #endif #endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index e3732e5ef8..647e3f3e21 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -1226,9 +1226,7 @@ void CardReader::fileHasFinished() { } #if ENABLED(AUTO_REPORT_SD_STATUS) - TERN_(HAS_MULTI_SERIAL, serial_index_t CardReader::auto_report_port); - CardReader::AutoReportSD CardReader::auto_reporter; - void CardReader::AutoReportSD::auto_report() { report_status(); } + AutoReporter CardReader::auto_reporter; #endif #if ENABLED(POWER_LOSS_RECOVERY) diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index b10a5acd0d..0a89bbba78 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -179,13 +179,8 @@ public: // // SD Auto Reporting // - #if HAS_MULTI_SERIAL - static serial_index_t auto_report_port; - #else - static constexpr serial_index_t auto_report_port = 0; - #endif - class AutoReportSD : public AutoReporter { void auto_report(); }; - static AutoReportSD auto_reporter; + struct AutoReportSD { static void report() { report_status(); } }; + static AutoReporter auto_reporter; #endif private: diff --git a/buildroot/tests/LPC1768-tests b/buildroot/tests/LPC1768-tests index 72d794634f..27d2fbf3ff 100755 --- a/buildroot/tests/LPC1768-tests +++ b/buildroot/tests/LPC1768-tests @@ -37,14 +37,15 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EEB opt_set EXTRUDERS 2 opt_set TEMP_SENSOR_1 -1 opt_set TEMP_SENSOR_BED 5 -opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \ +opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \ FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING SOUND_MENU_ITEM \ NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR PREHEAT_BEFORE_LEVELING G29_RETRY_AND_RECOVER 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 \ Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \ HOST_KEEPALIVE_FEATURE HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT \ - LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA EMERGENCY_PARSER + LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES \ + SDSUPPORT SDCARD_SORT_ALPHA AUTO_REPORT_SD_STATUS EMERGENCY_PARSER opt_set GRID_MAX_POINTS_X 16 opt_set NOZZLE_TO_PROBE_OFFSET "{ 0, 0, 0 }" opt_set NOZZLE_CLEAN_MIN_TEMP 170 diff --git a/buildroot/tests/mega2560-tests b/buildroot/tests/mega2560-tests index 105258d402..e603ea2496 100755 --- a/buildroot/tests/mega2560-tests +++ b/buildroot/tests/mega2560-tests @@ -27,7 +27,7 @@ opt_set TEMP_SENSOR_4 1000 opt_set TEMP_SENSOR_BED 1 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING BOOT_MARLIN_LOGO_SMALL \ - SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \ + SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ From 7626ef57b94a3670b9de107597f949c2519f7c0b Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Mon, 1 Feb 2021 01:15:14 +0100 Subject: [PATCH 05/51] Refresh screen on M22 (detach) (#20958) --- Marlin/src/gcode/sd/M21_M22.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/sd/M21_M22.cpp b/Marlin/src/gcode/sd/M21_M22.cpp index a618bc0be3..f42784d8eb 100644 --- a/Marlin/src/gcode/sd/M21_M22.cpp +++ b/Marlin/src/gcode/sd/M21_M22.cpp @@ -26,6 +26,7 @@ #include "../gcode.h" #include "../../sd/cardreader.h" +#include "../../lcd/marlinui.h" /** * M21: Init SD Card @@ -36,9 +37,8 @@ void GcodeSuite::M21() { card.mount(); } * M22: Release SD Card */ void GcodeSuite::M22() { - if (!IS_SD_PRINTING()) card.release(); - + IF_ENABLED(TFT_COLOR_UI, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT)); } #endif // SDSUPPORT From 33c78d2bb265961a92680629ef7da838ed6d6d13 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 1 Feb 2021 00:17:15 +0000 Subject: [PATCH 06/51] [cron] Bump distribution date (2021-02-01) --- 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 9b34824553..488e570d81 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 "2021-01-31" + #define STRING_DISTRIBUTION_DATE "2021-02-01" #endif /** From c74f972627ab8dcf69a637268cf86682959bd18e Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Mon, 1 Feb 2021 01:18:39 +0100 Subject: [PATCH 07/51] LVGL UI G-code console (#20755) --- Marlin/src/HAL/AVR/HAL.h | 4 +- Marlin/src/HAL/AVR/MarlinSerial.cpp | 2 +- Marlin/src/HAL/AVR/MarlinSerial.h | 8 +- Marlin/src/HAL/STM32/HAL.h | 2 +- .../src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp | 1 - Marlin/src/HAL/STM32F1/MarlinSerial.h | 26 +++++ Marlin/src/core/macros.h | 4 +- Marlin/src/core/serial_hook.h | 7 +- .../src/lcd/extui/lib/mks_ui/draw_gcode.cpp | 109 ++++++++++++++++++ Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h | 33 ++++++ .../lcd/extui/lib/mks_ui/draw_keyboard.cpp | 24 +++- .../extui/lib/mks_ui/draw_level_settings.cpp | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp | 34 +++--- Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp | 3 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 1 + Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 9 +- .../lcd/extui/lib/mks_ui/tft_Language_en.h | 2 + .../lcd/extui/lib/mks_ui/tft_Language_fr.h | 50 ++++---- .../lcd/extui/lib/mks_ui/tft_Language_it.h | 2 + .../lcd/extui/lib/mks_ui/tft_Language_ru.h | 2 + .../lcd/extui/lib/mks_ui/tft_Language_s_cn.h | 2 + .../lcd/extui/lib/mks_ui/tft_Language_sp.h | 2 + .../lcd/extui/lib/mks_ui/tft_Language_t_cn.h | 2 + .../extui/lib/mks_ui/tft_multi_language.cpp | 16 +++ .../lcd/extui/lib/mks_ui/tft_multi_language.h | 2 + Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h | 8 +- buildroot/tests/mega2560-tests | 5 +- docs/Serial.md | 16 +-- 28 files changed, 299 insertions(+), 79 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 2b565bbe13..5e22ac0836 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -82,14 +82,14 @@ typedef int8_t pin_t; // Serial ports #ifdef USBCON - #include "../../core/serial_hook.h" + #include "../../core/serial_hook.h" typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial; extern DefaultSerial MSerial; #ifdef BLUETOOTH typedef ForwardSerial0Type< decltype(bluetoothSerial) > BTSerial; extern BTSerial btSerial; #endif - + #define MYSERIAL0 TERN(BLUETOOTH, btSerial, MSerial) #else #if !WITHIN(SERIAL_PORT, -1, 3) diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index 904395de1d..265acfae92 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -611,7 +611,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser); template class MarlinSerial< LCDSerialCfg >; MSerialT4 lcdSerial(MSerialT4::HasEmergencyParser); - + #if HAS_DGUS_LCD template typename MarlinSerial::ring_buffer_pos_t MarlinSerial::get_tx_buffer_free() { diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 93a3fb84d1..2834dbed35 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -238,11 +238,11 @@ static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED); }; - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT; + typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT; extern MSerialT customizedSerial1; #ifdef SERIAL_PORT_2 - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT2; + typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT2; extern MSerialT2 customizedSerial2; #endif @@ -262,7 +262,7 @@ static constexpr bool RX_OVERRUNS = false; }; - typedef Serial0Type< MarlinSerial< MMU2SerialCfg > > MSerialT3; + typedef Serial0Type< MarlinSerial< MMU2SerialCfg > > MSerialT3; extern MSerial3 mmuSerial; #endif @@ -292,7 +292,7 @@ }; - typedef Serial0Type< MarlinSerial< LCDSerialCfg > > MSerialT4; + typedef Serial0Type< MarlinSerial< LCDSerialCfg > > MSerialT4; extern MSerialT4 lcdSerial; #endif diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 29df0a5c6d..5eb827b970 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -39,7 +39,7 @@ #ifdef USBCON #include - #include "../../core/serial_hook.h" + #include "../../core/serial_hook.h" typedef ForwardSerial0Type< decltype(SerialUSB) > DefaultSerial; extern DefaultSerial MSerial; #endif diff --git a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp index e00fb9b16f..fc9b960c1c 100644 --- a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp +++ b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp @@ -163,7 +163,6 @@ GPIO_InitStruct.Pin = GPIO_PIN_2; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - #if DISABLED(STM32F1xx) // TODO: use __HAL_RCC_SDIO_RELEASE_RESET() and __HAL_RCC_SDIO_CLK_ENABLE(); RCC->APB2RSTR &= ~RCC_APB2RSTR_SDIORST_Msk; // take SDIO out of reset diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.h b/Marlin/src/HAL/STM32F1/MarlinSerial.h index 692e97e618..4c0bf0e100 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.h +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.h @@ -28,6 +28,10 @@ #include "../../inc/MarlinConfigPre.h" #include "../../core/serial_hook.h" +#if HAS_TFT_LVGL_UI + extern "C" { extern char public_buf_m[100]; } +#endif + // Increase priority of serial interrupts, to reduce overflow errors #define UART_IRQ_PRIO 1 @@ -45,6 +49,28 @@ struct MarlinSerial : public HardwareSerial { nvic_irq_set_priority(c_dev()->irq_num, UART_IRQ_PRIO); } #endif + + #if HAS_TFT_LVGL_UI + // Hook the serial write method to capture the output of GCode command sent via LCD + uint32_t current_wpos; + void (*line_callback)(void *, const char * msg); + void *user_pointer; + + void set_hook(void (*hook)(void *, const char *), void * that) { line_callback = hook; user_pointer = that; current_wpos = 0; } + + size_t write(uint8_t c) { + if (line_callback) { + if (c == '\n' || current_wpos == sizeof(public_buf_m) - 1) { // End of line, probably end of command anyway + public_buf_m[current_wpos] = 0; + line_callback(user_pointer, public_buf_m); + current_wpos = 0; + } + else + public_buf_m[current_wpos++] = c; + } + return HardwareSerial::write(c); + } + #endif }; typedef Serial0Type MSerialT; diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index dcc688ae29..905b85d56d 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -320,8 +320,8 @@ template struct enable_if { }; template struct enable_if { typedef _Tp type; }; } - // C++11 solution using SFINAE to detect the existance of a member in a class at compile time. - // It creates a HasMember structure containing 'value' set to true if the member exists + // C++11 solution using SFINAE to detect the existance of a member in a class at compile time. + // It creates a HasMember structure containing 'value' set to true if the member exists #define HAS_MEMBER_IMPL(Member) \ namespace Private { \ template struct HasMember_ ## Member { \ diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index e14b821a9c..45e64d7793 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -131,10 +131,11 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial >, public Seria using BaseClassT::print; using BaseClassT::println; + // Underlying implementation might use Arduino's bool operator - bool connected() { - return Private::HasMember_connected::value ? CALL_IF_EXISTS(bool, static_cast(this), connected) : static_cast(this)->operator bool(); - } + bool connected() { + return Private::HasMember_connected::value ? CALL_IF_EXISTS(bool, static_cast(this), connected) : static_cast(this)->operator bool(); + } void setHook(WriteHook writeHook = 0, EndOfMessageHook eofHook = 0, void * userPointer = 0) { // Order is important here as serial code can be called inside interrupts diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.cpp new file mode 100644 index 0000000000..bd7028720a --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.cpp @@ -0,0 +1,109 @@ +/** + * 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 + +#include "../../../../inc/MarlinConfig.h" + +extern lv_group_t *g; +static lv_obj_t *scr,*outL,*outV = 0; +static int currentWritePos = 0; +extern uint8_t public_buf[513]; +extern "C" { extern char public_buf_m[100]; } + +enum { + ID_GCODE_RETURN = 1, + ID_GCODE_COMMAND, +}; + +static void event_handler(lv_obj_t *obj, lv_event_t event) { + if (event != LV_EVENT_RELEASED) return; + lv_clear_gcode(); + switch (obj->mks_obj_id) { + case ID_GCODE_RETURN: + lv_draw_more(); + return; + case ID_GCODE_COMMAND: + keyboard_value = GCodeCommand; + lv_draw_keyboard(); + break; + } +} + +void lv_show_gcode_output(void * that, const char * txt) { + // Ignore echo of command + if (!memcmp(txt, "echo:", 5)) { + public_buf[0] = 0; // Clear output buffer + return; + } + + // Avoid overflow if the answer is too large + size_t len = strlen((const char*)public_buf), tlen = strlen(txt); + if (len + tlen + 1 < sizeof(public_buf)) { + memcpy(public_buf + len, txt, tlen); + public_buf[len + tlen] = '\n'; + } +} + +void lv_serial_capt_hook(void * userPointer, uint8_t c) +{ + if (c == '\n' || currentWritePos == sizeof(public_buf_m) - 1) { // End of line, probably end of command anyway + public_buf_m[currentWritePos] = 0; + lv_show_gcode_output(userPointer, public_buf_m); + currentWritePos = 0; + } + else public_buf_m[currentWritePos++] = c; +} +void lv_eom_hook(void *) +{ + // Message is done, let's remove the hook now + MYSERIAL0.setHook(); + // We are back from the keyboard, so let's redraw ourselves + draw_return_ui(); +} + +void lv_draw_gcode(bool clear) { + if (clear) { + currentWritePos = 0; + public_buf[0] = 0; + } + scr = lv_screen_create(GCODE_UI, more_menu.gcode); + lv_screen_menu_item(scr, more_menu.entergcode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_GCODE_COMMAND, 1); + outL = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2, "Result:"); + outV = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, (const char*)public_buf); + + lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_GCODE_RETURN, true); +} + +void lv_clear_gcode() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); + outV = 0; +} + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h new file mode 100644 index 0000000000..30a378a15a --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.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_gcode(bool clear = false); +extern void lv_clear_gcode(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp index ee219d5d0d..2cf6f05a99 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp @@ -27,6 +27,7 @@ #include #include "../../../../inc/MarlinConfig.h" +#include "../../../../gcode/queue.h" extern lv_group_t *g; static lv_obj_t *scr; @@ -153,13 +154,22 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { lv_draw_wifi_tips(); break; #endif // MKS_WIFI_MODULE - case gcodeCommand: + case autoLevelGcodeCommand: 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; + case GCodeCommand: + if (queue.length <= (BUFSIZE - 3)) { + // Hook anything that goes to the serial port + MYSERIAL0.setHook(lv_serial_capt_hook, lv_eom_hook, 0); + queue.enqueue_one_now(ret_ta_txt); + } + lv_clear_keyboard(); + // draw_return_ui is called in the end of message hook + break; default: break; } } @@ -238,12 +248,18 @@ void lv_draw_keyboard() { // Create a text area. The keyboard will write here lv_obj_t *ta = lv_ta_create(scr, nullptr); lv_obj_align(ta, nullptr, LV_ALIGN_IN_TOP_MID, 0, 10); - if (keyboard_value == gcodeCommand) { + switch (keyboard_value) { + case autoLevelGcodeCommand: 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 { + break; + case GCodeCommand: + // Start with uppercase by default + lv_btnm_set_map(kb, kb_map_uc); + lv_btnm_set_ctrl_map(kb, kb_ctrl_uc_map); + // Fallthrough + default: lv_ta_set_text(ta, ""); } 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 index 58c6337204..b5c1890309 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp @@ -49,7 +49,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { lv_draw_manual_level_pos_settings(); break; case ID_LEVEL_COMMAND: - keyboard_value = gcodeCommand; + keyboard_value = autoLevelGcodeCommand; lv_draw_keyboard(); break; #if HAS_BED_PROBE diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp index 76bb34988a..c085c4c936 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp @@ -41,20 +41,19 @@ enum { ID_CUSTOM_4, ID_CUSTOM_5, ID_CUSTOM_6, - ID_CUSTOM_7, ID_M_RETURN, }; static void event_handler(lv_obj_t * obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; switch (obj->mks_obj_id) { + case ID_GCODE: lv_clear_more(); lv_draw_gcode(true); break; case ID_CUSTOM_1: TERN_(USER_CMD_1_ENABLE, queue.inject_P(PSTR(USER_GCODE_1))); break; case ID_CUSTOM_2: TERN_(USER_CMD_2_ENABLE, queue.inject_P(PSTR(USER_GCODE_2))); break; case ID_CUSTOM_3: TERN_(USER_CMD_3_ENABLE, queue.inject_P(PSTR(USER_GCODE_3))); break; case ID_CUSTOM_4: TERN_(USER_CMD_4_ENABLE, queue.inject_P(PSTR(USER_GCODE_4))); break; case ID_CUSTOM_5: TERN_(USER_CMD_5_ENABLE, queue.inject_P(PSTR(USER_GCODE_5))); break; case ID_CUSTOM_6: TERN_(USER_CMD_6_ENABLE, queue.inject_P(PSTR(USER_GCODE_6))); break; - case ID_CUSTOM_7: TERN_(USER_CMD_7_ENABLE, queue.inject_P(PSTR(USER_GCODE_7))); break; case ID_M_RETURN: lv_clear_more(); lv_draw_tool(); @@ -67,53 +66,54 @@ void lv_draw_more() { const bool enc_ena = TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable); + lv_obj_t *buttonGCode = lv_imgbtn_create(scr, "F:/bmp_machine_para.bin", INTERVAL_V, titleHeight, event_handler, ID_GCODE); + if (enc_ena) lv_group_add_obj(g, buttonGCode); + lv_obj_t *labelGCode = lv_label_create_empty(buttonGCode); + #if ENABLED(USER_CMD_1_ENABLE) - lv_obj_t *buttonCustom1 = lv_imgbtn_create(scr, "F:/bmp_custom1.bin", INTERVAL_V, titleHeight, event_handler, ID_CUSTOM_1); + lv_obj_t *buttonCustom1 = lv_imgbtn_create(scr, "F:/bmp_custom1.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_CUSTOM_1); if (enc_ena) lv_group_add_obj(g, buttonCustom1); lv_obj_t *labelCustom1 = lv_label_create_empty(buttonCustom1); #endif #if ENABLED(USER_CMD_2_ENABLE) - lv_obj_t *buttonCustom2 = lv_imgbtn_create(scr, "F:/bmp_custom2.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_CUSTOM_2); + lv_obj_t *buttonCustom2 = lv_imgbtn_create(scr, "F:/bmp_custom2.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_CUSTOM_2); if (enc_ena) lv_group_add_obj(g, buttonCustom2); lv_obj_t *labelCustom2 = lv_label_create_empty(buttonCustom2); #endif #if ENABLED(USER_CMD_3_ENABLE) - lv_obj_t *buttonCustom3 = lv_imgbtn_create(scr, "F:/bmp_custom3.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_CUSTOM_3); + lv_obj_t *buttonCustom3 = lv_imgbtn_create(scr, "F:/bmp_custom3.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_CUSTOM_3); if (enc_ena) lv_group_add_obj(g, buttonCustom3); lv_obj_t *labelCustom3 = lv_label_create_empty(buttonCustom3); #endif #if ENABLED(USER_CMD_4_ENABLE) - lv_obj_t *buttonCustom4 = lv_imgbtn_create(scr, "F:/bmp_custom4.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_CUSTOM_4); + lv_obj_t *buttonCustom4 = lv_imgbtn_create(scr, "F:/bmp_custom4.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_4); if (enc_ena) lv_group_add_obj(g, buttonCustom4); lv_obj_t *labelCustom4 = lv_label_create_empty(buttonCustom4); #endif #if ENABLED(USER_CMD_5_ENABLE) - lv_obj_t *buttonCustom5 = lv_imgbtn_create(scr, "F:/bmp_custom5.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_5); + lv_obj_t *buttonCustom5 = lv_imgbtn_create(scr, "F:/bmp_custom5.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_5); if (enc_ena) lv_group_add_obj(g, buttonCustom5); lv_obj_t *labelCustom5 = lv_label_create_empty(buttonCustom5); #endif #if ENABLED(USER_CMD_6_ENABLE) - lv_obj_t *buttonCustom6 = lv_imgbtn_create(scr, "F:/bmp_custom6.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_6); + lv_obj_t *buttonCustom6 = lv_imgbtn_create(scr, "F:/bmp_custom6.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_6); if (enc_ena) lv_group_add_obj(g, buttonCustom6); lv_obj_t *labelCustom6 = lv_label_create_empty(buttonCustom6); #endif - #if ENABLED(USER_CMD_7_ENABLE) - blv_obj_t *uttonCustom7 = lv_imgbtn_create(scr, "F:/bmp_custom7.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_7); - if (enc_ena) lv_group_add_obj(g, buttonCustom7); - lv_obj_t *labelCustom7 = lv_label_create_empty(buttonCustom7); - #endif - lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN); if (enc_ena) lv_group_add_obj(g, buttonBack); lv_obj_t *label_Back = lv_label_create_empty(buttonBack); if (gCfgItems.multiple_language != 0) { + lv_label_set_text(labelGCode, more_menu.gcode); + lv_obj_align(labelGCode, buttonGCode, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + #if ENABLED(USER_CMD_1_ENABLE) lv_label_set_text(labelCustom1, more_menu.custom1); lv_obj_align(labelCustom1, buttonCustom1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); @@ -138,23 +138,19 @@ void lv_draw_more() { lv_label_set_text(labelCustom6, more_menu.custom6); lv_obj_align(labelCustom6, buttonCustom6, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); #endif - #if ENABLED(USER_CMD_7_ENABLE) - lv_label_set_text(labelCustom7, more_menu.custom7); - lv_obj_align(labelCustom7, buttonCustom7, 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 BUTTONS_EXIST(EN1, EN2, ENC) if (enc_ena) { + lv_group_add_obj(g, buttonGCode); TERN_(USER_CMD_1_ENABLE, lv_group_add_obj(g, buttonCustom1)); TERN_(USER_CMD_2_ENABLE, lv_group_add_obj(g, buttonCustom2)); TERN_(USER_CMD_3_ENABLE, lv_group_add_obj(g, buttonCustom3)); TERN_(USER_CMD_4_ENABLE, lv_group_add_obj(g, buttonCustom4)); TERN_(USER_CMD_5_ENABLE, lv_group_add_obj(g, buttonCustom5)); TERN_(USER_CMD_6_ENABLE, lv_group_add_obj(g, buttonCustom6)); - TERN_(USER_CMD_7_ENABLE, lv_group_add_obj(g, buttonCustom7)); lv_group_add_obj(g, buttonBack); } #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 682d40858c..a2ecb0e436 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -71,7 +71,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target; lv_draw_filament_change(); break; - case ID_T_MORE: break; + case ID_T_MORE: lv_draw_more(); break; case ID_T_RETURN: TERN_(MKS_TEST, curent_disp_ui = 1); lv_draw_ready_print(); @@ -87,6 +87,7 @@ void lv_draw_tool() { lv_big_button_create(scr, "F:/bmp_zero.bin", tool_menu.home, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_T_HOME); lv_big_button_create(scr, "F:/bmp_leveling.bin", tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling), INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_LEVELING); lv_big_button_create(scr, "F:/bmp_filamentchange.bin", tool_menu.filament, BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight, event_handler,ID_T_FILAMENT); + lv_big_button_create(scr, "F:/bmp_more.bin", tool_menu.more, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_MORE); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_RETURN); } 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 84049d51ab..9d13ca3120 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -1077,6 +1077,7 @@ void draw_return_ui() { case NOZZLE_PROBE_OFFSET_UI: lv_draw_auto_level_offset_settings(); break; #endif case TOOL_UI: lv_draw_tool(); break; + case GCODE_UI: lv_draw_gcode(); break; case MESHLEVELING_UI: break; case HARDWARE_TEST_UI: break; #if ENABLED(MKS_WIFI_MODULE) 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 f02a58ad43..34c6b1f254 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -46,6 +46,7 @@ #include "draw_preHeat.h" #include "draw_extrusion.h" #include "draw_home.h" +#include "draw_gcode.h" #include "draw_more.h" #include "draw_move_motor.h" #include "draw_fan.h" @@ -326,7 +327,8 @@ typedef enum { WIFI_SETTINGS_UI, HOMING_SENSITIVITY_UI, ENCODER_SETTINGS_UI, - TOUCH_CALIBRATION_UI + TOUCH_CALIBRATION_UI, + GCODE_UI, } DISP_STATE; typedef struct { @@ -413,7 +415,8 @@ typedef enum { wifiName, wifiPassWord, wifiConfig, - gcodeCommand + autoLevelGcodeCommand, + GCodeCommand, } keyboard_value_state; extern keyboard_value_state keyboard_value; @@ -449,6 +452,8 @@ 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); +extern void lv_serial_capt_hook(void *, uint8_t); +extern void lv_eom_hook(void *); #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/tft_Language_en.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h index 2261eeeba9..5fa1c82027 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 @@ -279,6 +279,8 @@ #define AUTO_LEVELING_TEXT_EN "AutoLevel" #define SET_TEXT_EN "Settings" #define MORE_TEXT_EN "More" +#define MORE_GCODE_EN "G-Code" +#define MORE_ENTER_GCODE_EN "Enter G-Code" #define ADD_TEXT_EN "Add" #define DEC_TEXT_EN "Dec" 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 e3226b3cbe..55416f0254 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 @@ -22,7 +22,7 @@ #pragma once //*************法文****************************// -#define TOOL_TEXT_FR "prêt" +#define TOOL_TEXT_FR "Prêt" #define PREHEAT_TEXT_FR "Préchauffe" #define MOVE_TEXT_FR "Déplace" #define HOME_TEXT_FR "Acceuil" @@ -32,6 +32,8 @@ #define AUTO_LEVELING_TEXT_FR "AutoLevel" #define SET_TEXT_FR "Config" #define MORE_TEXT_FR "Plus" +#define MORE_GCODE_FR "G-Code" +#define MORE_ENTER_GCODE_FR "Saisir G-Code" #define ADD_TEXT_FR "Ajouter" #define DEC_TEXT_FR "Réduire" @@ -74,7 +76,7 @@ #define PAGE_DOWN_TEXT_FR "En bas" #define EXTRUDER_IN_TEXT_FR "Insérer" -#define EXTRUDER_OUT_TEXT_FR "éjecter" +#define EXTRUDER_OUT_TEXT_FR "Éjecter" #define EXTRUDE_1MM_TEXT_FR "1mm" #define EXTRUDE_5MM_TEXT_FR "5mm" #define EXTRUDE_10MM_TEXT_FR "10mm" @@ -91,13 +93,13 @@ #define FILESYS_TEXT_FR "Fichier" #define WIFI_TEXT_FR "WiFi" #define FAN_TEXT_FR "Fan" -#define ABOUT_TEXT_FR "A propos" +#define ABOUT_TEXT_FR "À propos" #define BREAK_POINT_TEXT_FR "Continuer" #define FILAMENT_TEXT_FR "Remplacer" #define LANGUAGE_TEXT_FR "Langue" #define MOTOR_OFF_TEXT_FR "M-hors" #define MOTOR_OFF_XY_TEXT_FR "M-hors-XY" -#define SHUTDOWN_TEXT_FR "Eteindre" +#define SHUTDOWN_TEXT_FR "Éteindre" #define MACHINE_PARA_FR "Config" #define EEPROM_SETTINGS_FR "Eeprom Set" @@ -130,27 +132,27 @@ #define FAN_TIPS2_TEXT_FR "ventilateur\n0" #define FILAMENT_IN_TEXT_FR "Insérer" -#define FILAMENT_OUT_TEXT_FR "éjecter" +#define FILAMENT_OUT_TEXT_FR "Éjecter" #define FILAMENT_EXT0_TEXT_FR "Extr1" #define FILAMENT_EXT1_TEXT_FR "Extr2" #define FILAMENT_HEAT_TEXT_FR "Preheat" #define FILAMENT_STOP_TEXT_FR "Arrêter" #define FILAMENT_TIPS2_TEXT_FR "T:" #define FILAMENT_TIPS3_TEXT_FR "Insérer le filament..." -#define FILAMENT_TIPS4_TEXT_FR "éjecter le filament..." +#define FILAMENT_TIPS4_TEXT_FR "Éjecter le filament..." #define FILAMENT_TIPS5_TEXT_FR "Température trop basse pour démarrer, chauffez svp" #define FILAMENT_TIPS6_TEXT_FR "Terminé" -#define FILAMENT_CHANGE_TEXT_FR "Please click \nor ,After \npinter pause." -#define FILAMENT_DIALOG_LOAD_HEAT_TIPS_FR "Heating up the nozzle,\nplease wait..." -#define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_FR "Heating up the nozzle,\nplease wait..." -#define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_FR "Heat completed,please load filament \nto extruder,and click \nfor start loading." -#define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_FR "Please load filament to extruder,\nand click for start loading." -#define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_FR "Heat completed,please \nclick for start unloading.!" -#define FILAMENT_DIALOG_LOADING_TIPS_FR "Is loading ,please wait!" -#define FILAMENT_DIALOG_UNLOADING_TIPS_FR "Is unloading,please wait!" -#define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_FR "Load filament completed,\nclick for return!" -#define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_FR "Unload filament completed,\nclick for return!" +#define FILAMENT_CHANGE_TEXT_FR "Veuillez presser \nou , après \nla pause." +#define FILAMENT_DIALOG_LOAD_HEAT_TIPS_FR "Chauffe de la tête\nPatientez SVP..." +#define FILAMENT_DIALOG_UNLOAD_HEAT_TIPS_FR "Chauffe de la tête\nPatientez SVP..." +#define FILAMENT_DIALOG_LOAD_CONFIRM1_TIPS_FR "Tête chaude, veuillez charger le\nfilament dans l'extruder & \nle chargement." +#define FILAMENT_DIALOG_LOAD_CONFIRM2_TIPS_FR "Veuillez charger le filament dans\nl'extruder & le chargement." +#define FILAMENT_DIALOG_UNLOAD_CONFIRM_TIPS_FR "Tête chaude, \npour le déchargement." +#define FILAMENT_DIALOG_LOADING_TIPS_FR "Chargement, patientez SVP." +#define FILAMENT_DIALOG_UNLOADING_TIPS_FR "Déchargement, patientez SVP." +#define FILAMENT_DIALOG_LOAD_COMPLETE_TIPS_FR "Chargement terminé,\n pour revenir!" +#define FILAMENT_DIALOG_UNLOAD_COMPLETE_TIPS_FR "Déchargement terminé,\n pour revenir!" #define PRE_HEAT_EXT_TEXT_FR "E" @@ -205,12 +207,12 @@ #define TITLE_FAN_FR "Ventilateur" #define TITLE_LANGUAGE_FR "Langue" #define TITLE_PAUSE_FR "Pause" -#define TITLE_CHANGESPEED_FR "Speed" +#define TITLE_CHANGESPEED_FR "Vitesse" #define TITLE_CLOUD_TEXT_FR "Cloud" -#define TITLE_DIALOG_CONFIRM_FR "Confirm" +#define TITLE_DIALOG_CONFIRM_FR "Confirmer" #define TITLE_FILESYS_FR "FileSys" -#define DIALOG_CLOSE_MACHINE_FR "Closing machine......" +#define DIALOG_CLOSE_MACHINE_FR "Extinction..." #define AUTO_SHUTDOWN_FR "Auto" #define MANUAL_SHUTDOWN_FR "Manuel" @@ -220,7 +222,7 @@ #define DIALOG_OK_FR "OK" #define DIALOG_RESET_FR "Réinitialiser" #define DIALOG_RETRY_FR "Recommencez" -#define DIALOG_DISABLE_FR "Disable" +#define DIALOG_DISABLE_FR "Désactiver" #define DIALOG_PRINT_MODEL_FR "Imprimer le fichier?" #define DIALOG_CANCEL_PRINT_FR "Arrêter?" @@ -229,12 +231,12 @@ #define DIALOG_ERROR_TIPS1_FR "Erreur:error:Aucun fichier, \nvérifiez à nouveau." #define DIALOG_ERROR_TIPS2_FR "Erreur:La opération a échoué. \nVerifiez que le baudrate de l'écran et de \nla carte mère soient identique!" #define DIALOG_ERROR_TIPS3_FR "Erreur: le nom du fichier ou le \nchemin d'accès est trop long." -#define DIALOG_UNBIND_PRINTER_FR "Unbind the printer?" -#define DIALOG_FILAMENT_NO_PRESS_FR "Filament detection switch is not pressed" +#define DIALOG_UNBIND_PRINTER_FR "Déconnecter l'imprimante?" +#define DIALOG_FILAMENT_NO_PRESS_FR "Détecteur de filament non pressé" #define DIALOG_PRINT_FINISH_FR "L'impression est terminée!" #define DIALOG_PRINT_TIME_FR "Temps d'impression: " -#define DIALOG_REPRINT_FR "Print again" -#define DIALOG_WIFI_ENABLE_TIPS_FR "The wifi module is being configured,\nplease wait a moment....." +#define DIALOG_REPRINT_FR "Réimprimer" +#define DIALOG_WIFI_ENABLE_TIPS_FR "Le module WIFI se charge\nAttendez SVP..." #define MESSAGE_PAUSING_FR "Parking..." #define MESSAGE_CHANGING_FR "Attente filament pour démarrer" 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 2a1ba83cd0..d46cccfeb8 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 @@ -32,6 +32,8 @@ #define AUTO_LEVELING_TEXT_IT "AutoLevel" #define SET_TEXT_IT "Imposta" #define MORE_TEXT_IT "Di più" +#define MORE_GCODE_IT "G-Code" +#define MORE_ENTER_GCODE_IT "Inserisci il G-Code" #define ADD_TEXT_IT "Aumentare" #define DEC_TEXT_IT "Ridurre" 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 94103354b9..f5955c38d1 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 @@ -32,6 +32,8 @@ #define AUTO_LEVELING_TEXT_RU "aвтоуровень" #define SET_TEXT_RU "настройки" #define MORE_TEXT_RU "больше" +#define MORE_GCODE_RU "G-код" +#define MORE_ENTER_GCODE_RU "Введите G-код" #define ADD_TEXT_RU "добавить" #define DEC_TEXT_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 046968ba87..7ae87b5d3f 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 @@ -263,6 +263,8 @@ #define AUTO_LEVELING_TEXT_CN "自动调平" #define SET_TEXT_CN "设置" #define MORE_TEXT_CN "更多" +#define MORE_GCODE_CN "G-Code" +#define MORE_ENTER_GCODE_CN "Enter G-Code" #define ADD_TEXT_CN "增加" #define DEC_TEXT_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 0b714930eb..28afe186f1 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 @@ -33,6 +33,8 @@ #define AUTO_LEVELING_TEXT_SP "Autolevel" #define SET_TEXT_SP "Config" #define MORE_TEXT_SP "Más" +#define MORE_GCODE_SP "G-Code" +#define MORE_ENTER_GCODE_SP "Introduzca el G-Code" #define ADD_TEXT_SP "Más" #define DEC_TEXT_SP "Menos" 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 30d0430313..8d38bc3c9a 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 @@ -263,6 +263,8 @@ #define AUTO_LEVELING_TEXT_T_CN "自動調平" #define SET_TEXT_T_CN "設置" #define MORE_TEXT_T_CN "更多" +#define MORE_GCODE_T_CN "G-Code" +#define MORE_ENTER_GCODE_T_CN "Enter G-Code" #define ADD_TEXT_T_CN "增加" #define DEC_TEXT_T_CN "減少" 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 28c90486d0..1fd17c20f7 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 @@ -943,6 +943,8 @@ void disp_language_init() { filesys_menu.usb_sys = U_DISK_TEXT_CN; // more_menu.title = TITLE_MORE_CN; + more_menu.gcode = MORE_GCODE_CN; + more_menu.entergcode = MORE_ENTER_GCODE_CN; TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_CN); TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_CN); TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_CN); @@ -1175,6 +1177,8 @@ void disp_language_init() { filesys_menu.usb_sys = U_DISK_TEXT_T_CN; // more_menu.title = TITLE_MORE_T_CN; + more_menu.gcode = MORE_GCODE_T_CN; + more_menu.entergcode = MORE_ENTER_GCODE_T_CN; TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_T_CN); TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_T_CN); TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_T_CN); @@ -1394,6 +1398,8 @@ void disp_language_init() { set_menu.eepromSet = EEPROM_SETTINGS_EN; // more_menu.title = TITLE_MORE_EN; + more_menu.gcode = MORE_GCODE_EN; + more_menu.entergcode = MORE_ENTER_GCODE_EN; TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_EN); TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_EN); TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_EN); @@ -1614,6 +1620,8 @@ 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.gcode = MORE_GCODE_RU; + more_menu.entergcode = MORE_ENTER_GCODE_RU; #if ENABLED(USER_CMD_1_ENABLE) more_menu.custom1 = MORE_CUSTOM1_TEXT_RU; #endif @@ -1944,6 +1952,8 @@ 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.gcode = MORE_GCODE_SP; + more_menu.entergcode = MORE_ENTER_GCODE_SP; #if ENABLED(USER_CMD_1_ENABLE) more_menu.custom1 = MORE_CUSTOM1_TEXT_SP; #endif @@ -2179,6 +2189,8 @@ 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.gcode = MORE_GCODE_FR; + more_menu.entergcode = MORE_ENTER_GCODE_FR; #if ENABLED(USER_CMD_1_ENABLE) more_menu.custom1 = MORE_CUSTOM1_TEXT_FR; #endif @@ -2415,6 +2427,8 @@ 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.gcode = MORE_GCODE_IT; + more_menu.entergcode = MORE_ENTER_GCODE_IT; #if ENABLED(USER_CMD_1_ENABLE) more_menu.custom1 = MORE_CUSTOM1_TEXT_IT; #endif @@ -2651,6 +2665,8 @@ void disp_language_init() { set_menu.eepromSet = EEPROM_SETTINGS_EN; // more_menu.title = TITLE_MORE_EN; + more_menu.gcode = MORE_GCODE_EN; + more_menu.entergcode = MORE_ENTER_GCODE_EN; TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_EN); TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_EN); TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_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 a3b55d469b..731b2eaecd 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 @@ -464,6 +464,8 @@ typedef struct more_menu_disp { const char *custom5; const char *custom6; const char *custom7; + const char *gcode; + const char *entergcode; const char *back; } more_menu_def; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h index c2885ccc90..fcc35a6a65 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h @@ -80,10 +80,10 @@ class WifiSerial { } /* 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 + 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 } } diff --git a/buildroot/tests/mega2560-tests b/buildroot/tests/mega2560-tests index e603ea2496..aef2b8756a 100755 --- a/buildroot/tests/mega2560-tests +++ b/buildroot/tests/mega2560-tests @@ -72,8 +72,9 @@ opt_set TEMP_SENSOR_1 1 opt_set TEMP_SENSOR_2 1 opt_set TEMP_SENSOR_3 1 opt_set TEMP_SENSOR_4 1 -opt_enable VIKI2 Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE BOOT_MARLIN_LOGO_ANIMATED \ - AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \ +opt_enable VIKI2 BOOT_MARLIN_LOGO_ANIMATED SDSUPPORT AUTO_REPORT_SD_STATUS \ + Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE \ + EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL \ NO_VOLUMETRICS EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES AUTOTEMP G38_PROBE_TARGET JOYSTICK \ DIRECT_STEPPING DETECT_BROKEN_ENDSTOP \ FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE Z_SAFE_HOMING FIL_RUNOUT3_PULLUP diff --git a/docs/Serial.md b/docs/Serial.md index 317f5f8c93..69fa94fc15 100644 --- a/docs/Serial.md +++ b/docs/Serial.md @@ -10,13 +10,13 @@ Starting with version `2.0.9`, Marlin provides a common interface for its serial ## Common interface -This interface is declared in `Marlin/src/core/serial_base.h` +This interface is declared in `Marlin/src/core/serial_base.h` Any implementation will need to follow this interface for being used transparently in Marlin's codebase. The implementation was written to prioritize performance over abstraction, so the base interface is not using virtual inheritance to avoid the cost of virtual dispatching while calling methods. Instead, the Curiously Recurring Template Pattern (**CRTP**) is used so that, upon compilation, the interface abstraction does not incur a performance cost. -Because some platform do not follow the same interface, the missing method in the actual low-level implementation are detected via SFINAE and a wrapper is generated when such method are missing. See `CALL_IF_EXISTS` macro in `Marlin/src/core/macros.h` for the documentation of this technic. +Because some platform do not follow the same interface, the missing method in the actual low-level implementation are detected via SFINAE and a wrapper is generated when such method are missing. See `CALL_IF_EXISTS` macro in `Marlin/src/core/macros.h` for the documentation of this technic. ## Composing the desired feature The different specificities for each architecture are provided by composing the serial type based on desired functionality. @@ -25,11 +25,11 @@ In the `Marlin/src/core/serial_hook.h` file, the different serial feature are de 2. `ForwardSerial` is a composing wrapper. It references an actual Arduino compatible `Serial` instance. You'll use this if the instance is declared in the platform's framework and is being referred directly in the framework. This is not as efficient as the `BaseSerial` implementation since static dereferencing is done for each method call (it'll still be faster than virtual dispatching) 3. `ConditionalSerial` is working a bit like the `ForwardSerial` interface, but it checks a boolean condition before calling the referenced instance. You'll use it when the serial output can be switch off at runtime, for example in a *telnet* like serial output that should not emit any packet if no client is connected. 4. `RuntimeSerial` is providing a runtime-modifiable hooking method for its `write` and `msgDone` method. You'll use it if you need to capture the serial output of Marlin, for example to display the G-Code parser's output on a GUI interface. The hooking interface is setup via the `setHook` method. -5. `MultiSerial` is a runtime modifiable serial output multiplexer. It can output (*respectively input*) to 2 different interface based on a port *mask*. You'll use this if you need to output the same serial stream to multiple port. You can plug a `MultiSerial` to itself to duplicate to more than 2 ports. +5. `MultiSerial` is a runtime modifiable serial output multiplexer. It can output (*respectively input*) to 2 different interface based on a port *mask*. You'll use this if you need to output the same serial stream to multiple port. You can plug a `MultiSerial` to itself to duplicate to more than 2 ports. ## Plumbing -Since all the types above are using CRTP, it's possible to combine them to get the appropriate functionality. -This is easily done via type definition of the feature. +Since all the types above are using CRTP, it's possible to combine them to get the appropriate functionality. +This is easily done via type definition of the feature. For example, to present a serial interface that's outputting to 2 serial port, the first one being hooked at runtime and the second one connected to a runtime switchable telnet client, you'll declare the type to use as: ``` @@ -37,8 +37,8 @@ typedef MultiSerial< RuntimeSerial, ConditionalSerial > Se ``` ## Emergency parser -By default, the serial base interface provide an emergency parser that's only enable for serial classes that support it. -Because of this condition, all underlying type takes a first `bool emergencyParserEnabled` argument to their constructor. You must take into account this parameter when defining the actual type used. +By default, the serial base interface provide an emergency parser that's only enable for serial classes that support it. +Because of this condition, all underlying type takes a first `bool emergencyParserEnabled` argument to their constructor. You must take into account this parameter when defining the actual type used. -*This document was written by [X-Ryl669](https://blog.cyril.by) and is under [CC-SA license](https://creativecommons.org/licenses/by-sa)* \ No newline at end of file +*This document was written by [X-Ryl669](https://blog.cyril.by) and is under [CC-SA license](https://creativecommons.org/licenses/by-sa)* From 32d859eede3a021140f14cec0a2db4163eaf4307 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 2 Feb 2021 00:17:47 +0000 Subject: [PATCH 08/51] [cron] Bump distribution date (2021-02-02) --- 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 488e570d81..a08e5348ce 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 "2021-02-01" + #define STRING_DISTRIBUTION_DATE "2021-02-02" #endif /** From 65483dcc953b359a8bad057d401b1a54af635278 Mon Sep 17 00:00:00 2001 From: ellensp Date: Wed, 3 Feb 2021 09:30:19 +1300 Subject: [PATCH 09/51] Fix host_response_handler compile (#20962) --- Marlin/src/feature/host_actions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index 5ba3a3e3d2..c194fb7a5b 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -182,7 +182,7 @@ void host_action(PGM_P const pstr, const bool eol) { break; case PROMPT_PAUSE_RESUME: msg = PSTR("LCD_PAUSE_RESUME"); - #if ENABLED(ADVANCED_PAUSE_FEATURE) + #if BOTH(ADVANCED_PAUSE_FEATURE, SDSUPPORT) extern const char M24_STR[]; queue.inject_P(M24_STR); #endif From 1f12273de12fceb59366481d0697b228e0652096 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Tue, 2 Feb 2021 17:31:01 -0300 Subject: [PATCH 10/51] Include ui_common for MARLIN_LOGO_FULL_SIZE (#20963) --- Marlin/src/lcd/tft/tft_image.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/lcd/tft/tft_image.cpp b/Marlin/src/lcd/tft/tft_image.cpp index 851410b2e0..f3480705e1 100644 --- a/Marlin/src/lcd/tft/tft_image.cpp +++ b/Marlin/src/lcd/tft/tft_image.cpp @@ -25,6 +25,7 @@ #if HAS_GRAPHICAL_TFT #include "tft_image.h" +#include "ui_common.h" const tImage NoLogo = { nullptr, 0, 0, NOCOLORS }; From 617f5dfe5e947a95d5037da9fffad655e849b805 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Tue, 2 Feb 2021 17:31:51 -0300 Subject: [PATCH 11/51] Touch Calibration Screen auto-save option (#20971) --- Marlin/Configuration.h | 4 ++++ Marlin/src/lcd/tft_io/touch_calibration.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d888e62aaf..d0c00d4ef5 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2457,6 +2457,10 @@ //#define TOUCH_OFFSET_Y 257 //#define TOUCH_ORIENTATION TOUCH_LANDSCAPE + #if BOTH(TOUCH_SCREEN_CALIBRATION, EEPROM_SETTINGS) + #define TOUCH_CALIBRATION_AUTO_SAVE // Auto save successful calibration values to EEPROM + #endif + #if ENABLED(TFT_COLOR_UI) //#define SINGLE_TOUCH_NAVIGATION #endif diff --git a/Marlin/src/lcd/tft_io/touch_calibration.cpp b/Marlin/src/lcd/tft_io/touch_calibration.cpp index 3c24d42734..0f9d25caeb 100644 --- a/Marlin/src/lcd/tft_io/touch_calibration.cpp +++ b/Marlin/src/lcd/tft_io/touch_calibration.cpp @@ -28,6 +28,10 @@ #define DEBUG_OUT ENABLED(DEBUG_TOUCH_CALIBRATION) #include "../../core/debug_out.h" +#if ENABLED(TOUCH_CALIBRATION_AUTO_SAVE) + #include "../../module/settings.h" +#endif + TouchCalibration touch_calibration; touch_calibration_t TouchCalibration::calibration; @@ -78,6 +82,7 @@ void TouchCalibration::validate_calibration() { SERIAL_ECHOLNPAIR("TOUCH_OFFSET_X ", calibration.offset_x); SERIAL_ECHOLNPAIR("TOUCH_OFFSET_Y ", calibration.offset_y); SERIAL_ECHO_TERNARY(calibration.orientation == TOUCH_LANDSCAPE, "TOUCH_ORIENTATION ", "TOUCH_LANDSCAPE", "TOUCH_PORTRAIT", "\n"); + TERN_(TOUCH_CALIBRATION_AUTO_SAVE, settings.save()); } } From 0ce3f6efe02454342517c5be23e61483c56c35b6 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Tue, 2 Feb 2021 21:33:07 +0100 Subject: [PATCH 12/51] Multi-language pertains to Color UI (#20972) --- Marlin/Configuration_adv.h | 2 +- Marlin/src/lcd/tft/tft_string.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d21c5069d6..ea75f48f7a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1529,7 +1529,7 @@ // // Specify additional languages for the UI. Default specified by LCD_LANGUAGE. // -#if EITHER(DOGLCD, TOUCH_UI_FTDI_EVE) +#if ANY(DOGLCD, TFT_COLOR_UI, TOUCH_UI_FTDI_EVE) //#define LCD_LANGUAGE_2 fr //#define LCD_LANGUAGE_3 de //#define LCD_LANGUAGE_4 es diff --git a/Marlin/src/lcd/tft/tft_string.cpp b/Marlin/src/lcd/tft/tft_string.cpp index 31ac14cf92..c2a571e826 100644 --- a/Marlin/src/lcd/tft/tft_string.cpp +++ b/Marlin/src/lcd/tft/tft_string.cpp @@ -26,6 +26,7 @@ #include "tft_string.h" #include "../fontutils.h" +#include "../marlinui.h" //#define DEBUG_TFT_FONT #define DEBUG_OUT ENABLED(DEBUG_TFT_FONT) From 28b8bf566b7a9ea116926a94466c3e1be6a5ddd8 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Tue, 2 Feb 2021 17:55:11 -0300 Subject: [PATCH 13/51] STM32 Shared Media - USB Mass Storage Device (#20956) --- Marlin/src/HAL/STM32/HAL.cpp | 18 ++++ Marlin/src/HAL/STM32/HAL.h | 2 + Marlin/src/HAL/STM32/inc/Conditionals_adv.h | 2 +- Marlin/src/HAL/STM32/msc_sd.cpp | 112 ++++++++++++++++++++ Marlin/src/HAL/STM32/msc_sd.h | 18 ++++ platformio.ini | 16 +++ 6 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 Marlin/src/HAL/STM32/msc_sd.cpp create mode 100644 Marlin/src/HAL/STM32/msc_sd.h diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index b8db5b5e0b..06744f16b8 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -42,6 +42,11 @@ #endif #endif +#if HAS_SD_HOST_DRIVE + #include "msc_sd.h" + #include "usbd_cdc_if.h" +#endif + // ------------------------ // Public Variables // ------------------------ @@ -88,6 +93,19 @@ void HAL_init() { #if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC USB_Hook_init(); #endif + + #if HAS_SD_HOST_DRIVE + MSC_SD_init(); // Enable USB SD card access + #endif +} + +// HAL idle task +void HAL_idletask() { + #if HAS_SHARED_MEDIA + // Stm32duino currently doesn't have a "loop/idle" method + CDC_resume_receive(); + CDC_continue_transmit(); + #endif } void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 5eb827b970..8f6c0a5990 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -135,6 +135,8 @@ extern uint16_t HAL_adc_result; // Enable hooks into setup for HAL void HAL_init(); +#define HAL_IDLETASK 1 +void HAL_idletask(); // Clear reset reason void HAL_clear_reset_source(); diff --git a/Marlin/src/HAL/STM32/inc/Conditionals_adv.h b/Marlin/src/HAL/STM32/inc/Conditionals_adv.h index e07c0d9cda..672d405d6b 100644 --- a/Marlin/src/HAL/STM32/inc/Conditionals_adv.h +++ b/Marlin/src/HAL/STM32/inc/Conditionals_adv.h @@ -21,6 +21,6 @@ */ #pragma once -#if defined(USBD_USE_CDC_COMPOSITE) && DISABLED(NO_SD_HOST_DRIVE) +#if defined(USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE) #define HAS_SD_HOST_DRIVE 1 #endif diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp new file mode 100644 index 0000000000..63ce7808f1 --- /dev/null +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -0,0 +1,112 @@ +/** + * Marlin 3D Printer Firmware + * + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2019 BigTreeTech [https://github.com/bigtreetech] + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "../../inc/MarlinConfigPre.h" + +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && HAS_SD_HOST_DRIVE + +#include "msc_sd.h" +#include "../shared/Marduino.h" +#include "usbd_core.h" +#include +#include + +#define BLOCK_SIZE 512 +#define PRODUCT_ID 0x29 + +#include "../../sd/cardreader.h" + +class Sd2CardUSBMscHandler : public USBMscHandler { +public: + bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize) { + *pBlockNum = card.getSd2Card().cardSize(); + *pBlockSize = BLOCK_SIZE; + return true; + } + + bool Write(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) { + auto sd2card = card.getSd2Card(); + // single block + if (blkLen == 1) { + watchdog_refresh(); + sd2card.writeBlock(blkAddr, pBuf); + return true; + } + + // multi block optmization + sd2card.writeStart(blkAddr, blkLen); + while (blkLen--) { + watchdog_refresh(); + sd2card.writeData(pBuf); + pBuf += BLOCK_SIZE; + } + sd2card.writeStop(); + return true; + } + + bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) { + auto sd2card = card.getSd2Card(); + // single block + if (blkLen == 1) { + watchdog_refresh(); + sd2card.readBlock(blkAddr, pBuf); + return true; + } + + // multi block optmization + sd2card.readStart(blkAddr); + while (blkLen--) { + watchdog_refresh(); + sd2card.readData(pBuf); + pBuf += BLOCK_SIZE; + } + sd2card.readStop(); + return true; + } + + bool IsReady() { + return card.isMounted(); + } +}; + +Sd2CardUSBMscHandler usbMscHandler; + +/* USB Mass storage Standard Inquiry Data */ +uint8_t Marlin_STORAGE_Inquirydata[] = { /* 36 */ + /* LUN 0 */ + 0x00, + 0x80, + 0x02, + 0x02, + (STANDARD_INQUIRY_DATA_LEN - 5), + 0x00, + 0x00, + 0x00, + 'M', 'A', 'R', 'L', 'I', 'N', ' ', ' ', /* Manufacturer : 8 bytes */ + 'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */ + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + '0', '.', '0', '1', /* Version : 4 Bytes */ +}; + +USBMscHandler *pSingleMscHandler = &usbMscHandler; + +void MSC_SD_init() { + USBDevice.end(); + delay(200); + USBDevice.begin(); + USBDevice.registerMscHandlers(1, &pSingleMscHandler, Marlin_STORAGE_Inquirydata); +} + +#endif // __STM32F1__ && HAS_SD_HOST_DRIVE diff --git a/Marlin/src/HAL/STM32/msc_sd.h b/Marlin/src/HAL/STM32/msc_sd.h new file mode 100644 index 0000000000..a8e5349f7c --- /dev/null +++ b/Marlin/src/HAL/STM32/msc_sd.h @@ -0,0 +1,18 @@ +/** + * Marlin 3D Printer Firmware + * + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2019 BigTreeTech [https://github.com/bigtreetech] + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +void MSC_SD_init(); diff --git a/platformio.ini b/platformio.ini index 2d81baa200..6008b943ec 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1524,6 +1524,22 @@ build_flags = ${stm32_flash_drive.build_flags} -DUSE_USB_HS_IN_FS -DUSBD_USE_CDC +# +# MKS Robin Nano V3 with USB Flash Drive Support and Shared Media +# Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged +# +[env:mks_robin_nano_v3_usb_flash_drive_msc] +extends = env:mks_robin_nano_v3 +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc.zip +build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC +build_flags = ${stm32_flash_drive.build_flags} + -DUSBCON + -DUSE_USBHOST_HS + -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -DUSE_USB_HS_IN_FS + -DUSBD_USE_CDC_MSC + # # Mingda MPX_ARM_MINI # From 6eec242a074d54cea02347520ac144ed072416fa Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Tue, 2 Feb 2021 21:57:30 +0100 Subject: [PATCH 14/51] Update a UBL comment (#20931) --- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index b0640e5fa2..513d9a9121 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -214,7 +214,7 @@ else if (isnan(f)) serialprintPGM(human ? PSTR(" . ") : PSTR("NAN")); else if (human || csv) { - if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Space for positive ('-' for negative) + if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits } if (csv && i < GRID_MAX_POINTS_X - 1) SERIAL_CHAR('\t'); From e3deb6e9a5cfcad127d46418ef008ffc57ea007e Mon Sep 17 00:00:00 2001 From: ellensp Date: Wed, 3 Feb 2021 10:00:41 +1300 Subject: [PATCH 15/51] Note (MarlinUI) limit on PREHEAT settings (#20966) Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d0c00d4ef5..b28eb72cb0 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1614,7 +1614,9 @@ // @section temperature -// Preheat Constants +// +// Preheat Constants - Up to 5 are supported without changes +// #define PREHEAT_1_LABEL "PLA" #define PREHEAT_1_TEMP_HOTEND 180 #define PREHEAT_1_TEMP_BED 70 From c6ef86029c89818dbefc271c7d6cb866cd92a48c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 2 Feb 2021 16:00:02 -0600 Subject: [PATCH 16/51] Evaluate ANY_SERIAL_IS in place --- Marlin/src/HAL/LPC1768/MarlinSerial.cpp | 8 ++--- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 8 ++--- Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp | 6 ++-- Marlin/src/inc/Conditionals_adv.h | 31 -------------------- 4 files changed, 11 insertions(+), 42 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp index 454ace33b2..c636a40a12 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp @@ -24,19 +24,19 @@ #include "../../inc/MarlinConfigPre.h" #include "MarlinSerial.h" -#if USING_SERIAL_0 +#if ANY_SERIAL_IS(0) MSerialT MSerial(true, LPC_UART0); extern "C" void UART0_IRQHandler() { MSerial.IRQHandler(); } #endif -#if USING_SERIAL_1 +#if ANY_SERIAL_IS(1) MSerialT MSerial1(true, (LPC_UART_TypeDef *) LPC_UART1); extern "C" void UART1_IRQHandler() { MSerial1.IRQHandler(); } #endif -#if USING_SERIAL_2 +#if ANY_SERIAL_IS(2) MSerialT MSerial2(true, LPC_UART2); extern "C" void UART2_IRQHandler() { MSerial2.IRQHandler(); } #endif -#if USING_SERIAL_3 +#if ANY_SERIAL_IS(3) MSerialT MSerial3(true, LPC_UART3); extern "C" void UART3_IRQHandler() { MSerial3.IRQHandler(); } #endif diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 14890bcd6e..be64ea832e 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 USING_SERIAL_0 +#if ANY_SERIAL_IS(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 USING_SERIAL_1 +#if ANY_SERIAL_IS(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 USING_SERIAL_2 +#if ANY_SERIAL_IS(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 USING_SERIAL_3 +#if ANY_SERIAL_IS(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/SAMD51/MarlinSerial_AGCM4.cpp b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp index ce32eafee5..3f43585cf2 100644 --- a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp +++ b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp @@ -27,7 +27,7 @@ #include "../../inc/MarlinConfig.h" -#if USING_SERIAL_1 +#if ANY_SERIAL_IS(1) UartT Serial2(false, &sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX); void SERCOM4_0_Handler() { Serial2.IrqHandler(); } void SERCOM4_1_Handler() { Serial2.IrqHandler(); } @@ -35,7 +35,7 @@ void SERCOM4_3_Handler() { Serial2.IrqHandler(); } #endif -#if USING_SERIAL_2 +#if ANY_SERIAL_IS(2) UartT Serial3(false, &sercom1, PIN_SERIAL3_RX, PIN_SERIAL3_TX, PAD_SERIAL3_RX, PAD_SERIAL3_TX); void SERCOM1_0_Handler() { Serial3.IrqHandler(); } void SERCOM1_1_Handler() { Serial3.IrqHandler(); } @@ -43,7 +43,7 @@ void SERCOM1_3_Handler() { Serial3.IrqHandler(); } #endif -#if USING_SERIAL_3 +#if ANY_SERIAL_IS(3) UartT Serial4(false, &sercom5, PIN_SERIAL4_RX, PIN_SERIAL4_TX, PAD_SERIAL4_RX, PAD_SERIAL4_TX); void SERCOM5_0_Handler() { Serial4.IrqHandler(); } void SERCOM5_1_Handler() { Serial4.IrqHandler(); } diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 22a671c5b3..d6245718f4 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -516,34 +516,3 @@ (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || \ (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == (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 From 9025c63c433d2668bb26bdb45c00b9a8ae59dea9 Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Tue, 2 Feb 2021 19:04:23 -0300 Subject: [PATCH 17/51] Add "more" menu in LVGL interface (#20940) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 3 +- Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp | 98 +++++++++++++------ Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp | 4 +- 3 files changed, 73 insertions(+), 32 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index ea75f48f7a..a3699128b4 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3342,7 +3342,8 @@ #endif /** - * User-defined menu items that execute custom GCode + * User-defined menu items to run custom G-code. + * Up to 25 may be defined, but the actual number is LCD-dependent. */ //#define CUSTOM_USER_MENUS #if ENABLED(CUSTOM_USER_MENUS) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp index c085c4c936..62769ae89f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp @@ -33,14 +33,28 @@ extern lv_group_t * g; static lv_obj_t * scr; +#define HAS_USER_ITEM(N) (ENABLED(CUSTOM_USER_MENUS) && defined(USER_DESC_##N) && defined(USER_GCODE_##N)) + enum { ID_GCODE = 1, - ID_CUSTOM_1, - ID_CUSTOM_2, - ID_CUSTOM_3, - ID_CUSTOM_4, - ID_CUSTOM_5, - ID_CUSTOM_6, + #if HAS_USER_ITEM(1) + ID_CUSTOM_1, + #endif + #if HAS_USER_ITEM(2) + ID_CUSTOM_2, + #endif + #if HAS_USER_ITEM(3) + ID_CUSTOM_3, + #endif + #if HAS_USER_ITEM(4) + ID_CUSTOM_4, + #endif + #if HAS_USER_ITEM(5) + ID_CUSTOM_5, + #endif + #if HAS_USER_ITEM(6) + ID_CUSTOM_6, + #endif ID_M_RETURN, }; @@ -48,12 +62,24 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; switch (obj->mks_obj_id) { case ID_GCODE: lv_clear_more(); lv_draw_gcode(true); break; - case ID_CUSTOM_1: TERN_(USER_CMD_1_ENABLE, queue.inject_P(PSTR(USER_GCODE_1))); break; - case ID_CUSTOM_2: TERN_(USER_CMD_2_ENABLE, queue.inject_P(PSTR(USER_GCODE_2))); break; - case ID_CUSTOM_3: TERN_(USER_CMD_3_ENABLE, queue.inject_P(PSTR(USER_GCODE_3))); break; - case ID_CUSTOM_4: TERN_(USER_CMD_4_ENABLE, queue.inject_P(PSTR(USER_GCODE_4))); break; - case ID_CUSTOM_5: TERN_(USER_CMD_5_ENABLE, queue.inject_P(PSTR(USER_GCODE_5))); break; - case ID_CUSTOM_6: TERN_(USER_CMD_6_ENABLE, queue.inject_P(PSTR(USER_GCODE_6))); break; + #if HAS_USER_ITEM(1) + case ID_CUSTOM_1: queue.inject_P(PSTR(USER_GCODE_1)); break; + #endif + #if HAS_USER_ITEM(2) + case ID_CUSTOM_2: queue.inject_P(PSTR(USER_GCODE_2)); break; + #endif + #if HAS_USER_ITEM(3) + case ID_CUSTOM_3: queue.inject_P(PSTR(USER_GCODE_3)); break; + #endif + #if HAS_USER_ITEM(4) + case ID_CUSTOM_4: queue.inject_P(PSTR(USER_GCODE_4)); break; + #endif + #if HAS_USER_ITEM(5) + case ID_CUSTOM_5: queue.inject_P(PSTR(USER_GCODE_5)); break; + #endif + #if HAS_USER_ITEM(6) + case ID_CUSTOM_6: queue.inject_P(PSTR(USER_GCODE_6)); break; + #endif case ID_M_RETURN: lv_clear_more(); lv_draw_tool(); @@ -70,37 +96,37 @@ void lv_draw_more() { if (enc_ena) lv_group_add_obj(g, buttonGCode); lv_obj_t *labelGCode = lv_label_create_empty(buttonGCode); - #if ENABLED(USER_CMD_1_ENABLE) + #if HAS_USER_ITEM(1) lv_obj_t *buttonCustom1 = lv_imgbtn_create(scr, "F:/bmp_custom1.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_CUSTOM_1); if (enc_ena) lv_group_add_obj(g, buttonCustom1); lv_obj_t *labelCustom1 = lv_label_create_empty(buttonCustom1); #endif - #if ENABLED(USER_CMD_2_ENABLE) + #if HAS_USER_ITEM(2) lv_obj_t *buttonCustom2 = lv_imgbtn_create(scr, "F:/bmp_custom2.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_CUSTOM_2); if (enc_ena) lv_group_add_obj(g, buttonCustom2); lv_obj_t *labelCustom2 = lv_label_create_empty(buttonCustom2); #endif - #if ENABLED(USER_CMD_3_ENABLE) + #if HAS_USER_ITEM(3) lv_obj_t *buttonCustom3 = lv_imgbtn_create(scr, "F:/bmp_custom3.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_CUSTOM_3); if (enc_ena) lv_group_add_obj(g, buttonCustom3); lv_obj_t *labelCustom3 = lv_label_create_empty(buttonCustom3); #endif - #if ENABLED(USER_CMD_4_ENABLE) + #if HAS_USER_ITEM(4) lv_obj_t *buttonCustom4 = lv_imgbtn_create(scr, "F:/bmp_custom4.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_4); if (enc_ena) lv_group_add_obj(g, buttonCustom4); lv_obj_t *labelCustom4 = lv_label_create_empty(buttonCustom4); #endif - #if ENABLED(USER_CMD_5_ENABLE) + #if HAS_USER_ITEM(5) lv_obj_t *buttonCustom5 = lv_imgbtn_create(scr, "F:/bmp_custom5.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_5); if (enc_ena) lv_group_add_obj(g, buttonCustom5); lv_obj_t *labelCustom5 = lv_label_create_empty(buttonCustom5); #endif - #if ENABLED(USER_CMD_6_ENABLE) + #if HAS_USER_ITEM(6) lv_obj_t *buttonCustom6 = lv_imgbtn_create(scr, "F:/bmp_custom6.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_6); if (enc_ena) lv_group_add_obj(g, buttonCustom6); lv_obj_t *labelCustom6 = lv_label_create_empty(buttonCustom6); @@ -114,27 +140,27 @@ void lv_draw_more() { lv_label_set_text(labelGCode, more_menu.gcode); lv_obj_align(labelGCode, buttonGCode, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); - #if ENABLED(USER_CMD_1_ENABLE) + #if HAS_USER_ITEM(1) lv_label_set_text(labelCustom1, more_menu.custom1); lv_obj_align(labelCustom1, buttonCustom1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); #endif - #if ENABLED(USER_CMD_2_ENABLE) + #if HAS_USER_ITEM(2) lv_label_set_text(labelCustom2, more_menu.custom2); lv_obj_align(labelCustom2, buttonCustom2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); #endif - #if ENABLED(USER_CMD_3_ENABLE) + #if HAS_USER_ITEM(3) lv_label_set_text(labelCustom3, more_menu.custom3); lv_obj_align(labelCustom3, buttonCustom3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); #endif - #if ENABLED(USER_CMD_4_ENABLE) + #if HAS_USER_ITEM(4) lv_label_set_text(labelCustom4, more_menu.custom4); lv_obj_align(labelCustom4, buttonCustom4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); #endif - #if ENABLED(USER_CMD_5_ENABLE) + #if HAS_USER_ITEM(5) lv_label_set_text(labelCustom5, more_menu.custom5); lv_obj_align(labelCustom5, buttonCustom5, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); #endif - #if ENABLED(USER_CMD_6_ENABLE) + #if HAS_USER_ITEM(6) lv_label_set_text(labelCustom6, more_menu.custom6); lv_obj_align(labelCustom6, buttonCustom6, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); #endif @@ -145,12 +171,24 @@ void lv_draw_more() { #if BUTTONS_EXIST(EN1, EN2, ENC) if (enc_ena) { lv_group_add_obj(g, buttonGCode); - TERN_(USER_CMD_1_ENABLE, lv_group_add_obj(g, buttonCustom1)); - TERN_(USER_CMD_2_ENABLE, lv_group_add_obj(g, buttonCustom2)); - TERN_(USER_CMD_3_ENABLE, lv_group_add_obj(g, buttonCustom3)); - TERN_(USER_CMD_4_ENABLE, lv_group_add_obj(g, buttonCustom4)); - TERN_(USER_CMD_5_ENABLE, lv_group_add_obj(g, buttonCustom5)); - TERN_(USER_CMD_6_ENABLE, lv_group_add_obj(g, buttonCustom6)); + #if HAS_USER_ITEM(1) + lv_group_add_obj(g, buttonCustom1); + #endif + #if HAS_USER_ITEM(2) + lv_group_add_obj(g, buttonCustom2); + #endif + #if HAS_USER_ITEM(3) + lv_group_add_obj(g, buttonCustom3); + #endif + #if HAS_USER_ITEM(4) + lv_group_add_obj(g, buttonCustom4); + #endif + #if HAS_USER_ITEM(5) + lv_group_add_obj(g, buttonCustom5); + #endif + #if HAS_USER_ITEM(6) + lv_group_add_obj(g, buttonCustom6); + #endif lv_group_add_obj(g, buttonBack); } #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 a2ecb0e436..aa6d3869a6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -71,7 +71,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target; lv_draw_filament_change(); break; - case ID_T_MORE: lv_draw_more(); break; + case ID_T_MORE: + lv_draw_more(); + break; case ID_T_RETURN: TERN_(MKS_TEST, curent_disp_ui = 1); lv_draw_ready_print(); From d079634c5e5b7a4179d737c45be433fc75b58cd4 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 3 Feb 2021 00:13:01 +0000 Subject: [PATCH 18/51] [cron] Bump distribution date (2021-02-03) --- 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 a08e5348ce..a7183ab71f 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 "2021-02-02" + #define STRING_DISTRIBUTION_DATE "2021-02-03" #endif /** From 68299c6a5e1c3c957c1014dbb1c9439759e3a0df Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 4 Feb 2021 00:11:57 +0000 Subject: [PATCH 19/51] [cron] Bump distribution date (2021-02-04) --- 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 a7183ab71f..46929c85c2 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 "2021-02-03" + #define STRING_DISTRIBUTION_DATE "2021-02-04" #endif /** From d58bbd5da1591dea0386170ba4831c549ac7eb9d Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Thu, 4 Feb 2021 18:31:46 -0300 Subject: [PATCH 20/51] Re-calibrate touch after EEPROM reset, if needed (#20934) --- Marlin/src/lcd/marlinui.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 46db571936..eea697a464 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1652,7 +1652,13 @@ void MarlinUI::update() { #endif // SDSUPPORT #if HAS_LCD_MENU - void MarlinUI::reset_settings() { settings.reset(); completion_feedback(); } + void MarlinUI::reset_settings() { + settings.reset(); + completion_feedback(); + #if ENABLED(TOUCH_SCREEN_CALIBRATION) + if (touch_calibration.need_calibration()) ui.goto_screen(touch_screen_calibration); + #endif + } #endif #if ENABLED(EEPROM_SETTINGS) From 6dac71e6180a55cfb5f395de7ff3315b6f343957 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 5 Feb 2021 00:12:11 +0000 Subject: [PATCH 21/51] [cron] Bump distribution date (2021-02-05) --- 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 46929c85c2..15105bd8bf 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 "2021-02-04" + #define STRING_DISTRIBUTION_DATE "2021-02-05" #endif /** From 604afd52d11f45c21194ff5679c829b57e5387e6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 4 Feb 2021 19:18:31 -0600 Subject: [PATCH 22/51] Fix some serial char, echo Co-Authored-By: X-Ryl669 <3277165+X-Ryl669@users.noreply.github.com> --- Marlin/src/HAL/shared/backtrace/backtrace.cpp | 4 +- Marlin/src/feature/bedlevel/bedlevel.cpp | 2 +- Marlin/src/feature/direct_stepping.cpp | 6 +- Marlin/src/feature/encoder_i2c.cpp | 23 ++++--- Marlin/src/feature/tmc_util.cpp | 64 +++++++++---------- Marlin/src/gcode/feature/advance/M900.cpp | 2 +- Marlin/src/gcode/queue.cpp | 5 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 7 +- Marlin/src/sd/cardreader.cpp | 2 +- 9 files changed, 55 insertions(+), 60 deletions(-) diff --git a/Marlin/src/HAL/shared/backtrace/backtrace.cpp b/Marlin/src/HAL/shared/backtrace/backtrace.cpp index 6cf5e055e1..605e165b05 100644 --- a/Marlin/src/HAL/shared/backtrace/backtrace.cpp +++ b/Marlin/src/HAL/shared/backtrace/backtrace.cpp @@ -34,9 +34,9 @@ static bool UnwReportOut(void* ctx, const UnwReport* bte) { (*p)++; - SERIAL_CHAR('#'); SERIAL_PRINT(*p, DEC); SERIAL_ECHOPGM(" : "); + SERIAL_CHAR('#'); SERIAL_ECHO(*p); SERIAL_ECHOPGM(" : "); SERIAL_ECHOPGM(bte->name ? bte->name : "unknown"); SERIAL_ECHOPGM("@0x"); SERIAL_PRINT(bte->function, HEX); - SERIAL_CHAR('+'); SERIAL_PRINT(bte->address - bte->function,DEC); + SERIAL_CHAR('+'); SERIAL_ECHO(bte->address - bte->function); SERIAL_ECHOPGM(" PC:"); SERIAL_PRINT(bte->address,HEX); SERIAL_CHAR('\n'); return true; } diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 0e0b87e890..e142b31a78 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -196,7 +196,7 @@ void reset_bed_level() { #endif } #ifdef SCAD_MESH_OUTPUT - SERIAL_CHAR(' ', ']'); // close sub-array + SERIAL_ECHOPGM(" ]"); // close sub-array if (y < sy - 1) SERIAL_CHAR(','); #endif SERIAL_EOL(); diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index 9766d14640..2698b53dd6 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -180,7 +180,7 @@ namespace DirectStepping { if (!page_states_dirty) return; page_states_dirty = false; - SERIAL_ECHO(Cfg::CONTROL_CHAR); + SERIAL_CHAR(Cfg::CONTROL_CHAR); constexpr int state_bits = 2; constexpr int n_bytes = Cfg::NUM_PAGES >> state_bits; volatile uint8_t bits_b[n_bytes] = { 0 }; @@ -192,10 +192,10 @@ namespace DirectStepping { uint8_t crc = 0; for (uint8_t i = 0 ; i < n_bytes ; i++) { crc ^= bits_b[i]; - SERIAL_ECHO(bits_b[i]); + SERIAL_CHAR(bits_b[i]); } - SERIAL_ECHO(crc); + SERIAL_CHAR(crc); SERIAL_EOL(); } diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index fa3cf1503f..af42165599 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -172,7 +172,7 @@ void I2CPositionEncoder::update() { float sumP = 0; LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i]; const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE)); - SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_ECHOLNPAIR(" : CORRECT ERR ", errorP * planner.steps_to_mm[encoderAxis], "mm"); babystep.add_steps(encoderAxis, -LROUND(errorP)); errPrstIdx = 0; @@ -192,7 +192,7 @@ void I2CPositionEncoder::update() { if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) { const millis_t ms = millis(); if (ELAPSED(ms, nextErrorCountTime)) { - SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_ECHOLNPAIR(" : LARGE ERR ", int(error), "; diffSum=", diffSum); errorCount++; nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS; @@ -213,7 +213,7 @@ void I2CPositionEncoder::set_homed() { trusted++; #ifdef I2CPE_DEBUG - SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_ECHOLNPAIR(" axis encoder homed, offset of ", zeroOffset, " ticks."); #endif } @@ -224,7 +224,7 @@ void I2CPositionEncoder::set_unhomed() { homed = trusted = false; #ifdef I2CPE_DEBUG - SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_ECHOLNPGM(" axis encoder unhomed."); #endif } @@ -232,7 +232,7 @@ void I2CPositionEncoder::set_unhomed() { bool I2CPositionEncoder::passes_test(const bool report) { if (report) { if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. "); - SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_CHAR(axis_codes[encoderAxis]); serial_ternary(H == I2CPE_MAG_SIG_BAD, PSTR(" axis "), PSTR("magnetic strip "), PSTR("encoder ")); switch (H) { case I2CPE_MAG_SIG_GOOD: @@ -253,7 +253,7 @@ float I2CPositionEncoder::get_axis_error_mm(const bool report) { error = ABS(diff) > 10000 ? 0 : diff; // Huge error is a bad reading if (report) { - SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_ECHOLNPAIR(" axis target=", target, "mm; actual=", actual, "mm; err=", error, "mm"); } @@ -263,7 +263,7 @@ float I2CPositionEncoder::get_axis_error_mm(const bool report) { int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) { if (!active) { if (report) { - SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_ECHOLNPGM(" axis encoder not active!"); } return 0; @@ -288,7 +288,7 @@ int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) { errorPrev = error; if (report) { - SERIAL_ECHO(axis_codes[encoderAxis]); + SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_ECHOLNPAIR(" axis target=", target, "; actual=", encoderCountInStepperTicksScaled, "; err=", error); } @@ -667,8 +667,7 @@ void I2CPositionEncodersMgr::report_position(const int8_t idx, const bool units, else { if (noOffset) { const int32_t raw_count = encoders[idx].get_raw_count(); - SERIAL_ECHO(axis_codes[encoders[idx].get_axis()]); - SERIAL_CHAR(' '); + SERIAL_CHAR(axis_codes[encoders[idx].get_axis()], ' '); for (uint8_t j = 31; j > 0; j--) SERIAL_ECHO((bool)(0x00000001 & (raw_count >> j))); @@ -723,7 +722,7 @@ void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const // and enable it (it will likely have failed initialization on power-up, before the address change). const int8_t idx = idx_from_addr(newaddr); if (idx >= 0 && !encoders[idx].get_active()) { - SERIAL_ECHO(axis_codes[encoders[idx].get_axis()]); + SERIAL_CHAR(axis_codes[encoders[idx].get_axis()]); SERIAL_ECHOLNPGM(" axis encoder was not detected on printer startup. Trying again."); encoders[idx].set_active(encoders[idx].passes_test(true)); } @@ -748,7 +747,7 @@ void I2CPositionEncodersMgr::report_module_firmware(const uint8_t address) { if (Wire.requestFrom(I2C_ADDRESS(address), uint8_t(32))) { char c; while (Wire.available() > 0 && (c = (char)Wire.read()) > 0) - SERIAL_ECHO(c); + SERIAL_CHAR(c); SERIAL_EOL(); } diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index 8d0156883b..a16af31e55 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -233,10 +233,10 @@ void report_polled_driver_data(TMC &st, const TMC_driver_data &data) { const uint32_t pwm_scale = get_pwm_scale(st); st.printLabel(); - SERIAL_CHAR(':'); SERIAL_PRINT(pwm_scale, DEC); + SERIAL_CHAR(':'); SERIAL_ECHO(pwm_scale); #if ENABLED(TMC_DEBUG) #if HAS_TMCX1X0 || HAS_TMC220x - SERIAL_CHAR('/'); SERIAL_PRINT(data.cs_actual, DEC); + SERIAL_CHAR('/'); SERIAL_ECHO(data.cs_actual); #endif #if HAS_STALLGUARD SERIAL_CHAR('/'); @@ -257,7 +257,7 @@ #endif if (st.flag_otpw) SERIAL_CHAR('F'); // otpw Flag SERIAL_CHAR('|'); - if (st.otpw_count > 0) SERIAL_PRINT(st.otpw_count, DEC); + if (st.otpw_count > 0) SERIAL_ECHO(st.otpw_count); SERIAL_CHAR('\t'); } @@ -551,8 +551,8 @@ #if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130) static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) { switch (i) { - case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break; - case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break; + case TMC_PWM_SCALE: SERIAL_ECHO(st.PWM_SCALE()); break; + case TMC_SGT: SERIAL_ECHO(st.sgt()); break; case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break; case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break; default: break; @@ -563,9 +563,9 @@ static void _tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) { switch (i) { case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('*'); break; - case TMC_SG_RESULT: SERIAL_PRINT(st.sg_result(), DEC); break; + case TMC_SG_RESULT: SERIAL_ECHO(st.sg_result()); break; case TMC_FSACTIVE: if (st.fsactive()) SERIAL_CHAR('*'); break; - case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break; + case TMC_DRV_CS_ACTUAL: SERIAL_ECHO(st.cs_actual()); break; default: break; } } @@ -580,13 +580,13 @@ static void _tmc_status(TMC2160Stepper &st, const TMC_debug_enum i) { switch (i) { - case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break; - case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break; + case TMC_PWM_SCALE: SERIAL_ECHO(st.PWM_SCALE()); break; + case TMC_SGT: SERIAL_ECHO(st.sgt()); break; case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break; case TMC_GLOBAL_SCALER: { uint16_t value = st.GLOBAL_SCALER(); - SERIAL_PRINT(value ?: 256, DEC); + SERIAL_ECHO(value ? value : 256); SERIAL_ECHOPGM("/256"); } break; @@ -599,10 +599,10 @@ #if HAS_TMC220x static void _tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) { switch (i) { - case TMC_PWM_SCALE_SUM: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break; - case TMC_PWM_SCALE_AUTO: SERIAL_PRINT(st.pwm_scale_auto(), DEC); break; - case TMC_PWM_OFS_AUTO: SERIAL_PRINT(st.pwm_ofs_auto(), DEC); break; - case TMC_PWM_GRAD_AUTO: SERIAL_PRINT(st.pwm_grad_auto(), DEC); break; + case TMC_PWM_SCALE_SUM: SERIAL_ECHO(st.pwm_scale_sum()); break; + case TMC_PWM_SCALE_AUTO: SERIAL_ECHO(st.pwm_scale_auto()); break; + case TMC_PWM_OFS_AUTO: SERIAL_ECHO(st.pwm_ofs_auto()); break; + case TMC_PWM_GRAD_AUTO: SERIAL_ECHO(st.pwm_grad_auto()); break; case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break; case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break; default: break; @@ -613,8 +613,8 @@ template static void _tmc_status(TMCMarlin &st, const TMC_debug_enum i) { switch (i) { - case TMC_SGT: SERIAL_PRINT(st.SGTHRS(), DEC); break; - case TMC_UART_ADDR: SERIAL_PRINT(st.get_address(), DEC); break; + case TMC_SGT: SERIAL_ECHO(st.SGTHRS()); break; + case TMC_UART_ADDR: SERIAL_ECHO(st.get_address()); break; default: TMC2208Stepper *parent = &st; _tmc_status(*parent, i); @@ -631,7 +631,7 @@ case TMC_T120: if (st.t120()) SERIAL_CHAR('*'); break; case TMC_S2VSA: if (st.s2vsa()) SERIAL_CHAR('*'); break; case TMC_S2VSB: if (st.s2vsb()) SERIAL_CHAR('*'); break; - case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break; + case TMC_DRV_CS_ACTUAL: SERIAL_ECHO(st.cs_actual()); break; default: break; } } @@ -639,7 +639,7 @@ #if HAS_DRIVER(TMC2209) static void _tmc_parse_drv_status(TMC2209Stepper &st, const TMC_drv_status_enum i) { switch (i) { - case TMC_SG_RESULT: SERIAL_PRINT(st.SG_RESULT(), DEC); break; + case TMC_SG_RESULT: SERIAL_ECHO(st.SG_RESULT()); break; default: _tmc_parse_drv_status(static_cast(st), i); break; } } @@ -666,15 +666,15 @@ case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break; case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break; case TMC_IRUN: - SERIAL_PRINT(st.irun(), DEC); + SERIAL_ECHO(st.irun()); SERIAL_ECHOPGM("/31"); break; case TMC_IHOLD: - SERIAL_PRINT(st.ihold(), DEC); + SERIAL_ECHO(st.ihold()); SERIAL_ECHOPGM("/31"); break; case TMC_CS_ACTUAL: - SERIAL_PRINT(st.cs_actual(), DEC); + SERIAL_ECHO(st.cs_actual()); SERIAL_ECHOPGM("/31"); break; case TMC_VSENSE: print_vsense(st); break; @@ -694,11 +694,11 @@ #if ENABLED(MONITOR_DRIVER_STATUS) case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break; #endif - case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break; - case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break; - case TMC_HEND: SERIAL_PRINT(st.hysteresis_end(), DEC); break; - case TMC_HSTRT: SERIAL_PRINT(st.hysteresis_start(), DEC); break; - case TMC_MSCNT: SERIAL_PRINT(st.get_microstep_counter(), DEC); break; + case TMC_TOFF: SERIAL_ECHO(st.toff()); break; + case TMC_TBL: SERIAL_ECHO(st.blank_time()); break; + case TMC_HEND: SERIAL_ECHO(st.hysteresis_end()); break; + case TMC_HSTRT: SERIAL_ECHO(st.hysteresis_start()); break; + case TMC_MSCNT: SERIAL_ECHO(st.get_microstep_counter()); break; default: _tmc_status(st, i); break; } } @@ -714,18 +714,18 @@ case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break; case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break; case TMC_IRUN: - SERIAL_PRINT(st.cs(), DEC); + SERIAL_ECHO(st.cs()); SERIAL_ECHOPGM("/31"); break; case TMC_VSENSE: serialprintPGM(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break; case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break; //case TMC_OTPW: serialprint_truefalse(st.otpw()); break; //case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break; - case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break; - case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break; - case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break; - case TMC_HEND: SERIAL_PRINT(st.hysteresis_end(), DEC); break; - case TMC_HSTRT: SERIAL_PRINT(st.hysteresis_start(), DEC); break; + case TMC_SGT: SERIAL_ECHO(st.sgt()); break; + case TMC_TOFF: SERIAL_ECHO(st.toff()); break; + case TMC_TBL: SERIAL_ECHO(st.blank_time()); break; + case TMC_HEND: SERIAL_ECHO(st.hysteresis_end()); break; + case TMC_HSTRT: SERIAL_ECHO(st.hysteresis_start()); break; default: break; } } diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 5c7155d7c9..3c2c27b62a 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -43,7 +43,7 @@ void GcodeSuite::M900() { auto echo_value_oor = [](const char ltr, const bool ten=true) { - SERIAL_CHAR('?'); SERIAL_CHAR(ltr); + SERIAL_CHAR('?', ltr); SERIAL_ECHOPGM(" value out of range"); if (ten) SERIAL_ECHOPGM(" (0-10)"); SERIAL_ECHOLNPGM("."); diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 4c42f7e353..d5bc857286 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -298,10 +298,9 @@ void GCodeQueue::ok_to_send() { #if ENABLED(ADVANCED_OK) char* p = command_buffer[index_r]; if (*p == 'N') { - SERIAL_ECHO(' '); - SERIAL_ECHO(*p++); + SERIAL_CHAR(' ', *p++); while (NUMERIC_SIGNED(*p)) - SERIAL_ECHO(*p++); + SERIAL_CHAR(*p++); } SERIAL_ECHOPAIR_P(SP_P_STR, int(planner.moves_free()), SP_B_STR, int(BUFSIZE - length)); 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 1508dc0d27..c44d667b8f 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 @@ -141,9 +141,7 @@ void AnycubicTFTClass::OnKillTFT() { void AnycubicTFTClass::OnSDCardStateChange(bool isInserted) { #if ENABLED(ANYCUBIC_LCD_DEBUG) - SERIAL_ECHOPGM("TFT Serial Debug: OnSDCardStateChange event triggered..."); - SERIAL_ECHO(ui8tostr2(isInserted)); - SERIAL_EOL(); + SERIAL_ECHOLNPAIR("TFT Serial Debug: OnSDCardStateChange event triggered...", (int)isInserted); #endif DoSDCardStateCheck(); } @@ -164,8 +162,7 @@ void AnycubicTFTClass::OnFilamentRunout() { void AnycubicTFTClass::OnUserConfirmRequired(const char * const msg) { #if ENABLED(ANYCUBIC_LCD_DEBUG) - SERIAL_ECHOPGM("TFT Serial Debug: OnUserConfirmRequired triggered... "); - SERIAL_ECHOLN(msg); + SERIAL_ECHOLNPAIR("TFT Serial Debug: OnUserConfirmRequired triggered... ", msg); #endif #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 647e3f3e21..c88fdc0693 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -369,7 +369,7 @@ void CardReader::printFilename() { #if ENABLED(LONG_FILENAME_HOST_SUPPORT) selectFileByName(dosFilename); if (longFilename[0]) { - SERIAL_ECHO(' '); + SERIAL_CHAR(' '); SERIAL_ECHO(longFilename); } #endif From 49564e5310184079c53ff322cd27e35e22877017 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 4 Feb 2021 19:37:59 -0600 Subject: [PATCH 23/51] Nybbles & Bits --- Marlin/src/libs/W25Qxx.cpp | 24 +++++++++---------- Marlin/src/module/planner.cpp | 24 +++++++++---------- .../src/sd/usb_flashdrive/lib-uhs2/printhex.h | 12 +++++----- .../lib-uhs3/UHS_host/UHS_printhex.h | 12 +++++----- .../USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h | 6 ++--- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Marlin/src/libs/W25Qxx.cpp b/Marlin/src/libs/W25Qxx.cpp index be5b4290dd..0eb40a1441 100644 --- a/Marlin/src/libs/W25Qxx.cpp +++ b/Marlin/src/libs/W25Qxx.cpp @@ -191,11 +191,11 @@ void W25QXXFlash::SPI_FLASH_SectorErase(uint32_t SectorAddr) { W25QXX_CS_L; // Send Sector Erase instruction spi_flash_Send(W25X_SectorErase); - // Send SectorAddr high nibble address byte + // Send SectorAddr high nybble address byte spi_flash_Send((SectorAddr & 0xFF0000) >> 16); - // Send SectorAddr medium nibble address byte + // Send SectorAddr medium nybble address byte spi_flash_Send((SectorAddr & 0xFF00) >> 8); - // Send SectorAddr low nibble address byte + // Send SectorAddr low nybble address byte spi_flash_Send(SectorAddr & 0xFF); // Deselect the FLASH: Chip Select high @@ -209,11 +209,11 @@ void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) { W25QXX_CS_L; // Send Sector Erase instruction spi_flash_Send(W25X_BlockErase); - // Send SectorAddr high nibble address byte + // Send SectorAddr high nybble address byte spi_flash_Send((BlockAddr & 0xFF0000) >> 16); - // Send SectorAddr medium nibble address byte + // Send SectorAddr medium nybble address byte spi_flash_Send((BlockAddr & 0xFF00) >> 8); - // Send SectorAddr low nibble address byte + // Send SectorAddr low nybble address byte spi_flash_Send(BlockAddr & 0xFF); W25QXX_CS_H; @@ -265,11 +265,11 @@ void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint W25QXX_CS_L; // Send "Write to Memory " instruction spi_flash_Send(W25X_PageProgram); - // Send WriteAddr high nibble address byte to write to + // Send WriteAddr high nybble address byte to write to spi_flash_Send((WriteAddr & 0xFF0000) >> 16); - // Send WriteAddr medium nibble address byte to write to + // Send WriteAddr medium nybble address byte to write to spi_flash_Send((WriteAddr & 0xFF00) >> 8); - // Send WriteAddr low nibble address byte to write to + // Send WriteAddr low nybble address byte to write to spi_flash_Send(WriteAddr & 0xFF); NOMORE(NumByteToWrite, SPI_FLASH_PerWritePageSize); @@ -371,11 +371,11 @@ void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint // Send "Read from Memory " instruction spi_flash_Send(W25X_ReadData); - // Send ReadAddr high nibble address byte to read from + // Send ReadAddr high nybble address byte to read from spi_flash_Send((ReadAddr & 0xFF0000) >> 16); - // Send ReadAddr medium nibble address byte to read from + // Send ReadAddr medium nybble address byte to read from spi_flash_Send((ReadAddr & 0xFF00) >> 8); - // Send ReadAddr low nibble address byte to read from + // Send ReadAddr low nybble address byte to read from spi_flash_Send(ReadAddr & 0xFF); if (NumByteToRead <= 32 || !flash_dma_mode) { diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 5897d10cd5..541aed943e 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -418,11 +418,11 @@ void Planner::init() { L("2") A("cpi %16,0x10") // (nr & 0xF00000) == 0 ? A("brcc 3f") // No, skip this - A("swap %15") // Swap nibbles - A("swap %16") // Swap nibbles. Low nibble is 0 + A("swap %15") // Swap nybbles + A("swap %16") // Swap nybbles. Low nybble is 0 A("mov %14, %15") - A("andi %14,0x0F") // Isolate low nibble - A("andi %15,0xF0") // Keep proper nibble in %15 + A("andi %14,0x0F") // Isolate low nybble + A("andi %15,0xF0") // Keep proper nybble in %15 A("or %16, %14") // %16:%15 <<= 4 A("subi %3,-4") // idx += 4 @@ -473,10 +473,10 @@ void Planner::init() { L("9") A("sbrs %3,2") // shift by 4bits position? A("rjmp 16f") // No - A("swap %15") // Swap nibbles. lo nibble of %15 will always be 0 - A("swap %14") // Swap nibbles + A("swap %15") // Swap nybbles. lo nybble of %15 will always be 0 + A("swap %14") // Swap nybbles A("mov %12,%14") - A("andi %12,0x0F") // isolate low nibble + A("andi %12,0x0F") // isolate low nybble A("andi %14,0xF0") // and clear it A("or %15,%12") // %15:%16 <<= 4 L("16") @@ -504,11 +504,11 @@ void Planner::init() { L("11") A("sbrs %3,2") // shift by 4 bit position ? A("rjmp 12f") // No, skip it - A("swap %15") // Swap nibbles - A("andi %14, 0xF0") // Lose the lowest nibble - A("swap %14") // Swap nibbles. Upper nibble is 0 - A("or %14,%15") // Pass nibble from upper byte - A("andi %15, 0x0F") // And get rid of that nibble + A("swap %15") // Swap nybbles + A("andi %14, 0xF0") // Lose the lowest nybble + A("swap %14") // Swap nybbles. Upper nybble is 0 + A("or %14,%15") // Pass nybble from upper byte + A("andi %15, 0x0F") // And get rid of that nybble L("12") A("sbrs %3,3") // shift by 8 bit position ? A("rjmp 6f") // No, skip it diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/printhex.h b/Marlin/src/sd/usb_flashdrive/lib-uhs2/printhex.h index 319cd9c4c8..6ded4fa9cc 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/printhex.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/printhex.h @@ -32,12 +32,12 @@ void E_Notifyc(char c, int lvl); template void PrintHex(T val, int lvl) { - int num_nibbles = sizeof (T) * 2; + int num_nybbles = sizeof (T) * 2; do { - char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F); + char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F); if (v > 57) v += 7; E_Notifyc(v, lvl); - } while (--num_nibbles); + } while (--num_nybbles); } template @@ -48,12 +48,12 @@ void PrintBin(T val, int lvl) { template void SerialPrintHex(T val) { - int num_nibbles = sizeof (T) * 2; + int num_nybbles = sizeof (T) * 2; do { - char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F); + char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F); if (v > 57) v += 7; USB_HOST_SERIAL.print(v); - } while (--num_nibbles); + } while (--num_nybbles); } template diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h index bfa052b8f7..edf673a4fb 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h @@ -33,13 +33,13 @@ void E_Notifyc(char c, int lvl); template void PrintHex(T val, int lvl) { - int num_nibbles = sizeof (T) * 2; + int num_nybbles = sizeof (T) * 2; do { - char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F); + char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F); if(v > 57) v += 7; E_Notifyc(v, lvl); - } while(--num_nibbles); + } while(--num_nybbles); } template @@ -53,13 +53,13 @@ void PrintBin(T val, int lvl) { template void SerialPrintHex(T val) { - int num_nibbles = sizeof (T) * 2; + int num_nybbles = sizeof (T) * 2; do { - char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0F); + char v = 48 + (((val >> (num_nybbles - 1) * 4)) & 0x0F); if(v > 57) v += 7; USB_HOST_SERIAL.print(v); - } while(--num_nibbles); + } while(--num_nybbles); } template diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h index f7dd315a04..7fe48652fd 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h @@ -96,7 +96,7 @@ uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* dat /* GPIO write */ /*GPIO byte is split between 2 registers, so two writes are needed to write one byte */ -/* GPOUT bits are in the low nibble. 0-3 in IOPINS1, 4-7 in IOPINS2 */ +/* GPOUT bits are in the low nybble. 0-3 in IOPINS1, 4-7 in IOPINS2 */ void UHS_NI MAX3421E_HOST::gpioWr(uint8_t data) { regWr(rIOPINS1, data); data >>= 4; @@ -132,11 +132,11 @@ uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* dat /* GPIO read. See gpioWr for explanation */ -/* GPIN pins are in high nibbles of IOPINS1, IOPINS2 */ +/* GPIN pins are in high nybbles of IOPINS1, IOPINS2 */ uint8_t UHS_NI MAX3421E_HOST::gpioRd() { uint8_t gpin = 0; gpin = regRd(rIOPINS2); //pins 4-7 - gpin &= 0xF0; //clean lower nibble + gpin &= 0xF0; //clean lower nybble gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation. return ( gpin); } From 708ea3d0bb82f067424c75636c28a549aa3d3b06 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 4 Feb 2021 23:22:42 -0600 Subject: [PATCH 24/51] Use serial shorthand --- Marlin/src/MarlinCore.cpp | 3 +- Marlin/src/feature/binary_stream.h | 9 +-- Marlin/src/feature/cancel_object.cpp | 3 +- Marlin/src/feature/mmu/mmu2.cpp | 9 +-- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 12 ++-- Marlin/src/gcode/config/M281.cpp | 16 ++--- Marlin/src/gcode/config/M304.cpp | 9 +-- Marlin/src/gcode/config/M305.cpp | 6 +- Marlin/src/gcode/control/M280.cpp | 15 ++--- Marlin/src/gcode/host/M113.cpp | 8 +-- Marlin/src/gcode/motion/M290.cpp | 6 +- Marlin/src/gcode/stats/M31.cpp | 3 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 6 +- .../ftdi_eve_lib/basic/commands.cpp | 17 ++--- .../ftdi_eve_lib/extended/event_loop.cpp | 6 +- .../ftdi_eve_lib/extended/screen_types.cpp | 3 +- .../screens/bio_printing_dialog_box.cpp | 3 +- Marlin/src/module/settings.cpp | 64 ++++++++----------- Marlin/src/module/temperature.cpp | 3 +- Marlin/src/module/tool_change.cpp | 3 +- Marlin/src/sd/cardreader.cpp | 16 ++--- 21 files changed, 88 insertions(+), 132 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 16111936da..f0d4fa05a6 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -419,8 +419,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { if (parked_or_ignoring) gcode.reset_stepper_timeout(ms); if (gcode.stepper_max_timed_out(ms)) { - SERIAL_ERROR_START(); - SERIAL_ECHOLNPAIR(STR_KILL_INACTIVE_TIME, parser.command_ptr); + SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr); kill(); } diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index 81d6e7184b..a70a0a4a27 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -352,8 +352,7 @@ public: } } else { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Packet header(", packet.header.sync, "?) corrupt"); + SERIAL_ECHO_MSG("Packet header(", packet.header.sync, "?) corrupt"); stream_state = StreamState::PACKET_RESEND; } } @@ -387,8 +386,7 @@ public: stream_state = StreamState::PACKET_PROCESS; } else { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Packet(", packet.header.sync, ") payload corrupt"); + SERIAL_ECHO_MSG("Packet(", packet.header.sync, ") payload corrupt"); stream_state = StreamState::PACKET_RESEND; } } @@ -406,8 +404,7 @@ public: if (packet_retries < MAX_RETRIES || MAX_RETRIES == 0) { packet_retries++; stream_state = StreamState::PACKET_RESET; - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Resend request ", int(packet_retries)); + SERIAL_ECHO_MSG("Resend request ", int(packet_retries)); SERIAL_ECHOLNPAIR("rs", sync); } else diff --git a/Marlin/src/feature/cancel_object.cpp b/Marlin/src/feature/cancel_object.cpp index 853e765b66..3ffd10e970 100644 --- a/Marlin/src/feature/cancel_object.cpp +++ b/Marlin/src/feature/cancel_object.cpp @@ -67,8 +67,7 @@ void CancelObject::uncancel_object(const int8_t obj) { void CancelObject::report() { if (active_object >= 0) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Active Object: ", int(active_object)); + SERIAL_ECHO_MSG("Active Object: ", int(active_object)); } if (canceled) { diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index e3036947d5..3bff73e956 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -514,8 +514,7 @@ static void mmu2_not_responding() { extruder = index; // filament change is finished active_extruder = 0; ENABLE_AXIS_E0(); - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder)); + SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder)); } ui.reset_status(); } @@ -602,8 +601,7 @@ static void mmu2_not_responding() { active_extruder = 0; ENABLE_AXIS_E0(); - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder)); + SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder)); ui.reset_status(); } @@ -698,8 +696,7 @@ static void mmu2_not_responding() { extruder = index; //filament change is finished active_extruder = 0; ENABLE_AXIS_E0(); - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder)); + SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder)); ui.reset_status(); } diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index cf27c14d3b..a08e4a0867 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -142,8 +142,7 @@ void GcodeSuite::G29() { if (parser.seenval('I')) { ix = parser.value_int(); if (!WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) { - SERIAL_ECHOPAIR("I out of range (0-", int(GRID_MAX_POINTS_X - 1)); - SERIAL_ECHOLNPGM(")"); + SERIAL_ECHOLNPAIR("I out of range (0-", int(GRID_MAX_POINTS_X - 1), ")"); return; } } @@ -153,8 +152,7 @@ void GcodeSuite::G29() { if (parser.seenval('J')) { iy = parser.value_int(); if (!WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1)) { - SERIAL_ECHOPAIR("J out of range (0-", int(GRID_MAX_POINTS_Y - 1)); - SERIAL_ECHOLNPGM(")"); + SERIAL_ECHOLNPAIR("J out of range (0-", int(GRID_MAX_POINTS_Y - 1), ")"); return; } } @@ -182,10 +180,8 @@ void GcodeSuite::G29() { } // switch(state) - if (state == MeshNext) { - SERIAL_ECHOPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS)); - SERIAL_ECHOLNPAIR(" of ", int(GRID_MAX_POINTS)); - } + if (state == MeshNext) + SERIAL_ECHOLNPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS), " of ", int(GRID_MAX_POINTS)); report_current_position(); } diff --git a/Marlin/src/gcode/config/M281.cpp b/Marlin/src/gcode/config/M281.cpp index 018ca1c092..eeb0fcc470 100644 --- a/Marlin/src/gcode/config/M281.cpp +++ b/Marlin/src/gcode/config/M281.cpp @@ -34,7 +34,9 @@ * U - Stowed Angle */ void GcodeSuite::M281() { + if (!parser.seenval('P')) return; + const int servo_index = parser.value_int(); if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) { #if ENABLED(BLTOUCH) @@ -53,16 +55,14 @@ void GcodeSuite::M281() { angle_change = true; } if (!angle_change) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(" Servo ", servo_index, - " L", servo_angles[servo_index][0], - " U", servo_angles[servo_index][1]); + SERIAL_ECHO_MSG(" Servo ", servo_index, + " L", servo_angles[servo_index][0], + " U", servo_angles[servo_index][1]); } } - else { - SERIAL_ERROR_START(); - SERIAL_ECHOLNPAIR("Servo ", servo_index, " out of range"); - } + else + SERIAL_ERROR_MSG("Servo ", servo_index, " out of range"); + } #endif // EDITABLE_SERVO_ANGLES diff --git a/Marlin/src/gcode/config/M304.cpp b/Marlin/src/gcode/config/M304.cpp index 10739be3f8..b1af5a5ae2 100644 --- a/Marlin/src/gcode/config/M304.cpp +++ b/Marlin/src/gcode/config/M304.cpp @@ -35,14 +35,15 @@ * D - Set the D value */ void GcodeSuite::M304() { + if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float(); if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float()); if (parser.seen('D')) thermalManager.temp_bed.pid.Kd = scalePID_d(parser.value_float()); - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(" p:", thermalManager.temp_bed.pid.Kp, - " i:", unscalePID_i(thermalManager.temp_bed.pid.Ki), - " d:", unscalePID_d(thermalManager.temp_bed.pid.Kd)); + SERIAL_ECHO_MSG(" p:", thermalManager.temp_bed.pid.Kp, + " i:", unscalePID_i(thermalManager.temp_bed.pid.Ki), + " d:", unscalePID_d(thermalManager.temp_bed.pid.Kd)); + } #endif // PIDTEMPBED diff --git a/Marlin/src/gcode/config/M305.cpp b/Marlin/src/gcode/config/M305.cpp index 3e7206aee4..9771ac2ced 100644 --- a/Marlin/src/gcode/config/M305.cpp +++ b/Marlin/src/gcode/config/M305.cpp @@ -49,10 +49,8 @@ void GcodeSuite::M305() { const bool do_set = parser.seen("BCRT"); // A valid P index is required - if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0)) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("!Invalid index. (0 <= P <= ", int(USER_THERMISTORS - 1), ")"); - } + if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0)) + SERIAL_ECHO_MSG("!Invalid index. (0 <= P <= ", int(USER_THERMISTORS - 1), ")"); else if (do_set) { if (parser.seen('R')) // Pullup resistor value if (!thermalManager.set_pull_up_res(t_index, parser.value_float())) diff --git a/Marlin/src/gcode/control/M280.cpp b/Marlin/src/gcode/control/M280.cpp index 6ccbb7becc..187c9a9b19 100644 --- a/Marlin/src/gcode/control/M280.cpp +++ b/Marlin/src/gcode/control/M280.cpp @@ -31,7 +31,9 @@ * M280: Get or set servo position. P [S] */ void GcodeSuite::M280() { + if (!parser.seen('P')) return; + const int servo_index = parser.value_int(); if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) { if (parser.seen('S')) { @@ -41,15 +43,12 @@ void GcodeSuite::M280() { else MOVE_SERVO(servo_index, a); } - else { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(" Servo ", servo_index, ": ", servo[servo_index].read()); - } - } - else { - SERIAL_ERROR_START(); - SERIAL_ECHOLNPAIR("Servo ", servo_index, " out of range"); + else + SERIAL_ECHO_MSG(" Servo ", servo_index, ": ", servo[servo_index].read()); } + else + SERIAL_ERROR_MSG("Servo ", servo_index, " out of range"); + } #endif // HAS_SERVOS diff --git a/Marlin/src/gcode/host/M113.cpp b/Marlin/src/gcode/host/M113.cpp index ce826d6acd..1183cc27a1 100644 --- a/Marlin/src/gcode/host/M113.cpp +++ b/Marlin/src/gcode/host/M113.cpp @@ -32,14 +32,14 @@ * S Optional. Set the keepalive interval. */ void GcodeSuite::M113() { + if (parser.seenval('S')) { host_keepalive_interval = parser.value_byte(); NOMORE(host_keepalive_interval, 60); } - else { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("M113 S", (unsigned long)host_keepalive_interval); - } + else + SERIAL_ECHO_MSG("M113 S", (uint16_t)host_keepalive_interval); + } #endif // HOST_KEEPALIVE_FEATURE diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index df8dad7999..8ff94a78fd 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -42,14 +42,12 @@ FORCE_INLINE void mod_probe_offset(const float &offs) { if (TERN1(BABYSTEP_HOTEND_Z_OFFSET, active_extruder == 0)) { probe.offset.z += offs; - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET " " STR_Z, probe.offset.z); + SERIAL_ECHO_MSG(STR_PROBE_OFFSET " " STR_Z, probe.offset.z); } else { #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) hotend_offset[active_extruder].z -= offs; - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET STR_Z ": ", hotend_offset[active_extruder].z); + SERIAL_ECHO_MSG(STR_PROBE_OFFSET STR_Z ": ", hotend_offset[active_extruder].z); #endif } } diff --git a/Marlin/src/gcode/stats/M31.cpp b/Marlin/src/gcode/stats/M31.cpp index 207f9e144e..355701f6a4 100644 --- a/Marlin/src/gcode/stats/M31.cpp +++ b/Marlin/src/gcode/stats/M31.cpp @@ -35,6 +35,5 @@ void GcodeSuite::M31() { ui.set_status(buffer); - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Print time: ", buffer); + SERIAL_ECHO_MSG("Print time: ", buffer); } 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 c44d667b8f..2b47094a4e 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 @@ -552,10 +552,8 @@ void AnycubicTFTClass::GetCommandFromTFT() { a_command = ((int)((strtod(&TFTcmdbuffer[TFTbufindw][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindw] + 1], nullptr)))); #if ENABLED(ANYCUBIC_LCD_DEBUG) - if ((a_command > 7) && (a_command != 20)) { // No debugging of status polls, please! - SERIAL_ECHOPGM("TFT Serial Command: "); - SERIAL_ECHOLN(TFTcmdbuffer[TFTbufindw]); - } + if ((a_command > 7) && (a_command != 20)) // No debugging of status polls, please! + SERIAL_ECHOLNPAIR("TFT Serial Command: ", TFTcmdbuffer[TFTbufindw]); #endif switch (a_command) { diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp index 1db1175d3c..62c66f16f2 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp @@ -1074,7 +1074,7 @@ void CLCD::init() { uint8_t device_id = mem_read_8(REG::ID); // Read Device ID, Should Be 0x7C; if (device_id == 0x7C) { #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_MSG("FTDI chip initialized "); + SERIAL_ECHO_MSG("FTDI chip initialized"); #endif break; } @@ -1082,11 +1082,10 @@ void CLCD::init() { delay(1); if (counter == 249) { - #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Timeout waiting for device ID, should be 124, got ", device_id); - #endif - } + #if ENABLED(TOUCH_UI_DEBUG) + SERIAL_ECHO_MSG("Timeout waiting for device ID, should be 124, got ", int(device_id)); + #endif + } } /* make sure that all units are in working conditions, usually the touch-controller needs a little more time */ @@ -1101,10 +1100,8 @@ void CLCD::init() { else delay(1); - if (ENABLED(TOUCH_UI_DEBUG) && counter == 99) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Timeout waiting for reset status. Should be 0x00, got ", reset_status); - } + if (ENABLED(TOUCH_UI_DEBUG) && counter == 99) + SERIAL_ECHO_MSG("Timeout waiting for reset status. Should be 0x00, got ", int(reset_status)); } mem_write_8(REG::PWM_DUTY, 0); // turn off Backlight, Frequency already is set to 250Hz default diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/event_loop.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/event_loop.cpp index 6c0392c200..78d5f2483e 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/event_loop.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/event_loop.cpp @@ -124,8 +124,7 @@ namespace FTDI { case UNPRESSED: if (tag != 0) { #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Touch start: ", tag); + SERIAL_ECHO_MSG("Touch start: ", int(tag)); #endif pressed_tag = tag; @@ -186,8 +185,7 @@ namespace FTDI { if (UIData::flags.bits.touch_end_sound) sound.play(unpress_sound); #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("Touch end: ", pressed_tag); + SERIAL_ECHO_MSG("Touch end: ", int(pressed_tag)); #endif const uint8_t saved_pressed_tag = pressed_tag; 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 944237bd28..a0b434818a 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 @@ -43,8 +43,7 @@ void ScreenRef::setScreen(onRedraw_func_t onRedraw_ptr) { if (type != 0xFF) { setType(type); #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("New screen: ", type); + SERIAL_ECHO_MSG("New screen: ", int(type)); #endif } } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp index 65b996dd51..fb8dc3edf3 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp @@ -127,8 +127,7 @@ void BioPrintingDialogBox::setStatusMessage(const char* message) { storeBackground(); #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("New status message: ", message); + SERIAL_ECHO_MSG("New status message: ", message); #endif if (AT_SCREEN(BioPrintingDialogBox)) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6908635d6e..089481d076 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -2946,7 +2946,7 @@ void MarlinSettings::reset() { } #define CONFIG_ECHO_START() do{ if (!forReplay) SERIAL_ECHO_START(); }while(0) - #define CONFIG_ECHO_MSG(STR) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPGM(STR); }while(0) + #define CONFIG_ECHO_MSG(V...) do{ CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR(V); }while(0) #define CONFIG_ECHO_HEADING(STR) config_heading(forReplay, PSTR(STR)) #if HAS_TRINAMIC_CONFIG @@ -3039,26 +3039,24 @@ void MarlinSettings::reset() { } #if EXTRUDERS == 1 - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M200 S", int(parser.volumetric_enabled) - , " D", LINEAR_UNIT(planner.filament_size[0]) - #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[0]) - #endif - ); + CONFIG_ECHO_MSG(" M200 S", int(parser.volumetric_enabled) + , " D", LINEAR_UNIT(planner.filament_size[0]) + #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) + , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[0]) + #endif + ); #else LOOP_L_N(i, EXTRUDERS) { - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M200 T", int(i) - , " D", LINEAR_UNIT(planner.filament_size[i]) - #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[i]) - #endif - ); + CONFIG_ECHO_MSG(" M200 T", int(i) + , " D", LINEAR_UNIT(planner.filament_size[i]) + #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) + , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[i]) + #endif + ); } - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M200 S", int(parser.volumetric_enabled)); + CONFIG_ECHO_MSG(" M200 S", int(parser.volumetric_enabled)); #endif + #endif // EXTRUDERS && !NO_VOLUMETRICS CONFIG_ECHO_HEADING("Steps per unit:"); @@ -3194,7 +3192,7 @@ void MarlinSettings::reset() { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( - PSTR(" M420 S"), planner.leveling_active ? 1 : 0 + PSTR(" M420 S"), int(planner.leveling_active) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) , SP_Z_STR, LINEAR_UNIT(planner.z_fade_height) #endif @@ -3260,8 +3258,7 @@ void MarlinSettings::reset() { #elif ENABLED(BLTOUCH) || (HAS_Z_SERVO_PROBE && defined(Z_SERVO_ANGLES)) case Z_PROBE_SERVO_NR: #endif - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M281 P", int(i), " L", servo_angles[i][0], " U", servo_angles[i][1]); + CONFIG_ECHO_MSG(" M281 P", int(i), " L", servo_angles[i][0], " U", servo_angles[i][1]); default: break; } } @@ -3382,8 +3379,7 @@ void MarlinSettings::reset() { #endif // PIDTEMP #if ENABLED(PIDTEMPBED) - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR( + CONFIG_ECHO_MSG( " M304 P", thermalManager.temp_bed.pid.Kp , " I", unscalePID_i(thermalManager.temp_bed.pid.Ki) , " D", unscalePID_d(thermalManager.temp_bed.pid.Kd) @@ -3400,16 +3396,14 @@ void MarlinSettings::reset() { #if HAS_LCD_CONTRAST CONFIG_ECHO_HEADING("LCD Contrast:"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M250 C", ui.contrast); + CONFIG_ECHO_MSG(" M250 C", ui.contrast); #endif TERN_(CONTROLLER_FAN_EDITABLE, M710_report(forReplay)); #if ENABLED(POWER_LOSS_RECOVERY) CONFIG_ECHO_HEADING("Power-Loss Recovery:"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M413 S", int(recovery.enabled)); + CONFIG_ECHO_MSG(" M413 S", int(recovery.enabled)); #endif #if ENABLED(FWRETRACT) @@ -3424,8 +3418,7 @@ void MarlinSettings::reset() { ); CONFIG_ECHO_HEADING("Recover: S F"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR( + CONFIG_ECHO_MSG( " M208 S", LINEAR_UNIT(fwretract.settings.retract_recover_extra) , " W", LINEAR_UNIT(fwretract.settings.swap_retract_recover_extra) , " F", LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_recover_feedrate_mm_s)) @@ -3434,8 +3427,7 @@ void MarlinSettings::reset() { #if ENABLED(FWRETRACT_AUTORETRACT) CONFIG_ECHO_HEADING("Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M209 S", fwretract.autoretract_enabled ? 1 : 0); + CONFIG_ECHO_MSG(" M209 S", int(fwretract.autoretract_enabled)); #endif // FWRETRACT_AUTORETRACT @@ -3780,13 +3772,10 @@ void MarlinSettings::reset() { #if ENABLED(LIN_ADVANCE) CONFIG_ECHO_HEADING("Linear Advance:"); #if EXTRUDERS < 2 - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M900 K", planner.extruder_advance_K[0]); + CONFIG_ECHO_MSG(" M900 K", planner.extruder_advance_K[0]); #else - LOOP_L_N(i, EXTRUDERS) { - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR(" M900 T", int(i), " K", planner.extruder_advance_K[i]); - } + LOOP_L_N(i, EXTRUDERS) + CONFIG_ECHO_MSG(" M900 T", int(i), " K", planner.extruder_advance_K[i]); #endif #endif @@ -3851,8 +3840,7 @@ void MarlinSettings::reset() { #if HAS_FILAMENT_SENSOR CONFIG_ECHO_HEADING("Filament runout sensor:"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR( + CONFIG_ECHO_MSG( " M412 S", int(runout.enabled) #if HAS_FILAMENT_RUNOUT_DISTANCE , " D", LINEAR_UNIT(runout.runout_distance()) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index b5820e17bf..f6d22420f2 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1037,8 +1037,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #if ENABLED(PID_BED_DEBUG) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR( + SERIAL_ECHO_MSG( " PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output, #if DISABLED(PID_OPENLOOP) STR_PID_DEBUG_PTERM, work_pid.Kp, diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 4278e6be26..191617be30 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1196,8 +1196,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_AFTER_TOOLCHANGE)); #endif - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(active_extruder)); + SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(active_extruder)); #endif // HAS_MULTI_EXTRUDER } diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index c88fdc0693..bda7f8aeba 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -270,10 +270,9 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt // Get a new directory object using the full path // and dive recursively into it. SdFile child; - if (!child.open(&parent, dosFilename, O_READ)) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_SD_CANT_OPEN_SUBDIR, dosFilename); - } + if (!child.open(&parent, dosFilename, O_READ)) + SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); + printListing(child, path); // close() is done automatically by destructor of SdFile } @@ -594,8 +593,7 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0* filespos[file_subcall_ctr] = sdpos; // For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345' - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos); + SERIAL_ECHO_MSG("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos); file_subcall_ctr++; break; @@ -941,10 +939,8 @@ void CardReader::cd(const char * relpath) { workDirParents[workDirDepth++] = workDir; TERN_(SDCARD_SORT_ALPHA, presort()); } - else { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPAIR(STR_SD_CANT_ENTER_SUBDIR, relpath); - } + else + SERIAL_ECHO_MSG(STR_SD_CANT_ENTER_SUBDIR, relpath); } int8_t CardReader::cdup() { From 67ae845b3c4c2aa1d451a878f635ddab5ac13654 Mon Sep 17 00:00:00 2001 From: "Zs.Antal" <45710979+AntoszHUN@users.noreply.github.com> Date: Fri, 5 Feb 2021 13:28:30 +0100 Subject: [PATCH 25/51] Update Hungarian language (#20996) --- Marlin/src/lcd/language/language_hu.h | 96 +++++++++++++++++++-------- 1 file changed, 70 insertions(+), 26 deletions(-) diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index 523f9c1c69..c5cd845c27 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -47,6 +47,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_MEDIA_INSERTED = _UxGT("Tároló Behelyezve"); PROGMEM Language_Str MSG_MEDIA_REMOVED = _UxGT("Tároló Eltávolítva"); PROGMEM Language_Str MSG_MEDIA_WAITING = _UxGT("Várakozás a tárolóra"); + PROGMEM Language_Str MSG_SD_INIT_FAIL = _UxGT("SD-Kártya hiba"); PROGMEM Language_Str MSG_MEDIA_READ_ERROR = _UxGT("Tároló olvasási hiba"); PROGMEM Language_Str MSG_MEDIA_USB_REMOVED = _UxGT("USB eltávolítva"); PROGMEM Language_Str MSG_MEDIA_USB_FAILED = _UxGT("USB eszköz hiba"); @@ -56,7 +57,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_MAIN = _UxGT(""); PROGMEM Language_Str MSG_ADVANCED_SETTINGS = _UxGT("További Beállítások"); PROGMEM Language_Str MSG_CONFIGURATION = _UxGT("Konfiguráció"); - PROGMEM Language_Str MSG_RUN_AUTO_FILES = _UxGT("Autoinditás"); + PROGMEM Language_Str MSG_AUTOSTART = _UxGT("Autoinditás"); PROGMEM Language_Str MSG_DISABLE_STEPPERS = _UxGT("Motorok kikapcsolása"); PROGMEM Language_Str MSG_DEBUG_MENU = _UxGT("Hiba Menü"); PROGMEM Language_Str MSG_PROGRESS_BAR_TEST = _UxGT("Haladás sáv teszt"); @@ -65,6 +66,10 @@ namespace Language_hu { PROGMEM Language_Str MSG_AUTO_HOME_Y = _UxGT("Y Kezdöpont"); PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Z Kezdöpont"); PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-Igazítás"); + PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Elektromos segéd"); + PROGMEM Language_Str MSG_ITERATION = _UxGT("G34 Ismétlés: %i"); + PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("Pontosság csökken!"); + PROGMEM Language_Str MSG_ACCURACY_ACHIEVED = _UxGT("Pontosság elérve"); PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("XYZ Kezdöpont"); PROGMEM Language_Str MSG_LEVEL_BED_WAITING = _UxGT("Kattints a kezdéshez."); PROGMEM Language_Str MSG_LEVEL_BED_NEXT_POINT = _UxGT("Következö Pont"); @@ -94,8 +99,12 @@ namespace Language_hu { PROGMEM Language_Str MSG_COOLDOWN = _UxGT("Visszahütés"); PROGMEM Language_Str MSG_CUTTER_FREQUENCY = _UxGT("Frekvencia"); PROGMEM Language_Str MSG_LASER_MENU = _UxGT("Lézer Vezérlés"); + PROGMEM Language_Str MSG_LASER_OFF = _UxGT("Lézer Ki"); + PROGMEM Language_Str MSG_LASER_ON = _UxGT("Lézer Be"); PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Lézer Teljesítmény"); PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Orsó Vezérlés"); + PROGMEM Language_Str MSG_SPINDLE_OFF = _UxGT("Orsó Ki"); + PROGMEM Language_Str MSG_SPINDLE_ON = _UxGT("Orsó Be"); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Orsó Teljesítmény"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Orsó Hátra"); PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Bekapcsolás"); @@ -114,12 +123,13 @@ namespace Language_hu { PROGMEM Language_Str MSG_MESH_X = _UxGT("Index X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Index Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Z Érték"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Egyéni Parancs"); + PROGMEM Language_Str MSG_USER_MENU = _UxGT("Egyéni parancs"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Probe Teszt"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Pont"); + PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Szonda határon kívül"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Eltérés"); PROGMEM Language_Str MSG_IDEX_MENU = _UxGT("IDEX Mód"); - PROGMEM Language_Str MSG_OFFSETS_MENU = _UxGT("Eszköz Eltolás"); + PROGMEM Language_Str MSG_OFFSETS_MENU = _UxGT("Eszköz eltolás"); PROGMEM Language_Str MSG_IDEX_MODE_AUTOPARK = _UxGT("Auto-Parkolás"); PROGMEM Language_Str MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplikálás"); PROGMEM Language_Str MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Tükrözött másolás"); @@ -129,9 +139,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_HOTEND_OFFSET_Z = _UxGT("2. fúvóka Z"); PROGMEM Language_Str MSG_UBL_DOING_G29 = _UxGT("Szintezz! G29"); PROGMEM Language_Str MSG_UBL_TOOLS = _UxGT("UBL Eszköz"); - PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Egységes Ágy Szint"); - PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Döntési Pont"); - PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Kézi Háló Építés"); + PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Egységes ágy szint"); + PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Döntési pont"); + PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Kézi háló építés"); PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Tégy alátétet és mérj"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Mérés"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Üres ágyat mérj"); @@ -148,14 +158,12 @@ namespace Language_hu { PROGMEM Language_Str MSG_UBL_DONE_EDITING_MESH = _UxGT("Háló Kész"); PROGMEM Language_Str MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Egyéni Háló Építés"); PROGMEM Language_Str MSG_UBL_BUILD_MESH_MENU = _UxGT("Háló Építés"); - #if PREHEAT_COUNT - PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Háló Építés ($)"); - PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Háló Elfogadás ($)"); - #endif - PROGMEM Language_Str MSG_UBL_BUILD_COLD_MESH = _UxGT("Hideg Háló Építés"); - PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("AHáló Magasság Állítása"); - PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Összmagasság"); + PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Háló Építés ($)"); + PROGMEM Language_Str MSG_UBL_BUILD_COLD_MESH = _UxGT("Hideg háló építés"); + PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Háló magasság állítás"); + PROGMEM Language_Str MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Magasság összege"); PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Háló Elfogadás"); + PROGMEM Language_Str MSG_UBL_VALIDATE_MESH_M = _UxGT("Háló Elfogadás ($)"); PROGMEM Language_Str MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Valódi Háló Elfogadása"); PROGMEM Language_Str MSG_G26_HEATING_BED = _UxGT("G26 Ágy Fűtés"); PROGMEM Language_Str MSG_G26_HEATING_NOZZLE = _UxGT("G26 Fúvóka Fűtés"); @@ -216,6 +224,10 @@ namespace Language_hu { PROGMEM Language_Str MSG_SET_LEDS_VIOLET = _UxGT("Viola"); PROGMEM Language_Str MSG_SET_LEDS_WHITE = _UxGT("Fehér"); PROGMEM Language_Str MSG_SET_LEDS_DEFAULT = _UxGT("Alapérték"); + PROGMEM Language_Str MSG_LED_CHANNEL_N = _UxGT("Csatorna ="); + PROGMEM Language_Str MSG_LEDS2 = _UxGT("LEDek #2"); + PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Fény #2 Megadott"); + PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Fényerő"); PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Egyéni Szín"); PROGMEM Language_Str MSG_INTENSITY_R = _UxGT("Piros Intenzitás"); PROGMEM Language_Str MSG_INTENSITY_G = _UxGT("Zöld Intenzitás"); @@ -231,7 +243,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_MOVE_E = _UxGT("Adagoló"); PROGMEM Language_Str MSG_MOVE_EN = _UxGT("Adagoló *"); PROGMEM Language_Str MSG_HOTEND_TOO_COLD = _UxGT("A fúvóka túl hideg"); - PROGMEM Language_Str MSG_MOVE_N_MM = _UxGT("Mozgás %smm"); + PROGMEM Language_Str MSG_MOVE_Z_DIST = _UxGT("Mozgás %smm"); PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Mozgás 0.1mm"); PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Mozgás 1mm"); PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Mozgás 10mm"); @@ -304,7 +316,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_TEMPERATURE = _UxGT("Höfok"); PROGMEM Language_Str MSG_MOTION = _UxGT("Mozgatások"); PROGMEM Language_Str MSG_FILAMENT = _UxGT("Nyomtatószál"); - PROGMEM Language_Str MSG_VOLUMETRIC_ENABLED = _UxGT("E mm") SUPERSCRIPT_THREE _UxGT("-ben"); + PROGMEM Language_Str MSG_VOLUMETRIC_ENABLED = _UxGT("E mm³-ben"); + PROGMEM Language_Str MSG_VOLUMETRIC_LIMIT = _UxGT("E Limit mm³-ben"); + PROGMEM Language_Str MSG_VOLUMETRIC_LIMIT_E = _UxGT("E Limit *"); PROGMEM Language_Str MSG_FILAMENT_DIAM = _UxGT("Szál. Átm."); PROGMEM Language_Str MSG_FILAMENT_DIAM_E = _UxGT("Szál. Átm. *"); PROGMEM Language_Str MSG_FILAMENT_UNLOAD = _UxGT("Kiadás mm"); @@ -326,12 +340,17 @@ namespace Language_hu { PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT(""); PROGMEM Language_Str MSG_PREPARE = _UxGT("Vezérlés"); PROGMEM Language_Str MSG_TUNE = _UxGT("Hangolás"); + PROGMEM Language_Str MSG_POWER_MONITOR = _UxGT("Teljesítménymonitor"); + PROGMEM Language_Str MSG_CURRENT = _UxGT("Jelenlegi"); + PROGMEM Language_Str MSG_VOLTAGE = _UxGT("Feszültség"); + PROGMEM Language_Str MSG_POWER = _UxGT("Energia"); PROGMEM Language_Str MSG_START_PRINT = _UxGT("Nyomtatás Indítása"); PROGMEM Language_Str MSG_BUTTON_NEXT = _UxGT("Tovább"); PROGMEM Language_Str MSG_BUTTON_INIT = _UxGT("Kezdet"); PROGMEM Language_Str MSG_BUTTON_STOP = _UxGT("Állj"); PROGMEM Language_Str MSG_BUTTON_PRINT = _UxGT("Nyomtatás"); PROGMEM Language_Str MSG_BUTTON_RESET = _UxGT("Újraindítás"); + PROGMEM Language_Str MSG_BUTTON_IGNORE = _UxGT("Mellöz"); PROGMEM Language_Str MSG_BUTTON_CANCEL = _UxGT("Mégse"); PROGMEM Language_Str MSG_BUTTON_DONE = _UxGT("Kész"); PROGMEM Language_Str MSG_BUTTON_BACK = _UxGT("Vissza"); @@ -339,6 +358,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_PAUSING = _UxGT("Szüneteltetve..."); PROGMEM Language_Str MSG_PAUSE_PRINT = _UxGT("Nyomtatás Szünetelés"); PROGMEM Language_Str MSG_RESUME_PRINT = _UxGT("Nyomtatás folytatása"); + PROGMEM Language_Str MSG_HOST_START_PRINT = _UxGT("Hoszt indítás"); PROGMEM Language_Str MSG_STOP_PRINT = _UxGT("Nyomtatás leállítása"); PROGMEM Language_Str MSG_PRINTING_OBJECT = _UxGT("Objektum Nyomtatása"); PROGMEM Language_Str MSG_CANCEL_OBJECT = _UxGT("Objektum Törlése"); @@ -361,8 +381,8 @@ namespace Language_hu { PROGMEM Language_Str MSG_CONTROL_RETRACT_ZHOP = _UxGT("Ugrás mm"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER = _UxGT("Visszah.helyre mm"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAP = _UxGT("Csere.Visszah.helyre mm"); - PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Visszavonás V"); - PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAPF = _UxGT("S Vi.vo V"); + PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Unretract V"); + PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAPF = _UxGT("S UnRet V"); PROGMEM Language_Str MSG_AUTORETRACT = _UxGT("AutoVisszah."); PROGMEM Language_Str MSG_FILAMENT_SWAP_LENGTH = _UxGT("Visszahúzás Távolság"); PROGMEM Language_Str MSG_FILAMENT_SWAP_EXTRA = _UxGT("Extra Csere"); @@ -408,16 +428,17 @@ namespace Language_hu { PROGMEM Language_Str MSG_BLTOUCH_MODE_CHANGE = _UxGT("VESZÉLY: A rossz beállítások kárt okozhatnak! Biztos továbblép?"); PROGMEM Language_Str MSG_TOUCHMI_PROBE = _UxGT("TouchMI"); PROGMEM Language_Str MSG_TOUCHMI_INIT = _UxGT("Kezd TouchMI"); - PROGMEM Language_Str MSG_TOUCHMI_ZTEST = _UxGT("Z Eltolás Teszt"); + PROGMEM Language_Str MSG_TOUCHMI_ZTEST = _UxGT("Z Offset Teszt"); PROGMEM Language_Str MSG_TOUCHMI_SAVE = _UxGT("Mentés"); PROGMEM Language_Str MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("TouchMI Használ"); - PROGMEM Language_Str MSG_MANUAL_DEPLOY = _UxGT("Z-Szonda Használ"); - PROGMEM Language_Str MSG_MANUAL_STOW = _UxGT("Z-Szonda Elhelyezés"); + PROGMEM Language_Str MSG_MANUAL_DEPLOY = _UxGT("Z-Probe Használ"); + PROGMEM Language_Str MSG_MANUAL_STOW = _UxGT("Z-Probe Elhelyezés"); PROGMEM Language_Str MSG_HOME_FIRST = _UxGT("Elsö %s%s%s Kell"); PROGMEM Language_Str MSG_ZPROBE_OFFSETS = _UxGT("Szonda Eltolások"); PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Szonda X Eltolás"); PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Szonda Y Eltolás"); PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Szonda Z Eltolás"); + PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED = _UxGT("Fúvóka az ágyhoz"); PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Mikrolépés X"); PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Mikrolépés Y"); PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Mikrolépés Z"); @@ -425,9 +446,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_ENDSTOP_ABORT = _UxGT("Végállás megszakítva!"); PROGMEM Language_Str MSG_HEATING_FAILED_LCD = _UxGT("Fütés hiba!"); PROGMEM Language_Str MSG_ERR_REDUNDANT_TEMP = _UxGT("Hiba: SZÜKSÉGTELEN HÖFOK"); - PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("FÜTÉSKIMARADÁS"); - PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("ÁGY FÜTÉSKIMARADÁS"); - PROGMEM Language_Str MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("KAMRA FÜTÉSKIMARADÁS"); + PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("FÜTÉS KIMARADÁS"); + PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("ÁGY FÜTÉS KIMARADÁS"); + PROGMEM Language_Str MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("KAMRA FÜTÉS KIMARADÁS"); PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("Hiba: MAX Höfok"); PROGMEM Language_Str MSG_ERR_MINTEMP = _UxGT("Hiba: MIN Höfok"); PROGMEM Language_Str MSG_HALTED = _UxGT("A NYOMTATÓ LEFAGYOTT"); @@ -439,6 +460,8 @@ namespace Language_hu { PROGMEM Language_Str MSG_COOLING = _UxGT("Hütés..."); PROGMEM Language_Str MSG_BED_HEATING = _UxGT("Ágy fütés..."); PROGMEM Language_Str MSG_BED_COOLING = _UxGT("Ágy hütés..."); + PROGMEM Language_Str MSG_PROBE_HEATING = _UxGT("Szonda fütése..."); + PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Szonda hütése..."); PROGMEM Language_Str MSG_CHAMBER_HEATING = _UxGT("Kamra fütés..."); PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Kamra hütés..."); PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Delta Kalibráció"); @@ -468,6 +491,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Protokoll"); PROGMEM Language_Str MSG_INFO_RUNAWAY_OFF = _UxGT("Futáselemzés: KI"); PROGMEM Language_Str MSG_INFO_RUNAWAY_ON = _UxGT("Futáselemzés: BE"); + PROGMEM Language_Str MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend üresjárati idök."); PROGMEM Language_Str MSG_CASE_LIGHT = _UxGT("Munkalámpa"); PROGMEM Language_Str MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Fényerösség"); @@ -556,6 +580,20 @@ namespace Language_hu { PROGMEM Language_Str MSG_SNAKE = _UxGT("Sn4k3"); PROGMEM Language_Str MSG_MAZE = _UxGT("Maze"); + PROGMEM Language_Str MSG_BAD_PAGE = _UxGT("Rossz oldalindex"); + PROGMEM Language_Str MSG_BAD_PAGE_SPEED = _UxGT("Rossz oldalsebesség"); + + PROGMEM Language_Str MSG_EDIT_PASSWORD = _UxGT("Jelszó szerkesztése"); + PROGMEM Language_Str MSG_LOGIN_REQUIRED = _UxGT("Belépés szükséges"); + PROGMEM Language_Str MSG_PASSWORD_SETTINGS = _UxGT("Jelszóbeállítások"); + PROGMEM Language_Str MSG_ENTER_DIGIT = _UxGT("Írja be a számokat"); + PROGMEM Language_Str MSG_CHANGE_PASSWORD = _UxGT("Jelszó Beáll/Szerk"); + PROGMEM Language_Str MSG_REMOVE_PASSWORD = _UxGT("Jelszó törlése"); + PROGMEM Language_Str MSG_PASSWORD_SET = _UxGT("A jelszó "); + PROGMEM Language_Str MSG_START_OVER = _UxGT("Újrakezdés"); + PROGMEM Language_Str MSG_REMINDER_SAVE_SETTINGS = _UxGT("Mentse el!"); + PROGMEM Language_Str MSG_PASSWORD_REMOVED = _UxGT("Jelszó törölve"); + // // Filament Change screens show up to 3 lines on a 4-line display // ...or up to 2 lines on a 3-line display @@ -571,7 +609,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_FILAMENT_CHANGE_LOAD = _UxGT(MSG_2_LINE("Várj a", "szál betöltésére")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_PURGE = _UxGT(MSG_2_LINE("Várj a", "szál tisztításra")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_CONT_PURGE = _UxGT(MSG_2_LINE("Kattints a készre", "szál tiszta")); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_2_LINE("Várj a nyomtatóra", "majd folytat...")); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_2_LINE("Várj a nyomtatóra", "majd foltyat...")); #else PROGMEM Language_Str MSG_ADVANCED_PAUSE_WAITING = _UxGT(MSG_1_LINE("Katt a folytatáshoz")); PROGMEM Language_Str MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_1_LINE("Parkolás...")); @@ -600,11 +638,17 @@ namespace Language_hu { PROGMEM Language_Str MSG_BACKLASH_CORRECTION = _UxGT("Korrekció"); PROGMEM Language_Str MSG_BACKLASH_SMOOTHING = _UxGT("Simítás"); - PROGMEM Language_Str MSG_LEVEL_X_AXIS = _UxGT("X Tengely Szint"); + PROGMEM Language_Str MSG_LEVEL_X_AXIS = _UxGT("X Tengely szint"); PROGMEM Language_Str MSG_AUTO_CALIBRATE = _UxGT("Önkalibrálás"); - PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Fűtéskimaradás"); + #if ENABLED(TOUCH_UI_FTDI_EVE) + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Tétlenségi idökorlát, a hömérséklet csökkent. Nyomja meg az OK gombot az ismételt felfűtéshez, és újra a folytatáshoz."); + #else + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Fűtés idökorlátja"); + #endif PROGMEM Language_Str MSG_REHEAT = _UxGT("Újrafűt"); PROGMEM Language_Str MSG_REHEATING = _UxGT("Újrafűtés..."); + + PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Szonda varázsló"); } #if FAN_COUNT == 1 From a9712330686609325a32c936250942a81a242e4f Mon Sep 17 00:00:00 2001 From: ellensp Date: Sat, 6 Feb 2021 02:07:10 +1300 Subject: [PATCH 26/51] Fix MKS SGen-L DOGLCD_MOSI pin for FYSETC_MINI_12864 LCD (#20998) --- Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 79c79c5914..abf5be3c89 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -337,7 +337,7 @@ #define DOGLCD_CS P0_18 #define DOGLCD_A0 P0_16 #define DOGLCD_SCK P0_07 - #define DOGLCD_MOSI P1_20 + #define DOGLCD_MOSI P0_09 #define LCD_BACKLIGHT_PIN -1 From 004bed8a7fc3ff9feb73a0ea9794635b50073c27 Mon Sep 17 00:00:00 2001 From: Chris Pepper Date: Fri, 5 Feb 2021 22:43:36 +0000 Subject: [PATCH 27/51] Mitigate RPi hosts kernel panic on M997 Work around M997 sometimes causing a kernel panic on the host when sent from a Raspbery Pi, the root cause is currently unknown. --- Marlin/src/HAL/LPC1768/HAL.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index 27aa569fae..eddd61af7d 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -63,7 +63,11 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { return ind > -1 ? ind : dval; } -void flashFirmware(const int16_t) { NVIC_SystemReset(); } +void flashFirmware(const int16_t) { + USB_Connect(FALSE); // USB clear connection + delay(2000); // Give OS time to notice + NVIC_SystemReset(); +} void HAL_clear_reset_source(void) { TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag()); From 62f060a38984ce37454ff57094c289b0fb55d92e Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 6 Feb 2021 00:12:05 +0000 Subject: [PATCH 28/51] [cron] Bump distribution date (2021-02-06) --- 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 15105bd8bf..50d13333a7 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 "2021-02-05" + #define STRING_DISTRIBUTION_DATE "2021-02-06" #endif /** From 10aaab6350cb5e54ea8376f36a5598d99f936b26 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 5 Feb 2021 18:47:53 -0600 Subject: [PATCH 29/51] Use 'false' --- Marlin/src/HAL/LPC1768/HAL.cpp | 2 +- Marlin/src/HAL/LPC1768/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index eddd61af7d..f567f26c9e 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -64,7 +64,7 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { } void flashFirmware(const int16_t) { - USB_Connect(FALSE); // USB clear connection + USB_Connect(false); // USB clear connection delay(2000); // Give OS time to notice NVIC_SystemReset(); } diff --git a/Marlin/src/HAL/LPC1768/main.cpp b/Marlin/src/HAL/LPC1768/main.cpp index f41a576376..1fbeddd9ea 100644 --- a/Marlin/src/HAL/LPC1768/main.cpp +++ b/Marlin/src/HAL/LPC1768/main.cpp @@ -119,9 +119,9 @@ void HAL_init() { #endif USB_Init(); // USB Initialization - USB_Connect(FALSE); // USB clear connection + USB_Connect(false); // USB clear connection delay(1000); // Give OS time to notice - USB_Connect(TRUE); + USB_Connect(true); #if HAS_SD_HOST_DRIVE MSC_SD_Init(0); // Enable USB SD card access From 1c19af2c8fd95ff6da86c9f8eb18166805ea0097 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Sat, 6 Feb 2021 05:43:51 +0100 Subject: [PATCH 30/51] Fix ARM delay function (#20901) --- Marlin/src/HAL/DUE/HAL_SPI.cpp | 8 +- .../dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp | 1 + .../dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp | 1 + Marlin/src/HAL/STM32/HAL.cpp | 11 -- Marlin/src/HAL/STM32/HAL.h | 1 + Marlin/src/HAL/STM32/HAL_SPI.cpp | 30 ++- Marlin/src/HAL/shared/Delay.cpp | 176 ++++++++++++++++++ Marlin/src/HAL/shared/Delay.h | 132 +++++++------ Marlin/src/MarlinCore.cpp | 3 + Marlin/src/core/macros.h | 2 + Marlin/src/gcode/gcode_d.cpp | 8 +- 11 files changed, 279 insertions(+), 94 deletions(-) create mode 100644 Marlin/src/HAL/shared/Delay.cpp diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp index 342c373735..6cb2912c12 100644 --- a/Marlin/src/HAL/DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp @@ -240,7 +240,7 @@ } // all the others - static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4µs => 125khz + static uint32_t spiDelayCyclesX4 = 4 * (F_CPU) / 1000000; // 4µs => 125khz static uint8_t spiTransferX(uint8_t b) { // using Mode 0 int bits = 8; @@ -249,12 +249,12 @@ b <<= 1; // little setup time WRITE(SD_SCK_PIN, HIGH); - __delay_4cycles(spiDelayCyclesX4); + DELAY_CYCLES(spiDelayCyclesX4); b |= (READ(SD_MISO_PIN) != 0); WRITE(SD_SCK_PIN, LOW); - __delay_4cycles(spiDelayCyclesX4); + DELAY_CYCLES(spiDelayCyclesX4); } while (--bits); return b; } @@ -510,7 +510,7 @@ spiRxBlock = (pfnSpiRxBlock)spiRxBlockX; break; default: - spiDelayCyclesX4 = ((F_CPU) / 1000000) >> (6 - spiRate); + spiDelayCyclesX4 = ((F_CPU) / 1000000) >> (6 - spiRate) << 2; // spiRate of 2 gives the maximum error with current CPU spiTransferTx = (pfnSpiTransfer)spiTransferX; spiTransferRx = (pfnSpiTransfer)spiTransferX; spiTxBlock = (pfnSpiTxBlock)spiTxBlockX; diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp index 7df180cbaa..d01cd4dd6b 100644 --- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp +++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp @@ -59,6 +59,7 @@ #if ENABLED(U8GLIB_ST7920) +#include "../../../inc/MarlinConfig.h" #include "../../shared/Delay.h" #include diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp index 615a386c35..4fb7a6e2c3 100644 --- a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp +++ b/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp @@ -59,6 +59,7 @@ #if HAS_MARLINUI_U8GLIB +#include "../../../inc/MarlinConfig.h" #include "../../shared/Delay.h" #include diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index 06744f16b8..e694a16a82 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -57,17 +57,6 @@ uint16_t HAL_adc_result; // Public functions // ------------------------ -// Needed for DELAY_NS() / DELAY_US() on CORTEX-M7 -#if (defined(__arm__) || defined(__thumb__)) && __CORTEX_M == 7 - // HAL pre-initialization task - // Force the preinit function to run between the premain() and main() function - // of the STM32 arduino core - __attribute__((constructor (102))) - void HAL_preinit() { - enableCycleCounter(); - } -#endif - // HAL initialization task void HAL_init() { FastIO_init(); diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 8f6c0a5990..be0cc30962 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -194,6 +194,7 @@ void flashFirmware(const int16_t); typedef void (*systickCallback_t)(void); void systick_attach_callback(systickCallback_t cb); void HAL_SYSTICK_Callback(); + extern volatile uint32_t systick_uptime_millis; #define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index eef480777b..c9f23e6fa3 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -51,18 +51,28 @@ static SPISettings spiConfig; OUT_WRITE(SD_MOSI_PIN, HIGH); } - static uint16_t delay_STM32_soft_spi; + // Use function with compile-time value so we can actually reach the desired frequency + // Need to adjust this a little bit: on a 72MHz clock, we have 14ns/clock + // and we'll use ~3 cycles to jump to the method and going back, so it'll take ~40ns from the given clock here + #define CALLING_COST_NS (3U * 1000000000U) / (F_CPU) + void (*delaySPIFunc)(); + void delaySPI_125() { DELAY_NS(125 - CALLING_COST_NS); } + void delaySPI_250() { DELAY_NS(250 - CALLING_COST_NS); } + void delaySPI_500() { DELAY_NS(500 - CALLING_COST_NS); } + void delaySPI_1000() { DELAY_NS(1000 - CALLING_COST_NS); } + void delaySPI_2000() { DELAY_NS(2000 - CALLING_COST_NS); } + void delaySPI_4000() { DELAY_NS(4000 - CALLING_COST_NS); } void spiInit(uint8_t spiRate) { // Use datarates Marlin uses switch (spiRate) { - case SPI_FULL_SPEED: delay_STM32_soft_spi = 125; break; // desired: 8,000,000 actual: ~1.1M - case SPI_HALF_SPEED: delay_STM32_soft_spi = 125; break; // desired: 4,000,000 actual: ~1.1M - case SPI_QUARTER_SPEED:delay_STM32_soft_spi = 250; break; // desired: 2,000,000 actual: ~890K - case SPI_EIGHTH_SPEED: delay_STM32_soft_spi = 500; break; // desired: 1,000,000 actual: ~590K - case SPI_SPEED_5: delay_STM32_soft_spi = 1000; break; // desired: 500,000 actual: ~360K - case SPI_SPEED_6: delay_STM32_soft_spi = 2000; break; // desired: 250,000 actual: ~210K - default: delay_STM32_soft_spi = 4000; break; // desired: 125,000 actual: ~123K + case SPI_FULL_SPEED: delaySPIFunc = &delaySPI_125; break; // desired: 8,000,000 actual: ~1.1M + case SPI_HALF_SPEED: delaySPIFunc = &delaySPI_125; break; // desired: 4,000,000 actual: ~1.1M + case SPI_QUARTER_SPEED:delaySPIFunc = &delaySPI_250; break; // desired: 2,000,000 actual: ~890K + case SPI_EIGHTH_SPEED: delaySPIFunc = &delaySPI_500; break; // desired: 1,000,000 actual: ~590K + case SPI_SPEED_5: delaySPIFunc = &delaySPI_1000; break; // desired: 500,000 actual: ~360K + case SPI_SPEED_6: delaySPIFunc = &delaySPI_2000; break; // desired: 250,000 actual: ~210K + default: delaySPIFunc = &delaySPI_4000; break; // desired: 125,000 actual: ~123K } SPI.begin(); } @@ -75,9 +85,9 @@ static SPISettings spiConfig; WRITE(SD_SCK_PIN, LOW); WRITE(SD_MOSI_PIN, b & 0x80); - DELAY_NS(delay_STM32_soft_spi); + delaySPIFunc(); WRITE(SD_SCK_PIN, HIGH); - DELAY_NS(delay_STM32_soft_spi); + delaySPIFunc(); b <<= 1; // little setup time b |= (READ(SD_MISO_PIN) != 0); diff --git a/Marlin/src/HAL/shared/Delay.cpp b/Marlin/src/HAL/shared/Delay.cpp new file mode 100644 index 0000000000..1ae1b3e381 --- /dev/null +++ b/Marlin/src/HAL/shared/Delay.cpp @@ -0,0 +1,176 @@ +/** + * 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 "Delay.h" + +#include "../../inc/MarlinConfig.h" + +#if defined(__arm__) || defined(__thumb__) + + static uint32_t ASM_CYCLES_PER_ITERATION = 4; // Initial bet which will be adjusted in calibrate_delay_loop + + // Simple assembler loop counting down + void delay_asm(uint32_t cy) { + cy = _MAX(cy / ASM_CYCLES_PER_ITERATION, 1U); // Zero is forbidden here + __asm__ __volatile__( + A(".syntax unified") // is to prevent CM0,CM1 non-unified syntax + L("1") + A("subs %[cnt],#1") + A("bne 1b") + : [cnt]"+r"(cy) // output: +r means input+output + : // input: + : "cc" // clobbers: + ); + } + + // We can't use CMSIS since it's not available on all platform, so fallback to hardcoded register values + #define HW_REG(X) *(volatile uint32_t *)(X) + #define _DWT_CTRL 0xE0001000 + #define _DWT_CYCCNT 0xE0001004 // CYCCNT is 32bits, takes 37s or so to wrap. + #define _DEM_CR 0xE000EDFC + #define _LAR 0xE0001FB0 + + // Use hardware cycle counter instead, it's much safer + void delay_dwt(uint32_t count) { + // Reuse the ASM_CYCLES_PER_ITERATION variable to avoid wasting another useless variable + register uint32_t start = HW_REG(_DWT_CYCCNT) - ASM_CYCLES_PER_ITERATION, elapsed; + do { + elapsed = HW_REG(_DWT_CYCCNT) - start; + } while (elapsed < count); + } + + // Pointer to asm function, calling the functions has a ~20 cycles overhead + DelayImpl DelayCycleFnc = delay_asm; + + void calibrate_delay_loop() { + // Check if we have a working DWT implementation in the CPU (see https://developer.arm.com/documentation/ddi0439/b/Data-Watchpoint-and-Trace-Unit/DWT-Programmers-Model) + if (!HW_REG(_DWT_CTRL)) { + // No DWT present, so fallback to plain old ASM nop counting + // Unfortunately, we don't exactly know how many iteration it'll take to decrement a counter in a loop + // It depends on the CPU architecture, the code current position (flash vs SRAM) + // So, instead of wild guessing and making mistake, instead + // compute it once for all + ASM_CYCLES_PER_ITERATION = 1; + // We need to fetch some reference clock before waiting + cli(); + uint32_t start = micros(); + delay_asm(1000); // On a typical CPU running in MHz, waiting 1000 "unknown cycles" means it'll take between 1ms to 6ms, that's perfectly acceptable + uint32_t end = micros(); + sei(); + uint32_t expectedCycles = (end - start) * ((F_CPU) / 1000000UL); // Convert microseconds to cycles + // Finally compute the right scale + ASM_CYCLES_PER_ITERATION = (uint32_t)(expectedCycles / 1000); + + // No DWT present, likely a Cortex M0 so NOP counting is our best bet here + DelayCycleFnc = delay_asm; + } + else { + // Enable DWT counter + // From https://stackoverflow.com/a/41188674/1469714 + HW_REG(_DEM_CR) = HW_REG(_DEM_CR) | 0x01000000; // Enable trace + #if __CORTEX_M == 7 + HW_REG(_LAR) = 0xC5ACCE55; // Unlock access to DWT registers, see https://developer.arm.com/documentation/ihi0029/e/ section B2.3.10 + #endif + HW_REG(_DWT_CYCCNT) = 0; // Clear DWT cycle counter + HW_REG(_DWT_CTRL) = HW_REG(_DWT_CTRL) | 1; // Enable DWT cycle counter + + // Then calibrate the constant offset from the counter + ASM_CYCLES_PER_ITERATION = 0; + uint32_t s = HW_REG(_DWT_CYCCNT); + uint32_t e = HW_REG(_DWT_CYCCNT); // (e - s) contains the number of cycle required to read the cycle counter + delay_dwt(0); + uint32_t f = HW_REG(_DWT_CYCCNT); // (f - e) contains the delay to call the delay function + the time to read the cycle counter + ASM_CYCLES_PER_ITERATION = (f - e) - (e - s); + + // Use safer DWT function + DelayCycleFnc = delay_dwt; + } + } + + #if ENABLED(MARLIN_DEV_MODE) + void dump_delay_accuracy_check() + { + auto report_call_time = [](PGM_P const name, const uint32_t cycles, const uint32_t total, const bool do_flush=true) { + SERIAL_ECHOPGM("Calling "); + serialprintPGM(name); + SERIAL_ECHOLNPAIR(" for ", cycles, "cycles took: ", total, "cycles"); + if (do_flush) SERIAL_FLUSH(); + }; + + uint32_t s, e; + + SERIAL_ECHOLNPAIR("Computed delay calibration value: ", ASM_CYCLES_PER_ITERATION); + SERIAL_FLUSH(); + // Display the results of the calibration above + constexpr uint32_t testValues[] = { 1, 5, 10, 20, 50, 100, 150, 200, 350, 500, 750, 1000 }; + for (auto i : testValues) { + s = micros(); DELAY_US(i); e = micros(); + report_call_time(PSTR("delay"), i, e - s); + } + + if (HW_REG(_DWT_CTRL)) { + for (auto i : testValues) { + s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(i); e = HW_REG(_DWT_CYCCNT); + report_call_time(PSTR("delay"), i, e - s); + } + + // Measure the delay to call a real function compared to a function pointer + s = HW_REG(_DWT_CYCCNT); delay_dwt(1); e = HW_REG(_DWT_CYCCNT); + report_call_time(PSTR("delay_dwt"), 1, e - s); + + static PGMSTR(dcd, "DELAY_CYCLES directly "); + + s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 1); e = HW_REG(_DWT_CYCCNT); + report_call_time(dcd, 1, e - s, false); + + s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 5); e = HW_REG(_DWT_CYCCNT); + report_call_time(dcd, 5, e - s, false); + + s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(10); e = HW_REG(_DWT_CYCCNT); + report_call_time(dcd, 10, e - s, false); + + s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(20); e = HW_REG(_DWT_CYCCNT); + report_call_time(dcd, 20, e - s, false); + + s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(50); e = HW_REG(_DWT_CYCCNT); + report_call_time(dcd, 50, e - s, false); + + s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(100); e = HW_REG(_DWT_CYCCNT); + report_call_time(dcd, 100, e - s, false); + + s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(200); e = HW_REG(_DWT_CYCCNT); + report_call_time(dcd, 200, e - s, false); + } + } + #endif // MARLIN_DEV_MODE + + +#else + + void calibrate_delay_loop() {} + #if ENABLED(MARLIN_DEV_MODE) + void dump_delay_accuracy_check() { + static PGMSTR(none, "N/A on this platform"); + serialprintPGM(none); + } + #endif + +#endif diff --git a/Marlin/src/HAL/shared/Delay.h b/Marlin/src/HAL/shared/Delay.h index a48f3f79cf..dc1f158b44 100644 --- a/Marlin/src/HAL/shared/Delay.h +++ b/Marlin/src/HAL/shared/Delay.h @@ -21,6 +21,8 @@ */ #pragma once +#include "../../inc/MarlinConfigPre.h" + /** * Busy wait delay cycles routines: * @@ -31,79 +33,68 @@ #include "../../core/macros.h" +void calibrate_delay_loop(); + #if defined(__arm__) || defined(__thumb__) - #if __CORTEX_M == 7 + // We want to have delay_cycle function with the lowest possible overhead, so we adjust at the function at runtime based on the current CPU best feature + typedef void (*DelayImpl)(uint32_t); + extern DelayImpl DelayCycleFnc; - // Cortex-M3 through M7 can use the cycle counter of the DWT unit - // https://www.anthonyvh.com/2017/05/18/cortex_m-cycle_counter/ + // I've measured 36 cycles on my system to call the cycle waiting method, but it shouldn't change much to have a bit more margin, it only consume a bit more flash + #define TRIP_POINT_FOR_CALLING_FUNCTION 40 - FORCE_INLINE static void enableCycleCounter() { - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - #if __CORTEX_M == 7 - DWT->LAR = 0xC5ACCE55; // Unlock DWT on the M7 - #endif - - DWT->CYCCNT = 0; - DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; + // A simple recursive template class that output exactly one 'nop' of code per recursion + template struct NopWriter { + FORCE_INLINE static void build() { + __asm__ __volatile__("nop"); + NopWriter::build(); } + }; + // End the loop + template <> struct NopWriter<0> { FORCE_INLINE static void build() {} }; - FORCE_INLINE volatile uint32_t getCycleCount() { return DWT->CYCCNT; } - - FORCE_INLINE static void DELAY_CYCLES(const uint32_t x) { - const uint32_t endCycles = getCycleCount() + x; - while (PENDING(getCycleCount(), endCycles)) {} - } - - #else - - // https://blueprints.launchpad.net/gcc-arm-embedded/+spec/delay-cycles - - #define nop() __asm__ __volatile__("nop;\n\t":::) - - FORCE_INLINE static void __delay_4cycles(uint32_t cy) { // +1 cycle - #if ARCH_PIPELINE_RELOAD_CYCLES < 2 - #define EXTRA_NOP_CYCLES A("nop") - #else - #define EXTRA_NOP_CYCLES "" - #endif - - __asm__ __volatile__( - A(".syntax unified") // is to prevent CM0,CM1 non-unified syntax - L("1") - A("subs %[cnt],#1") - EXTRA_NOP_CYCLES - A("bne 1b") - : [cnt]"+r"(cy) // output: +r means input+output - : // input: - : "cc" // clobbers: - ); - } - - // Delay in cycles - FORCE_INLINE static void DELAY_CYCLES(uint32_t x) { - - if (__builtin_constant_p(x)) { - #define MAXNOPS 4 - - if (x <= (MAXNOPS)) { - switch (x) { case 4: nop(); case 3: nop(); case 2: nop(); case 1: nop(); } - } - else { // because of +1 cycle inside delay_4cycles - const uint32_t rem = (x - 1) % (MAXNOPS); - switch (rem) { case 3: nop(); case 2: nop(); case 1: nop(); } - if ((x = (x - 1) / (MAXNOPS))) - __delay_4cycles(x); // if need more then 4 nop loop is more optimal - } - #undef MAXNOPS + namespace Private { + // Split recursing template in 2 different class so we don't reach the maximum template instantiation depth limit + template struct Helper { + FORCE_INLINE static void build() { + DelayCycleFnc(N - 2); // Approximative cost of calling the function (might be off by one or 2 cycles) } - else if ((x >>= 2)) - __delay_4cycles(x); - } - #undef nop + }; - #endif + template struct Helper { + FORCE_INLINE static void build() { + NopWriter::build(); + } + }; + + template <> struct Helper { + FORCE_INLINE static void build() {} + }; + + } + // Select a behavior based on the constexpr'ness of the parameter + // If called with a compile-time parameter, then write as many NOP as required to reach the asked cycle count + // (there is some tripping point here to start looping when it's more profitable than gruntly executing NOPs) + // If not called from a compile-time parameter, fallback to a runtime loop counting version instead + template + struct SmartDelay { + FORCE_INLINE SmartDelay(int) { + if (Cycles == 0) return; + Private::Helper::build(); + } + }; + // Runtime version below. There is no way this would run under less than ~TRIP_POINT_FOR_CALLING_FUNCTION cycles + template + struct SmartDelay { + FORCE_INLINE SmartDelay(int v) { DelayCycleFnc(v); } + }; + + #define DELAY_CYCLES(X) do { SmartDelay _smrtdly_X(X); } while(0) + + // For delay in microseconds, no smart delay selection is required, directly call the delay function + // Teensy compiler is too old and does not accept smart delay compile-time / run-time selection correctly + #define DELAY_US(x) DelayCycleFnc((x) * ((F_CPU) / 1000000UL)) #elif defined(__AVR__) @@ -144,10 +135,15 @@ } #undef nop + // Delay in microseconds + #define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL)) + #elif defined(__PLAT_LINUX__) || defined(ESP32) - // specified inside platform + // DELAY_CYCLES specified inside platform + // Delay in microseconds + #define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL)) #else #error "Unsupported MCU architecture" @@ -157,5 +153,5 @@ // Delay in nanoseconds #define DELAY_NS(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL) / 1000UL) -// Delay in microseconds -#define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL)) + + diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index f0d4fa05a6..626f934ddc 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1005,6 +1005,9 @@ void setup() { SERIAL_ECHO_MSG("Compiled: " __DATE__); SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, (int)sizeof(block_t) * (BLOCK_BUFFER_SIZE)); + // Some HAL need precise delay adjustment + calibrate_delay_loop(); + // Init buzzer pin(s) #if USE_BEEPER SETUP_RUN(buzzer.init()); diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 905b85d56d..8361248e1c 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -61,6 +61,8 @@ #define _O2 __attribute__((optimize("O2"))) #define _O3 __attribute__((optimize("O3"))) +#define IS_CONSTEXPR(...) __builtin_constant_p(__VA_ARGS__) // Only valid solution with C++14. Should use std::is_constant_evaluated() in C++20 instead + #ifndef UNUSED #define UNUSED(x) ((void)(x)) #endif diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 0bd2955875..653ae6a553 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -30,6 +30,8 @@ #include "../HAL/shared/eeprom_if.h" #include "../HAL/shared/Delay.h" + extern void dump_delay_accuracy_check(); + /** * Dn: G-code for development and testing * @@ -141,7 +143,7 @@ } } break; - case 5: { // D4 Read / Write onboard Flash + case 5: { // D5 Read / Write onboard Flash #define FLASH_SIZE 1024 uint8_t *pointer = parser.hex_adr_val('A'); uint16_t len = parser.ushortval('C', 1); @@ -162,6 +164,10 @@ } } break; + case 6: // D6 Check delay loop accuracy + dump_delay_accuracy_check(); + break; + case 100: { // D100 Disable heaters and attempt a hard hang (Watchdog Test) SERIAL_ECHOLNPGM("Disabling heaters and attempting to trigger Watchdog"); SERIAL_ECHOLNPGM("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")"); From ee66d9ccf9772206d151cf821b5adff2081423bb Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Wed, 3 Feb 2021 10:03:48 -0700 Subject: [PATCH 31/51] Refactor FTDI EVE Touch Screen (#20987) --- .../ftdi_eve_lib/extended/screen_types.cpp | 4 +- .../ftdi_eve_lib/extended/screen_types.h | 14 +- .../screens/about_screen.cpp | 7 +- .../ftdi_eve_touch_ui/screens/about_screen.h | 33 + .../screens/advanced_settings_menu.cpp | 7 +- .../screens/advanced_settings_menu.h | 32 + .../screens/alert_dialog_box.cpp | 15 +- .../screens/alert_dialog_box.h | 39 + .../screens/backlash_compensation_screen.cpp | 7 +- .../screens/backlash_compensation_screen.h | 32 + .../base_numeric_adjustment_screen.cpp | 21 +- .../screens/base_numeric_adjustment_screen.h | 87 ++ .../ftdi_eve_touch_ui/screens/base_screen.cpp | 7 +- .../ftdi_eve_touch_ui/screens/base_screen.h | 43 + .../screens/bed_mesh_screen.cpp | 51 +- .../screens/bed_mesh_screen.h | 62 ++ .../screens/bio_advanced_settings.cpp | 7 +- .../screens/bio_advanced_settings.h | 32 + .../screens/bio_confirm_home_e.cpp | 7 +- .../screens/bio_confirm_home_e.h | 32 + .../screens/bio_confirm_home_xyz.cpp | 7 +- .../screens/bio_confirm_home_xyz.h | 32 + .../screens/bio_main_menu.cpp | 7 +- .../ftdi_eve_touch_ui/screens/bio_main_menu.h | 32 + .../screens/bio_printing_dialog_box.cpp | 7 +- .../screens/bio_printing_dialog_box.h | 44 + .../screens/bio_status_screen.cpp | 7 +- .../screens/bio_status_screen.h | 56 ++ .../screens/bio_tune_menu.cpp | 7 +- .../ftdi_eve_touch_ui/screens/bio_tune_menu.h | 35 + .../ftdi_eve_touch_ui/screens/boot_screen.cpp | 7 +- .../ftdi_eve_touch_ui/screens/boot_screen.h | 35 + .../screens/case_light_screen.cpp | 7 +- .../screens/case_light_screen.h | 31 + .../screens/change_filament_screen.cpp | 61 +- .../screens/change_filament_screen.h | 51 ++ .../cocoa_press_advanced_settings_menu.cpp | 7 +- .../cocoa_press_advanced_settings_menu.h | 32 + .../screens/cocoa_press_load_chocolate.cpp | 7 +- .../screens/cocoa_press_load_chocolate.h | 34 + .../screens/cocoa_press_main_menu.cpp | 7 +- .../screens/cocoa_press_main_menu.h | 33 + .../screens/cocoa_press_move_e_screen.cpp | 7 +- .../screens/cocoa_press_move_e_screen.h | 33 + .../screens/cocoa_press_move_xyz_screen.cpp | 11 +- .../screens/cocoa_press_move_xyz_screen.h | 33 + .../screens/cocoa_press_preheat_menu.cpp | 7 +- .../screens/cocoa_press_preheat_menu.h | 31 + .../screens/cocoa_press_preheat_screen.cpp | 13 +- .../screens/cocoa_press_preheat_screen.h | 46 + .../screens/cocoa_press_status_screen.cpp | 7 +- .../screens/cocoa_press_status_screen.h | 55 ++ .../screens/cocoa_press_unload_cartridge.cpp | 7 +- .../screens/cocoa_press_unload_cartridge.h | 34 + .../confirm_abort_print_dialog_box.cpp | 7 +- .../screens/confirm_abort_print_dialog_box.h | 32 + .../confirm_auto_calibration_dialog_box.cpp | 7 +- .../confirm_auto_calibration_dialog_box.h | 32 + .../confirm_erase_flash_dialog_box.cpp | 7 +- .../screens/confirm_erase_flash_dialog_box.h | 32 + .../confirm_start_print_dialog_box.cpp | 13 +- .../screens/confirm_start_print_dialog_box.h | 43 + .../confirm_user_request_alert_box.cpp | 9 +- .../screens/confirm_user_request_alert_box.h | 35 + .../screens/custom_user_menus.cpp | 7 +- .../screens/custom_user_menus.h | 32 + .../screens/default_acceleration_screen.cpp | 7 +- .../screens/default_acceleration_screen.h | 32 + .../screens/developer_menu.cpp | 7 +- .../screens/developer_menu.h | 32 + .../screens/dialog_box_base_class.cpp | 7 +- .../screens/dialog_box_base_class.h | 40 + .../screens/display_tuning_screen.cpp | 7 +- .../screens/display_tuning_screen.h | 32 + .../screens/endstop_state_screen.cpp | 7 +- .../screens/endstop_state_screen.h | 35 + .../screens/feedrate_percent_screen.cpp | 7 +- .../screens/feedrate_percent_screen.h | 32 + .../screens/filament_menu.cpp | 7 +- .../ftdi_eve_touch_ui/screens/filament_menu.h | 32 + .../screens/filament_runout_screen.cpp | 7 +- .../screens/filament_runout_screen.h | 32 + .../screens/files_screen.cpp | 69 +- .../ftdi_eve_touch_ui/screens/files_screen.h | 75 ++ .../screens/interface_settings_screen.cpp | 24 +- .../screens/interface_settings_screen.h | 67 ++ .../screens/interface_sounds_screen.cpp | 15 +- .../screens/interface_sounds_screen.h | 57 ++ .../ftdi_eve_touch_ui/screens/jerk_screen.cpp | 7 +- .../ftdi_eve_touch_ui/screens/jerk_screen.h | 32 + .../screens/junction_deviation_screen.cpp | 13 +- .../screens/junction_deviation_screen.h | 32 + .../ftdi_eve_touch_ui/screens/kill_screen.cpp | 7 +- .../ftdi_eve_touch_ui/screens/kill_screen.h | 33 + .../screens/language_menu.cpp | 10 +- .../ftdi_eve_touch_ui/screens/language_menu.h | 32 + .../screens/leveling_menu.cpp | 7 +- .../ftdi_eve_touch_ui/screens/leveling_menu.h | 32 + .../screens/linear_advance_screen.cpp | 7 +- .../screens/linear_advance_screen.h | 32 + .../ftdi_eve_touch_ui/screens/lock_screen.cpp | 28 +- .../ftdi_eve_touch_ui/screens/lock_screen.h | 53 ++ .../ftdi_eve_touch_ui/screens/main_menu.cpp | 7 +- .../lib/ftdi_eve_touch_ui/screens/main_menu.h | 33 + .../screens/max_acceleration_screen.cpp | 7 +- .../screens/max_acceleration_screen.h | 32 + .../screens/max_velocity_screen.cpp | 7 +- .../screens/max_velocity_screen.h | 32 + .../screens/media_player_screen.cpp | 7 +- .../screens/media_player_screen.h | 40 + .../screens/move_axis_screen.cpp | 37 +- .../screens/move_axis_screen.h | 48 + .../screens/nozzle_offsets_screen.cpp | 7 +- .../screens/nozzle_offsets_screen.h | 33 + .../screens/nudge_nozzle_screen.cpp | 45 +- .../screens/nudge_nozzle_screen.h | 44 + .../screens/restore_failsafe_dialog_box.cpp | 7 +- .../screens/restore_failsafe_dialog_box.h | 32 + .../screens/save_settings_dialog_box.cpp | 7 +- .../screens/save_settings_dialog_box.h | 38 + .../ftdi_eve_touch_ui/screens/screen_data.h | 95 +- .../lib/ftdi_eve_touch_ui/screens/screens.cpp | 192 ++-- .../lib/ftdi_eve_touch_ui/screens/screens.h | 825 ++---------------- .../screens/spinner_dialog_box.cpp | 17 +- .../screens/spinner_dialog_box.h | 41 + .../screens/statistics_screen.cpp | 7 +- .../screens/statistics_screen.h | 32 + .../screens/status_screen.cpp | 7 +- .../ftdi_eve_touch_ui/screens/status_screen.h | 45 + .../stepper_bump_sensitivity_screen.cpp | 11 +- .../screens/stepper_bump_sensitivity_screen.h | 32 + .../screens/stepper_current_screen.cpp | 7 +- .../screens/stepper_current_screen.h | 32 + .../screens/steps_screen.cpp | 7 +- .../ftdi_eve_touch_ui/screens/steps_screen.h | 32 + .../screens/stress_test_screen.cpp | 23 +- .../screens/stress_test_screen.h | 48 + .../screens/temperature_screen.cpp | 13 +- .../screens/temperature_screen.h | 32 + .../screens/touch_calibration_screen.cpp | 7 +- .../screens/touch_calibration_screen.h | 34 + .../screens/touch_registers_screen.cpp | 7 +- .../screens/touch_registers_screen.h | 32 + .../ftdi_eve_touch_ui/screens/tune_menu.cpp | 7 +- .../lib/ftdi_eve_touch_ui/screens/tune_menu.h | 35 + .../screens/widget_demo_screen.cpp | 7 +- .../screens/widget_demo_screen.h | 34 + .../screens/z_offset_screen.cpp | 7 +- .../screens/z_offset_screen.h | 32 + .../lib/mks_ui/draw_tmc_current_settings.h | 1 - Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h | 3 - .../src/lcd/extui/lib/mks_ui/draw_wifi_tips.h | 1 - 152 files changed, 3378 insertions(+), 1370 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/alert_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/backlash_compensation_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_advanced_settings.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_e.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_main_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_tune_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/case_light_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_abort_print_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_erase_flash_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_start_print_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_user_request_alert_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/default_acceleration_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/developer_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/dialog_box_base_class.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/display_tuning_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/feedrate_percent_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_runout_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_sounds_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/jerk_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/junction_deviation_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/kill_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/language_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/lock_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/main_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_acceleration_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/media_player_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/save_settings_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/spinner_dialog_box.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/statistics_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_bump_sensitivity_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_registers_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/tune_menu.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/widget_demo_screen.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/z_offset_screen.h 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 a0b434818a..d76b897e0f 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 < tableSize(); type++) { if (GET_METHOD(type, onRedraw) == onRedraw_ptr) { return type; } @@ -49,7 +49,7 @@ 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 < tableSize(); type++) GET_METHOD(type, onStartup)(); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.h index 1581cbbbc7..94d6d4e26c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/screen_types.h @@ -50,7 +50,11 @@ typedef enum { #define GET_METHOD(type, method) reinterpret_cast(pgm_read_ptr_far(&functionTable[type].method##_ptr)) #define SCREEN_TABLE PROGMEM const ScreenRef::table_t ScreenRef::functionTable[] = -#define SCREEN_TABLE_POST const uint8_t ScreenRef::functionTableSize = sizeof(ScreenRef::functionTable)/sizeof(ScreenRef::functionTable[0]); +#define SCREEN_TABLE_POST size_t ScreenRef::tableSize() { \ + constexpr size_t siz = sizeof(functionTable)/sizeof(functionTable[0]); \ + static_assert(siz > 0, "The screen table is empty!"); \ + return siz; \ + } class ScreenRef { protected: @@ -79,14 +83,12 @@ class ScreenRef { uint8_t type = 0; static PROGMEM const table_t functionTable[]; - static const uint8_t functionTableSize; public: - uint8_t getType() {return type;} + static size_t tableSize(); - void setType(uint8_t t) { - type = t; - } + uint8_t getType() {return type;} + void setType(uint8_t t) {type = t;} uint8_t lookupScreen(onRedraw_func_t onRedraw_ptr); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.cpp index 952f0cac02..1d8db12ef9 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_ABOUT_SCREEN + #define GRID_COLS 4 #define GRID_ROWS 7 @@ -113,4 +112,4 @@ bool AboutScreen::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_ABOUT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.h new file mode 100644 index 0000000000..b9d94f08b3 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/about_screen.h @@ -0,0 +1,33 @@ +/****************** + * about_screen.h * + ******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_ABOUT_SCREEN +#define FTDI_ABOUT_SCREEN_CLASS AboutScreen + +class AboutScreen : public BaseScreen, public UncachedScreen { + public: + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp index 9036fc144b..b9255c11b9 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && NONE(TOUCH_UI_LULZBOT_BIO, TOUCH_UI_COCOA_PRESS) - #include "screens.h" +#ifdef FTDI_ADVANCED_SETTINGS_MENU + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -153,4 +152,4 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && !TOUCH_UI_LULZBOT_BIO +#endif // FTDI_ADVANCED_SETTINGS_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.h new file mode 100644 index 0000000000..a7e34fe6fe --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.h @@ -0,0 +1,32 @@ +/*************************** + * advance_settings_menu.h * + ***************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_ADVANCED_SETTINGS_MENU +#define FTDI_ADVANCED_SETTINGS_MENU_CLASS AdvancedSettingsMenu + +class AdvancedSettingsMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/alert_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/alert_dialog_box.cpp index d63119afe5..bbe922ad5d 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/alert_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/alert_dialog_box.cpp @@ -21,18 +21,19 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_ALERT_DIALOG_BOX + +constexpr static AlertDialogBoxData &mydata = screen_data.AlertDialogBox; + using namespace FTDI; using namespace Theme; void AlertDialogBox::onEntry() { BaseScreen::onEntry(); - sound.play(screen_data.AlertDialog.isError ? sad_trombone : twinkle, PLAY_ASYNCHRONOUS); + sound.play(mydata.isError ? sad_trombone : twinkle, PLAY_ASYNCHRONOUS); } void AlertDialogBox::onRedraw(draw_mode_t what) { @@ -45,7 +46,7 @@ template void AlertDialogBox::show(const T message) { drawMessage(message); storeBackground(); - screen_data.AlertDialog.isError = false; + mydata.isError = false; GOTO_SCREEN(AlertDialogBox); } @@ -53,7 +54,7 @@ template void AlertDialogBox::showError(const T message) { drawMessage(message); storeBackground(); - screen_data.AlertDialog.isError = true; + mydata.isError = true; GOTO_SCREEN(AlertDialogBox); } @@ -67,4 +68,4 @@ template void AlertDialogBox::show(const progmem_str); template void AlertDialogBox::showError(const char *); template void AlertDialogBox::showError(const progmem_str); -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_ALERT_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/alert_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/alert_dialog_box.h new file mode 100644 index 0000000000..0186acf7a0 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/alert_dialog_box.h @@ -0,0 +1,39 @@ +/********************** + * alert_dialog_box.h * + **********************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_ALERT_DIALOG_BOX +#define FTDI_ALERT_DIALOG_BOX_CLASS AlertDialogBox + +struct AlertDialogBoxData { + bool isError; +}; + +class AlertDialogBox : public DialogBoxBaseClass, public CachedScreen { + public: + static void onEntry(); + static void onRedraw(draw_mode_t); + template static void show(T); + template static void showError(T); + static void hide(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/backlash_compensation_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/backlash_compensation_screen.cpp index 58f4544ffc..11fb72b5a8 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/backlash_compensation_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/backlash_compensation_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, BACKLASH_GCODE) - #include "screens.h" +#ifdef FTDI_BACKLASH_COMP_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -73,4 +72,4 @@ bool BacklashCompensationScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_BACKLASH_COMP_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/backlash_compensation_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/backlash_compensation_screen.h new file mode 100644 index 0000000000..b9e46eb27f --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/backlash_compensation_screen.h @@ -0,0 +1,32 @@ +/********************************** + * backlash_compensation_screen.h * + **********************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BACKLASH_COMP_SCREEN +#define FTDI_BACKLASH_COMP_SCREEN_CLASS BacklashCompensationScreen + +class BacklashCompensationScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.cpp index 5271df3022..3b40e7f14e 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.cpp @@ -21,15 +21,16 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_BASE_NUMERIC_ADJ_SCREEN + using namespace FTDI; using namespace Theme; +constexpr static BaseNumericAdjustmentScreenData &mydata = screen_data.BaseNumericAdjustmentScreen; + #if ENABLED(TOUCH_UI_PORTRAIT) #define GRID_COLS 13 #define GRID_ROWS 10 @@ -116,8 +117,8 @@ void BaseNumericAdjustmentScreen::widgets_t::_button(CommandProcessor &cmd, uint BaseNumericAdjustmentScreen::widgets_t &BaseNumericAdjustmentScreen::widgets_t::precision(uint8_t decimals, precision_default_t initial) { _decimals = decimals; - if (screen_data.BaseNumericAdjustment.increment == 0) { - screen_data.BaseNumericAdjustment.increment = 243 + (initial - DEFAULT_LOWEST) - _decimals; + if (mydata.increment == 0) { + mydata.increment = 243 + (initial - DEFAULT_LOWEST) - _decimals; } return *this; } @@ -154,7 +155,7 @@ void BaseNumericAdjustmentScreen::widgets_t::heading(progmem_str label) { void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(CommandProcessor &cmd, uint8_t, const uint8_t tag) { const char *label = PSTR("?"); uint8_t pos; - uint8_t & increment = screen_data.BaseNumericAdjustment.increment; + uint8_t & increment = mydata.increment; if (increment == 0) { increment = tag; // Set the default value to be the first. @@ -358,7 +359,7 @@ void BaseNumericAdjustmentScreen::widgets_t::home_buttons(uint8_t tag) { } void BaseNumericAdjustmentScreen::onEntry() { - screen_data.BaseNumericAdjustment.increment = 0; // This will force the increment to be picked while drawing. + mydata.increment = 0; // This will force the increment to be picked while drawing. BaseScreen::onEntry(); CommandProcessor cmd; cmd.set_button_style_callback(nullptr); @@ -367,14 +368,14 @@ void BaseNumericAdjustmentScreen::onEntry() { bool BaseNumericAdjustmentScreen::onTouchEnd(uint8_t tag) { switch (tag) { case 1: GOTO_PREVIOUS(); return true; - case 240 ... 245: screen_data.BaseNumericAdjustment.increment = tag; break; + case 240 ... 245: mydata.increment = tag; break; default: return current_screen.onTouchHeld(tag); } return true; } float BaseNumericAdjustmentScreen::getIncrement() { - switch (screen_data.BaseNumericAdjustment.increment) { + switch (mydata.increment) { case 240: return 0.001; case 241: return 0.01; case 242: return 0.1; @@ -385,4 +386,4 @@ float BaseNumericAdjustmentScreen::getIncrement() { } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_BASE_NUMERIC_ADJ_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.h new file mode 100644 index 0000000000..c097752674 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_numeric_adjustment_screen.h @@ -0,0 +1,87 @@ +/************************************ + * base_numeric_adjustment_screen.h * + ************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BASE_NUMERIC_ADJ_SCREEN +#define FTDI_BASE_NUMERIC_ADJ_SCREEN_CLASS BaseNumericAdjustmentScreen + +struct BaseNumericAdjustmentScreenData { + uint8_t increment; +}; + +class BaseNumericAdjustmentScreen : public BaseScreen { + public: + enum precision_default_t { + DEFAULT_LOWEST, + DEFAULT_MIDRANGE, + DEFAULT_HIGHEST + }; + + protected: + class widgets_t { + private: + draw_mode_t _what; + uint8_t _line; + uint32_t _color; + uint8_t _decimals; + progmem_str _units; + enum style_t { + BTN_NORMAL, + BTN_ACTION, + BTN_TOGGLE, + BTN_DISABLED, + TEXT_AREA, + TEXT_LABEL + } _style; + + protected: + void _draw_increment_btn(CommandProcessor &, uint8_t line, const uint8_t tag); + void _button(CommandProcessor &, uint8_t tag, int16_t x, int16_t y, int16_t w, int16_t h, progmem_str, bool enabled = true, bool highlight = false); + void _button_style(CommandProcessor &cmd, style_t style); + public: + widgets_t(draw_mode_t); + + widgets_t &color(uint32_t color) {_color = color; return *this;} + widgets_t &units(progmem_str units) {_units = units; return *this;} + widgets_t &draw_mode(draw_mode_t what) {_what = what; return *this;} + widgets_t &precision(uint8_t decimals, precision_default_t = DEFAULT_HIGHEST); + + void heading (progmem_str label); + void adjuster_sram_val (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true); + void adjuster (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true); + void adjuster (uint8_t tag, progmem_str label, float value=0, bool is_enabled = true); + void button (uint8_t tag, progmem_str label, bool is_enabled = true); + void text_field (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true); + void two_buttons (uint8_t tag1, progmem_str label1, + uint8_t tag2, progmem_str label2, bool is_enabled = true); + void toggle (uint8_t tag, progmem_str label, bool value, bool is_enabled = true); + void home_buttons (uint8_t tag); + void increments (); + }; + + static float getIncrement(); + + public: + static void onEntry(); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_screen.cpp index 16b26e6821..139a3100cf 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_BASE_SCREEN + using namespace FTDI; using namespace Theme; @@ -87,4 +86,4 @@ void BaseScreen::reset_menu_timeout() { uint32_t BaseScreen::last_interaction; #endif -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_BASE_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_screen.h new file mode 100644 index 0000000000..cbeea1f750 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/base_screen.h @@ -0,0 +1,43 @@ +/***************** + * base_screen.h * + *****************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BASE_SCREEN +#define FTDI_BASE_SCREEN_CLASS BaseScreen + +class BaseScreen : public UIScreen { + protected: + #if LCD_TIMEOUT_TO_STATUS > 0 + static uint32_t last_interaction; + #endif + + static bool buttonIsPressed(uint8_t tag); + + public: + static bool buttonStyleCallback(CommandProcessor &, uint8_t, uint8_t &, uint16_t &, bool); + + static void reset_menu_timeout(); + + static void onEntry(); + static void onIdle(); +}; 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 9fb2b20025..b62a9bf01b 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 @@ -20,16 +20,17 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, HAS_MESH) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_BED_MESH_SCREEN + using namespace FTDI; using namespace Theme; using namespace ExtUI; +constexpr static BedMeshScreenData &mydata = screen_data.BedMeshScreen; + #if ENABLED(TOUCH_UI_PORTRAIT) #define GRID_COLS 2 #define GRID_ROWS 10 @@ -196,7 +197,7 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI:: } if (opts & USE_HIGHLIGHT) { - const uint8_t tag = screen_data.BedMesh.highlightedTag; + const uint8_t tag = mydata.highlightedTag; uint8_t x, y; if (tagToPoint(tag, x, y)) { cmd.cmd(COLOR_A(128)) @@ -221,16 +222,16 @@ bool BedMeshScreen::tagToPoint(uint8_t tag, uint8_t &x, uint8_t &y) { } void BedMeshScreen::onEntry() { - screen_data.BedMesh.highlightedTag = 0; - screen_data.BedMesh.count = GRID_MAX_POINTS; - screen_data.BedMesh.message = screen_data.BedMesh.MSG_NONE; + mydata.highlightedTag = 0; + mydata.count = GRID_MAX_POINTS; + mydata.message = mydata.MSG_NONE; BaseScreen::onEntry(); } float BedMeshScreen::getHightlightedValue() { - if (screen_data.BedMesh.highlightedTag) { + if (mydata.highlightedTag) { xy_uint8_t pt; - tagToPoint(screen_data.BedMesh.highlightedTag, pt.x, pt.y); + tagToPoint(mydata.highlightedTag, pt.x, pt.y); return ExtUI::getMeshPoint(pt); } return NAN; @@ -253,9 +254,9 @@ void BedMeshScreen::drawHighlightedPointValue() { .tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY)) .tag(0); - switch (screen_data.BedMesh.message) { - case screen_data.BedMesh.MSG_MESH_COMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE)); break; - case screen_data.BedMesh.MSG_MESH_INCOMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE)); break; + switch (mydata.message) { + case mydata.MSG_MESH_COMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE)); break; + case mydata.MSG_MESH_INCOMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE)); break; default: break; } } @@ -277,11 +278,11 @@ void BedMeshScreen::onRedraw(draw_mode_t what) { if (what & FOREGROUND) { constexpr float autoscale_max_amplitude = 0.03; - const bool gotAllPoints = screen_data.BedMesh.count >= GRID_MAX_POINTS; + const bool gotAllPoints = mydata.count >= GRID_MAX_POINTS; if (gotAllPoints) { drawHighlightedPointValue(); } - const float levelingProgress = sq(float(screen_data.BedMesh.count) / GRID_MAX_POINTS); + const float levelingProgress = sq(float(mydata.count) / GRID_MAX_POINTS); BedMeshScreen::drawMesh(INSET_POS(MESH_POS), ExtUI::getMeshArray(), USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (gotAllPoints ? USE_COLORS : 0), autoscale_max_amplitude * levelingProgress @@ -290,7 +291,7 @@ void BedMeshScreen::onRedraw(draw_mode_t what) { } bool BedMeshScreen::onTouchStart(uint8_t tag) { - screen_data.BedMesh.highlightedTag = tag; + mydata.highlightedTag = tag; return true; } @@ -312,21 +313,21 @@ void BedMeshScreen::onMeshUpdate(const int8_t, const int8_t, const float) { 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.BedMesh.count = 0; - screen_data.BedMesh.message = screen_data.BedMesh.MSG_NONE; + mydata.count = 0; + mydata.message = mydata.MSG_NONE; break; case ExtUI::MESH_FINISH: - if (screen_data.BedMesh.count == GRID_MAX_POINTS && ExtUI::getMeshValid()) - screen_data.BedMesh.message = screen_data.BedMesh.MSG_MESH_COMPLETE; + if (mydata.count == GRID_MAX_POINTS && ExtUI::getMeshValid()) + mydata.message = mydata.MSG_MESH_COMPLETE; else - screen_data.BedMesh.message = screen_data.BedMesh.MSG_MESH_INCOMPLETE; - screen_data.BedMesh.count = GRID_MAX_POINTS; + mydata.message = mydata.MSG_MESH_INCOMPLETE; + mydata.count = GRID_MAX_POINTS; break; case ExtUI::PROBE_START: - screen_data.BedMesh.highlightedTag = pointToTag(x, y); + mydata.highlightedTag = pointToTag(x, y); break; case ExtUI::PROBE_FINISH: - screen_data.BedMesh.count++; + mydata.count++; break; } BedMeshScreen::onMeshUpdate(x, y, 0); @@ -334,8 +335,8 @@ void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::pr void BedMeshScreen::startMeshProbe() { GOTO_SCREEN(BedMeshScreen); - screen_data.BedMesh.count = 0; + mydata.count = 0; injectCommands_P(PSTR(BED_LEVELING_COMMANDS)); } -#endif // TOUCH_UI_FTDI_EVE && HAS_MESH +#endif // FTDI_BED_MESH_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.h new file mode 100644 index 0000000000..7aac484cb6 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.h @@ -0,0 +1,62 @@ +/********************* + * bed_mesh_screen.h * + *********************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2020 * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BED_MESH_SCREEN +#define FTDI_BED_MESH_SCREEN_CLASS BedMeshScreen + +struct BedMeshScreenData { + enum : uint8_t { + MSG_NONE, + MSG_MESH_COMPLETE, + MSG_MESH_INCOMPLETE + } message; + uint8_t count; + uint8_t highlightedTag; +}; + +class BedMeshScreen : public BaseScreen, public CachedScreen { + private: + enum MeshOpts { + USE_POINTS = 0x01, + USE_COLORS = 0x02, + USE_TAGS = 0x04, + USE_HIGHLIGHT = 0x08, + USE_AUTOSCALE = 0x10 + }; + + static uint8_t pointToTag(uint8_t x, uint8_t y); + static bool tagToPoint(uint8_t tag, uint8_t &x, uint8_t &y); + static float getHightlightedValue(); + static void drawHighlightedPointValue(); + static void drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::bed_mesh_t data, uint8_t opts, float autoscale_max = 0.1); + + public: + static void onMeshUpdate(const int8_t x, const int8_t y, const float val); + static void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t); + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchStart(uint8_t tag); + static bool onTouchEnd(uint8_t tag); + + static void startMeshProbe(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_advanced_settings.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_advanced_settings.cpp index cabcd5ded7..16b2891e27 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_advanced_settings.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_advanced_settings.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_LULZBOT_BIO) - #include "screens.h" +#ifdef FTDI_BIO_ADVANCED_SETTINGS_MENU + using namespace FTDI; using namespace Theme; @@ -134,4 +133,4 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && TOUCH_UI_LULZBOT_BIO +#endif // FTDI_BIO_ADVANCED_SETTINGS_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_advanced_settings.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_advanced_settings.h new file mode 100644 index 0000000000..29a21fe5d9 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_advanced_settings.h @@ -0,0 +1,32 @@ +/*************************** + * bio_advanced_settings.h * + ***************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BIO_ADVANCED_SETTINGS_MENU +#define FTDI_BIO_ADVANCED_SETTINGS_MENU_CLASS AdvancedSettingsMenu + +class AdvancedSettingsMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_e.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_e.cpp index 3f6b4116f1..3b55551375 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_e.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_e.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_LULZBOT_BIO) - #include "screens.h" +#ifdef FTDI_BIO_CONFIRM_HOME_E + using namespace FTDI; void BioConfirmHomeE::onRedraw(draw_mode_t) { @@ -54,4 +53,4 @@ bool BioConfirmHomeE::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && TOUCH_UI_LULZBOT_BIO +#endif // FTDI_BIO_CONFIRM_HOME_E diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_e.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_e.h new file mode 100644 index 0000000000..151b784b93 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_e.h @@ -0,0 +1,32 @@ +/**************************** + * bio_confirm_home_e.h * + ****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BIO_CONFIRM_HOME_E +#define FTDI_BIO_CONFIRM_HOME_E_CLASS BioConfirmHomeE + +class BioConfirmHomeE : public DialogBoxBaseClass, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.cpp index f712fdfff9..f1abd2e76a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_LULZBOT_BIO) - #include "screens.h" +#ifdef FTDI_BIO_CONFIRM_HOME_XYZ + using namespace FTDI; void BioConfirmHomeXYZ::onRedraw(draw_mode_t) { @@ -53,4 +52,4 @@ bool BioConfirmHomeXYZ::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && TOUCH_UI_LULZBOT_BIO +#endif // FTDI_BIO_CONFIRM_HOME_XYZ diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.h new file mode 100644 index 0000000000..d8cb1cdb67 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_confirm_home_xyz.h @@ -0,0 +1,32 @@ +/************************** + * bio_confirm_home_xyz.h * + **************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BIO_CONFIRM_HOME_XYZ +#define FTDI_BIO_CONFIRM_HOME_XYZ_CLASS BioConfirmHomeXYZ + +class BioConfirmHomeXYZ : public DialogBoxBaseClass, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_main_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_main_menu.cpp index 53203cd35e..6897ceb914 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_main_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_main_menu.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_LULZBOT_BIO) - #include "screens.h" +#ifdef FTDI_BIO_MAIN_MENU + using namespace FTDI; using namespace Theme; @@ -85,4 +84,4 @@ bool MainMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && TOUCH_UI_LULZBOT_BIO +#endif // FTDI_BIO_MAIN_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_main_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_main_menu.h new file mode 100644 index 0000000000..fdf977fcbf --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_main_menu.h @@ -0,0 +1,32 @@ +/********************* + * bio_main_menu.cpp * + *********************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BIO_MAIN_MENU +#define FTDI_BIO_MAIN_MENU_CLASS MainMenu + +class MainMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp index fb8dc3edf3..7f81d49a27 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_LULZBOT_BIO) - #include "screens.h" +#ifdef FTDI_BIO_PRINTING_DIALOG_BOX + #include "../ftdi_eve_lib/extras/circular_progress.h" using namespace FTDI; @@ -147,4 +146,4 @@ void BioPrintingDialogBox::show() { GOTO_SCREEN(BioPrintingDialogBox); } -#endif // TOUCH_UI_FTDI_EVE && TOUCH_UI_LULZBOT_BIO +#endif // FTDI_BIO_PRINTING_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.h new file mode 100644 index 0000000000..aebbd16128 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.h @@ -0,0 +1,44 @@ +/***************************** + * bio_printing_dialog_box.h * + *****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BIO_PRINTING_DIALOG_BOX +#define FTDI_BIO_PRINTING_DIALOG_BOX_CLASS BioPrintingDialogBox + +class BioPrintingDialogBox : public BaseScreen, public CachedScreen { + private: + static void draw_status_message(draw_mode_t, const char * const); + static void draw_progress(draw_mode_t); + static void draw_time_remaining(draw_mode_t); + static void draw_interaction_buttons(draw_mode_t); + public: + static void onRedraw(draw_mode_t); + + static void show(); + + static void setStatusMessage(const char *); + static void setStatusMessage(progmem_str); + + static void onIdle(); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.cpp index 90d8d6251d..f2bb5f3d3c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.cpp @@ -22,11 +22,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_LULZBOT_BIO) - #include "screens.h" +#ifdef FTDI_BIO_STATUS_SCREEN + #include "../ftdi_eve_lib/extras/poly_ui.h" #if ENABLED(TOUCH_UI_PORTRAIT) @@ -376,4 +375,4 @@ void StatusScreen::onIdle() { } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_BIO_STATUS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.h new file mode 100644 index 0000000000..a3bbb60f6c --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.h @@ -0,0 +1,56 @@ +/************************* + * bio_status_screen.cpp * + *************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BIO_STATUS_SCREEN +#define FTDI_BIO_STATUS_SCREEN_CLASS StatusScreen + +class StatusScreen : public BaseScreen, public CachedScreen { + private: + static float increment; + static bool jog_xy; + static bool fine_motion; + + static void draw_progress(draw_mode_t what); + static void draw_temperature(draw_mode_t what); + static void draw_syringe(draw_mode_t what); + static void draw_arrows(draw_mode_t what); + static void draw_overlay_icons(draw_mode_t what); + static void draw_fine_motion(draw_mode_t what); + static void draw_buttons(draw_mode_t what); + public: + static void loadBitmaps(); + static void unlockMotors(); + + static void setStatusMessage(const char *); + static void setStatusMessage(progmem_str); + + static void onRedraw(draw_mode_t); + + static bool onTouchStart(uint8_t tag); + static bool onTouchHeld(uint8_t tag); + static bool onTouchEnd(uint8_t tag); + static void onIdle(); + +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_tune_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_tune_menu.cpp index dacc1cb6ea..806f7bd1af 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_tune_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_tune_menu.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_LULZBOT_BIO) - #include "screens.h" +#ifdef FTDI_BIO_TUNE_MENU + using namespace FTDI; using namespace Theme; using namespace ExtUI; @@ -76,4 +75,4 @@ bool TuneMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && TOUCH_UI_LULZBOT_BIO +#endif // FTDI_BIO_TUNE_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_tune_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_tune_menu.h new file mode 100644 index 0000000000..52fe694f37 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_tune_menu.h @@ -0,0 +1,35 @@ +/******************* + * bio_tune_menu.h * + *******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BIO_TUNE_MENU +#define FTDI_BIO_TUNE_MENU_CLASS TuneMenu + +class TuneMenu : public BaseScreen, public CachedScreen { + private: + static void pausePrint(); + static void resumePrint(); + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; 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 a6a8705350..236830dbc4 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 @@ -22,11 +22,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_BOOT_SCREEN + #include "../ftdi_eve_lib/extras/poly_ui.h" #include "../archim2-flash/flash_storage.h" @@ -127,4 +126,4 @@ void BootScreen::showSplashScreen() { ExtUI::delay_ms(2500); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_BOOT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.h new file mode 100644 index 0000000000..a267faba6a --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.h @@ -0,0 +1,35 @@ +/***************** + * boot_screen.h * + *****************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_BOOT_SCREEN +#define FTDI_BOOT_SCREEN_CLASS BootScreen + +class BootScreen : public BaseScreen, public UncachedScreen { + private: + static void showSplashScreen(); + public: + static void onRedraw(draw_mode_t); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/case_light_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/case_light_screen.cpp index 5b2b7d4116..04327128ab 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/case_light_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/case_light_screen.cpp @@ -20,11 +20,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, CASE_LIGHT_ENABLE) - #include "screens.h" +#ifdef FTDI_CASE_LIGHT_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -59,4 +58,4 @@ bool CaseLightScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_CASE_LIGHT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/case_light_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/case_light_screen.h new file mode 100644 index 0000000000..55d5fe902f --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/case_light_screen.h @@ -0,0 +1,31 @@ +/*********************** + * case_light_screen.h * + ***********************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_CASE_LIGHT_SCREEN +#define FTDI_CASE_LIGHT_SCREEN_CLASS CaseLightScreen + +class CaseLightScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp index 624bb263eb..e9fa8a66d4 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.cpp @@ -21,16 +21,17 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_CHANGE_FILAMENT_SCREEN + using namespace ExtUI; using namespace FTDI; using namespace Theme; +constexpr static ChangeFilamentScreenData &mydata = screen_data.ChangeFilamentScreen; + #ifdef TOUCH_UI_PORTRAIT #define GRID_COLS 2 #define GRID_ROWS 11 @@ -122,17 +123,17 @@ void ChangeFilamentScreen::drawTempGradient(uint16_t x, uint16_t y, uint16_t w, void ChangeFilamentScreen::onEntry() { BaseScreen::onEntry(); - screen_data.ChangeFilament.e_tag = ExtUI::getActiveTool() + 10; - screen_data.ChangeFilament.t_tag = 0; - screen_data.ChangeFilament.repeat_tag = 0; - screen_data.ChangeFilament.saved_extruder = getActiveTool(); + mydata.e_tag = ExtUI::getActiveTool() + 10; + mydata.t_tag = 0; + mydata.repeat_tag = 0; + mydata.saved_extruder = getActiveTool(); #if FILAMENT_UNLOAD_PURGE_LENGTH > 0 - screen_data.ChangeFilament.need_purge = true; + mydata.need_purge = true; #endif } void ChangeFilamentScreen::onExit() { - setActiveTool(screen_data.ChangeFilament.saved_extruder, true); + setActiveTool(mydata.saved_extruder, true); } void ChangeFilamentScreen::onRedraw(draw_mode_t what) { @@ -170,7 +171,7 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) { const bool t_ok = getActualTemp_celsius(e) > getSoftenTemp() - 10; - if (screen_data.ChangeFilament.t_tag && !t_ok) { + if (mydata.t_tag && !t_ok) { cmd.text(HEATING_LBL_POS, GET_TEXT_F(MSG_HEATING)); } else if (getActualTemp_celsius(e) > 100) { cmd.cmd(COLOR_RGB(0xFF0000)) @@ -181,12 +182,12 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) { #define TOG_STYLE(A) colors(A ? action_btn : normal_btn) - const bool tog2 = screen_data.ChangeFilament.t_tag == 2; - const bool tog3 = screen_data.ChangeFilament.t_tag == 3; - const bool tog4 = screen_data.ChangeFilament.t_tag == 4; - const bool tog10 = screen_data.ChangeFilament.e_tag == 10; + const bool tog2 = mydata.t_tag == 2; + const bool tog3 = mydata.t_tag == 3; + const bool tog4 = mydata.t_tag == 4; + const bool tog10 = mydata.e_tag == 10; #if HAS_MULTI_HOTEND - const bool tog11 = screen_data.ChangeFilament.e_tag == 11; + const bool tog11 = mydata.e_tag == 11; #endif cmd.TOG_STYLE(tog10) @@ -200,8 +201,8 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) { if (!t_ok) reset_menu_timeout(); - const bool tog7 = screen_data.ChangeFilament.repeat_tag == 7; - const bool tog8 = screen_data.ChangeFilament.repeat_tag == 8; + const bool tog7 = mydata.repeat_tag == 7; + const bool tog8 = mydata.repeat_tag == 8; { char str[30]; @@ -228,7 +229,7 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) { } uint8_t ChangeFilamentScreen::getSoftenTemp() { - switch (screen_data.ChangeFilament.t_tag) { + switch (mydata.t_tag) { case 2: return LOW_TEMP; case 3: return MED_TEMP; case 4: return HIGH_TEMP; @@ -237,7 +238,7 @@ uint8_t ChangeFilamentScreen::getSoftenTemp() { } ExtUI::extruder_t ChangeFilamentScreen::getExtruder() { - switch (screen_data.ChangeFilament.e_tag) { + switch (mydata.e_tag) { case 13: return ExtUI::E3; case 12: return ExtUI::E2; case 11: return ExtUI::E1; @@ -248,8 +249,8 @@ ExtUI::extruder_t ChangeFilamentScreen::getExtruder() { void ChangeFilamentScreen::doPurge() { #if FILAMENT_UNLOAD_PURGE_LENGTH > 0 constexpr float purge_distance_mm = FILAMENT_UNLOAD_PURGE_LENGTH; - if (screen_data.ChangeFilament.need_purge) { - screen_data.ChangeFilament.need_purge = false; + if (mydata.need_purge) { + mydata.need_purge = false; MoveAxisScreen::setManualFeedrate(getExtruder(), purge_distance_mm); ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(getExtruder()) + purge_distance_mm, getExtruder()); } @@ -277,23 +278,23 @@ bool ChangeFilamentScreen::onTouchEnd(uint8_t tag) { case 3: case 4: // Change temperature - screen_data.ChangeFilament.t_tag = tag; + mydata.t_tag = tag; setTargetTemp_celsius(getSoftenTemp(), getExtruder()); break; case 7: - screen_data.ChangeFilament.repeat_tag = (screen_data.ChangeFilament.repeat_tag == 7) ? 0 : 7; + mydata.repeat_tag = (mydata.repeat_tag == 7) ? 0 : 7; break; case 8: - screen_data.ChangeFilament.repeat_tag = (screen_data.ChangeFilament.repeat_tag == 8) ? 0 : 8; + mydata.repeat_tag = (mydata.repeat_tag == 8) ? 0 : 8; break; case 10: case 11: // Change extruder - screen_data.ChangeFilament.e_tag = tag; - screen_data.ChangeFilament.t_tag = 0; - screen_data.ChangeFilament.repeat_tag = 0; + mydata.e_tag = tag; + mydata.t_tag = 0; + mydata.repeat_tag = 0; #if FILAMENT_UNLOAD_PURGE_LENGTH > 0 - screen_data.ChangeFilament.need_purge = true; + mydata.need_purge = true; #endif setActiveTool(getExtruder(), true); break; @@ -319,7 +320,7 @@ bool ChangeFilamentScreen::onTouchHeld(uint8_t tag) { void ChangeFilamentScreen::onIdle() { reset_menu_timeout(); - if (screen_data.ChangeFilament.repeat_tag) onTouchHeld(screen_data.ChangeFilament.repeat_tag); + if (mydata.repeat_tag) onTouchHeld(mydata.repeat_tag); if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) { onRefresh(); refresh_timer.start(); @@ -327,4 +328,4 @@ void ChangeFilamentScreen::onIdle() { BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_CHANGE_FILAMENT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.h new file mode 100644 index 0000000000..43a4bae6e0 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/change_filament_screen.h @@ -0,0 +1,51 @@ +/**************************** + * change_filament_screen.h * + ****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_CHANGE_FILAMENT_SCREEN +#define FTDI_CHANGE_FILAMENT_SCREEN_CLASS ChangeFilamentScreen + +struct ChangeFilamentScreenData { + uint8_t e_tag, t_tag, repeat_tag; + ExtUI::extruder_t saved_extruder; + #if FILAMENT_UNLOAD_PURGE_LENGTH > 0 + bool need_purge; + #endif +}; + +class ChangeFilamentScreen : public BaseScreen, public CachedScreen { + private: + static uint8_t getSoftenTemp(); + static ExtUI::extruder_t getExtruder(); + static void drawTempGradient(uint16_t x, uint16_t y, uint16_t w, uint16_t h); + static uint32_t getTempColor(uint32_t temp); + static void doPurge(); + public: + static void onEntry(); + static void onExit(); + static void onRedraw(draw_mode_t); + static bool onTouchStart(uint8_t tag); + static bool onTouchEnd(uint8_t tag); + static bool onTouchHeld(uint8_t tag); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.cpp index 656bf1db13..8d5a3d793a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS) - #include "screens.h" +#ifdef FTDI_COCOA_ADVANCED_SETTINGS_MENU + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -99,4 +98,4 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) { } return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_ADVANCED_SETTINGS_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.h new file mode 100644 index 0000000000..08c0745321 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_advanced_settings_menu.h @@ -0,0 +1,32 @@ +/*************************************** + * cocoa_press_advance_settings_menu.h * + ***************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_ADVANCED_SETTINGS_MENU +#define FTDI_COCOA_ADVANCED_SETTINGS_MENU_CLASS AdvancedSettingsMenu + +class AdvancedSettingsMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp index 36dc3404b9..23ad1b5da6 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp @@ -22,12 +22,11 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && ENABLED(TOUCH_UI_COCOA_PRESS) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_COCOA_LOAD_CHOCOLATE_SCREEN + using namespace ExtUI; using namespace FTDI; using namespace Theme; @@ -98,4 +97,4 @@ bool LoadChocolateScreen::onTouchHeld(uint8_t tag) { return false; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_LOAD_CHOCOLATE_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.h new file mode 100644 index 0000000000..262a6c9802 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.h @@ -0,0 +1,34 @@ +/******************************** + * cocoa_press_load_chocolate.h * + ********************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2020 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_LOAD_CHOCOLATE_SCREEN +#define FTDI_COCOA_LOAD_CHOCOLATE_SCREEN_CLASS LoadChocolateScreen + +class LoadChocolateScreen : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.cpp index 9c8ad062aa..56981e3084 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.cpp @@ -22,11 +22,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS) - #include "screens.h" +#ifdef FTDI_COCOA_MAIN_MENU + using namespace FTDI; using namespace Theme; @@ -86,4 +85,4 @@ bool MainMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_MAIN_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.h new file mode 100644 index 0000000000..7c2bb5039a --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_main_menu.h @@ -0,0 +1,33 @@ +/*************************** + * cocoa_press_main_menu.h * + ***************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_MAIN_MENU +#define FTDI_COCOA_MAIN_MENU_CLASS MainMenu + +class MainMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.cpp index 61411afa1b..10660736fa 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.cpp @@ -22,12 +22,11 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_COCOA_MOVE_E_SCREEN + using namespace FTDI; using namespace ExtUI; @@ -59,4 +58,4 @@ void MoveEScreen::onIdle() { } BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_MOVE_E_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.h new file mode 100644 index 0000000000..e86a91a529 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_e_screen.h @@ -0,0 +1,33 @@ +/******************************* + * cocoa_press_move_e_screen.h * + *******************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_MOVE_E_SCREEN +#define FTDI_COCOA_MOVE_E_SCREEN_CLASS MoveEScreen + +class MoveEScreen : public BaseMoveAxisScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.cpp index 52a70448cd..c9442c9322 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.cpp @@ -1,6 +1,6 @@ -/************************************ +/*********************************** * cocoa_press_move_xyz_screen.cpp * - ************************************/ + ***********************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * @@ -22,12 +22,11 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_COCOA_MOVE_XYZ_SCREEN + using namespace FTDI; using namespace ExtUI; @@ -50,4 +49,4 @@ void MoveXYZScreen::onIdle() { } BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_MOVE_XYZ_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.h new file mode 100644 index 0000000000..9cbec113e6 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_move_xyz_screen.h @@ -0,0 +1,33 @@ +/********************************* + * cocoa_press_move_xyz_screen.h * + *********************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_MOVE_XYZ_SCREEN +#define FTDI_COCOA_MOVE_XYZ_SCREEN_CLASS MoveXYZScreen + +class MoveXYZScreen : public BaseMoveAxisScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.cpp index 99c0c1b664..d515b2a27b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.cpp @@ -20,11 +20,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS) - #include "screens.h" +#ifdef FTDI_COCOA_PREHEAT_MENU + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -110,4 +109,4 @@ bool PreheatMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_PREHEAT_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.h new file mode 100644 index 0000000000..a109e42111 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_menu.h @@ -0,0 +1,31 @@ +/****************************** + * cocoa_press_preheat_menu.h * + ******************************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2020 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_PREHEAT_MENU +#define FTDI_COCOA_PREHEAT_MENU_CLASS PreheatMenu + +class PreheatMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp index c9caef6524..abea9dcdfe 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp @@ -20,18 +20,19 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_COCOA_PREHEAT_SCREEN + #include "../ftdi_eve_lib/extras/circular_progress.h" using namespace FTDI; using namespace ExtUI; using namespace Theme; +constexpr static PreheatTimerScreenData &mydata = screen_data.PreheatTimerScreen; + #define GRID_COLS 2 #define GRID_ROWS 8 @@ -54,7 +55,7 @@ void PreheatTimerScreen::draw_message(draw_mode_t what) { } uint16_t PreheatTimerScreen::secondsRemaining() { - const uint32_t elapsed_sec = (millis() - screen_data.PreheatTimer.start_ms) / 1000; + const uint32_t elapsed_sec = (millis() - mydata.start_ms) / 1000; return (COCOA_PRESS_PREHEAT_SECONDS > elapsed_sec) ? COCOA_PRESS_PREHEAT_SECONDS - elapsed_sec : 0; } @@ -118,7 +119,7 @@ void PreheatTimerScreen::draw_adjuster(draw_mode_t what, uint8_t tag, progmem_st } void PreheatTimerScreen::onEntry() { - screen_data.PreheatTimer.start_ms = millis(); + mydata.start_ms = millis(); } void PreheatTimerScreen::onRedraw(draw_mode_t what) { @@ -169,4 +170,4 @@ void PreheatTimerScreen::onIdle() { BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_PREHEAT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.h new file mode 100644 index 0000000000..e91340a3aa --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.h @@ -0,0 +1,46 @@ +/********************************* + * cocoapress_preheat_screen.cpp * + *********************************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_PREHEAT_SCREEN +#define FTDI_COCOA_PREHEAT_SCREEN_CLASS PreheatTimerScreen + +struct PreheatTimerScreenData { + uint32_t start_ms; +}; + +class PreheatTimerScreen : public BaseScreen, public CachedScreen { + private: + static uint16_t secondsRemaining(); + + static void draw_message(draw_mode_t); + static void draw_time_remaining(draw_mode_t); + static void draw_interaction_buttons(draw_mode_t); + static void draw_adjuster(draw_mode_t, uint8_t tag, progmem_str label, float value, int16_t x, int16_t y, int16_t w, int16_t h); + public: + static void onRedraw(draw_mode_t); + + static void onEntry(); + static void onIdle(); + static bool onTouchHeld(uint8_t tag); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp index d9881d747a..f7d44e2936 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp @@ -22,11 +22,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS) - #include "screens.h" +#ifdef FTDI_COCOA_STATUS_SCREEN + #include "../ftdi_eve_lib/extras/poly_ui.h" #include "cocoa_press_ui.h" @@ -304,4 +303,4 @@ void StatusScreen::onIdle() { } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_STATUS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.h new file mode 100644 index 0000000000..b22bceac14 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.h @@ -0,0 +1,55 @@ +/******************************* + * cocoa_press_status_screen.h * + *******************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_STATUS_SCREEN +#define FTDI_COCOA_STATUS_SCREEN_CLASS StatusScreen + +class StatusScreen : public BaseScreen, public CachedScreen { + private: + static float increment; + static bool jog_xy; + static bool fine_motion; + + static void draw_progress(draw_mode_t what); + static void draw_temperature(draw_mode_t what); + static void draw_syringe(draw_mode_t what); + static void draw_arrows(draw_mode_t what); + static void draw_overlay_icons(draw_mode_t what); + static void draw_fine_motion(draw_mode_t what); + static void draw_buttons(draw_mode_t what); + public: + static void loadBitmaps(); + static void unlockMotors(); + + static void setStatusMessage(const char *); + static void setStatusMessage(progmem_str); + + static void onRedraw(draw_mode_t); + + static bool onTouchStart(uint8_t tag); + static bool onTouchHeld(uint8_t tag); + static bool onTouchEnd(uint8_t tag); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.cpp index 2e71093370..3428c38bb1 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.cpp @@ -22,12 +22,11 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && ENABLED(TOUCH_UI_COCOA_PRESS) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN + using namespace ExtUI; using namespace FTDI; using namespace Theme; @@ -98,4 +97,4 @@ bool UnloadCartridgeScreen::onTouchHeld(uint8_t tag) { return false; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.h new file mode 100644 index 0000000000..95a9ee47ec --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_unload_cartridge.h @@ -0,0 +1,34 @@ +/********************************** + * cocoa_press_unload_cartridge.h * + **********************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2020 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN +#define FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN_CLASS UnloadCartridgeScreen + +class UnloadCartridgeScreen : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_abort_print_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_abort_print_dialog_box.cpp index 528d93d5d1..dba565189a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_abort_print_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_abort_print_dialog_box.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_CONFIRM_ABORT_PRINT_DIALOG_BOX + #include "../../../../../feature/host_actions.h" using namespace ExtUI; @@ -50,4 +49,4 @@ bool ConfirmAbortPrintDialogBox::onTouchEnd(uint8_t tag) { } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_CONFIRM_ABORT_PRINT_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_abort_print_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_abort_print_dialog_box.h new file mode 100644 index 0000000000..a97a2000a0 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_abort_print_dialog_box.h @@ -0,0 +1,32 @@ +/************************************ + * confirm_abort_print_dialog_box.h * + ************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_CONFIRM_ABORT_PRINT_DIALOG_BOX +#define FTDI_CONFIRM_ABORT_PRINT_DIALOG_BOX_CLASS ConfirmAbortPrintDialogBox + +class ConfirmAbortPrintDialogBox : public DialogBoxBaseClass, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.cpp index f7c85672af..65b5140ccb 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, CALIBRATION_GCODE) - #include "screens.h" +#ifdef FTDI_CONFIRM_AUTO_CALIBRATION_DIALOG_BOX + using namespace ExtUI; using namespace Theme; @@ -45,4 +44,4 @@ bool ConfirmAutoCalibrationDialogBox::onTouchEnd(uint8_t tag) { } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_CONFIRM_AUTO_CALIBRATION_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.h new file mode 100644 index 0000000000..5093b68c73 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_auto_calibration_dialog_box.h @@ -0,0 +1,32 @@ +/***************************************** + * confirm_auto_calibration_dialog_box.h * + *****************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_CONFIRM_AUTO_CALIBRATION_DIALOG_BOX +#define FTDI_CONFIRM_AUTO_CALIBRATION_DIALOG_BOX_CLASS ConfirmAutoCalibrationDialogBox + +class ConfirmAutoCalibrationDialogBox : public DialogBoxBaseClass, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_erase_flash_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_erase_flash_dialog_box.cpp index baf5959c1b..13d61005e8 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_erase_flash_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_erase_flash_dialog_box.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_DEVELOPER_MENU) - #include "screens.h" +#ifdef FTDI_CONFIRM_ERASE_FLASH_DIALOG_BOX + #include "../archim2-flash/flash_storage.h" using namespace FTDI; @@ -51,4 +50,4 @@ bool ConfirmEraseFlashDialogBox::onTouchEnd(uint8_t tag) { } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_CONFIRM_ERASE_FLASH_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_erase_flash_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_erase_flash_dialog_box.h new file mode 100644 index 0000000000..a06f886176 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_erase_flash_dialog_box.h @@ -0,0 +1,32 @@ +/************************************ + * confirm_erase_flash_dialog_box.h * + ************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_CONFIRM_ERASE_FLASH_DIALOG_BOX +#define FTDI_CONFIRM_ERASE_FLASH_DIALOG_BOX_CLASS ConfirmEraseFlashDialogBox + +class ConfirmEraseFlashDialogBox : public DialogBoxBaseClass, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_start_print_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_start_print_dialog_box.cpp index eeca88f280..86e7e33035 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_start_print_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_start_print_dialog_box.cpp @@ -21,16 +21,17 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_CONFIRM_START_PRINT_DIALOG_BOX + using namespace FTDI; using namespace Theme; using namespace ExtUI; +constexpr static ConfirmStartPrintDialogBoxData &mydata = screen_data.ConfirmStartPrintDialogBox; + void ConfirmStartPrintDialogBox::onRedraw(draw_mode_t) { const char *filename = getLongFilename(); char buffer[strlen_P(GET_TEXT(MSG_START_PRINT_CONFIRMATION)) + strlen(filename) + 1]; @@ -53,13 +54,13 @@ bool ConfirmStartPrintDialogBox::onTouchEnd(uint8_t tag) { const char *ConfirmStartPrintDialogBox::getFilename(bool longName) { FileList files; - files.seek(screen_data.ConfirmStartPrintDialog.file_index, true); + files.seek(mydata.file_index, true); return longName ? files.longFilename() : files.shortFilename(); } void ConfirmStartPrintDialogBox::show(uint8_t file_index) { - screen_data.ConfirmStartPrintDialog.file_index = file_index; + mydata.file_index = file_index; GOTO_SCREEN(ConfirmStartPrintDialogBox); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_CONFIRM_START_PRINT_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_start_print_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_start_print_dialog_box.h new file mode 100644 index 0000000000..e073ed55fa --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_start_print_dialog_box.h @@ -0,0 +1,43 @@ +/************************************ + * confirm_start_print_dialog_box.h * + ************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_CONFIRM_START_PRINT_DIALOG_BOX +#define FTDI_CONFIRM_START_PRINT_DIALOG_BOX_CLASS ConfirmStartPrintDialogBox + +struct ConfirmStartPrintDialogBoxData { + uint8_t file_index; +}; + +class ConfirmStartPrintDialogBox : public DialogBoxBaseClass, public UncachedScreen { + private: + inline static const char *getShortFilename() {return getFilename(false);} + inline static const char *getLongFilename() {return getFilename(true);} + + static const char *getFilename(bool longName); + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t); + + static void show(uint8_t file_index); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_user_request_alert_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_user_request_alert_box.cpp index 59e1c8220d..957c95f047 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_user_request_alert_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_user_request_alert_box.cpp @@ -21,12 +21,11 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_CONFIRM_USER_REQUEST_ALERT_BOX + using namespace FTDI; void ConfirmUserRequestAlertBox::onRedraw(draw_mode_t mode) { @@ -54,7 +53,7 @@ bool ConfirmUserRequestAlertBox::onTouchEnd(uint8_t tag) { void ConfirmUserRequestAlertBox::show(const char* msg) { drawMessage(msg); storeBackground(); - screen_data.AlertDialog.isError = false; + screen_data.AlertDialogBox.isError = false; GOTO_SCREEN(ConfirmUserRequestAlertBox); } @@ -63,4 +62,4 @@ void ConfirmUserRequestAlertBox::hide() { GOTO_PREVIOUS(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_CONFIRM_USER_REQUEST_ALERT_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_user_request_alert_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_user_request_alert_box.h new file mode 100644 index 0000000000..d9a6c4a4fe --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/confirm_user_request_alert_box.h @@ -0,0 +1,35 @@ +/************************************ + * confirm_user_request_alert_box.h * + ************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_CONFIRM_USER_REQUEST_ALERT_BOX +#define FTDI_CONFIRM_USER_REQUEST_ALERT_BOX_CLASS ConfirmUserRequestAlertBox + +class ConfirmUserRequestAlertBox : public AlertDialogBox { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t); + static void hide(); + static void show(const char*); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.cpp index 20f90d5a41..9c7c12e10b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.cpp @@ -21,11 +21,10 @@ */ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, CUSTOM_USER_MENUS) && NONE(TOUCH_UI_LULZBOT_BIO, TOUCH_UI_COCOA_PRESS) - #include "screens.h" +#ifdef FTDI_CUSTOM_USER_MENUS + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -212,4 +211,4 @@ bool CustomUserMenus::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && CUSTOM_USER_MENUS && !TOUCH_UI_LULZBOT_BIO && !TOUCH_UI_COCOA_PRESS +#endif // FTDI_CUSTOM_USER_MENUS diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.h new file mode 100644 index 0000000000..e46a280369 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.h @@ -0,0 +1,32 @@ +/** + * 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 + +#define FTDI_CUSTOM_USER_MENUS +#define FTDI_CUSTOM_USER_MENUS_CLASS CustomUserMenus + +class CustomUserMenus : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/default_acceleration_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/default_acceleration_screen.cpp index de617d4374..6178228d09 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/default_acceleration_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/default_acceleration_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_DEFAULT_ACCELERATION_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -60,4 +59,4 @@ bool DefaultAccelerationScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_DEFAULT_ACCELERATION_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/default_acceleration_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/default_acceleration_screen.h new file mode 100644 index 0000000000..9042f6d2b8 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/default_acceleration_screen.h @@ -0,0 +1,32 @@ +/********************************* + * default_acceleration_screen.h * + *********************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_DEFAULT_ACCELERATION_SCREEN +#define FTDI_DEFAULT_ACCELERATION_SCREEN_CLASS DefaultAccelerationScreen + +class DefaultAccelerationScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/developer_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/developer_menu.cpp index 9df060a6c4..0bbce08a2b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/developer_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/developer_menu.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_DEVELOPER_MENU) - #include "screens.h" +#ifdef FTDI_DEVELOPER_MENU + #include "../archim2-flash/flash_storage.h" using namespace FTDI; @@ -147,4 +146,4 @@ bool DeveloperMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_DEVELOPER_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/developer_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/developer_menu.h new file mode 100644 index 0000000000..8757248329 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/developer_menu.h @@ -0,0 +1,32 @@ +/******************** + * developer_menu.h * + ********************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_DEVELOPER_MENU +#define FTDI_DEVELOPER_MENU_CLASS DeveloperMenu + +class DeveloperMenu : public BaseScreen, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/dialog_box_base_class.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/dialog_box_base_class.cpp index 6fe7be492d..feaebb77be 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/dialog_box_base_class.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/dialog_box_base_class.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_DIALOG_BOX_BASE_CLASS + using namespace FTDI; using namespace Theme; @@ -84,4 +83,4 @@ void DialogBoxBaseClass::onIdle() { reset_menu_timeout(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_DIALOG_BOX_BASE_CLASS diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/dialog_box_base_class.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/dialog_box_base_class.h new file mode 100644 index 0000000000..ef5e6b569b --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/dialog_box_base_class.h @@ -0,0 +1,40 @@ +/*************************** + * dialog_box_base_class.h * + ***************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_DIALOG_BOX_BASE_CLASS +#define FTDI_DIALOG_BOX_BASE_CLASS_CLASS DialogBoxBaseClass + +class DialogBoxBaseClass : public BaseScreen { + protected: + template static void drawMessage(const T, int16_t font = 0); + static void drawYesNoButtons(uint8_t default_btn = 0); + static void drawOkayButton(); + static void drawSpinner(); + static void drawButton(const progmem_str); + + static void onRedraw(draw_mode_t) {}; + public: + static bool onTouchEnd(uint8_t tag); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/display_tuning_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/display_tuning_screen.cpp index 1a4d9fd705..62a329e907 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/display_tuning_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/display_tuning_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_DISPLAY_TUNING_SCREEN + using namespace FTDI; using namespace Theme; @@ -58,4 +57,4 @@ bool DisplayTuningScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_DISPLAY_TUNING_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/display_tuning_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/display_tuning_screen.h new file mode 100644 index 0000000000..3de840b82e --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/display_tuning_screen.h @@ -0,0 +1,32 @@ +/*************************** + * display_tuning_screen.h * + ***************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_DISPLAY_TUNING_SCREEN +#define FTDI_DISPLAY_TUNING_SCREEN_CLASS DisplayTuningScreen + +class DisplayTuningScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; 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 a091197a87..3648321dce 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 @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_ENDSTOP_STATE_SCREEN + using namespace FTDI; using namespace Theme; using namespace ExtUI; @@ -149,4 +148,4 @@ void EndstopStatesScreen::onIdle() { BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_ENDSTOP_STATE_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.h new file mode 100644 index 0000000000..c0eaccbe01 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.h @@ -0,0 +1,35 @@ +/************************** + * endstop_state_screen.h * + **************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_ENDSTOP_STATE_SCREEN +#define FTDI_ENDSTOP_STATE_SCREEN_CLASS EndstopStatesScreen + +class EndstopStatesScreen : public BaseScreen, public UncachedScreen { + public: + static void onEntry(); + static void onExit(); + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/feedrate_percent_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/feedrate_percent_screen.cpp index 28f0e6a731..8b3984aa01 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/feedrate_percent_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/feedrate_percent_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_FEEDRATE_PERCENT_SCREEN + using namespace FTDI; using namespace ExtUI; @@ -49,4 +48,4 @@ bool FeedratePercentScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_FEEDRATE_PERCENT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/feedrate_percent_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/feedrate_percent_screen.h new file mode 100644 index 0000000000..076cfe97ca --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/feedrate_percent_screen.h @@ -0,0 +1,32 @@ +/***************************** + * feedrate_percent_screen.h * + *****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_FEEDRATE_PERCENT_SCREEN +#define FTDI_FEEDRATE_PERCENT_SCREEN_CLASS FeedratePercentScreen + +class FeedratePercentScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_menu.cpp index f63fc416dd..cf63a1a124 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_menu.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && ANY(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR) - #include "screens.h" +#ifdef FTDI_FILAMENT_MENU + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -82,4 +81,4 @@ bool FilamentMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_FILAMENT_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_menu.h new file mode 100644 index 0000000000..73ceec29a5 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_menu.h @@ -0,0 +1,32 @@ +/******************* + * filament_menu.h * + *******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_FILAMENT_MENU +#define FTDI_FILAMENT_MENU_CLASS FilamentMenu + +class FilamentMenu : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_runout_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_runout_screen.cpp index 41e3be22ef..069686b541 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_runout_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_runout_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, FILAMENT_RUNOUT_SENSOR) - #include "screens.h" +#ifdef FTDI_FILAMENT_RUNOUT_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -62,4 +61,4 @@ bool FilamentRunoutScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_FILAMENT_RUNOUT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_runout_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_runout_screen.h new file mode 100644 index 0000000000..ebe7d020cb --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/filament_runout_screen.h @@ -0,0 +1,32 @@ +/**************************** + * filament_runout_screen.h * + ****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_FILAMENT_RUNOUT_SCREEN +#define FTDI_FILAMENT_RUNOUT_SCREEN_CLASS FilamentRunoutScreen + +class FilamentRunoutScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; 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 cadc582267..c8febfd7d8 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 @@ -21,19 +21,20 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, SDSUPPORT) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_FILES_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; +constexpr static FilesScreenData &mydata = screen_data.FilesScreen; + void FilesScreen::onEntry() { - screen_data.Files.cur_page = 0; - screen_data.Files.selected_tag = 0xFF; + mydata.cur_page = 0; + mydata.selected_tag = 0xFF; #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) CLCD::mem_write_32(CLCD::REG::MACRO_0,DL::NOP); #endif @@ -50,21 +51,21 @@ const char *FilesScreen::getSelectedFilename(bool longName) { void FilesScreen::drawSelectedFile() { FileList files; files.seek(getSelectedFileIndex(), true); - screen_data.Files.flags.is_dir = files.isDir(); + mydata.flags.is_dir = files.isDir(); drawFileButton( files.filename(), - screen_data.Files.selected_tag, - screen_data.Files.flags.is_dir, + mydata.selected_tag, + mydata.flags.is_dir, true ); } uint16_t FilesScreen::getSelectedFileIndex() { - return getFileForTag(screen_data.Files.selected_tag); + return getFileForTag(mydata.selected_tag); } uint16_t FilesScreen::getFileForTag(uint8_t tag) { - return screen_data.Files.cur_page * files_per_page + tag - 2; + return mydata.cur_page * files_per_page + tag - 2; } #if ENABLED(TOUCH_UI_PORTRAIT) @@ -106,15 +107,15 @@ void FilesScreen::drawFileButton(const char* filename, uint8_t tag, bool is_dir, void FilesScreen::drawFileList() { FileList files; - screen_data.Files.num_page = max(1,ceil(float(files.count()) / files_per_page)); - screen_data.Files.cur_page = min(screen_data.Files.cur_page, screen_data.Files.num_page-1); - screen_data.Files.flags.is_root = files.isAtRootDir(); + mydata.num_page = max(1,ceil(float(files.count()) / files_per_page)); + mydata.cur_page = min(mydata.cur_page, mydata.num_page-1); + mydata.flags.is_root = files.isAtRootDir(); #undef MARGIN_T #undef MARGIN_B #define MARGIN_T 0 #define MARGIN_B 0 - uint16_t fileIndex = screen_data.Files.cur_page * files_per_page; + uint16_t fileIndex = mydata.cur_page * files_per_page; for (uint8_t i = 0; i < files_per_page; i++, fileIndex++) { if (files.seek(fileIndex)) { drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false); @@ -126,8 +127,8 @@ void FilesScreen::drawFileList() { } void FilesScreen::drawHeader() { - const bool prev_enabled = screen_data.Files.cur_page > 0; - const bool next_enabled = screen_data.Files.cur_page < (screen_data.Files.num_page - 1); + const bool prev_enabled = mydata.cur_page > 0; + const bool next_enabled = mydata.cur_page < (mydata.num_page - 1); #undef MARGIN_T #undef MARGIN_B @@ -136,7 +137,7 @@ void FilesScreen::drawHeader() { char str[16]; sprintf_P(str, PSTR("Page %d of %d"), - screen_data.Files.cur_page + 1, screen_data.Files.num_page); + mydata.cur_page + 1, mydata.num_page); CommandProcessor cmd; cmd.colors(normal_btn) @@ -158,8 +159,8 @@ void FilesScreen::drawFooter() { #define MARGIN_T 5 #define MARGIN_B 5 #endif - const bool has_selection = screen_data.Files.selected_tag != 0xFF; - const uint8_t back_tag = screen_data.Files.flags.is_root ? 240 : 245; + const bool has_selection = mydata.selected_tag != 0xFF; + const uint8_t back_tag = mydata.flags.is_root ? 240 : 245; const uint8_t y = GRID_ROWS - footer_h + 1; const uint8_t h = footer_h; @@ -171,7 +172,7 @@ void FilesScreen::drawFooter() { .enabled(has_selection) .colors(has_selection ? action_btn : normal_btn); - if (screen_data.Files.flags.is_dir) + if (mydata.flags.is_dir) cmd.tag(244).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_OPEN)); else cmd.tag(243).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_PRINT)); @@ -186,8 +187,8 @@ void FilesScreen::onRedraw(draw_mode_t what) { } void FilesScreen::gotoPage(uint8_t page) { - screen_data.Files.selected_tag = 0xFF; - screen_data.Files.cur_page = page; + mydata.selected_tag = 0xFF; + mydata.cur_page = page; CommandProcessor cmd; cmd.cmd(CMD_DLSTART) .cmd(CLEAR_COLOR_RGB(bg_color)) @@ -201,13 +202,13 @@ bool FilesScreen::onTouchEnd(uint8_t tag) { switch (tag) { case 240: GOTO_PREVIOUS(); return true; case 241: - if (screen_data.Files.cur_page > 0) { - gotoPage(screen_data.Files.cur_page-1); + if (mydata.cur_page > 0) { + gotoPage(mydata.cur_page-1); } break; case 242: - if (screen_data.Files.cur_page < (screen_data.Files.num_page-1)) { - gotoPage(screen_data.Files.cur_page+1); + if (mydata.cur_page < (mydata.num_page-1)) { + gotoPage(mydata.cur_page+1); } break; case 243: @@ -229,18 +230,18 @@ bool FilesScreen::onTouchEnd(uint8_t tag) { break; default: if (tag < 240) { - screen_data.Files.selected_tag = tag; + mydata.selected_tag = tag; #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) if (FTDI::ftdi_chip >= 810) { const char *longFilename = getSelectedLongFilename(); if (longFilename[0]) { CommandProcessor cmd; uint16_t text_width = cmd.font(font_medium).text_width(longFilename); - screen_data.Files.scroll_pos = 0; + mydata.scroll_pos = 0; if (text_width > display_width) - screen_data.Files.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R; + mydata.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R; else - screen_data.Files.scroll_max = 0; + mydata.scroll_max = 0; } } #endif @@ -254,11 +255,11 @@ void FilesScreen::onIdle() { #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) if (FTDI::ftdi_chip >= 810) { CLCD::mem_write_32(CLCD::REG::MACRO_0, - VERTEX_TRANSLATE_X(-int32_t(screen_data.Files.scroll_pos))); - if (screen_data.Files.scroll_pos < screen_data.Files.scroll_max * 16) - screen_data.Files.scroll_pos++; + VERTEX_TRANSLATE_X(-int32_t(mydata.scroll_pos))); + if (mydata.scroll_pos < mydata.scroll_max * 16) + mydata.scroll_pos++; } #endif } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_FILES_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.h new file mode 100644 index 0000000000..a4fb37cc14 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/files_screen.h @@ -0,0 +1,75 @@ +/****************** + * files_screen.h * + ******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_FILES_SCREEN +#define FTDI_FILES_SCREEN_CLASS FilesScreen + +struct FilesScreenData { + struct { + uint8_t is_dir : 1; + uint8_t is_root : 1; + } flags; + uint8_t selected_tag; + 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; + #endif +}; + +class FilesScreen : public BaseScreen, public CachedScreen { + private: + #if ENABLED(TOUCH_UI_PORTRAIT) + static constexpr uint8_t header_h = 2; + static constexpr uint8_t footer_h = 2; + static constexpr uint8_t files_per_page = 11; + #else + static constexpr uint8_t header_h = 1; + static constexpr uint8_t footer_h = 1; + static constexpr uint8_t files_per_page = 6; + #endif + + static uint8_t getTagForLine(uint8_t line) {return line + 2;} + static uint8_t getLineForTag(uint8_t tag) {return tag - 2;} + static uint16_t getFileForTag(uint8_t tag); + static uint16_t getSelectedFileIndex(); + + inline static const char *getSelectedShortFilename() {return getSelectedFilename(false);} + inline static const char *getSelectedLongFilename() {return getSelectedFilename(true);} + static const char *getSelectedFilename(bool longName); + + static void drawFileButton(const char* filename, uint8_t tag, bool is_dir, bool is_highlighted); + static void drawFileList(); + static void drawHeader(); + static void drawFooter(); + static void drawSelectedFile(); + + static void gotoPage(uint8_t); + public: + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); + static void onIdle(); +}; 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 3d50b616fc..2566a960e1 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 @@ -21,12 +21,11 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_INTERFACE_SETTINGS_SCREEN + #include "../archim2-flash/flash_storage.h" #include "../../../../../module/settings.h" @@ -42,13 +41,14 @@ using namespace ExtUI; using namespace Theme; constexpr bool PERSISTENT_STORE_SUCCESS = false; // persistentStore uses true for error +constexpr static InterfaceSettingsScreenData &mydata = screen_data.InterfaceSettingsScreen; void InterfaceSettingsScreen::onStartup() { } void InterfaceSettingsScreen::onEntry() { - screen_data.InterfaceSettings.brightness = CLCD::get_brightness(); - screen_data.InterfaceSettings.volume = SoundPlayer::get_volume(); + mydata.brightness = CLCD::get_brightness(); + mydata.volume = SoundPlayer::get_volume(); BaseScreen::onEntry(); } @@ -96,9 +96,9 @@ void InterfaceSettingsScreen::onRedraw(draw_mode_t what) { #define EDGE_R 30 .colors(ui_slider) #if DISABLED(LCD_FYSETC_TFT81050) - .tag(2).slider(BTN_POS(3,2), BTN_SIZE(2,1), screen_data.InterfaceSettings.brightness, 128) + .tag(2).slider(BTN_POS(3,2), BTN_SIZE(2,1), mydata.brightness, 128) #endif - .tag(3).slider(BTN_POS(3,3), BTN_SIZE(2,1), screen_data.InterfaceSettings.volume, 0xFF) + .tag(3).slider(BTN_POS(3,3), BTN_SIZE(2,1), mydata.volume, 0xFF) .colors(ui_toggle) .tag(4).toggle2(BTN_POS(3,4), BTN_SIZE(w,1), GET_TEXT_F(MSG_NO), GET_TEXT_F(MSG_YES), LockScreen::is_enabled()) #if DISABLED(TOUCH_UI_NO_BOOTSCREEN) @@ -161,13 +161,13 @@ void InterfaceSettingsScreen::onIdle() { CommandProcessor cmd; switch (cmd.track_tag(value)) { case 2: - screen_data.InterfaceSettings.brightness = max(11, (value * 128UL) / 0xFFFF); - CLCD::set_brightness(screen_data.InterfaceSettings.brightness); + mydata.brightness = max(11, (value * 128UL) / 0xFFFF); + CLCD::set_brightness(mydata.brightness); SaveSettingsDialogBox::settingsChanged(); break; case 3: - screen_data.InterfaceSettings.volume = value >> 8; - SoundPlayer::set_volume(screen_data.InterfaceSettings.volume); + mydata.volume = value >> 8; + SoundPlayer::set_volume(mydata.volume); SaveSettingsDialogBox::settingsChanged(); break; default: @@ -288,4 +288,4 @@ void InterfaceSettingsScreen::loadSettings(const char *buff) { } #endif -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_INTERFACE_SETTINGS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.h new file mode 100644 index 0000000000..f5ddbb1004 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.h @@ -0,0 +1,67 @@ +/******************************* + * interface_settings_screen.h * + *******************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_INTERFACE_SETTINGS_SCREEN +#define FTDI_INTERFACE_SETTINGS_SCREEN_CLASS InterfaceSettingsScreen + +struct InterfaceSettingsScreenData { + uint8_t volume; + uint8_t brightness; +}; + +class InterfaceSettingsScreen : public BaseScreen, public CachedScreen { + private: + struct persistent_data_t { + uint32_t touch_transform_a; + uint32_t touch_transform_b; + uint32_t touch_transform_c; + uint32_t touch_transform_d; + uint32_t touch_transform_e; + uint32_t touch_transform_f; + uint16_t passcode; + uint8_t display_brightness; + int8_t display_h_offset_adj; + int8_t display_v_offset_adj; + uint8_t sound_volume; + uint8_t bit_flags; + uint8_t event_sounds[InterfaceSoundsScreen::NUM_EVENTS]; + }; + + public: + #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE + static bool backupEEPROM(); + #endif + + static void saveSettings(char *); + static void loadSettings(const char *); + static void defaultSettings(); + static void failSafeSettings(); + + static void onStartup(); + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchStart(uint8_t tag); + static bool onTouchEnd(uint8_t tag); + static void onIdle(); +}; 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 9f21c6b8c7..4e47653899 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 @@ -21,12 +21,11 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_INTERFACE_SOUNDS_SCREEN + using namespace FTDI; using namespace Theme; using namespace ExtUI; @@ -93,7 +92,7 @@ void InterfaceSoundsScreen::onRedraw(draw_mode_t what) { cmd.font(font_medium) .colors(ui_slider) #define EDGE_R 30 - .tag(2).slider (BTN_POS(3,2), BTN_SIZE(2,1), screen_data.InterfaceSettings.volume, 0xFF) + .tag(2).slider (BTN_POS(3,2), BTN_SIZE(2,1), screen_data.InterfaceSettingsScreen.volume, 0xFF) .colors(ui_toggle) .tag(3).toggle2 (BTN_POS(3,3), BTN_SIZE(w,1), GET_TEXT_F(MSG_NO), GET_TEXT_F(MSG_YES), UIData::touch_sounds_enabled()) #undef EDGE_R @@ -108,7 +107,7 @@ void InterfaceSoundsScreen::onRedraw(draw_mode_t what) { } void InterfaceSoundsScreen::onEntry() { - screen_data.InterfaceSettings.volume = SoundPlayer::get_volume(); + screen_data.InterfaceSettingsScreen.volume = SoundPlayer::get_volume(); BaseScreen::onEntry(); } @@ -145,8 +144,8 @@ void InterfaceSoundsScreen::onIdle() { CommandProcessor cmd; switch (cmd.track_tag(value)) { case 2: - screen_data.InterfaceSettings.volume = value >> 8; - SoundPlayer::set_volume(screen_data.InterfaceSettings.volume); + screen_data.InterfaceSettingsScreen.volume = value >> 8; + SoundPlayer::set_volume(screen_data.InterfaceSettingsScreen.volume); SaveSettingsDialogBox::settingsChanged(); break; default: @@ -157,4 +156,4 @@ void InterfaceSoundsScreen::onIdle() { BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_INTERFACE_SOUNDS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_sounds_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_sounds_screen.h new file mode 100644 index 0000000000..046d7390fe --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_sounds_screen.h @@ -0,0 +1,57 @@ +/***************************** + * interface_sounds_screen.h * + *****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_INTERFACE_SOUNDS_SCREEN +#define FTDI_INTERFACE_SOUNDS_SCREEN_CLASS InterfaceSoundsScreen + +class InterfaceSoundsScreen : public BaseScreen, public CachedScreen { + public: + enum event_t { + PRINTING_STARTED = 0, + PRINTING_FINISHED = 1, + PRINTING_FAILED = 2, + + NUM_EVENTS + }; + + private: + friend class InterfaceSettingsScreen; + + static uint8_t event_sounds[NUM_EVENTS]; + + static const char* getSoundSelection(event_t); + static void toggleSoundSelection(event_t); + static void setSoundSelection(event_t, const FTDI::SoundPlayer::sound_t*); + + public: + static void playEventSound(event_t, FTDI::play_mode_t = FTDI::PLAY_ASYNCHRONOUS); + + static void defaultSettings(); + + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchStart(uint8_t tag); + static bool onTouchEnd(uint8_t tag); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/jerk_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/jerk_screen.cpp index 9c751bc345..d74879fd41 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/jerk_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/jerk_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, CLASSIC_JERK) - #include "screens.h" +#ifdef FTDI_JERK_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -62,4 +61,4 @@ bool JerkScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && CLASSIC_JERK +#endif // FTDI_JERK_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/jerk_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/jerk_screen.h new file mode 100644 index 0000000000..5f7acb2960 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/jerk_screen.h @@ -0,0 +1,32 @@ +/***************** + * jerk_screen.h * + *****************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_JERK_SCREEN +#define FTDI_JERK_SCREEN_CLASS JerkScreen + +class JerkScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/junction_deviation_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/junction_deviation_screen.cpp index 329fa6c97f..4b9f5512bb 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/junction_deviation_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/junction_deviation_screen.cpp @@ -1,6 +1,6 @@ -/******************* - * boot_screen.cpp * - *******************/ +/********************************* + * junction_deviation_screen.cpp * + *********************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, HAS_JUNCTION_DEVIATION) - #include "screens.h" +#ifdef FTDI_JUNCTION_DEVIATION_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -51,4 +50,4 @@ bool JunctionDeviationScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && !CLASSIC_JERK +#endif // FTDI_JUNCTION_DEVIATION_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/junction_deviation_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/junction_deviation_screen.h new file mode 100644 index 0000000000..2239e2a450 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/junction_deviation_screen.h @@ -0,0 +1,32 @@ +/******************************* + * junction_deviation_screen.h * + *******************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_JUNCTION_DEVIATION_SCREEN +#define FTDI_JUNCTION_DEVIATION_SCREEN_CLASS JunctionDeviationScreen + +class JunctionDeviationScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/kill_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/kill_screen.cpp index 273da348c1..fe58cad93c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/kill_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/kill_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_KILL_SCREEN + using namespace FTDI; // The kill screen is an oddball that happens after Marlin has killed the events @@ -59,4 +58,4 @@ void KillScreen::show(const char *message) { InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED, PLAY_SYNCHRONOUS); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_KILL_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/kill_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/kill_screen.h new file mode 100644 index 0000000000..b6d9495884 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/kill_screen.h @@ -0,0 +1,33 @@ +/***************** + * kill_screen.h * + *****************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_KILL_SCREEN +#define FTDI_KILL_SCREEN_CLASS KillScreen + +class KillScreen { + // The KillScreen is behaves differently than the + // others, so we do not bother extending UIScreen. + public: + static void show(const char*); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/language_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/language_menu.cpp index 6c5dfcfa9f..77c0d02756 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/language_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/language_menu.cpp @@ -21,12 +21,12 @@ ****************************************************************************/ #include "../config.h" -#include "../language/language.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && NUM_LANGUAGES > 1 - #include "screens.h" +#ifdef FTDI_LANGUAGE_MENU + +#include "../language/language.h" + using namespace FTDI; using namespace Theme; @@ -63,4 +63,4 @@ bool LanguageMenu::onTouchEnd(uint8_t tag) { return false; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_LANGUAGE_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/language_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/language_menu.h new file mode 100644 index 0000000000..a86333363f --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/language_menu.h @@ -0,0 +1,32 @@ +/******************* + * language_menu.h * + *******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_LANGUAGE_MENU +#define FTDI_LANGUAGE_MENU_CLASS LanguageMenu + +class LanguageMenu : public BaseScreen, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; 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 8d372309bd..1d4ef84271 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 @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE,HAS_LEVELING) - #include "screens.h" +#ifdef FTDI_LEVELING_MENU + #if BOTH(HAS_BED_PROBE,BLTOUCH) #include "../../../../../feature/bltouch.h" #endif @@ -118,4 +117,4 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && HAS_LEVELING +#endif // FTDI_LEVELING_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.h new file mode 100644 index 0000000000..aaf852be6c --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.h @@ -0,0 +1,32 @@ +/******************* + * leveling_menu.h * + *******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_LEVELING_MENU +#define FTDI_LEVELING_MENU_CLASS LevelingMenu + +class LevelingMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; 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 2feaa03295..e70d6933cc 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 @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, LIN_ADVANCE) - #include "screens.h" +#ifdef FTDI_LINEAR_ADVANCE_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -74,4 +73,4 @@ bool LinearAdvanceScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_LINEAR_ADVANCE_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.h new file mode 100644 index 0000000000..8c083c8aeb --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/linear_advance_screen.h @@ -0,0 +1,32 @@ +/*************************** + * linear_advance_screen.h * + ***************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_LINEAR_ADVANCE_SCREEN +#define FTDI_LINEAR_ADVANCE_SCREEN_CLASS LinearAdvanceScreen + +class LinearAdvanceScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/lock_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/lock_screen.cpp index 766f414a11..f89ad5c44c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/lock_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/lock_screen.cpp @@ -21,21 +21,21 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_LOCK_SCREEN + using namespace FTDI; using namespace Theme; uint16_t LockScreen::passcode = 0; +constexpr static LockScreenData &mydata = screen_data.LockScreen; void LockScreen::onEntry() { - const uint8_t siz = sizeof(screen_data.Lock.passcode); - memset(screen_data.Lock.passcode, '_', siz-1); - screen_data.Lock.passcode[siz-1] = '\0'; + const uint8_t siz = sizeof(mydata.passcode); + memset(mydata.passcode, '_', siz-1); + mydata.passcode[siz-1] = '\0'; BaseScreen::onEntry(); } @@ -84,11 +84,11 @@ void LockScreen::onRedraw(draw_mode_t what) { #if ENABLED(TOUCH_UI_PORTRAIT) .text(BTN_POS(1,2), BTN_SIZE(1,1), message) .font(font_xlarge) - .text(BTN_POS(1,4), BTN_SIZE(1,1), screen_data.Lock.passcode) + .text(BTN_POS(1,4), BTN_SIZE(1,1), mydata.passcode) #else .text(BTN_POS(1,1), BTN_SIZE(1,1), message) .font(font_xlarge) - .text(BTN_POS(1,2), BTN_SIZE(1,1), screen_data.Lock.passcode) + .text(BTN_POS(1,2), BTN_SIZE(1,1), mydata.passcode) #endif .font(font_large) .colors(normal_btn) @@ -117,8 +117,8 @@ void LockScreen::onRedraw(draw_mode_t what) { char &LockScreen::message_style() { // We use the last byte of the passcode string as a flag to indicate, // which message to show. - constexpr uint8_t last_char = sizeof(screen_data.Lock.passcode)-1; - return screen_data.Lock.passcode[last_char]; + constexpr uint8_t last_char = sizeof(mydata.passcode)-1; + return mydata.passcode[last_char]; } void LockScreen::onPasscodeEntered() { @@ -145,10 +145,10 @@ void LockScreen::onPasscodeEntered() { } bool LockScreen::onTouchEnd(uint8_t tag) { - char *c = strchr(screen_data.Lock.passcode,'_'); + char *c = strchr(mydata.passcode,'_'); if (c) { if (tag == '<') { - if (c != screen_data.Lock.passcode) { + if (c != mydata.passcode) { // Backspace deletes previous entered characters. *--c = '_'; } @@ -167,7 +167,7 @@ bool LockScreen::onTouchEnd(uint8_t tag) { uint16_t LockScreen::compute_checksum() { uint16_t checksum = 0; - const char* c = screen_data.Lock.passcode; + const char* c = mydata.passcode; while (*c) { checksum = (checksum << 2) ^ *c++; } @@ -202,4 +202,4 @@ void LockScreen::enable() { GOTO_SCREEN(LockScreen); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_LOCK_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/lock_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/lock_screen.h new file mode 100644 index 0000000000..05ab8bf80f --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/lock_screen.h @@ -0,0 +1,53 @@ +/***************** + * lock_screen.h * + *****************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_LOCK_SCREEN +#define FTDI_LOCK_SCREEN_CLASS LockScreen + +struct LockScreenData { + char passcode[5]; +}; + +class LockScreen : public BaseScreen, public CachedScreen { + private: + friend InterfaceSettingsScreen; + + static uint16_t passcode; + + static char & message_style(); + static uint16_t compute_checksum(); + static void onPasscodeEntered(); + public: + static bool is_enabled(); + static void check_passcode(); + static void enable(); + static void disable(); + + static void set_hash(uint16_t pass) {passcode = pass;}; + static uint16_t get_hash() {return passcode;}; + + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/main_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/main_menu.cpp index 146b799c20..b7914d629b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/main_menu.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/main_menu.cpp @@ -22,11 +22,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && NONE(TOUCH_UI_LULZBOT_BIO,TOUCH_UI_COCOA_PRESS) - #include "screens.h" +#ifdef FTDI_MAIN_MENU + using namespace FTDI; using namespace Theme; @@ -128,4 +127,4 @@ bool MainMenu::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && !TOUCH_UI_LULZBOT_BIO +#endif // FTDI_MAIN_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/main_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/main_menu.h new file mode 100644 index 0000000000..ac1300e1b8 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/main_menu.h @@ -0,0 +1,33 @@ +/*************** + * main_menu.h * + ***************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2019 - Cocoa Press * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_MAIN_MENU +#define FTDI_MAIN_MENU_CLASS MainMenu + +class MainMenu : public BaseScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_acceleration_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_acceleration_screen.cpp index fdbb9623b5..d4d14d6331 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_acceleration_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_acceleration_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_MAX_ACCELERATION_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -83,4 +82,4 @@ bool MaxAccelerationScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_MAX_ACCELERATION_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_acceleration_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_acceleration_screen.h new file mode 100644 index 0000000000..87a79b3bd9 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_acceleration_screen.h @@ -0,0 +1,32 @@ +/***************************** + * max_acceleration_screen.h * + *****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_MAX_ACCELERATION_SCREEN +#define FTDI_MAX_ACCELERATION_SCREEN_CLASS MaxAccelerationScreen + +class MaxAccelerationScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; 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 ac1374b99a..4de3e33360 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 @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_MAX_VELOCITY_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -87,4 +86,4 @@ bool MaxVelocityScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_MAX_VELOCITY_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.h new file mode 100644 index 0000000000..e904a2c058 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/max_velocity_screen.h @@ -0,0 +1,32 @@ +/************************* + * max_velocity_screen.h * + *************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_MAX_VELOCITY_SCREEN +#define FTDI_MAX_VELOCITY_SCREEN_CLASS MaxVelocityScreen + +class MaxVelocityScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/media_player_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/media_player_screen.cpp index eb0b78a325..38e8b0b5c7 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/media_player_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/media_player_screen.cpp @@ -21,6 +21,7 @@ ****************************************************************************/ #include "../config.h" +#include "screens.h" /** * The MediaPlayerScreen allows an AVI to be played. @@ -39,9 +40,7 @@ * ffmpeg -i video.avi -i silence.wav -c copy -map 0:v:0 -map 1:a:0 startup.avi */ -#if ENABLED(TOUCH_UI_FTDI_EVE) - -#include "screens.h" +#ifdef FTDI_MEDIA_PLAYER_SCREEN #include "../archim2-flash/flash_storage.h" #include "../archim2-flash/media_file_reader.h" @@ -165,4 +164,4 @@ void MediaPlayerScreen::playStream(void *obj, media_streamer_func_t *data_stream #endif // FTDI_API_LEVEL >= 810 } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_MEDIA_PLAYER_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/media_player_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/media_player_screen.h new file mode 100644 index 0000000000..510d5a9386 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/media_player_screen.h @@ -0,0 +1,40 @@ +/************************* + * media_player_screen.h * + *************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_MEDIA_PLAYER_SCREEN +#define FTDI_MEDIA_PLAYER_SCREEN_CLASS MediaPlayerScreen + +class MediaPlayerScreen : public BaseScreen, public UncachedScreen { + private: + typedef int16_t media_streamer_func_t(void *obj, void *buff, size_t bytes); + + public: + static bool playCardMedia(); + static bool playBootMedia(); + + static void onEntry(); + static void onRedraw(draw_mode_t); + + static void playStream(void *obj, media_streamer_func_t*); +}; 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 ba38918b1c..5f5971458a 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 @@ -21,15 +21,16 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_MOVE_AXIS_SCREEN + using namespace FTDI; using namespace ExtUI; +constexpr static MoveAxisScreenData &mydata = screen_data.MoveAxisScreen; + void BaseMoveAxisScreen::onEntry() { // Since Marlin keeps only one absolute position for all the extruders, // we have to keep track of the relative motion of individual extruders @@ -37,7 +38,7 @@ void BaseMoveAxisScreen::onEntry() { // screen is entered. LOOP_L_N(i, ExtUI::extruderCount) { - screen_data.MoveAxis.e_rel[i] = 0; + mydata.e_rel[i] = 0; } BaseNumericAdjustmentScreen::onEntry(); } @@ -54,15 +55,15 @@ 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.MoveAxis.e_rel[0], canMove(E0)); + w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E), mydata.e_rel[0], canMove(E0)); #elif HAS_MULTI_EXTRUDER - w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), screen_data.MoveAxis.e_rel[0], canMove(E0)); - w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), screen_data.MoveAxis.e_rel[1], canMove(E1)); + w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), mydata.e_rel[0], canMove(E0)); + w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), mydata.e_rel[1], canMove(E1)); #if EXTRUDERS > 2 - w.adjuster( 12, GET_TEXT_F(MSG_AXIS_E3), screen_data.MoveAxis.e_rel[2], canMove(E2)); + w.adjuster( 12, GET_TEXT_F(MSG_AXIS_E3), mydata.e_rel[2], canMove(E2)); #endif #if EXTRUDERS > 3 - w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), screen_data.MoveAxis.e_rel[3], canMove(E3)); + w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), mydata.e_rel[3], canMove(E3)); #endif #endif w.increments(); @@ -80,19 +81,19 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) { case 6: UI_DECREMENT_AXIS(Z); break; case 7: UI_INCREMENT_AXIS(Z); break; // For extruders, also update relative distances. - case 8: UI_DECREMENT_AXIS(E0); screen_data.MoveAxis.e_rel[0] -= increment; break; - case 9: UI_INCREMENT_AXIS(E0); screen_data.MoveAxis.e_rel[0] += increment; break; + case 8: UI_DECREMENT_AXIS(E0); mydata.e_rel[0] -= increment; break; + case 9: UI_INCREMENT_AXIS(E0); mydata.e_rel[0] += increment; break; #if HAS_MULTI_EXTRUDER - case 10: UI_DECREMENT_AXIS(E1); screen_data.MoveAxis.e_rel[1] -= increment; break; - case 11: UI_INCREMENT_AXIS(E1); screen_data.MoveAxis.e_rel[1] += increment; break; + case 10: UI_DECREMENT_AXIS(E1); mydata.e_rel[1] -= increment; break; + case 11: UI_INCREMENT_AXIS(E1); mydata.e_rel[1] += increment; break; #endif #if EXTRUDERS > 2 - case 12: UI_DECREMENT_AXIS(E2); screen_data.MoveAxis.e_rel[2] -= increment; break; - case 13: UI_INCREMENT_AXIS(E2); screen_data.MoveAxis.e_rel[2] += increment; break; + case 12: UI_DECREMENT_AXIS(E2); mydata.e_rel[2] -= increment; break; + case 13: UI_INCREMENT_AXIS(E2); mydata.e_rel[2] += increment; break; #endif #if EXTRUDERS > 3 - case 14: UI_DECREMENT_AXIS(E3); screen_data.MoveAxis.e_rel[3] -= increment; break; - case 15: UI_INCREMENT_AXIS(E3); screen_data.MoveAxis.e_rel[3] += increment; break; + case 14: UI_DECREMENT_AXIS(E3); mydata.e_rel[3] -= increment; break; + case 15: UI_INCREMENT_AXIS(E3); mydata.e_rel[3] += increment; break; #endif case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28X")); break; case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28Y")); break; @@ -130,4 +131,4 @@ void MoveAxisScreen::onIdle() { BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_MOVE_AXIS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.h new file mode 100644 index 0000000000..6053286eda --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/move_axis_screen.h @@ -0,0 +1,48 @@ +/********************** + * move_axis_screen.h * + **********************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_MOVE_AXIS_SCREEN +#define FTDI_MOVE_AXIS_SCREEN_CLASS MoveAxisScreen + +struct MoveAxisScreenData { + struct BaseNumericAdjustmentScreenData placeholder; + float e_rel[ExtUI::extruderCount]; +}; + +class BaseMoveAxisScreen : public BaseNumericAdjustmentScreen { + private: + static float getManualFeedrate(uint8_t axis, float increment_mm); + public: + static void setManualFeedrate(ExtUI::axis_t, float increment_mm); + static void setManualFeedrate(ExtUI::extruder_t, float increment_mm); + + static void onEntry(); + static bool onTouchHeld(uint8_t tag); +}; + +class MoveAxisScreen : public BaseMoveAxisScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.cpp index 85c7206b04..a444a07cfc 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, HAS_MULTI_HOTEND) - #include "screens.h" +#ifdef FTDI_NOZZLE_OFFSETS_SCREEN + using namespace FTDI; using namespace ExtUI; @@ -70,4 +69,4 @@ bool NozzleOffsetScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_NOZZLE_OFFSETS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.h new file mode 100644 index 0000000000..763f3364ce --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nozzle_offsets_screen.h @@ -0,0 +1,33 @@ +/*************************** + * nozzle_offsets_screen.h * + ***************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_NOZZLE_OFFSETS_SCREEN +#define FTDI_NOZZLE_OFFSETS_SCREEN_CLASS NozzleOffsetScreen + +class NozzleOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; 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 f0d3f7eec5..96ad833b14 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 @@ -21,22 +21,23 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, BABYSTEPPING) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_NUDGE_NOZZLE_SCREEN + using namespace FTDI; using namespace Theme; using namespace ExtUI; +constexpr static NudgeNozzleScreenData &mydata = screen_data.NudgeNozzleScreen; + void NudgeNozzleScreen::onEntry() { - screen_data.NudgeNozzle.show_offsets = false; + mydata.show_offsets = false; #if HAS_MULTI_EXTRUDER - screen_data.NudgeNozzle.link_nozzles = true; + mydata.link_nozzles = true; #endif - screen_data.NudgeNozzle.rel.reset(); + mydata.rel.reset(); BaseNumericAdjustmentScreen::onEntry(); } @@ -47,19 +48,19 @@ void NudgeNozzleScreen::onRedraw(draw_mode_t what) { w.heading(GET_TEXT_F(MSG_NUDGE_NOZZLE)); #if ENABLED(BABYSTEP_XY) - w.color(x_axis).adjuster(2, GET_TEXT_F(MSG_AXIS_X), screen_data.NudgeNozzle.rel.x / getAxisSteps_per_mm(X)); - w.color(y_axis).adjuster(4, GET_TEXT_F(MSG_AXIS_Y), screen_data.NudgeNozzle.rel.y / getAxisSteps_per_mm(Y)); + w.color(x_axis).adjuster(2, GET_TEXT_F(MSG_AXIS_X), mydata.rel.x / getAxisSteps_per_mm(X)); + w.color(y_axis).adjuster(4, GET_TEXT_F(MSG_AXIS_Y), mydata.rel.y / getAxisSteps_per_mm(Y)); #endif - w.color(z_axis).adjuster(6, GET_TEXT_F(MSG_AXIS_Z), screen_data.NudgeNozzle.rel.z / getAxisSteps_per_mm(Z)); + w.color(z_axis).adjuster(6, GET_TEXT_F(MSG_AXIS_Z), mydata.rel.z / getAxisSteps_per_mm(Z)); w.increments(); #if HAS_MULTI_EXTRUDER - w.toggle(8, GET_TEXT_F(MSG_ADJUST_BOTH_NOZZLES), screen_data.NudgeNozzle.link_nozzles); + w.toggle(8, GET_TEXT_F(MSG_ADJUST_BOTH_NOZZLES), mydata.link_nozzles); #endif #if HAS_MULTI_EXTRUDER || HAS_BED_PROBE - w.toggle(9, GET_TEXT_F(MSG_SHOW_OFFSETS), screen_data.NudgeNozzle.show_offsets); + w.toggle(9, GET_TEXT_F(MSG_SHOW_OFFSETS), mydata.show_offsets); - if (screen_data.NudgeNozzle.show_offsets) { + if (mydata.show_offsets) { char str[19]; w.draw_mode(BOTH); @@ -83,22 +84,22 @@ void NudgeNozzleScreen::onRedraw(draw_mode_t what) { bool NudgeNozzleScreen::onTouchHeld(uint8_t tag) { const float inc = getIncrement(); #if HAS_MULTI_EXTRUDER - const bool link = screen_data.NudgeNozzle.link_nozzles; + const bool link = mydata.link_nozzles; #else constexpr bool link = true; #endif int16_t steps; switch (tag) { - case 2: steps = mmToWholeSteps(inc, X); smartAdjustAxis_steps(-steps, X, link); screen_data.NudgeNozzle.rel.x -= steps; break; - case 3: steps = mmToWholeSteps(inc, X); smartAdjustAxis_steps( steps, X, link); screen_data.NudgeNozzle.rel.x += steps; break; - case 4: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps(-steps, Y, link); screen_data.NudgeNozzle.rel.y -= steps; break; - case 5: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps( steps, Y, link); screen_data.NudgeNozzle.rel.y += steps; break; - case 6: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps(-steps, Z, link); screen_data.NudgeNozzle.rel.z -= steps; break; - case 7: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps( steps, Z, link); screen_data.NudgeNozzle.rel.z += steps; break; + case 2: steps = mmToWholeSteps(inc, X); smartAdjustAxis_steps(-steps, X, link); mydata.rel.x -= steps; break; + case 3: steps = mmToWholeSteps(inc, X); smartAdjustAxis_steps( steps, X, link); mydata.rel.x += steps; break; + case 4: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps(-steps, Y, link); mydata.rel.y -= steps; break; + case 5: steps = mmToWholeSteps(inc, Y); smartAdjustAxis_steps( steps, Y, link); mydata.rel.y += steps; break; + case 6: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps(-steps, Z, link); mydata.rel.z -= steps; break; + case 7: steps = mmToWholeSteps(inc, Z); smartAdjustAxis_steps( steps, Z, link); mydata.rel.z += steps; break; #if HAS_MULTI_EXTRUDER - case 8: screen_data.NudgeNozzle.link_nozzles = !link; break; + case 8: mydata.link_nozzles = !link; break; #endif - case 9: screen_data.NudgeNozzle.show_offsets = !screen_data.NudgeNozzle.show_offsets; break; + case 9: mydata.show_offsets = !mydata.show_offsets; break; default: return false; } #if HAS_MULTI_EXTRUDER || HAS_BED_PROBE @@ -120,4 +121,4 @@ void NudgeNozzleScreen::onIdle() { reset_menu_timeout(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_NUDGE_NOZZLE_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.h new file mode 100644 index 0000000000..c490a25fea --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/nudge_nozzle_screen.h @@ -0,0 +1,44 @@ +/****************** + * nudge_nozzle.h * + ******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_NUDGE_NOZZLE_SCREEN +#define FTDI_NUDGE_NOZZLE_SCREEN_CLASS NudgeNozzleScreen + +struct NudgeNozzleScreenData { + struct BaseNumericAdjustmentScreenData placeholder; + xyz_int_t rel; + #if HAS_MULTI_EXTRUDER + bool link_nozzles; + #endif + bool show_offsets; +}; + +class NudgeNozzleScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); + static bool onTouchHeld(uint8_t tag); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.cpp index 9be2239797..8dce1a259c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_RESTORE_FAILSAFE_DIALOG_BOX + using namespace ExtUI; void RestoreFailsafeDialogBox::onRedraw(draw_mode_t) { @@ -48,4 +47,4 @@ bool RestoreFailsafeDialogBox::onTouchEnd(uint8_t tag) { } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_RESTORE_FAILSAFE_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.h new file mode 100644 index 0000000000..84a994730d --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/restore_failsafe_dialog_box.h @@ -0,0 +1,32 @@ +/********************************* + * restore_failsafe_dialog_box.h * + *********************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_RESTORE_FAILSAFE_DIALOG_BOX +#define FTDI_RESTORE_FAILSAFE_DIALOG_BOX_CLASS RestoreFailsafeDialogBox + +class RestoreFailsafeDialogBox : public DialogBoxBaseClass, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/save_settings_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/save_settings_dialog_box.cpp index eff0431a94..a475a9863c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/save_settings_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/save_settings_dialog_box.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_SAVE_SETTINGS_DIALOG_BOX + using namespace ExtUI; bool SaveSettingsDialogBox::needs_save = false; @@ -61,4 +60,4 @@ void SaveSettingsDialogBox::promptToSaveSettings() { GOTO_PREVIOUS(); // No save needed. } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_SAVE_SETTINGS_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/save_settings_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/save_settings_dialog_box.h new file mode 100644 index 0000000000..8985a974fe --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/save_settings_dialog_box.h @@ -0,0 +1,38 @@ +/****************************** + * save_settings_dialog_box.h * + ******************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_SAVE_SETTINGS_DIALOG_BOX +#define FTDI_SAVE_SETTINGS_DIALOG_BOX_CLASS SaveSettingsDialogBox + +class SaveSettingsDialogBox : public DialogBoxBaseClass, public UncachedScreen { + private: + static bool needs_save; + + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); + + static void promptToSaveSettings(); + static void settingsChanged() {needs_save = 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 fe35fc457b..e725a23797 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 @@ -27,71 +27,40 @@ // To save RAM, store state information related to a particular screen // in a union. The values should be initialized in the onEntry method. -struct base_numeric_adjustment_t {uint8_t increment;}; +/** + * The DECL_DATA_IF_INCLUDED macro: + * + * union screen_data_t { + * DECL_DATA_IF_INCLUDED(FTDI_EXAMPLE_SCREEN) + * } + * + * Is a shorthand for: + * + * union screen_data_t { + * #ifdef FTDI_EXAMPLE_SCREEN + * struct ExampleScreenData ExampleScreen; + * #endif + * } + * + */ +#define __DECL_DATA_IF_INCLUDED(CLASS) struct CLASS ## Data CLASS ; +#define _DECL_DATA_IF_INCLUDED(CLASS) __DECL_DATA_IF_INCLUDED(CLASS) +#define DECL_DATA_IF_INCLUDED(HEADER) TERN(HEADER, _DECL_DATA_IF_INCLUDED(HEADER ## _CLASS), ) union screen_data_t { - struct base_numeric_adjustment_t BaseNumericAdjustment; - struct {uint8_t volume; uint8_t brightness;} InterfaceSettings; - struct {char passcode[5];} Lock; - struct {bool isError;} AlertDialog; - struct {bool auto_hide;} SpinnerDialog; - struct {uint8_t file_index;} ConfirmStartPrintDialog; - struct { - uint8_t e_tag, t_tag, repeat_tag; - ExtUI::extruder_t saved_extruder; - #if FILAMENT_UNLOAD_PURGE_LENGTH > 0 - bool need_purge; - #endif - } ChangeFilament; - struct { - struct { - uint8_t is_dir : 1; - uint8_t is_root : 1; - } flags; - uint8_t selected_tag; - 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; - #endif - } Files; - struct { - struct base_numeric_adjustment_t placeholder; - float e_rel[ExtUI::extruderCount]; - } MoveAxis; - #if HAS_MESH - struct { - enum : uint8_t { - MSG_NONE, - MSG_MESH_COMPLETE, - MSG_MESH_INCOMPLETE - } message; - uint8_t count; - uint8_t highlightedTag; - } BedMesh; - #endif - #if ENABLED(TOUCH_UI_DEVELOPER_MENU) - struct { - uint32_t next_watchdog_trigger; - const char* message; - } StressTest; - #endif - #if ENABLED(TOUCH_UI_COCOA_PRESS) - struct { - uint32_t start_ms; - } PreheatTimer; - #endif - #if ENABLED(BABYSTEPPING) - struct { - struct base_numeric_adjustment_t placeholder; - xyz_int_t rel; - #if HAS_MULTI_EXTRUDER - bool link_nozzles; - #endif - bool show_offsets; - } NudgeNozzle; - #endif + DECL_DATA_IF_INCLUDED(FTDI_INTERFACE_SETTINGS_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_LOCK_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_SPINNER_DIALOG_BOX) + DECL_DATA_IF_INCLUDED(FTDI_CONFIRM_START_PRINT_DIALOG_BOX) + DECL_DATA_IF_INCLUDED(FTDI_CHANGE_FILAMENT_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_FILES_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_MOVE_AXIS_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_BED_MESH_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_STRESS_TEST_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_COCOA_PREHEAT_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_NUDGE_NOZZLE_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_BASE_NUMERIC_ADJ_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_ALERT_DIALOG_BOX) }; extern screen_data_t screen_data; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.cpp index 5841c38f53..ab3c3d7114 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.cpp @@ -24,116 +24,98 @@ #if ENABLED(TOUCH_UI_FTDI_EVE) #include "screens.h" -#include "screen_data.h" - tiny_timer_t refresh_timer; -screen_data_t screen_data; + + +/** + * DECL_SCREEN_IF_INCLUDED allows for a concise + * definition of SCREEN_TABLE: + * + * SCREEN_TABLE { + * DECL_SCREEN_IF_INCLUDED(MY_HEADER) + * } + * + * Is a shorthand for: + * + * SCREEN_TABLE { + * #ifdef MY_HEADER + * DECL_SCREEN(MY_HEADER), + * #endif + * } + * + */ +#define COMMA , +#define __DECL_SCREEN_IF_INCLUDED(O,C) THIRD(O, DECL_SCREEN(C) COMMA,) +#define _DECL_SCREEN_IF_INCLUDED(O,C) __DECL_SCREEN_IF_INCLUDED(O ## COMMA, C) +#define DECL_SCREEN_IF_INCLUDED(H) _DECL_SCREEN_IF_INCLUDED(H, H ## _CLASS) SCREEN_TABLE { - DECL_SCREEN(BootScreen), - #if NUM_LANGUAGES > 1 - DECL_SCREEN(LanguageMenu), - #endif - DECL_SCREEN(TouchCalibrationScreen), - DECL_SCREEN(StatusScreen), - DECL_SCREEN(MainMenu), - DECL_SCREEN(TuneMenu), - DECL_SCREEN(AdvancedSettingsMenu), - DECL_SCREEN(AlertDialogBox), - DECL_SCREEN(ConfirmUserRequestAlertBox), - DECL_SCREEN(RestoreFailsafeDialogBox), - DECL_SCREEN(SaveSettingsDialogBox), - DECL_SCREEN(ConfirmStartPrintDialogBox), - DECL_SCREEN(ConfirmAbortPrintDialogBox), - #if ENABLED(CALIBRATION_GCODE) - DECL_SCREEN(ConfirmAutoCalibrationDialogBox), - #endif - #if ENABLED(CUSTOM_USER_MENUS) - DECL_SCREEN(CustomUserMenus), - #endif - DECL_SCREEN(SpinnerDialogBox), - DECL_SCREEN(AboutScreen), - #if ENABLED(PRINTCOUNTER) - DECL_SCREEN(StatisticsScreen), - #endif - #if ENABLED(BABYSTEPPING) - DECL_SCREEN(NudgeNozzleScreen), - #endif - DECL_SCREEN(MoveAxisScreen), - DECL_SCREEN(StepsScreen), - #if HAS_TRINAMIC_CONFIG - DECL_SCREEN(StepperCurrentScreen), - DECL_SCREEN(StepperBumpSensitivityScreen), - #endif - #if HAS_LEVELING - DECL_SCREEN(LevelingMenu), - #if HAS_BED_PROBE - DECL_SCREEN(ZOffsetScreen), - #endif - #if HAS_MESH - DECL_SCREEN(BedMeshScreen), - #endif - #endif - #if HAS_MULTI_HOTEND - DECL_SCREEN(NozzleOffsetScreen), - #endif - #if ENABLED(BACKLASH_GCODE) - DECL_SCREEN(BacklashCompensationScreen), - #endif - DECL_SCREEN(FeedratePercentScreen), - DECL_SCREEN(MaxVelocityScreen), - DECL_SCREEN(MaxAccelerationScreen), - DECL_SCREEN(DefaultAccelerationScreen), - #if HAS_JUNCTION_DEVIATION - DECL_SCREEN(JunctionDeviationScreen), - #else - DECL_SCREEN(JerkScreen), - #endif - #if ENABLED(CASE_LIGHT_ENABLE) - DECL_SCREEN(CaseLightScreen), - #endif - #if EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR) - DECL_SCREEN(FilamentMenu), - #endif - #if ENABLED(FILAMENT_RUNOUT_SENSOR) - DECL_SCREEN(FilamentRunoutScreen), - #endif - #if ENABLED(LIN_ADVANCE) - DECL_SCREEN(LinearAdvanceScreen), - #endif - DECL_SCREEN(TemperatureScreen), - DECL_SCREEN(ChangeFilamentScreen), - DECL_SCREEN(InterfaceSettingsScreen), - DECL_SCREEN(InterfaceSoundsScreen), - DECL_SCREEN(LockScreen), - #if ENABLED(SDSUPPORT) - DECL_SCREEN(FilesScreen), - #endif - DECL_SCREEN(EndstopStatesScreen), - #if ENABLED(TOUCH_UI_LULZBOT_BIO) - DECL_SCREEN(BioPrintingDialogBox), - DECL_SCREEN(BioConfirmHomeXYZ), - DECL_SCREEN(BioConfirmHomeE), - #endif - #if ENABLED(TOUCH_UI_COCOA_PRESS) - DECL_SCREEN(PreheatMenu), - DECL_SCREEN(PreheatTimerScreen), - DECL_SCREEN(UnloadCartridgeScreen), - DECL_SCREEN(LoadChocolateScreen), - DECL_SCREEN(MoveXYZScreen), - DECL_SCREEN(MoveEScreen), - #endif - #if ENABLED(TOUCH_UI_DEVELOPER_MENU) - DECL_SCREEN(DeveloperMenu), - DECL_SCREEN(ConfirmEraseFlashDialogBox), - DECL_SCREEN(WidgetsScreen), - DECL_SCREEN(TouchRegistersScreen), - DECL_SCREEN(StressTestScreen), - #endif - DECL_SCREEN(MediaPlayerScreen), - DECL_SCREEN(DisplayTuningScreen) + DECL_SCREEN_IF_INCLUDED(FTDI_BOOT_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_LANGUAGE_MENU) + DECL_SCREEN_IF_INCLUDED(FTDI_TOUCH_CALIBRATION_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_STATUS_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_MAIN_MENU) + DECL_SCREEN_IF_INCLUDED(FTDI_TUNE_MENU) + DECL_SCREEN_IF_INCLUDED(FTDI_ADVANCED_SETTINGS_MENU) + DECL_SCREEN_IF_INCLUDED(FTDI_ALERT_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_CONFIRM_USER_REQUEST_ALERT_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_RESTORE_FAILSAFE_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_SAVE_SETTINGS_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_CONFIRM_START_PRINT_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_CONFIRM_ABORT_PRINT_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_CONFIRM_AUTO_CALIBRATION_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_CUSTOM_USER_MENUS) + DECL_SCREEN_IF_INCLUDED(FTDI_SPINNER_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_ABOUT_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_STATISTICS_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_NUDGE_NOZZLE_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_MOVE_AXIS_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_STEPS_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_STEPPER_CURRENT_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_STEPPER_BUMP_SENSITIVITY_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_LEVELING_MENU) + DECL_SCREEN_IF_INCLUDED(FTDI_Z_OFFSET_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_BED_MESH_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_NOZZLE_OFFSETS_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_BACKLASH_COMP_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_FEEDRATE_PERCENT_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_MAX_VELOCITY_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_MAX_ACCELERATION_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_DEFAULT_ACCELERATION_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_JUNCTION_DEVIATION_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_JERK_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_CASE_LIGHT_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_FILAMENT_MENU) + DECL_SCREEN_IF_INCLUDED(FTDI_FILAMENT_RUNOUT_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_LINEAR_ADVANCE_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_TEMPERATURE_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_CHANGE_FILAMENT_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_INTERFACE_SETTINGS_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_INTERFACE_SOUNDS_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_LOCK_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_FILES_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_ENDSTOP_STATE_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_BIO_PRINTING_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_BIO_CONFIRMOME_XYZ) + DECL_SCREEN_IF_INCLUDED(FTDI_BIO_CONFIRMOME_E) + DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_PREHEAT_MENU) + DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_PREHEAT_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_UNLOAD_CARTRIDGE_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_LOAD_CHOCOLATE_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_MOVE_XYZ_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_COCOA_MOVE_E_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_DEVELOPER_MENU) + DECL_SCREEN_IF_INCLUDED(FTDI_CONFIRM_ERASE_FLASH_DIALOG_BOX) + DECL_SCREEN_IF_INCLUDED(FTDI_WIDGET_DEMO_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_TOUCH_REGISTERS_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_STRESS_TEST_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_MEDIA_PLAYER_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_DISPLAY_TUNING_SCREEN) }; SCREEN_TABLE_POST +#include "screen_data.h" +screen_data_t screen_data; + #endif // TOUCH_UI_FTDI_EVE 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 51fc76f15b..a82d8988da 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 @@ -22,6 +22,8 @@ #pragma once +#if ENABLED(TOUCH_UI_FTDI_EVE) + #include "../ftdi_eve_lib/ftdi_eve_lib.h" #include "../language/language.h" #include "../theme/theme.h" @@ -127,785 +129,140 @@ enum { /************************* MENU SCREEN DECLARATIONS *************************/ -class BaseScreen : public UIScreen { - protected: - #if LCD_TIMEOUT_TO_STATUS > 0 - static uint32_t last_interaction; - #endif - - static bool buttonIsPressed(uint8_t tag); - - public: - static bool buttonStyleCallback(CommandProcessor &, uint8_t, uint8_t &, uint16_t &, bool); - - static void reset_menu_timeout(); - - static void onEntry(); - static void onIdle(); -}; - -class BootScreen : public BaseScreen, public UncachedScreen { - private: - static void showSplashScreen(); - public: - static void onRedraw(draw_mode_t); - static void onIdle(); -}; - -class AboutScreen : public BaseScreen, public UncachedScreen { - public: - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; - -#if ENABLED(PRINTCOUNTER) - class StatisticsScreen : public BaseScreen, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; -#endif - -class KillScreen { - // The KillScreen is behaves differently than the - // others, so we do not bother extending UIScreen. - public: - static void show(const char*); -}; - -class DialogBoxBaseClass : public BaseScreen { - protected: - template static void drawMessage(const T, int16_t font = 0); - static void drawYesNoButtons(uint8_t default_btn = 0); - static void drawOkayButton(); - static void drawSpinner(); - static void drawButton(const progmem_str); - - static void onRedraw(draw_mode_t) {}; - public: - static bool onTouchEnd(uint8_t tag); - static void onIdle(); -}; - -class AlertDialogBox : public DialogBoxBaseClass, public CachedScreen { - public: - static void onEntry(); - static void onRedraw(draw_mode_t); - template static void show(T); - template static void showError(T); - static void hide(); -}; - -class RestoreFailsafeDialogBox : public DialogBoxBaseClass, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; - -class SaveSettingsDialogBox : public DialogBoxBaseClass, public UncachedScreen { - private: - static bool needs_save; - - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - - static void promptToSaveSettings(); - static void settingsChanged() {needs_save = true;} -}; - -class ConfirmStartPrintDialogBox : public DialogBoxBaseClass, public UncachedScreen { - private: - inline static const char *getShortFilename() {return getFilename(false);} - inline static const char *getLongFilename() {return getFilename(true);} - - static const char *getFilename(bool longName); - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t); - - static void show(uint8_t file_index); -}; - -class ConfirmAbortPrintDialogBox : public DialogBoxBaseClass, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; - -#if ENABLED(CALIBRATION_GCODE) -class ConfirmAutoCalibrationDialogBox : public DialogBoxBaseClass, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; -#endif - -class ConfirmUserRequestAlertBox : public AlertDialogBox { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t); - static void hide(); - static void show(const char*); -}; - -#if ENABLED(CUSTOM_USER_MENUS) - class CustomUserMenus : public BaseScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; -#endif - -class SpinnerDialogBox : public DialogBoxBaseClass, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static void onIdle(); - - static void show(const progmem_str); - static void hide(); - static void enqueueAndWait_P(const progmem_str commands); - static void enqueueAndWait_P(const progmem_str message, const progmem_str commands); -}; - -#if NONE(TOUCH_UI_LULZBOT_BIO, TOUCH_UI_COCOA_PRESS) -class StatusScreen : public BaseScreen, public CachedScreen { - private: - static void draw_axis_position(draw_mode_t); - static void draw_temperature(draw_mode_t); - static void draw_progress(draw_mode_t); - static void draw_interaction_buttons(draw_mode_t); - static void draw_status_message(draw_mode_t, const char * const); - static void _format_time(char *outstr, uint32_t time); - public: - static void loadBitmaps(); - static void setStatusMessage(const char *); - static void setStatusMessage(progmem_str); - static void onRedraw(draw_mode_t); - static void onStartup(); - static void onEntry(); - static void onIdle(); - static bool onTouchEnd(uint8_t tag); -}; -#else - class StatusScreen : public BaseScreen, public CachedScreen { - private: - static float increment; - static bool jog_xy; - static bool fine_motion; - - static void draw_progress(draw_mode_t what); - static void draw_temperature(draw_mode_t what); - static void draw_syringe(draw_mode_t what); - static void draw_arrows(draw_mode_t what); - static void draw_overlay_icons(draw_mode_t what); - static void draw_fine_motion(draw_mode_t what); - static void draw_buttons(draw_mode_t what); - public: - static void loadBitmaps(); - static void unlockMotors(); - - static void setStatusMessage(const char *); - static void setStatusMessage(progmem_str); - - static void onRedraw(draw_mode_t); - - static bool onTouchStart(uint8_t tag); - static bool onTouchHeld(uint8_t tag); - static bool onTouchEnd(uint8_t tag); - static void onIdle(); - - }; -#endif +#include "base_screen.h" +#include "base_numeric_adjustment_screen.h" +#include "dialog_box_base_class.h" #if ENABLED(TOUCH_UI_LULZBOT_BIO) - class BioPrintingDialogBox : public BaseScreen, public CachedScreen { - private: - static void draw_status_message(draw_mode_t, const char * const); - static void draw_progress(draw_mode_t); - static void draw_time_remaining(draw_mode_t); - static void draw_interaction_buttons(draw_mode_t); - public: - static void onRedraw(draw_mode_t); + #include "bio_status_screen.h" + #include "bio_main_menu.h" + #include "bio_tune_menu.h" + #include "bio_advanced_settings.h" + #include "bio_printing_dialog_box.h" + #include "bio_confirm_home_xyz.h" + #include "bio_confirm_home_e.h" - static void show(); +#elif ENABLED(TOUCH_UI_COCOA_PRESS) + #include "cocoa_press_status_screen.h" + #include "cocoa_press_main_menu.h" + #include "cocoa_press_advanced_settings.h" + #include "cocoa_press_preheat_menu.h" + #include "cocoa_press_preheat_screen.h" + #include "cocoa_press_unload_cartridge.h" + #include "cocoa_press_load_chocolate.h" + #include "cocoa_press_move_xyz_screen.h" + #include "cocoa_press_move_e_screen.h" + #include "tune_menu.h" - static void setStatusMessage(const char *); - static void setStatusMessage(progmem_str); - - static void onIdle(); - static bool onTouchEnd(uint8_t tag); - }; - - class BioConfirmHomeXYZ : public DialogBoxBaseClass, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; - - class BioConfirmHomeE : public DialogBoxBaseClass, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; +#else + #include "status_screen.h" + #include "main_menu.h" + #include "advanced_settings_menu.h" + #include "tune_menu.h" #endif -class MainMenu : public BaseScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; +#include "boot_screen.h" +#include "about_screen.h" +#include "kill_screen.h" +#include "alert_dialog_box.h" +#include "spinner_dialog_box.h" +#include "restore_failsafe_dialog_box.h" +#include "save_settings_dialog_box.h" +#include "confirm_start_print_dialog_box.h" +#include "confirm_abort_print_dialog_box.h" +#include "confirm_user_request_alert_box.h" +#include "touch_calibration_screen.h" +#include "touch_registers_screen.h" +#include "change_filament_screen.h" +#include "move_axis_screen.h" +#include "steps_screen.h" +#include "stepper_current_screen.h" +#include "feedrate_percent_screen.h" +#include "max_velocity_screen.h" +#include "max_acceleration_screen.h" +#include "default_acceleration_screen.h" +#include "temperature_screen.h" +#include "interface_sounds_screen.h" +#include "interface_settings_screen.h" +#include "lock_screen.h" +#include "endstop_state_screen.h" +#include "display_tuning_screen.h" +#include "media_player_screen.h" -class TuneMenu : public BaseScreen, public CachedScreen { - private: - static void pausePrint(); - static void resumePrint(); - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; - -class TouchCalibrationScreen : public BaseScreen, public UncachedScreen { - public: - static void onRefresh(); - static void onEntry(); - static void onRedraw(draw_mode_t); - static void onIdle(); -}; - -class TouchRegistersScreen : public BaseScreen, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; - -class AdvancedSettingsMenu : public BaseScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; - -class ChangeFilamentScreen : public BaseScreen, public CachedScreen { - private: - static uint8_t getSoftenTemp(); - static ExtUI::extruder_t getExtruder(); - static void drawTempGradient(uint16_t x, uint16_t y, uint16_t w, uint16_t h); - static uint32_t getTempColor(uint32_t temp); - static void doPurge(); - public: - static void onEntry(); - static void onExit(); - static void onRedraw(draw_mode_t); - static bool onTouchStart(uint8_t tag); - static bool onTouchEnd(uint8_t tag); - static bool onTouchHeld(uint8_t tag); - static void onIdle(); -}; - -class BaseNumericAdjustmentScreen : public BaseScreen { - public: - enum precision_default_t { - DEFAULT_LOWEST, - DEFAULT_MIDRANGE, - DEFAULT_HIGHEST - }; - - protected: - class widgets_t { - private: - draw_mode_t _what; - uint8_t _line; - uint32_t _color; - uint8_t _decimals; - progmem_str _units; - enum style_t { - BTN_NORMAL, - BTN_ACTION, - BTN_TOGGLE, - BTN_DISABLED, - TEXT_AREA, - TEXT_LABEL - } _style; - - protected: - void _draw_increment_btn(CommandProcessor &, uint8_t line, const uint8_t tag); - void _button(CommandProcessor &, uint8_t tag, int16_t x, int16_t y, int16_t w, int16_t h, progmem_str, bool enabled = true, bool highlight = false); - void _button_style(CommandProcessor &cmd, style_t style); - public: - widgets_t(draw_mode_t); - - widgets_t &color(uint32_t color) {_color = color; return *this;} - widgets_t &units(progmem_str units) {_units = units; return *this;} - widgets_t &draw_mode(draw_mode_t what) {_what = what; return *this;} - widgets_t &precision(uint8_t decimals, precision_default_t = DEFAULT_HIGHEST); - - void heading (progmem_str label); - void adjuster_sram_val (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true); - void adjuster (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true); - void adjuster (uint8_t tag, progmem_str label, float value=0, bool is_enabled = true); - void button (uint8_t tag, progmem_str label, bool is_enabled = true); - void text_field (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true); - void two_buttons (uint8_t tag1, progmem_str label1, - uint8_t tag2, progmem_str label2, bool is_enabled = true); - void toggle (uint8_t tag, progmem_str label, bool value, bool is_enabled = true); - void home_buttons (uint8_t tag); - void increments (); - }; - - static float getIncrement(); - - public: - static void onEntry(); - static bool onTouchEnd(uint8_t tag); -}; - -class BaseMoveAxisScreen : public BaseNumericAdjustmentScreen { - private: - static float getManualFeedrate(uint8_t axis, float increment_mm); - public: - static void setManualFeedrate(ExtUI::axis_t, float increment_mm); - static void setManualFeedrate(ExtUI::extruder_t, float increment_mm); - - static void onEntry(); - static bool onTouchHeld(uint8_t tag); -}; - -class MoveAxisScreen : public BaseMoveAxisScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static void onIdle(); -}; - -class StepsScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); -}; +#if ENABLED(PRINTCOUNTER) + #include "statistics_screen.h" +#endif #if HAS_TRINAMIC_CONFIG - class StepperCurrentScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; - - class StepperBumpSensitivityScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "stepper_current_screen.h" + #include "stepper_bump_sensitivity_screen.h" #endif #if HAS_MULTI_HOTEND - class NozzleOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "nozzle_offsets_screen.h" #endif #if HAS_LEVELING - - class LevelingMenu : public BaseScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; - + #include "leveling_menu.h" #if HAS_BED_PROBE - class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "z_offset_screen.h" #endif - #if HAS_MESH + #include "bed_mesh_screen.h" + #endif +#endif - class BedMeshScreen : public BaseScreen, public CachedScreen { - private: - enum MeshOpts { - USE_POINTS = 0x01, - USE_COLORS = 0x02, - USE_TAGS = 0x04, - USE_HIGHLIGHT = 0x08, - USE_AUTOSCALE = 0x10 - }; - - static uint8_t pointToTag(uint8_t x, uint8_t y); - static bool tagToPoint(uint8_t tag, uint8_t &x, uint8_t &y); - static float getHightlightedValue(); - static void drawHighlightedPointValue(); - static void drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::bed_mesh_t data, uint8_t opts, float autoscale_max = 0.1); - - public: - static void onMeshUpdate(const int8_t x, const int8_t y, const float val); - static void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t); - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchStart(uint8_t tag); - static bool onTouchEnd(uint8_t tag); - - static void startMeshProbe(); - }; - - #endif // HAS_MESH - -#endif // HAS_LEVELING +#if ENABLED(CALIBRATION_GCODE) + #include "confirm_auto_calibration_dialog_box.h" +#endif #if ENABLED(BABYSTEPPING) - class NudgeNozzleScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - static bool onTouchHeld(uint8_t tag); - static void onIdle(); - }; + #include "nudge_nozzle_screen.h" #endif #if ENABLED(BACKLASH_GCODE) - class BacklashCompensationScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "backlash_compensation_screen.h" #endif -class FeedratePercentScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); -}; - -class MaxVelocityScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); -}; - -class MaxAccelerationScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); -}; - -class DefaultAccelerationScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); -}; - #if HAS_JUNCTION_DEVIATION - class JunctionDeviationScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "junction_deviation_screen.h" #else - class JerkScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "jerk_screen.h" #endif #if ENABLED(CASE_LIGHT_ENABLE) - class CaseLightScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "case_light_screen.h" #endif #if EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR) - class FilamentMenu : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; + #include "filament_menu.h" #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) - class FilamentRunoutScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "filament_runout_screen.h" #endif #if ENABLED(LIN_ADVANCE) - class LinearAdvanceScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); - }; + #include "linear_advance_screen.h" #endif -class TemperatureScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); -}; - -class InterfaceSoundsScreen : public BaseScreen, public CachedScreen { - public: - enum event_t { - PRINTING_STARTED = 0, - PRINTING_FINISHED = 1, - PRINTING_FAILED = 2, - - NUM_EVENTS - }; - - private: - friend class InterfaceSettingsScreen; - - static uint8_t event_sounds[NUM_EVENTS]; - - static const char* getSoundSelection(event_t); - static void toggleSoundSelection(event_t); - static void setSoundSelection(event_t, const FTDI::SoundPlayer::sound_t*); - - public: - static void playEventSound(event_t, FTDI::play_mode_t = FTDI::PLAY_ASYNCHRONOUS); - - static void defaultSettings(); - - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchStart(uint8_t tag); - static bool onTouchEnd(uint8_t tag); - static void onIdle(); -}; - -class InterfaceSettingsScreen : public BaseScreen, public CachedScreen { - private: - struct persistent_data_t { - uint32_t touch_transform_a; - uint32_t touch_transform_b; - uint32_t touch_transform_c; - uint32_t touch_transform_d; - uint32_t touch_transform_e; - uint32_t touch_transform_f; - uint16_t passcode; - uint8_t display_brightness; - int8_t display_h_offset_adj; - int8_t display_v_offset_adj; - uint8_t sound_volume; - uint8_t bit_flags; - uint8_t event_sounds[InterfaceSoundsScreen::NUM_EVENTS]; - }; - - public: - #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE - static bool backupEEPROM(); - #endif - - static void saveSettings(char *); - static void loadSettings(const char *); - static void defaultSettings(); - static void failSafeSettings(); - - static void onStartup(); - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchStart(uint8_t tag); - static bool onTouchEnd(uint8_t tag); - static void onIdle(); -}; - -class LockScreen : public BaseScreen, public CachedScreen { - private: - friend InterfaceSettingsScreen; - - static uint16_t passcode; - - static char & message_style(); - static uint16_t compute_checksum(); - static void onPasscodeEntered(); - public: - static bool is_enabled(); - static void check_passcode(); - static void enable(); - static void disable(); - - static void set_hash(uint16_t pass) {passcode = pass;}; - static uint16_t get_hash() {return passcode;}; - - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); -}; - #if ENABLED(SDSUPPORT) - - class FilesScreen : public BaseScreen, public CachedScreen { - private: - #if ENABLED(TOUCH_UI_PORTRAIT) - static constexpr uint8_t header_h = 2; - static constexpr uint8_t footer_h = 2; - static constexpr uint8_t files_per_page = 11; - #else - static constexpr uint8_t header_h = 1; - static constexpr uint8_t footer_h = 1; - static constexpr uint8_t files_per_page = 6; - #endif - - static uint8_t getTagForLine(uint8_t line) {return line + 2;} - static uint8_t getLineForTag(uint8_t tag) {return tag - 2;} - static uint16_t getFileForTag(uint8_t tag); - static uint16_t getSelectedFileIndex(); - - inline static const char *getSelectedShortFilename() {return getSelectedFilename(false);} - inline static const char *getSelectedLongFilename() {return getSelectedFilename(true);} - static const char *getSelectedFilename(bool longName); - - static void drawFileButton(const char* filename, uint8_t tag, bool is_dir, bool is_highlighted); - static void drawFileList(); - static void drawHeader(); - static void drawFooter(); - static void drawSelectedFile(); - - static void gotoPage(uint8_t); - public: - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - static void onIdle(); - }; - -#endif // SDSUPPORT - -class EndstopStatesScreen : public BaseScreen, public UncachedScreen { - public: - static void onEntry(); - static void onExit(); - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - static void onIdle(); -}; - -class DisplayTuningScreen : public BaseNumericAdjustmentScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchHeld(uint8_t tag); -}; - -#if ENABLED(TOUCH_UI_DEVELOPER_MENU) - - class DeveloperMenu : public BaseScreen, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; - - class ConfirmEraseFlashDialogBox : public DialogBoxBaseClass, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; - - class WidgetsScreen : public BaseScreen, public UncachedScreen { - public: - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchStart(uint8_t tag); - static void onIdle(); - }; - - class StressTestScreen : public BaseScreen, public UncachedScreen { - private: - static void drawDots(uint16_t x, uint16_t y, uint16_t h, uint16_t v); - static bool watchDogTestNow(); - static void recursiveLockup(); - static void iterativeLockup(); - static void runTestOnBootup(bool enable); - - public: - static void startupCheck(); - - static void onEntry(); - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - static void onIdle(); - }; - -#endif // TOUCH_UI_DEVELOPER_MENU - -class MediaPlayerScreen : public BaseScreen, public UncachedScreen { - private: - typedef int16_t media_streamer_func_t(void *obj, void *buff, size_t bytes); - - public: - static bool playCardMedia(); - static bool playBootMedia(); - - static void onEntry(); - static void onRedraw(draw_mode_t); - - static void playStream(void *obj, media_streamer_func_t*); -}; - -#if NUM_LANGUAGES > 1 - class LanguageMenu : public BaseScreen, public UncachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; + #include "files_screen.h" #endif -#if ENABLED(TOUCH_UI_COCOA_PRESS) +#if ENABLED(CUSTOM_USER_MENUS) + #include "custom_user_menus.h" +#endif - class PreheatMenu : public BaseScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - }; +#if ENABLED(TOUCH_UI_DEVELOPER_MENU) + #include "developer_menu.h" + #include "confirm_erase_flash_dialog_box.h" + #include "widget_demo_screen.h" + #include "stress_test_screen.h" +#endif - class PreheatTimerScreen : public BaseScreen, public CachedScreen { - private: - static uint16_t secondsRemaining(); +#if NUM_LANGUAGES > 1 + #include "language_menu.h" +#endif - static void draw_message(draw_mode_t); - static void draw_time_remaining(draw_mode_t); - static void draw_interaction_buttons(draw_mode_t); - static void draw_adjuster(draw_mode_t, uint8_t tag, progmem_str label, float value, int16_t x, int16_t y, int16_t w, int16_t h); - public: - static void onRedraw(draw_mode_t); - - static void onEntry(); - static void onIdle(); - static bool onTouchHeld(uint8_t tag); - static bool onTouchEnd(uint8_t tag); - }; - - class UnloadCartridgeScreen : public BaseScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - static bool onTouchHeld(uint8_t tag); - }; - - class LoadChocolateScreen : public BaseScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static bool onTouchEnd(uint8_t tag); - static bool onTouchHeld(uint8_t tag); - }; - - class MoveXYZScreen : public BaseMoveAxisScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static void onIdle(); - }; - - class MoveEScreen : public BaseMoveAxisScreen, public CachedScreen { - public: - static void onRedraw(draw_mode_t); - static void onIdle(); - }; - -#endif // TOUCH_UI_COCOA_PRESS +#endif // TOUCH_UI_FTDI_EVE diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/spinner_dialog_box.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/spinner_dialog_box.cpp index 2318a0d108..7483261e3c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/spinner_dialog_box.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/spinner_dialog_box.cpp @@ -21,15 +21,16 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_SPINNER_DIALOG_BOX + using namespace FTDI; using namespace ExtUI; +constexpr static SpinnerDialogBoxData &mydata = screen_data.SpinnerDialogBox; + void SpinnerDialogBox::onRedraw(draw_mode_t) { } @@ -37,7 +38,7 @@ void SpinnerDialogBox::show(const progmem_str message) { drawMessage(message); drawSpinner(); storeBackground(); - screen_data.SpinnerDialog.auto_hide = false; + mydata.auto_hide = false; } void SpinnerDialogBox::hide() { @@ -53,16 +54,16 @@ void SpinnerDialogBox::enqueueAndWait_P(const progmem_str message, const progmem show(message); GOTO_SCREEN(SpinnerDialogBox); ExtUI::injectCommands_P((const char*)commands); - screen_data.SpinnerDialog.auto_hide = true; + mydata.auto_hide = true; } void SpinnerDialogBox::onIdle() { reset_menu_timeout(); - if (screen_data.SpinnerDialog.auto_hide && !commandsInQueue()) { - screen_data.SpinnerDialog.auto_hide = false; + if (mydata.auto_hide && !commandsInQueue()) { + mydata.auto_hide = false; hide(); GOTO_PREVIOUS(); } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_SPINNER_DIALOG_BOX diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/spinner_dialog_box.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/spinner_dialog_box.h new file mode 100644 index 0000000000..c5f0ae8e9f --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/spinner_dialog_box.h @@ -0,0 +1,41 @@ +/************************ + * spinner_dialog_box.h * + ************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_SPINNER_DIALOG_BOX +#define FTDI_SPINNER_DIALOG_BOX_CLASS SpinnerDialogBox + +struct SpinnerDialogBoxData { + bool auto_hide; +}; + +class SpinnerDialogBox : public DialogBoxBaseClass, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static void onIdle(); + + static void show(const progmem_str); + static void hide(); + static void enqueueAndWait_P(const progmem_str commands); + static void enqueueAndWait_P(const progmem_str message, const progmem_str commands); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/statistics_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/statistics_screen.cpp index 0e224da967..2d62d5349b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/statistics_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/statistics_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, PRINTCOUNTER) - #include "screens.h" +#ifdef FTDI_STATISTICS_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -75,4 +74,4 @@ bool StatisticsScreen::onTouchEnd(uint8_t tag) { } } -#endif // TOUCH_UI_FTDI_EVE && PRINTCOUNTER +#endif // FTDI_STATISTICS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/statistics_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/statistics_screen.h new file mode 100644 index 0000000000..4176f54101 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/statistics_screen.h @@ -0,0 +1,32 @@ +/*********************** + * statistics_screen.h * + ***********************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_STATISTICS_SCREEN +#define FTDI_STATISTICS_SCREEN_CLASS StatisticsScreen + +class StatisticsScreen : public BaseScreen, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; 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 51f50343e0..956795c977 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 @@ -21,12 +21,11 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && NONE(TOUCH_UI_LULZBOT_BIO, TOUCH_UI_COCOA_PRESS) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_STATUS_SCREEN + #include "../archim2-flash/flash_storage.h" using namespace FTDI; @@ -462,4 +461,4 @@ bool StatusScreen::onTouchEnd(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_STATUS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.h new file mode 100644 index 0000000000..3a2ba1746c --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/status_screen.h @@ -0,0 +1,45 @@ +/******************* + * status_screen.h * + *******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_STATUS_SCREEN +#define FTDI_STATUS_SCREEN_CLASS StatusScreen + +class StatusScreen : public BaseScreen, public CachedScreen { + private: + static void draw_axis_position(draw_mode_t); + static void draw_temperature(draw_mode_t); + static void draw_progress(draw_mode_t); + static void draw_interaction_buttons(draw_mode_t); + static void draw_status_message(draw_mode_t, const char * const); + static void _format_time(char *outstr, uint32_t time); + public: + static void loadBitmaps(); + static void setStatusMessage(const char *); + static void setStatusMessage(progmem_str); + static void onRedraw(draw_mode_t); + static void onStartup(); + static void onEntry(); + static void onIdle(); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_bump_sensitivity_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_bump_sensitivity_screen.cpp index 84d76dcefa..701fb78062 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_bump_sensitivity_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_bump_sensitivity_screen.cpp @@ -1,5 +1,5 @@ -/************************************** - * stepper_bump_sensiivity_screen.cpp * +/*************************************** + * stepper_bump_sensitivity_screen.cpp * **************************************/ /**************************************************************************** @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, HAS_TRINAMIC_CONFIG) - #include "screens.h" +#ifdef FTDI_STEPPER_BUMP_SENSITIVITY_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -56,4 +55,4 @@ bool StepperBumpSensitivityScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && HAS_TRINAMIC_CONFIG +#endif // FTDI_STEPPER_BUMP_SENSITIVITY_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_bump_sensitivity_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_bump_sensitivity_screen.h new file mode 100644 index 0000000000..b37b8014e8 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_bump_sensitivity_screen.h @@ -0,0 +1,32 @@ +/************************************* + * stepper_bump_sensitivity_screen.h * + *************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_STEPPER_BUMP_SENSITIVITY_SCREEN +#define FTDI_STEPPER_BUMP_SENSITIVITY_SCREEN_CLASS StepperBumpSensitivityScreen + +class StepperBumpSensitivityScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; 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 d6e36c1efa..4b63b1f3e4 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 @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, HAS_TRINAMIC_CONFIG) - #include "screens.h" +#ifdef FTDI_STEPPER_CURRENT_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -124,4 +123,4 @@ bool StepperCurrentScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_STEPPER_CURRENT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.h new file mode 100644 index 0000000000..9186eb1637 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stepper_current_screen.h @@ -0,0 +1,32 @@ +/**************************** + * stepper_current_screen.h * + ****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_STEPPER_CURRENT_SCREEN +#define FTDI_STEPPER_CURRENT_SCREEN_CLASS StepperCurrentScreen + +class StepperCurrentScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; 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 e9bc50ae45..ec812b776b 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 @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_STEPS_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -83,4 +82,4 @@ bool StepsScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_STEPS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.h new file mode 100644 index 0000000000..68a3ced8fa --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/steps_screen.h @@ -0,0 +1,32 @@ +/****************** + * steps_screen.h * + ******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_STEPS_SCREEN +#define FTDI_STEPS_SCREEN_CLASS StepsScreen + +class StepsScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; 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 6c4aab6d31..37fe81938e 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 @@ -21,12 +21,11 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_DEVELOPER_MENU) - #include "screens.h" #include "screen_data.h" +#ifdef FTDI_STRESS_TEST_SCREEN + #define STRESS_TEST_CHANGE_INTERVAL 6000 #define GRID_COLS 4 @@ -36,6 +35,8 @@ using namespace FTDI; using namespace Theme; using namespace ExtUI; +constexpr static StressTestScreenData &mydata = screen_data.StressTestScreen; + 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++) { @@ -47,8 +48,8 @@ void StressTestScreen::drawDots(uint16_t x, uint16_t y, uint16_t w, uint16_t h) } bool StressTestScreen::watchDogTestNow() { - return screen_data.StressTest.next_watchdog_trigger && - ELAPSED(millis(), screen_data.StressTest.next_watchdog_trigger); + return mydata.next_watchdog_trigger && + ELAPSED(millis(), mydata.next_watchdog_trigger); } void StressTestScreen::onRedraw(draw_mode_t) { @@ -58,7 +59,7 @@ void StressTestScreen::onRedraw(draw_mode_t) { .cmd(CLEAR(true,true,true)) .cmd(COLOR_RGB(bg_text_enabled)) .font(font_medium) - .text(BTN_POS(1,1), BTN_SIZE(4,1), progmem_str(screen_data.StressTest.message)); + .text(BTN_POS(1,1), BTN_SIZE(4,1), progmem_str(mydata.message)); drawDots(BTN_POS(1,3), BTN_SIZE(4,4)); @@ -92,8 +93,8 @@ void StressTestScreen::startupCheck() { } void StressTestScreen::onEntry() { - screen_data.StressTest.next_watchdog_trigger = millis() + 10000 + random(40000); - screen_data.StressTest.message = PSTR("Test 1: Stress testing..."); + mydata.next_watchdog_trigger = millis() + 10000 + random(40000); + mydata.message = PSTR("Test 1: Stress testing..."); // Turn off heaters. setTargetTemp_celsius(0, E0); @@ -104,13 +105,13 @@ void StressTestScreen::onEntry() { } void StressTestScreen::recursiveLockup() { - screen_data.StressTest.message = PSTR("Test 2: Printer will restart."); + mydata.message = PSTR("Test 2: Printer will restart."); current_screen.onRefresh(); recursiveLockup(); } void StressTestScreen::iterativeLockup() { - screen_data.StressTest.message = PSTR("Test 3: Printer will restart."); + mydata.message = PSTR("Test 3: Printer will restart."); for (;;) current_screen.onRefresh(); } @@ -146,4 +147,4 @@ void StressTestScreen::onIdle() { BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_STRESS_TEST_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.h new file mode 100644 index 0000000000..f35f11adb6 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/stress_test_screen.h @@ -0,0 +1,48 @@ +/************************ + * stress_test_screen.h * + ************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_STRESS_TEST_SCREEN +#define FTDI_STRESS_TEST_SCREEN_CLASS StressTestScreen + +struct StressTestScreenData { + uint32_t next_watchdog_trigger; + const char* message; +}; + +class StressTestScreen : public BaseScreen, public UncachedScreen { + private: + static void drawDots(uint16_t x, uint16_t y, uint16_t h, uint16_t v); + static bool watchDogTestNow(); + static void recursiveLockup(); + static void iterativeLockup(); + static void runTestOnBootup(bool enable); + + public: + static void startupCheck(); + + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.cpp index bdd434b5de..ee78591230 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.cpp @@ -1,6 +1,6 @@ -/******************* - * boot_screen.cpp * - *******************/ +/************************** + * temperature_screen.cpp * + **************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_TEMPERATURE_SCREEN + using namespace FTDI; using namespace Theme; using namespace ExtUI; @@ -116,4 +115,4 @@ bool TemperatureScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_TEMPERATURE_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.h new file mode 100644 index 0000000000..de928c8978 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.h @@ -0,0 +1,32 @@ +/************************ + * temperature_screen.h * + ************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_TEMPERATURE_SCREEN +#define FTDI_TEMPERATURE_SCREEN_CLASS TemperatureScreen + +class TemperatureScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.cpp index b5312add5a..37f0c5d33a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "screens.h" +#ifdef FTDI_TOUCH_CALIBRATION_SCREEN + using namespace FTDI; using namespace Theme; @@ -91,4 +90,4 @@ void TouchCalibrationScreen::onIdle() { } } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_TOUCH_CALIBRATION_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.h new file mode 100644 index 0000000000..b4e6cfb66c --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_calibration_screen.h @@ -0,0 +1,34 @@ +/****************************** + * touch_calibration_screen.h * + ******************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_TOUCH_CALIBRATION_SCREEN +#define FTDI_TOUCH_CALIBRATION_SCREEN_CLASS TouchCalibrationScreen + +class TouchCalibrationScreen : public BaseScreen, public UncachedScreen { + public: + static void onRefresh(); + static void onEntry(); + static void onRedraw(draw_mode_t); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_registers_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_registers_screen.cpp index 3739413213..01c7169a3e 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_registers_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_registers_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_DEVELOPER_MENU) - #include "screens.h" +#ifdef FTDI_TOUCH_REGISTERS_SCREEN + using namespace FTDI; using namespace Theme; @@ -83,4 +82,4 @@ void TouchRegistersScreen::onRedraw(draw_mode_t) { return true; } -#endif // TOUCH_UI_FTDI_EVE +#endif // FTDI_TOUCH_REGISTERS_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_registers_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_registers_screen.h new file mode 100644 index 0000000000..b6d4ba8e00 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/touch_registers_screen.h @@ -0,0 +1,32 @@ +/**************************** + * touch_registers_screen.h * + ****************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_TOUCH_REGISTERS_SCREEN +#define FTDI_TOUCH_REGISTERS_SCREEN_CLASS TouchRegistersScreen + +class TouchRegistersScreen : public BaseScreen, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; 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 5a290109ff..c7ff97ea65 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 @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && DISABLED(TOUCH_UI_LULZBOT_BIO) - #include "screens.h" +#ifdef FTDI_TUNE_MENU + #include "../../../../../feature/host_actions.h" using namespace FTDI; @@ -153,4 +152,4 @@ void TuneMenu::resumePrint() { GOTO_SCREEN(StatusScreen); } -#endif // TOUCH_UI_FTDI_EVE && !TOUCH_UI_LULZBOT_BIO +#endif // FTDI_TUNE_MENU diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/tune_menu.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/tune_menu.h new file mode 100644 index 0000000000..b8f9373b19 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/tune_menu.h @@ -0,0 +1,35 @@ +/*************** + * tune_menu.h * + ***************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_TUNE_MENU +#define FTDI_TUNE_MENU_CLASS TuneMenu + +class TuneMenu : public BaseScreen, public CachedScreen { + private: + static void pausePrint(); + static void resumePrint(); + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/widget_demo_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/widget_demo_screen.cpp index 96887102dc..451b7e786e 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/widget_demo_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/widget_demo_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_DEVELOPER_MENU) - #include "screens.h" +#ifdef FTDI_WIDGET_DEMO_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -155,4 +154,4 @@ void WidgetsScreen::onIdle() { BaseScreen::onIdle(); } -#endif // TOUCH_UI_FTDI_EVE && TOUCH_UI_DEVELOPER_MENU +#endif // FTDI_WIDGET_DEMO_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/widget_demo_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/widget_demo_screen.h new file mode 100644 index 0000000000..e0f7422d12 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/widget_demo_screen.h @@ -0,0 +1,34 @@ +/************************ + * widget_demo_screen.h * + ************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_WIDGET_DEMO_SCREEN +#define FTDI_WIDGET_DEMO_SCREEN_CLASS WidgetsScreen + +class WidgetsScreen : public BaseScreen, public UncachedScreen { + public: + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchStart(uint8_t tag); + static void onIdle(); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/z_offset_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/z_offset_screen.cpp index 0acfbb07d6..51c9ca79b0 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/z_offset_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/z_offset_screen.cpp @@ -21,11 +21,10 @@ ****************************************************************************/ #include "../config.h" - -#if ENABLED(TOUCH_UI_FTDI_EVE) && BOTH(HAS_LEVELING, HAS_BED_PROBE) - #include "screens.h" +#ifdef FTDI_Z_OFFSET_SCREEN + using namespace FTDI; using namespace ExtUI; using namespace Theme; @@ -51,4 +50,4 @@ bool ZOffsetScreen::onTouchHeld(uint8_t tag) { return true; } -#endif // TOUCH_UI_FTDI_EVE && HAS_BED_PROBE +#endif // FTDI_Z_OFFSET_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/z_offset_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/z_offset_screen.h new file mode 100644 index 0000000000..24f38e827c --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/z_offset_screen.h @@ -0,0 +1,32 @@ +/*********************** + * z_offset_screen.h * + ***********************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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: . * + ****************************************************************************/ + +#pragma once + +#define FTDI_Z_OFFSET_SCREEN +#define FTDI_Z_OFFSET_SCREEN_CLASS ZOffsetScreen + +class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchHeld(uint8_t tag); +}; 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 8310305e61..92a2fb12b5 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 @@ -31,4 +31,3 @@ extern void lv_clear_tmc_current_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ #endif - diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h index 1187741ad6..77ba5925a3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h @@ -33,6 +33,3 @@ extern void disp_wifi_state(); #ifdef __cplusplus } /* C-declarations for C++ */ #endif - - - 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 index f9896edcc8..2f9c9f5745 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h @@ -48,4 +48,3 @@ extern TIPS_DISP tips_disp; #ifdef __cplusplus } /* C-declarations for C++ */ #endif - From e34f27929549a601a2efe13bb0f5e2b3ebe2c30f Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 7 Feb 2021 00:12:48 +0000 Subject: [PATCH 32/51] [cron] Bump distribution date (2021-02-07) --- 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 50d13333a7..2c10a3d4a6 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 "2021-02-06" + #define STRING_DISTRIBUTION_DATE "2021-02-07" #endif /** From 52c246ae19549b5d99cd9a8e26cd7c8a1f0458b2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 14 Dec 2020 00:24:01 -0600 Subject: [PATCH 33/51] Melzi, comments cleanup --- Marlin/src/core/boards.h | 2 -- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h | 2 +- Marlin/src/pins/sanguino/pins_MELZI.h | 2 ++ 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index afb6887766..0f076b1b2a 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -415,5 +415,3 @@ #define _MB_1(B) (defined(BOARD_##B) && MOTHERBOARD==BOARD_##B) #define MB(V...) DO(MB,||,V) - -#define IS_MELZI MB(MELZI, MELZI_CREALITY, MELZI_MAKR3D, MELZI_MALYAN, MELZI_TRONXY, MELZI_V2) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b3beedfe80..964f894e9e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1907,7 +1907,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if !HAS_HEATER_0 && EXTRUDERS #error "HEATER_0_PIN not defined for this board." #elif !ANY_PIN(TEMP_0, MAX6675_SS) - #error "TEMP_0_PIN not defined for this board." + #error "TEMP_0_PIN or MAX6675_SS not defined for this board." #elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR)) #error "E0_STEP_PIN or E0_DIR_PIN not defined for this board." #elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE)) diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index a43940f8f0..80d61d9c47 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -29,7 +29,7 @@ #error "Oops! Make sure you have the LPC1768 environment selected in your IDE." #endif -// If you have the Big tree tech driver expantion module, enable HAS_BTT_EXP_MOT +// If you have the Big tree tech driver expansion module, enable HAS_BTT_EXP_MOT // https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT //#define HAS_BTT_EXP_MOT 1 diff --git a/Marlin/src/pins/sanguino/pins_MELZI.h b/Marlin/src/pins/sanguino/pins_MELZI.h index 887aae1858..de4dd1b01d 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI.h +++ b/Marlin/src/pins/sanguino/pins_MELZI.h @@ -29,4 +29,6 @@ #define BOARD_INFO_NAME "Melzi" #endif +#define IS_MELZI 1 + #include "pins_SANGUINOLOLU_12.h" From 5233e6676294b010ff85fca352baa7296f45645a Mon Sep 17 00:00:00 2001 From: Chris Pepper Date: Sun, 7 Feb 2021 20:46:24 +0000 Subject: [PATCH 34/51] Improve RPi host kernel panic mitigation It was still possible to cause a Kernel panic, this additional 500ms delay before disconnect appears to mitigate it completely. --- Marlin/src/HAL/LPC1768/HAL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index f567f26c9e..26a2c0e7db 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -64,8 +64,9 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { } void flashFirmware(const int16_t) { + delay(500); // Give OS time to disconnect USB_Connect(false); // USB clear connection - delay(2000); // Give OS time to notice + delay(1000); // Give OS time to notice NVIC_SystemReset(); } From af4e8b171c01f5620b2aca011115cdbc712be259 Mon Sep 17 00:00:00 2001 From: Simon Jouet Date: Sun, 7 Feb 2021 22:56:39 +0000 Subject: [PATCH 35/51] Fix ESP32 I2S init placement (#21019) --- Marlin/src/HAL/ESP32/HAL.cpp | 6 ++++-- Marlin/src/HAL/ESP32/HAL.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 6ff1446b1c..fb5f531b22 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -90,8 +90,6 @@ volatile int numPWMUsed = 0, #endif -void HAL_init() { TERN_(I2S_STEPPER_STREAM, i2s_init()); } - void HAL_init_board() { #if ENABLED(ESP3D_WIFISUPPORT) @@ -126,6 +124,10 @@ void HAL_init_board() { #endif #endif + // Initialize the i2s peripheral only if the I2S stepper stream is enabled. + // The following initialization is performed after Serial1 and Serial2 are defined as + // their native pins might conflict with the i2s stream even when they are remapped. + TERN_(I2S_STEPPER_STREAM, i2s_init()); } void HAL_idletask() { diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 3dc27c6493..4d1db571d0 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -139,7 +139,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin); #define HAL_IDLETASK 1 #define BOARD_INIT() HAL_init_board(); void HAL_idletask(); -void HAL_init(); +inline void HAL_init() {} void HAL_init_board(); // From b35bfeb1c3f1271016227a1d79dcb552e67e3cb9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 7 Feb 2021 16:58:06 -0600 Subject: [PATCH 36/51] Fix TEMP_0_TR_ENABLE, rename temp conditions (#21016) --- Marlin/Configuration_adv.h | 8 +- Marlin/src/MarlinCore.cpp | 4 +- Marlin/src/inc/Conditionals_post.h | 180 +++++---- Marlin/src/inc/SanityCheck.h | 52 +-- Marlin/src/module/temperature.cpp | 361 ++++++++--------- Marlin/src/module/temperature.h | 33 +- Marlin/src/module/thermistor/thermistors.h | 376 +++++++++--------- .../pins/stm32f4/pins_BTT_SKR_PRO_common.h | 2 +- platformio.ini | 2 +- 9 files changed, 525 insertions(+), 493 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a3699128b4..f615a54671 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -113,6 +113,12 @@ #define CHAMBER_BETA 3950 // Beta value #endif +#if TEMP_SENSOR_PROBE == 1000 + #define PROBE_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define PROBE_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define PROBE_BETA 3950 // Beta value +#endif + // // Hephestos 2 24V heated bed upgrade kit. // https://store.bq.com/en/heated-bed-kit-hephestos2 @@ -331,7 +337,7 @@ * High Temperature Thermistor Support * * Thermistors able to support high temperature tend to have a hard time getting - * good readings at room and lower temperatures. This means HEATER_X_RAW_LO_TEMP + * good readings at room and lower temperatures. This means TEMP_SENSOR_X_RAW_LO_TEMP * will probably be caught when the heating element first turns on during the * preheating process, which will trigger a min_temp_error as a safety measure * and force stop everything. diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 626f934ddc..df383d8a96 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -938,10 +938,10 @@ void setup() { SETUP_RUN(HAL_init()); // Init and disable SPI thermocouples - #if HEATER_0_USES_MAX6675 + #if TEMP_SENSOR_0_IS_MAX6675 OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable #endif - #if HEATER_1_USES_MAX6675 + #if TEMP_SENSOR_1_IS_MAX6675 OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index acf8f3620b..04c4eb120d 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -404,30 +404,33 @@ #endif #if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2 - #define HEATER_0_USES_MAX6675 1 + #define TEMP_SENSOR_0_IS_MAX_TC 1 + #define HAS_MAX_TC 1 #if TEMP_SENSOR_0 == -3 - #define HEATER_0_MAX6675_TMIN -270 - #define HEATER_0_MAX6675_TMAX 1800 + #define TEMP_SENSOR_0_MAX_TC_TMIN -270 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1800 #else - #define HEATER_0_MAX6675_TMIN 0 - #define HEATER_0_MAX6675_TMAX 1024 + #define TEMP_SENSOR_0_MAX_TC_TMIN 0 + #define TEMP_SENSOR_0_MAX_TC_TMAX 1024 #endif #if TEMP_SENSOR_0 == -5 - #define MAX6675_0_IS_MAX31865 1 + #define TEMP_SENSOR_0_IS_MAX31865 1 #elif TEMP_SENSOR_0 == -3 - #define MAX6675_0_IS_MAX31855 1 + #define TEMP_SENSOR_0_IS_MAX31855 1 + #elif TEMP_SENSOR_0 == -2 + #define TEMP_SENSOR_0_IS_MAX6675 1 #endif #elif TEMP_SENSOR_0 == -4 - #define HEATER_0_USES_AD8495 1 + #define TEMP_SENSOR_0_IS_AD8495 1 #elif TEMP_SENSOR_0 == -1 - #define HEATER_0_USES_AD595 1 + #define TEMP_SENSOR_0_IS_AD595 1 #elif TEMP_SENSOR_0 > 0 - #define THERMISTOR_HEATER_0 TEMP_SENSOR_0 - #define HEATER_0_USES_THERMISTOR 1 + #define TEMP_SENSOR_0_THERMISTOR_ID TEMP_SENSOR_0 + #define TEMP_SENSOR_0_IS_THERMISTOR 1 #if TEMP_SENSOR_0 == 1000 - #define HEATER_0_USER_THERMISTOR 1 + #define TEMP_SENSOR_0_IS_CUSTOM 1 #elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999 - #define HEATER_0_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_0_IS_DUMMY 1 #endif #else #undef HEATER_0_MINTEMP @@ -435,18 +438,21 @@ #endif #if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2 - #define HEATER_1_USES_MAX6675 1 + #define TEMP_SENSOR_1_IS_MAX_TC 1 + #define HAS_MAX_TC 1 #if TEMP_SENSOR_1 == -3 - #define HEATER_1_MAX6675_TMIN -270 - #define HEATER_1_MAX6675_TMAX 1800 + #define TEMP_SENSOR_1_MAX_TC_TMIN -270 + #define TEMP_SENSOR_1_MAX_TC_TMAX 1800 #else - #define HEATER_1_MAX6675_TMIN 0 - #define HEATER_1_MAX6675_TMAX 1024 + #define TEMP_SENSOR_1_MAX_TC_TMIN 0 + #define TEMP_SENSOR_1_MAX_TC_TMAX 1024 #endif #if TEMP_SENSOR_1 == -5 - #define MAX6675_1_IS_MAX31865 1 + #define TEMP_SENSOR_1_IS_MAX31865 1 #elif TEMP_SENSOR_1 == -3 - #define MAX6675_1_IS_MAX31855 1 + #define TEMP_SENSOR_1_IS_MAX31855 1 + #elif TEMP_SENSOR_1 == -2 + #define TEMP_SENSOR_1_IS_MAX6675 1 #endif #if TEMP_SENSOR_1 != TEMP_SENSOR_0 #if TEMP_SENSOR_1 == -5 @@ -458,37 +464,47 @@ #endif #endif #elif TEMP_SENSOR_1 == -4 - #define HEATER_1_USES_AD8495 1 + #define TEMP_SENSOR_1_IS_AD8495 1 #elif TEMP_SENSOR_1 == -1 - #define HEATER_1_USES_AD595 1 + #define TEMP_SENSOR_1_IS_AD595 1 #elif TEMP_SENSOR_1 > 0 - #define THERMISTOR_HEATER_1 TEMP_SENSOR_1 - #define HEATER_1_USES_THERMISTOR 1 + #define TEMP_SENSOR_1_THERMISTOR_ID TEMP_SENSOR_1 + #define TEMP_SENSOR_1_IS_THERMISTOR 1 #if TEMP_SENSOR_1 == 1000 - #define HEATER_1_USER_THERMISTOR 1 + #define TEMP_SENSOR_1_IS_CUSTOM 1 #elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999 - #define HEATER_1_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_1_IS_DUMMY 1 #endif #else #undef HEATER_1_MINTEMP #undef HEATER_1_MAXTEMP #endif +#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 + #define HAS_MAX31855 1 +#endif +#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 + #define HAS_MAX31865 1 +#endif +#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 + #define HAS_MAX6675 1 +#endif + #if TEMP_SENSOR_2 == -4 - #define HEATER_2_USES_AD8495 1 + #define TEMP_SENSOR_2_IS_AD8495 1 #elif TEMP_SENSOR_2 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2." #elif TEMP_SENSOR_2 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2." #elif TEMP_SENSOR_2 == -1 - #define HEATER_2_USES_AD595 1 + #define TEMP_SENSOR_2_IS_AD595 1 #elif TEMP_SENSOR_2 > 0 - #define THERMISTOR_HEATER_2 TEMP_SENSOR_2 - #define HEATER_2_USES_THERMISTOR 1 + #define TEMP_SENSOR_2_THERMISTOR_ID TEMP_SENSOR_2 + #define TEMP_SENSOR_2_IS_THERMISTOR 1 #if TEMP_SENSOR_2 == 1000 - #define HEATER_2_USER_THERMISTOR 1 + #define TEMP_SENSOR_2_IS_CUSTOM 1 #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999 - #define HEATER_2_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_2_IS_DUMMY 1 #endif #else #undef HEATER_2_MINTEMP @@ -496,20 +512,20 @@ #endif #if TEMP_SENSOR_3 == -4 - #define HEATER_3_USES_AD8495 1 + #define TEMP_SENSOR_3_IS_AD8495 1 #elif TEMP_SENSOR_3 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3." #elif TEMP_SENSOR_3 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3." #elif TEMP_SENSOR_3 == -1 - #define HEATER_3_USES_AD595 1 + #define TEMP_SENSOR_3_IS_AD595 1 #elif TEMP_SENSOR_3 > 0 - #define THERMISTOR_HEATER_3 TEMP_SENSOR_3 - #define HEATER_3_USES_THERMISTOR 1 + #define TEMP_SENSOR_3_THERMISTOR_ID TEMP_SENSOR_3 + #define TEMP_SENSOR_3_IS_THERMISTOR 1 #if TEMP_SENSOR_3 == 1000 - #define HEATER_3_USER_THERMISTOR 1 + #define TEMP_SENSOR_3_IS_CUSTOM 1 #elif TEMP_SENSOR_3 == 998 || TEMP_SENSOR_3 == 999 - #define HEATER_3_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_3_IS_DUMMY 1 #endif #else #undef HEATER_3_MINTEMP @@ -517,20 +533,20 @@ #endif #if TEMP_SENSOR_4 == -4 - #define HEATER_4_USES_AD8495 1 + #define TEMP_SENSOR_4_IS_AD8495 1 #elif TEMP_SENSOR_4 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4." #elif TEMP_SENSOR_4 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4." #elif TEMP_SENSOR_4 == -1 - #define HEATER_4_USES_AD595 1 + #define TEMP_SENSOR_4_IS_AD595 1 #elif TEMP_SENSOR_4 > 0 - #define THERMISTOR_HEATER_4 TEMP_SENSOR_4 - #define HEATER_4_USES_THERMISTOR 1 + #define TEMP_SENSOR_4_THERMISTOR_ID TEMP_SENSOR_4 + #define TEMP_SENSOR_4_IS_THERMISTOR 1 #if TEMP_SENSOR_4 == 1000 - #define HEATER_4_USER_THERMISTOR 1 + #define TEMP_SENSOR_4_IS_CUSTOM 1 #elif TEMP_SENSOR_4 == 998 || TEMP_SENSOR_4 == 999 - #define HEATER_4_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_4_IS_DUMMY 1 #endif #else #undef HEATER_4_MINTEMP @@ -538,20 +554,20 @@ #endif #if TEMP_SENSOR_5 == -4 - #define HEATER_5_USES_AD8495 1 + #define TEMP_SENSOR_5_IS_AD8495 1 #elif TEMP_SENSOR_5 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5." #elif TEMP_SENSOR_5 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5." #elif TEMP_SENSOR_5 == -1 - #define HEATER_5_USES_AD595 1 + #define TEMP_SENSOR_5_IS_AD595 1 #elif TEMP_SENSOR_5 > 0 - #define THERMISTOR_HEATER_5 TEMP_SENSOR_5 - #define HEATER_5_USES_THERMISTOR 1 + #define TEMP_SENSOR_5_THERMISTOR_ID TEMP_SENSOR_5 + #define TEMP_SENSOR_5_IS_THERMISTOR 1 #if TEMP_SENSOR_5 == 1000 - #define HEATER_5_USER_THERMISTOR 1 + #define TEMP_SENSOR_5_IS_CUSTOM 1 #elif TEMP_SENSOR_5 == 998 || TEMP_SENSOR_5 == 999 - #define HEATER_5_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_5_IS_DUMMY 1 #endif #else #undef HEATER_5_MINTEMP @@ -559,20 +575,20 @@ #endif #if TEMP_SENSOR_6 == -4 - #define HEATER_6_USES_AD8495 1 + #define TEMP_SENSOR_6_IS_AD8495 1 #elif TEMP_SENSOR_6 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6." #elif TEMP_SENSOR_6 == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_6." #elif TEMP_SENSOR_6 == -1 - #define HEATER_6_USES_AD595 1 + #define TEMP_SENSOR_6_IS_AD595 1 #elif TEMP_SENSOR_6 > 0 - #define THERMISTOR_HEATER_6 TEMP_SENSOR_6 - #define HEATER_6_USES_THERMISTOR 1 + #define TEMP_SENSOR_6_THERMISTOR_ID TEMP_SENSOR_6 + #define TEMP_SENSOR_6_IS_THERMISTOR 1 #if TEMP_SENSOR_6 == 1000 - #define HEATER_6_USER_THERMISTOR 1 + #define TEMP_SENSOR_6_IS_CUSTOM 1 #elif TEMP_SENSOR_6 == 998 || TEMP_SENSOR_6 == 999 - #define HEATER_6_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_6_IS_DUMMY 1 #endif #else #undef HEATER_6_MINTEMP @@ -580,20 +596,20 @@ #endif #if TEMP_SENSOR_7 == -4 - #define HEATER_7_USES_AD8495 1 + #define TEMP_SENSOR_7_IS_AD8495 1 #elif TEMP_SENSOR_7 == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7." #elif TEMP_SENSOR_7 == -2 #error "MAX7775 Thermocouples (-2) not supported for TEMP_SENSOR_7." #elif TEMP_SENSOR_7 == -1 - #define HEATER_7_USES_AD595 1 + #define TEMP_SENSOR_7_IS_AD595 1 #elif TEMP_SENSOR_7 > 0 - #define THERMISTOR_HEATER_7 TEMP_SENSOR_7 - #define HEATER_7_USES_THERMISTOR 1 + #define TEMP_SENSOR_7_THERMISTOR_ID TEMP_SENSOR_7 + #define TEMP_SENSOR_7_IS_THERMISTOR 1 #if TEMP_SENSOR_7 == 1000 - #define HEATER_7_USER_THERMISTOR 1 + #define TEMP_SENSOR_7_IS_CUSTOM 1 #elif TEMP_SENSOR_7 == 998 || TEMP_SENSOR_7 == 999 - #define HEATER_7_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_7_IS_DUMMY 1 #endif #else #undef HEATER_7_MINTEMP @@ -601,20 +617,20 @@ #endif #if TEMP_SENSOR_BED == -4 - #define HEATER_BED_USES_AD8495 1 + #define TEMP_SENSOR_BED_IS_AD8495 1 #elif TEMP_SENSOR_BED == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED." #elif TEMP_SENSOR_BED == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED." #elif TEMP_SENSOR_BED == -1 - #define HEATER_BED_USES_AD595 1 + #define TEMP_SENSOR_BED_IS_AD595 1 #elif TEMP_SENSOR_BED > 0 - #define THERMISTORBED TEMP_SENSOR_BED - #define HEATER_BED_USES_THERMISTOR 1 + #define TEMP_SENSOR_BED_THERMISTOR_ID TEMP_SENSOR_BED + #define TEMP_SENSOR_BED_IS_THERMISTOR 1 #if TEMP_SENSOR_BED == 1000 - #define HEATER_BED_USER_THERMISTOR 1 + #define TEMP_SENSOR_BED_IS_CUSTOM 1 #elif TEMP_SENSOR_BED == 998 || TEMP_SENSOR_BED == 999 - #define HEATER_BED_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_BED_IS_DUMMY 1 #endif #else #undef BED_MINTEMP @@ -622,20 +638,20 @@ #endif #if TEMP_SENSOR_CHAMBER == -4 - #define HEATER_CHAMBER_USES_AD8495 1 + #define TEMP_SENSOR_CHAMBER_IS_AD8495 1 #elif TEMP_SENSOR_CHAMBER == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER." #elif TEMP_SENSOR_CHAMBER == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER." #elif TEMP_SENSOR_CHAMBER == -1 - #define HEATER_CHAMBER_USES_AD595 1 + #define TEMP_SENSOR_CHAMBER_IS_AD595 1 #elif TEMP_SENSOR_CHAMBER > 0 - #define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER - #define HEATER_CHAMBER_USES_THERMISTOR 1 + #define TEMP_SENSOR_CHAMBER_THERMISTOR_ID TEMP_SENSOR_CHAMBER + #define TEMP_SENSOR_CHAMBER_IS_THERMISTOR 1 #if TEMP_SENSOR_CHAMBER == 1000 - #define HEATER_CHAMBER_USER_THERMISTOR 1 + #define TEMP_SENSOR_CHAMBER_IS_CUSTOM 1 #elif TEMP_SENSOR_CHAMBER == 998 || TEMP_SENSOR_CHAMBER == 999 - #define HEATER_CHAMBER_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_CHAMBER_IS_DUMMY 1 #endif #else #undef CHAMBER_MINTEMP @@ -643,20 +659,20 @@ #endif #if TEMP_SENSOR_PROBE == -4 - #define HEATER_PROBE_USES_AD8495 1 + #define TEMP_SENSOR_PROBE_IS_AD8495 1 #elif TEMP_SENSOR_PROBE == -3 #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE." #elif TEMP_SENSOR_PROBE == -2 #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_PROBE." #elif TEMP_SENSOR_PROBE == -1 - #define HEATER_PROBE_USES_AD595 1 + #define TEMP_SENSOR_PROBE_IS_AD595 1 #elif TEMP_SENSOR_PROBE > 0 - #define THERMISTORPROBE TEMP_SENSOR_PROBE - #define HEATER_PROBE_USES_THERMISTOR 1 + #define TEMP_SENSOR_PROBE_THERMISTOR_ID TEMP_SENSOR_PROBE + #define TEMP_SENSOR_PROBE_IS_THERMISTOR 1 #if TEMP_SENSOR_PROBE == 1000 - #define HEATER_PROBE_USER_THERMISTOR 1 + #define TEMP_SENSOR_PROBE_IS_CUSTOM 1 #elif TEMP_SENSOR_PROBE == 998 || TEMP_SENSOR_PROBE == 999 - #define HEATER_PROBE_DUMMY_THERMISTOR 1 + #define TEMP_SENSOR_PROBE_IS_DUMMY 1 #endif #endif @@ -1792,7 +1808,7 @@ // // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // -#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(HEATER_##P##_USES_MAX6675, HEATER_##P##_DUMMY_THERMISTOR)) +#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(TEMP_SENSOR_##P##_IS_MAX_TC, TEMP_SENSOR_##P##_IS_DUMMY)) #if HAS_ADC_TEST(0) #define HAS_TEMP_ADC_0 1 #endif @@ -1827,7 +1843,7 @@ #define HAS_TEMP_ADC_CHAMBER 1 #endif -#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, HEATER_##N##_USES_MAX6675, HEATER_##N##_DUMMY_THERMISTOR) +#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY) #if HAS_HOTEND && HAS_TEMP(0) #define HAS_TEMP_HOTEND 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 964f894e9e..2ff5293de2 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1698,46 +1698,48 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal /** * Required custom thermistor settings */ -#if HEATER_0_USER_THERMISTOR && !(defined(HOTEND0_PULLUP_RESISTOR_OHMS) && defined(HOTEND0_RESISTANCE_25C_OHMS) && defined(HOTEND0_BETA)) +#if TEMP_SENSOR_0_IS_CUSTOM && !(defined(HOTEND0_PULLUP_RESISTOR_OHMS) && defined(HOTEND0_RESISTANCE_25C_OHMS) && defined(HOTEND0_BETA)) #error "TEMP_SENSOR_0 1000 requires HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS and HOTEND0_BETA in Configuration_adv.h." -#elif HEATER_1_USER_THERMISTOR && !(defined(HOTEND1_PULLUP_RESISTOR_OHMS) && defined(HOTEND1_RESISTANCE_25C_OHMS) && defined(HOTEND1_BETA)) +#elif TEMP_SENSOR_1_IS_CUSTOM && !(defined(HOTEND1_PULLUP_RESISTOR_OHMS) && defined(HOTEND1_RESISTANCE_25C_OHMS) && defined(HOTEND1_BETA)) #error "TEMP_SENSOR_1 1000 requires HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS and HOTEND1_BETA in Configuration_adv.h." -#elif HEATER_2_USER_THERMISTOR && !(defined(HOTEND2_PULLUP_RESISTOR_OHMS) && defined(HOTEND2_RESISTANCE_25C_OHMS) && defined(HOTEND2_BETA)) +#elif TEMP_SENSOR_2_IS_CUSTOM && !(defined(HOTEND2_PULLUP_RESISTOR_OHMS) && defined(HOTEND2_RESISTANCE_25C_OHMS) && defined(HOTEND2_BETA)) #error "TEMP_SENSOR_2 1000 requires HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS and HOTEND2_BETA in Configuration_adv.h." -#elif HEATER_3_USER_THERMISTOR && !(defined(HOTEND3_PULLUP_RESISTOR_OHMS) && defined(HOTEND3_RESISTANCE_25C_OHMS) && defined(HOTEND3_BETA)) +#elif TEMP_SENSOR_3_IS_CUSTOM && !(defined(HOTEND3_PULLUP_RESISTOR_OHMS) && defined(HOTEND3_RESISTANCE_25C_OHMS) && defined(HOTEND3_BETA)) #error "TEMP_SENSOR_3 1000 requires HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS and HOTEND3_BETA in Configuration_adv.h." -#elif HEATER_4_USER_THERMISTOR && !(defined(HOTEND4_PULLUP_RESISTOR_OHMS) && defined(HOTEND4_RESISTANCE_25C_OHMS) && defined(HOTEND4_BETA)) +#elif TEMP_SENSOR_4_IS_CUSTOM && !(defined(HOTEND4_PULLUP_RESISTOR_OHMS) && defined(HOTEND4_RESISTANCE_25C_OHMS) && defined(HOTEND4_BETA)) #error "TEMP_SENSOR_4 1000 requires HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS and HOTEND4_BETA in Configuration_adv.h." -#elif HEATER_5_USER_THERMISTOR && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA)) +#elif TEMP_SENSOR_5_IS_CUSTOM && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA)) #error "TEMP_SENSOR_5 1000 requires HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS and HOTEND5_BETA in Configuration_adv.h." -#elif HEATER_6_USER_THERMISTOR && !(defined(HOTEND6_PULLUP_RESISTOR_OHMS) && defined(HOTEND6_RESISTANCE_25C_OHMS) && defined(HOTEND6_BETA)) +#elif TEMP_SENSOR_6_IS_CUSTOM && !(defined(HOTEND6_PULLUP_RESISTOR_OHMS) && defined(HOTEND6_RESISTANCE_25C_OHMS) && defined(HOTEND6_BETA)) #error "TEMP_SENSOR_6 1000 requires HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS and HOTEND6_BETA in Configuration_adv.h." -#elif HEATER_7_USER_THERMISTOR && !(defined(HOTEND7_PULLUP_RESISTOR_OHMS) && defined(HOTEND7_RESISTANCE_25C_OHMS) && defined(HOTEND7_BETA)) +#elif TEMP_SENSOR_7_IS_CUSTOM && !(defined(HOTEND7_PULLUP_RESISTOR_OHMS) && defined(HOTEND7_RESISTANCE_25C_OHMS) && defined(HOTEND7_BETA)) #error "TEMP_SENSOR_7 1000 requires HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS and HOTEND7_BETA in Configuration_adv.h." -#elif HEATER_BED_USER_THERMISTOR && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA)) +#elif TEMP_SENSOR_BED_IS_CUSTOM && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA)) #error "TEMP_SENSOR_BED 1000 requires BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS and BED_BETA in Configuration_adv.h." -#elif HEATER_CHAMBER_USER_THERMISTOR && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA)) +#elif TEMP_SENSOR_CHAMBER_IS_CUSTOM && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA)) #error "TEMP_SENSOR_CHAMBER 1000 requires CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS and CHAMBER_BETA in Configuration_adv.h." +#elif TEMP_SENSOR_PROBE_IS_CUSTOM && !(defined(PROBE_PULLUP_RESISTOR_OHMS) && defined(PROBE_RESISTANCE_25C_OHMS) && defined(PROBE_BETA)) + #error "TEMP_SENSOR_PROBE 1000 requires PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS and PROBE_BETA in Configuration_adv.h." #endif /** * Pins and Sensor IDs must be set for each heater */ -#if HEATER_0_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS) - #error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board." -#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !HEATER_0_DUMMY_THERMISTOR +#if TEMP_SENSOR_0_IS_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS) + #error "TEMP_SENSOR_0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN." +#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." #elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1 #error "HEATER_1_PIN is not defined. TEMP_SENSOR_1 might not be set, or the board (not EEB / EEF?) doesn't define a pin." #endif #if HAS_MULTI_HOTEND - #if HEATER_1_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS2) - #error "MAX6675_SS2_PIN (required for TEMP_SENSOR_1) not defined for this board." + #if TEMP_SENSOR_1_IS_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2) + #error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." - #elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !HEATER_1_DUMMY_THERMISTOR - #error "TEMP_1_PIN not defined for this board." + #elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !TEMP_SENSOR_1_IS_DUMMY + #error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board." #elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT." #endif @@ -1746,7 +1748,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_2 is required with 3 or more HOTENDS." #elif !HAS_HEATER_2 #error "HEATER_2_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_2) && !HEATER_2_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_2_IS_DUMMY #error "TEMP_2_PIN not defined for this board." #endif #if HOTENDS > 3 @@ -1754,7 +1756,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_3 is required with 4 or more HOTENDS." #elif !HAS_HEATER_3 #error "HEATER_3_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_3) && !HEATER_3_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_3) && !TEMP_SENSOR_3_IS_DUMMY #error "TEMP_3_PIN not defined for this board." #endif #if HOTENDS > 4 @@ -1762,7 +1764,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_4 is required with 5 or more HOTENDS." #elif !HAS_HEATER_4 #error "HEATER_4_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_4) && !HEATER_4_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_4) && !TEMP_SENSOR_4_IS_DUMMY #error "TEMP_4_PIN not defined for this board." #endif #if HOTENDS > 5 @@ -1770,7 +1772,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_5 is required with 6 HOTENDS." #elif !HAS_HEATER_5 #error "HEATER_5_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_5) && !HEATER_5_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_5) && !TEMP_SENSOR_5_IS_DUMMY #error "TEMP_5_PIN not defined for this board." #endif #if HOTENDS > 6 @@ -1778,7 +1780,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_6 is required with 6 HOTENDS." #elif !HAS_HEATER_6 #error "HEATER_6_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_6) && !HEATER_6_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_6) && !TEMP_SENSOR_6_IS_DUMMY #error "TEMP_6_PIN not defined for this board." #endif #if HOTENDS > 7 @@ -1786,7 +1788,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_7 is required with 7 HOTENDS." #elif !HAS_HEATER_7 #error "HEATER_7_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_7) && !HEATER_7_DUMMY_THERMISTOR + #elif !PIN_EXISTS(TEMP_7) && !TEMP_SENSOR_7_IS_DUMMY #error "TEMP_7_PIN not defined for this board." #endif #elif TEMP_SENSOR_7 != 0 @@ -1895,9 +1897,9 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT." #endif -#if MAX6675_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0)) +#if TEMP_SENSOR_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0)) #error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0 is MAX31865." -#elif MAX6675_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1)) +#elif TEMP_SENSOR_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1)) #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1 is MAX31865." #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f6d22420f2..c935323867 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -47,12 +47,12 @@ #include "../lcd/extui/ui_api.h" #endif -#if MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865 +#if HAS_MAX31865 #include - #if MAX6675_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) + #if TEMP_SENSOR_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) #define MAX31865_CS_PIN MAX6675_SS_PIN #endif - #if MAX6675_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) + #if TEMP_SENSOR_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) #define MAX31865_CS2_PIN MAX6675_SS2_PIN #endif #ifndef MAX31865_MOSI_PIN @@ -64,16 +64,16 @@ #ifndef MAX31865_SCK_PIN #define MAX31865_SCK_PIN MAX6675_SCK_PIN #endif - #if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) - #define HAS_MAX31865 1 + #if TEMP_SENSOR_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) + #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN #if MAX31865_CS_PIN != MAX6675_SS_PIN , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK #endif ); #endif - #if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) - #define HAS_MAX31865 1 + #if TEMP_SENSOR_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) + #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN #if MAX31865_CS2_PIN != MAX6675_SS2_PIN , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK @@ -82,11 +82,11 @@ #endif #endif -#if EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) - #define MAX6675_SEPARATE_SPI 1 +#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS + #define THERMO_SEPARATE_SPI 1 #endif -#if MAX6675_SEPARATE_SPI +#if THERMO_SEPARATE_SPI #include "../libs/private_spi.h" #endif @@ -132,20 +132,20 @@ #include "./servo.h" #endif -#if ANY(HEATER_0_USES_THERMISTOR, HEATER_1_USES_THERMISTOR, HEATER_2_USES_THERMISTOR, HEATER_3_USES_THERMISTOR, \ - HEATER_4_USES_THERMISTOR, HEATER_5_USES_THERMISTOR, HEATER_6_USES_THERMISTOR, HEATER_7_USES_THERMISTOR ) +#if ANY(TEMP_SENSOR_0_IS_THERMISTOR, TEMP_SENSOR_1_IS_THERMISTOR, TEMP_SENSOR_2_IS_THERMISTOR, TEMP_SENSOR_3_IS_THERMISTOR, \ + TEMP_SENSOR_4_IS_THERMISTOR, TEMP_SENSOR_5_IS_THERMISTOR, TEMP_SENSOR_6_IS_THERMISTOR, TEMP_SENSOR_7_IS_THERMISTOR ) #define HAS_HOTEND_THERMISTOR 1 #endif #if HAS_HOTEND_THERMISTOR #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - static const temp_entry_t* heater_ttbl_map[2] = { HEATER_0_TEMPTABLE, HEATER_1_TEMPTABLE }; - static constexpr uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN }; + static const temp_entry_t* heater_ttbl_map[2] = { TEMPTABLE_0, TEMPTABLE_1 }; + static constexpr uint8_t heater_ttbllen_map[2] = { TEMPTABLE_0_LEN, TEMPTABLE_1_LEN }; #else - #define NEXT_TEMPTABLE(N) ,HEATER_##N##_TEMPTABLE - #define NEXT_TEMPTABLE_LEN(N) ,HEATER_##N##_TEMPTABLE_LEN - static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); - static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN)); + #define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N + #define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN + static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); + static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN)); #endif #endif @@ -285,10 +285,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, bed_info_t Temperature::temp_bed; // = { 0 } // Init min and max temp with extreme values to prevent false errors during startup #ifdef BED_MINTEMP - int16_t Temperature::mintemp_raw_BED = HEATER_BED_RAW_LO_TEMP; + int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP; #endif #ifdef BED_MAXTEMP - int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP; + int16_t Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; #endif TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); @@ -303,10 +303,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, millis_t next_cool_check_ms_2 = 0; float old_temp = 9999; #ifdef CHAMBER_MINTEMP - int16_t Temperature::mintemp_raw_CHAMBER = HEATER_CHAMBER_RAW_LO_TEMP; + int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP; #endif #ifdef CHAMBER_MAXTEMP - int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP; + int16_t Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; #endif #if WATCH_CHAMBER chamber_watch_t Temperature::watch_chamber{0}; @@ -347,18 +347,18 @@ volatile bool Temperature::raw_temps_ready = false; lpq_ptr_t Temperature::lpq_ptr = 0; #endif -#define TEMPDIR(N) ((HEATER_##N##_RAW_LO_TEMP) < (HEATER_##N##_RAW_HI_TEMP) ? 1 : -1) +#define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1) #if HAS_HOTEND // Init mintemp and maxtemp with extreme values to prevent false errors during startup - constexpr temp_range_t sensor_heater_0 { HEATER_0_RAW_LO_TEMP, HEATER_0_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_1 { HEATER_1_RAW_LO_TEMP, HEATER_1_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_2 { HEATER_2_RAW_LO_TEMP, HEATER_2_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_3 { HEATER_3_RAW_LO_TEMP, HEATER_3_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_4 { HEATER_4_RAW_LO_TEMP, HEATER_4_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_5 { HEATER_5_RAW_LO_TEMP, HEATER_5_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_6 { HEATER_6_RAW_LO_TEMP, HEATER_6_RAW_HI_TEMP, 0, 16383 }, - sensor_heater_7 { HEATER_7_RAW_LO_TEMP, HEATER_7_RAW_HI_TEMP, 0, 16383 }; + constexpr temp_range_t sensor_heater_0 { TEMP_SENSOR_0_RAW_LO_TEMP, TEMP_SENSOR_0_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_1 { TEMP_SENSOR_1_RAW_LO_TEMP, TEMP_SENSOR_1_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_2 { TEMP_SENSOR_2_RAW_LO_TEMP, TEMP_SENSOR_2_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_3 { TEMP_SENSOR_3_RAW_LO_TEMP, TEMP_SENSOR_3_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_4 { TEMP_SENSOR_4_RAW_LO_TEMP, TEMP_SENSOR_4_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_5 { TEMP_SENSOR_5_RAW_LO_TEMP, TEMP_SENSOR_5_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_6 { TEMP_SENSOR_6_RAW_LO_TEMP, TEMP_SENSOR_6_RAW_HI_TEMP, 0, 16383 }, + sensor_heater_7 { TEMP_SENSOR_7_RAW_LO_TEMP, TEMP_SENSOR_7_RAW_HI_TEMP, 0, 16383 }; temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0, sensor_heater_1, sensor_heater_2, sensor_heater_3, sensor_heater_4, sensor_heater_5, sensor_heater_6, sensor_heater_7); #endif @@ -1083,13 +1083,13 @@ void Temperature::manage_heater() { updateTemperaturesFromRawValues(); // also resets the watchdog #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) - #if HEATER_0_USES_MAX6675 - if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0); - if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0); + #if TEMP_SENSOR_0_IS_MAX_TC + if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); + if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); #endif - #if HEATER_1_USES_MAX6675 - if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1); - if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1); + #if TEMP_SENSOR_1_IS_MAX_TC + if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); + if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); #endif #endif @@ -1373,36 +1373,39 @@ void Temperature::manage_heater() { void Temperature::reset_user_thermistors() { user_thermistor_t default_user_thermistor[USER_THERMISTORS] = { - #if HEATER_0_USER_THERMISTOR + #if TEMP_SENSOR_0_IS_CUSTOM { true, 0, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 }, #endif - #if HEATER_1_USER_THERMISTOR + #if TEMP_SENSOR_1_IS_CUSTOM { true, 0, 0, HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS, 0, 0, HOTEND1_BETA, 0 }, #endif - #if HEATER_2_USER_THERMISTOR + #if TEMP_SENSOR_2_IS_CUSTOM { true, 0, 0, HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS, 0, 0, HOTEND2_BETA, 0 }, #endif - #if HEATER_3_USER_THERMISTOR + #if TEMP_SENSOR_3_IS_CUSTOM { true, 0, 0, HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS, 0, 0, HOTEND3_BETA, 0 }, #endif - #if HEATER_4_USER_THERMISTOR + #if TEMP_SENSOR_4_IS_CUSTOM { true, 0, 0, HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS, 0, 0, HOTEND4_BETA, 0 }, #endif - #if HEATER_5_USER_THERMISTOR + #if TEMP_SENSOR_5_IS_CUSTOM { true, 0, 0, HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS, 0, 0, HOTEND5_BETA, 0 }, #endif - #if HEATER_6_USER_THERMISTOR + #if TEMP_SENSOR_6_IS_CUSTOM { true, 0, 0, HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS, 0, 0, HOTEND6_BETA, 0 }, #endif - #if HEATER_7_USER_THERMISTOR + #if TEMP_SENSOR_7_IS_CUSTOM { true, 0, 0, HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS, 0, 0, HOTEND7_BETA, 0 }, #endif - #if HEATER_BED_USER_THERMISTOR + #if TEMP_SENSOR_BED_IS_CUSTOM { true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 }, #endif - #if HEATER_CHAMBER_USER_THERMISTOR + #if TEMP_SENSOR_CHAMBER_IS_CUSTOM { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 } #endif + #if TEMP_SENSOR_PROBE_IS_CUSTOM + { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 } + #endif }; COPY(user_thermistor, default_user_thermistor); } @@ -1423,16 +1426,17 @@ void Temperature::manage_heater() { SERIAL_ECHOPAIR_F_P(SP_C_STR, t.sh_c_coeff, 9); SERIAL_ECHOPGM(" ; "); serialprintPGM( - TERN_(HEATER_0_USER_THERMISTOR, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :) - TERN_(HEATER_1_USER_THERMISTOR, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :) - TERN_(HEATER_2_USER_THERMISTOR, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :) - TERN_(HEATER_3_USER_THERMISTOR, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :) - TERN_(HEATER_4_USER_THERMISTOR, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :) - TERN_(HEATER_5_USER_THERMISTOR, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :) - TERN_(HEATER_6_USER_THERMISTOR, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :) - TERN_(HEATER_7_USER_THERMISTOR, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :) - TERN_(HEATER_BED_USER_THERMISTOR, t_index == CTI_BED ? PSTR("BED") :) - TERN_(HEATER_CHAMBER_USER_THERMISTOR, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :) + TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :) + TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :) + TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :) + TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :) + TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :) + TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :) + TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :) + TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :) + TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? PSTR("BED") :) + TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :) + TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :) nullptr ); SERIAL_EOL(); @@ -1498,85 +1502,85 @@ void Temperature::manage_heater() { switch (e) { case 0: - #if HEATER_0_USER_THERMISTOR + #if TEMP_SENSOR_0_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_0, raw); - #elif HEATER_0_USES_MAX6675 - return TERN(MAX6675_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25); - #elif HEATER_0_USES_AD595 + #elif TEMP_SENSOR_0_IS_MAX_TC + return TERN(TEMP_SENSOR_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25); + #elif TEMP_SENSOR_0_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_0_USES_AD8495 + #elif TEMP_SENSOR_0_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 1: - #if HEATER_1_USER_THERMISTOR + #if TEMP_SENSOR_1_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_1, raw); - #elif HEATER_1_USES_MAX6675 - return TERN(MAX6675_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25); - #elif HEATER_1_USES_AD595 + #elif TEMP_SENSOR_1_IS_MAX_TC + return TERN(TEMP_SENSOR_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25); + #elif TEMP_SENSOR_1_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_1_USES_AD8495 + #elif TEMP_SENSOR_1_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 2: - #if HEATER_2_USER_THERMISTOR + #if TEMP_SENSOR_2_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_2, raw); - #elif HEATER_2_USES_AD595 + #elif TEMP_SENSOR_2_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_2_USES_AD8495 + #elif TEMP_SENSOR_2_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 3: - #if HEATER_3_USER_THERMISTOR + #if TEMP_SENSOR_3_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_3, raw); - #elif HEATER_3_USES_AD595 + #elif TEMP_SENSOR_3_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_3_USES_AD8495 + #elif TEMP_SENSOR_3_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 4: - #if HEATER_4_USER_THERMISTOR + #if TEMP_SENSOR_4_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_4, raw); - #elif HEATER_4_USES_AD595 + #elif TEMP_SENSOR_4_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_4_USES_AD8495 + #elif TEMP_SENSOR_4_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 5: - #if HEATER_5_USER_THERMISTOR + #if TEMP_SENSOR_5_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_5, raw); - #elif HEATER_5_USES_AD595 + #elif TEMP_SENSOR_5_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_5_USES_AD8495 + #elif TEMP_SENSOR_5_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 6: - #if HEATER_6_USER_THERMISTOR + #if TEMP_SENSOR_6_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_6, raw); - #elif HEATER_6_USES_AD595 + #elif TEMP_SENSOR_6_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_6_USES_AD8495 + #elif TEMP_SENSOR_6_IS_AD8495 return TEMP_AD8495(raw); #else break; #endif case 7: - #if HEATER_7_USER_THERMISTOR + #if TEMP_SENSOR_7_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_7, raw); - #elif HEATER_7_USES_AD595 + #elif TEMP_SENSOR_7_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_7_USES_AD8495 + #elif TEMP_SENSOR_7_IS_AD8495 return TEMP_AD8495(raw); #else break; @@ -1598,13 +1602,13 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For bed temperature measurement. float Temperature::analog_to_celsius_bed(const int raw) { - #if HEATER_BED_USER_THERMISTOR + #if TEMP_SENSOR_BED_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BED, raw); - #elif HEATER_BED_USES_THERMISTOR - SCAN_THERMISTOR_TABLE(BED_TEMPTABLE, BED_TEMPTABLE_LEN); - #elif HEATER_BED_USES_AD595 + #elif TEMP_SENSOR_BED_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_BED, TEMPTABLE_BED_LEN); + #elif TEMP_SENSOR_BED_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_BED_USES_AD8495 + #elif TEMP_SENSOR_BED_IS_AD8495 return TEMP_AD8495(raw); #else UNUSED(raw); @@ -1617,13 +1621,13 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For chamber temperature measurement. float Temperature::analog_to_celsius_chamber(const int raw) { - #if HEATER_CHAMBER_USER_THERMISTOR + #if TEMP_SENSOR_CHAMBER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_CHAMBER, raw); - #elif HEATER_CHAMBER_USES_THERMISTOR - SCAN_THERMISTOR_TABLE(CHAMBER_TEMPTABLE, CHAMBER_TEMPTABLE_LEN); - #elif HEATER_CHAMBER_USES_AD595 + #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_CHAMBER, TEMPTABLE_CHAMBER_LEN); + #elif TEMP_SENSOR_CHAMBER_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_CHAMBER_USES_AD8495 + #elif TEMP_SENSOR_CHAMBER_IS_AD8495 return TEMP_AD8495(raw); #else UNUSED(raw); @@ -1636,13 +1640,13 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For probe temperature measurement. float Temperature::analog_to_celsius_probe(const int raw) { - #if HEATER_PROBE_USER_THERMISTOR + #if TEMP_SENSOR_PROBE_IS_CUSTOM return user_thermistor_to_deg_c(CTI_PROBE, raw); - #elif HEATER_PROBE_USES_THERMISTOR - SCAN_THERMISTOR_TABLE(PROBE_TEMPTABLE, PROBE_TEMPTABLE_LEN); - #elif HEATER_PROBE_USES_AD595 + #elif TEMP_SENSOR_PROBE_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_PROBE, TEMPTABLE_PROBE_LEN); + #elif TEMP_SENSOR_PROBE_IS_AD595 return TEMP_AD595(raw); - #elif HEATER_PROBE_USES_AD8495 + #elif TEMP_SENSOR_PROBE_IS_AD8495 return TEMP_AD8495(raw); #else UNUSED(raw); @@ -1658,8 +1662,8 @@ void Temperature::manage_heater() { * as it would block the stepper routine. */ void Temperature::updateTemperaturesFromRawValues() { - TERN_(HEATER_0_USES_MAX6675, temp_hotend[0].raw = READ_MAX6675(0)); - TERN_(HEATER_1_USES_MAX6675, temp_hotend[1].raw = READ_MAX6675(1)); + TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0)); + TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1)); #if HAS_HOTEND HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); #endif @@ -1676,9 +1680,9 @@ void Temperature::updateTemperaturesFromRawValues() { raw_temps_ready = false; } -#if MAX6675_SEPARATE_SPI +#if THERMO_SEPARATE_SPI template SoftSPI SPIclass::softSPI; - SPIclass max6675_spi; + SPIclass max_tc_spi; #endif // Init fans according to whether they're native PWM or Software PWM @@ -1715,8 +1719,8 @@ void Temperature::updateTemperaturesFromRawValues() { */ void Temperature::init() { - TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); + TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); #if EARLY_WATCHDOG // Flag that the thermalManager should be running @@ -1726,7 +1730,7 @@ void Temperature::init() { #if MB(RUMBA) // Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - #define _AD(N) (HEATER_##N##_USES_AD595 || HEATER_##N##_USES_AD8495) + #define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495) #if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER) MCUCR = _BV(JTD); MCUCR = _BV(JTD); @@ -1734,11 +1738,11 @@ void Temperature::init() { #endif // Thermistor activation by MCU pin - #if PIN_EXISTS(TEMP_0_TR_ENABLE_PIN) - OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(HEATER_0_USES_MAX6675)); + #if PIN_EXISTS(TEMP_0_TR_ENABLE) + OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_0_IS_MAX_TC)); #endif - #if PIN_EXISTS(TEMP_1_TR_ENABLE_PIN) - OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(HEATER_1_USES_MAX6675)); + #if PIN_EXISTS(TEMP_1_TR_ENABLE) + OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC)); #endif #if BOTH(PIDTEMP, PID_EXTRUSION_SCALING) @@ -1815,7 +1819,7 @@ void Temperature::init() { INIT_FAN_PIN(CONTROLLER_FAN_PIN); #endif - TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init()); + TERN_(THERMO_SEPARATE_SPI, max_tc_spi.init()); HAL_adc_init(); @@ -1914,19 +1918,19 @@ void Temperature::init() { #if HAS_HOTEND #define _TEMP_MIN_E(NR) do{ \ - const int16_t tmin = _MAX(HEATER_ ##NR## _MINTEMP, TERN(HEATER_##NR##_USER_THERMISTOR, 0, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MINTEMP_IND].celsius))); \ + const int16_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \ temp_range[NR].mintemp = tmin; \ while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \ temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) #define _TEMP_MAX_E(NR) do{ \ - const int16_t tmax = _MIN(HEATER_ ##NR## _MAXTEMP, TERN(HEATER_##NR##_USER_THERMISTOR, 2000, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MAXTEMP_IND].celsius) - 1)); \ + const int16_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \ temp_range[NR].maxtemp = tmax; \ while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \ temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) - #define _MINMAX_TEST(N,M) (HOTENDS > N && THERMISTOR_HEATER_##N && THERMISTOR_HEATER_##N != 998 && THERMISTOR_HEATER_##N != 999 && defined(HEATER_##N##_##M##TEMP)) + #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## THERMISTOR_ID && TEMP_SENSOR_ ##N## THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## THERMISTOR_ID != 999 && defined(HEATER_##N##_##M##TEMP)) #if _MINMAX_TEST(0, MIN) _TEMP_MIN_E(0); @@ -2221,105 +2225,106 @@ void Temperature::disable_all_heaters() { #endif -#if HAS_MAX6675 +#if HAS_MAX_TC #ifndef THERMOCOUPLE_MAX_ERRORS #define THERMOCOUPLE_MAX_ERRORS 15 #endif - int Temperature::read_max6675(TERN_(HAS_MULTI_6675, const uint8_t hindex/*=0*/)) { + int Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { #define MAX6675_HEAT_INTERVAL 250UL - #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 - static uint32_t max6675_temp = 2000; - #define MAX6675_ERROR_MASK 7 - #define MAX6675_DISCARD_BITS 18 - #define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 - #elif HAS_MAX31865 - static uint16_t max6675_temp = 2000; // From datasheet 16 bits D15-D0 - #define MAX6675_ERROR_MASK 1 // D0 Bit not used - #define MAX6675_DISCARD_BITS 1 // Data is in D15-D1 - #define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 + #if HAS_MAX31855 + static uint32_t max_tc_temp = 2000; + #define MAX_TC_ERROR_MASK 7 + #define MAX_TC_DISCARD_BITS 18 + #define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 + #elif HAS_MAX31865_TEMP + static uint16_t max_tc_temp = 2000; // From datasheet 16 bits D15-D0 + #define MAX_TC_ERROR_MASK 1 // D0 Bit not used + #define MAX_TC_DISCARD_BITS 1 // Data is in D15-D1 + #define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64 #else - static uint16_t max6675_temp = 2000; - #define MAX6675_ERROR_MASK 4 - #define MAX6675_DISCARD_BITS 3 - #define MAX6675_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16 + static uint16_t max_tc_temp = 2000; + #define MAX_TC_ERROR_MASK 4 + #define MAX_TC_DISCARD_BITS 3 + #define MAX_TC_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16 #endif - #if HAS_MULTI_6675 + #if HAS_MULTI_MAX_TC // Needed to return the correct temp when this is called between readings - static uint16_t max6675_temp_previous[COUNT_6675] = { 0 }; - #define MAX6675_TEMP(I) max6675_temp_previous[I] - #define MAX6675_SEL(A,B) (hindex ? (B) : (A)) + static uint16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; + #define THERMO_TEMP(I) max_tc_temp_previous[I] + #define THERMO_SEL(A,B) (hindex ? (B) : (A)) #define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) #define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0) #else constexpr uint8_t hindex = 0; - #define MAX6675_TEMP(I) max6675_temp - #if MAX6675_1_IS_MAX31865 - #define MAX6675_SEL(A,B) B + #define THERMO_TEMP(I) max_tc_temp + #if TEMP_SENSOR_1_IS_MAX31865 + #define THERMO_SEL(A,B) B #else - #define MAX6675_SEL(A,B) A + #define THERMO_SEL(A,B) A #endif - #if HEATER_0_USES_MAX6675 + #if TEMP_SENSOR_0_IS_MAX6675 #define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V) #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN) #else #define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V) #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN) #endif + #endif - static uint8_t max6675_errors[COUNT_6675] = { 0 }; + static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 }; // Return last-read value between readings - static millis_t next_max6675_ms[COUNT_6675] = { 0 }; + static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; millis_t ms = millis(); - if (PENDING(ms, next_max6675_ms[hindex])) return int(MAX6675_TEMP(hindex)); - next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; + if (PENDING(ms, next_max_tc_ms[hindex])) return int(THERMO_TEMP(hindex)); + next_max_tc_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; - #if HAS_MAX31865 - Adafruit_MAX31865 &maxref = MAX6675_SEL(max31865_0, max31865_1); - const uint16_t max31865_ohms = (uint32_t(maxref.readRTD()) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + #if HAS_MAX31865_TEMP + Adafruit_MAX31865 &maxref = THERMO_SEL(max31865_0, max31865_1); + const uint16_t max31865_ohms = (uint32_t(maxref.readRTD()) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; #endif // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. // - #if !MAX6675_SEPARATE_SPI + #if !THERMO_SEPARATE_SPI spiBegin(); - spiInit(MAX6675_SPEED_BITS); + spiInit(MAX_TC_SPEED_BITS); #endif - MAX6675_WRITE(LOW); // enable TT_MAX6675 - DELAY_NS(100); // Ensure 100ns delay + MAX6675_WRITE(LOW); // enable TT_MAX6675 + DELAY_NS(100); // Ensure 100ns delay // Read a big-endian temperature value - max6675_temp = 0; - for (uint8_t i = sizeof(max6675_temp); i--;) { - max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec()); - if (i > 0) max6675_temp <<= 8; // shift left if not the last byte + max_tc_temp = 0; + for (uint8_t i = sizeof(max_tc_temp); i--;) { + max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max_tc_spi.receive(), spiRec()); + if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte } MAX6675_WRITE(HIGH); // disable TT_MAX6675 - const uint8_t fault_31865 = TERN1(HAS_MAX31865, maxref.readFault()); + const uint8_t fault_31865 = TERN1(HAS_MAX31865_TEMP, maxref.readFault()); - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) { - max6675_errors[hindex]++; - if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max_tc_temp & MAX_TC_ERROR_MASK) && fault_31865) { + max_tc_errors[hindex]++; + if (max_tc_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { SERIAL_ERROR_START(); SERIAL_ECHOPGM("Temp measurement error! "); - #if MAX6675_ERROR_MASK == 7 + #if MAX_TC_ERROR_MASK == 7 SERIAL_ECHOPGM("MAX31855 "); - if (max6675_temp & 1) + if (max_tc_temp & 1) SERIAL_ECHOLNPGM("Open Circuit"); - else if (max6675_temp & 2) + else if (max_tc_temp & 2) SERIAL_ECHOLNPGM("Short to GND"); - else if (max6675_temp & 4) + else if (max_tc_temp & 4) SERIAL_ECHOLNPGM("Short to VCC"); - #elif HAS_MAX31865 + #elif HAS_MAX31865_TEMP if (fault_31865) { maxref.clearFault(); SERIAL_ECHOPAIR("MAX31865 Fault :(", fault_31865, ") >>"); @@ -2341,43 +2346,43 @@ void Temperature::disable_all_heaters() { #endif // Thermocouple open - max6675_temp = 4 * MAX6675_SEL(HEATER_0_MAX6675_TMAX, HEATER_1_MAX6675_TMAX); + max_tc_temp = 4 * THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX); } else - max6675_temp >>= MAX6675_DISCARD_BITS; + max_tc_temp >>= MAX_TC_DISCARD_BITS; } else { - max6675_temp >>= MAX6675_DISCARD_BITS; - max6675_errors[hindex] = 0; + max_tc_temp >>= MAX_TC_DISCARD_BITS; + max_tc_errors[hindex] = 0; } - #if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855 - if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature + #if HAS_MAX31855 + if (max_tc_temp & 0x00002000) max_tc_temp |= 0xFFFFC000; // Support negative temperature #endif // Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES - TERN_(HAS_MAX31865, max6675_temp = max31865_ohms); + TERN_(HAS_MAX31865_TEMP, max_tc_temp = max31865_ohms); - MAX6675_TEMP(hindex) = max6675_temp; + THERMO_TEMP(hindex) = max_tc_temp; - return int(max6675_temp); + return int(max_tc_temp); } -#endif // HAS_MAX6675 +#endif // HAS_MAX_TC /** * Update raw temperatures */ void Temperature::update_raw_temperatures() { - #if HAS_TEMP_ADC_0 && !HEATER_0_USES_MAX6675 + #if HAS_TEMP_ADC_0 && !TEMP_SENSOR_0_IS_MAX_TC temp_hotend[0].update(); #endif #if HAS_TEMP_ADC_1 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) redundant_temperature_raw = temp_hotend[1].acc; - #elif !HEATER_1_USES_MAX6675 + #elif !TEMP_SENSOR_1_IS_MAX_TC temp_hotend[1].update(); #endif #endif @@ -2423,9 +2428,9 @@ void Temperature::readings_ready() { #if HAS_HOTEND static constexpr int8_t temp_dir[] = { - TERN(HEATER_0_USES_MAX6675, 0, TEMPDIR(0)) + TERN(TEMP_SENSOR_0_IS_MAX_TC, 0, TEMPDIR(0)) #if HAS_MULTI_HOTEND - , TERN(HEATER_1_USES_MAX6675, 0, TEMPDIR(1)) + , TERN(TEMP_SENSOR_1_IS_MAX_TC, 0, TEMPDIR(1)) #if HOTENDS > 2 #define _TEMPDIR(N) , TEMPDIR(N) REPEAT_S(2, HOTENDS, _TEMPDIR) diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 002e1cbf71..75da232874 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -257,31 +257,31 @@ typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t; #if HAS_USER_THERMISTORS enum CustomThermistorIndex : uint8_t { - #if HEATER_0_USER_THERMISTOR + #if TEMP_SENSOR_0_IS_CUSTOM CTI_HOTEND_0, #endif - #if HEATER_1_USER_THERMISTOR + #if TEMP_SENSOR_1_IS_CUSTOM CTI_HOTEND_1, #endif - #if HEATER_2_USER_THERMISTOR + #if TEMP_SENSOR_2_IS_CUSTOM CTI_HOTEND_2, #endif - #if HEATER_3_USER_THERMISTOR + #if TEMP_SENSOR_3_IS_CUSTOM CTI_HOTEND_3, #endif - #if HEATER_4_USER_THERMISTOR + #if TEMP_SENSOR_4_IS_CUSTOM CTI_HOTEND_4, #endif - #if HEATER_5_USER_THERMISTOR + #if TEMP_SENSOR_5_IS_CUSTOM CTI_HOTEND_5, #endif - #if HEATER_BED_USER_THERMISTOR + #if TEMP_SENSOR_BED_IS_CUSTOM CTI_BED, #endif - #if HEATER_PROBE_USER_THERMISTOR + #if TEMP_SENSOR_PROBE_IS_CUSTOM CTI_PROBE, #endif - #if HEATER_CHAMBER_USER_THERMISTOR + #if TEMP_SENSOR_CHAMBER_IS_CUSTOM CTI_CHAMBER, #endif USER_THERMISTORS @@ -813,16 +813,15 @@ class Temperature { static void update_raw_temperatures(); static void updateTemperaturesFromRawValues(); - #define HAS_MAX6675 EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) - #if HAS_MAX6675 - #define COUNT_6675 1 + BOTH(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) - #if COUNT_6675 > 1 - #define HAS_MULTI_6675 1 - #define READ_MAX6675(N) read_max6675(N) + #if HAS_MAX_TC + #define MAX_TC_COUNT 1 + BOTH(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC) + #if MAX_TC_COUNT > 1 + #define HAS_MULTI_MAX_TC 1 + #define READ_MAX_TC(N) read_max_tc(N) #else - #define READ_MAX6675(N) read_max6675() + #define READ_MAX_TC(N) read_max_tc() #endif - static int read_max6675(TERN_(HAS_MULTI_6675, const uint8_t hindex=0)); + static int read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); #endif static void checkExtruderAutoFans(); diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 03ed5c2a57..77fc50c8d3 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -42,7 +42,7 @@ #define OV_SCALE(N) (N) #define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) -#define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTOR_HEATER_6 == n || THERMISTOR_HEATER_7 == n || THERMISTORBED == n || THERMISTORCHAMBER == n || THERMISTORPROBE == n) +#define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n) typedef struct { int16_t value, celsius; } temp_entry_t; @@ -205,121 +205,121 @@ typedef struct { int16_t value, celsius; } temp_entry_t; #define TT_NAME(_N) _TT_NAME(_N) -#if THERMISTOR_HEATER_0 - #define HEATER_0_TEMPTABLE TT_NAME(THERMISTOR_HEATER_0) - #define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE) -#elif HEATER_0_USES_THERMISTOR +#if TEMP_SENSOR_0_THERMISTOR_ID + #define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0_THERMISTOR_ID) + #define TEMPTABLE_0_LEN COUNT(TEMPTABLE_0) +#elif TEMP_SENSOR_0_IS_THERMISTOR #error "No heater 0 thermistor table specified" #else - #define HEATER_0_TEMPTABLE nullptr - #define HEATER_0_TEMPTABLE_LEN 0 + #define TEMPTABLE_0 nullptr + #define TEMPTABLE_0_LEN 0 #endif -#if THERMISTOR_HEATER_1 - #define HEATER_1_TEMPTABLE TT_NAME(THERMISTOR_HEATER_1) - #define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE) -#elif HEATER_1_USES_THERMISTOR +#if TEMP_SENSOR_1_THERMISTOR_ID + #define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1_THERMISTOR_ID) + #define TEMPTABLE_1_LEN COUNT(TEMPTABLE_1) +#elif TEMP_SENSOR_1_IS_THERMISTOR #error "No heater 1 thermistor table specified" #else - #define HEATER_1_TEMPTABLE nullptr - #define HEATER_1_TEMPTABLE_LEN 0 + #define TEMPTABLE_1 nullptr + #define TEMPTABLE_1_LEN 0 #endif -#if THERMISTOR_HEATER_2 - #define HEATER_2_TEMPTABLE TT_NAME(THERMISTOR_HEATER_2) - #define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE) -#elif HEATER_2_USES_THERMISTOR +#if TEMP_SENSOR_2_THERMISTOR_ID + #define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2_THERMISTOR_ID) + #define TEMPTABLE_2_LEN COUNT(TEMPTABLE_2) +#elif TEMP_SENSOR_2_IS_THERMISTOR #error "No heater 2 thermistor table specified" #else - #define HEATER_2_TEMPTABLE nullptr - #define HEATER_2_TEMPTABLE_LEN 0 + #define TEMPTABLE_2 nullptr + #define TEMPTABLE_2_LEN 0 #endif -#if THERMISTOR_HEATER_3 - #define HEATER_3_TEMPTABLE TT_NAME(THERMISTOR_HEATER_3) - #define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE) -#elif HEATER_3_USES_THERMISTOR +#if TEMP_SENSOR_3_THERMISTOR_ID + #define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3_THERMISTOR_ID) + #define TEMPTABLE_3_LEN COUNT(TEMPTABLE_3) +#elif TEMP_SENSOR_3_IS_THERMISTOR #error "No heater 3 thermistor table specified" #else - #define HEATER_3_TEMPTABLE nullptr - #define HEATER_3_TEMPTABLE_LEN 0 + #define TEMPTABLE_3 nullptr + #define TEMPTABLE_3_LEN 0 #endif -#if THERMISTOR_HEATER_4 - #define HEATER_4_TEMPTABLE TT_NAME(THERMISTOR_HEATER_4) - #define HEATER_4_TEMPTABLE_LEN COUNT(HEATER_4_TEMPTABLE) -#elif HEATER_4_USES_THERMISTOR +#if TEMP_SENSOR_4_THERMISTOR_ID + #define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4_THERMISTOR_ID) + #define TEMPTABLE_4_LEN COUNT(TEMPTABLE_4) +#elif TEMP_SENSOR_4_IS_THERMISTOR #error "No heater 4 thermistor table specified" #else - #define HEATER_4_TEMPTABLE nullptr - #define HEATER_4_TEMPTABLE_LEN 0 + #define TEMPTABLE_4 nullptr + #define TEMPTABLE_4_LEN 0 #endif -#if THERMISTOR_HEATER_5 - #define HEATER_5_TEMPTABLE TT_NAME(THERMISTOR_HEATER_5) - #define HEATER_5_TEMPTABLE_LEN COUNT(HEATER_5_TEMPTABLE) -#elif HEATER_5_USES_THERMISTOR +#if TEMP_SENSOR_5_THERMISTOR_ID + #define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5_THERMISTOR_ID) + #define TEMPTABLE_5_LEN COUNT(TEMPTABLE_5) +#elif TEMP_SENSOR_5_IS_THERMISTOR #error "No heater 5 thermistor table specified" #else - #define HEATER_5_TEMPTABLE nullptr - #define HEATER_5_TEMPTABLE_LEN 0 + #define TEMPTABLE_5 nullptr + #define TEMPTABLE_5_LEN 0 #endif -#if THERMISTOR_HEATER_6 - #define HEATER_6_TEMPTABLE TT_NAME(THERMISTOR_HEATER_6) - #define HEATER_6_TEMPTABLE_LEN COUNT(HEATER_6_TEMPTABLE) -#elif HEATER_6_USES_THERMISTOR +#if TEMP_SENSOR_6_THERMISTOR_ID + #define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6_THERMISTOR_ID) + #define TEMPTABLE_6_LEN COUNT(TEMPTABLE_6) +#elif TEMP_SENSOR_6_IS_THERMISTOR #error "No heater 6 thermistor table specified" #else - #define HEATER_6_TEMPTABLE nullptr - #define HEATER_6_TEMPTABLE_LEN 0 + #define TEMPTABLE_6 nullptr + #define TEMPTABLE_6_LEN 0 #endif -#if THERMISTOR_HEATER_7 - #define HEATER_7_TEMPTABLE TT_NAME(THERMISTOR_HEATER_7) - #define HEATER_7_TEMPTABLE_LEN COUNT(HEATER_7_TEMPTABLE) -#elif HEATER_7_USES_THERMISTOR +#if TEMP_SENSOR_7_THERMISTOR_ID + #define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7_THERMISTOR_ID) + #define TEMPTABLE_7_LEN COUNT(TEMPTABLE_7) +#elif TEMP_SENSOR_7_IS_THERMISTOR #error "No heater 7 thermistor table specified" #else - #define HEATER_7_TEMPTABLE nullptr - #define HEATER_7_TEMPTABLE_LEN 0 + #define TEMPTABLE_7 nullptr + #define TEMPTABLE_7_LEN 0 #endif -#ifdef THERMISTORBED - #define BED_TEMPTABLE TT_NAME(THERMISTORBED) - #define BED_TEMPTABLE_LEN COUNT(BED_TEMPTABLE) -#elif HEATER_BED_USES_THERMISTOR +#ifdef TEMP_SENSOR_BED_THERMISTOR_ID + #define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED_THERMISTOR_ID) + #define TEMPTABLE_BED_LEN COUNT(TEMPTABLE_BED) +#elif TEMP_SENSOR_BED_IS_THERMISTOR #error "No bed thermistor table specified" #else - #define BED_TEMPTABLE_LEN 0 + #define TEMPTABLE_BED_LEN 0 #endif -#ifdef THERMISTORCHAMBER - #define CHAMBER_TEMPTABLE TT_NAME(THERMISTORCHAMBER) - #define CHAMBER_TEMPTABLE_LEN COUNT(CHAMBER_TEMPTABLE) -#elif HEATER_CHAMBER_USES_THERMISTOR +#ifdef TEMP_SENSOR_CHAMBER_THERMISTOR_ID + #define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER_THERMISTOR_ID) + #define TEMPTABLE_CHAMBER_LEN COUNT(TEMPTABLE_CHAMBER) +#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR #error "No chamber thermistor table specified" #else - #define CHAMBER_TEMPTABLE_LEN 0 + #define TEMPTABLE_CHAMBER_LEN 0 #endif -#ifdef THERMISTORPROBE - #define PROBE_TEMPTABLE TT_NAME(THERMISTORPROBE) - #define PROBE_TEMPTABLE_LEN COUNT(PROBE_TEMPTABLE) -#elif HEATER_PROBE_USES_THERMISTOR +#ifdef TEMP_SENSOR_PROBE_THERMISTOR_ID + #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE_THERMISTOR_ID) + #define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE) +#elif TEMP_SENSOR_PROBE_IS_THERMISTOR #error "No probe thermistor table specified" #else - #define PROBE_TEMPTABLE_LEN 0 + #define TEMPTABLE_PROBE_LEN 0 #endif // The SCAN_THERMISTOR_TABLE macro needs alteration? static_assert( - HEATER_0_TEMPTABLE_LEN < 256 && HEATER_1_TEMPTABLE_LEN < 256 - && HEATER_2_TEMPTABLE_LEN < 256 && HEATER_3_TEMPTABLE_LEN < 256 - && HEATER_4_TEMPTABLE_LEN < 256 && HEATER_5_TEMPTABLE_LEN < 256 - && HEATER_6_TEMPTABLE_LEN < 256 && HEATER_7_TEMPTABLE_LEN < 256 - && BED_TEMPTABLE_LEN < 256 && CHAMBER_TEMPTABLE_LEN < 256 - && PROBE_TEMPTABLE_LEN < 256, + TEMPTABLE_0_LEN < 256 && TEMPTABLE_1_LEN < 256 + && TEMPTABLE_2_LEN < 256 && TEMPTABLE_3_LEN < 256 + && TEMPTABLE_4_LEN < 256 && TEMPTABLE_5_LEN < 256 + && TEMPTABLE_6_LEN < 256 && TEMPTABLE_7_LEN < 256 + && TEMPTABLE_BED_LEN < 256 && TEMPTABLE_CHAMBER_LEN < 256 + && TEMPTABLE_PROBE_LEN < 256, "Temperature conversion tables over 255 entries need special consideration." ); @@ -327,181 +327,185 @@ static_assert( // For thermistors the highest temperature results in the lowest ADC value // For thermocouples the highest temperature results in the highest ADC value -#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N -#define TT_REV(N) _TT_REV(N) +#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N +#define TT_REV(N) _TT_REV(TEMP_SENSOR_##N##_THERMISTOR_ID) +#define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR +#define TT_REVRAW(N) (TT_REV(N) || _TT_REVRAW(N)) -#ifdef HEATER_0_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_0) - #define HEATER_0_SENSOR_MINTEMP_IND 0 - #define HEATER_0_SENSOR_MAXTEMP_IND HEATER_0_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_0 + #if TT_REV(0) + #define TEMP_SENSOR_0_MINTEMP_IND 0 + #define TEMPTABLE_0_MAXTEMP_IND HEATER_0_LEN - 1 #else - #define HEATER_0_SENSOR_MINTEMP_IND HEATER_0_TEMPTABLE_LEN - 1 - #define HEATER_0_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_0_MINTEMP_IND HEATER_0_LEN - 1 + #define TEMP_SENSOR_0_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_1_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_1) - #define HEATER_1_SENSOR_MINTEMP_IND 0 - #define HEATER_1_SENSOR_MAXTEMP_IND HEATER_1_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_1 + #if TT_REV(1) + #define TEMP_SENSOR_1_MINTEMP_IND 0 + #define TEMPTABLE_1_MAXTEMP_IND HEATER_1_LEN - 1 #else - #define HEATER_1_SENSOR_MINTEMP_IND HEATER_1_TEMPTABLE_LEN - 1 - #define HEATER_1_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_1_MINTEMP_IND HEATER_1_LEN - 1 + #define TEMP_SENSOR_1_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_2_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_2) - #define HEATER_2_SENSOR_MINTEMP_IND 0 - #define HEATER_2_SENSOR_MAXTEMP_IND HEATER_2_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_2 + #if TT_REV(2) + #define TEMP_SENSOR_2_MINTEMP_IND 0 + #define TEMPTABLE_2_MAXTEMP_IND HEATER_2_LEN - 1 #else - #define HEATER_2_SENSOR_MINTEMP_IND HEATER_2_TEMPTABLE_LEN - 1 - #define HEATER_2_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_2_MINTEMP_IND HEATER_2_LEN - 1 + #define TEMP_SENSOR_2_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_3_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_3) - #define HEATER_3_SENSOR_MINTEMP_IND 0 - #define HEATER_3_SENSOR_MAXTEMP_IND HEATER_3_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_3 + #if TT_REV(3) + #define TEMP_SENSOR_3_MINTEMP_IND 0 + #define TEMPTABLE_3_MAXTEMP_IND HEATER_3_LEN - 1 #else - #define HEATER_3_SENSOR_MINTEMP_IND HEATER_3_TEMPTABLE_LEN - 1 - #define HEATER_3_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_3_MINTEMP_IND HEATER_3_LEN - 1 + #define TEMP_SENSOR_3_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_4_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_4) - #define HEATER_4_SENSOR_MINTEMP_IND 0 - #define HEATER_4_SENSOR_MAXTEMP_IND HEATER_4_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_4 + #if TT_REV(4) + #define TEMP_SENSOR_4_MINTEMP_IND 0 + #define TEMPTABLE_4_MAXTEMP_IND HEATER_4_LEN - 1 #else - #define HEATER_4_SENSOR_MINTEMP_IND HEATER_4_TEMPTABLE_LEN - 1 - #define HEATER_4_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_4_MINTEMP_IND HEATER_4_LEN - 1 + #define TEMP_SENSOR_4_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_5_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_5) - #define HEATER_5_SENSOR_MINTEMP_IND 0 - #define HEATER_5_SENSOR_MAXTEMP_IND HEATER_5_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_5 + #if TT_REV(5) + #define TEMP_SENSOR_5_MINTEMP_IND 0 + #define TEMPTABLE_5_MAXTEMP_IND HEATER_5_LEN - 1 #else - #define HEATER_5_SENSOR_MINTEMP_IND HEATER_5_TEMPTABLE_LEN - 1 - #define HEATER_5_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_5_MINTEMP_IND HEATER_5_LEN - 1 + #define TEMP_SENSOR_5_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_6_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_6) - #define HEATER_6_SENSOR_MINTEMP_IND 0 - #define HEATER_6_SENSOR_MAXTEMP_IND HEATER_6_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_6 + #if TT_REV(6) + #define TEMP_SENSOR_6_MINTEMP_IND 0 + #define TEMPTABLE_6_MAXTEMP_IND HEATER_6_LEN - 1 #else - #define HEATER_6_SENSOR_MINTEMP_IND HEATER_6_TEMPTABLE_LEN - 1 - #define HEATER_6_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_6_MINTEMP_IND HEATER_6_LEN - 1 + #define TEMP_SENSOR_6_MAXTEMP_IND 0 #endif #endif -#ifdef HEATER_7_TEMPTABLE - #if TT_REV(THERMISTOR_HEATER_7) - #define HEATER_7_SENSOR_MINTEMP_IND 0 - #define HEATER_7_SENSOR_MAXTEMP_IND HEATER_7_TEMPTABLE_LEN - 1 +#ifdef TEMPTABLE_7 + #if TT_REV(7) + #define TEMP_SENSOR_7_MINTEMP_IND 0 + #define TEMPTABLE_7_MAXTEMP_IND HEATER_7_LEN - 1 #else - #define HEATER_7_SENSOR_MINTEMP_IND HEATER_7_TEMPTABLE_LEN - 1 - #define HEATER_7_SENSOR_MAXTEMP_IND 0 + #define TEMPTABLE_7_MINTEMP_IND HEATER_7_LEN - 1 + #define TEMP_SENSOR_7_MAXTEMP_IND 0 #endif #endif -#ifndef HEATER_0_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_0) || !HEATER_0_USES_THERMISTOR - #define HEATER_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_0_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_0_RAW_HI_TEMP + #if TT_REVRAW(0) + #define TEMP_SENSOR_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_0_RAW_LO_TEMP 0 #else - #define HEATER_0_RAW_HI_TEMP 0 - #define HEATER_0_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_0_RAW_HI_TEMP 0 + #define TEMP_SENSOR_0_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_1_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_1) || !HEATER_1_USES_THERMISTOR - #define HEATER_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_1_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_1_RAW_HI_TEMP + #if TT_REVRAW(1) + #define TEMP_SENSOR_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_1_RAW_LO_TEMP 0 #else - #define HEATER_1_RAW_HI_TEMP 0 - #define HEATER_1_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_1_RAW_HI_TEMP 0 + #define TEMP_SENSOR_1_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_2_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_2) || !HEATER_2_USES_THERMISTOR - #define HEATER_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_2_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_2_RAW_HI_TEMP + #if TT_REVRAW(2) + #define TEMP_SENSOR_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_2_RAW_LO_TEMP 0 #else - #define HEATER_2_RAW_HI_TEMP 0 - #define HEATER_2_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_2_RAW_HI_TEMP 0 + #define TEMP_SENSOR_2_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_3_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_3) || !HEATER_3_USES_THERMISTOR - #define HEATER_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_3_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_3_RAW_HI_TEMP + #if TT_REVRAW(3) + #define TEMP_SENSOR_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_3_RAW_LO_TEMP 0 #else - #define HEATER_3_RAW_HI_TEMP 0 - #define HEATER_3_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_3_RAW_HI_TEMP 0 + #define TEMP_SENSOR_3_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_4_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_4) || !HEATER_4_USES_THERMISTOR - #define HEATER_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_4_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_4_RAW_HI_TEMP + #if TT_REVRAW(4) + #define TEMP_SENSOR_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_4_RAW_LO_TEMP 0 #else - #define HEATER_4_RAW_HI_TEMP 0 - #define HEATER_4_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_4_RAW_HI_TEMP 0 + #define TEMP_SENSOR_4_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_5_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_5) || !HEATER_5_USES_THERMISTOR - #define HEATER_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_5_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_5_RAW_HI_TEMP + #if TT_REVRAW(5) + #define TEMP_SENSOR_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_5_RAW_LO_TEMP 0 #else - #define HEATER_5_RAW_HI_TEMP 0 - #define HEATER_5_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_5_RAW_HI_TEMP 0 + #define TEMP_SENSOR_5_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_6_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_6) || !HEATER_6_USES_THERMISTOR - #define HEATER_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_6_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_6_RAW_HI_TEMP + #if TT_REVRAW(6) + #define TEMP_SENSOR_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_6_RAW_LO_TEMP 0 #else - #define HEATER_6_RAW_HI_TEMP 0 - #define HEATER_6_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_6_RAW_HI_TEMP 0 + #define TEMP_SENSOR_6_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_7_RAW_HI_TEMP - #if TT_REV(THERMISTOR_HEATER_7) || !HEATER_7_USES_THERMISTOR - #define HEATER_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_7_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_7_RAW_HI_TEMP + #if TT_REVRAW(7) + #define TEMP_SENSOR_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_7_RAW_LO_TEMP 0 #else - #define HEATER_7_RAW_HI_TEMP 0 - #define HEATER_7_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_7_RAW_HI_TEMP 0 + #define TEMP_SENSOR_7_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_BED_RAW_HI_TEMP - #if TT_REV(THERMISTORBED) || !HEATER_BED_USES_THERMISTOR - #define HEATER_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_BED_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_BED_RAW_HI_TEMP + #if TT_REVRAW(BED) + #define TEMP_SENSOR_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_BED_RAW_LO_TEMP 0 #else - #define HEATER_BED_RAW_HI_TEMP 0 - #define HEATER_BED_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_BED_RAW_HI_TEMP 0 + #define TEMP_SENSOR_BED_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_CHAMBER_RAW_HI_TEMP - #if TT_REV(THERMISTORCHAMBER) || !HEATER_CHAMBER_USES_THERMISTOR - #define HEATER_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_CHAMBER_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_CHAMBER_RAW_HI_TEMP + #if TT_REVRAW(CHAMBER) + #define TEMP_SENSOR_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_CHAMBER_RAW_LO_TEMP 0 #else - #define HEATER_CHAMBER_RAW_HI_TEMP 0 - #define HEATER_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_CHAMBER_RAW_HI_TEMP 0 + #define TEMP_SENSOR_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif -#ifndef HEATER_PROBE_RAW_HI_TEMP - #if TT_REV(THERMISTORPROBE) || !HEATER_PROBE_USES_THERMISTOR - #define HEATER_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE - #define HEATER_PROBE_RAW_LO_TEMP 0 +#ifndef TEMP_SENSOR_PROBE_RAW_HI_TEMP + #if TT_REVRAW(PROBE) + #define TEMP_SENSOR_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_PROBE_RAW_LO_TEMP 0 #else - #define HEATER_PROBE_RAW_HI_TEMP 0 - #define HEATER_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_PROBE_RAW_HI_TEMP 0 + #define TEMP_SENSOR_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif #undef _TT_REV #undef TT_REV +#undef _TT_REVRAW +#undef TT_REVRAW 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 54153beb1e..549b578f42 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -135,7 +135,7 @@ #define Y_STEP_PIN PE11 #define Y_DIR_PIN PE8 #define Y_ENABLE_PIN PD7 - #ifndef Y_CS_PIN +#ifndef Y_CS_PIN #define Y_CS_PIN PB8 #endif diff --git a/platformio.ini b/platformio.ini index 6008b943ec..9239ace72c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -235,7 +235,7 @@ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + + NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 src_filter=+ -MAX6675_._IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 +TEMP_.+_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 USES_LIQUIDCRYSTAL = bitbucket-fmalpartida/LiquidCrystal@1.5.0 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 From 01756b6b021118e82d109f9c5996846b10caed62 Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Sun, 7 Feb 2021 20:45:14 -0300 Subject: [PATCH 37/51] Fix LVGL "more" menu user items (#21004) Co-authored-by: Scott Lahteine --- Marlin/src/inc/Conditionals_adv.h | 7 + .../screens/custom_user_menus.cpp | 3 - Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp | 2 - .../lcd/extui/lib/mks_ui/tft_Language_en.h | 1 - .../lcd/extui/lib/mks_ui/tft_Language_fr.h | 1 - .../lcd/extui/lib/mks_ui/tft_Language_it.h | 1 - .../lcd/extui/lib/mks_ui/tft_Language_ru.h | 6 - .../lcd/extui/lib/mks_ui/tft_Language_s_cn.h | 1 - .../lcd/extui/lib/mks_ui/tft_Language_sp.h | 1 - .../lcd/extui/lib/mks_ui/tft_Language_t_cn.h | 1 - .../extui/lib/mks_ui/tft_multi_language.cpp | 160 +++++++++++------- Marlin/src/lcd/menu/menu_custom.cpp | 1 - 12 files changed, 103 insertions(+), 82 deletions(-) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index d6245718f4..c2ba04f0bc 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -516,3 +516,10 @@ (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || \ (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == (N)) || \ (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N)) + +#if ENABLED(CUSTOM_USER_MENUS) + #define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N)) + #define HAS_USER_ITEM(V...) DO(HAS,||,V) +#else + #define HAS_USER_ITEM(N) 0 +#endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.cpp index 9c7c12e10b..ea175706f7 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/custom_user_menus.cpp @@ -35,9 +35,6 @@ using namespace Theme; #define _USER_ITEM(N) .tag(_ITEM_TAG(N)).button(USER_ITEM_POS(N), _USER_DESC(N)) #define _USER_ACTION(N) case _ITEM_TAG(N): injectCommands_P(PSTR(_USER_GCODE(N))); TERN_(USER_SCRIPT_RETURN, GOTO_SCREEN(StatusScreen)); break; -#define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N)) -#define HAS_USER_ITEM(V...) DO(HAS,||,V) - void CustomUserMenus::onRedraw(draw_mode_t what) { if (what & BACKGROUND) { CommandProcessor cmd; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp index 62769ae89f..1eb54d231e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp @@ -33,8 +33,6 @@ extern lv_group_t * g; static lv_obj_t * scr; -#define HAS_USER_ITEM(N) (ENABLED(CUSTOM_USER_MENUS) && defined(USER_DESC_##N) && defined(USER_GCODE_##N)) - enum { ID_GCODE = 1, #if HAS_USER_ITEM(1) 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 5fa1c82027..fd5780e1d8 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 @@ -734,4 +734,3 @@ #define MORE_CUSTOM4_TEXT_EN USER_DESC_4 #define MORE_CUSTOM5_TEXT_EN USER_DESC_5 #define MORE_CUSTOM6_TEXT_EN USER_DESC_6 -#define MORE_CUSTOM7_TEXT_EN USER_DESC_7 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 55416f0254..9440b8b0eb 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 @@ -266,4 +266,3 @@ #define MORE_CUSTOM4_TEXT_FR USER_DESC_4 #define MORE_CUSTOM5_TEXT_FR USER_DESC_5 #define MORE_CUSTOM6_TEXT_FR USER_DESC_6 -#define MORE_CUSTOM7_TEXT_FR USER_DESC_7 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 d46cccfeb8..9b88de3df4 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 @@ -263,4 +263,3 @@ #define MORE_CUSTOM4_TEXT_IT USER_DESC_4 #define MORE_CUSTOM5_TEXT_IT USER_DESC_5 #define MORE_CUSTOM6_TEXT_IT USER_DESC_6 -#define MORE_CUSTOM7_TEXT_IT USER_DESC_7 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 f5955c38d1..1989eaef1b 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 @@ -261,11 +261,7 @@ #define MORE_CUSTOM4_TEXT_RU USER_DESC_4 #define MORE_CUSTOM5_TEXT_RU USER_DESC_5 #define MORE_CUSTOM6_TEXT_RU USER_DESC_6 -#define MORE_CUSTOM7_TEXT_RU USER_DESC_7 -//Malderin translate -// -// #define EEPROM_STORE_TIPS_RU "Cохранить настройки в EEPROM?" #define EEPROM_READ_TIPS_RU "читать настройки из EEPROM?" #define EEPROM_REVERT_TIPS_RU "Cбросить настройки к значениям по умолчанию?" @@ -365,5 +361,3 @@ #define ENCODER_CONF_TITLE_RU "Hастройки принтера>Hастройки энкодера" #define ENCODER_CONF_TEXT_RU "энкодер используется?" - -//end of Malderin translate 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 7ae87b5d3f..cc1a870339 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 @@ -501,4 +501,3 @@ #define MORE_CUSTOM4_TEXT_CN USER_DESC_4 #define MORE_CUSTOM5_TEXT_CN USER_DESC_5 #define MORE_CUSTOM6_TEXT_CN USER_DESC_6 -#define MORE_CUSTOM7_TEXT_CN USER_DESC_7 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 28afe186f1..4654abddee 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 @@ -272,4 +272,3 @@ #define MORE_CUSTOM4_TEXT_SP USER_DESC_4 #define MORE_CUSTOM5_TEXT_SP USER_DESC_5 #define MORE_CUSTOM6_TEXT_SP USER_DESC_6 -#define MORE_CUSTOM7_TEXT_SP USER_DESC_7 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 8d38bc3c9a..8057a3110e 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 @@ -499,4 +499,3 @@ #define MORE_CUSTOM4_TEXT_T_CN USER_DESC_4 #define MORE_CUSTOM5_TEXT_T_CN USER_DESC_5 #define MORE_CUSTOM6_TEXT_T_CN USER_DESC_6 -#define MORE_CUSTOM7_TEXT_T_CN USER_DESC_7 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 1fd17c20f7..5ee184571f 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 @@ -945,13 +945,24 @@ void disp_language_init() { more_menu.title = TITLE_MORE_CN; more_menu.gcode = MORE_GCODE_CN; more_menu.entergcode = MORE_ENTER_GCODE_CN; - TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_CN); - TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_CN); - TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_CN); - TERN_(USER_CMD_4_ENABLE, more_menu.custom4 = MORE_CUSTOM4_TEXT_CN); - TERN_(USER_CMD_5_ENABLE, more_menu.custom5 = MORE_CUSTOM5_TEXT_CN); - TERN_(USER_CMD_6_ENABLE, more_menu.custom6 = MORE_CUSTOM6_TEXT_CN); - TERN_(USER_CMD_7_ENABLE, more_menu.custom7 = MORE_CUSTOM7_TEXT_CN); + #if HAS_USER_ITEM(1) + more_menu.custom1 = MORE_CUSTOM1_TEXT_CN; + #endif + #if HAS_USER_ITEM(2) + more_menu.custom2 = MORE_CUSTOM2_TEXT_CN; + #endif + #if HAS_USER_ITEM(3) + more_menu.custom3 = MORE_CUSTOM3_TEXT_CN; + #endif + #if HAS_USER_ITEM(4) + more_menu.custom4 = MORE_CUSTOM4_TEXT_CN; + #endif + #if HAS_USER_ITEM(5) + more_menu.custom5 = MORE_CUSTOM5_TEXT_CN; + #endif + #if HAS_USER_ITEM(6) + more_menu.custom6 = MORE_CUSTOM6_TEXT_CN; + #endif // WIFI wifi_menu.title = WIFI_TEXT; wifi_menu.cloud = CLOUD_TEXT_CN; @@ -1179,13 +1190,24 @@ void disp_language_init() { more_menu.title = TITLE_MORE_T_CN; more_menu.gcode = MORE_GCODE_T_CN; more_menu.entergcode = MORE_ENTER_GCODE_T_CN; - TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_T_CN); - TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_T_CN); - TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_T_CN); - TERN_(USER_CMD_4_ENABLE, more_menu.custom4 = MORE_CUSTOM4_TEXT_T_CN); - TERN_(USER_CMD_5_ENABLE, more_menu.custom5 = MORE_CUSTOM5_TEXT_T_CN); - TERN_(USER_CMD_6_ENABLE, more_menu.custom6 = MORE_CUSTOM6_TEXT_T_CN); - TERN_(USER_CMD_7_ENABLE, more_menu.custom7 = MORE_CUSTOM7_TEXT_T_CN); + #if HAS_USER_ITEM(1) + more_menu.custom1 = MORE_CUSTOM1_TEXT_CN; + #endif + #if HAS_USER_ITEM(2) + more_menu.custom2 = MORE_CUSTOM2_TEXT_CN; + #endif + #if HAS_USER_ITEM(3) + more_menu.custom3 = MORE_CUSTOM3_TEXT_CN; + #endif + #if HAS_USER_ITEM(4) + more_menu.custom4 = MORE_CUSTOM4_TEXT_CN; + #endif + #if HAS_USER_ITEM(5) + more_menu.custom5 = MORE_CUSTOM5_TEXT_CN; + #endif + #if HAS_USER_ITEM(6) + more_menu.custom6 = MORE_CUSTOM6_TEXT_CN; + #endif // WIFI wifi_menu.title = WIFI_TEXT; wifi_menu.cloud = CLOUD_TEXT_T_CN; @@ -1400,13 +1422,24 @@ void disp_language_init() { more_menu.title = TITLE_MORE_EN; more_menu.gcode = MORE_GCODE_EN; more_menu.entergcode = MORE_ENTER_GCODE_EN; - TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_EN); - TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_EN); - TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_EN); - TERN_(USER_CMD_4_ENABLE, more_menu.custom4 = MORE_CUSTOM4_TEXT_EN); - TERN_(USER_CMD_5_ENABLE, more_menu.custom5 = MORE_CUSTOM5_TEXT_EN); - TERN_(USER_CMD_6_ENABLE, more_menu.custom6 = MORE_CUSTOM6_TEXT_EN); - TERN_(USER_CMD_7_ENABLE, more_menu.custom7 = MORE_CUSTOM7_TEXT_EN); + #if HAS_USER_ITEM(1) + more_menu.custom1 = MORE_CUSTOM1_TEXT_EN; + #endif + #if HAS_USER_ITEM(2) + more_menu.custom2 = MORE_CUSTOM2_TEXT_EN; + #endif + #if HAS_USER_ITEM(3) + more_menu.custom3 = MORE_CUSTOM3_TEXT_EN; + #endif + #if HAS_USER_ITEM(4) + more_menu.custom4 = MORE_CUSTOM4_TEXT_EN; + #endif + #if HAS_USER_ITEM(5) + more_menu.custom5 = MORE_CUSTOM5_TEXT_EN; + #endif + #if HAS_USER_ITEM(6) + more_menu.custom6 = MORE_CUSTOM6_TEXT_EN; + #endif // filesys_menu.title = TITLE_FILESYS_EN; @@ -1622,27 +1655,24 @@ void disp_language_init() { more_menu.title = TITLE_MORE_RU; more_menu.gcode = MORE_GCODE_RU; more_menu.entergcode = MORE_ENTER_GCODE_RU; - #if ENABLED(USER_CMD_1_ENABLE) + #if HAS_USER_ITEM(1) more_menu.custom1 = MORE_CUSTOM1_TEXT_RU; #endif - #if ENABLED(USER_CMD_2_ENABLE) + #if HAS_USER_ITEM(2) more_menu.custom2 = MORE_CUSTOM2_TEXT_RU; #endif - #if ENABLED(USER_CMD_3_ENABLE) + #if HAS_USER_ITEM(3) more_menu.custom3 = MORE_CUSTOM3_TEXT_RU; #endif - #if ENABLED(USER_CMD_4_ENABLE) + #if HAS_USER_ITEM(4) more_menu.custom4 = MORE_CUSTOM4_TEXT_RU; #endif - #if ENABLED(USER_CMD_5_ENABLE) + #if HAS_USER_ITEM(5) more_menu.custom5 = MORE_CUSTOM5_TEXT_RU; #endif - #if ENABLED(USER_CMD_6_ENABLE) + #if HAS_USER_ITEM(6) more_menu.custom6 = MORE_CUSTOM6_TEXT_RU; #endif - #if ENABLED(USER_CMD_7_ENABLE) - more_menu.custom7 = MORE_CUSTOM7_TEXT_RU; - #endif // filesys_menu.title = TITLE_FILESYS_RU; filesys_menu.sd_sys = SD_CARD_TEXT_RU; @@ -1954,27 +1984,24 @@ void disp_language_init() { more_menu.title = TITLE_MORE_SP; more_menu.gcode = MORE_GCODE_SP; more_menu.entergcode = MORE_ENTER_GCODE_SP; - #if ENABLED(USER_CMD_1_ENABLE) + #if HAS_USER_ITEM(1) more_menu.custom1 = MORE_CUSTOM1_TEXT_SP; #endif - #if ENABLED(USER_CMD_2_ENABLE) + #if HAS_USER_ITEM(2) more_menu.custom2 = MORE_CUSTOM2_TEXT_SP; #endif - #if ENABLED(USER_CMD_3_ENABLE) + #if HAS_USER_ITEM(3) more_menu.custom3 = MORE_CUSTOM3_TEXT_SP; #endif - #if ENABLED(USER_CMD_4_ENABLE) + #if HAS_USER_ITEM(4) more_menu.custom4 = MORE_CUSTOM4_TEXT_SP; #endif - #if ENABLED(USER_CMD_5_ENABLE) + #if HAS_USER_ITEM(5) more_menu.custom5 = MORE_CUSTOM5_TEXT_SP; #endif - #if ENABLED(USER_CMD_6_ENABLE) + #if HAS_USER_ITEM(6) more_menu.custom6 = MORE_CUSTOM6_TEXT_SP; #endif - #if ENABLED(USER_CMD_7_ENABLE) - more_menu.custom7 = MORE_CUSTOM7_TEXT_SP; - #endif // filesys_menu.title = TITLE_FILESYS_SP; filesys_menu.sd_sys = SD_CARD_TEXT_SP; @@ -2191,27 +2218,24 @@ void disp_language_init() { more_menu.title = TITLE_MORE_FR; more_menu.gcode = MORE_GCODE_FR; more_menu.entergcode = MORE_ENTER_GCODE_FR; - #if ENABLED(USER_CMD_1_ENABLE) + #if HAS_USER_ITEM(1) more_menu.custom1 = MORE_CUSTOM1_TEXT_FR; #endif - #if ENABLED(USER_CMD_2_ENABLE) + #if HAS_USER_ITEM(2) more_menu.custom2 = MORE_CUSTOM2_TEXT_FR; #endif - #if ENABLED(USER_CMD_3_ENABLE) + #if HAS_USER_ITEM(3) more_menu.custom3 = MORE_CUSTOM3_TEXT_FR; #endif - #if ENABLED(USER_CMD_4_ENABLE) + #if HAS_USER_ITEM(4) more_menu.custom4 = MORE_CUSTOM4_TEXT_FR; #endif - #if ENABLED(USER_CMD_5_ENABLE) + #if HAS_USER_ITEM(5) more_menu.custom5 = MORE_CUSTOM5_TEXT_FR; #endif - #if ENABLED(USER_CMD_6_ENABLE) + #if HAS_USER_ITEM(6) more_menu.custom6 = MORE_CUSTOM6_TEXT_FR; #endif - #if ENABLED(USER_CMD_7_ENABLE) - more_menu.custom7 = MORE_CUSTOM7_TEXT_FR; - #endif // filesys_menu.title = TITLE_FILESYS_FR; filesys_menu.sd_sys = SD_CARD_TEXT_FR; @@ -2429,27 +2453,24 @@ void disp_language_init() { more_menu.title = TITLE_MORE_IT; more_menu.gcode = MORE_GCODE_IT; more_menu.entergcode = MORE_ENTER_GCODE_IT; - #if ENABLED(USER_CMD_1_ENABLE) + #if HAS_USER_ITEM(1) more_menu.custom1 = MORE_CUSTOM1_TEXT_IT; #endif - #if ENABLED(USER_CMD_2_ENABLE) + #if HAS_USER_ITEM(2) more_menu.custom2 = MORE_CUSTOM2_TEXT_IT; #endif - #if ENABLED(USER_CMD_3_ENABLE) + #if HAS_USER_ITEM(3) more_menu.custom3 = MORE_CUSTOM3_TEXT_IT; #endif - #if ENABLED(USER_CMD_4_ENABLE) + #if HAS_USER_ITEM(4) more_menu.custom4 = MORE_CUSTOM4_TEXT_IT; #endif - #if ENABLED(USER_CMD_5_ENABLE) + #if HAS_USER_ITEM(5) more_menu.custom5 = MORE_CUSTOM5_TEXT_IT; #endif - #if ENABLED(USER_CMD_6_ENABLE) + #if HAS_USER_ITEM(6) more_menu.custom6 = MORE_CUSTOM6_TEXT_IT; #endif - #if ENABLED(USER_CMD_7_ENABLE) - more_menu.custom7 = MORE_CUSTOM7_TEXT_IT; - #endif // filesys_menu.title = TITLE_FILESYS_IT; filesys_menu.sd_sys = SD_CARD_TEXT_IT; @@ -2667,13 +2688,24 @@ void disp_language_init() { more_menu.title = TITLE_MORE_EN; more_menu.gcode = MORE_GCODE_EN; more_menu.entergcode = MORE_ENTER_GCODE_EN; - TERN_(USER_CMD_1_ENABLE, more_menu.custom1 = MORE_CUSTOM1_TEXT_EN); - TERN_(USER_CMD_2_ENABLE, more_menu.custom2 = MORE_CUSTOM2_TEXT_EN); - TERN_(USER_CMD_3_ENABLE, more_menu.custom3 = MORE_CUSTOM3_TEXT_EN); - TERN_(USER_CMD_4_ENABLE, more_menu.custom4 = MORE_CUSTOM4_TEXT_EN); - TERN_(USER_CMD_5_ENABLE, more_menu.custom5 = MORE_CUSTOM5_TEXT_EN); - TERN_(USER_CMD_6_ENABLE, more_menu.custom6 = MORE_CUSTOM6_TEXT_EN); - TERN_(USER_CMD_7_ENABLE, more_menu.custom7 = MORE_CUSTOM7_TEXT_EN); + #if HAS_USER_ITEM(1) + more_menu.custom1 = MORE_CUSTOM1_TEXT_EN; + #endif + #if HAS_USER_ITEM(2) + more_menu.custom2 = MORE_CUSTOM2_TEXT_EN; + #endif + #if HAS_USER_ITEM(3) + more_menu.custom3 = MORE_CUSTOM3_TEXT_EN; + #endif + #if HAS_USER_ITEM(4) + more_menu.custom4 = MORE_CUSTOM4_TEXT_EN; + #endif + #if HAS_USER_ITEM(5) + more_menu.custom5 = MORE_CUSTOM5_TEXT_EN; + #endif + #if HAS_USER_ITEM(6) + more_menu.custom6 = MORE_CUSTOM6_TEXT_EN; + #endif // filesys_menu.title = TITLE_FILESYS_EN; filesys_menu.sd_sys = SD_CARD_TEXT_EN; diff --git a/Marlin/src/lcd/menu/menu_custom.cpp b/Marlin/src/lcd/menu/menu_custom.cpp index 7c54ec6e26..f3f946883f 100644 --- a/Marlin/src/lcd/menu/menu_custom.cpp +++ b/Marlin/src/lcd/menu/menu_custom.cpp @@ -46,7 +46,6 @@ void _lcd_user_gcode(PGM_P const cmd) { void menu_user() { START_MENU(); BACK_ITEM(MSG_MAIN); - #define HAS_USER_ITEM(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N)) #define USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); }); #if HAS_USER_ITEM(1) USER_ITEM(1); From 42761acf4fd3c7c0d40f0351053db6b73eabaa55 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 8 Feb 2021 00:15:33 +0000 Subject: [PATCH 38/51] [cron] Bump distribution date (2021-02-08) --- 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 2c10a3d4a6..ad0d520b50 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 "2021-02-07" + #define STRING_DISTRIBUTION_DATE "2021-02-08" #endif /** From 6dcb77f7b59ce894bbb1ffec9064681155a3da4b Mon Sep 17 00:00:00 2001 From: ellensp Date: Mon, 8 Feb 2021 15:36:04 +1300 Subject: [PATCH 39/51] Fix mini12864 v2.1 + PSU control + NeoPixel backlight (#21021) --- Marlin/src/feature/leds/leds.cpp | 12 +++++++----- Marlin/src/feature/leds/leds.h | 2 +- Marlin/src/lcd/marlinui.cpp | 2 +- Marlin/src/lcd/menu/menu_led.cpp | 13 +++++++++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index ef9099fb20..c8cbdec33b 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -147,11 +147,13 @@ void LEDLights::set_color(const LEDColor &incol millis_t LEDLights::led_off_time; // = 0 void LEDLights::update_timeout(const bool power_on) { - const millis_t ms = millis(); - if (power_on) - reset_timeout(ms); - else if (ELAPSED(ms, led_off_time)) - set_off(); + if (lights_on) { + const millis_t ms = millis(); + if (power_on) + reset_timeout(ms); + else if (ELAPSED(ms, led_off_time)) + set_off(); + } } #endif diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 57b21d576c..d41c61144a 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -203,7 +203,7 @@ public: public: static inline void reset_timeout(const millis_t &ms) { led_off_time = ms + LED_BACKLIGHT_TIMEOUT; - if (!lights_on) set_default(); + if (!lights_on) update(); } static void update_timeout(const bool power_on); #endif diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index eea697a464..eaee08f43b 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -994,7 +994,7 @@ void MarlinUI::update() { refresh(LCDVIEW_REDRAW_NOW); #ifdef LED_BACKLIGHT_TIMEOUT - leds.reset_timeout(ms); + if (!powersupply_on) leds.reset_timeout(ms); #endif } diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 552c03a69f..de57502788 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -121,11 +121,20 @@ void menu_led() { BACK_ITEM(MSG_MAIN); #if ENABLED(LED_CONTROL_MENU) - editable.state = leds.lights_on; - EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle); + #if ENABLED(PSU_CONTROL) + extern bool powersupply_on; + #else + constexpr bool powersupply_on = true; + #endif + if (powersupply_on) { + editable.state = leds.lights_on; + EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle); + } + #if ENABLED(LED_COLOR_PRESETS) ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default); #endif + #if ENABLED(NEOPIXEL2_SEPARATE) editable.state = leds2.lights_on; EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle); From 57e4b82b66e0d98a370e1928a64840d2a9d5f501 Mon Sep 17 00:00:00 2001 From: MKS-Sean <56996910+MKS-Sean@users.noreply.github.com> Date: Mon, 8 Feb 2021 10:36:57 +0800 Subject: [PATCH 40/51] Fix: Unsupported use of %f in printf (#21001) --- .../lib/mks_ui/draw_acceleration_settings.cpp | 8 +-- .../draw_auto_level_offset_settings.cpp | 7 +- .../extui/lib/mks_ui/draw_baby_stepping.cpp | 20 ++++-- .../extui/lib/mks_ui/draw_jerk_settings.cpp | 9 +-- .../lib/mks_ui/draw_max_feedrate_settings.cpp | 11 ++-- .../lcd/extui/lib/mks_ui/draw_move_motor.cpp | 6 +- .../lcd/extui/lib/mks_ui/draw_number_key.cpp | 58 ++++++++--------- .../extui/lib/mks_ui/draw_pause_position.cpp | 7 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 3 +- .../extui/lib/mks_ui/draw_step_settings.cpp | 11 ++-- .../lib/mks_ui/draw_tmc_current_settings.cpp | 11 ++-- .../extui/lib/mks_ui/printer_operation.cpp | 11 ++-- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 64 +++++++++++++------ Marlin/src/module/temperature.cpp | 4 +- 15 files changed, 137 insertions(+), 95 deletions(-) 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 04c5ee77cb..4bc01c9e2d 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 @@ -109,15 +109,15 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_draw_acceleration_settings() { scr = lv_screen_create(ACCELERATION_UI, machine_menu.AccelerationConfTitle); - + char str_1[16]; if (!uiCfg.para_ui_page) { - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.acceleration); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.acceleration, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.PrintAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ACCE_PRINT, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.retract_acceleration); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.retract_acceleration, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.RetractAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_ACCE_RETRA, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.travel_acceleration); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.travel_acceleration, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.TravelAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_ACCE_TRAVEL, 2, public_buf_l); sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]); 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 index e41ad44c7a..f1cdbfe414 100644 --- 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 @@ -65,15 +65,16 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_auto_level_offset_settings() { + char str_1[16]; scr = lv_screen_create(NOZZLE_PROBE_OFFSET_UI, machine_menu.OffsetConfTitle); - sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0)); + sprintf_P(public_buf_l, PSTR("%s"), TERN(HAS_PROBE_XY_OFFSET, dtostrf(probe.offset.x, 1, 1, str_1) , 0)); lv_screen_menu_item_1_edit(scr, machine_menu.Xoffset, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_OFFSET_X, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0)); + sprintf_P(public_buf_l, PSTR("%s"), TERN(HAS_PROBE_XY_OFFSET, dtostrf(probe.offset.y, 1, 1, str_1) , 0)); lv_screen_menu_item_1_edit(scr, machine_menu.Yoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_OFFSET_Y, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z); + sprintf_P(public_buf_l, PSTR("%s"), TERN(HAS_PROBE_XY_OFFSET, dtostrf(probe.offset.z, 1, 1, str_1) , 0)); lv_screen_menu_item_1_edit(scr, machine_menu.Zoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_OFFSET_Z, 2, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_OFFSET_RETURN, true); 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 index 255f6e8f8a..1e268c9e82 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp @@ -60,34 +60,35 @@ static uint8_t has_adjust_z = 0; static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; char baby_buf[30] = { 0 }; + char str_1[16]; switch (obj->mks_obj_id) { case ID_BABY_STEP_X_P: - sprintf_P(baby_buf, PSTR("M290 X%.3f"), babystep_dist); + sprintf_P(baby_buf, PSTR("M290 X%s"), dtostrf(babystep_dist, 1, 3, str_1)); gcode.process_subcommands_now_P(PSTR(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_X_N: - sprintf_P(baby_buf, PSTR("M290 X%.3f"), -babystep_dist); + sprintf_P(baby_buf, PSTR("M290 X%s"), dtostrf(-babystep_dist, 1, 3, str_1)); gcode.process_subcommands_now_P(PSTR(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_Y_P: - sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist); + sprintf_P(baby_buf, PSTR("M290 Y%s"), dtostrf(babystep_dist, 1, 3, str_1)); gcode.process_subcommands_now_P(PSTR(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_Y_N: - sprintf_P(baby_buf, PSTR("M290 Y%.3f"), -babystep_dist); + sprintf_P(baby_buf, PSTR("M290 Y%s"), dtostrf(-babystep_dist, 1, 3, str_1)); gcode.process_subcommands_now_P(PSTR(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_Z_P: - sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist); + sprintf_P(baby_buf, PSTR("M290 Z%s"), dtostrf(babystep_dist, 1, 3, str_1)); gcode.process_subcommands_now_P(PSTR(baby_buf)); has_adjust_z = 1; break; case ID_BABY_STEP_Z_N: - sprintf_P(baby_buf, PSTR("M290 Z%.3f"), -babystep_dist); + sprintf_P(baby_buf, PSTR("M290 Z%s"), dtostrf(-babystep_dist, 1, 3, str_1)); gcode.process_subcommands_now_P(PSTR(baby_buf)); has_adjust_z = 1; break; @@ -161,7 +162,12 @@ void disp_baby_step_dist() { void disp_z_offset_value() { char buf[20]; - sprintf_P(buf, PSTR("offset Z: %.3f"), (float)TERN(HAS_BED_PROBE, probe.offset.z, 0)); + #if HAS_BED_PROBE + char str_1[16]; + sprintf_P(buf, PSTR("Offset Z: %s mm"), dtostrf(probe.offset.z, 1, 3, str_1)); + #else + strcpy_P(buf, PSTR("Offset Z: 0 mm")); + #endif lv_label_set_text(zOffsetText, buf); } 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 1c4ac9da61..c911b09128 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 @@ -71,18 +71,19 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_jerk_settings() { + char str_1[16]; scr = lv_screen_create(JERK_UI, machine_menu.JerkConfTitle); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.max_jerk[X_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.X_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_JERK_X, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Y_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.max_jerk[Y_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_JERK_Y, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Z_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.max_jerk[Z_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_JERK_Z, 2, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[E_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.max_jerk[E_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.E_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_JERK_E, 3, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_JERK_RETURN, true); 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 47bd906a51..cf74f42ee7 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 @@ -80,25 +80,26 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_max_feedrate_settings() { + char str_1[16]; scr = lv_screen_create(MAXFEEDRATE_UI, machine_menu.MaxFeedRateConfTitle); if (!uiCfg.para_ui_page) { - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.XMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_X, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.YMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FEED_Y, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.ZMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FEED_Z, 2, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.E0MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FEED_E0, 3, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_DOWN, true); } else { - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.E1MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_E1, 0, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_UP, true); 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 d10175344d..1c07583d53 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 @@ -52,6 +52,7 @@ enum { }; static void event_handler(lv_obj_t *obj, lv_event_t event) { + char str_1[16]; if (event != LV_EVENT_RELEASED) return; if (queue.length <= (BUFSIZE - 3)) { bool do_inject = true; @@ -63,7 +64,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { default: do_inject = false; } if (do_inject) { - sprintf_P(public_buf_l, PSTR("G91\nG1 %c%3.1f F%d\nG90"), cur_label, dist, uiCfg.moveSpeed); + sprintf_P(public_buf_l, PSTR("G91\nG1 %c%s F%d\nG90"), cur_label, dtostrf(dist, 1, 3, str_1), uiCfg.moveSpeed); queue.inject(public_buf_l); } } @@ -125,7 +126,8 @@ void lv_draw_move_motor() { } void disp_cur_pos() { - sprintf_P(public_buf_l, PSTR("%c:%3.1fmm"), cur_label, cur_pos); + char str_1[16]; + sprintf_P(public_buf_l, PSTR("%c:%s mm"), cur_label, dtostrf(cur_pos, 1, 1, str_1)); if (labelP) lv_label_set_text(labelP, public_buf_l); } 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 0694f89d74..d001175915 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 @@ -73,19 +73,20 @@ enum { static void disp_key_value() { char *temp; + char str_1[16]; #if HAS_TRINAMIC_CONFIG float milliamps; #endif switch (value) { case PrintAcceleration: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.acceleration); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.acceleration, 1, 1, str_1)); break; case RetractAcceleration: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.retract_acceleration); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.retract_acceleration, 1, 1, str_1)); break; case TravelAcceleration: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.travel_acceleration); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.travel_acceleration, 1, 1, str_1)); break; case XAcceleration: sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]); @@ -103,105 +104,104 @@ static void disp_key_value() { sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]); break; case XMaxFeedRate: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, str_1)); break; case YMaxFeedRate: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, str_1)); break; case ZMaxFeedRate: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, str_1)); break; case E0MaxFeedRate: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, str_1)); break; case E1MaxFeedRate: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, str_1)); break; case XJerk: #if HAS_CLASSIC_JERK - sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[X_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.max_jerk[X_AXIS], 1, 1, str_1)); #endif break; case YJerk: #if HAS_CLASSIC_JERK - sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[Y_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.max_jerk[Y_AXIS], 1, 1, str_1)); #endif break; case ZJerk: #if HAS_CLASSIC_JERK - sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[Z_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.max_jerk[Z_AXIS], 1, 1, str_1)); #endif break; case EJerk: #if HAS_CLASSIC_JERK - sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[E_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.max_jerk[E_AXIS], 1, 1, str_1)); #endif break; case Xstep: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]); - + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, str_1)); break; case Ystep: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Y_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, str_1)); break; case Zstep: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Z_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, str_1)); break; case E0step: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, str_1)); break; case E1step: - sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, str_1)); break; case Xcurrent: #if AXIS_IS_TMC(X) milliamps = stepperX.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); #endif break; case Ycurrent: #if AXIS_IS_TMC(Y) milliamps = stepperY.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); #endif break; case Zcurrent: #if AXIS_IS_TMC(Z) milliamps = stepperZ.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); #endif break; case E0current: #if AXIS_IS_TMC(E0) milliamps = stepperE0.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); #endif break; case E1current: #if AXIS_IS_TMC(E1) milliamps = stepperE1.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); #endif break; case pause_pos_x: - sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosX); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(gCfgItems.pausePosX, 1, 1, str_1)); break; case pause_pos_y: - sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosY); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(gCfgItems.pausePosY, 1, 1, str_1)); break; case pause_pos_z: - sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosZ); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(gCfgItems.pausePosZ, 1, 1, str_1)); break; case level_pos_x1: sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[0][0]); @@ -236,16 +236,16 @@ static void disp_key_value() { #if HAS_BED_PROBE case x_offset: #if HAS_PROBE_XY_OFFSET - sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.x); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(probe.offset.x, 1, 3, str_1)); #endif break; case y_offset: #if HAS_PROBE_XY_OFFSET - sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.y); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(probe.offset.y, 1, 3, str_1)); #endif break; case z_offset: - sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.z); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(probe.offset.z, 1, 3, str_1)); break; #endif case load_length: 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 46aa1a58d1..385276af39 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 @@ -60,15 +60,16 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_pause_position() { + char str_1[16]; scr = lv_screen_create(PAUSE_POS_UI, machine_menu.PausePosText); - sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosX); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(gCfgItems.pausePosX, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.xPos, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_X, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosY); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(gCfgItems.pausePosY, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.yPos, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_PAUSE_Y, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosZ); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(gCfgItems.pausePosZ, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.zPos, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_PAUSE_Z, 2, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_PAUSE_RETURN, true); 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 273462ac90..f2fda3a286 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -56,7 +56,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); } } - #if DISABLED(SINGLENOZZLE) && HAS_MULTI_EXTRUDER + #if HAS_MULTI_HOTEND 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); } 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 169cf1af7c..782ce21992 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -235,7 +235,8 @@ void disp_print_time() { } void disp_fan_Zpos() { - sprintf_P(public_buf_l, PSTR("%.3f"), current_position[Z_AXIS]); + char str_1[16]; + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(current_position[Z_AXIS], 1, 3, str_1)); lv_label_set_text(labelZpos, public_buf_l); } 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 c5cf45143f..a88669f371 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 @@ -79,25 +79,26 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } void lv_draw_step_settings() { + char str_1[16]; scr = lv_screen_create(STEPS_UI, machine_menu.StepsConfTitle); if (!uiCfg.para_ui_page) { - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.X_Steps, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_STEP_X, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Y_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_STEP_Y, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Z_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_STEP_Z, 2, public_buf_l); - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.E0_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_STEP_E0, 3, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_STEP_DOWN, true); } else { - sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.E1_Steps, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_STEP_E1, 0, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_STEP_UP, true); 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 61ee3be1c3..7f889461ea 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 @@ -95,13 +95,14 @@ void lv_draw_tmc_current_settings() { scr = lv_screen_create(TMC_CURRENT_UI, machine_menu.TmcCurrentConfTitle); float milliamps; + char str_1[16]; if (!uiCfg.para_ui_page) { #if AXIS_IS_TMC(X) milliamps = stepperX.getMilliamps(); #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.X_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_X, 0, public_buf_l); #if AXIS_IS_TMC(Y) @@ -109,7 +110,7 @@ void lv_draw_tmc_current_settings() { #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_CURRENT_Y, 1, public_buf_l); #if AXIS_IS_TMC(Z) @@ -117,7 +118,7 @@ void lv_draw_tmc_current_settings() { #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_CURRENT_Z, 2, public_buf_l); #if AXIS_IS_TMC(E0) @@ -125,7 +126,7 @@ void lv_draw_tmc_current_settings() { #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.E0_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_CURRENT_E0, 3, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_DOWN, true); @@ -136,7 +137,7 @@ void lv_draw_tmc_current_settings() { #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%.1f"), milliamps); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); lv_screen_menu_item_1_edit(scr, machine_menu.E1_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_E1, 0, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_UP, true); 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 4467df59d9..03bcf22822 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp @@ -42,6 +42,7 @@ extern uint32_t To_pre_view; extern bool flash_preview_begin, default_preview_flg, gcode_preview_over; void printer_state_polling() { + char str_1[16]; if (uiCfg.print_state == PAUSING) { #if ENABLED(SDSUPPORT) if (!planner.has_blocks_queued() && card.getIndex() > MIN_FILE_PRINTED) @@ -59,11 +60,11 @@ void printer_state_polling() { uiCfg.current_z_position_bak = current_position.z; if (gCfgItems.pausePosZ != (float)-1) { - sprintf_P(public_buf_l, PSTR("G91\nG1 Z%.1f\nG90"), gCfgItems.pausePosZ); + sprintf_P(public_buf_l, PSTR("G91\nG1 Z%s\nG90"), dtostrf(gCfgItems.pausePosZ, 1, 1, str_1)); gcode.process_subcommands_now(public_buf_l); } if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) { - sprintf_P(public_buf_l, PSTR("G1 X%.1f Y%.1f"), gCfgItems.pausePosX, gCfgItems.pausePosY); + sprintf_P(public_buf_l, PSTR("G1 X%s Y%s"), dtostrf(gCfgItems.pausePosX, 1, 1, str_1), dtostrf(gCfgItems.pausePosY, 1, 1, str_1)); gcode.process_subcommands_now(public_buf_l); } uiCfg.print_state = PAUSED; @@ -83,12 +84,12 @@ void printer_state_polling() { if (uiCfg.print_state == RESUMING) { if (IS_SD_PAUSED()) { if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) { - sprintf_P(public_buf_m, PSTR("G1 X%.1f Y%.1f"), uiCfg.current_x_position_bak, uiCfg.current_y_position_bak); + sprintf_P(public_buf_m, PSTR("G1 X%s Y%s"), dtostrf(uiCfg.current_x_position_bak, 1, 1, str_1), dtostrf(uiCfg.current_y_position_bak, 1, 1, str_1)); gcode.process_subcommands_now(public_buf_m); } if (gCfgItems.pausePosZ != (float)-1) { ZERO(public_buf_m); - sprintf_P(public_buf_m, PSTR("G1 Z%.1f"), uiCfg.current_z_position_bak); + sprintf_P(public_buf_m, PSTR("G1 Z%s"), dtostrf(uiCfg.current_z_position_bak, 1, 1, str_1)); gcode.process_subcommands_now(public_buf_m); } gcode.process_subcommands_now_P(M24_STR); @@ -126,7 +127,7 @@ void printer_state_polling() { gcode.process_subcommands_now(public_buf_m); if (gCfgItems.pause_reprint && gCfgItems.pausePosZ != -1.0f) { - sprintf_P(public_buf_l, PSTR("G91\nG1 Z-%.1f\nG90"), gCfgItems.pausePosZ); + sprintf_P(public_buf_l, PSTR("G91\nG1 Z-%s\nG90"), dtostrf(gCfgItems.pausePosZ, 1, 1, str_2)); gcode.process_subcommands_now(public_buf_l); } #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp index 785e854c52..71cdb0f7d4 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -874,38 +874,64 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { } } break; + case 105: case 991: ZERO(tempBuf); if (cmd_value == 105) { - SEND_OK_TO_WIFI; - sprintf_P((char *)tempBuf, PSTR("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, + SEND_OK_TO_WIFI; + + char *outBuf = (char *)tempBuf; + char str_1[16], tbuf[34]; + + dtostrf(thermalManager.temp_hotend[0].celsius, 1, 1, tbuf); + strcat_P(tbuf, PSTR(" /")); + strcat(tbuf, dtostrf(thermalManager.temp_hotend[0].target, 1, 1, str_1)); + + const int tlen = strlen(tbuf); + + sprintf_P(outBuf, PSTR("T:%s"), tbuf); + outBuf += 2 + tlen; + + strcpy_P(outBuf, PSTR(" B:")); + outBuf += 3; #if HAS_HEATED_BED - (float)thermalManager.temp_bed.celsius, (float)thermalManager.temp_bed.target, + strcpy(outBuf, dtostrf(thermalManager.temp_bed.celsius, 1, 1, str_1)); + strcat_P(outBuf, PSTR(" /")); + strcat(outBuf, dtostrf(thermalManager.temp_bed.target, 1, 1, str_1)); #else - 0.0f, 0.0f, + strcpy_P(outBuf, PSTR("0 /0")); #endif - (float)thermalManager.temp_hotend[0].celsius, (float)thermalManager.temp_hotend[0].target, - #if DISABLED(SINGLENOZZLE) && HAS_MULTI_EXTRUDER - (float)thermalManager.temp_hotend[1].celsius, (float)thermalManager.temp_hotend[1].target + outBuf += 4; + + strcat_P(outBuf, PSTR(" T0:")); + strcat(outBuf, tbuf); + outBuf += 4 + tlen; + + strcat_P(outBuf, PSTR(" T1:")); + outBuf += 4; + #if HAS_MULTI_HOTEND + strcat(outBuf, dtostrf(thermalManager.temp_hotend[1].celsius, 1, 1, str_1)); + strcat_P(outBuf, PSTR(" /")); + strcat(outBuf, dtostrf(thermalManager.temp_hotend[1].target, 1, 1, str_1)); #else - 0.0f, 0.0f + strcat_P(outBuf, PSTR("0 /0")); #endif - ); + outBuf += 4; + + strcat_P(outBuf, PSTR(" @:0 B@:0\r\n")); } else { sprintf_P((char *)tempBuf, PSTR("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 DISABLED(SINGLENOZZLE) && HAS_MULTI_EXTRUDER + (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 HAS_MULTI_HOTEND (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target #else 0, 0 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index c935323867..f66d60ab15 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3093,7 +3093,7 @@ void Temperature::tick() { #endif , H_CHAMBER ); - #endif // HAS_TEMP_CHAMBER + #endif #if HAS_TEMP_PROBE print_heater_state(degProbe(), 0 #if ENABLED(SHOW_TEMP_ADC_VALUES) @@ -3101,7 +3101,7 @@ void Temperature::tick() { #endif , H_PROBE ); - #endif // HAS_TEMP_PROBE + #endif #if HAS_MULTI_HOTEND HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e) #if ENABLED(SHOW_TEMP_ADC_VALUES) From 5f824c5708191f8d170a735e1a2ab2257fdc9e54 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 7 Feb 2021 20:43:18 -0600 Subject: [PATCH 41/51] Fix animated boot screen --- Marlin/src/lcd/dogm/dogm_Bootscreen.h | 4 ++++ Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 15 ++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Marlin/src/lcd/dogm/dogm_Bootscreen.h b/Marlin/src/lcd/dogm/dogm_Bootscreen.h index 0b8845ed79..4240861471 100644 --- a/Marlin/src/lcd/dogm/dogm_Bootscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Bootscreen.h @@ -39,6 +39,10 @@ #include "../../../_Bootscreen.h" + #if ENABLED(CUSTOM_BOOTSCREEN_ANIMATED) && DISABLED(CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME) && !defined(CUSTOM_BOOTSCREEN_FRAME_TIME) + #define CUSTOM_BOOTSCREEN_FRAME_TIME 500 // (ms) + #endif + #ifndef CUSTOM_BOOTSCREEN_BMPWIDTH #define CUSTOM_BOOTSCREEN_BMPWIDTH 128 #endif diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index c7c5908b36..d2b1ce7740 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -118,12 +118,10 @@ bool MarlinUI::detected() { return true; } #endif #if ENABLED(CUSTOM_BOOTSCREEN_ANIMATED) - const void * const frame_ptr = pgm_read_ptr(&custom_bootscreen_animation[frame]); - #if ENABLED(CUSTOM_BOOTSCREEN_TIME_PER_FRAME) - const boot_frame_t * const frame_info = (boot_frame_t*)frame_ptr; - const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)pgm_read_ptr(&frame_info->bitmap); + #if ENABLED(CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME) + const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)pgm_read_ptr(&custom_bootscreen_animation[frame].bitmap); #else - const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)frame_ptr; + const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)pgm_read_ptr(&custom_bootscreen_animation[frame]); #endif #else const u8g_pgm_uint8_t * const bmp = custom_start_bmp; @@ -150,16 +148,15 @@ bool MarlinUI::detected() { return true; } constexpr millis_t frame_time = 0; constexpr uint8_t f = 0; #else - #if DISABLED(CUSTOM_BOOTSCREEN_TIME_PER_FRAME) + #if DISABLED(CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME) constexpr millis_t frame_time = CUSTOM_BOOTSCREEN_FRAME_TIME; #endif LOOP_L_N(f, COUNT(custom_bootscreen_animation)) #endif { - #if ENABLED(CUSTOM_BOOTSCREEN_TIME_PER_FRAME) + #if ENABLED(CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME) const uint8_t fr = _MIN(f, COUNT(custom_bootscreen_animation) - 1); - const boot_frame_t * const frame_info = (boot_frame_t*)pgm_read_ptr(&custom_bootscreen_animation[fr]); - const millis_t frame_time = pgm_read_word(&frame_info->duration); + const millis_t frame_time = pgm_read_word(&custom_bootscreen_animation[fr].duration); #endif u8g.firstPage(); do { draw_custom_bootscreen(f); } while (u8g.nextPage()); From 24e18a9fbd567e0ed9e0633a50ebc7f599ef5cd5 Mon Sep 17 00:00:00 2001 From: "Alexander D. Kanevskiy" Date: Mon, 8 Feb 2021 06:44:49 +0200 Subject: [PATCH 42/51] Allow SERVO0_PIN override on Creality Melzi (#21007) --- Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h index 97db36dd54..225392de1b 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h @@ -68,8 +68,12 @@ #define LCD_PINS_D4 30 // ST9720 CLK #if ENABLED(BLTOUCH) - #define SERVO0_PIN 27 - #undef BEEPER_PIN + #ifndef SERVO0_PIN + #define SERVO0_PIN 27 + #endif + #if SERVO0_PIN == BEEPER_PIN + #undef BEEPER_PIN + #endif #elif ENABLED(FILAMENT_RUNOUT_SENSOR) #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 27 From 1e726fe405cb8e218398a42bb14ca571e25466b5 Mon Sep 17 00:00:00 2001 From: Arjan Mels <43108771+arjanmels@users.noreply.github.com> Date: Mon, 8 Feb 2021 05:47:08 +0100 Subject: [PATCH 43/51] Fix STM32F1 emergency parser (#21011) --- Marlin/src/HAL/STM32F1/HAL.cpp | 29 +++++++++++++++++++++++++++- Marlin/src/HAL/STM32F1/msc_sd.cpp | 32 +++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index c1e29a843c..2f29b9b0e3 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -84,7 +84,32 @@ #if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE USBSerial SerialUSB; - DefaultSerial MSerial(false, SerialUSB); + DefaultSerial MSerial(true, SerialUSB); + + #if ENABLED(EMERGENCY_PARSER) + #include "../libmaple/usb/stm32f1/usb_reg_map.h" + #include "libmaple/usb_cdcacm.h" + // The original callback is not called (no way to retrieve address). + // That callback detects a special STM32 reset sequence: this functionality is not essential + // as M997 achieves the same. + void my_rx_callback(unsigned int, void*) { + // max length of 16 is enough to contain all emergency commands + uint8 buf[16]; + + //rx is usbSerialPart.endpoints[2] + uint16 len = usb_get_ep_rx_count(USB_CDCACM_RX_ENDP); + uint32 total = usb_cdcacm_data_available(); + + if (len == 0 || total == 0 || !WITHIN(total, len, COUNT(buf))) + return; + + // cannot get character by character due to bug in composite_cdcacm_peek_ex + len = usb_cdcacm_peek(buf, total); + + for (uint32 i = 0; i < len; i++) + emergency_parser.update(MSerial.emergency_state, buf[i + total - len]); + } + #endif #endif uint16_t HAL_adc_result; @@ -254,6 +279,8 @@ void HAL_init() { #endif #if HAS_SD_HOST_DRIVE MSC_SD_init(); + #elif BOTH(SERIAL_USB, EMERGENCY_PARSER) + usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, my_rx_callback); #endif #if PIN_EXISTS(USB_CONNECT) OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection diff --git a/Marlin/src/HAL/STM32F1/msc_sd.cpp b/Marlin/src/HAL/STM32F1/msc_sd.cpp index 548a6dbc57..a916184999 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.cpp +++ b/Marlin/src/HAL/STM32F1/msc_sd.cpp @@ -19,6 +19,7 @@ #include "msc_sd.h" #include "SPI.h" +#include "usb_reg_map.h" #define PRODUCT_ID 0x29 @@ -41,14 +42,27 @@ Serial0Type MarlinCompositeSerial(true); #endif #if ENABLED(EMERGENCY_PARSER) - void (*real_rx_callback)(void); - void my_rx_callback(void) { - real_rx_callback(); - int len = MarlinCompositeSerial.available(); - while (len-- > 0) // >0 because available() may return a negative value - emergency_parser.update(MarlinCompositeSerial.emergency_state, MarlinCompositeSerial.peek()); - } +// The original callback is not called (no way to retrieve address). +// That callback detects a special STM32 reset sequence: this functionality is not essential +// as M997 achieves the same. +void my_rx_callback(unsigned int, void*) { + // max length of 16 is enough to contain all emergency commands + uint8 buf[16]; + + //rx is usbSerialPart.endpoints[2] + uint16 len = usb_get_ep_rx_count(usbSerialPart.endpoints[2].address); + uint32 total = composite_cdcacm_data_available(); + + if (len == 0 || total == 0 || !WITHIN(total, len, COUNT(buf))) + return; + + // cannot get character by character due to bug in composite_cdcacm_peek_ex + len = composite_cdcacm_peek(buf, total); + + for (uint32 i = 0; i < len; i++) + emergency_parser.update(MarlinCompositeSerial.emergency_state, buf[i+total-len]); +} #endif void MSC_SD_init() { @@ -73,9 +87,7 @@ void MSC_SD_init() { MarlinCompositeSerial.registerComponent(); USBComposite.begin(); #if ENABLED(EMERGENCY_PARSER) - //rx is usbSerialPart.endpoints[2] - real_rx_callback = usbSerialPart.endpoints[2].callback; - usbSerialPart.endpoints[2].callback = my_rx_callback; + composite_cdcacm_set_hooks(USBHID_CDCACM_HOOK_RX, my_rx_callback); #endif } From e7c711996bd3080f5e343eff5556736cbf2e2416 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Mon, 8 Feb 2021 07:37:24 +0100 Subject: [PATCH 44/51] Serial refactor. Default 8-bit ECHO to int, not char (#20985) Co-authored-by: Scott Lahteine --- Marlin/src/HAL/AVR/MarlinSerial.cpp | 2 +- Marlin/src/HAL/AVR/MarlinSerial.h | 2 +- Marlin/src/HAL/AVR/pinsDebug.h | 22 +-- Marlin/src/HAL/DUE/MarlinSerialUSB.cpp | 9 +- Marlin/src/HAL/DUE/MarlinSerialUSB.h | 19 ++- Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp | 6 +- Marlin/src/HAL/STM32F1/MarlinSerial.h | 26 ---- Marlin/src/HAL/shared/backtrace/backtrace.cpp | 4 +- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/core/macros.h | 6 + Marlin/src/core/serial.cpp | 4 +- Marlin/src/core/serial.h | 132 ++++++++++-------- Marlin/src/core/serial_base.h | 120 ++++++++++------ Marlin/src/core/serial_hook.h | 7 +- Marlin/src/feature/bedlevel/abl/abl.cpp | 4 +- Marlin/src/feature/bedlevel/bedlevel.cpp | 4 +- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 4 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 8 +- Marlin/src/feature/binary_stream.h | 2 +- Marlin/src/feature/bltouch.cpp | 6 +- Marlin/src/feature/cancel_object.cpp | 5 +- Marlin/src/feature/encoder_i2c.cpp | 8 +- Marlin/src/feature/encoder_i2c.h | 10 +- Marlin/src/feature/mixing.cpp | 4 +- Marlin/src/feature/mixing.h | 14 +- Marlin/src/feature/mmu/mmu2.cpp | 6 +- Marlin/src/feature/pause.cpp | 14 +- Marlin/src/feature/powerloss.cpp | 12 +- Marlin/src/feature/repeat.cpp | 6 +- Marlin/src/gcode/bedlevel/G26.cpp | 2 +- Marlin/src/gcode/bedlevel/G35.cpp | 4 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 4 +- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 6 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 18 +-- Marlin/src/gcode/calibrate/G425.cpp | 4 +- Marlin/src/gcode/calibrate/M48.cpp | 4 +- Marlin/src/gcode/config/M217.cpp | 2 +- Marlin/src/gcode/config/M305.cpp | 2 +- Marlin/src/gcode/config/M43.cpp | 6 +- Marlin/src/gcode/config/M92.cpp | 2 +- Marlin/src/gcode/control/M605.cpp | 16 +-- Marlin/src/gcode/eeprom/M500-M504.cpp | 4 +- Marlin/src/gcode/feature/advance/M900.cpp | 6 +- Marlin/src/gcode/feature/leds/M7219.cpp | 2 +- Marlin/src/gcode/feature/mixing/M166.cpp | 4 +- .../src/gcode/feature/network/M552-M554.cpp | 2 +- Marlin/src/gcode/feature/pause/G61.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 4 +- Marlin/src/gcode/host/M113.cpp | 2 +- Marlin/src/gcode/host/M360.cpp | 2 +- Marlin/src/gcode/motion/M290.cpp | 2 +- Marlin/src/gcode/parser.cpp | 6 +- Marlin/src/gcode/parser.h | 4 +- Marlin/src/gcode/probe/M851.cpp | 6 +- Marlin/src/gcode/queue.cpp | 4 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 2 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 2 +- .../ftdi_eve_lib/basic/commands.cpp | 4 +- .../ftdi_eve_lib/extended/event_loop.cpp | 4 +- .../ftdi_eve_lib/extended/screen_types.cpp | 2 +- .../ftdi_eve_lib/extended/sound_player.cpp | 4 +- Marlin/src/lcd/marlinui.cpp | 4 +- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/libs/bresenham.h | 2 +- Marlin/src/module/motion.cpp | 6 +- Marlin/src/module/probe.cpp | 2 +- Marlin/src/module/settings.cpp | 38 +++-- Marlin/src/module/temperature.cpp | 6 +- Marlin/src/module/tool_change.cpp | 26 ++-- Marlin/src/sd/SdBaseFile.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 2 +- docs/Serial.md | 20 +++ 72 files changed, 379 insertions(+), 337 deletions(-) diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index 265acfae92..562a70ced7 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -595,7 +595,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser); MarlinSerial>::_tx_udr_empty_irq(); } - template class MarlinSerial< MarlinSerialCfg >; + template class MarlinSerial< MMU2SerialCfg >; MSerialT3 mmuSerial(MSerialT3::HasEmergencyParser); #endif diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 2834dbed35..9abc3dbed0 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -263,7 +263,7 @@ }; typedef Serial0Type< MarlinSerial< MMU2SerialCfg > > MSerialT3; - extern MSerial3 mmuSerial; + extern MSerialT3 mmuSerial; #endif #ifdef LCD_SERIAL_PORT diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index dac6b1b150..6bf9f33a0c 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -235,8 +235,8 @@ static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin"); inline void com_print(const uint8_t N, const uint8_t Z) { const uint8_t *TCCRA = (uint8_t*)TCCR_A(N); - SERIAL_ECHOPGM(" COM"); - SERIAL_CHAR('0' + N, Z); + SERIAL_ECHOPAIR(" COM", AS_CHAR('0' + N)); + SERIAL_CHAR(Z); SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03)); } @@ -247,8 +247,8 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1)))); if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1); - SERIAL_ECHOPGM(" TIMER"); - SERIAL_CHAR(T + '0', L); + SERIAL_ECHOPAIR(" TIMER", AS_CHAR(T + '0')); + SERIAL_CHAR(L); SERIAL_ECHO_SP(3); if (N == 3) { @@ -262,19 +262,11 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - SERIAL_ECHOPAIR(" WGM: ", WGM); com_print(T,L); SERIAL_ECHOPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) )); - - SERIAL_ECHOPGM(" TCCR"); - SERIAL_CHAR(T + '0'); - SERIAL_ECHOPAIR("A: ", *TCCRA); - - SERIAL_ECHOPGM(" TCCR"); - SERIAL_CHAR(T + '0'); - SERIAL_ECHOPAIR("B: ", *TCCRB); + SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "A: ", *TCCRA); + SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "B: ", *TCCRB); const uint8_t *TMSK = (uint8_t*)TIMSK(T); - SERIAL_ECHOPGM(" TIMSK"); - SERIAL_CHAR(T + '0'); - SERIAL_ECHOPAIR(": ", *TMSK); + SERIAL_ECHOPAIR(" TIMSK", AS_CHAR(T + '0'), ": ", *TMSK); const uint8_t OCIE = L - 'A' + 1; if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); } diff --git a/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp index d85aaf14b0..a04993ca35 100644 --- a/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp @@ -33,10 +33,6 @@ #include "MarlinSerialUSB.h" -#if ENABLED(EMERGENCY_PARSER) - #include "../../feature/e_parser.h" -#endif - // Imports from Atmel USB Stack/CDC implementation extern "C" { bool usb_task_cdc_isenabled(); @@ -69,7 +65,7 @@ int MarlinSerialUSB::peek() { pending_char = udi_cdc_getc(); - TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)pending_char)); + TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast(this)->emergency_state, (char)pending_char)); return pending_char; } @@ -91,7 +87,7 @@ int MarlinSerialUSB::read() { int c = udi_cdc_getc(); - TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)c)); + TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast(this)->emergency_state, (char)c)); return c; } @@ -105,7 +101,6 @@ bool MarlinSerialUSB::available() { } void MarlinSerialUSB::flush() { } -void MarlinSerialUSB::flushTX() { } size_t MarlinSerialUSB::write(const uint8_t c) { diff --git a/Marlin/src/HAL/DUE/MarlinSerialUSB.h b/Marlin/src/HAL/DUE/MarlinSerialUSB.h index 9643a8465a..5281a006b1 100644 --- a/Marlin/src/HAL/DUE/MarlinSerialUSB.h +++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.h @@ -34,21 +34,20 @@ struct MarlinSerialUSB { - static void begin(const long); - static void end(); - static int peek(); - static int read(); - static void flush(); - static void flushTX(); - static bool available(); - static size_t write(const uint8_t c); + void begin(const long); + void end(); + int peek(); + int read(); + void flush(); + bool available(); + size_t write(const uint8_t c); #if ENABLED(SERIAL_STATS_DROPPED_RX) - FORCE_INLINE static uint32_t dropped() { return 0; } + FORCE_INLINE uint32_t dropped() { return 0; } #endif #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED) - FORCE_INLINE static int rxMaxEnqueued() { return 0; } + FORCE_INLINE int rxMaxEnqueued() { return 0; } #endif }; typedef Serial0Type MSerialT; diff --git a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp index 54a64ccd72..b97b161dc9 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp @@ -84,16 +84,16 @@ static void debug_rw(const bool write, int &pos, const uint8_t *value, const siz PGM_P const rw_str = write ? PSTR("write") : PSTR("read"); SERIAL_CHAR(' '); serialprintPGM(rw_str); - SERIAL_ECHOLNPAIR("_data(", pos, ",", int(value), ",", int(size), ", ...)"); + SERIAL_ECHOLNPAIR("_data(", pos, ",", value, ",", size, ", ...)"); if (total) { SERIAL_ECHOPGM(" f_"); serialprintPGM(rw_str); - SERIAL_ECHOPAIR("()=", int(s), "\n size=", int(size), "\n bytes_"); + SERIAL_ECHOPAIR("()=", s, "\n size=", size, "\n bytes_"); serialprintPGM(write ? PSTR("written=") : PSTR("read=")); SERIAL_ECHOLN(total); } else - SERIAL_ECHOLNPAIR(" f_lseek()=", int(s)); + SERIAL_ECHOLNPAIR(" f_lseek()=", s); } // File function return codes for type FRESULT. This goes away soon, but diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.h b/Marlin/src/HAL/STM32F1/MarlinSerial.h index 4c0bf0e100..692e97e618 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.h +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.h @@ -28,10 +28,6 @@ #include "../../inc/MarlinConfigPre.h" #include "../../core/serial_hook.h" -#if HAS_TFT_LVGL_UI - extern "C" { extern char public_buf_m[100]; } -#endif - // Increase priority of serial interrupts, to reduce overflow errors #define UART_IRQ_PRIO 1 @@ -49,28 +45,6 @@ struct MarlinSerial : public HardwareSerial { nvic_irq_set_priority(c_dev()->irq_num, UART_IRQ_PRIO); } #endif - - #if HAS_TFT_LVGL_UI - // Hook the serial write method to capture the output of GCode command sent via LCD - uint32_t current_wpos; - void (*line_callback)(void *, const char * msg); - void *user_pointer; - - void set_hook(void (*hook)(void *, const char *), void * that) { line_callback = hook; user_pointer = that; current_wpos = 0; } - - size_t write(uint8_t c) { - if (line_callback) { - if (c == '\n' || current_wpos == sizeof(public_buf_m) - 1) { // End of line, probably end of command anyway - public_buf_m[current_wpos] = 0; - line_callback(user_pointer, public_buf_m); - current_wpos = 0; - } - else - public_buf_m[current_wpos++] = c; - } - return HardwareSerial::write(c); - } - #endif }; typedef Serial0Type MSerialT; diff --git a/Marlin/src/HAL/shared/backtrace/backtrace.cpp b/Marlin/src/HAL/shared/backtrace/backtrace.cpp index 605e165b05..4a8990c00b 100644 --- a/Marlin/src/HAL/shared/backtrace/backtrace.cpp +++ b/Marlin/src/HAL/shared/backtrace/backtrace.cpp @@ -35,9 +35,9 @@ static bool UnwReportOut(void* ctx, const UnwReport* bte) { (*p)++; SERIAL_CHAR('#'); SERIAL_ECHO(*p); SERIAL_ECHOPGM(" : "); - SERIAL_ECHOPGM(bte->name ? bte->name : "unknown"); SERIAL_ECHOPGM("@0x"); SERIAL_PRINT(bte->function, HEX); + SERIAL_ECHOPGM(bte->name ? bte->name : "unknown"); SERIAL_ECHOPGM("@0x"); SERIAL_PRINT(bte->function, PrintBase::Hex); SERIAL_CHAR('+'); SERIAL_ECHO(bte->address - bte->function); - SERIAL_ECHOPGM(" PC:"); SERIAL_PRINT(bte->address,HEX); SERIAL_CHAR('\n'); + SERIAL_ECHOPGM(" PC:"); SERIAL_PRINT(bte->address, PrintBase::Hex); SERIAL_CHAR('\n'); return true; } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index df383d8a96..6b2259dd08 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1003,7 +1003,7 @@ void setup() { ); #endif SERIAL_ECHO_MSG("Compiled: " __DATE__); - SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, (int)sizeof(block_t) * (BLOCK_BUFFER_SIZE)); + SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE)); // Some HAL need precise delay adjustment calibrate_delay_loop(); diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 8361248e1c..0112dbc736 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -321,6 +321,12 @@ namespace Private { template struct enable_if { }; template struct enable_if { typedef _Tp type; }; + + template struct is_same { enum { value = false }; }; + template struct is_same { enum { value = true }; }; + + template struct first_type_of { typedef T type; }; + template struct first_type_of { typedef T type; }; } // C++11 solution using SFINAE to detect the existance of a member in a class at compile time. // It creates a HasMember structure containing 'value' set to true if the member exists diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 365f28ba55..31f6d67e32 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -59,12 +59,14 @@ void serialprintPGM(PGM_P str) { void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serialprintPGM(echomagic); } void serial_error_start() { static PGMSTR(errormagic, "Error:"); serialprintPGM(errormagic); } +void serial_echopair_PGM(PGM_P const s_P, serial_char_t v) { serialprintPGM(s_P); SERIAL_CHAR(v.c); } void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } +void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); } +void serial_echopair_PGM(PGM_P const s_P, unsigned char v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 4c0c32f7d8..c422f8e25b 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -81,37 +81,49 @@ typedef int8_t serial_index_t; #define PORT_REDIRECT(p) _PORT_REDIRECT(1,p) #define SERIAL_PORTMASK(P) _BV(P) -#define SERIAL_ECHO(x) SERIAL_OUT(print, x) -#define SERIAL_ECHO_F(V...) SERIAL_OUT(print, V) -#define SERIAL_ECHOLN(x) SERIAL_OUT(println, x) -#define SERIAL_PRINT(x,b) SERIAL_OUT(print, x, b) -#define SERIAL_PRINTLN(x,b) SERIAL_OUT(println, x, b) -#define SERIAL_FLUSH() SERIAL_OUT(flush) +// +// SERIAL_CHAR - Print one or more individual chars +// +inline void SERIAL_CHAR(char a) { SERIAL_IMPL.write(a); } +template +void SERIAL_CHAR(char a, Args ... args) { SERIAL_IMPL.write(a); SERIAL_CHAR(args ...); } -#ifdef ARDUINO_ARCH_STM32 - #define SERIAL_FLUSHTX() SERIAL_OUT(flush) -#elif TX_BUFFER_SIZE > 0 - #define SERIAL_FLUSHTX() SERIAL_OUT(flushTX) -#else - #define SERIAL_FLUSHTX() -#endif +/** + * SERIAL_ECHO - Print a single string or value. + * Any numeric parameter (including char) is printed as a base-10 number. + * A string pointer or literal will be output as a string. + * + * NOTE: Use SERIAL_CHAR to print char as a single character. + */ +template +void SERIAL_ECHO(T x) { SERIAL_IMPL.print(x); } -// Print up to 10 chars from a list -#define __CHAR_N(N,V...) _CHAR_##N(V) -#define _CHAR_N(N,V...) __CHAR_N(N,V) -#define _CHAR_1(c) SERIAL_OUT(write, c) -#define _CHAR_2(a,b) do{ _CHAR_1(a); _CHAR_1(b); }while(0) -#define _CHAR_3(a,V...) do{ _CHAR_1(a); _CHAR_2(V); }while(0) -#define _CHAR_4(a,V...) do{ _CHAR_1(a); _CHAR_3(V); }while(0) -#define _CHAR_5(a,V...) do{ _CHAR_1(a); _CHAR_4(V); }while(0) -#define _CHAR_6(a,V...) do{ _CHAR_1(a); _CHAR_5(V); }while(0) -#define _CHAR_7(a,V...) do{ _CHAR_1(a); _CHAR_6(V); }while(0) -#define _CHAR_8(a,V...) do{ _CHAR_1(a); _CHAR_7(V); }while(0) -#define _CHAR_9(a,V...) do{ _CHAR_1(a); _CHAR_8(V); }while(0) -#define _CHAR_10(a,V...) do{ _CHAR_1(a); _CHAR_9(V); }while(0) +// Wrapper for ECHO commands to interpret a char +typedef struct SerialChar { char c; SerialChar(char n) : c(n) { } } serial_char_t; +inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); } +#define AS_CHAR(C) serial_char_t(C) -#define SERIAL_CHAR(V...) _CHAR_N(NUM_ARGS(V),V) +// SERIAL_ECHO_F prints a floating point value with optional precision +inline void SERIAL_ECHO_F(EnsureDouble x, int digit = 2) { SERIAL_IMPL.print(x, digit); } +template +void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); } + +// SERIAL_PRINT works like SERIAL_ECHO but allow to specify the encoding base of the number printed +template +void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); } + +template +void SERIAL_PRINTLN(T x, U y) { SERIAL_IMPL.println(x, y); } + +// Flush the serial port +inline void SERIAL_FLUSH() { SERIAL_IMPL.flush(); } +inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); } + +// Print a single PROGMEM string to serial +void serialprintPGM(PGM_P str); + +// SERIAL_ECHOPAIR / SERIAL_ECHOPAIR_P is used to output a key value pair. The key must be a string and the value can be anything // Print up to 12 pairs of values. Odd elements auto-wrapped in PSTR(). #define __SEP_N(N,V...) _SEP_##N(V) #define _SEP_N(N,V...) __SEP_N(N,V) @@ -170,6 +182,7 @@ typedef int8_t serial_index_t; #define _SEP_23_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_21_P(V); }while(0) #define _SEP_24_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_22_P(V); }while(0) +// SERIAL_ECHOPAIR_P is used to output a key value pair. Unlike SERIAL_ECHOPAIR, the key must be a PGM string already and the value can be anything #define SERIAL_ECHOPAIR_P(V...) _SEP_N_P(NUM_ARGS(V),V) // Print up to 12 pairs of values followed by newline @@ -244,32 +257,39 @@ typedef int8_t serial_index_t; #define SERIAL_ECHOLNPAIR_P(V...) _SELP_N_P(NUM_ARGS(V),V) -// Print up to 20 comma-separated pairs of values -#define __SLST_N(N,V...) _SLST_##N(V) -#define _SLST_N(N,V...) __SLST_N(N,V) -#define _SLST_1(a) SERIAL_ECHO(a) -#define _SLST_2(a,b) do{ SERIAL_ECHO(a); SERIAL_ECHOPAIR(", ",b); }while(0) -#define _SLST_3(a,b,c) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_1(c); }while(0) -#define _SLST_4(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_2(V); }while(0) -#define _SLST_5(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_3(V); }while(0) -#define _SLST_6(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_4(V); }while(0) -#define _SLST_7(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_5(V); }while(0) -#define _SLST_8(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_6(V); }while(0) -#define _SLST_9(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_7(V); }while(0) -#define _SLST_10(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_8(V); }while(0) -#define _SLST_11(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_9(V); }while(0) -#define _SLST_12(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_10(V); }while(0) -#define _SLST_13(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_11(V); }while(0) -#define _SLST_14(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_12(V); }while(0) -#define _SLST_15(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_13(V); }while(0) -#define _SLST_16(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_14(V); }while(0) -#define _SLST_17(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_15(V); }while(0) -#define _SLST_18(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_16(V); }while(0) -#define _SLST_19(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_17(V); }while(0) -#define _SLST_20(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_18(V); }while(0) // Eat two args, pass the rest up +#ifdef AllowDifferentTypeInList -#define SERIAL_ECHOLIST(pre,V...) do{ SERIAL_ECHOPGM(pre); _SLST_N(NUM_ARGS(V),V); }while(0) -#define SERIAL_ECHOLIST_N(N,V...) _SLST_N(N,LIST_N(N,V)) + inline void SERIAL_ECHOLIST_IMPL() {} + template + void SERIAL_ECHOLIST_IMPL(T && t) { SERIAL_IMPL.print(t); } + + template + void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) { + SERIAL_IMPL.print(t); + serialprintPGM(PSTR(", ")); + SERIAL_ECHOLIST_IMPL(args...); + } + + template + void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) { + SERIAL_IMPL.print(str); + SERIAL_ECHOLIST_IMPL(args...); + } + +#else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead) + + template + void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) { + serialprintPGM(str); + typename Private::first_type_of::type values[] = { args... }; + constexpr size_t argsSize = sizeof...(args); + for (size_t i = 0; i < argsSize; i++) { + if (i) serialprintPGM(PSTR(", ")); + SERIAL_IMPL.print(values[i]); + } + } + +#endif #define SERIAL_ECHOPGM_P(P) (serialprintPGM(P)) #define SERIAL_ECHOLNPGM_P(P) (serialprintPGM(P "\n")) @@ -303,19 +323,19 @@ typedef int8_t serial_index_t; // // Functions for serial printing from PROGMEM. (Saves loads of SRAM.) // +void serial_echopair_PGM(PGM_P const s_P, serial_char_t v); void serial_echopair_PGM(PGM_P const s_P, const char *v); void serial_echopair_PGM(PGM_P const s_P, char v); void serial_echopair_PGM(PGM_P const s_P, int v); -void serial_echopair_PGM(PGM_P const s_P, unsigned int v); void serial_echopair_PGM(PGM_P const s_P, long v); -void serial_echopair_PGM(PGM_P const s_P, unsigned long v); void serial_echopair_PGM(PGM_P const s_P, float v); void serial_echopair_PGM(PGM_P const s_P, double v); -inline void serial_echopair_PGM(PGM_P const s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); } +void serial_echopair_PGM(PGM_P const s_P, unsigned char v); +void serial_echopair_PGM(PGM_P const s_P, unsigned int v); +void serial_echopair_PGM(PGM_P const s_P, unsigned long v); inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); } inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (uintptr_t)v); } -void serialprintPGM(PGM_P str); void serial_echo_start(); void serial_error_start(); void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post=nullptr); diff --git a/Marlin/src/core/serial_base.h b/Marlin/src/core/serial_base.h index f52fa11202..81403b55f2 100644 --- a/Marlin/src/core/serial_base.h +++ b/Marlin/src/core/serial_base.h @@ -22,25 +22,41 @@ #pragma once #include "../inc/MarlinConfigPre.h" +#include "macros.h" #if ENABLED(EMERGENCY_PARSER) #include "../feature/e_parser.h" #endif -#ifndef DEC - #define DEC 10 - #define HEX 16 - #define OCT 8 - #define BIN 2 -#endif - // flushTX is not implemented in all HAL, so use SFINAE to call the method where it is. CALL_IF_EXISTS_IMPL(void, flushTX ); CALL_IF_EXISTS_IMPL(bool, connected, true); +// In order to catch usage errors in code, we make the base to encode number explicit +// If given a number (and not this enum), the compiler will reject the overload, falling back to the (double, digit) version +// We don't want hidden conversion of the first parameter to double, so it has to be as hard to do for the compiler as creating this enum +enum class PrintBase { + Dec = 10, + Hex = 16, + Oct = 8, + Bin = 2 +}; + +// A simple forward struct that prevent the compiler to select print(double, int) as a default overload for any type different than +// double or float. For double or float, a conversion exists so the call will be transparent +struct EnsureDouble { + double a; + FORCE_INLINE operator double() { return a; } + // If the compiler breaks on ambiguity here, it's likely because you're calling print(X, base) with X not a double or a float, and a + // base that's not one of PrintBase's value. This exact code is made to detect such error, you NEED to set a base explicitely like this: + // SERIAL_PRINT(v, PrintBase::Hex) + FORCE_INLINE EnsureDouble(double a) : a(a) {} + FORCE_INLINE EnsureDouble(float a) : a(a) {} +}; + // Using Curiously Recurring Template Pattern here to avoid virtual table cost when compiling. -// Since the real serial class is known at compile time, this results in compiler writing a completely -// efficient code +// Since the real serial class is known at compile time, this results in the compiler writing +// a completely efficient code. template struct SerialBase { #if ENABLED(EMERGENCY_PARSER) @@ -78,39 +94,47 @@ struct SerialBase { FORCE_INLINE void write(const char* str) { while (*str) write(*str++); } FORCE_INLINE void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); } FORCE_INLINE void print(const char* str) { write(str); } - NO_INLINE void print(char c, int base = 0) { print((long)c, base); } - NO_INLINE void print(unsigned char c, int base = 0) { print((unsigned long)c, base); } - NO_INLINE void print(int c, int base = DEC) { print((long)c, base); } - NO_INLINE void print(unsigned int c, int base = DEC) { print((unsigned long)c, base); } - void print(unsigned long c, int base = DEC) { printNumber(c, base); } - void print(double c, int digits = 2) { printFloat(c, digits); } - void print(long c, int base = DEC) { - if (!base) { - write(c); - return; - } - if (base == DEC && c < 0) { - write((uint8_t)'-'); c = -c; - } - printNumber(c, base); - } + // No default argument to avoid ambiguity + NO_INLINE void print(char c, PrintBase base) { printNumber((signed long)c, (uint8_t)base); } + NO_INLINE void print(unsigned char c, PrintBase base) { printNumber((unsigned long)c, (uint8_t)base); } + NO_INLINE void print(int c, PrintBase base) { printNumber((signed long)c, (uint8_t)base); } + NO_INLINE void print(unsigned int c, PrintBase base) { printNumber((unsigned long)c, (uint8_t)base); } + void print(unsigned long c, PrintBase base) { printNumber((unsigned long)c, (uint8_t)base); } + void print(long c, PrintBase base) { printNumber((signed long)c, (uint8_t)base); } + void print(EnsureDouble c, int digits) { printFloat(c, digits); } - NO_INLINE void println(const char s[]) { print(s); println(); } - NO_INLINE void println(char c, int base = 0) { print(c, base); println(); } - NO_INLINE void println(unsigned char c, int base = 0) { print(c, base); println(); } - NO_INLINE void println(int c, int base = DEC) { print(c, base); println(); } - NO_INLINE void println(unsigned int c, int base = DEC) { print(c, base); println(); } - NO_INLINE void println(long c, int base = DEC) { print(c, base); println(); } - NO_INLINE void println(unsigned long c, int base = DEC) { print(c, base); println(); } - NO_INLINE void println(double c, int digits = 2) { print(c, digits); println(); } - NO_INLINE void println() { write('\r'); write('\n'); } + // Forward the call to the former's method + FORCE_INLINE void print(char c) { print(c, PrintBase::Dec); } + FORCE_INLINE void print(unsigned char c) { print(c, PrintBase::Dec); } + FORCE_INLINE void print(int c) { print(c, PrintBase::Dec); } + FORCE_INLINE void print(unsigned int c) { print(c, PrintBase::Dec); } + FORCE_INLINE void print(unsigned long c) { print(c, PrintBase::Dec); } + FORCE_INLINE void print(long c) { print(c, PrintBase::Dec); } + FORCE_INLINE void print(double c) { print(c, 2); } + + FORCE_INLINE void println(const char s[]) { print(s); println(); } + FORCE_INLINE void println(char c, PrintBase base) { print(c, base); println(); } + FORCE_INLINE void println(unsigned char c, PrintBase base) { print(c, base); println(); } + FORCE_INLINE void println(int c, PrintBase base) { print(c, base); println(); } + FORCE_INLINE void println(unsigned int c, PrintBase base) { print(c, base); println(); } + FORCE_INLINE void println(long c, PrintBase base) { print(c, base); println(); } + FORCE_INLINE void println(unsigned long c, PrintBase base) { print(c, base); println(); } + FORCE_INLINE void println(double c, int digits) { print(c, digits); println(); } + FORCE_INLINE void println() { write('\r'); write('\n'); } + + // Forward the call to the former's method + FORCE_INLINE void println(char c) { println(c, PrintBase::Dec); } + FORCE_INLINE void println(unsigned char c) { println(c, PrintBase::Dec); } + FORCE_INLINE void println(int c) { println(c, PrintBase::Dec); } + FORCE_INLINE void println(unsigned int c) { println(c, PrintBase::Dec); } + FORCE_INLINE void println(unsigned long c) { println(c, PrintBase::Dec); } + FORCE_INLINE void println(long c) { println(c, PrintBase::Dec); } + FORCE_INLINE void println(double c) { println(c, 2); } // Print a number with the given base - void printNumber(unsigned long n, const uint8_t base) { - if (!base) { - write((uint8_t)n); - return; - } + NO_INLINE void printNumber(unsigned long n, const uint8_t base) { + if (!base) return; // Hopefully, this should raise visible bug immediately + if (n) { unsigned char buf[8 * sizeof(long)]; // Enough space for base 2 int8_t i = 0; @@ -122,9 +146,19 @@ struct SerialBase { } else write('0'); } + void printNumber(signed long n, const uint8_t base) { + if (base == 10 && n < 0) { + n = -n; // This works because all platforms Marlin's builds on are using 2-complement encoding for negative number + // On such CPU, changing the sign of a number is done by inverting the bits and adding one, so if n = 0x80000000 = -2147483648 then + // -n = 0x7FFFFFFF + 1 => 0x80000000 = 2147483648 (if interpreted as unsigned) or -2147483648 if interpreted as signed. + // On non 2-complement CPU, there would be no possible representation for 2147483648. + write('-'); + } + printNumber((unsigned long)n , base); + } // Print a decimal number - void printFloat(double number, uint8_t digits) { + NO_INLINE void printFloat(double number, uint8_t digits) { // Handle negative numbers if (number < 0.0) { write('-'); @@ -147,7 +181,7 @@ struct SerialBase { // Extract digits from the remainder one at a time while (digits--) { remainder *= 10.0; - int toPrint = int(remainder); + unsigned long toPrint = (unsigned long)remainder; printNumber(toPrint, 10); remainder -= toPrint; } @@ -155,5 +189,5 @@ struct SerialBase { } }; -// All serial instances will be built by chaining the features required for the function in a form of a template -// type definition +// All serial instances will be built by chaining the features required +// for the function in the form of a template type definition. diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index 45e64d7793..ad8ec12b6e 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -21,6 +21,7 @@ */ #pragma once +#include "macros.h" #include "serial_base.h" // The most basic serial class: it dispatch to the base serial class with no hook whatsoever. This will compile to nothing but the base serial class @@ -37,6 +38,8 @@ struct BaseSerial : public SerialBase< BaseSerial >, public SerialT { bool available(uint8_t index) { return index == 0 && SerialT::available(); } int read(uint8_t index) { return index == 0 ? SerialT::read() : -1; } bool connected() { return CALL_IF_EXISTS(bool, static_cast(this), connected);; } + void flushTX() { CALL_IF_EXISTS(void, static_cast(this), flushTX); } + // We have 2 implementation of the same method in both base class, let's say which one we want using SerialT::available; using SerialT::read; @@ -68,6 +71,7 @@ struct ConditionalSerial : public SerialBase< ConditionalSerial > { void msgDone() {} bool connected() { return CALL_IF_EXISTS(bool, &out, connected); } + void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); } bool available(uint8_t index) { return index == 0 && out.available(); } int read(uint8_t index) { return index == 0 ? out.read() : -1; } @@ -91,6 +95,7 @@ struct ForwardSerial : public SerialBase< ForwardSerial > { void msgDone() {} // Existing instances implement Arduino's operator bool, so use that if it's available bool connected() { return Private::HasMember_connected::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; } + void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); } bool available(uint8_t index) { return index == 0 && out.available(); } int read(uint8_t index) { return index == 0 ? out.read() : -1; } @@ -131,11 +136,11 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial >, public Seria using BaseClassT::print; using BaseClassT::println; - // Underlying implementation might use Arduino's bool operator bool connected() { return Private::HasMember_connected::value ? CALL_IF_EXISTS(bool, static_cast(this), connected) : static_cast(this)->operator bool(); } + void flushTX() { CALL_IF_EXISTS(void, static_cast(this), flushTX); } void setHook(WriteHook writeHook = 0, EndOfMessageHook eofHook = 0, void * userPointer = 0) { // Order is important here as serial code can be called inside interrupts diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index 3fb0cfc358..a663ee571d 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -47,11 +47,11 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Extrapolate ["); if (x < 10) DEBUG_CHAR(' '); - DEBUG_ECHO((int)x); + DEBUG_ECHO(x); DEBUG_CHAR(xdir ? (xdir > 0 ? '+' : '-') : ' '); DEBUG_CHAR(' '); if (y < 10) DEBUG_CHAR(' '); - DEBUG_ECHO((int)y); + DEBUG_ECHO(y); DEBUG_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' '); DEBUG_ECHOLNPGM("]"); } diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index e142b31a78..2ad4ffecaf 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -160,7 +160,7 @@ void reset_bed_level() { #ifndef SCAD_MESH_OUTPUT LOOP_L_N(x, sx) { serial_spaces(precision + (x < 10 ? 3 : 2)); - SERIAL_ECHO(int(x)); + SERIAL_ECHO(x); } SERIAL_EOL(); #endif @@ -172,7 +172,7 @@ void reset_bed_level() { SERIAL_ECHOPGM(" ["); // open sub-array #else if (y < 10) SERIAL_CHAR(' '); - SERIAL_ECHO(int(y)); + SERIAL_ECHO(y); #endif LOOP_L_N(x, sx) { SERIAL_CHAR(' '); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 513d9a9121..ef3289f732 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -50,7 +50,7 @@ GRID_LOOP(x, y) if (!isnan(z_values[x][y])) { SERIAL_ECHO_START(); - SERIAL_ECHOPAIR(" M421 I", int(x), " J", int(y)); + SERIAL_ECHOPAIR(" M421 I", x, " J", y); SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4); serial_delay(75); // Prevent Printrun from exploding } @@ -150,7 +150,7 @@ SERIAL_ECHO_SP(7); LOOP_L_N(i, GRID_MAX_POINTS_X) { if (i < 10) SERIAL_CHAR(' '); - SERIAL_ECHO((int)i); + SERIAL_ECHO(i); SERIAL_ECHO_SP(sp); } serial_delay(10); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 41d2a36359..36acc96d6e 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -742,7 +742,7 @@ if (do_ubl_mesh_map) display_map(g29_map_type); const int point_num = (GRID_MAX_POINTS) - count + 1; - SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", int(GRID_MAX_POINTS), "."); + SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, "."); TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS))); #if HAS_LCD_MENU @@ -1694,7 +1694,7 @@ SERIAL_EOL(); #if HAS_KILL - SERIAL_ECHOLNPAIR("Kill pin on :", int(KILL_PIN), " state:", int(kill_state())); + SERIAL_ECHOLNPAIR("Kill pin on :", KILL_PIN, " state:", kill_state()); #endif SERIAL_EOL(); @@ -1707,8 +1707,8 @@ SERIAL_ECHOLNPAIR("Meshes go from ", hex_address((void*)settings.meshes_start_index()), " to ", hex_address((void*)settings.meshes_end_index())); serial_delay(50); - SERIAL_ECHOLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl)); SERIAL_EOL(); - SERIAL_ECHOLNPAIR("z_value[][] size: ", (int)sizeof(z_values)); SERIAL_EOL(); + SERIAL_ECHOLNPAIR("sizeof(ubl) : ", sizeof(ubl)); SERIAL_EOL(); + SERIAL_ECHOLNPAIR("z_value[][] size: ", sizeof(z_values)); SERIAL_EOL(); serial_delay(25); SERIAL_ECHOLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.meshes_end_index() - settings.meshes_start_index()))); diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index a70a0a4a27..d092b7152f 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -404,7 +404,7 @@ public: if (packet_retries < MAX_RETRIES || MAX_RETRIES == 0) { packet_retries++; stream_state = StreamState::PACKET_RESET; - SERIAL_ECHO_MSG("Resend request ", int(packet_retries)); + SERIAL_ECHO_MSG("Resend request ", packet_retries); SERIAL_ECHOLNPAIR("rs", sync); } else diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 48eaf9efc4..7fccc52d05 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -64,7 +64,7 @@ void BLTouch::init(const bool set_voltage/*=false*/) { #else if (DEBUGGING(LEVELING)) { - DEBUG_ECHOLNPAIR("last_written_mode - ", (int)last_written_mode); + DEBUG_ECHOLNPAIR("last_written_mode - ", last_written_mode); DEBUG_ECHOLNPGM("config mode - " #if ENABLED(BLTOUCH_SET_5V_MODE) "BLTOUCH_SET_5V_MODE" @@ -175,7 +175,7 @@ bool BLTouch::status_proc() { _set_SW_mode(); // Incidentally, _set_SW_mode() will also RESET any active alarm const bool tr = triggered(); // If triggered in SW mode, the pin is up, it is STOWED - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch is ", (int)tr); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch is ", tr); if (tr) _stow(); else _deploy(); // Turn off SW mode, reset any trigger, honor pin state return !tr; @@ -187,7 +187,7 @@ void BLTouch::mode_conv_proc(const bool M5V) { * BLTOUCH V3.0: This will set the mode (twice) and sadly, a STOW is needed at the end, because of the deploy * BLTOUCH V3.1: This will set the mode and store it in the eeprom. The STOW is not needed but does not hurt */ - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch Set Mode - ", (int)M5V); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch Set Mode - ", M5V); _deploy(); if (M5V) _set_5V_mode(); else _set_OD_mode(); _mode_store(); diff --git a/Marlin/src/feature/cancel_object.cpp b/Marlin/src/feature/cancel_object.cpp index 3ffd10e970..e2e429ea10 100644 --- a/Marlin/src/feature/cancel_object.cpp +++ b/Marlin/src/feature/cancel_object.cpp @@ -66,9 +66,8 @@ void CancelObject::uncancel_object(const int8_t obj) { } void CancelObject::report() { - if (active_object >= 0) { - SERIAL_ECHO_MSG("Active Object: ", int(active_object)); - } + if (active_object >= 0) + SERIAL_ECHO_MSG("Active Object: ", active_object); if (canceled) { SERIAL_ECHO_START(); diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index af42165599..cf5ebfd012 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -49,7 +49,7 @@ void I2CPositionEncoder::init(const uint8_t address, const AxisEnum axis) { initialized++; - SERIAL_ECHOLNPAIR("Setting up encoder on ", axis_codes[encoderAxis], " axis, addr = ", address); + SERIAL_ECHOLNPAIR("Setting up encoder on ", AS_CHAR(axis_codes[encoderAxis]), " axis, addr = ", address); position = get_position(); } @@ -67,7 +67,7 @@ void I2CPositionEncoder::update() { /* if (trusted) { //commented out as part of the note below trusted = false; - SERIAL_ECHOLMPAIR("Fault detected on ", axis_codes[encoderAxis], " axis encoder. Disengaging error correction until module is trusted again."); + SERIAL_ECHOLNPAIR("Fault detected on ", AS_CHAR(axis_codes[encoderAxis]), " axis encoder. Disengaging error correction until module is trusted again."); } */ return; @@ -92,7 +92,7 @@ void I2CPositionEncoder::update() { if (millis() - lastErrorTime > I2CPE_TIME_TRUSTED) { trusted = true; - SERIAL_ECHOLNPAIR("Untrusted encoder module on ", axis_codes[encoderAxis], " axis has been fault-free for set duration, reinstating error correction."); + SERIAL_ECHOLNPAIR("Untrusted encoder module on ", AS_CHAR(axis_codes[encoderAxis]), " axis has been fault-free for set duration, reinstating error correction."); //the encoder likely lost its place when the error occured, so we'll reset and use the printer's //idea of where it the axis is to re-initialize @@ -193,7 +193,7 @@ void I2CPositionEncoder::update() { const millis_t ms = millis(); if (ELAPSED(ms, nextErrorCountTime)) { SERIAL_CHAR(axis_codes[encoderAxis]); - SERIAL_ECHOLNPAIR(" : LARGE ERR ", int(error), "; diffSum=", diffSum); + SERIAL_ECHOLNPAIR(" : LARGE ERR ", error, "; diffSum=", diffSum); errorCount++; nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS; } diff --git a/Marlin/src/feature/encoder_i2c.h b/Marlin/src/feature/encoder_i2c.h index 511e560ba0..e771130391 100644 --- a/Marlin/src/feature/encoder_i2c.h +++ b/Marlin/src/feature/encoder_i2c.h @@ -261,32 +261,32 @@ class I2CPositionEncodersMgr { static void report_error_count(const int8_t idx, const AxisEnum axis) { CHECK_IDX(); - SERIAL_ECHOLNPAIR("Error count on ", axis_codes[axis], " axis is ", encoders[idx].get_error_count()); + SERIAL_ECHOLNPAIR("Error count on ", AS_CHAR(axis_codes[axis]), " axis is ", encoders[idx].get_error_count()); } static void reset_error_count(const int8_t idx, const AxisEnum axis) { CHECK_IDX(); encoders[idx].set_error_count(0); - SERIAL_ECHOLNPAIR("Error count on ", axis_codes[axis], " axis has been reset."); + SERIAL_ECHOLNPAIR("Error count on ", AS_CHAR(axis_codes[axis]), " axis has been reset."); } static void enable_ec(const int8_t idx, const bool enabled, const AxisEnum axis) { CHECK_IDX(); encoders[idx].set_ec_enabled(enabled); - SERIAL_ECHOPAIR("Error correction on ", axis_codes[axis]); + SERIAL_ECHOPAIR("Error correction on ", AS_CHAR(axis_codes[axis])); SERIAL_ECHO_TERNARY(encoders[idx].get_ec_enabled(), " axis is ", "en", "dis", "abled.\n"); } static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) { CHECK_IDX(); encoders[idx].set_ec_threshold(newThreshold); - SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis set to ", newThreshold, "mm."); + SERIAL_ECHOLNPAIR("Error correct threshold for ", AS_CHAR(axis_codes[axis]), " axis set to ", newThreshold, "mm."); } static void get_ec_threshold(const int8_t idx, const AxisEnum axis) { CHECK_IDX(); const float threshold = encoders[idx].get_ec_threshold(); - SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis is ", threshold, "mm."); + SERIAL_ECHOLNPAIR("Error correct threshold for ", AS_CHAR(axis_codes[axis]), " axis is ", threshold, "mm."); } static int8_t idx_from_axis(const AxisEnum axis) { diff --git a/Marlin/src/feature/mixing.cpp b/Marlin/src/feature/mixing.cpp index b002e9808a..722020ba8a 100644 --- a/Marlin/src/feature/mixing.cpp +++ b/Marlin/src/feature/mixing.cpp @@ -135,11 +135,11 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*= cmax = _MAX(cmax, v); csum += v; } - //SERIAL_ECHOPAIR("Mixer::refresh_collector(", proportion, ", ", int(t), ") cmax=", cmax, " csum=", csum, " color"); + //SERIAL_ECHOPAIR("Mixer::refresh_collector(", proportion, ", ", t, ") cmax=", cmax, " csum=", csum, " color"); const float inv_prop = proportion / csum; MIXER_STEPPER_LOOP(i) { c[i] = color[t][i] * inv_prop; - //SERIAL_ECHOPAIR(" [", int(t), "][", int(i), "] = ", int(color[t][i]), " (", c[i], ") "); + //SERIAL_ECHOPAIR(" [", t, "][", i, "] = ", color[t][i], " (", c[i], ") "); } //SERIAL_EOL(); } diff --git a/Marlin/src/feature/mixing.h b/Marlin/src/feature/mixing.h index 7fe7062a7a..65d1f1bf95 100644 --- a/Marlin/src/feature/mixing.h +++ b/Marlin/src/feature/mixing.h @@ -139,9 +139,9 @@ class Mixer { #ifdef MIXER_NORMALIZER_DEBUG SERIAL_ECHOPGM("Mix [ "); - SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(mix[0]), int(mix[1]), int(mix[2]), int(mix[3]), int(mix[4]), int(mix[5])); + SERIAL_ECHOLIST_N(MIXING_STEPPERS, mix[0], mix[1], mix[2], mix[3], mix[4], mix[5]); SERIAL_ECHOPGM(" ] to Color [ "); - SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(tcolor[0]), int(tcolor[1]), int(tcolor[2]), int(tcolor[3]), int(tcolor[4]), int(tcolor[5])); + SERIAL_ECHOLIST_N(MIXING_STEPPERS, tcolor[0], tcolor[1], tcolor[2], tcolor[3], tcolor[4], tcolor[5]); SERIAL_ECHOLNPGM(" ]"); #endif } @@ -153,10 +153,10 @@ class Mixer { MIXER_STEPPER_LOOP(i) mix[i] = mixer_perc_t(100.0f * color[j][i] / ctot); #ifdef MIXER_NORMALIZER_DEBUG - SERIAL_ECHOPAIR("V-tool ", int(j), " [ "); - SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(color[j][0]), int(color[j][1]), int(color[j][2]), int(color[j][3]), int(color[j][4]), int(color[j][5])); + SERIAL_ECHOPAIR("V-tool ", j, " [ "); + SERIAL_ECHOLIST_N(MIXING_STEPPERS, color[j][0], color[j][1], color[j][2], color[j][3], color[j][4], color[j][5]); SERIAL_ECHOPGM(" ] to Mix [ "); - SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(mix[0]), int(mix[1]), int(mix[2]), int(mix[3]), int(mix[4]), int(mix[5])); + SERIAL_ECHOLIST_N(MIXING_STEPPERS, mix[0], mix[1], mix[2], mix[3], mix[4], mix[5]); SERIAL_ECHOLNPGM(" ]"); #endif } @@ -199,9 +199,9 @@ class Mixer { #ifdef MIXER_NORMALIZER_DEBUG SERIAL_ECHOPGM("Gradient [ "); - SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(gradient.color[0]), int(gradient.color[1]), int(gradient.color[2]), int(gradient.color[3]), int(gradient.color[4]), int(gradient.color[5])); + SERIAL_ECHOLIST_N(MIXING_STEPPERS, gradient.color[0], gradient.color[1], gradient.color[2], gradient.color[3], gradient.color[4], gradient.color[5]); SERIAL_ECHOPGM(" ] to Mix [ "); - SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(mix[0]), int(mix[1]), int(mix[2]), int(mix[3]), int(mix[4]), int(mix[5])); + SERIAL_ECHOLIST_N(MIXING_STEPPERS, mix[0], mix[1], mix[2], mix[3], mix[4], mix[5]); SERIAL_ECHOLNPGM(" ]"); #endif } diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 3bff73e956..1aa53ef5eb 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -514,7 +514,7 @@ static void mmu2_not_responding() { extruder = index; // filament change is finished active_extruder = 0; ENABLE_AXIS_E0(); - SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder)); + SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder); } ui.reset_status(); } @@ -601,7 +601,7 @@ static void mmu2_not_responding() { active_extruder = 0; ENABLE_AXIS_E0(); - SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder)); + SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder); ui.reset_status(); } @@ -696,7 +696,7 @@ static void mmu2_not_responding() { extruder = index; //filament change is finished active_extruder = 0; ENABLE_AXIS_E0(); - SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(extruder)); + SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder); ui.reset_status(); } diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 5ab4f2b146..012e6c6e50 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -130,7 +130,7 @@ fil_change_settings_t fc_settings[EXTRUDERS]; */ static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=PAUSE_MODE_SAME) { DEBUG_SECTION(est, "ensure_safe_temperature", true); - DEBUG_ECHOLNPAIR("... wait:", int(wait), " mode:", int(mode)); + DEBUG_ECHOLNPAIR("... wait:", wait, " mode:", mode); #if ENABLED(PREVENT_COLD_EXTRUSION) if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) @@ -176,7 +176,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l DXC_ARGS ) { DEBUG_SECTION(lf, "load_filament", true); - DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", int(max_beep_count), " showlcd:", int(show_lcd), " pauseforuser:", int(pause_for_user), " pausemode:", int(mode) DXC_SAY); + DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", max_beep_count, " showlcd:", show_lcd, " pauseforuser:", pause_for_user, " pausemode:", mode DXC_SAY); if (!ensure_safe_temperature(false, mode)) { if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_STATUS, mode); @@ -309,7 +309,7 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/, #endif ) { DEBUG_SECTION(uf, "unload_filament", true); - DEBUG_ECHOLNPAIR("... unloadlen:", unload_length, " showlcd:", int(show_lcd), " mode:", int(mode) + DEBUG_ECHOLNPAIR("... unloadlen:", unload_length, " showlcd:", show_lcd, " mode:", mode #if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER) , " mixmult:", mix_multiplier #endif @@ -373,7 +373,7 @@ uint8_t did_pause_print = 0; bool pause_print(const float &retract, const xyz_pos_t &park_point, const float &unload_length/*=0*/, const bool show_lcd/*=false*/ DXC_ARGS) { DEBUG_SECTION(pp, "pause_print", true); - DEBUG_ECHOLNPAIR("... park.x:", park_point.x, " y:", park_point.y, " z:", park_point.z, " unloadlen:", unload_length, " showlcd:", int(show_lcd) DXC_SAY); + DEBUG_ECHOLNPAIR("... park.x:", park_point.x, " y:", park_point.y, " z:", park_point.z, " unloadlen:", unload_length, " showlcd:", show_lcd DXC_SAY); UNUSED(show_lcd); @@ -456,7 +456,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float void show_continue_prompt(const bool is_reload) { DEBUG_SECTION(scp, "pause_print", true); - DEBUG_ECHOLNPAIR("... is_reload:", int(is_reload)); + DEBUG_ECHOLNPAIR("... is_reload:", is_reload); ui.pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING); SERIAL_ECHO_START(); @@ -465,7 +465,7 @@ void show_continue_prompt(const bool is_reload) { void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep_count/*=0*/ DXC_ARGS) { DEBUG_SECTION(wfc, "wait_for_confirmation", true); - DEBUG_ECHOLNPAIR("... is_reload:", is_reload, " maxbeep:", int(max_beep_count) DXC_SAY); + DEBUG_ECHOLNPAIR("... is_reload:", is_reload, " maxbeep:", max_beep_count DXC_SAY); bool nozzle_timed_out = false; @@ -561,7 +561,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep */ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/, int16_t targetTemp/*=0*/ DXC_ARGS) { DEBUG_SECTION(rp, "resume_print", true); - DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", int(max_beep_count), " targetTemp:", targetTemp DXC_SAY); + DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", max_beep_count, " targetTemp:", targetTemp DXC_SAY); /* SERIAL_ECHOLNPAIR( diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index be35ff8511..46b94dbc11 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -532,7 +532,7 @@ void PrintJobRecovery::resume() { void PrintJobRecovery::debug(PGM_P const prefix) { DEBUG_PRINT_P(prefix); - DEBUG_ECHOLNPAIR(" Job Recovery Info...\nvalid_head:", int(info.valid_head), " valid_foot:", int(info.valid_foot)); + DEBUG_ECHOLNPAIR(" Job Recovery Info...\nvalid_head:", info.valid_head, " valid_foot:", info.valid_foot); if (info.valid_head) { if (info.valid_head == info.valid_foot) { DEBUG_ECHOPGM("current_position: "); @@ -565,7 +565,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOLNPAIR("feedrate: ", info.feedrate); #if HAS_MULTI_EXTRUDER - DEBUG_ECHOLNPAIR("active_extruder: ", int(info.active_extruder)); + DEBUG_ECHOLNPAIR("active_extruder: ", info.active_extruder); #endif #if HAS_HOTEND @@ -584,14 +584,14 @@ void PrintJobRecovery::resume() { #if HAS_FAN DEBUG_ECHOPGM("fan_speed: "); FANS_LOOP(i) { - DEBUG_ECHO(int(info.fan_speed[i])); + DEBUG_ECHO(info.fan_speed[i]); if (i < FAN_COUNT - 1) DEBUG_CHAR(','); } DEBUG_EOL(); #endif #if HAS_LEVELING - DEBUG_ECHOLNPAIR("leveling: ", int(info.flag.leveling), " fade: ", info.fade); + DEBUG_ECHOLNPAIR("leveling: ", info.flag.leveling, " fade: ", info.fade); #endif #if ENABLED(FWRETRACT) DEBUG_ECHOPGM("retract: "); @@ -605,8 +605,8 @@ void PrintJobRecovery::resume() { DEBUG_ECHOLNPAIR("sd_filename: ", info.sd_filename); DEBUG_ECHOLNPAIR("sdpos: ", info.sdpos); DEBUG_ECHOLNPAIR("print_job_elapsed: ", info.print_job_elapsed); - DEBUG_ECHOLNPAIR("dryrun: ", int(info.flag.dryrun)); - DEBUG_ECHOLNPAIR("allow_cold_extrusion: ", int(info.flag.allow_cold_extrusion)); + DEBUG_ECHOLNPAIR("dryrun: ", info.flag.dryrun); + DEBUG_ECHOLNPAIR("allow_cold_extrusion: ", info.flag.allow_cold_extrusion); } else DEBUG_ECHOLNPGM("INVALID DATA"); diff --git a/Marlin/src/feature/repeat.cpp b/Marlin/src/feature/repeat.cpp index d48157a84d..11e4dd6a93 100644 --- a/Marlin/src/feature/repeat.cpp +++ b/Marlin/src/feature/repeat.cpp @@ -43,7 +43,7 @@ void Repeat::add_marker(const uint32_t sdpos, const uint16_t count) { marker[index].sdpos = sdpos; marker[index].counter = count ?: -1; index++; - DEBUG_ECHOLNPAIR("Add Marker ", int(index), " at ", sdpos, " (", count, ")"); + DEBUG_ECHOLNPAIR("Add Marker ", index, " at ", sdpos, " (", count, ")"); } } @@ -53,14 +53,14 @@ void Repeat::loop() { else { const uint8_t ind = index - 1; // Active marker's index if (!marker[ind].counter) { // Did its counter run out? - DEBUG_ECHOLNPAIR("Pass Marker ", int(index)); + DEBUG_ECHOLNPAIR("Pass Marker ", index); index--; // Carry on. Previous marker on the next 'M808'. } else { card.setIndex(marker[ind].sdpos); // Loop back to the marker. if (marker[ind].counter > 0) // Ignore a negative (or zero) counter. --marker[ind].counter; // Decrement the counter. If zero this 'M808' will be skipped next time. - DEBUG_ECHOLNPAIR("Goto Marker ", int(index), " at ", marker[ind].sdpos, " (", marker[ind].counter, ")"); + DEBUG_ECHOLNPAIR("Goto Marker ", index, " at ", marker[ind].sdpos, " (", marker[ind].counter, ")"); } } } diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 5a79aaac7b..9e3cad34f2 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -537,7 +537,7 @@ void GcodeSuite::G26() { if (bedtemp) { if (!WITHIN(bedtemp, 40, BED_MAX_TARGET)) { - SERIAL_ECHOLNPAIR("?Specified bed temperature not plausible (40-", int(BED_MAX_TARGET), "C)."); + SERIAL_ECHOLNPAIR("?Specified bed temperature not plausible (40-", BED_MAX_TARGET, "C)."); return; } g26_bed_temp = bedtemp; diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 46f75f2590..5195ff87c0 100755 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -104,7 +104,7 @@ void GcodeSuite::G35() { const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { - SERIAL_ECHOPAIR("G35 failed at point ", int(i), " ("); + SERIAL_ECHOPAIR("G35 failed at point ", i, " ("); SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i])); SERIAL_CHAR(')'); SERIAL_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y); @@ -113,7 +113,7 @@ void GcodeSuite::G35() { } if (DEBUGGING(LEVELING)) { - DEBUG_ECHOPAIR("Probing point ", int(i), " ("); + DEBUG_ECHOPAIR("Probing point ", i, " ("); DEBUG_PRINT_P((char *)pgm_read_ptr(&tramming_point_name[i])); DEBUG_CHAR(')'); DEBUG_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y, SP_Z_STR, z_probed_height); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 2e80f090a4..b1e9fcedaa 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -637,7 +637,7 @@ G29_TYPE GcodeSuite::G29() { // Avoid probing outside the round or hexagonal area if (TERN0(IS_KINEMATIC, !probe.can_reach(probePos))) continue; - if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", abl_points, "."); + if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", pt_index, "/", abl_points, "."); TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(abl_points))); measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level); @@ -682,7 +682,7 @@ G29_TYPE GcodeSuite::G29() { // Probe at 3 arbitrary points LOOP_L_N(i, 3) { - if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", int(i + 1), "/3."); + if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", i + 1, "/3."); TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i + 1))); // Retain the last probe position diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index a08e4a0867..c16338a692 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -142,7 +142,7 @@ void GcodeSuite::G29() { if (parser.seenval('I')) { ix = parser.value_int(); if (!WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) { - SERIAL_ECHOLNPAIR("I out of range (0-", int(GRID_MAX_POINTS_X - 1), ")"); + SERIAL_ECHOLNPAIR("I out of range (0-", GRID_MAX_POINTS_X - 1, ")"); return; } } @@ -152,7 +152,7 @@ void GcodeSuite::G29() { if (parser.seenval('J')) { iy = parser.value_int(); if (!WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1)) { - SERIAL_ECHOLNPAIR("J out of range (0-", int(GRID_MAX_POINTS_Y - 1), ")"); + SERIAL_ECHOLNPAIR("J out of range (0-", GRID_MAX_POINTS_Y - 1, ")"); return; } } @@ -181,7 +181,7 @@ void GcodeSuite::G29() { } // switch(state) if (state == MeshNext) - SERIAL_ECHOLNPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS), " of ", int(GRID_MAX_POINTS)); + SERIAL_ECHOLNPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS), " of ", GRID_MAX_POINTS); report_current_position(); } diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 0bcf954faf..50476e8e7c 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -238,7 +238,7 @@ void GcodeSuite::G34() { // the next iteration of probing. This allows adjustments to be made away from the bed. z_measured[iprobe] = z_probed_height + Z_CLEARANCE_BETWEEN_PROBES; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(iprobe + 1), " measured position is ", z_measured[iprobe]); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", iprobe + 1, " measured position is ", z_measured[iprobe]); // Remember the minimum measurement to calculate the correction later on z_measured_min = _MIN(z_measured_min, z_measured[iprobe]); @@ -267,7 +267,7 @@ void GcodeSuite::G34() { linear_fit_data lfd; incremental_LSF_reset(&lfd); LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { - SERIAL_ECHOLNPAIR("PROBEPT_", int(i), ": ", z_measured[i]); + SERIAL_ECHOLNPAIR("PROBEPT_", i, ": ", z_measured[i]); incremental_LSF(&lfd, z_stepper_align.xy[i], z_measured[i]); } finish_incremental_LSF(&lfd); @@ -357,8 +357,8 @@ void GcodeSuite::G34() { // Check for less accuracy compared to last move if (decreasing_accuracy(last_z_align_move[zstepper], z_align_abs)) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " last_z_align_move = ", last_z_align_move[zstepper]); - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " z_align_abs = ", z_align_abs); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", zstepper + 1, " last_z_align_move = ", last_z_align_move[zstepper]); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", zstepper + 1, " z_align_abs = ", z_align_abs); adjustment_reverse = !adjustment_reverse; } @@ -370,7 +370,7 @@ void GcodeSuite::G34() { // Stop early if all measured points achieve accuracy target if (z_align_abs > z_auto_align_accuracy) success_break = false; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " corrected by ", z_align_move); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", zstepper + 1, " corrected by ", z_align_move); // Lock all steppers except one stepper.set_all_z_lock(true, zstepper); @@ -380,7 +380,7 @@ void GcodeSuite::G34() { // Will match reversed Z steppers on dual steppers. Triple will need more work to map. if (adjustment_reverse) { z_align_move = -z_align_move; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " correction reversed to ", z_align_move); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", zstepper + 1, " correction reversed to ", z_align_move); } #endif @@ -406,7 +406,7 @@ void GcodeSuite::G34() { if (err_break) SERIAL_ECHOLNPGM("G34 aborted."); else { - SERIAL_ECHOLNPAIR("Did ", int(iteration + (iteration != z_auto_align_iterations)), " of ", int(z_auto_align_iterations)); + SERIAL_ECHOLNPAIR("Did ", iteration + (iteration != z_auto_align_iterations), " of ", z_auto_align_iterations); SERIAL_ECHOLNPAIR_F("Accuracy: ", z_maxdiff); } @@ -467,10 +467,10 @@ void GcodeSuite::M422() { if (!parser.seen_any()) { LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) - SERIAL_ECHOLNPAIR_P(PSTR("M422 S"), int(i + 1), SP_X_STR, z_stepper_align.xy[i].x, SP_Y_STR, z_stepper_align.xy[i].y); + SERIAL_ECHOLNPAIR_P(PSTR("M422 S"), i + 1, SP_X_STR, z_stepper_align.xy[i].x, SP_Y_STR, z_stepper_align.xy[i].y); #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) - SERIAL_ECHOLNPAIR_P(PSTR("M422 W"), int(i + 1), SP_X_STR, z_stepper_align.stepper_xy[i].x, SP_Y_STR, z_stepper_align.stepper_xy[i].y); + SERIAL_ECHOLNPAIR_P(PSTR("M422 W"), i + 1, SP_X_STR, z_stepper_align.stepper_xy[i].x, SP_Y_STR, z_stepper_align.stepper_xy[i].y); #endif return; } diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 9510da7740..0918bc9d4f 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -375,7 +375,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { inline void report_measured_positional_error(const measurements_t &m) { SERIAL_CHAR('T'); - SERIAL_ECHO(int(active_extruder)); + SERIAL_ECHO(active_extruder); SERIAL_ECHOLNPGM(" Positional Error:"); #if HAS_X_CENTER SERIAL_ECHOLNPAIR_P(SP_X_STR, m.pos_error.x); @@ -408,7 +408,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { // inline void report_hotend_offsets() { LOOP_S_L_N(e, 1, HOTENDS) - SERIAL_ECHOLNPAIR_P(PSTR("T"), int(e), PSTR(" Hotend Offset X"), hotend_offset[e].x, SP_Y_STR, hotend_offset[e].y, SP_Z_STR, hotend_offset[e].z); + SERIAL_ECHOLNPAIR_P(PSTR("T"), e, PSTR(" Hotend Offset X"), hotend_offset[e].x, SP_Y_STR, hotend_offset[e].y, SP_Z_STR, hotend_offset[e].z); } #endif diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 97aea59221..63d2370697 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -240,8 +240,8 @@ void GcodeSuite::M48() { sigma = SQRT(dev_sum / (n + 1)); if (verbose_level > 1) { - SERIAL_ECHO((int)(n + 1)); - SERIAL_ECHOPAIR(" of ", (int)n_samples); + SERIAL_ECHO(n + 1); + SERIAL_ECHOPAIR(" of ", n_samples); SERIAL_ECHOPAIR_F(": z: ", pz, 3); SERIAL_CHAR(' '); dev_report(verbose_level > 2, mean, sigma, min, max); diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index f2fefb5756..ebe1dbc03c 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -47,7 +47,7 @@ void M217_report(const bool eeprom=false) { " G", toolchange_settings.fan_time); #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) - SERIAL_ECHOPAIR(" A", int(migration.automode)); + SERIAL_ECHOPAIR(" A", migration.automode); SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last)); #endif diff --git a/Marlin/src/gcode/config/M305.cpp b/Marlin/src/gcode/config/M305.cpp index 9771ac2ced..10ef55c173 100644 --- a/Marlin/src/gcode/config/M305.cpp +++ b/Marlin/src/gcode/config/M305.cpp @@ -50,7 +50,7 @@ void GcodeSuite::M305() { // A valid P index is required if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0)) - SERIAL_ECHO_MSG("!Invalid index. (0 <= P <= ", int(USER_THERMISTORS - 1), ")"); + SERIAL_ECHO_MSG("!Invalid index. (0 <= P <= ", USER_THERMISTORS - 1, ")"); else if (do_set) { if (parser.seen('R')) // Pullup resistor value if (!thermalManager.set_pull_up_res(t_index, parser.value_float())) diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 005fdf0f31..42a74fb54f 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -131,7 +131,7 @@ inline void servo_probe_test() { const uint8_t probe_index = parser.byteval('P', Z_PROBE_SERVO_NR); SERIAL_ECHOLNPAIR("Servo probe test\n" - ". using index: ", int(probe_index), + ". using index: ", probe_index, ", deploy angle: ", servo_angles[probe_index][0], ", stow angle: ", servo_angles[probe_index][1] ); @@ -143,7 +143,7 @@ inline void servo_probe_test() { #define PROBE_TEST_PIN Z_MIN_PIN constexpr bool probe_inverting = Z_MIN_ENDSTOP_INVERTING; - SERIAL_ECHOLNPAIR(". Probe Z_MIN_PIN: ", int(PROBE_TEST_PIN)); + SERIAL_ECHOLNPAIR(". Probe Z_MIN_PIN: ", PROBE_TEST_PIN); SERIAL_ECHOPGM(". Z_MIN_ENDSTOP_INVERTING: "); #else @@ -151,7 +151,7 @@ inline void servo_probe_test() { #define PROBE_TEST_PIN Z_MIN_PROBE_PIN constexpr bool probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING; - SERIAL_ECHOLNPAIR(". Probe Z_MIN_PROBE_PIN: ", int(PROBE_TEST_PIN)); + SERIAL_ECHOLNPAIR(". Probe Z_MIN_PROBE_PIN: ", PROBE_TEST_PIN); SERIAL_ECHOPGM( ". Z_MIN_PROBE_ENDSTOP_INVERTING: "); #endif diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index 0a7d52b633..bdb95db8d6 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -37,7 +37,7 @@ void report_M92(const bool echo=true, const int8_t e=-1) { LOOP_L_N(i, E_STEPPERS) { if (e >= 0 && i != e) continue; if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' '); - SERIAL_ECHOLNPAIR_P(PSTR(" M92 T"), (int)i, + SERIAL_ECHOLNPAIR_P(PSTR(" M92 T"), i, SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)])); } #endif diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 0d7a9f431b..3d13cb1c24 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -122,26 +122,26 @@ case DXC_DUPLICATION_MODE: DEBUG_ECHOPGM("DUPLICATION"); break; case DXC_MIRRORED_MODE: DEBUG_ECHOPGM("MIRRORED"); break; } - DEBUG_ECHOPAIR("\nActive Ext: ", int(active_extruder)); + DEBUG_ECHOPAIR("\nActive Ext: ", active_extruder); if (!active_extruder_parked) DEBUG_ECHOPGM(" NOT "); DEBUG_ECHOPGM(" parked."); DEBUG_ECHOPAIR("\nactive_extruder_x_pos: ", current_position.x); DEBUG_ECHOPAIR("\ninactive_extruder_x: ", inactive_extruder_x); - DEBUG_ECHOPAIR("\nextruder_duplication_enabled: ", int(extruder_duplication_enabled)); + DEBUG_ECHOPAIR("\nextruder_duplication_enabled: ", extruder_duplication_enabled); DEBUG_ECHOPAIR("\nduplicate_extruder_x_offset: ", duplicate_extruder_x_offset); DEBUG_ECHOPAIR("\nduplicate_extruder_temp_offset: ", duplicate_extruder_temp_offset); DEBUG_ECHOPAIR("\ndelayed_move_time: ", delayed_move_time); - DEBUG_ECHOPAIR("\nX1 Home X: ", x_home_pos(0), "\nX1_MIN_POS=", int(X1_MIN_POS), "\nX1_MAX_POS=", int(X1_MAX_POS)); - DEBUG_ECHOPAIR("\nX2 Home X: ", x_home_pos(1), "\nX2_MIN_POS=", int(X2_MIN_POS), "\nX2_MAX_POS=", int(X2_MAX_POS)); - DEBUG_ECHOPAIR("\nX2_HOME_DIR=", int(X2_HOME_DIR), "\nX2_HOME_POS=", int(X2_HOME_POS)); + DEBUG_ECHOPAIR("\nX1 Home X: ", x_home_pos(0), "\nX1_MIN_POS=", X1_MIN_POS, "\nX1_MAX_POS=", X1_MAX_POS); + DEBUG_ECHOPAIR("\nX2 Home X: ", x_home_pos(1), "\nX2_MIN_POS=", X2_MIN_POS, "\nX2_MAX_POS=", X2_MAX_POS); + DEBUG_ECHOPAIR("\nX2_HOME_DIR=", X2_HOME_DIR, "\nX2_HOME_POS=", X2_HOME_POS); DEBUG_ECHOPAIR("\nDEFAULT_DUAL_X_CARRIAGE_MODE=", STRINGIFY(DEFAULT_DUAL_X_CARRIAGE_MODE)); DEBUG_ECHOPAIR("\toolchange_settings.z_raise=", toolchange_settings.z_raise); - DEBUG_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", int(DEFAULT_DUPLICATION_X_OFFSET)); + DEBUG_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", DEFAULT_DUPLICATION_X_OFFSET); DEBUG_EOL(); HOTEND_LOOP() { - DEBUG_ECHOPAIR_P(SP_T_STR, int(e)); - LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", int(e), "].", XYZ_CHAR(a) | 0x20, "=", hotend_offset[e][a]); + DEBUG_ECHOPAIR_P(SP_T_STR, e); + LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", e, "].", XYZ_CHAR(a) | 0x20, "=", hotend_offset[e][a]); DEBUG_EOL(); } DEBUG_EOL(); diff --git a/Marlin/src/gcode/eeprom/M500-M504.cpp b/Marlin/src/gcode/eeprom/M500-M504.cpp index 26c50a6129..cd7833c701 100644 --- a/Marlin/src/gcode/eeprom/M500-M504.cpp +++ b/Marlin/src/gcode/eeprom/M500-M504.cpp @@ -75,7 +75,7 @@ void GcodeSuite::M502() { if (dowrite) { val = parser.byteval('V'); persistentStore.write_data(addr, &val); - SERIAL_ECHOLNPAIR("Wrote address ", addr, " with ", int(val)); + SERIAL_ECHOLNPAIR("Wrote address ", addr, " with ", val); } else { if (parser.seenval('T')) { @@ -90,7 +90,7 @@ void GcodeSuite::M502() { } else { persistentStore.read_data(addr, &val); - SERIAL_ECHOLNPAIR("Read address ", addr, " and got ", int(val)); + SERIAL_ECHOLNPAIR("Read address ", addr, " and got ", val); } } return; diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 3c2c27b62a..1d76ebf7d5 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -115,12 +115,12 @@ void GcodeSuite::M900() { #if ENABLED(EXTRA_LIN_ADVANCE_K) #if EXTRUDERS < 2 - SERIAL_ECHOLNPAIR("Advance S", int(new_slot), " K", kref, "(S", int(!new_slot), " K", lref, ")"); + SERIAL_ECHOLNPAIR("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")"); #else LOOP_L_N(i, EXTRUDERS) { const bool slot = TEST(lin_adv_slot, i); - SERIAL_ECHOLNPAIR("Advance T", int(i), " S", int(slot), " K", planner.extruder_advance_K[i], - "(S", int(!slot), " K", other_extruder_advance_K[i], ")"); + SERIAL_ECHOLNPAIR("Advance T", i, " S", slot, " K", planner.extruder_advance_K[i], + "(S", !slot, " K", other_extruder_advance_K[i], ")"); SERIAL_EOL(); } #endif diff --git a/Marlin/src/gcode/feature/leds/M7219.cpp b/Marlin/src/gcode/feature/leds/M7219.cpp index a6ee71174b..40d3554dfe 100644 --- a/Marlin/src/gcode/feature/leds/M7219.cpp +++ b/Marlin/src/gcode/feature/leds/M7219.cpp @@ -82,7 +82,7 @@ void GcodeSuite::M7219() { LOOP_L_N(r, MAX7219_LINES) { SERIAL_ECHOPGM("led_line["); if (r < 10) SERIAL_CHAR(' '); - SERIAL_ECHO(int(r)); + SERIAL_ECHO(r); SERIAL_ECHOPGM("]="); for (uint8_t b = 8; b--;) SERIAL_CHAR('0' + TEST(max7219.led_line[r], b)); SERIAL_EOL(); diff --git a/Marlin/src/gcode/feature/mixing/M166.cpp b/Marlin/src/gcode/feature/mixing/M166.cpp index 9e071a47ec..3f2b8b79e8 100644 --- a/Marlin/src/gcode/feature/mixing/M166.cpp +++ b/Marlin/src/gcode/feature/mixing/M166.cpp @@ -30,7 +30,7 @@ #include "../../../feature/mixing.h" inline void echo_mix() { - SERIAL_ECHOPAIR(" (", int(mixer.mix[0]), "%|", int(mixer.mix[1]), "%)"); + SERIAL_ECHOPAIR(" (", mixer.mix[0], "%|", mixer.mix[1], "%)"); } inline void echo_zt(const int t, const float &z) { @@ -74,7 +74,7 @@ void GcodeSuite::M166() { #if ENABLED(GRADIENT_VTOOL) if (mixer.gradient.vtool_index >= 0) { - SERIAL_ECHOPAIR(" (T", int(mixer.gradient.vtool_index)); + SERIAL_ECHOPAIR(" (T", mixer.gradient.vtool_index); SERIAL_CHAR(')'); } #endif diff --git a/Marlin/src/gcode/feature/network/M552-M554.cpp b/Marlin/src/gcode/feature/network/M552-M554.cpp index 6ea15fefbf..22c718c042 100644 --- a/Marlin/src/gcode/feature/network/M552-M554.cpp +++ b/Marlin/src/gcode/feature/network/M552-M554.cpp @@ -48,7 +48,7 @@ void MAC_report() { SERIAL_ECHOPGM(" MAC: "); LOOP_L_N(i, 6) { if (mac[i] < 16) SERIAL_CHAR('0'); - SERIAL_PRINT(mac[i], HEX); + SERIAL_PRINT(mac[i], PrintBase::Hex); if (i < 5) SERIAL_CHAR(':'); } } diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index 5d89af0ab8..9d5dcc060a 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -49,7 +49,7 @@ void GcodeSuite::G61(void) { // No saved position? No axes being restored? if (!TEST(saved_slots[slot >> 3], slot & 0x07) || !parser.seen("XYZ")) return; - SERIAL_ECHOPAIR(STR_RESTORING_POS " S", int(slot)); + SERIAL_ECHOPAIR(STR_RESTORING_POS " S", slot); LOOP_XYZ(i) { destination[i] = parser.seen(XYZ_CHAR(i)) ? stored_position[slot][i] + parser.value_axis_units((AxisEnum)i) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index f9173188dc..77ac1fbff8 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -105,7 +105,7 @@ int8_t GcodeSuite::get_target_extruder_from_command() { if (e < EXTRUDERS) return e; SERIAL_ECHO_START(); SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum); - SERIAL_ECHOLNPAIR(" " STR_INVALID_EXTRUDER " ", int(e)); + SERIAL_ECHOLNPAIR(" " STR_INVALID_EXTRUDER " ", e); return -1; } return active_extruder; @@ -124,7 +124,7 @@ int8_t GcodeSuite::get_target_e_stepper_from_command() { if (e == -1) SERIAL_ECHOLNPGM(" " STR_E_STEPPER_NOT_SPECIFIED); else - SERIAL_ECHOLNPAIR(" " STR_INVALID_E_STEPPER " ", int(e)); + SERIAL_ECHOLNPAIR(" " STR_INVALID_E_STEPPER " ", e); return -1; } diff --git a/Marlin/src/gcode/host/M113.cpp b/Marlin/src/gcode/host/M113.cpp index 1183cc27a1..ddabcefb13 100644 --- a/Marlin/src/gcode/host/M113.cpp +++ b/Marlin/src/gcode/host/M113.cpp @@ -38,7 +38,7 @@ void GcodeSuite::M113() { NOMORE(host_keepalive_interval, 60); } else - SERIAL_ECHO_MSG("M113 S", (uint16_t)host_keepalive_interval); + SERIAL_ECHO_MSG("M113 S", host_keepalive_interval); } diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index f49a32cc61..b0bd4a3b8e 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -35,7 +35,7 @@ static void config_prefix(PGM_P const name, PGM_P const pref=nullptr, const int8_t ind=-1) { SERIAL_ECHOPGM("Config:"); if (pref) serialprintPGM(pref); - if (ind >= 0) { SERIAL_ECHO(int(ind)); SERIAL_CHAR(':'); } + if (ind >= 0) { SERIAL_ECHO(ind); SERIAL_CHAR(':'); } serialprintPGM(name); SERIAL_CHAR(':'); } diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index 8ff94a78fd..1cae8d11a2 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -97,7 +97,7 @@ void GcodeSuite::M290() { #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) { SERIAL_ECHOLNPAIR_P( - PSTR("Hotend "), int(active_extruder) + PSTR("Hotend "), active_extruder #if ENABLED(BABYSTEP_XY) , PSTR("Offset X"), hotend_offset[active_extruder].x , SP_Y_STR, hotend_offset[active_extruder].y diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index a513c4b596..6408b2ce2d 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -307,7 +307,7 @@ void GCodeParser::parse(char *p) { #if ENABLED(DEBUG_GCODE_PARSER) if (debug) { - SERIAL_ECHOPAIR("Got param ", param, " at index ", (int)(p - command_ptr - 1)); + SERIAL_ECHOPAIR("Got param ", param, " at index ", p - command_ptr - 1); if (has_val) SERIAL_ECHOPGM(" (has_val)"); } #endif @@ -391,8 +391,8 @@ void GCodeParser::unknown_command_warning() { "\n sec-ms: ", value_millis_from_seconds(), "\n int: ", value_int(), "\n ushort: ", value_ushort(), - "\n byte: ", (int)value_byte(), - "\n bool: ", (int)value_bool(), + "\n byte: ", value_byte(), + "\n bool: ", value_bool(), "\n linear: ", value_linear_units(), "\n celsius: ", value_celsius() ); diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index cf531c4e47..d60b21a906 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -133,9 +133,9 @@ public: param[ind] = ptr ? ptr - command_ptr : 0; // parameter offset or 0 #if ENABLED(DEBUG_GCODE_PARSER) if (codenum == 800) { - SERIAL_ECHOPAIR("Set bit ", (int)ind, " of codebits (", hex_address((void*)(codebits >> 16))); + SERIAL_ECHOPAIR("Set bit ", ind, " of codebits (", hex_address((void*)(codebits >> 16))); print_hex_word((uint16_t)(codebits & 0xFFFF)); - SERIAL_ECHOLNPAIR(") | param = ", (int)param[ind]); + SERIAL_ECHOLNPAIR(") | param = ", param[ind]); } #endif } diff --git a/Marlin/src/gcode/probe/M851.cpp b/Marlin/src/gcode/probe/M851.cpp index 04b293de31..ee6244932e 100644 --- a/Marlin/src/gcode/probe/M851.cpp +++ b/Marlin/src/gcode/probe/M851.cpp @@ -58,7 +58,7 @@ void GcodeSuite::M851() { if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE)) offs.x = x; else { - SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")"); + SERIAL_ECHOLNPAIR("?X out of range (-", X_BED_SIZE, " to ", X_BED_SIZE, ")"); ok = false; } #else @@ -72,7 +72,7 @@ void GcodeSuite::M851() { if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE)) offs.y = y; else { - SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")"); + SERIAL_ECHOLNPAIR("?Y out of range (-", Y_BED_SIZE, " to ", Y_BED_SIZE, ")"); ok = false; } #else @@ -85,7 +85,7 @@ void GcodeSuite::M851() { if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) offs.z = z; else { - SERIAL_ECHOLNPAIR("?Z out of range (", int(Z_PROBE_OFFSET_RANGE_MIN), " to ", int(Z_PROBE_OFFSET_RANGE_MAX), ")"); + SERIAL_ECHOLNPAIR("?Z out of range (", Z_PROBE_OFFSET_RANGE_MIN, " to ", Z_PROBE_OFFSET_RANGE_MAX, ")"); ok = false; } } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index d5bc857286..c483522cd7 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -302,8 +302,8 @@ void GCodeQueue::ok_to_send() { while (NUMERIC_SIGNED(*p)) SERIAL_CHAR(*p++); } - SERIAL_ECHOPAIR_P(SP_P_STR, int(planner.moves_free()), - SP_B_STR, int(BUFSIZE - length)); + SERIAL_ECHOPAIR_P(SP_P_STR, planner.moves_free(), + SP_B_STR, BUFSIZE - length); #endif SERIAL_EOL(); } diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 39f161f5ad..55554a98cf 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -1772,7 +1772,7 @@ void HMI_SDCardUpdate() { if (HMI_flag.home_flag) return; if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); - // SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", int(DWIN_lcd_sd_status)); + // SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", DWIN_lcd_sd_status); if (DWIN_lcd_sd_status) { if (checkkey == SelectFile) Redraw_SD_List(); 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 2b47094a4e..a990c4c640 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 @@ -141,7 +141,7 @@ void AnycubicTFTClass::OnKillTFT() { void AnycubicTFTClass::OnSDCardStateChange(bool isInserted) { #if ENABLED(ANYCUBIC_LCD_DEBUG) - SERIAL_ECHOLNPAIR("TFT Serial Debug: OnSDCardStateChange event triggered...", (int)isInserted); + SERIAL_ECHOLNPAIR("TFT Serial Debug: OnSDCardStateChange event triggered...", isInserted); #endif DoSDCardStateCheck(); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp index 62c66f16f2..77d870fd4c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp @@ -1083,7 +1083,7 @@ void CLCD::init() { if (counter == 249) { #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_MSG("Timeout waiting for device ID, should be 124, got ", int(device_id)); + SERIAL_ECHO_MSG("Timeout waiting for device ID, should be 124, got ", device_id); #endif } } @@ -1101,7 +1101,7 @@ void CLCD::init() { delay(1); if (ENABLED(TOUCH_UI_DEBUG) && counter == 99) - SERIAL_ECHO_MSG("Timeout waiting for reset status. Should be 0x00, got ", int(reset_status)); + SERIAL_ECHO_MSG("Timeout waiting for reset status. Should be 0x00, got ", reset_status); } mem_write_8(REG::PWM_DUTY, 0); // turn off Backlight, Frequency already is set to 250Hz default diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/event_loop.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/event_loop.cpp index 78d5f2483e..ac8f49a055 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/event_loop.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/event_loop.cpp @@ -124,7 +124,7 @@ namespace FTDI { case UNPRESSED: if (tag != 0) { #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_MSG("Touch start: ", int(tag)); + SERIAL_ECHO_MSG("Touch start: ", tag); #endif pressed_tag = tag; @@ -185,7 +185,7 @@ namespace FTDI { if (UIData::flags.bits.touch_end_sound) sound.play(unpress_sound); #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_MSG("Touch end: ", int(pressed_tag)); + SERIAL_ECHO_MSG("Touch end: ", pressed_tag); #endif const uint8_t saved_pressed_tag = pressed_tag; 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 d76b897e0f..4e318cef17 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 @@ -43,7 +43,7 @@ void ScreenRef::setScreen(onRedraw_func_t onRedraw_ptr) { if (type != 0xFF) { setType(type); #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_MSG("New screen: ", int(type)); + SERIAL_ECHO_MSG("New screen: ", type); #endif } } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp index 07d1ff5624..f48448eb84 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp @@ -37,9 +37,7 @@ namespace FTDI { void SoundPlayer::play(effect_t effect, note_t note) { #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOPAIR ("Playing note ", int(note)); - SERIAL_ECHOLNPAIR(", instrument ", int(effect)); + SERIAL_ECHO_MSG("Playing note ", note, ", instrument ", effect); #endif // Play the note diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index eaee08f43b..88566713a4 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -751,7 +751,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { // For Cartesian / Core motion simply move to the current_position planner.buffer_line(current_position, fr_mm_s, axis == E_AXIS ? e_index : active_extruder); - //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", int(axis), " at FR ", fr_mm_s); + //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", axis, " at FR ", fr_mm_s); axis = NO_AXIS; @@ -772,7 +772,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { #endif start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves axis = move_axis; - //SERIAL_ECHOLNPAIR("Post Move with Axis ", int(axis), " soon."); + //SERIAL_ECHOLNPAIR("Post Move with Axis ", axis, " soon."); } #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 7b95f435ba..179a2c2d55 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -216,7 +216,7 @@ void menu_advanced_settings(); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) void bltouch_report() { - SERIAL_ECHOLNPAIR("EEPROM Last BLTouch Mode - ", (int)bltouch.last_written_mode); + SERIAL_ECHOLNPAIR("EEPROM Last BLTouch Mode - ", bltouch.last_written_mode); SERIAL_ECHOLNPGM("Configuration BLTouch Mode - " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD")); char mess[21]; strcpy_P(mess, PSTR("BLTouch Mode - ")); diff --git a/Marlin/src/libs/bresenham.h b/Marlin/src/libs/bresenham.h index ade231e26d..6e4162fd13 100644 --- a/Marlin/src/libs/bresenham.h +++ b/Marlin/src/libs/bresenham.h @@ -120,7 +120,7 @@ public: static void report(const uint8_t index) { if (index < Cfg::SIZE) { - SERIAL_ECHOPAIR("bresenham ", int(index), " : (", dividend[index], "/", divisor, ") "); + SERIAL_ECHOPAIR("bresenham ", index, " : (", dividend[index], "/", divisor, ") "); if (counter[index] >= 0) SERIAL_CHAR(' '); if (labs(counter[index]) < 100) { SERIAL_CHAR(' '); if (labs(counter[index]) < 10) SERIAL_CHAR(' '); } SERIAL_ECHO(counter[index]); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index f7fc66b27a..8dc84c33d6 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1305,7 +1305,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t const feedRate_t home_fr_mm_s = fr_mm_s ?: homing_feedrate(axis); if (DEBUGGING(LEVELING)) { - DEBUG_ECHOPAIR("...(", axis_codes[axis], ", ", distance, ", "); + DEBUG_ECHOPAIR("...(", AS_CHAR(axis_codes[axis]), ", ", distance, ", "); if (fr_mm_s) DEBUG_ECHO(fr_mm_s); else @@ -1398,7 +1398,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t * Callers must sync the planner position after calling this! */ void set_axis_is_at_home(const AxisEnum axis) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", axis_codes[axis], ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")"); set_axis_trusted(axis); set_axis_homed(axis); @@ -1448,7 +1448,7 @@ void set_axis_is_at_home(const AxisEnum axis) { if (DEBUGGING(LEVELING)) { #if HAS_HOME_OFFSET - DEBUG_ECHOLNPAIR("> home_offset[", axis_codes[axis], "] = ", home_offset[axis]); + DEBUG_ECHOLNPAIR("> home_offset[", AS_CHAR(axis_codes[axis]), "] = ", home_offset[axis]); #endif DEBUG_POS("", current_position); DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", axis_codes[axis], ")"); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 94c409eb72..925538ef83 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -719,7 +719,7 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise DEBUG_ECHOLNPAIR( "...(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry), ", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none", - ", ", int(verbose_level), + ", ", verbose_level, ", ", probe_relative ? "probe" : "nozzle", "_relative)" ); DEBUG_POS("", current_position); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 089481d076..7fb378191e 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -2289,7 +2289,7 @@ void MarlinSettings::postprocess() { eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET)); if (eeprom_error) { DEBUG_ECHO_START(); - DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize()); + DEBUG_ECHOLNPAIR("Index: ", eeprom_index - (EEPROM_OFFSET), " Size: ", datasize()); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_index()); } else if (working_crc != stored_crc) { @@ -3039,7 +3039,7 @@ void MarlinSettings::reset() { } #if EXTRUDERS == 1 - CONFIG_ECHO_MSG(" M200 S", int(parser.volumetric_enabled) + CONFIG_ECHO_MSG(" M200 S", parser.volumetric_enabled , " D", LINEAR_UNIT(planner.filament_size[0]) #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[0]) @@ -3047,14 +3047,14 @@ void MarlinSettings::reset() { ); #else LOOP_L_N(i, EXTRUDERS) { - CONFIG_ECHO_MSG(" M200 T", int(i) + CONFIG_ECHO_MSG(" M200 T", i , " D", LINEAR_UNIT(planner.filament_size[i]) #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[i]) #endif ); } - CONFIG_ECHO_MSG(" M200 S", int(parser.volumetric_enabled)); + CONFIG_ECHO_MSG(" M200 S", parser.volumetric_enabled); #endif #endif // EXTRUDERS && !NO_VOLUMETRICS @@ -3076,7 +3076,7 @@ void MarlinSettings::reset() { LOOP_L_N(i, E_STEPPERS) { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( - PSTR(" M203 T"), (int)i + PSTR(" M203 T"), i , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)]) ); } @@ -3096,7 +3096,7 @@ void MarlinSettings::reset() { LOOP_L_N(i, E_STEPPERS) { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( - PSTR(" M201 T"), (int)i + PSTR(" M201 T"), i , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]) ); } @@ -3158,7 +3158,7 @@ void MarlinSettings::reset() { CONFIG_ECHO_START(); LOOP_S_L_N(e, 1, HOTENDS) { SERIAL_ECHOPAIR_P( - PSTR(" M218 T"), (int)e, + PSTR(" M218 T"), e, SP_X_STR, LINEAR_UNIT(hotend_offset[e].x), SP_Y_STR, LINEAR_UNIT(hotend_offset[e].y) ); @@ -3192,7 +3192,7 @@ void MarlinSettings::reset() { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( - PSTR(" M420 S"), int(planner.leveling_active) + PSTR(" M420 S"), planner.leveling_active #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) , SP_Z_STR, LINEAR_UNIT(planner.z_fade_height) #endif @@ -3204,7 +3204,7 @@ void MarlinSettings::reset() { LOOP_L_N(py, GRID_MAX_POINTS_Y) { LOOP_L_N(px, GRID_MAX_POINTS_X) { CONFIG_ECHO_START(); - SERIAL_ECHOPAIR_P(PSTR(" G29 S3 I"), (int)px, PSTR(" J"), (int)py); + SERIAL_ECHOPAIR_P(PSTR(" G29 S3 I"), px, PSTR(" J"), py); SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(mbl.z_values[px][py]), 5); } } @@ -3233,7 +3233,7 @@ void MarlinSettings::reset() { LOOP_L_N(py, GRID_MAX_POINTS_Y) { LOOP_L_N(px, GRID_MAX_POINTS_X) { CONFIG_ECHO_START(); - SERIAL_ECHOPAIR(" G29 W I", (int)px, " J", (int)py); + SERIAL_ECHOPAIR(" G29 W I", px, " J", py); SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(z_values[px][py]), 5); } } @@ -3258,7 +3258,7 @@ void MarlinSettings::reset() { #elif ENABLED(BLTOUCH) || (HAS_Z_SERVO_PROBE && defined(Z_SERVO_ANGLES)) case Z_PROBE_SERVO_NR: #endif - CONFIG_ECHO_MSG(" M281 P", int(i), " L", servo_angles[i][0], " U", servo_angles[i][1]); + CONFIG_ECHO_MSG(" M281 P", i, " L", servo_angles[i][0], " U", servo_angles[i][1]); default: break; } } @@ -3334,7 +3334,7 @@ void MarlinSettings::reset() { LOOP_L_N(i, PREHEAT_COUNT) { CONFIG_ECHO_START(); SERIAL_ECHOLNPAIR_P( - PSTR(" M145 S"), (int)i + PSTR(" M145 S"), i #if HAS_HOTEND , PSTR(" H"), TEMP_UNIT(ui.material_preset[i].hotend_temp) #endif @@ -3403,7 +3403,7 @@ void MarlinSettings::reset() { #if ENABLED(POWER_LOSS_RECOVERY) CONFIG_ECHO_HEADING("Power-Loss Recovery:"); - CONFIG_ECHO_MSG(" M413 S", int(recovery.enabled)); + CONFIG_ECHO_MSG(" M413 S", recovery.enabled); #endif #if ENABLED(FWRETRACT) @@ -3425,11 +3425,9 @@ void MarlinSettings::reset() { ); #if ENABLED(FWRETRACT_AUTORETRACT) - CONFIG_ECHO_HEADING("Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); - CONFIG_ECHO_MSG(" M209 S", int(fwretract.autoretract_enabled)); - - #endif // FWRETRACT_AUTORETRACT + CONFIG_ECHO_MSG(" M209 S", fwretract.autoretract_enabled); + #endif #endif // FWRETRACT @@ -3775,7 +3773,7 @@ void MarlinSettings::reset() { CONFIG_ECHO_MSG(" M900 K", planner.extruder_advance_K[0]); #else LOOP_L_N(i, EXTRUDERS) - CONFIG_ECHO_MSG(" M900 T", int(i), " K", planner.extruder_advance_K[i]); + CONFIG_ECHO_MSG(" M900 T", i, " K", planner.extruder_advance_K[i]); #endif #endif @@ -3841,7 +3839,7 @@ void MarlinSettings::reset() { #if HAS_FILAMENT_SENSOR CONFIG_ECHO_HEADING("Filament runout sensor:"); CONFIG_ECHO_MSG( - " M412 S", int(runout.enabled) + " M412 S", runout.enabled #if HAS_FILAMENT_RUNOUT_DISTANCE , " D", LINEAR_UNIT(runout.runout_distance()) #endif @@ -3859,7 +3857,7 @@ void MarlinSettings::reset() { #if HAS_MULTI_LANGUAGE CONFIG_ECHO_HEADING("UI Language:"); - SERIAL_ECHO_MSG(" M414 S", int(ui.language)); + SERIAL_ECHO_MSG(" M414 S", ui.language); #endif } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f66d60ab15..5a4ed16744 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -828,7 +828,7 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms serialprintPGM(serial_msg); SERIAL_ECHOPGM(STR_STOPPED_HEATER); if (heater_id >= 0) - SERIAL_ECHO((int)heater_id); + SERIAL_ECHO(heater_id); else if (TERN0(HAS_HEATED_CHAMBER, heater_id == H_CHAMBER)) SERIAL_ECHOPGM(STR_HEATER_CHAMBER); else @@ -1494,7 +1494,7 @@ void Temperature::manage_heater() { float Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) { if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) { SERIAL_ERROR_START(); - SERIAL_ECHO((int)e); + SERIAL_ECHO(e); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM); kill(); return 0; @@ -2065,7 +2065,7 @@ void Temperature::init() { switch (heater_id) { case H_BED: SERIAL_ECHOPGM("bed"); break; case H_CHAMBER: SERIAL_ECHOPGM("chamber"); break; - default: SERIAL_ECHO((int)heater_id); + default: SERIAL_ECHO(heater_id); } SERIAL_ECHOLNPAIR( " ; sizeof(running_temp):", sizeof(running_temp), diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 191617be30..0ed3d15b45 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -186,7 +186,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.x = mpe_settings.parking_xpos[new_tool] + offsetcompensation; - DEBUG_ECHOPAIR("(1) Move extruder ", int(new_tool)); + DEBUG_ECHOPAIR("(1) Move extruder ", new_tool); DEBUG_POS(" to new extruder ParkPos", current_position); planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool); @@ -196,7 +196,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.x = grabpos + offsetcompensation; - DEBUG_ECHOPAIR("(2) Couple extruder ", int(new_tool)); + DEBUG_ECHOPAIR("(2) Couple extruder ", new_tool); DEBUG_POS(" to new extruder GrabPos", current_position); planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool); @@ -209,7 +209,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.x = mpe_settings.parking_xpos[new_tool] + offsetcompensation; - DEBUG_ECHOPAIR("(3) Move extruder ", int(new_tool)); + DEBUG_ECHOPAIR("(3) Move extruder ", new_tool); DEBUG_POS(" back to new extruder ParkPos", current_position); planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool); @@ -219,7 +219,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.x = mpe_settings.parking_xpos[active_extruder] + (active_extruder == 0 ? MPE_TRAVEL_DISTANCE : -MPE_TRAVEL_DISTANCE) + offsetcompensation; - DEBUG_ECHOPAIR("(4) Move extruder ", int(new_tool)); + DEBUG_ECHOPAIR("(4) Move extruder ", new_tool); DEBUG_POS(" close to old extruder ParkPos", current_position); planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool); @@ -229,7 +229,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.x = mpe_settings.parking_xpos[active_extruder] + offsetcompensation; - DEBUG_ECHOPAIR("(5) Park extruder ", int(new_tool)); + DEBUG_ECHOPAIR("(5) Park extruder ", new_tool); DEBUG_POS(" at old extruder ParkPos", current_position); planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool); @@ -239,7 +239,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.x = oldx; - DEBUG_ECHOPAIR("(6) Move extruder ", int(new_tool)); + DEBUG_ECHOPAIR("(6) Move extruder ", new_tool); DEBUG_POS(" to starting position", current_position); planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool); @@ -274,9 +274,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a if (homed_towards_final_tool) { pe_solenoid_magnet_off(1 - final_tool); - DEBUG_ECHOLNPAIR("Disengage magnet", (int)(1 - final_tool)); + DEBUG_ECHOLNPAIR("Disengage magnet", 1 - final_tool); pe_solenoid_magnet_on(final_tool); - DEBUG_ECHOLNPAIR("Engage magnet", (int)final_tool); + DEBUG_ECHOLNPAIR("Engage magnet", final_tool); parking_extruder_set_parked(false); return false; } @@ -315,7 +315,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a if (!extruder_parked) { current_position.x = parkingposx[active_extruder] + x_offset; - DEBUG_ECHOLNPAIR("(1) Park extruder ", int(active_extruder)); + DEBUG_ECHOLNPAIR("(1) Park extruder ", active_extruder); DEBUG_POS("Moving ParkPos", current_position); fast_line_to_current(X_AXIS); @@ -411,7 +411,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.x = placexpos; - DEBUG_ECHOLNPAIR("(1) Place old tool ", int(active_extruder)); + DEBUG_ECHOLNPAIR("(1) Place old tool ", active_extruder); DEBUG_POS("Move X SwitchPos", current_position); fast_line_to_current(X_AXIS); @@ -509,7 +509,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR; - SERIAL_ECHOLNPAIR("(1) Place old tool ", int(active_extruder)); + SERIAL_ECHOLNPAIR("(1) Place old tool ", active_extruder); DEBUG_POS("Move Y SwitchPos + Security", current_position); fast_line_to_current(Y_AXIS); @@ -709,7 +709,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a #if EXTRUDERS inline void invalid_extruder_error(const uint8_t e) { SERIAL_ECHO_START(); - SERIAL_CHAR('T'); SERIAL_ECHO((int)e); + SERIAL_CHAR('T'); SERIAL_ECHO(e); SERIAL_CHAR(' '); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER); } #endif @@ -1196,7 +1196,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_AFTER_TOOLCHANGE)); #endif - SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, int(active_extruder)); + SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, active_extruder); #endif // HAS_MULTI_EXTRUDER } diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 7693c52330..3cd88318ff 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -926,7 +926,7 @@ int SdBaseFile::peek() { // print uint8_t with width 2 static void print2u(const uint8_t v) { if (v < 10) SERIAL_CHAR('0'); - SERIAL_ECHO((int)v); + SERIAL_ECHO(v); } /** diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index bda7f8aeba..fd26bdd671 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -583,7 +583,7 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0* // Too deep? The firmware has to bail. if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) { - SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:", int(SD_PROCEDURE_DEPTH)); + SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:", SD_PROCEDURE_DEPTH); kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW)); return; } diff --git a/docs/Serial.md b/docs/Serial.md index 69fa94fc15..948e07b448 100644 --- a/docs/Serial.md +++ b/docs/Serial.md @@ -40,5 +40,25 @@ typedef MultiSerial< RuntimeSerial, ConditionalSerial > Se By default, the serial base interface provide an emergency parser that's only enable for serial classes that support it. Because of this condition, all underlying type takes a first `bool emergencyParserEnabled` argument to their constructor. You must take into account this parameter when defining the actual type used. +## SERIAL macros +The following macros are defined (in `serial.h`) to output data to the serial ports: + +| MACRO | Parameters | Usage | Example | Expected output | +|-------|------------|-------|---------|-----------------| +| `SERIAL_ECHO` | Any basic type is supported (`char`, `uint8_t`, `int16_t`, `int32_t`, `float`, `long`, `const char*`, ...). | For a numeric type it prints the number in decimal. A string is output as a string. | `uint8_t a = 123; SERIAL_ECHO(a); SERIAL_CHAR(' '); SERIAL_ECHO(' '); ` | `123 32` | +| `SERIAL_ECHOLN` | Same as `SERIAL_ECHO` | Do `SERIAL_ECHO`, adding a newline | `int a = 456; SERIAL_ECHOLN(a);` | `456\n` | +| `SERIAL_ECHO_F` | `float` or `double` | Print a decimal value with a given precision (default 2) | `float a = 3.1415; SERIAL_ECHO_F(a); SERIAL_CHAR(' '); SERIAL_ECHO_F(a, 4);` | `3.14 3.1415`| +| `SERIAL_ECHOPAIR` | String / Value pairs | Print a series of string literals and values alternately | `SERIAL_ECHOPAIR("Bob", 34);` | `Bob34` | +| `SERIAL_ECHOLNPAIR` | Same as `SERIAL_ECHOPAIR` | Do `SERIAL_ECHOPAIR`, adding a newline | `SERIAL_ECHOPAIR("Alice", 56);` | `alice56` | +| `SERIAL_ECHOPAIR_P` | Like `SERIAL_ECHOPAIR` but takes PGM strings | Print a series of PGM strings and values alternately | `SERIAL_ECHOPAIR_P(GET_TEXT(MSG_HELLO), 123);` | `Hello123` | +| `SERIAL_ECHOLNPAIR_P` | Same as `SERIAL_ECHOPAIR_P` | Do `SERIAL_ECHOPAIR_P`, adding a newline | `SERIAL_ECHOLNPAIR_P(PSTR("Alice"), 78);` | `alice78\n` | +| `SERIAL_ECHOLIST` | String literal, values | Print a string literal and a list of values | `SERIAL_ECHOLIST("Key ", 1, 2, 3);` | `Key 1, 2, 3` | +| `SERIAL_ECHO_START` | None | Prefix an echo line | `SERIAL_ECHO_START();` | `echo:` | +| `SERIAL_ECHO_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full echo line | `SERIAL_ECHO_MSG("Count is ", count);` | `echo:Count is 3` | +| `SERIAL_ERROR_START`| None | Prefix an error line | `SERIAL_ERROR_START();` | `Error:` | +| `SERIAL_ERROR_MSG` | Same as `SERIAL_ECHOLN_PAIR` | Print a full error line | `SERIAL_ERROR_MSG("Not found");` | `Error:Not found` | +| `SERIAL_ECHO_SP` | Number of spaces | Print one or more spaces | `SERIAL_ECHO_SP(3)` | ` ` | +| `SERIAL_EOL` | None | Print an end of line | `SERIAL_EOL();` | `\n` | +| `SERIAL_OUT` | `SERIAL_OUT(myMethod)` | Call a custom serial method | `SERIAL_OUT(msgDone);` | ... | *This document was written by [X-Ryl669](https://blog.cyril.by) and is under [CC-SA license](https://creativecommons.org/licenses/by-sa)* From 0127763ade586d70183974062e296d3971091dd2 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 9 Feb 2021 00:12:14 +0000 Subject: [PATCH 45/51] [cron] Bump distribution date (2021-02-09) --- 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 ad0d520b50..3d6e501bfd 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 "2021-02-08" + #define STRING_DISTRIBUTION_DATE "2021-02-09" #endif /** From 8707ae23e22d40e7f818cf77e7ec89038fdaacf7 Mon Sep 17 00:00:00 2001 From: JoAnn Manges Date: Mon, 8 Feb 2021 20:51:57 -0500 Subject: [PATCH 46/51] MAX Thermocouples rework (#20447) Co-authored-by: Scott Lahteine --- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 2 +- Marlin/src/MarlinCore.cpp | 6 +- Marlin/src/inc/Conditionals_post.h | 84 +++++++ Marlin/src/module/temperature.cpp | 229 +++++++++++++++----- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 1 + 5 files changed, 266 insertions(+), 56 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index be64ea832e..10d6737714 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -31,7 +31,7 @@ /** * Detect an old pins file by checking for old ADC pins values. */ -#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && _CAT(P,_PIN) != 2 && _CAT(P,_PIN) != 3 +#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !WITHIN(_CAT(P,_PIN), TERN(LPC1768_IS_SKRV1_3, 0, 2), 3) // Include P0_00 and P0_01 for SKR V1.3 board #if _OLD_TEMP_PIN(TEMP_BED) #error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)." #elif _OLD_TEMP_PIN(TEMP_0) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 6b2259dd08..b085e6145a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -937,11 +937,11 @@ void setup() { SETUP_RUN(HAL_init()); - // Init and disable SPI thermocouples - #if TEMP_SENSOR_0_IS_MAX6675 + // Init and disable SPI thermocouples; this is still needed + #if TEMP_SENSOR_0_IS_MAX_TC OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable #endif - #if TEMP_SENSOR_1_IS_MAX6675 + #if TEMP_SENSOR_1_IS_MAX_TC OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 04c4eb120d..949885eab7 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -490,6 +490,90 @@ #define HAS_MAX6675 1 #endif +// +// Compatibility layer for MAX (SPI) temp boards +// +#if PIN_EXISTS(MAX6675_SS) + #if TEMP_SENSOR_0_IS_MAX31855 + #define MAX31855_CS_PIN MAX6675_SS_PIN + #elif TEMP_SENSOR_0_IS_MAX31865 + #define MAX31865_CS_PIN MAX6675_SS_PIN + #elif TEMP_SENSOR_0_IS_MAX6675 + #define MAX6675_CS_PIN MAX6675_SS_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_SS2) + #if TEMP_SENSOR_1_IS_MAX31855 + #define MAX31855_CS2_PIN MAX6675_SS2_PIN + #elif TEMP_SENSOR_1_IS_MAX31865 + #define MAX31865_CS2_PIN MAX6675_SS2_PIN + #elif TEMP_SENSOR_1_IS_MAX6675 + #define MAX6675_CS2_PIN MAX6675_SS2_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_DO) + #if HAS_MAX31855 + #define MAX31855_MISO_PIN MAX6675_DO_PIN + #elif HAS_MAX31865 + #define MAX31865_MISO_PIN MAX6675_DO_PIN + #elif HAS_MAX6675 + #define MAX6675_MISO_PIN MAX6675_DO_PIN + #endif +#endif + +#if PIN_EXISTS(MAX6675_SCK) + #if HAS_MAX31855 + #define MAX31855_SCK_PIN MAX6675_SCK_PIN + #elif HAS_MAX31865 + #define MAX31865_SCK_PIN MAX6675_SCK_PIN + #endif +#endif + +// Compatibility Layer for use when HAL manipulates PINS for MAX31855 and MAX6675 +#if PIN_EXISTS(MAX31855_CS) && !PIN_EXISTS(MAX6675_SS) + #define MAX6675_SS_PIN MAX31855_CS_PIN +#endif +#if PIN_EXISTS(MAX31855_CS2) && !PIN_EXISTS(MAX6675_SS2) + #define MAX6675_SS2_PIN MAX31855_CS2_PIN +#endif +#if PIN_EXISTS(MAX6675_CS) && !PIN_EXISTS(MAX6675_SS) + #define MAX6675_SS_PIN MAX6675_CS_PIN +#endif +#if PIN_EXISTS(MAX6675_CS2) && !PIN_EXISTS(MAX6675_SS2) + #define MAX6675_SS2_PIN MAX6675_CS2_PIN +#endif +#if PIN_EXISTS(MAX31855_MISO) && !PIN_EXISTS(MAX6675_DO) + #define MAX6675_DO_PIN MAX31855_MISO_PIN +#endif +#if PIN_EXISTS(MAX6675_MISO) && !PIN_EXISTS(MAX6675_DO) + #define MAX6675_DO_PIN MAX6675_MISO_PIN +#endif +#if PIN_EXISTS(MAX31855_SCK) && !PIN_EXISTS(MAX6675_SCK) + #define MAX6675_SCK_PIN MAX31855_SCK_PIN +#endif + +// +// User-defined thermocouple libraries +// +// Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags +// to select a USER library for MAX6675, MAX31855, MAX31865 +// +#if BOTH(HAS_MAX6675, LIB_MAX6675) + #define LIB_USR_MAX6675 1 +#endif +#if BOTH(HAS_MAX31855, LIB_MAX31855) + #define LIB_USR_MAX31855 1 +#endif +#if HAS_MAX31865 + #if ENABLED(LIB_MAX31865) + #define LIB_USR_MAX31865 1 + #else + #define LIB_ADAFRUIT_MAX31865 1 + #endif +#endif + #if TEMP_SENSOR_2 == -4 #define TEMP_SENSOR_2_IS_AD8495 1 #elif TEMP_SENSOR_2 == -3 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 5a4ed16744..edd76df3b7 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -47,41 +47,104 @@ #include "../lcd/extui/ui_api.h" #endif +// LIB_MAX31855 can be added to the build_flags in platformio.ini to use a user-defined library +#if LIB_USR_MAX31855 + #include + #if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK) + #define MAX31855_USES_SW_SPI 1 + #endif + #if TEMP_SENSOR_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS) + #define HAS_MAX31855_TEMP 1 + Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN + #if MAX31855_USES_SW_SPI + , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK + #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif + ); + #endif + #if TEMP_SENSOR_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2) + #define HAS_MAX31855_TEMP 1 + Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN + #if MAX31855_USES_SW_SPI + , MAX31855_MISO_PIN, MAX31855_SCK_PIN // For software SPI also set MISO/SCK + #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif + ); + #endif +#endif + +// LIB_MAX31865 can be added to the build_flags in platformio.ini to use a user-defined library. +// If LIB_MAX31865 is not on the build_flags then the Adafruit MAX31865 V1.1.0 library is used. #if HAS_MAX31865 #include - #if TEMP_SENSOR_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS) - #define MAX31865_CS_PIN MAX6675_SS_PIN - #endif - #if TEMP_SENSOR_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2) - #define MAX31865_CS2_PIN MAX6675_SS2_PIN - #endif #ifndef MAX31865_MOSI_PIN #define MAX31865_MOSI_PIN SD_MOSI_PIN #endif - #ifndef MAX31865_MISO_PIN - #define MAX31865_MISO_PIN MAX6675_DO_PIN - #endif - #ifndef MAX31865_SCK_PIN - #define MAX31865_SCK_PIN MAX6675_SCK_PIN + #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK) + #define MAX31865_USES_SW_SPI 1 #endif #if TEMP_SENSOR_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS) #define HAS_MAX31865_TEMP 1 - Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN - #if MAX31865_CS_PIN != MAX6675_SS_PIN - , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK - #endif - ); + Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN + #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) + , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK + #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif + ); #endif #if TEMP_SENSOR_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2) #define HAS_MAX31865_TEMP 1 Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN - #if MAX31865_CS2_PIN != MAX6675_SS2_PIN - , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK + #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI) + , MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK + #endif + #if ENABLED(LARGE_PINMAP) + , HIGH #endif ); #endif #endif +// LIB_MAX6675 can be added to the build_flags in platformio.ini to use a user-defined library +#if LIB_USR_MAX6675 + #include + #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK) + #define MAX6675_USES_SW_SPI 1 + #endif + #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) + #define HAS_MAX6675_TEMP 1 + MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN + #if MAX6675_USES_SW_SPI + , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK + #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif + ); + #endif + #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) + #define HAS_MAX6675_TEMP 1 + MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN + #if MAX6675_USES_SW_SPI + , MAX6675_MISO_PIN, MAX6675_SCK_PIN // For software SPI also set MISO/SCK + #endif + #if ENABLED(LARGE_PINMAP) + , HIGH + #endif + ); + #endif +#endif + +#if !HAS_MAX6675_TEMP && !HAS_MAX31855_TEMP && !HAS_MAX31865_TEMP + #define NO_THERMO_TEMPS 1 +#endif + #if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS #define THERMO_SEPARATE_SPI 1 #endif @@ -1718,9 +1781,38 @@ void Temperature::updateTemperaturesFromRawValues() { * The manager is implemented by periodic calls to manage_heater() */ void Temperature::init() { + // Init (and disable) SPI thermocouples + #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) + OUT_WRITE(MAX6675_CS_PIN, HIGH); + #endif + #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2) + OUT_WRITE(MAX6675_CS2_PIN, HIGH); + #endif + #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31855_CS) + OUT_WRITE(MAX31855_CS_PIN, HIGH); + #endif + #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31855_CS2) + OUT_WRITE(MAX31855_CS2_PIN, HIGH); + #endif + #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31865_CS) + OUT_WRITE(MAX31865_CS_PIN, HIGH); + #endif + #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31865_CS2) + OUT_WRITE(MAX31865_CS2_PIN, HIGH); + #endif - TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); + #if HAS_MAX31865_TEMP + TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE)); + #endif + #if HAS_MAX31855_TEMP + TERN_(TEMP_SENSOR_0_IS_MAX31855, max31855_0.begin()); + TERN_(TEMP_SENSOR_1_IS_MAX31855, max31855_1.begin()); + #endif + #if HAS_MAX6675_TEMP + TERN_(TEMP_SENSOR_0_IS_MAX6675, max6675_0.begin()); + TERN_(TEMP_SENSOR_1_IS_MAX6675, max6675_1.begin()); + #endif #if EARLY_WATCHDOG // Flag that the thermalManager should be running @@ -2234,7 +2326,7 @@ void Temperature::disable_all_heaters() { int Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { #define MAX6675_HEAT_INTERVAL 250UL - #if HAS_MAX31855 + #if HAS_MAX31855_TEMP static uint32_t max_tc_temp = 2000; #define MAX_TC_ERROR_MASK 7 #define MAX_TC_DISCARD_BITS 18 @@ -2284,65 +2376,91 @@ void Temperature::disable_all_heaters() { if (PENDING(ms, next_max_tc_ms[hindex])) return int(THERMO_TEMP(hindex)); next_max_tc_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; - #if HAS_MAX31865_TEMP - Adafruit_MAX31865 &maxref = THERMO_SEL(max31865_0, max31865_1); - const uint16_t max31865_ohms = (uint32_t(maxref.readRTD()) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; - #endif - // // TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used. // - #if !THERMO_SEPARATE_SPI + #if !THERMO_SEPARATE_SPI && NO_THERMO_TEMPS spiBegin(); spiInit(MAX_TC_SPEED_BITS); #endif - MAX6675_WRITE(LOW); // enable TT_MAX6675 - DELAY_NS(100); // Ensure 100ns delay + #if NO_THERMO_TEMPS + MAX6675_WRITE(LOW); // enable TT_MAX6675 + DELAY_NS(100); // Ensure 100ns delay + #endif + + max_tc_temp = 0; // Read a big-endian temperature value - max_tc_temp = 0; - for (uint8_t i = sizeof(max_tc_temp); i--;) { - max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max_tc_spi.receive(), spiRec()); - if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte - } + #if NO_THERMO_TEMPS + for (uint8_t i = sizeof(max_tc_temp); i--;) { + max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max_tc_spi.receive(), spiRec()); + if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte + } + MAX6675_WRITE(HIGH); // disable TT_MAX6675 + #endif - MAX6675_WRITE(HIGH); // disable TT_MAX6675 + #if HAS_MAX31855_TEMP + Adafruit_MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1); + max_tc_temp = max855ref.readRaw32(); + #endif - const uint8_t fault_31865 = TERN1(HAS_MAX31865_TEMP, maxref.readFault()); + #if HAS_MAX31865_TEMP + Adafruit_MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1); + #if ENABLED(LIB_USR_MAX31865) + max_tc_temp = max865ref.readRTD_with_Fault(); + #endif + #endif - if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max_tc_temp & MAX_TC_ERROR_MASK) && fault_31865) { + #if HAS_MAX6675_TEMP + MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); + max_tc_temp = max6675ref.readRaw16(); + #endif + + #if ENABLED(LIB_ADAFRUIT_MAX31865) + const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; + #endif + + if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) + && TERN(LIB_ADAFRUIT_MAX31865, fault_31865, (max_tc_temp & MAX_TC_ERROR_MASK)) + ) { max_tc_errors[hindex]++; if (max_tc_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) { SERIAL_ERROR_START(); SERIAL_ECHOPGM("Temp measurement error! "); #if MAX_TC_ERROR_MASK == 7 - SERIAL_ECHOPGM("MAX31855 "); - if (max_tc_temp & 1) + SERIAL_ECHOPGM("MAX31855 Fault : (", max_tc_temp & 0x7, ") >> "); + if (max_tc_temp & 0x1) SERIAL_ECHOLNPGM("Open Circuit"); - else if (max_tc_temp & 2) + else if (max_tc_temp & 0x2) SERIAL_ECHOLNPGM("Short to GND"); - else if (max_tc_temp & 4) + else if (max_tc_temp & 0x4) SERIAL_ECHOLNPGM("Short to VCC"); - #elif HAS_MAX31865_TEMP + #elif HAS_MAX31865 + #if ENABLED(LIB_USR_MAX31865) + // At the present time we do not have the ability to set the MAX31865 HIGH threshold + // or thr LOW threshold, so no need to check for them, zero these bits out + const uint8_t fault_31865 = max865ref.readFault() & 0x3FU; + #endif + max865ref.clearFault(); if (fault_31865) { - maxref.clearFault(); - SERIAL_ECHOPAIR("MAX31865 Fault :(", fault_31865, ") >>"); + SERIAL_EOL(); + SERIAL_ECHOLNPAIR("\nMAX31865 Fault :(", fault_31865, ") >>"); if (fault_31865 & MAX31865_FAULT_HIGHTHRESH) SERIAL_ECHOLNPGM("RTD High Threshold"); - else if (fault_31865 & MAX31865_FAULT_LOWTHRESH) + if (fault_31865 & MAX31865_FAULT_LOWTHRESH) SERIAL_ECHOLNPGM("RTD Low Threshold"); - else if (fault_31865 & MAX31865_FAULT_REFINLOW) + if (fault_31865 & MAX31865_FAULT_REFINLOW) SERIAL_ECHOLNPGM("REFIN- > 0.85 x Bias"); - else if (fault_31865 & MAX31865_FAULT_REFINHIGH) + if (fault_31865 & MAX31865_FAULT_REFINHIGH) SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); - else if (fault_31865 & MAX31865_FAULT_RTDINLOW) + if (fault_31865 & MAX31865_FAULT_RTDINLOW) SERIAL_ECHOLNPGM("REFIN- < 0.85 x Bias - FORCE- open"); - else if (fault_31865 & MAX31865_FAULT_OVUV) + if (fault_31865 & MAX31865_FAULT_OVUV) SERIAL_ECHOLNPGM("Under/Over voltage"); } #else - SERIAL_ECHOLNPGM("MAX6675"); + SERIAL_ECHOLNPGM("MAX6675 Open Circuit"); #endif // Thermocouple open @@ -2361,7 +2479,13 @@ void Temperature::disable_all_heaters() { #endif // Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES - TERN_(HAS_MAX31865_TEMP, max_tc_temp = max31865_ohms); + #if HAS_MAX31865_TEMP + #if ENABLED(LIB_ADAFRUIT_MAX31865) + max_tc_temp = (uint32_t(max865ref.readRTD()) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + #elif ENABLED(LIB_USR_MAX31865) + max_tc_temp = (uint32_t(max_tc_temp) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16; + #endif + #endif THERMO_TEMP(hindex) = max_tc_temp; @@ -3047,7 +3171,8 @@ void Temperature::tick() { SERIAL_ECHOPGM(" /"); SERIAL_PRINT(t, SFP); #if ENABLED(SHOW_TEMP_ADC_VALUES) - SERIAL_ECHOPAIR(" (", r * RECIPROCAL(OVERSAMPLENR)); + // Temperature MAX SPI boards do not have an OVERSAMPLENR defined + SERIAL_ECHOPAIR(" (", TERN(NO_THERMO_TEMPS, false, k == 'T') ? r : r * RECIPROCAL(OVERSAMPLENR)); SERIAL_CHAR(')'); #endif delay(2); 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 e5b78024cb..db9f85c742 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -22,6 +22,7 @@ #pragma once #define BOARD_INFO_NAME "BTT SKR V1.3" +#define LPC1768_IS_SKRV1_3 1 // // Trinamic Stallguard pins From 187602dfaf744615e715c540b9e2d4f01d308224 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 7 Feb 2021 18:16:43 -0600 Subject: [PATCH 47/51] Update M808 comment --- Marlin/src/gcode/queue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index c483522cd7..c49247912c 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -610,7 +610,7 @@ void GCodeQueue::get_serial_commands() { if (!is_eol && sd_count) ++sd_count; // End of file with no newline if (!process_line_done(sd_input_state, command_buffer[index_w], sd_count)) { - // M808 S saves the sdpos of the next line. M808 loops to a new sdpos. + // M808 L saves the sdpos of the next line. M808 loops to a new sdpos. TERN_(GCODE_REPEAT_MARKERS, repeat.early_parse_M808(command_buffer[index_w])); // Put the new command into the buffer (no "ok" sent) From 662d81c801eaa6323ef8f5c99fb2d2206812a0ce Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Feb 2021 21:27:00 -0600 Subject: [PATCH 48/51] Ender 3 V2 DWIN cleanup (#21026) --- Marlin/src/core/macros.h | 8 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 214 ++++++++++++++---------------- Marlin/src/lcd/dwin/e3v2/dwin.h | 12 +- 3 files changed, 110 insertions(+), 124 deletions(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 0112dbc736..16e18ac902 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -130,20 +130,20 @@ #define NOLESS(v, n) \ do{ \ - __typeof__(n) _n = (n); \ + __typeof__(v) _n = (n); \ if (_n > v) v = _n; \ }while(0) #define NOMORE(v, n) \ do{ \ - __typeof__(n) _n = (n); \ + __typeof__(v) _n = (n); \ if (_n < v) v = _n; \ }while(0) #define LIMIT(v, n1, n2) \ do{ \ - __typeof__(n1) _n1 = (n1); \ - __typeof__(n2) _n2 = (n2); \ + __typeof__(v) _n1 = (n1); \ + __typeof__(v) _n2 = (n2); \ if (_n1 > v) v = _n1; \ else if (_n2 < v) v = _n2; \ }while(0) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 55554a98cf..69889b6b06 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -191,16 +191,12 @@ constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; #endif -uint8_t Percentrecord = 0; -uint16_t remain_time = 0; +static uint8_t _card_percent = 0; +static 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 + TERN_(HAS_HOTEND, uint16_t resume_hotend_temp = 0); + TERN_(HAS_HEATED_BED, uint16_t resume_bed_temp = 0); #endif #if HAS_ZOFFSET_ITEM @@ -1081,8 +1077,8 @@ 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, Color_Bg_Black, 2, 117, 133, Percentrecord); + DWIN_Draw_Rectangle(1, BarFill_Color, 16 + _card_percent * 240 / 100, 93, 256, 113); + DWIN_Draw_IntValue(true, true, 0, font8x16, Percent_Color, Color_Bg_Black, 2, 117, 133, _card_percent); DWIN_Draw_String(false, false, font8x16, Percent_Color, Color_Bg_Black, 133, 133, F("%")); } @@ -1094,9 +1090,9 @@ void Draw_Print_ProgressElapsed() { } void Draw_Print_ProgressRemain() { - DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 176, 212, remain_time / 3600); + 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); + DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 200, 212, (_remain_time % 3600) / 60); } void Goto_PrintProcess() { @@ -1158,10 +1154,10 @@ inline ENCODER_DiffState get_encoder_state() { void HMI_Move_X() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scale)) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scaled)) { checkkey = AxisMove; EncoderRate.enabled = false; - 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(1), HMI_ValueStruct.Move_X_scaled); if (!planner.is_full()) { // Wait for planner moves to finish! planner.synchronize(); @@ -1170,10 +1166,9 @@ void HMI_Move_X() { DWIN_UpdateLCD(); return; } - 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 / MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + LIMIT(HMI_ValueStruct.Move_X_scaled, (X_MIN_POS) * MINUNITMULT, (X_MAX_POS) * MINUNITMULT); + current_position.x = HMI_ValueStruct.Move_X_scaled / MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled); DWIN_UpdateLCD(); } } @@ -1181,10 +1176,10 @@ void HMI_Move_X() { void HMI_Move_Y() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scale)) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scaled)) { checkkey = AxisMove; EncoderRate.enabled = false; - 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(2), HMI_ValueStruct.Move_Y_scaled); if (!planner.is_full()) { // Wait for planner moves to finish! planner.synchronize(); @@ -1193,10 +1188,9 @@ void HMI_Move_Y() { DWIN_UpdateLCD(); return; } - 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 / MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + LIMIT(HMI_ValueStruct.Move_Y_scaled, (Y_MIN_POS) * MINUNITMULT, (Y_MAX_POS) * MINUNITMULT); + current_position.y = HMI_ValueStruct.Move_Y_scaled / MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled); DWIN_UpdateLCD(); } } @@ -1204,10 +1198,10 @@ void HMI_Move_Y() { void HMI_Move_Z() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scale)) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scaled)) { checkkey = AxisMove; EncoderRate.enabled = false; - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled); if (!planner.is_full()) { // Wait for planner moves to finish! planner.synchronize(); @@ -1216,10 +1210,9 @@ void HMI_Move_Z() { DWIN_UpdateLCD(); return; } - 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 / MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + LIMIT(HMI_ValueStruct.Move_Z_scaled, Z_MIN_POS * MINUNITMULT, Z_MAX_POS * MINUNITMULT); + current_position.z = HMI_ValueStruct.Move_Z_scaled / MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled); DWIN_UpdateLCD(); } } @@ -1227,14 +1220,14 @@ void HMI_Move_Z() { #if HAS_HOTEND void HMI_Move_E() { - static float last_E_scale = 0; + static float last_E_scaled = 0; ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scale)) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scaled)) { checkkey = AxisMove; EncoderRate.enabled = false; - last_E_scale = HMI_ValueStruct.Move_E_scale; - DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + last_E_scaled = HMI_ValueStruct.Move_E_scaled; + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled); if (!planner.is_full()) { planner.synchronize(); // Wait for planner moves to finish! planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder); @@ -1242,12 +1235,12 @@ void HMI_Move_Z() { DWIN_UpdateLCD(); return; } - if ((HMI_ValueStruct.Move_E_scale - last_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) - HMI_ValueStruct.Move_E_scale = last_E_scale + (EXTRUDE_MAXLENGTH) * MINUNITMULT; - else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) - HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT; - current_position.e = HMI_ValueStruct.Move_E_scale / MINUNITMULT; - DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, UNITFDIGITS, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + if ((HMI_ValueStruct.Move_E_scaled - last_E_scaled) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) + HMI_ValueStruct.Move_E_scaled = last_E_scaled + (EXTRUDE_MAXLENGTH) * MINUNITMULT; + else if ((last_E_scaled - HMI_ValueStruct.Move_E_scaled) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) + HMI_ValueStruct.Move_E_scaled = last_E_scaled - (EXTRUDE_MAXLENGTH) * MINUNITMULT; + current_position.e = HMI_ValueStruct.Move_E_scaled / MINUNITMULT; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, UNITFDIGITS, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled); DWIN_UpdateLCD(); } } @@ -1277,8 +1270,7 @@ void HMI_Move_Z() { 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); + LIMIT(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100, (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) @@ -1326,8 +1318,7 @@ void HMI_Move_Z() { return; } // E_Temp limit - NOMORE(HMI_ValueStruct.E_Temp, MAX_E_TEMP); - NOLESS(HMI_ValueStruct.E_Temp, MIN_E_TEMP); + LIMIT(HMI_ValueStruct.E_Temp, MIN_E_TEMP, MAX_E_TEMP); // E_Temp value DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } @@ -1370,8 +1361,7 @@ void HMI_Move_Z() { return; } // Bed_Temp limit - NOMORE(HMI_ValueStruct.Bed_Temp, BED_MAX_TARGET); - NOLESS(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP); + LIMIT(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP, BED_MAX_TARGET); // Bed_Temp value DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } @@ -1415,8 +1405,7 @@ void HMI_Move_Z() { return; } // Fan_speed limit - NOMORE(HMI_ValueStruct.Fan_speed, FANON); - NOLESS(HMI_ValueStruct.Fan_speed, FANOFF); + LIMIT(HMI_ValueStruct.Fan_speed, FANOFF, FANON); // Fan_speed value DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } @@ -1435,8 +1424,7 @@ void HMI_PrintSpeed() { return; } // print_speed limit - NOMORE(HMI_ValueStruct.print_speed, MAX_PRINT_SPEED); - NOLESS(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED); + LIMIT(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED, MAX_PRINT_SPEED); // print_speed value DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); } @@ -1491,20 +1479,20 @@ void HMI_MaxAccelerationXYZE() { void HMI_MaxJerkXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk)) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk_scaled)) { checkkey = MaxJerk; EncoderRate.enabled = false; if (WITHIN(HMI_flag.jerk_axis, X_AXIS, E_AXIS)) - planner.set_max_jerk(HMI_flag.jerk_axis, HMI_ValueStruct.Max_Jerk / 10); - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + planner.set_max_jerk(HMI_flag.jerk_axis, HMI_ValueStruct.Max_Jerk_scaled / 10); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk_scaled); 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); + NOMORE(HMI_ValueStruct.Max_Jerk_scaled, default_max_jerk[HMI_flag.jerk_axis] * 2 * MINUNITMULT); + NOLESS(HMI_ValueStruct.Max_Jerk_scaled, (MIN_MAXJERK) * MINUNITMULT); // MaxJerk value - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk_scaled); } } @@ -1513,43 +1501,41 @@ void HMI_MaxAccelerationXYZE() { void HMI_StepXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step)) { + if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step_scaled)) { checkkey = Step; 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, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step_scaled / 10; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step_scaled); return; } // Step limit if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) - NOMORE(HMI_ValueStruct.Max_Step, 999.9 * MINUNITMULT); - NOLESS(HMI_ValueStruct.Max_Step, MIN_STEP); + NOMORE(HMI_ValueStruct.Max_Step_scaled, 999.9 * MINUNITMULT); + NOLESS(HMI_ValueStruct.Max_Step_scaled, MIN_STEP); // Step value - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step_scaled); } } 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 + TERN_(HAS_HOTEND, static float last_temp_hotend_target = 0); + TERN_(HAS_HEATED_BED, static float last_temp_bed_target = 0); + TERN_(HAS_FAN, static uint8_t last_fan_speed = 0); /* Tune page temperature update */ if (checkkey == Tune) { #if HAS_HOTEND - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) + if (last_temp_hotend_target != 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); + last_temp_hotend_target = thermalManager.temp_hotend[0].target; + } #endif #if HAS_HEATED_BED - if (last_temp_bed_target != thermalManager.temp_bed.target) + if (last_temp_bed_target != 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); + last_temp_bed_target = thermalManager.temp_bed.target; + } #endif #if HAS_FAN if (last_fan_speed != thermalManager.fan_speed[0]) { @@ -1562,12 +1548,16 @@ void update_variable() { /* Temperature page temperature update */ if (checkkey == TemperatureID) { #if HAS_HOTEND - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) + if (last_temp_hotend_target != 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); + last_temp_hotend_target = thermalManager.temp_hotend[0].target; + } #endif #if HAS_HEATED_BED - if (last_temp_bed_target != thermalManager.temp_bed.target) + if (last_temp_bed_target != 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); + last_temp_bed_target = thermalManager.temp_bed.target; + } #endif #if HAS_FAN if (last_fan_speed != thermalManager.fan_speed[0]) { @@ -1579,9 +1569,10 @@ void update_variable() { /* Bottom temperature update */ #if HAS_HOTEND - if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) { + static float _hotendtemp = 0; + if (_hotendtemp != 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; + _hotendtemp = thermalManager.temp_hotend[0].celsius; } if (last_temp_hotend_target != 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); @@ -1589,9 +1580,10 @@ void update_variable() { } #endif #if HAS_HEATED_BED - if (last_temp_bed_current != thermalManager.temp_bed.celsius) { + static float _bedtemp = 0; + if (_bedtemp != 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; + _bedtemp = thermalManager.temp_bed.celsius; } if (last_temp_bed_target != 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); @@ -2135,13 +2127,11 @@ void HMI_Printing() { char cmd[40]; cmd[0] = '\0'; - #if ENABLED(PAUSE_HEAT) - #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 + #if BOTH(HAS_HOTEND, PAUSE_HEAT) + if (resume_hotend_temp) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), resume_hotend_temp); + #endif + #if BOTH(HAS_HEATED_BED, PAUSE_HEAT) + if (resume_bed_temp) sprintf_P(cmd, PSTR("M190 S%i\n"), resume_bed_temp); #endif strcat_P(cmd, M24_STR); @@ -2322,8 +2312,8 @@ void HMI_Prepare() { DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(2), current_position.y * MINUNITMULT); DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(3), current_position.z * MINUNITMULT); #if HAS_HOTEND - HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT; - DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT; + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled); #endif break; case PREPARE_CASE_DISA: // Disable steppers @@ -2573,11 +2563,11 @@ void HMI_AxisMove() { if (HMI_flag.ETempTooLow_flag) { if (encoder_diffState == ENCODER_DIFF_ENTER) { HMI_flag.ETempTooLow_flag = false; - HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT; + HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT; Draw_Move_Menu(); - 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_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled); + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled); DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), 0); DWIN_UpdateLCD(); } @@ -2602,20 +2592,20 @@ void HMI_AxisMove() { break; case 1: // X axis move checkkey = Move_X; - HMI_ValueStruct.Move_X_scale = current_position.x * MINUNITMULT; - DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); + HMI_ValueStruct.Move_X_scaled = current_position.x * MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled); 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, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); + HMI_ValueStruct.Move_Y_scaled = current_position.y * MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled); 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, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); + HMI_ValueStruct.Move_Z_scaled = current_position.z * MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled); EncoderRate.enabled = true; break; #if HAS_HOTEND @@ -2630,8 +2620,8 @@ void HMI_AxisMove() { } #endif 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); + HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled); EncoderRate.enabled = true; break; #endif @@ -3417,8 +3407,8 @@ void HMI_MaxAcceleration() { 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, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + HMI_ValueStruct.Max_Jerk_scaled = planner.max_jerk[HMI_flag.jerk_axis] * MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk_scaled); EncoderRate.enabled = true; } else { // Back @@ -3447,8 +3437,8 @@ void HMI_Step() { if (WITHIN(select_step.now, 1, 4)) { 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, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); + HMI_ValueStruct.Max_Step_scaled = planner.settings.axis_steps_per_mm[HMI_flag.step_axis] * MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step_scaled); EncoderRate.enabled = true; } else { // Back @@ -3499,7 +3489,7 @@ void EachMomentUpdate() { planner.finish_and_disable(); // show percent bar and value - Percentrecord = 0; + _card_percent = 0; Draw_Print_ProgressBar(); // show print done confirm @@ -3517,12 +3507,8 @@ void EachMomentUpdate() { if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) { HMI_flag.pause_action = false; #if ENABLED(PAUSE_HEAT) - #if HAS_HEATED_BED - tempbed = thermalManager.temp_bed.target; - #endif - #if HAS_HOTEND - temphot = thermalManager.temp_hotend[0].target; - #endif + TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.temp_hotend[0].target); + TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.temp_bed.target); thermalManager.disable_all_heaters(); #endif queue.inject_P(PSTR("G1 F1200 X0 Y0")); @@ -3534,7 +3520,7 @@ void EachMomentUpdate() { if (last_cardpercentValue != card_pct) { // print percent last_cardpercentValue = card_pct; if (card_pct) { - Percentrecord = card_pct; + _card_percent = card_pct; Draw_Print_ProgressBar(); } } @@ -3551,8 +3537,8 @@ void EachMomentUpdate() { // 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) { - remain_time = (elapsed.value - dwin_heat_time) / (Percentrecord * 0.01f) - (elapsed.value - dwin_heat_time); + if (_card_percent > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) { + _remain_time = (elapsed.value - dwin_heat_time) / (_card_percent * 0.01f) - (elapsed.value - dwin_heat_time); next_remain_time_update += SEC_TO_MS(20); Draw_Print_ProgressRemain(); } diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index 5656d67e9a..57f9873145 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -240,13 +240,13 @@ typedef struct { int16_t print_speed = 100; float Max_Feedspeed = 0; float Max_Acceleration = 0; - float Max_Jerk = 0; - float Max_Step = 0; - float Move_X_scale = 0; - float Move_Y_scale = 0; - float Move_Z_scale = 0; + float Max_Jerk_scaled = 0; + float Max_Step_scaled = 0; + float Move_X_scaled = 0; + float Move_Y_scaled = 0; + float Move_Z_scaled = 0; #if HAS_HOTEND - float Move_E_scale = 0; + float Move_E_scaled = 0; #endif float offset_value = 0; int8_t show_mode = 0; // -1: Temperature control 0: Printing temperature From 653d73ff074c2d8f6cfafb95a7ddf53dae50be4e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Feb 2021 21:31:26 -0600 Subject: [PATCH 49/51] Reheat bed first --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 69889b6b06..04171b9d79 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -2127,12 +2127,12 @@ void HMI_Printing() { char cmd[40]; cmd[0] = '\0'; - #if BOTH(HAS_HOTEND, PAUSE_HEAT) - if (resume_hotend_temp) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), resume_hotend_temp); - #endif #if BOTH(HAS_HEATED_BED, PAUSE_HEAT) if (resume_bed_temp) sprintf_P(cmd, PSTR("M190 S%i\n"), resume_bed_temp); #endif + #if BOTH(HAS_HOTEND, PAUSE_HEAT) + if (resume_hotend_temp) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), resume_hotend_temp); + #endif strcat_P(cmd, M24_STR); queue.inject(cmd); From dd5e0f724a26c5a7fea8b3a017a19933f62739c1 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 10 Feb 2021 00:12:10 +0000 Subject: [PATCH 50/51] [cron] Bump distribution date (2021-02-10) --- 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 3d6e501bfd..6c4f17ca27 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 "2021-02-09" + #define STRING_DISTRIBUTION_DATE "2021-02-10" #endif /** From 9d24ee8daf0773ca1870a5c156a253458cc2ee1b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 Feb 2021 02:57:27 -0600 Subject: [PATCH 51/51] chmod and paths --- Marlin/src/gcode/bedlevel/G35.cpp | 0 buildroot/share/PlatformIO/scripts/mks_robin_mini.py | 0 buildroot/share/PlatformIO/scripts/mks_robin_nano.py | 0 buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp | 0 buildroot/share/PlatformIO/variants/CHITU_F103/board/board.h | 0 buildroot/share/PlatformIO/variants/CHITU_F103/pins_arduino.h | 0 buildroot/share/PlatformIO/variants/CHITU_F103/variant.h | 0 .../share/PlatformIO/variants/CHITU_F103/wirish/boards.cpp | 0 .../PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp | 0 .../share/PlatformIO/variants/megaextendedpins/pins_arduino.h | 0 buildroot/share/vscode/auto_build.py | 4 ++-- buildroot/share/vscode/create_custom_upload_command_CDC.py | 4 ++-- 12 files changed, 4 insertions(+), 4 deletions(-) mode change 100755 => 100644 Marlin/src/gcode/bedlevel/G35.cpp mode change 100755 => 100644 buildroot/share/PlatformIO/scripts/mks_robin_mini.py mode change 100755 => 100644 buildroot/share/PlatformIO/scripts/mks_robin_nano.py mode change 100755 => 100644 buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp mode change 100755 => 100644 buildroot/share/PlatformIO/variants/CHITU_F103/board/board.h mode change 100755 => 100644 buildroot/share/PlatformIO/variants/CHITU_F103/pins_arduino.h mode change 100755 => 100644 buildroot/share/PlatformIO/variants/CHITU_F103/variant.h mode change 100755 => 100644 buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards.cpp mode change 100755 => 100644 buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp mode change 100755 => 100644 buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp b/buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/board/board.h b/buildroot/share/PlatformIO/variants/CHITU_F103/board/board.h old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/pins_arduino.h b/buildroot/share/PlatformIO/variants/CHITU_F103/pins_arduino.h old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/variant.h b/buildroot/share/PlatformIO/variants/CHITU_F103/variant.h old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards.cpp old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp b/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp old mode 100755 new mode 100644 diff --git a/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h b/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h old mode 100755 new mode 100644 diff --git a/buildroot/share/vscode/auto_build.py b/buildroot/share/vscode/auto_build.py index 5dd2d0d8a3..61cacca4d7 100644 --- a/buildroot/share/vscode/auto_build.py +++ b/buildroot/share/vscode/auto_build.py @@ -77,8 +77,8 @@ import os pwd = os.getcwd() # make sure we're executing from the correct directory level pwd = pwd.replace('\\', '/') -if 0 <= pwd.find('buildroot/share/atom'): - pwd = pwd[:pwd.find('buildroot/share/atom')] +if 0 <= pwd.find('buildroot/share/vscode'): + pwd = pwd[:pwd.find('buildroot/share/vscode')] os.chdir(pwd) print('pwd: ', pwd) diff --git a/buildroot/share/vscode/create_custom_upload_command_CDC.py b/buildroot/share/vscode/create_custom_upload_command_CDC.py index acfd1787fb..65edbd15b8 100644 --- a/buildroot/share/vscode/create_custom_upload_command_CDC.py +++ b/buildroot/share/vscode/create_custom_upload_command_CDC.py @@ -92,9 +92,9 @@ else: get_com_port('COM', 'Hardware ID:', 13) # avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf' - avrdude_conf_path = 'buildroot\\share\\atom\\avrdude.conf' + avrdude_conf_path = 'buildroot\\share\\vscode\\avrdude.conf' - avrdude_exe_path = 'buildroot\\share\\atom\\avrdude_5.10.exe' + avrdude_exe_path = 'buildroot\\share\\vscode\\avrdude_5.10.exe' # source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex' source_path = '.pio\\build\\' + env.get("PIOENV") + '\\firmware.hex'