From d05bf563a21e023f91d0637e3e9012df7c0d1d01 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 6 Mar 2021 00:12:57 +0000 Subject: [PATCH 001/311] [cron] Bump distribution date (2021-03-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 e57a3485d9..be2dd72ec4 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-03-05" + #define STRING_DISTRIBUTION_DATE "2021-03-06" #endif /** From 3eb8e26174efd20797addced921069050d1a344f Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Fri, 5 Mar 2021 23:53:44 -0800 Subject: [PATCH 002/311] Tweak/Consolidate followup (#21261) --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 74452754ad..0ed883ba0d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -729,7 +729,7 @@ board = nxp_lpc1769 # BTT SKR 1.4 needs a UART3 tweak [env:LPC1768_btt_skr_v1_4] -platform = ${LPC1768.platform} +platform = ${env:LPC1768.platform} extends = env:LPC1768 build_flags = ${env:LPC1768.build_flags} -DLPC_PINCFG_UART3_P4_28 From a1796ecace74680434237507548d40cef15564ad Mon Sep 17 00:00:00 2001 From: qwewer0 <57561110+qwewer0@users.noreply.github.com> Date: Sat, 6 Mar 2021 08:56:43 +0100 Subject: [PATCH 003/311] Link to bugfix tree (#21263) --- config/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/README.md b/config/README.md index b5013627ea..4bd6ab851e 100644 --- a/config/README.md +++ b/config/README.md @@ -2,7 +2,7 @@ Marlin configurations for specific machines are now maintained in their own repository at: -## https://github.com/MarlinFirmware/Configurations +## https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.0.x Configuration files for use with the nightly `bugfix-2.0.x` branch can be downloaded from: From 4182cf3e9e935ff90701a497ee34ca8ebef263c4 Mon Sep 17 00:00:00 2001 From: "Zs.Antal" <45710979+AntoszHUN@users.noreply.github.com> Date: Sat, 6 Mar 2021 09:00:10 +0100 Subject: [PATCH 004/311] Update Hungarian language (#21266) --- Marlin/src/lcd/language/language_hu.h | 403 ++++++++++++++------------ 1 file changed, 214 insertions(+), 189 deletions(-) diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index c5cd845c27..e29b75fb35 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -27,14 +27,12 @@ * LCD Menü Üzenetek. Lásd még https://marlinfw.org/docs/development/lcd_language.html * Marlin 2.0.x bugfix Magyar fordítása. A fordítást folyamatosan javítom és frissítem. * A Magyar fordítást készítette: AntoszHUN - * - * + * A Fordítás utolsó frissítése: 2021.03.06. - 08:00 */ namespace Language_hu { using namespace Language_en; // A fordítás az örökölt Amerikai Angol (English) karakterláncokat használja. - constexpr uint8_t CHARSIZE = 2; PROGMEM Language_Str LANGUAGE = _UxGT("Magyar"); @@ -44,8 +42,8 @@ namespace Language_hu { PROGMEM Language_Str MSG_NO = _UxGT("NEM"); PROGMEM Language_Str MSG_BACK = _UxGT("Vissza"); PROGMEM Language_Str MSG_MEDIA_ABORTING = _UxGT("Megszakítás..."); - 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_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"); @@ -53,31 +51,34 @@ namespace Language_hu { PROGMEM Language_Str MSG_MEDIA_USB_FAILED = _UxGT("USB eszköz hiba"); PROGMEM Language_Str MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Túlfolyás"); PROGMEM Language_Str MSG_LCD_ENDSTOPS = _UxGT("Végállás"); // Maximum 8 karakter - PROGMEM Language_Str MSG_LCD_SOFT_ENDSTOPS = _UxGT("Szoft. Végállás"); + PROGMEM Language_Str MSG_LCD_SOFT_ENDSTOPS = _UxGT("Szoft. végállás"); PROGMEM Language_Str MSG_MAIN = _UxGT(""); - PROGMEM Language_Str MSG_ADVANCED_SETTINGS = _UxGT("További Beállítások"); + 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_AUTOSTART = _UxGT("Autoinditás"); + PROGMEM Language_Str MSG_RUN_AUTO_FILES = _UxGT("Fájl auto. futtatá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"); - PROGMEM Language_Str MSG_AUTO_HOME = _UxGT("XYZ Auto kezdöpont"); + PROGMEM Language_Str MSG_AUTO_HOME = _UxGT("X-Y-Z Auto kezdöpont"); PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("X Kezdöpont"); 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_HOMING = _UxGT("X-Y-Z 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"); - PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Szintezés Kész!"); - PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Szint Csökkentés"); + PROGMEM Language_Str MSG_LEVEL_BED_NEXT_POINT = _UxGT("Következö pont"); + PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Szintezés kész!"); + PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Szint csökkentés"); PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Kezdöpont eltolás"); PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Eltolás beállítva."); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Eredeti Be"); + PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Elektromos segéd"); + PROGMEM Language_Str MSG_TRAMMING_WIZARD = _UxGT("Elektromos varázsló"); + PROGMEM Language_Str MSG_SELECT_ORIGIN = _UxGT("Eredeti választása"); + PROGMEM Language_Str MSG_LAST_VALUE_SP = _UxGT("Utolsó érték "); #if PREHEAT_COUNT PROGMEM Language_Str MSG_PREHEAT_1 = _UxGT("Fütés ") PREHEAT_1_LABEL; PROGMEM Language_Str MSG_PREHEAT_1_H = _UxGT("Fütés ") PREHEAT_1_LABEL " ~"; @@ -95,36 +96,43 @@ namespace Language_hu { PROGMEM Language_Str MSG_PREHEAT_M_BEDONLY = _UxGT("Fütés $ Ágy"); PROGMEM Language_Str MSG_PREHEAT_M_SETTINGS = _UxGT("Fütés $ Beáll"); #endif - PROGMEM Language_Str MSG_PREHEAT_CUSTOM = _UxGT("Egyedi Elömelegítés"); + PROGMEM Language_Str MSG_PREHEAT_CUSTOM = _UxGT("Egyedi elömelegítés"); 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_LASER_MENU = _UxGT("Lézer vezérlés"); + PROGMEM Language_Str MSG_SPINDLE_MENU = _UxGT("Orsó vezérlés"); + PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Lézer telj."); + PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Orsó telj."); + PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Lézer váltás"); + PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Impulzus teszt ms"); + PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Tűz impulzus"); + PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Orsóváltás"); + PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Orsó előre"); + PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Orsó hátra"); + PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Bekapcsolás"); PROGMEM Language_Str MSG_SWITCH_PS_OFF = _UxGT("Kikapcsolás"); - PROGMEM Language_Str MSG_EXTRUDE = _UxGT("Extrudál"); + PROGMEM Language_Str MSG_EXTRUDE = _UxGT("Adagol"); PROGMEM Language_Str MSG_RETRACT = _UxGT("Visszahúz"); - PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Tengelyek Mozgatása"); - PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Ágy Szintezés"); + PROGMEM Language_Str MSG_MOVE_AXIS = _UxGT("Tengelyek mozgatása"); + PROGMEM Language_Str MSG_BED_LEVELING = _UxGT("Ágy szintezés"); PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Ágy szintezése"); PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Sarok szint"); + PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Ágy emelése a szonda váltásig"); + PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Minden sarok tolerancián belül. Szint jó"); + PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Jó pontok: "); + PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Utolsó Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Következö sarok"); - PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Háló Szerkesztö"); - PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Háló Szerkesztése"); - PROGMEM Language_Str MSG_EDITING_STOPPED = _UxGT("Háló Szerk. Állj"); + PROGMEM Language_Str MSG_MESH_EDITOR = _UxGT("Háló szerkesztö"); + PROGMEM Language_Str MSG_EDIT_MESH = _UxGT("Háló szerkesztése"); + PROGMEM Language_Str MSG_EDITING_STOPPED = _UxGT("Háló szerk. állj"); PROGMEM Language_Str MSG_PROBING_MESH = _UxGT("Próbapont"); 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_M48_TEST = _UxGT("M48 Probe Teszt"); + 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"); @@ -134,6 +142,7 @@ namespace Language_hu { 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"); PROGMEM Language_Str MSG_IDEX_MODE_FULL_CTRL = _UxGT("Teljes felügyelet"); + PROGMEM Language_Str MSG_IDEX_DUPE_GAP = _UxGT("X-Hézag másolása"); PROGMEM Language_Str MSG_HOTEND_OFFSET_X = _UxGT("2. fúvóka X"); PROGMEM Language_Str MSG_HOTEND_OFFSET_Y = _UxGT("2. fúvóka Y"); PROGMEM Language_Str MSG_HOTEND_OFFSET_Z = _UxGT("2. fúvóka Z"); @@ -146,75 +155,75 @@ namespace Language_hu { PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Mérés"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Üres ágyat mérj"); PROGMEM Language_Str MSG_UBL_MOVING_TO_NEXT = _UxGT("Továbblépés"); - PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("UBL Aktivál"); - PROGMEM Language_Str MSG_UBL_DEACTIVATE_MESH = _UxGT("UBL Deaktivál"); - PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = _UxGT("Ágy Höfok"); - PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Ágy Höfok"); - PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = _UxGT("Fúvóka Höfok"); - PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Fúvóka Höfok"); - PROGMEM Language_Str MSG_UBL_MESH_EDIT = _UxGT("Háló Szerkesztés"); - PROGMEM Language_Str MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Egyéni Háló Szerkesztés"); - PROGMEM Language_Str MSG_UBL_FINE_TUNE_MESH = _UxGT("Finomított Háló"); - 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"); - PROGMEM Language_Str MSG_UBL_BUILD_MESH_M = _UxGT("Háló Építés ($)"); + PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("UBL Aktívál"); + PROGMEM Language_Str MSG_UBL_DEACTIVATE_MESH = _UxGT("UBL Deaktívál"); + PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = _UxGT("Ágy höfok"); + PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Ágy höfok"); + PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = _UxGT("Fúvóka höfok"); + PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Fúvóka höfok"); + PROGMEM Language_Str MSG_UBL_MESH_EDIT = _UxGT("Háló szerkesztés"); + PROGMEM Language_Str MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Egyéni háló szerkesztés"); + PROGMEM Language_Str MSG_UBL_FINE_TUNE_MESH = _UxGT("Finomított háló"); + 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"); + 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"); + 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"); PROGMEM Language_Str MSG_G26_MANUAL_PRIME = _UxGT("Kézi alapozás..."); PROGMEM Language_Str MSG_G26_FIXED_LENGTH = _UxGT("Fix hosszúságú alap"); - PROGMEM Language_Str MSG_G26_PRIME_DONE = _UxGT("Alapozás Kész"); + PROGMEM Language_Str MSG_G26_PRIME_DONE = _UxGT("Alapozás kész"); PROGMEM Language_Str MSG_G26_CANCELED = _UxGT("G26 Törölve"); PROGMEM Language_Str MSG_G26_LEAVING = _UxGT("Kilépö G26"); - PROGMEM Language_Str MSG_UBL_CONTINUE_MESH = _UxGT("Ágy Háló Folyt."); - PROGMEM Language_Str MSG_UBL_MESH_LEVELING = _UxGT("Háló Szintezés"); - PROGMEM Language_Str MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-Pontos Szintezés"); - PROGMEM Language_Str MSG_UBL_GRID_MESH_LEVELING = _UxGT("Rács Szintezés"); - PROGMEM Language_Str MSG_UBL_MESH_LEVEL = _UxGT("Háló Szint"); + PROGMEM Language_Str MSG_UBL_CONTINUE_MESH = _UxGT("Ágy háló folyt."); + PROGMEM Language_Str MSG_UBL_MESH_LEVELING = _UxGT("Háló szintezés"); + PROGMEM Language_Str MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-Pontos szintezés"); + PROGMEM Language_Str MSG_UBL_GRID_MESH_LEVELING = _UxGT("Rács szintezés"); + PROGMEM Language_Str MSG_UBL_MESH_LEVEL = _UxGT("Háló szint"); PROGMEM Language_Str MSG_UBL_SIDE_POINTS = _UxGT("Oldal pontok"); - PROGMEM Language_Str MSG_UBL_MAP_TYPE = _UxGT("Térkép Típus"); - PROGMEM Language_Str MSG_UBL_OUTPUT_MAP = _UxGT("Háló Térkép Kimenet"); - PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_HOST = _UxGT("Host Kimenet"); - PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_CSV = _UxGT("CSV Kimenet"); - PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Nyomtató Backup Ki"); - PROGMEM Language_Str MSG_UBL_INFO_UBL = _UxGT("UBL Infó Kimenet"); - PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Kitöltési Költség"); - PROGMEM Language_Str MSG_UBL_MANUAL_FILLIN = _UxGT("Kézi Kitöltés"); - PROGMEM Language_Str MSG_UBL_SMART_FILLIN = _UxGT("Okos Kitöltés"); - PROGMEM Language_Str MSG_UBL_FILLIN_MESH = _UxGT("Háló Kitöltés"); - PROGMEM Language_Str MSG_UBL_INVALIDATE_ALL = _UxGT("Minden Érvénytelen"); - PROGMEM Language_Str MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Közelebbi Érvénytelen"); - PROGMEM Language_Str MSG_UBL_FINE_TUNE_ALL = _UxGT("Mindet Finomhangolja"); - PROGMEM Language_Str MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Közelebbi Finomhangolása"); - PROGMEM Language_Str MSG_UBL_STORAGE_MESH_MENU = _UxGT("Háló Tárolás"); - PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Memória Foglalat"); - PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Ágy háló Betöltés"); - PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Ágy háló Mentés"); - PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Háló %i Betöltve"); - PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Háló %i Mentve"); + PROGMEM Language_Str MSG_UBL_MAP_TYPE = _UxGT("Térkép típus"); + PROGMEM Language_Str MSG_UBL_OUTPUT_MAP = _UxGT("Háló térkép kimenet"); + PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_HOST = _UxGT("Host kimenet"); + PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_CSV = _UxGT("CSV kimenet"); + PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Nyomtató bizt.mentés"); + PROGMEM Language_Str MSG_UBL_INFO_UBL = _UxGT("UBL Infó kimenet"); + PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Kitöltési költség"); + PROGMEM Language_Str MSG_UBL_MANUAL_FILLIN = _UxGT("Kézi kitöltés"); + PROGMEM Language_Str MSG_UBL_SMART_FILLIN = _UxGT("Okos kitöltés"); + PROGMEM Language_Str MSG_UBL_FILLIN_MESH = _UxGT("Háló kitöltés"); + PROGMEM Language_Str MSG_UBL_INVALIDATE_ALL = _UxGT("Minden érvénytelen"); + PROGMEM Language_Str MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Közelebbi érvénytelen"); + PROGMEM Language_Str MSG_UBL_FINE_TUNE_ALL = _UxGT("Mindet finomhangolja"); + PROGMEM Language_Str MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Közelebbi finomhangolása"); + PROGMEM Language_Str MSG_UBL_STORAGE_MESH_MENU = _UxGT("Háló tárolás"); + PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Memória foglalat"); + PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Ágy háló betöltés"); + PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Ágy háló mentés"); + PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Háló %i betöltve"); + PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Háló %i mentve"); PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Nincs tároló"); PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Hiba: UBL Mentés"); PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Hiba: UBL Visszaáll"); PROGMEM Language_Str MSG_UBL_Z_OFFSET = _UxGT("Z-Eltolás: "); - PROGMEM Language_Str MSG_UBL_Z_OFFSET_STOPPED = _UxGT("Z-Eltolás Leállítva"); - PROGMEM Language_Str MSG_UBL_STEP_BY_STEP_MENU = _UxGT("Lépésröl Lépésre UBL"); - PROGMEM Language_Str MSG_UBL_1_BUILD_COLD_MESH = _UxGT("1. Hideg Háló Készítés"); - PROGMEM Language_Str MSG_UBL_2_SMART_FILLIN = _UxGT("2. Inteligens Kitöltés"); - PROGMEM Language_Str MSG_UBL_3_VALIDATE_MESH_MENU = _UxGT("3. Háló Érvényesítés"); - PROGMEM Language_Str MSG_UBL_4_FINE_TUNE_ALL = _UxGT("4. Minden Finomítása"); - PROGMEM Language_Str MSG_UBL_5_VALIDATE_MESH_MENU = _UxGT("5. Háló Érvényesítés"); - PROGMEM Language_Str MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6. Minden Finomítása"); - PROGMEM Language_Str MSG_UBL_7_SAVE_MESH = _UxGT("7. Ágy Háló Mentése"); + PROGMEM Language_Str MSG_UBL_Z_OFFSET_STOPPED = _UxGT("Z-Eltolás leállítva"); + PROGMEM Language_Str MSG_UBL_STEP_BY_STEP_MENU = _UxGT("Lépésröl lépésre UBL"); + PROGMEM Language_Str MSG_UBL_1_BUILD_COLD_MESH = _UxGT("1. Hideg háló készítés"); + PROGMEM Language_Str MSG_UBL_2_SMART_FILLIN = _UxGT("2. Inteligens kitöltés"); + PROGMEM Language_Str MSG_UBL_3_VALIDATE_MESH_MENU = _UxGT("3. Háló érvényesítés"); + PROGMEM Language_Str MSG_UBL_4_FINE_TUNE_ALL = _UxGT("4. Minden finomítása"); + PROGMEM Language_Str MSG_UBL_5_VALIDATE_MESH_MENU = _UxGT("5. Háló érvényesítés"); + PROGMEM Language_Str MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6. Minden finomítása"); + PROGMEM Language_Str MSG_UBL_7_SAVE_MESH = _UxGT("7. Ágy háló mentése"); PROGMEM Language_Str MSG_LED_CONTROL = _UxGT("LED Vezérlés"); PROGMEM Language_Str MSG_LEDS = _UxGT("Világítás"); - PROGMEM Language_Str MSG_LED_PRESETS = _UxGT("Beállított Színek"); + PROGMEM Language_Str MSG_LED_PRESETS = _UxGT("Beállított színek"); PROGMEM Language_Str MSG_SET_LEDS_RED = _UxGT("Piros"); PROGMEM Language_Str MSG_SET_LEDS_ORANGE = _UxGT("Narancs"); PROGMEM Language_Str MSG_SET_LEDS_YELLOW = _UxGT("Sárga"); @@ -225,14 +234,14 @@ namespace Language_hu { 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_LEDS2 = _UxGT("LED-ek #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"); - PROGMEM Language_Str MSG_INTENSITY_B = _UxGT("Kék Intenzitás"); - PROGMEM Language_Str MSG_INTENSITY_W = _UxGT("Fehér Intenzitás"); + 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"); + PROGMEM Language_Str MSG_INTENSITY_B = _UxGT("Kék intenzitás"); + PROGMEM Language_Str MSG_INTENSITY_W = _UxGT("Fehér intenzitás"); PROGMEM Language_Str MSG_LED_BRIGHTNESS = _UxGT("Fényerö"); PROGMEM Language_Str MSG_MOVING = _UxGT("Mozgás..."); @@ -243,27 +252,30 @@ 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_Z_DIST = _UxGT("Mozgás %smm"); + PROGMEM Language_Str MSG_MOVE_N_MM = _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"); + PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Mozgás 0.001mm"); + PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Mozgás 0.01mm"); + PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Mozgás 0.1mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Sebesség"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Z ágy"); PROGMEM Language_Str MSG_NOZZLE = _UxGT("Fúvóka"); PROGMEM Language_Str MSG_NOZZLE_N = _UxGT("Fúvóka ~"); - PROGMEM Language_Str MSG_NOZZLE_PARKED = _UxGT("Fej Parkolva"); - PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Fej Készenlétbe"); + PROGMEM Language_Str MSG_NOZZLE_PARKED = _UxGT("Fej parkolva"); + PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Fej készenlétbe"); PROGMEM Language_Str MSG_BED = _UxGT("Ágy"); PROGMEM Language_Str MSG_CHAMBER = _UxGT("Burkolat"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Hütés sebesség"); PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Hütés sebesség ="); - PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Tárolt Hütés ="); + PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Tárolt hütés ="); PROGMEM Language_Str MSG_EXTRA_FAN_SPEED = _UxGT("Extra hütés sebesség"); PROGMEM Language_Str MSG_EXTRA_FAN_SPEED_N = _UxGT("Extra hütés sebesség ="); PROGMEM Language_Str MSG_CONTROLLER_FAN = _UxGT("Hűtésvezérlés"); PROGMEM Language_Str MSG_CONTROLLER_FAN_IDLE_SPEED = _UxGT("Alapjárat"); - PROGMEM Language_Str MSG_CONTROLLER_FAN_AUTO_ON = _UxGT("Automatikus Mód"); - PROGMEM Language_Str MSG_CONTROLLER_FAN_SPEED = _UxGT("Aktív Sebesség"); + PROGMEM Language_Str MSG_CONTROLLER_FAN_AUTO_ON = _UxGT("Automatikus mód"); + PROGMEM Language_Str MSG_CONTROLLER_FAN_SPEED = _UxGT("Aktív sebesség"); PROGMEM Language_Str MSG_CONTROLLER_FAN_DURATION = _UxGT("Készenlét"); PROGMEM Language_Str MSG_FLOW = _UxGT("Folyás"); PROGMEM Language_Str MSG_FLOW_N = _UxGT("Folyás ~"); @@ -271,13 +283,13 @@ namespace Language_hu { PROGMEM Language_Str MSG_MIN = " " LCD_STR_THERMOMETER _UxGT(" Minimum"); PROGMEM Language_Str MSG_MAX = " " LCD_STR_THERMOMETER _UxGT(" Maximum"); PROGMEM Language_Str MSG_FACTOR = " " LCD_STR_THERMOMETER _UxGT(" Tényezö"); - PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Automata Höfok"); + PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Automata höfok"); PROGMEM Language_Str MSG_LCD_ON = _UxGT("Be"); PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Ki"); PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("PID Hangolás"); PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("PID Hangolás *"); - PROGMEM Language_Str MSG_PID_AUTOTUNE_DONE = _UxGT("PID hangolás kész"); - PROGMEM Language_Str MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Hangolási hiba. Rossz Adagoló."); + PROGMEM Language_Str MSG_PID_AUTOTUNE_DONE = _UxGT("PID Hangolás kész"); + PROGMEM Language_Str MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Hangolási hiba. Rossz adagoló."); PROGMEM Language_Str MSG_PID_TEMP_TOO_HIGH = _UxGT("Hangolási hiba. Magas hömérséklet."); PROGMEM Language_Str MSG_PID_TIMEOUT = _UxGT("Hangolási hiba! Idötúllépés."); PROGMEM Language_Str MSG_SELECT = _UxGT("Kiválaszt"); @@ -288,25 +300,25 @@ namespace Language_hu { PROGMEM Language_Str MSG_VB_JERK = LCD_STR_B _UxGT(" Ránt. Seb."); PROGMEM Language_Str MSG_VC_JERK = LCD_STR_C _UxGT(" Ránt. Seb."); PROGMEM Language_Str MSG_VE_JERK = _UxGT("E Ránt. Seb."); - PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Csomopont Eltérés"); + PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Csomopont eltérés"); PROGMEM Language_Str MSG_VELOCITY = _UxGT("Sebesség"); - PROGMEM Language_Str MSG_VMAX_A = _UxGT("Max Sebesség ") LCD_STR_A; - PROGMEM Language_Str MSG_VMAX_B = _UxGT("Max Sebesség ") LCD_STR_B; - PROGMEM Language_Str MSG_VMAX_C = _UxGT("Max Sebesség ") LCD_STR_C; - PROGMEM Language_Str MSG_VMAX_E = _UxGT("Max Sebesség ") LCD_STR_E; - PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Max Sebesség *"); - PROGMEM Language_Str MSG_VMIN = _UxGT("Min Sebesség"); - PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Min Utazó.seb."); + PROGMEM Language_Str MSG_VMAX_A = _UxGT("Max sebesség ") LCD_STR_A; + PROGMEM Language_Str MSG_VMAX_B = _UxGT("Max sebesség ") LCD_STR_B; + PROGMEM Language_Str MSG_VMAX_C = _UxGT("Max sebesség ") LCD_STR_C; + PROGMEM Language_Str MSG_VMAX_E = _UxGT("Max sebesség ") LCD_STR_E; + PROGMEM Language_Str MSG_VMAX_EN = _UxGT("Max sebesség *"); + PROGMEM Language_Str MSG_VMIN = _UxGT("Min sebesség"); + PROGMEM Language_Str MSG_VTRAV_MIN = _UxGT("Min utazó.seb."); PROGMEM Language_Str MSG_ACCELERATION = _UxGT("Gyorsulás"); - PROGMEM Language_Str MSG_AMAX_A = _UxGT("Max Gyors. ") LCD_STR_A; - PROGMEM Language_Str MSG_AMAX_B = _UxGT("Max Gyors. ") LCD_STR_B; - PROGMEM Language_Str MSG_AMAX_C = _UxGT("Max Gyors. ") LCD_STR_C; - PROGMEM Language_Str MSG_AMAX_E = _UxGT("Max Gyors. ") LCD_STR_E; - PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Max Gyorsulás *"); + PROGMEM Language_Str MSG_AMAX_A = _UxGT("Max gyors. ") LCD_STR_A; + PROGMEM Language_Str MSG_AMAX_B = _UxGT("Max gyors. ") LCD_STR_B; + PROGMEM Language_Str MSG_AMAX_C = _UxGT("Max gyors. ") LCD_STR_C; + PROGMEM Language_Str MSG_AMAX_E = _UxGT("Max gyors. ") LCD_STR_E; + PROGMEM Language_Str MSG_AMAX_EN = _UxGT("Max gyorsulás *"); PROGMEM Language_Str MSG_A_RETRACT = _UxGT("Visszahúzás"); PROGMEM Language_Str MSG_A_TRAVEL = _UxGT("Utazás"); - PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("Max Frekvencia"); - PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min Elötolás"); + PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("Max frekvencia"); + PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min elötolás"); PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("Lépés/mm"); PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" lépés/mm"); PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" lépés/mm"); @@ -325,7 +337,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_FILAMENT_LOAD = _UxGT("Betöltés mm"); PROGMEM Language_Str MSG_ADVANCE_K = _UxGT("Haladó K"); PROGMEM Language_Str MSG_ADVANCE_K_E = _UxGT("Haladó K *"); - PROGMEM Language_Str MSG_CONTRAST = _UxGT("LCD kontraszt"); + PROGMEM Language_Str MSG_CONTRAST = _UxGT("LCD Kontraszt"); PROGMEM Language_Str MSG_STORE_EEPROM = _UxGT("Mentés EEPROM"); PROGMEM Language_Str MSG_LOAD_EEPROM = _UxGT("Betöltés EEPROM"); PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("Alapértelmezett"); @@ -333,9 +345,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_ERR_EEPROM_CRC = _UxGT("Hiba: EEPROM CRC"); PROGMEM Language_Str MSG_ERR_EEPROM_INDEX = _UxGT("Hiba: EEPROM Index"); PROGMEM Language_Str MSG_ERR_EEPROM_VERSION = _UxGT("Hiba: EEPROM Verzió"); - PROGMEM Language_Str MSG_SETTINGS_STORED = _UxGT("Beállítások Mentve"); - PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Tároló Frissítés"); - PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Nyomtató Újraindítása"); + PROGMEM Language_Str MSG_SETTINGS_STORED = _UxGT("Beállítások mentve"); + PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Tároló frissítés"); + PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Nyomtató újraindítása"); PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT("Frissítés"); PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT(""); PROGMEM Language_Str MSG_PREPARE = _UxGT("Vezérlés"); @@ -344,7 +356,7 @@ namespace Language_hu { 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_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"); @@ -355,23 +367,25 @@ namespace Language_hu { PROGMEM Language_Str MSG_BUTTON_DONE = _UxGT("Kész"); PROGMEM Language_Str MSG_BUTTON_BACK = _UxGT("Vissza"); PROGMEM Language_Str MSG_BUTTON_PROCEED = _UxGT("Folytatás"); + PROGMEM Language_Str MSG_BUTTON_SKIP = _UxGT("Kihagy"); PROGMEM Language_Str MSG_PAUSING = _UxGT("Szüneteltetve..."); - PROGMEM Language_Str MSG_PAUSE_PRINT = _UxGT("Nyomtatás Szünetelés"); + 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"); - PROGMEM Language_Str MSG_CANCEL_OBJECT_N = _UxGT("Objektum Törlése ="); - PROGMEM Language_Str MSG_OUTAGE_RECOVERY = _UxGT("Kiesés Helyreáll."); - PROGMEM Language_Str MSG_MEDIA_MENU = _UxGT("Nyomtatás Tárolóról"); - PROGMEM Language_Str MSG_NO_MEDIA = _UxGT("Nincs Tároló"); + PROGMEM Language_Str MSG_END_LOOPS = _UxGT("Hurok ismétlés vége"); + PROGMEM Language_Str MSG_PRINTING_OBJECT = _UxGT("Objektum nyomtatása"); + PROGMEM Language_Str MSG_CANCEL_OBJECT = _UxGT("Objektum törlése"); + PROGMEM Language_Str MSG_CANCEL_OBJECT_N = _UxGT("Objektum törlése ="); + PROGMEM Language_Str MSG_OUTAGE_RECOVERY = _UxGT("Kiesés helyreáll."); + PROGMEM Language_Str MSG_MEDIA_MENU = _UxGT("Nyomtatás tárolóról"); + PROGMEM Language_Str MSG_NO_MEDIA = _UxGT("Nincs tároló"); PROGMEM Language_Str MSG_DWELL = _UxGT("Alvás..."); PROGMEM Language_Str MSG_USERWAIT = _UxGT("Katt a folytatáshoz..."); PROGMEM Language_Str MSG_PRINT_PAUSED = _UxGT("Nyomtatás szünetelve"); PROGMEM Language_Str MSG_PRINTING = _UxGT("Nyomtatás..."); PROGMEM Language_Str MSG_PRINT_ABORTED = _UxGT("Nyomtatás leállítva"); - PROGMEM Language_Str MSG_PRINT_DONE = _UxGT("Nyomtatás Kész"); + PROGMEM Language_Str MSG_PRINT_DONE = _UxGT("Nyomtatás kész"); PROGMEM Language_Str MSG_NO_MOVE = _UxGT("Nincs mozgás."); PROGMEM Language_Str MSG_KILLED = _UxGT("HALOTT! "); PROGMEM Language_Str MSG_STOPPED = _UxGT("MEGÁLLT! "); @@ -381,25 +395,25 @@ 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("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"); - PROGMEM Language_Str MSG_FILAMENT_PURGE_LENGTH = _UxGT("Tisztítási Távolság"); + PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Visszahúzás V"); + PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAPF = _UxGT("S Vissza.h V"); + PROGMEM Language_Str MSG_AUTORETRACT = _UxGT("Auto Visszah."); + PROGMEM Language_Str MSG_FILAMENT_SWAP_LENGTH = _UxGT("Visszahúzás távolság"); + PROGMEM Language_Str MSG_FILAMENT_SWAP_EXTRA = _UxGT("Extra csere"); + PROGMEM Language_Str MSG_FILAMENT_PURGE_LENGTH = _UxGT("Tisztítási távolság"); PROGMEM Language_Str MSG_TOOL_CHANGE = _UxGT("Szerszámcsere"); PROGMEM Language_Str MSG_TOOL_CHANGE_ZLIFT = _UxGT("Z Emelés"); PROGMEM Language_Str MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Fösebesség"); PROGMEM Language_Str MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Visszah. Sebesség"); - PROGMEM Language_Str MSG_FILAMENT_PARK_ENABLED = _UxGT("Fej Parkolás"); - PROGMEM Language_Str MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Visszahúzás Sebesség"); + PROGMEM Language_Str MSG_FILAMENT_PARK_ENABLED = _UxGT("Fej parkolás"); + PROGMEM Language_Str MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Visszav.visszah. sebesség"); PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("FAN Sebesség"); PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_TIME = _UxGT("FAN idö"); PROGMEM Language_Str MSG_TOOL_MIGRATION_ON = _UxGT("Auto BE"); PROGMEM Language_Str MSG_TOOL_MIGRATION_OFF = _UxGT("Auto KI"); PROGMEM Language_Str MSG_TOOL_MIGRATION = _UxGT("Szerszámcsere"); - PROGMEM Language_Str MSG_TOOL_MIGRATION_AUTO = _UxGT("Automata Csere"); - PROGMEM Language_Str MSG_TOOL_MIGRATION_END = _UxGT("Utolsó Adagoló"); + PROGMEM Language_Str MSG_TOOL_MIGRATION_AUTO = _UxGT("Automata csere"); + PROGMEM Language_Str MSG_TOOL_MIGRATION_END = _UxGT("Utolsó adagoló"); PROGMEM Language_Str MSG_TOOL_MIGRATION_SWAP = _UxGT("Csere *"); PROGMEM Language_Str MSG_FILAMENTCHANGE = _UxGT("Szál csere"); PROGMEM Language_Str MSG_FILAMENTCHANGE_E = _UxGT("Szál csere *"); @@ -407,12 +421,12 @@ namespace Language_hu { PROGMEM Language_Str MSG_FILAMENTLOAD_E = _UxGT("Szál betöltés *"); PROGMEM Language_Str MSG_FILAMENTUNLOAD = _UxGT("Szál eltávolítás"); PROGMEM Language_Str MSG_FILAMENTUNLOAD_E = _UxGT("Szál eltávolítás *"); - PROGMEM Language_Str MSG_FILAMENTUNLOAD_ALL = _UxGT("Mindet Eltávolít"); + PROGMEM Language_Str MSG_FILAMENTUNLOAD_ALL = _UxGT("Mindet eltávolít"); PROGMEM Language_Str MSG_ATTACH_MEDIA = _UxGT("Tároló"); PROGMEM Language_Str MSG_CHANGE_MEDIA = _UxGT("Tároló csere"); PROGMEM Language_Str MSG_RELEASE_MEDIA = _UxGT("Tároló Kiadása"); PROGMEM Language_Str MSG_ZPROBE_OUT = _UxGT("Z szonda tálcán kivül"); - PROGMEM Language_Str MSG_SKEW_FACTOR = _UxGT("Ferdeség Faktor"); + PROGMEM Language_Str MSG_SKEW_FACTOR = _UxGT("Ferdeség faktor"); PROGMEM Language_Str MSG_BLTOUCH = _UxGT("BLTouch"); PROGMEM Language_Str MSG_BLTOUCH_SELFTEST = _UxGT("Önteszt"); PROGMEM Language_Str MSG_BLTOUCH_RESET = _UxGT("Visszaállítás"); @@ -428,16 +442,16 @@ 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 Offset Teszt"); + PROGMEM Language_Str MSG_TOUCHMI_ZTEST = _UxGT("Z Eltolás 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-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_MANUAL_DEPLOY_TOUCHMI = _UxGT("TouchMI használ"); + 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("X Szonda eltolás"); + PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Y Szonda eltolás"); + PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Z Szonda 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"); @@ -464,31 +478,31 @@ namespace Language_hu { 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ó"); + PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Delta kalibráció"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("X Kalibrálás"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Y Kalibrálás"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_Z = _UxGT("Z Kalibrálás"); - PROGMEM Language_Str MSG_DELTA_CALIBRATE_CENTER = _UxGT("Központ Kalibrálás"); - PROGMEM Language_Str MSG_DELTA_SETTINGS = _UxGT("Delta Beállítások"); - PROGMEM Language_Str MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto Kalibráció"); - PROGMEM Language_Str MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Delta Magasság Kalib."); - PROGMEM Language_Str MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Z Szonda Eltolás"); - PROGMEM Language_Str MSG_DELTA_DIAG_ROD = _UxGT("Diag Rúd"); + PROGMEM Language_Str MSG_DELTA_CALIBRATE_CENTER = _UxGT("Központ kalibrálás"); + PROGMEM Language_Str MSG_DELTA_SETTINGS = _UxGT("Delta beállítások"); + PROGMEM Language_Str MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto kalibráció"); + PROGMEM Language_Str MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Delta magasság kalib."); + PROGMEM Language_Str MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Z Eltolás"); + PROGMEM Language_Str MSG_DELTA_DIAG_ROD = _UxGT("Diag rúd"); PROGMEM Language_Str MSG_DELTA_HEIGHT = _UxGT("Magasság"); PROGMEM Language_Str MSG_DELTA_RADIUS = _UxGT("Sugár"); PROGMEM Language_Str MSG_INFO_MENU = _UxGT("A Nyomtatóról"); - PROGMEM Language_Str MSG_INFO_PRINTER_MENU = _UxGT("Nyomtató Infó"); - PROGMEM Language_Str MSG_3POINT_LEVELING = _UxGT("3-Pontos Szintezés"); - PROGMEM Language_Str MSG_LINEAR_LEVELING = _UxGT("Lineáris Szintezés"); - PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Bilineáris Szintezés"); - PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Egységes Ágy Szintezés"); - PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Háló Szintezés"); + PROGMEM Language_Str MSG_INFO_PRINTER_MENU = _UxGT("Nyomtató infó"); + PROGMEM Language_Str MSG_3POINT_LEVELING = _UxGT("3-Pontos szintezés"); + PROGMEM Language_Str MSG_LINEAR_LEVELING = _UxGT("Lineáris szintezés"); + PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Bilineáris szintezés"); + PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Egységes ágy szintezés"); + PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Háló szintezés"); PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Statisztikák"); - PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Alaplap Infó"); + PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Alaplap infó"); PROGMEM Language_Str MSG_INFO_THERMISTOR_MENU = _UxGT("Termisztorok"); PROGMEM Language_Str MSG_INFO_EXTRUDERS = _UxGT("Adagolók"); PROGMEM Language_Str MSG_INFO_BAUDRATE = _UxGT("Átviteli sebesség"); - PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Protokoll"); + PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Protokol"); 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."); @@ -498,7 +512,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_KILL_EXPECTED_PRINTER = _UxGT("HELYTELEN NYOMTATÓ"); #if LCD_WIDTH >= 20 - PROGMEM Language_Str MSG_INFO_PRINT_COUNT = _UxGT("Nyomtatás Számláló"); + PROGMEM Language_Str MSG_INFO_PRINT_COUNT = _UxGT("Nyomtatás számláló"); PROGMEM Language_Str MSG_INFO_COMPLETED_PRINTS = _UxGT("Befejezett"); PROGMEM Language_Str MSG_INFO_PRINT_TIME = _UxGT("Összes nyomtatási idö"); PROGMEM Language_Str MSG_INFO_PRINT_LONGEST = _UxGT("Leghosszabb munkaidö"); @@ -511,16 +525,16 @@ namespace Language_hu { PROGMEM Language_Str MSG_INFO_PRINT_FILAMENT = _UxGT("Kiadott"); #endif - PROGMEM Language_Str MSG_INFO_MIN_TEMP = _UxGT("Min Höfok"); - PROGMEM Language_Str MSG_INFO_MAX_TEMP = _UxGT("Max Höfok"); + PROGMEM Language_Str MSG_INFO_MIN_TEMP = _UxGT("Min höfok"); + PROGMEM Language_Str MSG_INFO_MAX_TEMP = _UxGT("Max höfok"); PROGMEM Language_Str MSG_INFO_PSU = _UxGT("PSU"); - PROGMEM Language_Str MSG_DRIVE_STRENGTH = _UxGT("Meghajtási Erö"); + PROGMEM Language_Str MSG_DRIVE_STRENGTH = _UxGT("Meghajtási erö"); PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X Meghajtó %"); PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y Meghajtó %"); PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z Meghajtó %"); PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E Meghajtó %"); PROGMEM Language_Str MSG_ERROR_TMC = _UxGT("TMC CSATLAKOZÁSI HIBA"); - PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Írása"); + PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM írása"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEADER = _UxGT("NYOMTATÓSZÁL CSERE"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("NYOMTATÁS SZÜNETEL"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEADER_LOAD = _UxGT("SZÁL BETÖLTÉS"); @@ -529,22 +543,22 @@ namespace Language_hu { PROGMEM Language_Str MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Tisztítsd meg"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Folytatás"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Fúvóka: "); - PROGMEM Language_Str MSG_RUNOUT_SENSOR = _UxGT("Túlfutás Szenzor"); - PROGMEM Language_Str MSG_RUNOUT_DISTANCE_MM = _UxGT("Túlfutás Táv. mm"); + PROGMEM Language_Str MSG_RUNOUT_SENSOR = _UxGT("Túlfutás szenzor"); + PROGMEM Language_Str MSG_RUNOUT_DISTANCE_MM = _UxGT("Túlfutás táv. mm"); PROGMEM Language_Str MSG_KILL_HOMING_FAILED = _UxGT("Tájolási hiba"); PROGMEM Language_Str MSG_LCD_PROBING_FAILED = _UxGT("Szondázás hiba"); PROGMEM Language_Str MSG_MMU2_CHOOSE_FILAMENT_HEADER = _UxGT("SZÁLVÁLASZTÁS"); PROGMEM Language_Str MSG_MMU2_MENU = _UxGT("MMU"); - PROGMEM Language_Str MSG_KILL_MMU2_FIRMWARE = _UxGT("MMU Szoftver Feltöltése!"); + PROGMEM Language_Str MSG_KILL_MMU2_FIRMWARE = _UxGT("MMU Szoftver feltöltése!"); PROGMEM Language_Str MSG_MMU2_NOT_RESPONDING = _UxGT("MMU Figyelmeztetés."); - PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("Nyomtatás Folytatása"); + PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("Nyomtatás folytatása"); PROGMEM Language_Str MSG_MMU2_RESUMING = _UxGT("Folytatás..."); - PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("Szál Betöltése"); - PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("Összes Betöltése"); - PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("Fúvóka Betöltése"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("Szál Kiadása"); - PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Szál Kiadása ~"); + PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("Szál betöltése"); + PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("Összes betöltése"); + PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("Fúvóka betöltése"); + PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("Szál kiadása"); + PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Szál kiadása ~"); PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("Kiadja a szálat"); PROGMEM Language_Str MSG_MMU2_LOADING_FILAMENT = _UxGT("Szál betölt. %i..."); PROGMEM Language_Str MSG_MMU2_EJECTING_FILAMENT = _UxGT("Szál kiadás...."); @@ -559,11 +573,11 @@ namespace Language_hu { PROGMEM Language_Str MSG_MIX_COMPONENT_N = _UxGT("Összetevö ="); PROGMEM Language_Str MSG_MIXER = _UxGT("Keverö"); PROGMEM Language_Str MSG_GRADIENT = _UxGT("Színátm."); - PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Teljes Színátm."); - PROGMEM Language_Str MSG_TOGGLE_MIX = _UxGT("Váltás Keverésre"); - PROGMEM Language_Str MSG_CYCLE_MIX = _UxGT("Ciklikus Keverés"); - PROGMEM Language_Str MSG_GRADIENT_MIX = _UxGT("Színátm. Keverés"); - PROGMEM Language_Str MSG_REVERSE_GRADIENT = _UxGT("Fordított Színátm."); + PROGMEM Language_Str MSG_FULL_GRADIENT = _UxGT("Teljes színátm."); + PROGMEM Language_Str MSG_TOGGLE_MIX = _UxGT("Váltás keverésre"); + PROGMEM Language_Str MSG_CYCLE_MIX = _UxGT("Ciklikus keverés"); + PROGMEM Language_Str MSG_GRADIENT_MIX = _UxGT("Színátm. keverés"); + PROGMEM Language_Str MSG_REVERSE_GRADIENT = _UxGT("Fordított színátm."); PROGMEM Language_Str MSG_ACTIVE_VTOOL = _UxGT("Aktív V-szerszám"); PROGMEM Language_Str MSG_START_VTOOL = _UxGT("Kezdés V-szerszám"); PROGMEM Language_Str MSG_END_VTOOL = _UxGT(" Vége V-szerszám"); @@ -591,7 +605,7 @@ namespace Language_hu { 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_REMINDER_SAVE_SETTINGS = _UxGT("Mentsd el!"); PROGMEM Language_Str MSG_PASSWORD_REMOVED = _UxGT("Jelszó törölve"); // @@ -613,7 +627,7 @@ namespace Language_hu { #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...")); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_INIT = _UxGT(MSG_1_LINE("Kérlek Várj...")); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_INIT = _UxGT(MSG_1_LINE("Kérlek várj...")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_INSERT = _UxGT(MSG_1_LINE("Behelyez majd katt")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEAT = _UxGT(MSG_1_LINE("Katt a fűtéshez")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEATING = _UxGT(MSG_1_LINE("Fűtés...")); @@ -625,10 +639,10 @@ namespace Language_hu { #endif PROGMEM Language_Str MSG_TMC_DRIVERS = _UxGT("TMC Meghajtók"); PROGMEM Language_Str MSG_TMC_CURRENT = _UxGT("Meghajtó áram"); - PROGMEM Language_Str MSG_TMC_HYBRID_THRS = _UxGT("Hibrid Küszöbérték"); - PROGMEM Language_Str MSG_TMC_HOMING_THRS = _UxGT("Motoros Kezdöpont"); - PROGMEM Language_Str MSG_TMC_STEPPING_MODE = _UxGT("Léptetö Mód"); - PROGMEM Language_Str MSG_TMC_STEALTH_ENABLED = _UxGT("StealthChop Mód"); + PROGMEM Language_Str MSG_TMC_HYBRID_THRS = _UxGT("Hibrid küszöbérték"); + PROGMEM Language_Str MSG_TMC_HOMING_THRS = _UxGT("Motoros kezdöpont"); + PROGMEM Language_Str MSG_TMC_STEPPING_MODE = _UxGT("Léptetö mód"); + PROGMEM Language_Str MSG_TMC_STEALTH_ENABLED = _UxGT("StealthChop mód"); PROGMEM Language_Str MSG_SERVICE_RESET = _UxGT("Újraindítás"); PROGMEM Language_Str MSG_SERVICE_IN = _UxGT(" be:"); PROGMEM Language_Str MSG_BACKLASH = _UxGT("Holtjáték"); @@ -649,6 +663,17 @@ namespace Language_hu { PROGMEM Language_Str MSG_REHEATING = _UxGT("Újrafűtés..."); PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Szonda varázsló"); + PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING = _UxGT("Z Referencia mérés"); + PROGMEM Language_Str MSG_PROBE_WIZARD_MOVING = _UxGT("Menjen a próba pontra"); + + PROGMEM Language_Str MSG_SOUND = _UxGT("Hang"); + + PROGMEM Language_Str MSG_TOP_LEFT = _UxGT("Bal felsö"); + PROGMEM Language_Str MSG_BOTTOM_LEFT = _UxGT("Bal alsó"); + PROGMEM Language_Str MSG_TOP_RIGHT = _UxGT("Jobb felsö"); + PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Jobb alsó"); + PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Kalibrálás befejezve"); + PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Kalibrálási hiba"); } #if FAN_COUNT == 1 From 2c5967925f5a09db2522d1611efd225dbd3990dd Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sat, 6 Mar 2021 01:50:26 -0800 Subject: [PATCH 005/311] Pins/tests followup (#21268) Missing commit from #21254 Co-authored-by: Scott Lahteine --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 4 ++++ Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h | 3 +++ Marlin/src/pins/ramps/pins_RAMPS.h | 3 +++ Marlin/src/pins/ramps/pins_RAMPS_S_12.h | 3 +++ .../scripts/common-dependencies-post.py | 16 ++++++++++++++++ platformio.ini | 7 +------ 6 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 buildroot/share/PlatformIO/scripts/common-dependencies-post.py diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index c555ef7863..94165d3948 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -27,6 +27,10 @@ #define BOARD_INFO_NAME "BTT SKR V1.4" #endif +#ifndef BOARD_CUSTOM_BUILD_FLAGS + #define BOARD_CUSTOM_BUILD_FLAGS -DLPC_PINCFG_UART3_P4_28 +#endif + // // SD Connection // diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index 2fd599e619..5ff3b366be 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -43,6 +43,9 @@ #warning "Serial 3 is originally reserved to Y limit switches. Hardware changes are required to use it." #endif +// Custom flags and defines for the build +//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ + #define BOARD_INFO_NAME "LGT KIT V1.0" // diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index f56a9ec38e..805c92d71a 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -47,6 +47,9 @@ #include "env_validate.h" +// Custom flags and defines for the build +//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ + #ifndef BOARD_INFO_NAME #define BOARD_INFO_NAME "RAMPS 1.4" #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h index 62b6e3ff94..e1ba91cde8 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h @@ -36,6 +36,9 @@ #include "env_validate.h" +// Custom flags and defines for the build +//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ + #ifndef BOARD_INFO_NAME #define BOARD_INFO_NAME "RAMPS S 1.2" #endif diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies-post.py b/buildroot/share/PlatformIO/scripts/common-dependencies-post.py new file mode 100644 index 0000000000..2b1b948119 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/common-dependencies-post.py @@ -0,0 +1,16 @@ +# +# common-dependencies-post.py +# Convenience script to add build flags for Marlin Enabled Features +# + +Import("env") +Import("projenv") + +def apply_board_build_flags(): + if not 'BOARD_CUSTOM_BUILD_FLAGS' in env['MARLIN_FEATURES']: + return + projenv.Append(CCFLAGS=env['MARLIN_FEATURES']['BOARD_CUSTOM_BUILD_FLAGS'].split()) + +# We need to add the board build flags in a post script +# so the platform build script doesn't overwrite the custom CCFLAGS +apply_board_build_flags() diff --git a/platformio.ini b/platformio.ini index 0ed883ba0d..aad59362cc 100644 --- a/platformio.ini +++ b/platformio.ini @@ -215,6 +215,7 @@ extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py pre:buildroot/share/PlatformIO/scripts/preflight-checks.py + post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants lib_deps = @@ -727,12 +728,6 @@ platform = ${common_LPC.platform} extends = common_LPC board = nxp_lpc1769 -# BTT SKR 1.4 needs a UART3 tweak -[env:LPC1768_btt_skr_v1_4] -platform = ${env:LPC1768.platform} -extends = env:LPC1768 -build_flags = ${env:LPC1768.build_flags} -DLPC_PINCFG_UART3_P4_28 - ################################# # # # STM32 Architecture # From 43b712d42b14014eeb820e6f38285a64e7b872db Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 6 Mar 2021 06:57:51 -0600 Subject: [PATCH 006/311] Pins/tests followup --- Marlin/src/pins/pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 55240021fa..b8cf695fb5 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -378,7 +378,7 @@ #elif MB(BTT_SKR_V1_3) #include "lpc1768/pins_BTT_SKR_V1_3.h" // LPC1768 env:LPC1768 #elif MB(BTT_SKR_V1_4) - #include "lpc1768/pins_BTT_SKR_V1_4.h" // LPC1768 env:LPC1768_btt_skr_v1_4 + #include "lpc1768/pins_BTT_SKR_V1_4.h" // LPC1768 env:LPC1768 // // LPC1769 ARM Cortex M3 From a94fa7b4768d3e7a5ab6c580de96160f697753db Mon Sep 17 00:00:00 2001 From: ellensp Date: Sun, 7 Mar 2021 02:19:15 +1300 Subject: [PATCH 007/311] Fix Creality DWIN - Broken (bool)Serial ? (#21272) Co-authored-by: ellensp --- Marlin/src/lcd/dwin/dwin_lcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/dwin/dwin_lcd.cpp b/Marlin/src/lcd/dwin/dwin_lcd.cpp index 1978c6a4f8..59bc46925a 100644 --- a/Marlin/src/lcd/dwin/dwin_lcd.cpp +++ b/Marlin/src/lcd/dwin/dwin_lcd.cpp @@ -95,7 +95,7 @@ bool DWIN_Handshake(void) { #endif LCD_SERIAL.begin(LCD_BAUDRATE); const millis_t serial_connect_timeout = millis() + 1000UL; - while (!LCD_SERIAL && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } size_t i = 0; DWIN_Byte(i, 0x00); From 72cc5a49e6fdcf7246b6bded66a4b4fc043054a3 Mon Sep 17 00:00:00 2001 From: Sola <42537573+solawc@users.noreply.github.com> Date: Sat, 6 Mar 2021 23:04:05 +0800 Subject: [PATCH 008/311] MKS H43 fixup (#21267) Co-authored-by: makerbase <4164049@qq.com> Co-authored-by: MKS-Sean <56996910+MKS-Sean@users.noreply.github.com> Co-authored-by: Scott Lahteine --- Marlin/src/gcode/queue.cpp | 8 +++ Marlin/src/gcode/queue.h | 9 ++- .../lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 9 ++- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 2 +- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.h | 6 +- .../extui/lib/dgus/mks/DGUSScreenHandler.cpp | 48 +++++++------- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 22 +++---- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 18 ++--- .../extui/lib/mks_ui/draw_filament_change.cpp | 34 +++++----- .../lcd/extui/lib/mks_ui/draw_operation.cpp | 4 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 65 +++++++++---------- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 4 +- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 8 +-- Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 6 +- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 14 ++-- 17 files changed, 139 insertions(+), 122 deletions(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 93deac0566..136293fd34 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -610,6 +610,14 @@ void GCodeQueue::get_available_commands() { TERN_(SDSUPPORT, get_sdcard_commands()); } +/** + * Run the entire queue in-place. Blocks SD completion/abort until complete. + */ +void GCodeQueue::exhaust() { + while (ring_buffer.occupied()) advance(); + planner.synchronize(); +} + /** * Get the next command in the queue, optionally log it to SD, then dispatch it */ diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 7bc3bfdbe5..4757b8c37e 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -93,7 +93,9 @@ public: inline bool full(uint8_t cmdCount=1) const { return length > (BUFSIZE - cmdCount); } - inline bool empty() const { return length == 0; } + inline bool occupied() const { return length != 0; } + + inline bool empty() const { return !occupied(); } inline CommandLine& peek_next_command() { return commands[index_r]; } @@ -162,6 +164,11 @@ public: */ static void advance(); + /** + * Run the entire queue in-place + */ + static void exhaust(); + /** * Add to the circular command queue the next command from: * - The command-injection queue (injected_commands_P) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index 9b0c329de2..180c895809 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -395,20 +395,23 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va default: return; #if HOTENDS >= 1 case VP_T_E0_Set: + NOMORE(newvalue, HEATER_0_MAXTEMP); thermalManager.setTargetHotend(newvalue, 0); - acceptedvalue = thermalManager.temp_hotend[0].target; + acceptedvalue = thermalManager.degTargetHotend(0); break; #endif #if HOTENDS >= 2 case VP_T_E1_Set: + NOMORE(newvalue, HEATER_1_MAXTEMP); thermalManager.setTargetHotend(newvalue, 1); - acceptedvalue = thermalManager.temp_hotend[1].target; + acceptedvalue = thermalManager.degTargetHotend(1); break; #endif #if HAS_HEATED_BED case VP_T_Bed_Set: + NOMORE(newvalue, BED_MAXTEMP); thermalManager.setTargetBed(newvalue); - acceptedvalue = thermalManager.temp_bed.target; + acceptedvalue = thermalManager.degTargetBed(); break; #endif } diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index 14b7394aaa..bfa518446d 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -75,7 +75,7 @@ uint16_t z_park_pos = 10; xyz_pos_t position_before_pause; void MKS_pause_print_move() { - planner.synchronize(); + queue.exhaust(); position_before_pause = current_position; do_blocking_move_to(X_MIN_POS + x_park_pos, Y_MIN_POS + y_park_pos, current_position.z + z_park_pos); } diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h index 47695edf0f..c8915a3d25 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h @@ -23,10 +23,10 @@ #include "../DGUSDisplayDef.h" -//#define USE_MKS_GREEN_UI +#define USE_MKS_GREEN_UI //#define DGUS_MKS_RUNOUT_SENSOR -#define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 5000, 1500) +#define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 8000, 1500) #if ENABLED(DGUS_MKS_RUNOUT_SENSOR) #define MT_DET_1_PIN 1 @@ -178,7 +178,7 @@ enum DGUSLCD_Screens : uint8_t { MKSLCD_SCREEN_PRINT_CONFIG = 72, MKSLCD_SCREEN_LEVEL_DATA = 106, MKSLCD_PrintPause_SET = 107, - //MKSLCD_FILAMENT_DATA = 50, + MKSLCD_FILAMENT_DATA = 50, MKSLCD_ABOUT = 83, MKSLCD_PID = 108, MKSLCD_PAUSE_SETTING_MOVE = 98, diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index 9fc56acf10..577171a135 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -39,6 +39,7 @@ #include "../../../../../gcode/gcode.h" #include "../../../../../pins/pins.h" #include "../../../../../libs/nozzle.h" + #if ENABLED(HAS_STEALTHCHOP) #include "../../../../../module/stepper/trinamic.h" #include "../../../../../module/stepper/indirection.h" @@ -60,7 +61,6 @@ uint8_t DGUSLanguageSwitch = 0; // Switch language for MKS DGUS uint32_t swap32(const uint32_t value) { return (value & 0x000000FFU) << 24U | (value & 0x0000FF00U) << 8U | (value & 0x00FF0000U) >> 8U | (value & 0xFF000000U) >> 24U; } #if 0 - void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t* line1, const uint16_t* line2, const uint16_t* line3, const uint16_t* line4) { dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true); @@ -264,7 +264,7 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { void DGUSScreenHandler::SDPrintingFinished() { if (DGUSAutoTurnOff) { - while (!queue.ring_buffer.empty()) queue.advance(); + queue.exhaust(); gcode.process_subcommands_now_P(PSTR("M81")); } GotoScreen(MKSLCD_SCREEN_PrintDone); @@ -465,7 +465,6 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) { cs = getCurrentScreen(); if (cs != MKSLCD_AUTO_LEVEL) GotoScreen(MKSLCD_AUTO_LEVEL); - #else GotoScreen(MKSLCD_SCREEN_LEVEL); @@ -499,14 +498,15 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { char cmd_buf[30]; float offset = mesh_adj_distance; int16_t integer, Deci, Deci2; - // float f3 = current_position.z; - // float f4 = current_position.z; + + if (!queue.ring_buffer.empty()) return; + switch (mesh_value) { case 0: offset = mesh_adj_distance; integer = offset; // get int - Deci = (offset * 100); - Deci = Deci % 100; + Deci = (offset * 10); + Deci = Deci % 10; Deci2 = offset * 100; Deci2 = Deci2 % 10; soft_endstop._enabled = false; @@ -520,8 +520,8 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { case 1: offset = mesh_adj_distance; integer = offset; // get int - Deci = (offset * 100); - Deci = Deci % 100; + Deci = (offset * 10); + Deci = Deci % 10; Deci2 = offset * 100; Deci2 = Deci2 % 10; soft_endstop._enabled = false; @@ -589,8 +589,8 @@ void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { uint16_t lcd_value = swap16(*(uint16_t *)val_ptr); - if(lcd_value > 100) lcd_value = 100; - else if(lcd_value < 10) lcd_value = 10; + if (lcd_value > 100) lcd_value = 100; + else if (lcd_value < 10) lcd_value = 10; lcd_default_light = lcd_value; @@ -794,7 +794,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPAIR("QUEUE LEN:", queue.length); - if (!print_job_timer.isPaused() && queue.ring_buffer.full(1)) + if (!print_job_timer.isPaused() && !queue.ring_buffer.empty()) return; char axiscode; @@ -1249,8 +1249,8 @@ void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { switch (val_t) { case 0: #if HOTENDS >= 1 - if (thermalManager.temp_hotend[0].celsius < thermalManager.extrude_min_temp) { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) + if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) { + if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); SetupConfirmAction(nullptr); @@ -1268,8 +1268,8 @@ void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { case 1: #if HOTENDS >= 2 - if (thermalManager.temp_hotend[1].celsius < thermalManager.extrude_min_temp) { - if (thermalManager.temp_hotend[1].target < thermalManager.extrude_min_temp) + if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) { + if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); SetupConfirmAction(nullptr); @@ -1284,8 +1284,8 @@ void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { } #endif #if ENABLED(SINGLENOZZLE) - if (thermalManager.temp_hotend[0].celsius < thermalManager.extrude_min_temp) { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) + if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) { + if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); SetupConfirmAction(nullptr); @@ -1313,8 +1313,8 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) switch (val_t) { case 0: #if HOTENDS >= 1 - if (thermalManager.temp_hotend[0].celsius < thermalManager.extrude_min_temp) { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) + if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) { + if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); SetupConfirmAction(nullptr); @@ -1331,8 +1331,8 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) break; case 1: #if HOTENDS >= 2 - if (thermalManager.temp_hotend[1].celsius < thermalManager.extrude_min_temp) { - if (thermalManager.temp_hotend[1].target < thermalManager.extrude_min_temp) + if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) { + if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); SetupConfirmAction(nullptr); @@ -1348,8 +1348,8 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) #endif #if ENABLED(SINGLENOZZLE) - if (thermalManager.temp_hotend[0].celsius < thermalManager.extrude_min_temp) { - if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) + if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) { + if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0); sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); SetupConfirmAction(nullptr); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index 6130e92224..5d02f79fd1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -191,7 +191,7 @@ static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) { TERN_(ADVANCED_PAUSE_FEATURE, pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT); } else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT, TYPE_FILAMENT_HEAT_LOAD_COMPLETED, TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) { - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak; + thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex); clear_cur_ui(); draw_return_ui(); } @@ -204,7 +204,7 @@ static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) { uiCfg.filament_loading_time_cnt = 0; uiCfg.filament_unloading_time_flg = false; uiCfg.filament_unloading_time_cnt = 0; - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak; + thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex); clear_cur_ui(); draw_return_ui(); } @@ -479,9 +479,9 @@ void lv_draw_dialog(uint8_t type) { void filament_sprayer_temp() { char buf[20] = {0}; - sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); - strcpy(public_buf_l, uiCfg.curSprayerChoose < 1 ? extrude_menu.ext1 : extrude_menu.ext2); + strcpy(public_buf_l, uiCfg.extruderIndex < 1 ? extrude_menu.ext1 : extrude_menu.ext2); strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); lv_label_set_text(tempText1, public_buf_l); @@ -500,7 +500,7 @@ void filament_dialog_handle() { planner.synchronize(); uiCfg.filament_loading_time_flg = true; uiCfg.filament_loading_time_cnt = 0; - sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E%d F%d\nG90"), uiCfg.curSprayerChoose, gCfgItems.filamentchange_load_length, gCfgItems.filamentchange_load_speed); + sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_load_length, gCfgItems.filamentchange_load_speed); queue.inject(public_buf_m); } if (uiCfg.filament_heat_completed_unload) { @@ -510,13 +510,13 @@ void filament_dialog_handle() { planner.synchronize(); uiCfg.filament_unloading_time_flg = true; uiCfg.filament_unloading_time_cnt = 0; - sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E-%d F%d\nG90"), uiCfg.curSprayerChoose, gCfgItems.filamentchange_unload_length, gCfgItems.filamentchange_unload_speed); + sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E-%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_unload_length, gCfgItems.filamentchange_unload_speed); queue.inject(public_buf_m); } - if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1) - || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper)) - && (uiCfg.filament_load_heat_flg) + if ( ((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1) + || ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper)) + && uiCfg.filament_load_heat_flg ) { uiCfg.filament_load_heat_flg = false; lv_clear_dialog(); @@ -529,8 +529,8 @@ void filament_dialog_handle() { lv_clear_dialog(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED); } - if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1) - || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper)) + if (((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1) + || ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper)) && uiCfg.filament_unload_heat_flg ) { uiCfg.filament_unload_heat_flg = false; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index b9af6d33a8..43ed214199 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -54,7 +54,7 @@ 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_E_ADD: - if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) { + if (thermalManager.degHotend(uiCfg.extruderIndex) >= EXTRUDE_MINTEMP) { sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), uiCfg.extruStep, 60 * uiCfg.extruSpeed); queue.inject(public_buf_l); extrudeAmount += uiCfg.extruStep; @@ -62,7 +62,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } break; case ID_E_DEC: - if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) { + if (thermalManager.degHotend(uiCfg.extruderIndex) >= EXTRUDE_MINTEMP) { sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed); queue.enqueue_one_now(public_buf_l); extrudeAmount -= uiCfg.extruStep; @@ -71,17 +71,17 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { break; case ID_E_TYPE: if (ENABLED(HAS_MULTI_EXTRUDER)) { - if (uiCfg.curSprayerChoose == 0) { - uiCfg.curSprayerChoose = 1; + if (uiCfg.extruderIndex == 0) { + uiCfg.extruderIndex = 1; queue.inject_P(PSTR("T1")); } else { - uiCfg.curSprayerChoose = 0; + uiCfg.extruderIndex = 0; queue.inject_P(PSTR("T0")); } } else - uiCfg.curSprayerChoose = 0; + uiCfg.extruderIndex = 0; extrudeAmount = 0; disp_hotend_temp(); @@ -153,7 +153,7 @@ void lv_draw_extrusion() { } void disp_ext_type() { - if (uiCfg.curSprayerChoose == 1) { + if (uiCfg.extruderIndex == 1) { lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin"); if (gCfgItems.multiple_language) { lv_label_set_text(labelType, extrude_menu.ext2); @@ -195,7 +195,7 @@ void disp_ext_speed() { void disp_hotend_temp() { char buf[20] = {0}; - sprintf(buf, extrude_menu.temp_value, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); + sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, extrude_menu.temper_text); strcat(public_buf_l, buf); lv_label_set_text(tempText, public_buf_l); @@ -213,7 +213,7 @@ void disp_extru_amount() { sprintf(buf1, extrude_menu.count_value_cm, extrudeAmount / 10); else sprintf(buf1, extrude_menu.count_value_m, extrudeAmount / 1000); - strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? extrude_menu.ext1 : extrude_menu.ext2); + strcat(public_buf_l, uiCfg.extruderIndex == 0 ? extrude_menu.ext1 : extrude_menu.ext2); strcat(public_buf_l, buf1); lv_label_set_text(ExtruText, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp index cff99119e8..e12a4b82cf 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -50,25 +50,25 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_FILAMNT_IN: uiCfg.filament_load_heat_flg = true; - if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1) - || (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) { + if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1) + || (gCfgItems.filament_limit_temper <= thermalManager.degHotend(uiCfg.extruderIndex))) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); } else { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT); - if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) { - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper; - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) { + thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex); + thermalManager.start_watching_hotend(uiCfg.extruderIndex); } } break; case ID_FILAMNT_OUT: uiCfg.filament_unload_heat_flg = true; - if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0) - && ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1) - || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper)) + if (thermalManager.degTargetHotend(uiCfg.extruderIndex) + && ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1) + || ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temper)) ) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); @@ -76,28 +76,28 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { else { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT); - if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) { - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper; - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) { + thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex); + thermalManager.start_watching_hotend(uiCfg.extruderIndex); } filament_sprayer_temp(); } break; case ID_FILAMNT_TYPE: #if HAS_MULTI_EXTRUDER - uiCfg.curSprayerChoose = !uiCfg.curSprayerChoose; + uiCfg.extruderIndex = !uiCfg.extruderIndex; #endif disp_filament_type(); break; case ID_FILAMNT_RETURN: #if HAS_MULTI_EXTRUDER if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED) - gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0")); + gcode.process_subcommands_now_P(uiCfg.extruderIndexBak == 1 ? PSTR("T1") : PSTR("T0")); #endif feedrate_mm_s = (float)uiCfg.moveSpeed_bak; if (uiCfg.print_state == PAUSED) planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak)); - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak; + thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex); clear_cur_ui(); draw_return_ui(); @@ -132,7 +132,7 @@ void lv_draw_filament_change() { } void disp_filament_type() { - if (uiCfg.curSprayerChoose == 1) { + if (uiCfg.extruderIndex == 1) { lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin"); if (gCfgItems.multiple_language) { lv_label_set_text(labelType, preheat_menu.ext2); @@ -153,8 +153,8 @@ void disp_filament_temp() { public_buf_l[0] = '\0'; - strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); + strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp index eb4b370838..cd77db8ae1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp @@ -66,7 +66,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { break; case ID_O_FILAMENT: #if HAS_MULTI_EXTRUDER - uiCfg.curSprayerChoose_bak = active_extruder; + uiCfg.extruderIndexBak = active_extruder; #endif if (uiCfg.print_state == WORKING) { #if ENABLED(SDSUPPORT) @@ -76,7 +76,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { #endif } uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s; - uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[active_extruder].target; + uiCfg.hotendTargetTempBak = thermalManager.degTargetHotend(active_extruder); lv_clear_operation(); lv_draw_filament_change(); break; 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 f2fda3a286..73a0808e9c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -48,47 +48,46 @@ enum { 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_P_ADD: + case ID_P_ADD: { if (uiCfg.curTempType == 0) { - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target += uiCfg.stepHeat; - if (uiCfg.curSprayerChoose == 0) { - if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) { - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); - } - } + int16_t max_target; + thermalManager.temp_hotend[uiCfg.extruderIndex].target += uiCfg.stepHeat; + if (uiCfg.extruderIndex == 0) + max_target = HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); #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); - } + else + max_target = HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1); #endif - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + if (thermalManager.degTargetHotend(uiCfg.extruderIndex) > max_target) + thermalManager.setTargetHotend(max_target, uiCfg.extruderIndex); + thermalManager.start_watching_hotend(uiCfg.extruderIndex); } #if HAS_HEATED_BED else { + constexpr int16_t max_target = BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1); thermalManager.temp_bed.target += uiCfg.stepHeat; - if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) { - thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1); - } + if (thermalManager.degTargetBed() > max_target) + thermalManager.setTargetBed(max_target); thermalManager.start_watching_bed(); } #endif disp_desire_temp(); - break; + } break; + case ID_P_DEC: if (uiCfg.curTempType == 0) { - if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat) - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat; + if ((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat) + thermalManager.temp_hotend[uiCfg.extruderIndex].target -= uiCfg.stepHeat; else - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = 0; - - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + thermalManager.setTargetHotend(0, uiCfg.extruderIndex); + thermalManager.start_watching_hotend(uiCfg.extruderIndex); } #if HAS_HEATED_BED else { if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat) thermalManager.temp_bed.target -= uiCfg.stepHeat; else - thermalManager.temp_bed.target = 0; + thermalManager.setTargetBed(0); thermalManager.start_watching_bed(); } @@ -98,20 +97,20 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_P_TYPE: if (uiCfg.curTempType == 0) { if (ENABLED(HAS_MULTI_EXTRUDER)) { - if (uiCfg.curSprayerChoose == 0) { - uiCfg.curSprayerChoose = 1; + if (uiCfg.extruderIndex == 0) { + uiCfg.extruderIndex = 1; } - else if (uiCfg.curSprayerChoose == 1) { + else if (uiCfg.extruderIndex == 1) { if (TEMP_SENSOR_BED != 0) { uiCfg.curTempType = 1; } else { uiCfg.curTempType = 0; - uiCfg.curSprayerChoose = 0; + uiCfg.extruderIndex = 0; } } } - else if (uiCfg.curSprayerChoose == 0) { + else if (uiCfg.extruderIndex == 0) { if (TEMP_SENSOR_BED != 0) uiCfg.curTempType = 1; else @@ -119,7 +118,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } } else if (uiCfg.curTempType == 1) { - uiCfg.curSprayerChoose = 0; + uiCfg.extruderIndex = 0; uiCfg.curTempType = 0; } disp_temp_type(); @@ -135,8 +134,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { break; case ID_P_OFF: if (uiCfg.curTempType == 0) { - thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = 0; - thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); + thermalManager.setTargetHotend(0, uiCfg.extruderIndex); + thermalManager.start_watching_hotend(uiCfg.extruderIndex); } #if HAS_HEATED_BED else { @@ -186,7 +185,7 @@ void lv_draw_preHeat() { void disp_temp_type() { if (uiCfg.curTempType == 0) { - if (uiCfg.curSprayerChoose == 1) { + if (uiCfg.extruderIndex == 1) { lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin"); if (gCfgItems.multiple_language) { lv_label_set_text(labelType, preheat_menu.ext2); @@ -217,13 +216,13 @@ void disp_desire_temp() { public_buf_l[0] = '\0'; if (uiCfg.curTempType == 0) { - strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); + strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); } #if HAS_HEATED_BED else { strcat(public_buf_l, preheat_menu.hotbed); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); } #endif strcat_P(public_buf_l, PSTR(": ")); 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 782ce21992..2cc6d19cc5 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -203,11 +203,11 @@ void lv_draw_printing() { } void disp_ext_temp() { - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, public_buf_l); #endif } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 047a6cdb70..7554f746ca 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -98,10 +98,10 @@ void disp_det_error() { lv_obj_t *e1, *e2, *e3, *bed; void mks_disp_test() { char buf[30] = {0}; - sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius); + sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.degHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND - sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.temp_hotend[1].celsius); + sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.degHotend(1)); lv_label_set_text(e2, buf); #endif #if HAS_HEATED_BED @@ -133,12 +133,12 @@ void lv_draw_ready_print() { #if 1 e1 = lv_label_create_empty(scr); lv_obj_set_pos(e1, 20, 20); - sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.temp_hotend[0].celsius); + sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND e2 = lv_label_create_empty(scr); lv_obj_set_pos(e2, 20, 45); - sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.temp_hotend[1].celsius); + sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(1)); lv_label_set_text(e2, buf); #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 aa6d3869a6..8e9e5d59fa 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp @@ -68,7 +68,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { #endif break; case ID_T_FILAMENT: - uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target; + uiCfg.hotendTargetTempBak = thermalManager.degTargetHotend(uiCfg.extruderIndex); lv_draw_filament_change(); break; case ID_T_MORE: 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 9d13ca3120..9b7fea0a45 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -179,7 +179,7 @@ void gCfgItems_init() { void ui_cfg_init() { uiCfg.curTempType = 0; - uiCfg.curSprayerChoose = 0; + uiCfg.extruderIndex = 0; uiCfg.stepHeat = 10; uiCfg.leveling_first_time = false; uiCfg.para_ui_page = false; 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 34c6b1f254..4b0ce2b4d8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -211,9 +211,9 @@ typedef struct { typedef struct { uint8_t curTempType:1, - curSprayerChoose:3, + extruderIndex:3, stepHeat:4, - curSprayerChoose_bak:4; + extruderIndexBak:4; bool leveling_first_time:1, para_ui_page:1, configWifi:1, @@ -246,7 +246,7 @@ typedef struct { filament_loading_time_cnt, filament_unloading_time_cnt; float move_dist; - float desireSprayerTempBak; + float hotendTargetTempBak; float current_x_position_bak, current_y_position_bak, current_z_position_bak, 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 02ca16e007..ddf7173297 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -885,9 +885,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { char *outBuf = (char *)tempBuf; char str_1[16], tbuf[34]; - dtostrf(thermalManager.temp_hotend[0].celsius, 1, 1, tbuf); + dtostrf(thermalManager.degHotend(0), 1, 1, tbuf); strcat_P(tbuf, PSTR(" /")); - strcat(tbuf, dtostrf(thermalManager.temp_hotend[0].target, 1, 1, str_1)); + strcat(tbuf, dtostrf(thermalManager.degTargetHotend(0), 1, 1, str_1)); const int tlen = strlen(tbuf); @@ -912,9 +912,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcat_P(outBuf, PSTR(" T1:")); outBuf += 4; #if HAS_MULTI_HOTEND - strcat(outBuf, dtostrf(thermalManager.temp_hotend[1].celsius, 1, 1, str_1)); + strcat(outBuf, dtostrf(thermalManager.degHotend(1), 1, 1, str_1)); strcat_P(outBuf, PSTR(" /")); - strcat(outBuf, dtostrf(thermalManager.temp_hotend[1].target, 1, 1, str_1)); + strcat(outBuf, dtostrf(thermalManager.degTargetHotend(1), 1, 1, str_1)); #else strcat_P(outBuf, PSTR("0 /0")); #endif @@ -924,15 +924,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { } 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, + (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0), #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, + (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0), #if HAS_MULTI_HOTEND - (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target + (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1) #else 0, 0 #endif From 87bef13a4c9c1c7f3a670f906c106bc868ab12f2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 6 Mar 2021 10:16:18 -0600 Subject: [PATCH 009/311] Fix DGUS include paths Followup to #20609 --- Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp | 2 +- Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp | 2 +- Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp index c43243b39d..5497dd53cc 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp @@ -37,7 +37,7 @@ #include "../../../../../sd/cardreader.h" #if ENABLED(POWER_LOSS_RECOVERY) - #include "../../../../feature/powerloss.h" + #include "../../../../../feature/powerloss.h" #endif #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp index 90cfae7f09..c170c288aa 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp @@ -37,7 +37,7 @@ #include "../../../../../sd/cardreader.h" #if ENABLED(POWER_LOSS_RECOVERY) - #include "../../../../feature/powerloss.h" + #include "../../../../../feature/powerloss.h" #endif #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp index f1d91371c2..ff924f4061 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp @@ -37,7 +37,7 @@ #include "../../../../../sd/cardreader.h" #if ENABLED(POWER_LOSS_RECOVERY) - #include "../../../../feature/powerloss.h" + #include "../../../../../feature/powerloss.h" #endif #if ENABLED(SDSUPPORT) From b95e548ddbcbc1c088eabc17992d0a06f82ac167 Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Sat, 6 Mar 2021 14:13:28 -0600 Subject: [PATCH 010/311] Cooler (for Laser) - M143, M193 (#21255) --- Marlin/Configuration.h | 4 + Marlin/Configuration_adv.h | 44 +++ Marlin/src/HAL/AVR/fastio.h | 2 +- Marlin/src/HAL/ESP32/HAL.cpp | 1 + Marlin/src/HAL/SAMD51/HAL.cpp | 14 + Marlin/src/HAL/STM32F1/HAL.cpp | 9 + Marlin/src/HAL/STM32F1/msc_sd.cpp | 35 +- Marlin/src/core/language.h | 2 + Marlin/src/feature/cooler.cpp | 37 ++ Marlin/src/feature/cooler.h | 50 +++ Marlin/src/feature/power.cpp | 7 + Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 11 - Marlin/src/gcode/gcode.cpp | 5 + Marlin/src/gcode/gcode.h | 7 + Marlin/src/gcode/host/M115.cpp | 3 + Marlin/src/gcode/temp/M140_M190.cpp | 11 - Marlin/src/gcode/temp/M141_M191.cpp | 12 - Marlin/src/gcode/temp/M143_M193.cpp | 67 ++++ Marlin/src/inc/Conditionals_adv.h | 4 + Marlin/src/inc/Conditionals_post.h | 60 ++- Marlin/src/inc/SanityCheck.h | 4 + Marlin/src/lcd/dogm/dogm_Statusscreen.h | 58 +++ Marlin/src/lcd/dogm/status/cooler.h | 70 ++++ Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 35 +- Marlin/src/lcd/extui/ui_api.cpp | 26 +- Marlin/src/lcd/extui/ui_api.h | 2 +- Marlin/src/lcd/language/language_en.h | 6 + Marlin/src/lcd/menu/menu_info.cpp | 10 + Marlin/src/lcd/menu/menu_temperature.cpp | 23 +- Marlin/src/lcd/tft/tft_color.h | 3 + Marlin/src/lcd/tft/touch.cpp | 6 + Marlin/src/lcd/tft/ui_320x240.cpp | 13 + Marlin/src/lcd/tft/ui_480x320.cpp | 6 + Marlin/src/lcd/tft/ui_common.h | 4 + Marlin/src/module/temperature.cpp | 380 +++++++++++++++++-- Marlin/src/module/temperature.h | 75 +++- Marlin/src/module/thermistor/thermistors.h | 21 +- Marlin/src/pins/pinsDebug_list.h | 6 + Marlin/src/pins/sensitive_pins.h | 20 +- buildroot/tests/BIGTREE_SKR_PRO | 11 +- platformio.ini | 2 + 41 files changed, 1041 insertions(+), 125 deletions(-) create mode 100644 Marlin/src/feature/cooler.cpp create mode 100644 Marlin/src/feature/cooler.h create mode 100644 Marlin/src/gcode/temp/M143_M193.cpp create mode 100644 Marlin/src/lcd/dogm/status/cooler.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 90ab4d58af..7b0023a564 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -329,8 +329,10 @@ #define AUTO_POWER_E_FANS #define AUTO_POWER_CONTROLLERFAN #define AUTO_POWER_CHAMBER_FAN + #define AUTO_POWER_COOLER_FAN //#define AUTO_POWER_E_TEMP 50 // (°C) Turn on PSU if any extruder is over this temperature //#define AUTO_POWER_CHAMBER_TEMP 30 // (°C) Turn on PSU if the chamber is over this temperature + //#define AUTO_POWER_COOLER_TEMP 26 // (°C) Turn on PSU if the cooler is over this temperature #define POWER_TIMEOUT 30 // (s) Turn off power if the machine is idle for this duration //#define POWER_OFF_DELAY 60 // (s) Delay of poweroff after M81 command. Useful to let fans run for extra time. #endif @@ -418,6 +420,7 @@ #define TEMP_SENSOR_BED 0 #define TEMP_SENSOR_PROBE 0 #define TEMP_SENSOR_CHAMBER 0 +#define TEMP_SENSOR_COOLER 0 // Dummy thermistor constant temperature readings, for use with 998 and 999 #define DUMMY_THERMISTOR_998_VALUE 25 @@ -636,6 +639,7 @@ #define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders #define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed #define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber +#define THERMAL_PROTECTION_COOLER // Enable thermal protection for the laser cooling //=========================================================================== //============================= Mechanical Settings ========================= diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8bbc50bee4..3168e9a001 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_COOLER == 1000 + #define COOLER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define COOLER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define COOLER_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 @@ -179,6 +185,25 @@ #endif #endif +// +// Laser Cooler options +// +#if TEMP_SENSOR_COOLER + #define COOLER_MINTEMP 8 // (°C) + #define COOLER_MAXTEMP 26 // (°C) + #define COOLER_DEFAULT_TEMP 16 // (°C) + #define TEMP_COOLER_HYSTERESIS 1 // (°C) Temperature proximity considered "close enough" to the target + #define COOLER_PIN 8 // Laser cooler on/off pin used to control power to the cooling element e.g. TEC, External chiller via relay + #define COOLER_INVERTING false + #define TEMP_COOLER_PIN 15 // Laser/Cooler temperature sensor pin. ADC is required. + #define COOLER_FAN // Enable a fan on the cooler, Fan# 0,1,2,3 etc. + #define COOLER_FAN_INDEX 0 // FAN number 0, 1, 2 etc. e.g. + #if ENABLED(COOLER_FAN) + #define COOLER_FAN_BASE 100 // Base Cooler fan PWM (0-255); turns on when Cooler temperature is above the target + #define COOLER_FAN_FACTOR 25 // PWM increase per °C above target + #endif +#endif + /** * Thermal Protection provides additional protection to your printer from damage * and fire. Marlin always includes safe min and max temperature ranges which @@ -248,6 +273,20 @@ #define WATCH_CHAMBER_TEMP_INCREASE 2 // Degrees Celsius #endif +/** + * Thermal Protection parameters for the laser cooler. + */ +#if ENABLED(THERMAL_PROTECTION_COOLER) + #define THERMAL_PROTECTION_COOLER_PERIOD 10 // Seconds + #define THERMAL_PROTECTION_COOLER_HYSTERESIS 3 // Degrees Celsius + + /** + * Laser cooling watch settings (M143/M193). + */ + #define WATCH_COOLER_TEMP_PERIOD 60 // Seconds + #define WATCH_COOLER_TEMP_INCREASE 3 // Degrees Celsius +#endif + #if ENABLED(PIDTEMP) // Add an experimental additional term to the heater power, proportional to the extrusion speed. // A well-chosen Kc value should add just enough power to melt the increased material volume. @@ -493,11 +532,15 @@ #define E6_AUTO_FAN_PIN -1 #define E7_AUTO_FAN_PIN -1 #define CHAMBER_AUTO_FAN_PIN -1 +#define COOLER_AUTO_FAN_PIN -1 +#define COOLER_FAN_PIN -1 #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // 255 == full speed #define CHAMBER_AUTO_FAN_TEMPERATURE 30 #define CHAMBER_AUTO_FAN_SPEED 255 +#define COOLER_AUTO_FAN_TEMPERATURE 18 +#define COOLER_AUTO_FAN_SPEED 255 /** * Part-Cooling Fan Multiplexer @@ -1495,6 +1538,7 @@ #define STATUS_BED_ANIM // Use a second bitmap to indicate bed heating #define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating //#define STATUS_CUTTER_ANIM // Use a second bitmap to indicate spindle / laser active + //#define STATUS_COOLER_ANIM // Use a second bitmap to indicate laser cooling //#define STATUS_ALT_BED_BITMAP // Use the alternative bed bitmap //#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap //#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h index dd01634661..cf704179c8 100644 --- a/Marlin/src/HAL/AVR/fastio.h +++ b/Marlin/src/HAL/AVR/fastio.h @@ -285,7 +285,7 @@ enum ClockSource2 : char { */ // Determine which harware PWMs are already in use -#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN) +#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN || P == COOLER_AUTO_FAN_PIN) #if PIN_EXISTS(CONTROLLER_FAN) #define PWM_CHK_FAN_B(P) (_PWM_CHK_FAN_B(P) || P == CONTROLLER_FAN_PIN) #else diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index fb5f531b22..ab28595071 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -185,6 +185,7 @@ void HAL_adc_init() { TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db)); TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db)); TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db)); TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db)); // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail. diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index 17e89c723f..4a6100b96b 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -57,6 +57,7 @@ #define GET_PROBE_ADC() TERN(HAS_TEMP_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1) #define GET_BED_ADC() TERN(HAS_TEMP_ADC_BED, PIN_TO_ADC(TEMP_BED_PIN), -1) #define GET_CHAMBER_ADC() TERN(HAS_TEMP_ADC_CHAMBER, PIN_TO_ADC(TEMP_CHAMBER_PIN), -1) +#define GET_COOLER_ADC() TERN(HAS_TEMP_ADC_COOLER, PIN_TO_ADC(TEMP_COOLER_PIN), -1) #define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1) #define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1) @@ -66,6 +67,7 @@ || GET_PROBE_ADC() == n \ || GET_BED_ADC() == n \ || GET_CHAMBER_ADC() == n \ + || GET_COOLER_ADC() == n \ || GET_FILAMENT_WIDTH_ADC() == n \ || GET_BUTTONS_ADC() == n \ ) @@ -144,6 +146,9 @@ uint16_t HAL_adc_result; #if GET_CHAMBER_ADC() == 0 TEMP_CHAMBER_PIN, #endif + #if GET_COOLER_ADC() == 0 + TEMP_COOLER_PIN, + #endif #if GET_FILAMENT_WIDTH_ADC() == 0 FILWIDTH_PIN, #endif @@ -184,6 +189,9 @@ uint16_t HAL_adc_result; #if GET_CHAMBER_ADC() == 1 TEMP_CHAMBER_PIN, #endif + #if GET_COOLER_ADC() == 1 + TEMP_COOLER_PIN, + #endif #if GET_FILAMENT_WIDTH_ADC() == 1 FILWIDTH_PIN, #endif @@ -232,6 +240,9 @@ uint16_t HAL_adc_result; #if GET_CHAMBER_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) }, #endif + #if GET_COOLER_ADC() == 0 + { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) }, + #endif #if GET_FILAMENT_WIDTH_ADC() == 0 { PIN_TO_INPUTCTRL(FILWIDTH_PIN) }, #endif @@ -281,6 +292,9 @@ uint16_t HAL_adc_result; #if GET_CHAMBER_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) }, #endif + #if GET_COOLER_ADC() == 1 + { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) }, + #endif #if GET_FILAMENT_WIDTH_ADC() == 1 { PIN_TO_INPUTCTRL(FILWIDTH_PIN) }, #endif diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index 020c623b77..182d9401c1 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -132,6 +132,9 @@ const uint8_t adc_pins[] = { #if HAS_TEMP_CHAMBER TEMP_CHAMBER_PIN, #endif + #if HAS_TEMP_COOLER + TEMP_COOLER_PIN, + #endif #if HAS_TEMP_ADC_1 TEMP_1_PIN, #endif @@ -189,6 +192,9 @@ enum TempPinIndex : char { #if HAS_TEMP_CHAMBER TEMP_CHAMBER, #endif + #if HAS_TEMP_COOLER + TEMP_COOLER_PIN, + #endif #if HAS_TEMP_ADC_1 TEMP_1, #endif @@ -385,6 +391,9 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { #if HAS_TEMP_CHAMBER case TEMP_CHAMBER_PIN: pin_index = TEMP_CHAMBER; break; #endif + #if HAS_TEMP_COOLER + case TEMP_COOLER_PIN: pin_index = TEMP_COOLER; break; + #endif #if HAS_TEMP_ADC_1 case TEMP_1_PIN: pin_index = TEMP_1; break; #endif diff --git a/Marlin/src/HAL/STM32F1/msc_sd.cpp b/Marlin/src/HAL/STM32F1/msc_sd.cpp index a916184999..1e2fe88174 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.cpp +++ b/Marlin/src/HAL/STM32F1/msc_sd.cpp @@ -43,26 +43,27 @@ Serial0Type MarlinCompositeSerial(true); #if ENABLED(EMERGENCY_PARSER) -// 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]; + // 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(); + //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; + 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); + // 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]); + } - for (uint32 i = 0; i < len; i++) - emergency_parser.update(MarlinCompositeSerial.emergency_state, buf[i+total-len]); -} #endif void MSC_SD_init() { @@ -87,7 +88,7 @@ void MSC_SD_init() { MarlinCompositeSerial.registerComponent(); USBComposite.begin(); #if ENABLED(EMERGENCY_PARSER) - composite_cdcacm_set_hooks(USBHID_CDCACM_HOOK_RX, my_rx_callback); + composite_cdcacm_set_hooks(USBHID_CDCACM_HOOK_RX, my_rx_callback); #endif } diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index c9c3fd0153..71e8ea524c 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -247,6 +247,8 @@ #define STR_HEATER_BED "bed" #define STR_HEATER_CHAMBER "chamber" +#define STR_COOLER "cooler" +#define STR_LASER_TEMP "laser temperature" #define STR_STOPPED_HEATER ", system stopped! Heater_ID: " #define STR_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !" diff --git a/Marlin/src/feature/cooler.cpp b/Marlin/src/feature/cooler.cpp new file mode 100644 index 0000000000..03640df487 --- /dev/null +++ b/Marlin/src/feature/cooler.cpp @@ -0,0 +1,37 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../inc/MarlinConfig.h" + +#if HAS_COOLER + +#include "cooler.h" +Cooler cooler; + +uint16_t Cooler::flowrate; // Flow meter reading in liters, 0 will result in shutdown if equiped +uint8_t Cooler::mode = 0; // 0 = CO2 Liquid cooling, 1 = Laser Diode TEC Heatsink Cooling +uint16_t Cooler::capacity; // Cooling capacity in watts +uint16_t Cooler::load; // Cooling load in watts +bool Cooler::flowmeter = false; +bool Cooler::state = false; // on = true, off = false + +#endif diff --git a/Marlin/src/feature/cooler.h b/Marlin/src/feature/cooler.h new file mode 100644 index 0000000000..42a95ccb63 --- /dev/null +++ b/Marlin/src/feature/cooler.h @@ -0,0 +1,50 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include + +#define _MSG_COOLER(M) MSG_COOLER_##M +#define MSG_COOLER(M) _MSG_COOLER(M) + +// Cooling device + +class Cooler { +public: + static uint16_t flowrate; // Flow meter reading in liters, 0 will result in shutdown if equiped + static uint8_t mode; // 0 = CO2 Liquid cooling, 1 = Laser Diode TEC Heatsink Cooling + static uint16_t capacity; // Cooling capacity in watts + static uint16_t load; // Cooling load in watts + static bool flowmeter; + static bool state; // on = true, off = false + + static bool is_enabled() { return state; } + static void enable() { state = true; } + static void disable() { state = false; } + static void set_mode(const uint8_t m) { mode = m; } + static void set_flowmeter(const bool sflag) { flowmeter = sflag; } + static uint16_t get_flowrate() { return flowrate; } + static void update_flowrate(uint16_t flow) { flowrate = flow; } + //static void init() { set_state(false); } +}; + +extern Cooler cooler; diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index d22247b46d..8ab49de2bd 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -61,6 +61,9 @@ bool Power::is_power_needed() { if (TERN0(AUTO_POWER_CHAMBER_FAN, thermalManager.chamberfan_speed)) return true; + if (TERN0(AUTO_POWER_COOLER_FAN, thermalManager.coolerfan_speed)) + return true; + // If any of the drivers or the bed are enabled... if (X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON || Z_ENABLE_READ() == Z_ENABLE_ON #if HAS_X2_ENABLE @@ -89,6 +92,10 @@ bool Power::is_power_needed() { if (thermalManager.degChamber() >= AUTO_POWER_CHAMBER_TEMP) return true; #endif + #if HAS_COOLER && AUTO_POWER_COOLER_TEMP + if (thermalManager.degCooler() >= AUTO_POWER_COOLER_TEMP) return true; + #endif + return false; } diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index 5d0bb0dc1e..8cfe6fee7b 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -36,17 +36,7 @@ #include "../../module/temperature.h" #include "../../module/probe.h" #include "../../feature/probe_temp_comp.h" - #include "../../lcd/marlinui.h" -#include "../../MarlinCore.h" // for wait_for_heatup, idle() - -#if ENABLED(PRINTJOB_TIMER_AUTOSTART) - #include "../../module/printcounter.h" -#endif - -#if ENABLED(PRINTER_EVENTS_LEDS) - #include "../../feature/leds/leds.h" -#endif /** * G76: calibrate probe and/or bed temperature offsets @@ -173,7 +163,6 @@ void GcodeSuite::G76() { remember_feedrate_scaling_off(); - /****************************************** * Calibrate bed temperature offsets ******************************************/ diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index e9a6d4aa2a..34b8d767d1 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -539,6 +539,11 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 191: M191(); break; // M191: Wait for chamber temperature to reach target #endif + #if HAS_COOLER + case 143: M143(); break; // M143: Set cooler temperature + case 193: M193(); break; // M193: Wait for cooler temperature to reach target + #endif + #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR) case 155: M155(); break; // M155: Set temperature auto-report interval #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 123b648f90..52570ff83f 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -153,6 +153,7 @@ * M129 - EtoP Closed. (Requires BARICUDA) * M140 - Set bed target temp. S * M141 - Set heated chamber target temp. S (Requires a chamber heater) + * M143 - Set cooler target temp. S (Requires a laser cooling device) * M145 - Set heatup values for materials on the LCD. H B F for S (0=PLA, 1=ABS) * M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT) * M150 - Set Status LED Color as R U B W P. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632). @@ -163,6 +164,7 @@ * M166 - Set the Gradient Mix for the mixing extruder. (Requires GRADIENT_MIX) * M190 - S Wait for bed current temp to reach target temp. ** Wait only when heating! ** * R Wait for bed current temp to reach target temp. ** Wait for heating or cooling. ** + * M193 - R Wait for cooler temp to reach target temp. ** Wait for cooling. ** * M200 - Set filament diameter, D, setting E axis units to cubic. (Use S0 to revert to linear units.) * M201 - Set max acceleration in units/s^2 for print moves: "M201 X Y Z E" * M202 - Set max acceleration in units/s^2 for travel moves: "M202 X Y Z E" ** UNUSED IN MARLIN! ** @@ -632,6 +634,11 @@ private: static void M191(); #endif + #if HAS_COOLER + static void M143(); + static void M193(); + #endif + #if PREHEAT_COUNT static void M145(); #endif diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index ac712aea07..316abc3048 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -141,6 +141,9 @@ void GcodeSuite::M115() { // CHAMBER_TEMPERATURE (M141, M191) cap_line(PSTR("CHAMBER_TEMPERATURE"), ENABLED(HAS_HEATED_CHAMBER)); + // COOLER_TEMPERATURE (M143, M193) + cap_line(PSTR("COOLER_TEMPERATURE"), ENABLED(HAS_COOLER)); + // MEATPACK Compresson cap_line(PSTR("MEATPACK"), ENABLED(MEATPACK)); diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index d684127fe1..9a1a0287d9 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -32,19 +32,8 @@ #include "../gcode.h" #include "../../module/temperature.h" -#include "../../module/motion.h" #include "../../lcd/marlinui.h" -#if ENABLED(PRINTJOB_TIMER_AUTOSTART) - #include "../../module/printcounter.h" -#endif - -#if ENABLED(PRINTER_EVENT_LEDS) - #include "../../feature/leds/leds.h" -#endif - -#include "../../MarlinCore.h" // for wait_for_heatup, idle, startOrResumeJob - /** * M140: Set bed temperature * diff --git a/Marlin/src/gcode/temp/M141_M191.cpp b/Marlin/src/gcode/temp/M141_M191.cpp index 17eb71eada..ed7637c92a 100644 --- a/Marlin/src/gcode/temp/M141_M191.cpp +++ b/Marlin/src/gcode/temp/M141_M191.cpp @@ -32,20 +32,8 @@ #include "../gcode.h" #include "../../module/temperature.h" - -#include "../../module/motion.h" #include "../../lcd/marlinui.h" -#if ENABLED(PRINTJOB_TIMER_AUTOSTART) - #include "../../module/printcounter.h" -#endif - -#if ENABLED(PRINTER_EVENT_LEDS) - #include "../../feature/leds/leds.h" -#endif - -#include "../../MarlinCore.h" // for wait_for_heatup, idle, startOrResumeJob - /** * M141: Set chamber temperature */ diff --git a/Marlin/src/gcode/temp/M143_M193.cpp b/Marlin/src/gcode/temp/M143_M193.cpp new file mode 100644 index 0000000000..aef4350e60 --- /dev/null +++ b/Marlin/src/gcode/temp/M143_M193.cpp @@ -0,0 +1,67 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * gcode/temp/M143_M193.cpp + * + * Laser Cooler target temperature control + */ + +#include "../../inc/MarlinConfig.h" + +#if HAS_COOLER + +#include "../../feature/cooler.h" +extern Cooler cooler; + +#include "../gcode.h" +#include "../../module/temperature.h" +#include "../../lcd/marlinui.h" + +/** + * M143: Set cooler temperature + */ +void GcodeSuite::M143() { + if (DEBUGGING(DRYRUN)) return; + if (parser.seenval('S')) { + thermalManager.setTargetCooler(parser.value_celsius()); + parser.value_celsius() ? cooler.enable() : cooler.disable(); + } +} + +/** + * M193: Sxxx Wait for laser current temp to reach target temp. Waits only when cooling. + */ +void GcodeSuite::M193() { + if (DEBUGGING(DRYRUN)) return; + + if (parser.seenval('S')) { + cooler.enable(); + thermalManager.setTargetCooler(parser.value_celsius()); + if (thermalManager.isLaserCooling()) { + ui.set_status_P(GET_TEXT(MSG_LASER_COOLING)); + thermalManager.wait_for_cooler(true); + } + } +} + +#endif // HAS_COOLER diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 43f20b6dfd..00b9b1faef 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -114,6 +114,10 @@ #undef THERMAL_PROTECTION_CHAMBER #endif +#if TEMP_SENSOR_COOLER == 0 + #undef THERMAL_PROTECTION_COOLER +#endif + #if ENABLED(MIXING_EXTRUDER) && (ENABLED(RETRACT_SYNC_MIXING) || BOTH(FILAMENT_LOAD_UNLOAD_GCODES, FILAMENT_UNLOAD_ALL_EXTRUDERS)) #define HAS_MIXER_SYNC_CHANNEL 1 #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index be04341200..e8ed0d5a91 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -399,7 +399,7 @@ * Temp Sensor defines */ -#define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_6 == (n) || TEMP_SENSOR_7 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_PROBE == (n) || TEMP_SENSOR_CHAMBER == (n)) +#define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_6 == (n) || TEMP_SENSOR_7 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_PROBE == (n) || TEMP_SENSOR_CHAMBER == (n) || TEMP_SENSOR_COOLER == (n)) #if ANY_TEMP_SENSOR_IS(1000) #define HAS_USER_THERMISTORS 1 @@ -744,6 +744,27 @@ #undef CHAMBER_MAXTEMP #endif +#if TEMP_SENSOR_COOLER == -4 + #define COOLER_USES_AD8495 1 +#elif TEMP_SENSOR_COOLER == -3 + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_COOLER." +#elif TEMP_SENSOR_COOLER == -2 + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_COOLER." +#elif TEMP_SENSOR_COOLER == -1 + #define COOLER_USES_AD595 1 +#elif TEMP_SENSOR_COOLER > 0 + #define TEMP_SENSOR_COOLER_THERMISTOR_ID TEMP_SENSOR_COOLER + #define TEMP_SENSOR_COOLER_IS_THERMISTOR 1 + #if TEMP_SENSOR_COOLER == 1000 + #define COOLER_USER_THERMISTOR 1 + #elif TEMP_SENSOR_COOLER == 998 || TEMP_SENSOR_COOLER == 999 + #define COOLER_DUMMY_THERMISTOR 1 + #endif +#else + #undef COOLER_MINTEMP + #undef COOLER_MAXTEMP +#endif + #if TEMP_SENSOR_PROBE == -4 #define TEMP_SENSOR_PROBE_IS_AD8495 1 #elif TEMP_SENSOR_PROBE == -3 @@ -1928,6 +1949,9 @@ #if HAS_ADC_TEST(CHAMBER) #define HAS_TEMP_ADC_CHAMBER 1 #endif +#if HAS_ADC_TEST(COOLER) + #define HAS_TEMP_ADC_COOLER 1 +#endif #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) @@ -1942,6 +1966,9 @@ #if HAS_TEMP(CHAMBER) #define HAS_TEMP_CHAMBER 1 #endif +#if HAS_TEMP(COOLER) + #define HAS_TEMP_COOLER 1 +#endif #if ENABLED(JOYSTICK) #if PIN_EXISTS(JOY_X) @@ -2001,7 +2028,10 @@ #if HAS_HEATED_BED || HAS_TEMP_CHAMBER #define BED_OR_CHAMBER 1 #endif -#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE +#if HAS_TEMP_COOLER && PIN_EXISTS(COOLER) + #define HAS_COOLER 1 +#endif +#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER #define HAS_TEMP_SENSOR 1 #endif @@ -2033,9 +2063,13 @@ #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0 #define WATCH_CHAMBER 1 #endif +#if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) && WATCH_COOLER_TEMP_PERIOD > 0 + #define WATCH_COOLER 1 +#endif #if (ENABLED(THERMAL_PROTECTION_HOTENDS) || !EXTRUDERS) \ && (ENABLED(THERMAL_PROTECTION_BED) || !HAS_HEATED_BED) \ - && (ENABLED(THERMAL_PROTECTION_CHAMBER) || !HAS_HEATED_CHAMBER) + && (ENABLED(THERMAL_PROTECTION_CHAMBER) || !HAS_HEATED_CHAMBER) \ + && (ENABLED(THERMAL_PROTECTION_COOLER) || !HAS_COOLER) #define THERMALLY_SAFE 1 #endif @@ -2067,8 +2101,11 @@ #if HAS_TEMP_CHAMBER && PIN_EXISTS(CHAMBER_AUTO_FAN) #define HAS_AUTO_CHAMBER_FAN 1 #endif +#if HAS_TEMP_COOLER && PIN_EXISTS(COOLER_AUTO_FAN) + #define HAS_AUTO_COOLER_FAN 1 +#endif -#if ANY(HAS_AUTO_FAN_0, HAS_AUTO_FAN_1, HAS_AUTO_FAN_2, HAS_AUTO_FAN_3, HAS_AUTO_FAN_4, HAS_AUTO_FAN_5, HAS_AUTO_FAN_6, HAS_AUTO_FAN_7, HAS_AUTO_CHAMBER_FAN) +#if ANY(HAS_AUTO_FAN_0, HAS_AUTO_FAN_1, HAS_AUTO_FAN_2, HAS_AUTO_FAN_3, HAS_AUTO_FAN_4, HAS_AUTO_FAN_5, HAS_AUTO_FAN_6, HAS_AUTO_FAN_7, HAS_AUTO_CHAMBER_FAN, HAS_AUTO_COOLER_FAN) #define HAS_AUTO_FAN 1 #endif #define _FANOVERLAP(A,B) (A##_AUTO_FAN_PIN == E##B##_AUTO_FAN_PIN) @@ -2364,7 +2401,20 @@ #define WRITE_HEATER_CHAMBER(v) WRITE(HEATER_CHAMBER_PIN, (v) ^ HEATER_CHAMBER_INVERTING) #endif -#if HAS_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER +/** + * Laser Cooling requires settings + */ +#if HAS_COOLER + #ifndef MAX_COOLER_POWER + #define MAX_COOLER_POWER 255 + #endif + #ifndef COOLER_INVERTING + #define COOLER_INVERTING true + #endif + #define WRITE_HEATER_COOLER(v) WRITE(COOLER_PIN, (v) ^ COOLER_INVERTING) +#endif + +#if HAS_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER || HAS_COOLER #define HAS_TEMPERATURE 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 4da25d0916..cd9ca84385 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1876,6 +1876,10 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_CHAMBER requires TEMP_CHAMBER_PIN." #endif +#if TEMP_SENSOR_COOLER && !(PIN_EXISTS(TEMP_COOLER) && ENABLED(LASER_FEATURE)) + #error "TEMP_SENSOR_COOLER requires LASER_FEATURE and TEMP_COOLER_PIN." +#endif + #if ENABLED(CHAMBER_FAN) && !(defined(CHAMBER_FAN_MODE) && WITHIN(CHAMBER_FAN_MODE, 0, 2)) #error "CHAMBER_FAN_MODE must be between 0 and 2." #endif diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index 61fee3e048..d0dc288613 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -78,6 +78,16 @@ #define STATUS_CUTTER_WIDTH 0 #endif +// +// Laser Cooler +// +#if !STATUS_COOLER_WIDTH && HAS_COOLER + #include "status/cooler.h" +#endif +#ifndef STATUS_COOLER_WIDTH + #define STATUS_COOLER_WIDTH 0 +#endif + // // Bed // @@ -498,6 +508,47 @@ #endif +// +// Cooler Bitmap Properties +// +#ifndef STATUS_COOLER_BYTEWIDTH + #define STATUS_COOLER_BYTEWIDTH BW(STATUS_COOLER_WIDTH) +#endif +#if STATUS_COOLER_WIDTH + + #ifndef STATUS_COOLER_X + #define STATUS_COOLER_X (LCD_PIXEL_WIDTH - (STATUS_COOLER_BYTEWIDTH + STATUS_FAN_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH) * 8) + #endif + + #ifndef STATUS_COOLER_HEIGHT + #ifdef STATUS_COOLER_ANIM + #define STATUS_COOLER_HEIGHT(S) ((S) ? sizeof(status_cooler_on_bmp) / (STATUS_COOLER_BYTEWIDTH) : sizeof(status_cooler_bmp) / (STATUS_COOLER_BYTEWIDTH)) + #else + #define STATUS_COOLER_HEIGHT(S) (sizeof(status_cooler_bmp) / (STATUS_COOLER_BYTEWIDTH)) + #endif + #endif + + #ifndef STATUS_COOLER_Y + #define STATUS_COOLER_Y(S) (18 - STATUS_COOLER_HEIGHT(S)) + #endif + + #ifndef STATUS_COOLER_TEXT_X + #define STATUS_COOLER_TEXT_X (STATUS_COOLER_X + 8) + #endif + + static_assert( + sizeof(status_cooler_bmp) == (STATUS_COOLER_BYTEWIDTH) * (STATUS_COOLER_HEIGHT(0)), + "Status cooler bitmap (status_cooler_bmp) dimensions don't match data." + ); + #ifdef STATUS_COOLER_ANIM + static_assert( + sizeof(status_cooler_on_bmp) == (STATUS_COOLER_BYTEWIDTH) * (STATUS_COOLER_HEIGHT(1)), + "Status cooler bitmap (status_cooler_on_bmp) dimensions don't match data." + ); + #endif + +#endif + // // Bed Bitmap Properties // @@ -585,6 +636,10 @@ #if HAS_CUTTER && !DO_DRAW_BED #define DO_DRAW_CUTTER 1 #endif +#if HAS_COOLER + #define DO_DRAW_COOLER 1 +#endif + #if HAS_TEMP_CHAMBER && STATUS_CHAMBER_WIDTH && HOTENDS <= 4 #define DO_DRAW_CHAMBER 1 #endif @@ -603,6 +658,9 @@ #if BOTH(DO_DRAW_CUTTER, STATUS_CUTTER_ANIM) #define ANIM_CUTTER 1 #endif +#if BOTH(DO_DRAW_COOLER, STATUS_COOLER_ANIM) + #define ANIM_COOLER 1 +#endif #if ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER || ANIM_CUTTER #define ANIM_HBCC 1 #endif diff --git a/Marlin/src/lcd/dogm/status/cooler.h b/Marlin/src/lcd/dogm/status/cooler.h new file mode 100644 index 0000000000..4e59e237a2 --- /dev/null +++ b/Marlin/src/lcd/dogm/status/cooler.h @@ -0,0 +1,70 @@ +/** + * 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 + +// +// lcd/dogm/status/cooler.h - Status Screen Laser Cooler bitmaps +// + +#define STATUS_COOLER_WIDTH 16 + +#ifdef STATUS_COOLER_ANIM + + const unsigned char status_cooler_on_bmp[] PROGMEM = { + B00010000,B00001000, + B00010010,B01001001, + B01010100,B00101010, + B00111000,B00011100, + B11111110,B11111111, + B00111000,B00011100, + B01010100,B00101010, + B10010000,B10001001, + B00010000,B10000000, + B00000100,B10010000, + B00000010,B10100000, + B00000001,B11000000, + B00011111,B11111100, + B00000001,B11000000, + B00000010,B10100000, + B00000100,B10010000 + }; + +#endif + +const unsigned char status_cooler_bmp[] PROGMEM = { + B00010000,B00001000, + B00010010,B01001001, + B01010100,B00101010, + B00101000,B00010100, + B11000111,B01100011, + B00101000,B00010100, + B01010100,B00101010, + B10010000,B10001001, + B00010000,B10000000, + B00000100,B10010000, + B00000010,B10100000, + B00000001,B01000000, + B00011110,B00111100, + B00000001,B01000000, + B00000010,B10100000, + B00000100,B10010000 +}; diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 8ae6ab6627..892ab5218b 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -86,6 +86,7 @@ HEATBIT_HOTEND, HEATBIT_BED = HOTENDS, HEATBIT_CHAMBER, + HEATBIT_COOLER, HEATBIT_CUTTER }; IF<(HEATBIT_CUTTER > 7), uint16_t, uint8_t>::type heat_bits; @@ -111,6 +112,11 @@ #else #define CUTTER_ALT() false #endif +#if ANIM_COOLER + #define COOLER_ALT(N) TEST(heat_bits, HEATBIT_COOLER) +#else + #define COOLER_ALT() false +#endif #if DO_DRAW_HOTENDS #define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE))) @@ -361,18 +367,22 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons #endif // DO_DRAW_BED #if DO_DRAW_CHAMBER - FORCE_INLINE void _draw_chamber_status() { #if HAS_HEATED_CHAMBER if (PAGE_UNDER(7)) _draw_centered_temp(thermalManager.degTargetChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 7); #endif - if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) _draw_centered_temp(thermalManager.degChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 28); } +#endif -#endif // DO_DRAW_CHAMBER +#if DO_DRAW_COOLER + FORCE_INLINE void _draw_cooler_status() { + if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) + _draw_centered_temp(thermalManager.degCooler(), STATUS_COOLER_TEXT_X, 28); + } +#endif // // Before homing, blink '123' <-> '???'. @@ -447,6 +457,9 @@ void MarlinUI::draw_status_screen() { #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER if (thermalManager.isHeatingChamber()) SBI(new_bits, HEATBIT_CHAMBER); #endif + #if DO_DRAW_COOLER && HAS_COOLER + if (thermalManager.isLaserCooling()) SBI(new_bits, HEATBIT_COOLER); + #endif if (TERN0(ANIM_CUTTER, cutter.enabled())) SBI(new_bits, HEATBIT_CUTTER); heat_bits = new_bits; #endif @@ -631,12 +644,28 @@ void MarlinUI::draw_status_screen() { } #endif + // Laser Cooler + #if DO_DRAW_COOLER + #if ANIM_COOLER + #define COOLER_BITMAP(S) ((S) ? status_cooler_bmp : status_cooler_on_bmp) + #else + #define COOLER_BITMAP(S) status_cooler_bmp + #endif + const uint8_t coolery = STATUS_COOLER_Y(COOLER_ALT()), + coolerh = STATUS_COOLER_HEIGHT(COOLER_ALT()); + if (PAGE_CONTAINS(coolery, coolery + coolerh - 1)) + u8g.drawBitmapP(STATUS_COOLER_X, coolery, STATUS_COOLER_BYTEWIDTH, coolerh, COOLER_BITMAP(COOLER_ALT())); + #endif + // Heated Bed TERN_(DO_DRAW_BED, _draw_bed_status(blink)); // Heated Chamber TERN_(DO_DRAW_CHAMBER, _draw_chamber_status()); + // Cooler + TERN_(DO_DRAW_COOLER, _draw_cooler_status()); + // Fan, if a bitmap was provided #if DO_DRAW_FAN if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) { diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 7c178a0339..c5c35321ca 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -176,6 +176,7 @@ namespace ExtUI { case BED: thermalManager.reset_bed_idle_timer(); return; #endif TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return); // Chamber has no idle timer + TERN_(HAS_COOLER, case COOLER: return); // Cooler has no idle timer default: TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0)); break; @@ -904,22 +905,23 @@ namespace ExtUI { value *= TOUCH_UI_LCD_TEMP_SCALING; #endif enableHeater(heater); - #if HAS_HEATED_CHAMBER - if (heater == CHAMBER) - thermalManager.setTargetChamber(LROUND(constrain(value, 0, CHAMBER_MAXTEMP - 10))); - else - #endif - #if HAS_HEATED_BED - if (heater == BED) - thermalManager.setTargetBed(LROUND(constrain(value, 0, BED_MAX_TARGET))); - else - #endif - { + switch (heater) { + #if HAS_HEATED_CHAMBER + case CHAMBER: thermalManager.setTargetChamber(LROUND(constrain(value, 0, CHAMBER_MAXTEMP - 10))); break; + #endif + #if HAS_COOLER + case COOLER: thermalManager.setTargetCooler(LROUND(constrain(value, 0, COOLER_MAXTEMP))); break; + #endif + #if HAS_HEATED_BED + case BED: thermalManager.setTargetBed(LROUND(constrain(value, 0, BED_MAX_TARGET))); break; + #endif + default: { #if HAS_HOTEND const int16_t e = heater - H0; thermalManager.setTargetHotend(LROUND(constrain(value, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT)), e); #endif - } + } break; + } } void setTargetTemp_celsius(float value, const extruder_t extruder) { diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 4214ba5821..a6cfb82b88 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -55,7 +55,7 @@ namespace ExtUI { enum axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 }; enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 }; - enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER }; + enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER, COOLER }; enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 }; enum result_t : uint8_t { PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE }; diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index b17e81d831..72f262c687 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -276,6 +276,9 @@ namespace Language_en { PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Nozzle Standby"); PROGMEM Language_Str MSG_BED = _UxGT("Bed"); PROGMEM Language_Str MSG_CHAMBER = _UxGT("Enclosure"); + PROGMEM Language_Str MSG_COOLER = _UxGT("Laser Coolant"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Toggle Cooler"); + PROGMEM Language_Str MSG_LASER = _UxGT("Laser"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Fan Speed"); PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Fan Speed ~"); PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Stored Fan ~"); @@ -482,6 +485,8 @@ namespace Language_en { PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("THERMAL RUNAWAY"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("BED THERMAL RUNAWAY"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("CHAMBER T. RUNAWAY"); + PROGMEM Language_Str MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Cooler Runaway"); + PROGMEM Language_Str MSG_COOLING_FAILED = _UxGT("Cooling Failed"); PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("Err: MAXTEMP"); PROGMEM Language_Str MSG_ERR_MINTEMP = _UxGT("Err: MINTEMP"); PROGMEM Language_Str MSG_HALTED = _UxGT("PRINTER HALTED"); @@ -497,6 +502,7 @@ namespace Language_en { PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Probe Cooling..."); PROGMEM Language_Str MSG_CHAMBER_HEATING = _UxGT("Chamber Heating..."); PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Chamber Cooling..."); + PROGMEM Language_Str MSG_LASER_COOLING = _UxGT("Laser Cooling..."); PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Delta Calibration"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("Calibrate X"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Calibrate Y"); diff --git a/Marlin/src/lcd/menu/menu_info.cpp b/Marlin/src/lcd/menu/menu_info.cpp index a4cbc31d8b..d00909c7b3 100644 --- a/Marlin/src/lcd/menu/menu_info.cpp +++ b/Marlin/src/lcd/menu/menu_info.cpp @@ -195,6 +195,16 @@ void menu_info_thermistors() { STATIC_ITEM(TERN(WATCH_CHAMBER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); #endif + #if HAS_COOLER + #undef THERMISTOR_ID + #define THERMISTOR_ID TEMP_SENSOR_COOLER + #include "../thermistornames.h" + STATIC_ITEM_P(PSTR("COOL: " THERMISTOR_NAME), SS_INVERT); + PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(COOLER_MINTEMP), SS_LEFT); + PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(COOLER_MAXTEMP), SS_LEFT); + STATIC_ITEM(TERN(WATCH_COOLER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); + #endif + END_SCREEN(); } diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index f347efe6db..3a9906ddeb 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -35,6 +35,10 @@ #include "../../module/motion.h" #endif +#if HAS_COOLER + #include "../../feature/cooler.h" +#endif + #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) #include "../../module/tool_change.h" #endif @@ -68,6 +72,10 @@ void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t i #if HAS_HEATED_BED inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(-1, -1, m); } #endif + #if HAS_COOLER + inline void _precool_laser(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); } + void do_precool_laser_m() { _precool_laser(editable.int8, thermalManager.temp_cooler.target); } + #endif #if HAS_TEMP_HOTEND && HAS_HEATED_BED inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); } @@ -143,6 +151,10 @@ void menu_temperature() { #endif #endif + #if HAS_COOLER + if (thermalManager.temp_cooler.target == 0) thermalManager.temp_cooler.target = COOLER_DEFAULT_TEMP; + #endif + START_MENU(); BACK_ITEM(MSG_MAIN); @@ -176,6 +188,15 @@ void menu_temperature() { EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber); #endif + // + // Cooler: + // + #if HAS_COOLER + editable.state = cooler.is_enabled(); + EDIT_ITEM(bool, MSG_COOLER(TOGGLE), &cooler.state, []{ if (editable.state) cooler.disable(); else cooler.enable(); }); + EDIT_ITEM_FAST(int3, MSG_COOLER, &thermalManager.temp_cooler.target, COOLER_MINTEMP + 2, COOLER_MAXTEMP - 2, thermalManager.start_watching_cooler); + #endif + // // Fan Speed: // @@ -232,7 +253,7 @@ void menu_temperature() { editable.int8 = m; #if HOTENDS > 1 || HAS_HEATED_BED SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m); - #else + #elif HAS_HOTEND ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); #endif } diff --git a/Marlin/src/lcd/tft/tft_color.h b/Marlin/src/lcd/tft/tft_color.h index a72a079f6e..d060d3209d 100644 --- a/Marlin/src/lcd/tft/tft_color.h +++ b/Marlin/src/lcd/tft/tft_color.h @@ -94,6 +94,9 @@ #ifndef COLOR_CHAMBER #define COLOR_CHAMBER COLOR_DARK_ORANGE #endif +#ifndef COLOR_COOLER + #define COLOR_COOLER COLOR_DARK_ORANGE +#endif #ifndef COLOR_FAN #define COLOR_FAN COLOR_AQUA #endif diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 7a45851a5d..29dd088c99 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -202,6 +202,12 @@ void Touch::touch(touch_control_t *control) { MenuItem_int3::action((const char *)GET_TEXT_F(MSG_CHAMBER), &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber); } #endif + #if HAS_COOLER + else if (heater == H_COOLER) { + MenuItem_int3::action((const char *)GET_TEXT_F(MSG_COOLER), &thermalManager.temp_cooler.target, 0, COOLER_MAXTEMP - 8, thermalManager.start_watching_cooler); + } + #endif + break; case FAN: ui.clear_lcd(); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index eadd09ef27..fb82188645 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -136,6 +136,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { #endif } #endif + #if HAS_TEMP_COOLER + else if (Heater == H_COOLER) { + currentTemperature = thermalManager.degCooler(); + targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO); + } + #endif else return; TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 64, 100, Heater)); @@ -159,6 +165,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { image = targetTemperature > 0 ? imgChamberHeated : imgChamber; } #endif + #if HAS_TEMP_COOLER + else if (Heater == H_COOLER) { + if (currentTemperature <= 26) Color = COLOR_COLD; + if (currentTemperature > 26) Color = COLOR_RED; + image = targetTemperature > 26 ? imgCoolerHot : imgCooler; + } + #endif tft.add_image(0, 18, image, Color); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 5000aedc39..164785a229 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -136,6 +136,12 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { #endif } #endif + #if HAS_TEMP_COOLER + else if (Heater == H_COOLER) { + currentTemperature = thermalManager.degCooler(); + targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO); + } + #endif else return; TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 80, 120, Heater)); diff --git a/Marlin/src/lcd/tft/ui_common.h b/Marlin/src/lcd/tft/ui_common.h index d40e471171..d43de1d43b 100644 --- a/Marlin/src/lcd/tft/ui_common.h +++ b/Marlin/src/lcd/tft/ui_common.h @@ -62,6 +62,10 @@ void menu_item(const uint8_t row, bool sel = false); #define ITEM_CHAMBER 2 #define ITEM_FAN 3 #define ITEMS_COUNT 4 +#elif HAS_TEMP_COOLER + #define ITEM_COOLER 0 + #define ITEM_FAN 1 + #define ITEMS_COUNT 2 #elif HOTENDS > 1 #define ITEM_E0 0 #define ITEM_E1 1 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index be98972b77..a1d5745de4 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -35,6 +35,11 @@ #include "endstops.h" #include "planner.h" +#if HAS_COOLER + #include "../feature/cooler.h" + #include "../feature/spindle_laser.h" +#endif + #if ENABLED(EMERGENCY_PARSER) #include "motion.h" #endif @@ -232,8 +237,13 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #else #define _CHAMBER_PSTR(h) #endif +#if HAS_COOLER + #define _COOLER_PSTR(h) (h) == H_COOLER ? GET_TEXT(MSG_COOLER) : +#else + #define _COOLER_PSTR(h) +#endif #define _E_PSTR(h,N) ((HOTENDS) > N && (h) == N) ? PSTR(LCD_STR_E##N) : -#define HEATER_PSTR(h) _BED_PSTR(h) _CHAMBER_PSTR(h) _E_PSTR(h,1) _E_PSTR(h,2) _E_PSTR(h,3) _E_PSTR(h,4) _E_PSTR(h,5) PSTR(LCD_STR_E0) +#define HEATER_PSTR(h) _BED_PSTR(h) _CHAMBER_PSTR(h) _COOLER_PSTR(h) _E_PSTR(h,1) _E_PSTR(h,2) _E_PSTR(h,3) _E_PSTR(h,4) _E_PSTR(h,5) PSTR(LCD_STR_E0) // public: @@ -254,6 +264,9 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, uint8_t Temperature::chamberfan_speed; // = 0 #endif +#if ENABLED(AUTO_POWER_COOLER_FAN) + uint8_t Temperature::coolerfan_speed; // = 0 +#endif #if HAS_FAN uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } @@ -355,14 +368,11 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #endif TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); -#endif // HAS_HEATED_BED +#endif #if HAS_TEMP_CHAMBER chamber_info_t Temperature::temp_chamber; // = { 0 } #if HAS_HEATED_CHAMBER - int16_t fan_chamber_pwm; - bool flag_chamber_off; - bool flag_chamber_excess_heat = false; millis_t next_cool_check_ms_2 = 0; float old_temp = 9999; #ifdef CHAMBER_MINTEMP @@ -373,8 +383,27 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #endif TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0}); IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms); - #endif // HAS_HEATED_CHAMBER -#endif // HAS_TEMP_CHAMBER + #endif +#endif + +#if HAS_TEMP_COOLER + cooler_info_t Temperature::temp_cooler; // = { 0 } + #if HAS_COOLER + bool flag_cooler_state; + //bool flag_cooler_excess = false; + float previous_temp = 9999; + #ifdef COOLER_MINTEMP + int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP; + #endif + #ifdef COOLER_MAXTEMP + int16_t Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; + #endif + #if WATCH_COOLER + cooler_watch_t Temperature::watch_cooler{0}; + #endif + millis_t Temperature::next_cooler_check_ms, Temperature::cooler_fan_flush_ms; + #endif +#endif #if HAS_TEMP_PROBE probe_info_t Temperature::temp_probe; // = { 0 } @@ -744,6 +773,9 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #if HAS_HEATED_CHAMBER case H_CHAMBER: return temp_chamber.soft_pwm_amount; #endif + #if HAS_COOLER + case H_COOLER: return temp_cooler.soft_pwm_amount; + #endif default: return TERN0(HAS_HOTEND, temp_hotend[heater_id].soft_pwm_amount); } @@ -779,6 +811,11 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { SBI(fanState, pgm_read_byte(&fanBit[CHAMBER_FAN_INDEX])); #endif + #if HAS_AUTO_COOLER_FAN + if (temp_cooler.celsius >= COOLER_AUTO_FAN_TEMPERATURE) + SBI(fanState, pgm_read_byte(&fanBit[COOLER_FAN_INDEX])); + #endif + #define _UPDATE_AUTO_FAN(P,D,A) do{ \ if (PWM_PIN(P##_AUTO_FAN_PIN) && A < 255) \ analogWrite(pin_t(P##_AUTO_FAN_PIN), D ? A : 0); \ @@ -874,6 +911,8 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms SERIAL_ECHO(heater_id); else if (TERN0(HAS_HEATED_CHAMBER, heater_id == H_CHAMBER)) SERIAL_ECHOPGM(STR_HEATER_CHAMBER); + else if (TERN0(HAS_COOLER, heater_id == H_COOLER)) + SERIAL_ECHOPGM(STR_COOLER); else SERIAL_ECHOPGM(STR_HEATER_BED); SERIAL_EOL(); @@ -1347,11 +1386,18 @@ void Temperature::manage_heater() { } #endif + #if EITHER(CHAMBER_FAN, CHAMBER_VENT) || DISABLED(PIDTEMPCHAMBER) + static bool flag_chamber_excess_heat; // = false; + #endif + #if EITHER(CHAMBER_FAN, CHAMBER_VENT) + static bool flag_chamber_off; // = false + if (temp_chamber.target > CHAMBER_MINTEMP) { flag_chamber_off = false; #if ENABLED(CHAMBER_FAN) + int16_t fan_chamber_pwm; #if CHAMBER_FAN_MODE == 0 fan_chamber_pwm = CHAMBER_FAN_BASE; #elif CHAMBER_FAN_MODE == 1 @@ -1376,7 +1422,8 @@ void Temperature::manage_heater() { // Open vent after MIN_COOLING_SLOPE_TIME_CHAMBER_VENT seconds if the // temperature didn't drop at least MIN_COOLING_SLOPE_DEG_CHAMBER_VENT if (next_cool_check_ms_2 == 0 || ELAPSED(ms, next_cool_check_ms_2)) { - if (old_temp - temp_chamber.celsius < float(MIN_COOLING_SLOPE_DEG_CHAMBER_VENT)) flag_chamber_excess_heat = true; //the bed is heating the chamber too much + if (temp_chamber.celsius - old_temp > MIN_COOLING_SLOPE_DEG_CHAMBER_VENT) + flag_chamber_excess_heat = true; // the bed is heating the chamber too much next_cool_check_ms_2 = ms + SEC_TO_MS(MIN_COOLING_SLOPE_TIME_CHAMBER_VENT); old_temp = temp_chamber.celsius; } @@ -1385,9 +1432,8 @@ void Temperature::manage_heater() { next_cool_check_ms_2 = 0; old_temp = 9999; } - if (flag_chamber_excess_heat && (temp_chamber.celsius - temp_chamber.target <= -LOW_EXCESS_HEAT_LIMIT) ) { + if (flag_chamber_excess_heat && (temp_chamber.target - temp_chamber.celsius >= LOW_EXCESS_HEAT_LIMIT)) flag_chamber_excess_heat = false; - } #endif } else if (!flag_chamber_off) { @@ -1402,17 +1448,14 @@ void Temperature::manage_heater() { } #endif - - - #if ENABLED(PIDTEMPCHAMBER) // PIDTEMPCHAMBER doens't support a CHAMBER_VENT yet. temp_chamber.soft_pwm_amount = WITHIN(temp_chamber.celsius, CHAMBER_MINTEMP, CHAMBER_MAXTEMP) ? (int)get_pid_output_chamber() >> 1 : 0; #else - if (ELAPSED(ms, next_chamber_check_ms)) { - next_chamber_check_ms = ms + CHAMBER_CHECK_INTERVAL; + if (ELAPSED(ms, next_chamber_check_ms)) { + next_chamber_check_ms = ms + CHAMBER_CHECK_INTERVAL; - if (WITHIN(temp_chamber.celsius, CHAMBER_MINTEMP, CHAMBER_MAXTEMP)) { + if (WITHIN(temp_chamber.celsius, CHAMBER_MINTEMP, CHAMBER_MAXTEMP)) { if (flag_chamber_excess_heat) { temp_chamber.soft_pwm_amount = 0; #if ENABLED(CHAMBER_VENT) @@ -1437,7 +1480,6 @@ void Temperature::manage_heater() { temp_chamber.soft_pwm_amount = 0; WRITE_HEATER_CHAMBER(LOW); } - } #if ENABLED(THERMAL_PROTECTION_CHAMBER) tr_state_machine[RUNAWAY_IND_CHAMBER].run(temp_chamber.celsius, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS); @@ -1446,6 +1488,66 @@ void Temperature::manage_heater() { #endif // HAS_HEATED_CHAMBER + #if HAS_COOLER + + #ifndef COOLER_CHECK_INTERVAL + #define COOLER_CHECK_INTERVAL 2000UL + #endif + + #if ENABLED(THERMAL_PROTECTION_COOLER) + if (degCooler() > COOLER_MAXTEMP) max_temp_error(H_COOLER); + #endif + + #if WATCH_COOLER + // Make sure temperature is decreasing + if (watch_cooler.elapsed(ms)) { // Time to check the cooler? + if (degCooler() > watch_cooler.target) // Failed to decrease enough? + _temp_error(H_COOLER, GET_TEXT(MSG_COOLING_FAILED), GET_TEXT(MSG_COOLING_FAILED)); + else + start_watching_cooler(); // Start again if the target is still far off + } + #endif + + static bool flag_cooler_state; // = false + + if (cooler.is_enabled()) { + flag_cooler_state = true; // used to allow M106 fan control when cooler is disabled + if (temp_cooler.target == 0) temp_cooler.target = COOLER_MINTEMP; + if (ELAPSED(ms, next_cooler_check_ms)) { + next_cooler_check_ms = ms + COOLER_CHECK_INTERVAL; + if (temp_cooler.celsius > temp_cooler.target) { + temp_cooler.soft_pwm_amount = temp_cooler.celsius > temp_cooler.target ? MAX_COOLER_POWER : 0; + flag_cooler_state = temp_cooler.soft_pwm_amount > 0 ? true : false; // used to allow M106 fan control when cooler is disabled + #if ENABLED(COOLER_FAN) + int16_t fan_cooler_pwm = (COOLER_FAN_BASE) + (COOLER_FAN_FACTOR) * ABS(temp_cooler.celsius - temp_cooler.target); + NOMORE(fan_cooler_pwm, 255); + set_fan_speed(COOLER_FAN_INDEX, fan_cooler_pwm); // Set cooler fan pwm + cooler_fan_flush_ms = ms + 5000; + #endif + } + else { + temp_cooler.soft_pwm_amount = 0; + #if ENABLED(COOLER_FAN) + set_fan_speed(COOLER_FAN_INDEX, temp_cooler.celsius > temp_cooler.target - 2 ? COOLER_FAN_BASE : 0); + #endif + WRITE_HEATER_COOLER(LOW); + } + } + } + else { + temp_cooler.soft_pwm_amount = 0; + if (flag_cooler_state) { + flag_cooler_state = false; + thermalManager.set_fan_speed(COOLER_FAN_INDEX, 0); + } + WRITE_HEATER_COOLER(LOW); + } + + #if ENABLED(THERMAL_PROTECTION_COOLER) + tr_state_machine[RUNAWAY_IND_COOLER].run(temp_cooler.celsius, temp_cooler.target, H_COOLER, THERMAL_PROTECTION_COOLER_PERIOD, THERMAL_PROTECTION_COOLER_HYSTERESIS); + #endif + #endif // HAS_COOLER + UNUSED(ms); } @@ -1510,6 +1612,9 @@ void Temperature::manage_heater() { #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_COOLER_IS_CUSTOM + { true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_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 @@ -1543,6 +1648,7 @@ void Temperature::manage_heater() { 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_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? PSTR("COOLER") :) TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :) nullptr ); @@ -1706,7 +1812,6 @@ void Temperature::manage_heater() { #endif // HAS_HOTEND #if HAS_HEATED_BED - // Derived from RepRap FiveD extruder::getTemperature() // For bed temperature measurement. float Temperature::analog_to_celsius_bed(const int raw) { #if TEMP_SENSOR_BED_IS_CUSTOM @@ -1725,7 +1830,6 @@ void Temperature::manage_heater() { #endif // HAS_HEATED_BED #if HAS_TEMP_CHAMBER - // Derived from RepRap FiveD extruder::getTemperature() // For chamber temperature measurement. float Temperature::analog_to_celsius_chamber(const int raw) { #if TEMP_SENSOR_CHAMBER_IS_CUSTOM @@ -1743,8 +1847,25 @@ void Temperature::manage_heater() { } #endif // HAS_TEMP_CHAMBER +#if HAS_TEMP_COOLER + // For cooler temperature measurement. + float Temperature::analog_to_celsius_cooler(const int raw) { + #if TEMP_SENSOR_COOLER_IS_CUSTOM + return user_thermistor_to_deg_c(CTI_COOLER, raw); + #elif TEMP_SENSOR_COOLER_IS_THERMISTOR + SCAN_THERMISTOR_TABLE(TEMPTABLE_COOLER, TEMPTABLE_COOLER_LEN); + #elif TEMP_SENSOR_COOLER_IS_AD595 + return TEMP_AD595(raw); + #elif TEMP_SENSOR_COOLER_IS_AD8495 + return TEMP_AD8495(raw); + #else + UNUSED(raw); + return 0; + #endif + } +#endif // HAS_TEMP_COOLER + #if HAS_TEMP_PROBE - // Derived from RepRap FiveD extruder::getTemperature() // For probe temperature measurement. float Temperature::analog_to_celsius_probe(const int raw) { #if TEMP_SENSOR_PROBE_IS_CUSTOM @@ -1776,6 +1897,7 @@ void Temperature::updateTemperaturesFromRawValues() { #endif TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw)); TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw)); + TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.raw)); TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw)); TERN_(TEMP_SENSOR_1_AS_REDUNDANT, redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1)); TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); @@ -1927,6 +2049,10 @@ void Temperature::init() { OUT_WRITE(HEATER_CHAMBER_PIN, HEATER_CHAMBER_INVERTING); #endif + #if HAS_COOLER + OUT_WRITE(COOLER_PIN, COOLER_INVERTING); + #endif + #if HAS_FAN0 INIT_FAN_PIN(FAN_PIN); #endif @@ -2001,6 +2127,9 @@ void Temperature::init() { #if HAS_TEMP_ADC_CHAMBER HAL_ANALOG_SELECT(TEMP_CHAMBER_PIN); #endif + #if HAS_TEMP_ADC_COOLER + HAL_ANALOG_SELECT(TEMP_COOLER_PIN); + #endif #if HAS_TEMP_ADC_PROBE HAL_ANALOG_SELECT(TEMP_PROBE_PIN); #endif @@ -2137,6 +2266,15 @@ void Temperature::init() { #endif #endif + #if HAS_COOLER + #ifdef COOLER_MINTEMP + while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR); + #endif + #ifdef COOLER_MAXTEMP + while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR); + #endif + #endif + TERN_(PROBING_HEATERS_OFF, paused = false); } @@ -2174,6 +2312,17 @@ void Temperature::init() { } #endif +#if WATCH_COOLER + /** + * Start Cooling Sanity Check for cooler that is above + * its target temperature by a configurable margin. + * This is called when the temperature is set. (M143, M193) + */ + void Temperature::start_watching_cooler() { + watch_cooler.restart(degCooler(), degTargetCooler()); + } +#endif + #if HAS_THERMAL_PROTECTION Temperature::tr_state_machine_t Temperature::tr_state_machine[NR_HEATER_RUNAWAY]; // = { { TRInactive, 0 } }; @@ -2301,10 +2450,18 @@ void Temperature::disable_all_heaters() { temp_chamber.soft_pwm_amount = 0; WRITE_HEATER_CHAMBER(LOW); #endif + + #if HAS_COOLER + setTargetCooler(0); + temp_cooler.soft_pwm_amount = 0; + WRITE_HEATER_COOLER(LOW); + #endif } #if ENABLED(PRINTJOB_TIMER_AUTOSTART) + #include "printcounter.h" + bool Temperature::auto_job_over_threshold() { #if HAS_HOTEND HOTEND_LOOP() if (degTargetHotend(e) > (EXTRUDE_MINTEMP) / 2) return true; @@ -2564,6 +2721,7 @@ void Temperature::update_raw_temperatures() { TERN_(HAS_TEMP_ADC_BED, temp_bed.update()); TERN_(HAS_TEMP_ADC_CHAMBER, temp_chamber.update()); TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); + TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); TERN_(HAS_JOY_ADC_X, joystick.x.update()); TERN_(HAS_JOY_ADC_Y, joystick.y.update()); @@ -2588,6 +2746,7 @@ void Temperature::readings_ready() { TERN_(HAS_HEATED_BED, temp_bed.reset()); TERN_(HAS_TEMP_CHAMBER, temp_chamber.reset()); TERN_(HAS_TEMP_PROBE, temp_probe.reset()); + TERN_(HAS_TEMP_COOLER, temp_cooler.reset()); TERN_(HAS_JOY_ADC_X, joystick.x.reset()); TERN_(HAS_JOY_ADC_Y, joystick.y.reset()); @@ -2650,6 +2809,18 @@ void Temperature::readings_ready() { if (CHAMBERCMP(temp_chamber.raw, maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); if (chamber_on && CHAMBERCMP(mintemp_raw_CHAMBER, temp_chamber.raw)) min_temp_error(H_CHAMBER); #endif + + #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) + #if TEMPDIR(COOLER) < 0 + #define COOLERCMP(A,B) ((A)<(B)) + #else + #define COOLERCMP(A,B) ((A)>(B)) + #endif + if (cutter.unitPower > 0) { + if (COOLERCMP(temp_cooler.raw, maxtemp_raw_COOLER)) max_temp_error(H_COOLER); + } + if (COOLERCMP(mintemp_raw_COOLER, temp_cooler.raw)) min_temp_error(H_COOLER); + #endif } /** @@ -2735,11 +2906,15 @@ void Temperature::tick() { static SoftPWM soft_pwm_chamber; #endif + #if HAS_COOLER + static SoftPWM soft_pwm_cooler; + #endif + #define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ FAN_INVERTING) #if DISABLED(SLOW_PWM_HEATERS) - #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_HEATED_CHAMBER, FAN_SOFT_PWM) + #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_HEATED_CHAMBER, HAS_COOLER, FAN_SOFT_PWM) constexpr uint8_t pwm_mask = TERN0(SOFT_PWM_DITHER, _BV(SOFT_PWM_SCALE) - 1); #define _PWM_MOD(N,S,T) do{ \ const bool on = S.add(pwm_mask, T.soft_pwm_amount); \ @@ -2766,6 +2941,10 @@ void Temperature::tick() { _PWM_MOD(CHAMBER,soft_pwm_chamber,temp_chamber); #endif + #if HAS_COOLER + _PWM_MOD(COOLER,soft_pwm_cooler,temp_cooler); + #endif + #if ENABLED(FAN_SOFT_PWM) #define _FAN_PWM(N) do{ \ uint8_t &spcf = soft_pwm_count_fan[N]; \ @@ -2813,6 +2992,10 @@ void Temperature::tick() { _PWM_LOW(CHAMBER, soft_pwm_chamber); #endif + #if HAS_COOLER + _PWM_LOW(COOLER, soft_pwm_cooler); + #endif + #if ENABLED(FAN_SOFT_PWM) #if HAS_FAN0 if (soft_pwm_count_fan[0] <= pwm_count_tmp) WRITE_FAN(0, LOW); @@ -2879,6 +3062,10 @@ void Temperature::tick() { _SLOW_PWM(CHAMBER, soft_pwm_chamber, temp_chamber); #endif + #if HAS_COOLER + _SLOW_PWM(COOLER, soft_pwm_cooler, temp_cooler); + #endif + } // slow_pwm_count == 0 #if HAS_HOTEND @@ -2894,6 +3081,10 @@ void Temperature::tick() { _PWM_OFF(CHAMBER, soft_pwm_chamber); #endif + #if HAS_COOLER + _PWM_OFF(COOLER, soft_pwm_cooler, temp_cooler); + #endif + #if ENABLED(FAN_SOFT_PWM) if (pwm_count_tmp >= 127) { pwm_count_tmp = 0; @@ -2973,6 +3164,7 @@ void Temperature::tick() { #endif TERN_(HAS_HEATED_BED, soft_pwm_bed.dec()); TERN_(HAS_HEATED_CHAMBER, soft_pwm_chamber.dec()); + TERN_(HAS_COOLER, soft_pwm_cooler.dec()); } #endif // SLOW_PWM_HEATERS @@ -3040,6 +3232,11 @@ void Temperature::tick() { case MeasureTemp_CHAMBER: ACCUMULATE_ADC(temp_chamber); break; #endif + #if HAS_TEMP_ADC_COOLER + case PrepareTemp_COOLER: HAL_START_ADC(TEMP_COOLER_PIN); break; + case MeasureTemp_COOLER: ACCUMULATE_ADC(temp_cooler); break; + #endif + #if HAS_TEMP_ADC_PROBE case PrepareTemp_PROBE: HAL_START_ADC(TEMP_PROBE_PIN); break; case MeasureTemp_PROBE: ACCUMULATE_ADC(temp_probe); break; @@ -3183,22 +3380,24 @@ void Temperature::tick() { ) { char k; switch (e) { + default: + #if HAS_TEMP_HOTEND + k = 'T'; break; + #endif + #if HAS_TEMP_BED + case H_BED: k = 'B'; break; + #endif #if HAS_TEMP_CHAMBER case H_CHAMBER: k = 'C'; break; #endif #if HAS_TEMP_PROBE case H_PROBE: k = 'P'; break; #endif - #if HAS_TEMP_HOTEND - default: k = 'T'; break; - #if HAS_HEATED_BED - case H_BED: k = 'B'; break; - #endif - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - case H_REDUNDANT: k = 'R'; break; - #endif - #elif HAS_HEATED_BED - default: k = 'B'; break; + #if HAS_TEMP_COOLER + case H_COOLER: k = 'L'; break; + #endif + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + case H_REDUNDANT: k = 'R'; break; #endif } SERIAL_CHAR(' ', k); @@ -3251,18 +3450,21 @@ void Temperature::tick() { ); #endif #if HAS_TEMP_CHAMBER - print_heater_state(degChamber() - #if HAS_HEATED_CHAMBER - , degTargetChamber() - #else - , 0 - #endif + print_heater_state(degChamber(), TERN0(HAS_HEATED_CHAMBER, degTargetChamber()) #if ENABLED(SHOW_TEMP_ADC_VALUES) , rawChamberTemp() #endif , H_CHAMBER ); - #endif + #endif // HAS_TEMP_CHAMBER + #if HAS_TEMP_COOLER + print_heater_state(degCooler(), TERN0(HAS_COOLER, degTargetCooler()) + #if ENABLED(SHOW_TEMP_ADC_VALUES) + , rawCoolerTemp() + #endif + , H_COOLER + ); + #endif // HAS_TEMP_COOLER #if HAS_TEMP_PROBE print_heater_state(degProbe(), 0 #if ENABLED(SHOW_TEMP_ADC_VALUES) @@ -3286,6 +3488,9 @@ void Temperature::tick() { #if HAS_HEATED_CHAMBER SERIAL_ECHOPAIR(" C@:", getHeaterPower(H_CHAMBER)); #endif + #if HAS_COOLER + SERIAL_ECHOPAIR(" C@:", getHeaterPower(H_COOLER)); + #endif #if HAS_MULTI_HOTEND HOTEND_LOOP() { SERIAL_ECHOPAIR(" @", e); @@ -3759,4 +3964,103 @@ void Temperature::tick() { #endif // HAS_HEATED_CHAMBER + #if HAS_COOLER + + #ifndef MIN_COOLING_SLOPE_DEG_COOLER + #define MIN_COOLING_SLOPE_DEG_COOLER 1.50 + #endif + #ifndef MIN_COOLING_SLOPE_TIME_COOLER + #define MIN_COOLING_SLOPE_TIME_COOLER 120 + #endif + + bool Temperature::wait_for_cooler(const bool no_wait_for_cooling/*=true*/) { + + #if TEMP_COOLER_RESIDENCY_TIME > 0 + millis_t residency_start_ms = 0; + bool first_loop = true; + // Loop until the temperature has stabilized + #define TEMP_COOLER_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + SEC_TO_MS(TEMP_COOLER_RESIDENCY_TIME))) + #else + // Loop until the temperature is very close target + #define TEMP_COOLER_CONDITIONS (wants_to_cool ? isLaserHeating() : isLaserCooling()) + #endif + + #if DISABLED(BUSY_WHILE_HEATING) && ENABLED(HOST_KEEPALIVE_FEATURE) + KEEPALIVE_STATE(NOT_BUSY); + #endif + + bool wants_to_cool = false; + float target_temp = -1, previous_temp = 9999; + millis_t now, next_temp_ms = 0, next_cooling_check_ms = 0; + wait_for_heatup = true; + do { + // Target temperature might be changed during the loop + if (target_temp != degTargetCooler()) { + wants_to_cool = isLaserHeating(); + target_temp = degTargetCooler(); + + // Exit if S, continue if S, R, or R + if (no_wait_for_cooling && wants_to_cool) break; + } + + now = millis(); + if (ELAPSED(now, next_temp_ms)) { // Print Temp Reading every 1 second while heating up. + next_temp_ms = now + 1000UL; + print_heater_states(active_extruder); + #if TEMP_COOLER_RESIDENCY_TIME > 0 + SERIAL_ECHOPGM(" W:"); + if (residency_start_ms) + SERIAL_ECHO(long((SEC_TO_MS(TEMP_COOLER_RESIDENCY_TIME) - (now - residency_start_ms)) / 1000UL)); + else + SERIAL_CHAR('?'); + #endif + SERIAL_EOL(); + } + + idle(); + gcode.reset_stepper_timeout(); // Keep steppers powered + + const float current_temp = degCooler(); + + #if TEMP_COOLER_RESIDENCY_TIME > 0 + + const float temp_diff = ABS(target_temp - temp); + + if (!residency_start_ms) { + // Start the TEMP_COOLER_RESIDENCY_TIME timer when we reach target temp for the first time. + if (temp_diff < TEMP_COOLER_WINDOW) + residency_start_ms = now + (first_loop ? SEC_TO_MS(TEMP_COOLER_RESIDENCY_TIME) / 3 : 0); + } + else if (temp_diff > TEMP_COOLER_HYSTERESIS) { + // Restart the timer whenever the temperature falls outside the hysteresis. + residency_start_ms = now; + } + + first_loop = false; + #endif // TEMP_COOLER_RESIDENCY_TIME > 0 + + if (wants_to_cool) { + // Break after MIN_COOLING_SLOPE_TIME_CHAMBER seconds + // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_CHAMBER + if (!next_cooling_check_ms || ELAPSED(now, next_cooling_check_ms)) { + if (previous_temp - current_temp < float(MIN_COOLING_SLOPE_DEG_COOLER)) break; + next_cooling_check_ms = now + SEC_TO_MS(MIN_COOLING_SLOPE_TIME_COOLER); + previous_temp = current_temp; + } + } + + } while (wait_for_heatup && TEMP_COOLER_CONDITIONS); + + // Prevent a wait-forever situation if R is misused i.e. M191 R0 + if (wait_for_heatup) { + wait_for_heatup = false; + ui.reset_status(); + return true; + } + + return false; + } + + #endif // HAS_COOLER + #endif // HAS_TEMP_SENSOR diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 5f5a076911..e69183f6f5 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -44,10 +44,10 @@ #define HOTEND_INDEX TERN(HAS_MULTI_HOTEND, e, 0) #define E_NAME TERN_(HAS_MULTI_HOTEND, e) -// Heater identifiers. Positive values are hotends. Negative values are other heaters. +// Element identifiers. Positive values are hotends. Negative values are other heaters or coolers. typedef enum : int8_t { - INDEX_NONE = -5, - H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED, + INDEX_NONE = -6, + H_COOLER, H_PROBE, H_REDUNDANT, H_CHAMBER, H_BED, H_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7 } heater_id_t; @@ -99,6 +99,9 @@ enum ADCSensorState : char { #if HAS_TEMP_ADC_CHAMBER PrepareTemp_CHAMBER, MeasureTemp_CHAMBER, #endif + #if HAS_TEMP_ADC_COOLER + PrepareTemp_COOLER, MeasureTemp_COOLER, + #endif #if HAS_TEMP_ADC_PROBE PrepareTemp_PROBE, MeasureTemp_PROBE, #endif @@ -218,6 +221,9 @@ struct PIDHeaterInfo : public HeaterInfo { #elif HAS_TEMP_CHAMBER typedef temp_info_t chamber_info_t; #endif +#if EITHER(HAS_COOLER, HAS_TEMP_COOLER) + typedef heater_info_t cooler_info_t; +#endif // Heater watch handling template @@ -249,6 +255,9 @@ struct HeaterWatch { #if WATCH_CHAMBER typedef struct HeaterWatch chamber_watch_t; #endif +#if WATCH_COOLER + typedef struct HeaterWatch cooler_watch_t; +#endif // Temperature sensor read value ranges typedef struct { int16_t raw_min, raw_max; } raw_range_t; @@ -288,6 +297,9 @@ typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t; #if TEMP_SENSOR_CHAMBER_IS_CUSTOM CTI_CHAMBER, #endif + #if COOLER_USER_THERMISTOR + CTI_COOLER, + #endif USER_THERMISTORS }; @@ -316,9 +328,11 @@ class Temperature { TERN_(HAS_HEATED_BED, static bed_info_t temp_bed); TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe); TERN_(HAS_TEMP_CHAMBER, static chamber_info_t temp_chamber); + TERN_(HAS_TEMP_COOLER, static cooler_info_t temp_cooler); TERN_(AUTO_POWER_E_FANS, static uint8_t autofan_speed[HOTENDS]); TERN_(AUTO_POWER_CHAMBER_FAN, static uint8_t chamberfan_speed); + TERN_(AUTO_POWER_COOLER_FAN, static uint8_t coolerfan_speed); #if ENABLED(FAN_SOFT_PWM) static uint8_t soft_pwm_amount_fan[FAN_COUNT], @@ -428,6 +442,17 @@ class Temperature { #endif #endif + #if HAS_COOLER + TERN_(WATCH_COOLER, static cooler_watch_t watch_cooler); + static millis_t next_cooler_check_ms, cooler_fan_flush_ms; + #ifdef COOLER_MINTEMP + static int16_t mintemp_raw_COOLER; + #endif + #ifdef COOLER_MAXTEMP + static int16_t maxtemp_raw_COOLER; + #endif + #endif + #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED static uint8_t consecutive_low_temperature_error[HOTENDS]; #endif @@ -492,7 +517,6 @@ class Temperature { #if HAS_HOTEND static float analog_to_celsius_hotend(const int raw, const uint8_t e); #endif - #if HAS_HEATED_BED static float analog_to_celsius_bed(const int raw); #endif @@ -502,6 +526,9 @@ class Temperature { #if HAS_TEMP_CHAMBER static float analog_to_celsius_chamber(const int raw); #endif + #if HAS_TEMP_COOLER + static float analog_to_celsius_cooler(const int raw); + #endif #if HAS_FAN @@ -737,6 +764,38 @@ class Temperature { } #endif + #if HAS_TEMP_COOLER + #if ENABLED(SHOW_TEMP_ADC_VALUES) + FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; } + #endif + FORCE_INLINE static float degCooler() { return temp_cooler.celsius; } + #if HAS_COOLER + FORCE_INLINE static int16_t degTargetCooler() { return temp_cooler.target; } + FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } + FORCE_INLINE static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } + static bool wait_for_cooler(const bool no_wait_for_cooling=true); + #endif + #endif + + #if WATCH_COOLER + static void start_watching_cooler(); + #else + static inline void start_watching_cooler() {} + #endif + + #if HAS_COOLER + static void setTargetCooler(const int16_t celsius) { + temp_cooler.target = + #ifdef COOLER_MAXTEMP + _MIN(celsius, COOLER_MAXTEMP - 10) + #else + celsius + #endif + ; + start_watching_cooler(); + } + #endif + /** * The software PWM power for a heater */ @@ -847,7 +906,7 @@ class Temperature { static void min_temp_error(const heater_id_t e); static void max_temp_error(const heater_id_t e); - #define HAS_THERMAL_PROTECTION ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, HAS_THERMALLY_PROTECTED_BED) + #define HAS_THERMAL_PROTECTION ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, HAS_THERMALLY_PROTECTED_BED, THERMAL_PROTECTION_COOLER) #if HAS_THERMAL_PROTECTION @@ -863,6 +922,9 @@ class Temperature { #if ENABLED(THERMAL_PROTECTION_CHAMBER) RUNAWAY_IND_CHAMBER, #endif + #if ENABLED(THERMAL_PROTECTION_COOLER) + RUNAWAY_IND_COOLER, + #endif NR_HEATER_RUNAWAY }; #undef _ENUM_FOR_E @@ -872,6 +934,9 @@ class Temperature { #if HAS_THERMALLY_PROTECTED_CHAMBER if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER; #endif + #if HAS_THERMALLY_PROTECTED_CHAMBER + if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER; + #endif #if HAS_THERMALLY_PROTECTED_BED if (heater_id == H_BED) return RUNAWAY_IND_BED; #endif diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 77fc50c8d3..f0ec289dfe 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) (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) +#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_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n) typedef struct { int16_t value, celsius; } temp_entry_t; @@ -303,6 +303,14 @@ typedef struct { int16_t value, celsius; } temp_entry_t; #define TEMPTABLE_CHAMBER_LEN 0 #endif +#ifdef TEMP_SENSOR_COOLER_THERMISTOR_ID + #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER_THERMISTOR_ID) + #define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER) +#elif TEMP_SENSOR_COOLER_IS_THERMISTOR + #error "No cooler thermistor table specified" +#else + #define TEMPTABLE_COOLER_LEN 0 +#endif #ifdef TEMP_SENSOR_PROBE_THERMISTOR_ID #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE_THERMISTOR_ID) #define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE) @@ -319,7 +327,7 @@ static_assert( && 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, + && TEMPTABLE_COOLER_LEN < 256 && TEMPTABLE_PROBE_LEN < 256, "Temperature conversion tables over 255 entries need special consideration." ); @@ -495,6 +503,15 @@ static_assert( #define TEMP_SENSOR_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif +#ifndef TEMP_SENSOR_COOLER_RAW_HI_TEMP + #if TT_REVRAW(COOLER) + #define TEMP_SENSOR_COOLER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define TEMP_SENSOR_COOLER_RAW_LO_TEMP 0 + #else + #define TEMP_SENSOR_COOLER_RAW_HI_TEMP 0 + #define TEMP_SENSOR_COOLER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #endif +#endif #ifndef TEMP_SENSOR_PROBE_RAW_HI_TEMP #if TT_REVRAW(PROBE) #define TEMP_SENSOR_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 42095fa926..51a00630a4 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -91,6 +91,9 @@ #if PIN_EXISTS(TEMP_CHAMBER) && ANALOG_OK(TEMP_CHAMBER_PIN) REPORT_NAME_ANALOG(__LINE__, TEMP_CHAMBER_PIN) #endif +#if PIN_EXISTS(TEMP_COOLER) && ANALOG_OK(TEMP_COOLER_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_COOLER_PIN) +#endif #if PIN_EXISTS(ADC_KEYPAD) && ANALOG_OK(ADC_KEYPAD_PIN) REPORT_NAME_ANALOG(__LINE__, ADC_KEYPAD_PIN) #endif @@ -706,6 +709,9 @@ #if PIN_EXISTS(HEATER_CHAMBER) REPORT_NAME_DIGITAL(__LINE__, HEATER_CHAMBER_PIN) #endif +#if PIN_EXISTS(COOLER) + REPORT_NAME_DIGITAL(__LINE__, COOLER_PIN) +#endif #if PIN_EXISTS(HOME) REPORT_NAME_DIGITAL(__LINE__, HOME_PIN) #endif diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index d7eb187245..b8be00bddd 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -676,6 +676,24 @@ #define _CHAMBER_FAN #endif +#if TEMP_SENSOR_COOLER && PIN_EXISTS(TEMP_COOLER) + #define _COOLER_TEMP analogInputToDigitalPin(TEMP_COOLER_PIN), +#else + #define _COOLER_TEMP +#endif + +#if TEMP_SENSOR_COOLER && PIN_EXISTS(COOLER) + #define _COOLER COOLER_PIN, +#else + #define _COOLER +#endif + +#if TEMP_SENSOR_COOLER && PINS_EXIST(TEMP_COOLER, COOLER_AUTO_FAN) + #define _COOLER_FAN COOLER_AUTO_FAN_PIN, +#else + #define _COOLER_FAN +#endif + #ifndef HAL_SENSITIVE_PINS #define HAL_SENSITIVE_PINS #endif @@ -685,5 +703,5 @@ _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS _E5_PINS _E6_PINS _E7_PINS \ _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS _H5_PINS _H6_PINS _H7_PINS \ _PS_ON _FAN0 _FAN1 _FAN2 _FAN3 _FAN4 _FAN5 _FAN6 _FAN7 _FANC \ - _BED_PINS _CHAMBER_TEMP _CHAMBER_HEATER _CHAMBER_FAN HAL_SENSITIVE_PINS \ + _BED_PINS _COOLER _CHAMBER_TEMP _CHAMBER_HEATER _CHAMBER_FAN HAL_SENSITIVE_PINS \ } diff --git a/buildroot/tests/BIGTREE_SKR_PRO b/buildroot/tests/BIGTREE_SKR_PRO index 74020c1b27..025d8cbce8 100755 --- a/buildroot/tests/BIGTREE_SKR_PRO +++ b/buildroot/tests/BIGTREE_SKR_PRO @@ -11,7 +11,7 @@ set -e # restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT 1 -exec_test $1 $2 "BigTreeTech SKR Pro Default Configuration" "$3" +exec_test $1 $2 "BigTreeTech SKR Pro | Default Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ @@ -19,14 +19,15 @@ opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 opt_enable BLTOUCH EEPROM_SETTINGS AUTO_BED_LEVELING_3POINT Z_SAFE_HOMING PINS_DEBUGGING -exec_test $1 $2 "BigTreeTech SKR Pro 3 Extruders, Auto-Fan, BLTOUCH, mixed TMC drivers" "$3" +exec_test $1 $2 "BigTreeTech SKR Pro | 3 Extruders | Auto-Fan | BLTOUCH | Mixed TMC" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ CUTTER_POWER_UNIT PERCENT \ - SPINDLE_LASER_PWM_PIN HEATER_1_PIN SPINDLE_LASER_ENA_PIN HEATER_2_PIN -opt_enable LASER_FEATURE REPRAP_DISCOUNT_SMART_CONTROLLER -exec_test $1 $2 "Laser, LCD, PERCENT power unit" "$3" + SPINDLE_LASER_PWM_PIN HEATER_1_PIN SPINDLE_LASER_ENA_PIN HEATER_2_PIN \ + TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 +opt_enable LASER_FEATURE REPRAP_DISCOUNT_SMART_CONTROLLER +exec_test $1 $2 "BigTreeTech SKR Pro | Laser (Percent) | Cooling | LCD" "$3" # clean up restore_configs diff --git a/platformio.ini b/platformio.ini index aad59362cc..d26b2a37ea 100644 --- a/platformio.ini +++ b/platformio.ini @@ -196,6 +196,7 @@ default_src_filter = + - - + - - - + - - - - @@ -406,6 +407,7 @@ SDSUPPORT = src_filter=+ + GCODE_REPEAT_MARKERS = src_filter=+ + HAS_EXTRUDERS = src_filter=+ + +HAS_COOLER = src_filter=- AUTO_REPORT_TEMPERATURES = src_filter=+ INCH_MODE_SUPPORT = src_filter=+ TEMPERATURE_UNITS_SUPPORT = src_filter=+ From 9f14127fd6f839d706084bf1faa15d466aa47ede Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 7 Mar 2021 00:14:45 +0000 Subject: [PATCH 011/311] [cron] Bump distribution date (2021-03-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 be2dd72ec4..eaf3cf4f70 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-03-06" + #define STRING_DISTRIBUTION_DATE "2021-03-07" #endif /** From ced1bb9404ee44a9b7f2f870a4d66a559418c2a0 Mon Sep 17 00:00:00 2001 From: ellensp Date: Sun, 7 Mar 2021 16:43:43 +1300 Subject: [PATCH 012/311] Update obsolete debug define (#21276) --- Marlin/src/core/debug_out.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/core/debug_out.h b/Marlin/src/core/debug_out.h index d93decf7ac..a7dc32622d 100644 --- a/Marlin/src/core/debug_out.h +++ b/Marlin/src/core/debug_out.h @@ -27,7 +27,7 @@ // #undef DEBUG_SECTION -#undef DEBUG_PRINT_P +#undef DEBUG_ECHOPGM_P #undef DEBUG_ECHO_START #undef DEBUG_ERROR_START #undef DEBUG_CHAR From 5dc8f5cfabbfcc6803cad1edd3ea469b29b0834a Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sat, 6 Mar 2021 20:55:37 -0800 Subject: [PATCH 013/311] Extend Heater Overshoot Options (#21273) Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7b0023a564..1098351d4e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -476,6 +476,15 @@ #define BED_MAXTEMP 150 #define CHAMBER_MAXTEMP 60 +/** + * Thermal Overshoot + * During heatup (and printing) the temperature can often "overshoot" the target by many degrees + * (especially before PID tuning). Setting the target temperature too close to MAXTEMP guarantees + * a MAXTEMP shutdown! Use these values to forbid temperatures being set too close to MAXTEMP. + */ +#define HOTEND_OVERSHOOT 15 // (°C) Forbid temperatures over MAXTEMP - OVERSHOOT +#define BED_OVERSHOOT 10 // (°C) Forbid temperatures over MAXTEMP - OVERSHOOT + //=========================================================================== //============================= PID Settings ================================ //=========================================================================== From f2ff75f3a2f978061932c20e915aa1cddcc66167 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 8 Mar 2021 00:18:19 +0000 Subject: [PATCH 014/311] [cron] Bump distribution date (2021-03-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 eaf3cf4f70..ec24ed058c 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-03-07" + #define STRING_DISTRIBUTION_DATE "2021-03-08" #endif /** From aa054471f2eac02a75ac411181dd4ca71f9fab74 Mon Sep 17 00:00:00 2001 From: ellensp Date: Mon, 8 Mar 2021 17:06:33 +1300 Subject: [PATCH 015/311] M303 followup (#21282) Followup to f2ed18d150 --- Marlin/src/gcode/temp/M303.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index 159a52bf26..0934e04e75 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -51,7 +51,7 @@ void GcodeSuite::M303() { thermalManager.pid_debug_flag ^= true; SERIAL_ECHO_START(); SERIAL_ECHOPGM("PID Debug "); - serialprintln_onoff(pid_debug_flag); + serialprintln_onoff(thermalManager.pid_debug_flag); return; } #endif From 1b9ff68f8ce59a2b142bbabd0fad3d3b377b5997 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Mon, 8 Mar 2021 04:11:37 -0300 Subject: [PATCH 016/311] Fix Host Keepalive serial target (#21283) Co-authored-by: Scott Lahteine --- .../src/HAL/ESP32/FlushableHardwareSerial.h | 6 ++--- Marlin/src/core/serial.h | 2 +- Marlin/src/core/serial_hook.h | 2 +- Marlin/src/gcode/gcode.cpp | 1 + Marlin/src/gcode/queue.cpp | 26 +++++++------------ platformio.ini | 6 ++--- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h index 27df0be4b6..d2762c0efa 100644 --- a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h +++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h @@ -21,9 +21,9 @@ */ #pragma once -#ifdef ARDUINO_ARCH_ESP32 - #include + +#include "../shared/Marduino.h" #include "../../core/serial_hook.h" class FlushableHardwareSerial : public HardwareSerial { @@ -32,5 +32,3 @@ public: }; extern Serial0Type flushableSerial; - -#endif // ARDUINO_ARCH_ESP32 diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index ec955a8dea..f76f0e32f5 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -62,7 +62,7 @@ extern uint8_t marlin_debug_flags; // // Serial redirection // -#define SERIAL_ALL 0x7F +#define SERIAL_ALL 0xFF #if HAS_MULTI_SERIAL #define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p) #define _PORT_RESTORE(n,p) RESTORE(n) diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index afd43892c7..dc2da13501 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -165,7 +165,7 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial >, public Seria RuntimeSerial(const bool e, Args... args) : BaseClassT(e), SerialT(args...), writeHook(0), eofHook(0), userPointer(0) {} }; -// A class that's duplicating its output conditionally to 2 serial interface +// A class that duplicates its output conditionally to 2 serial interfaces template struct MultiSerial : public SerialBase< MultiSerial > { typedef SerialBase< MultiSerial > BaseClassT; diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 34b8d767d1..5f30064b11 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -1067,6 +1067,7 @@ void GcodeSuite::process_subcommands_now(char * gcode) { static millis_t next_busy_signal_ms = 0; if (!autoreport_paused && host_keepalive_interval && busy_state != NOT_BUSY) { if (PENDING(ms, next_busy_signal_ms)) return; + PORT_REDIRECT(SERIAL_ALL); switch (busy_state) { case IN_HANDLER: case IN_PROCESS: diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 136293fd34..9b69f9f1fc 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -272,21 +272,7 @@ void GCodeQueue::flush_and_request_resend(const serial_index_t serial_ind) { SERIAL_ECHOLN(serial_state[serial_ind].last_N + 1); } -// Multiserial already handle the dispatch to/from multiple port by itself -inline bool serial_data_available(uint8_t index = SERIAL_ALL) { - if (index == SERIAL_ALL) { - for (index = 0; index < NUM_SERIAL; index++) { - const int a = SERIAL_IMPL.available(index); - #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE) - if (a > RX_BUFFER_SIZE - 2) { - PORT_REDIRECT(SERIAL_PORTMASK(index)); - SERIAL_ERROR_MSG("RX BUF overflow, increase RX_BUFFER_SIZE: ", a); - } - #endif - if (a > 0) return true; - } - return false; - } +inline bool serial_data_available(uint8_t index) { const int a = SERIAL_IMPL.available(index); #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE) if (a > RX_BUFFER_SIZE - 2) { @@ -294,10 +280,16 @@ inline bool serial_data_available(uint8_t index = SERIAL_ALL) { SERIAL_ERROR_MSG("RX BUF overflow, increase RX_BUFFER_SIZE: ", a); } #endif - return a > 0; } +// Multiserial already handles dispatch to/from multiple ports +inline bool any_serial_data_available() { + LOOP_L_N(p, NUM_SERIAL) + if (serial_data_available(p)) + return true; +} + inline int read_serial(const uint8_t index) { return SERIAL_IMPL.read(index); } void GCodeQueue::gcode_line_error(PGM_P const err, const serial_index_t serial_ind) { @@ -409,7 +401,7 @@ void GCodeQueue::get_serial_commands() { // send "wait" to indicate Marlin is still waiting. #if NO_TIMEOUTS > 0 const millis_t ms = millis(); - if (ring_buffer.empty() && !serial_data_available() && ELAPSED(ms, last_command_time + NO_TIMEOUTS)) { + if (ring_buffer.empty() && !any_serial_data_available() && ELAPSED(ms, last_command_time + NO_TIMEOUTS)) { SERIAL_ECHOLNPGM(STR_WAIT); last_command_time = ms; } diff --git a/platformio.ini b/platformio.ini index d26b2a37ea..b8235c84fd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -424,9 +424,9 @@ HAS_SERVOS = src_filter=+ + HAS_MICROSTEPS = src_filter=+ (ESP3D_)?WIFISUPPORT = AsyncTCP, ESP Async WebServer - ESP3DLib=https://github.com/luc-github/ESP3DLib.git - arduinoWebSockets=https://github.com/Links2004/arduinoWebSockets.git - ESP32SSDP=https://github.com/luc-github/ESP32SSDP.git + ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master.zip + arduinoWebSockets=links2004/WebSockets@2.3.4 + luc-github/ESP32SSDP@^1.1.1 lib_ignore=ESPAsyncTCP # From aad0f517b45c03da54b75f8cac00a4a91e86f520 Mon Sep 17 00:00:00 2001 From: ellensp Date: Mon, 8 Mar 2021 23:14:18 +1300 Subject: [PATCH 017/311] CUSTOM_USER_BUTTONS followup (#21284) Followup to #18389 --- Marlin/Configuration_adv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 3168e9a001..868b0c239a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3420,7 +3420,7 @@ //#define CUSTOM_USER_BUTTONS #if ENABLED(CUSTOM_USER_BUTTONS) //#define BUTTON1_PIN -1 - #if PIN_EXISTS(BUTTON1_PIN) + #if PIN_EXISTS(BUTTON1) #define BUTTON1_HIT_STATE LOW // State of the triggered button. NC=LOW. NO=HIGH. #define BUTTON1_WHEN_PRINTING false // Button allowed to trigger during printing? #define BUTTON1_GCODE "G28" @@ -3428,7 +3428,7 @@ #endif //#define BUTTON2_PIN -1 - #if PIN_EXISTS(BUTTON2_PIN) + #if PIN_EXISTS(BUTTON2) #define BUTTON2_HIT_STATE LOW #define BUTTON2_WHEN_PRINTING false #define BUTTON2_GCODE "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) @@ -3436,7 +3436,7 @@ #endif //#define BUTTON3_PIN -1 - #if PIN_EXISTS(BUTTON3_PIN) + #if PIN_EXISTS(BUTTON3) #define BUTTON3_HIT_STATE LOW #define BUTTON3_WHEN_PRINTING false #define BUTTON3_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) From 18a10c0db1f63b263157fe584697b720b5339a0d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 9 Mar 2021 00:13:12 +0000 Subject: [PATCH 018/311] [cron] Bump distribution date (2021-03-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 ec24ed058c..be64e830d4 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-03-08" + #define STRING_DISTRIBUTION_DATE "2021-03-09" #endif /** From 2f1fd4bbaab08e7fee2c405226dd7453de958b5b Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Mon, 8 Mar 2021 22:59:35 -0300 Subject: [PATCH 019/311] Host Keepalive followup (#21290) Followup to #21283 Co-authored-by: Scott Lahteine --- Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp index cc5a4fc476..9e2f4c1d96 100644 --- a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp +++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp @@ -20,11 +20,10 @@ * */ -#include "FlushableHardwareSerial.h" - #ifdef ARDUINO_ARCH_ESP32 +#include "FlushableHardwareSerial.h" Serial0Type flushableSerial(false, 0); -#endif // ARDUINO_ARCH_ESP32 +#endif From 55c31fbe9a70710c6a209d40b7d0165d081dcdd0 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Tue, 9 Mar 2021 10:20:37 +0100 Subject: [PATCH 020/311] Distinguish serial index from mask (#21287) --- Marlin/src/core/serial.h | 31 +++-- Marlin/src/core/serial_base.h | 23 +++- Marlin/src/core/serial_hook.h | 106 ++++++++++-------- Marlin/src/feature/host_actions.cpp | 10 +- Marlin/src/feature/meatpack.h | 24 ++-- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/host/M118.cpp | 2 +- Marlin/src/gcode/queue.cpp | 14 +-- Marlin/src/gcode/queue.h | 6 +- Marlin/src/gcode/sd/M1001.cpp | 2 +- .../lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 6 +- Marlin/src/libs/autoreport.h | 4 +- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 4 +- 14 files changed, 135 insertions(+), 101 deletions(-) diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index f76f0e32f5..57e9636be0 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -62,37 +62,36 @@ extern uint8_t marlin_debug_flags; // // Serial redirection // -#define SERIAL_ALL 0xFF #if HAS_MULTI_SERIAL - #define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p) - #define _PORT_RESTORE(n,p) RESTORE(n) - #define SERIAL_ASSERT(P) if(multiSerial.portMask!=(P)){ debugger(); } + #define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p) + #define _PORT_RESTORE(n,p) RESTORE(n) + #define SERIAL_ASSERT(P) if(multiSerial.portMask!=(P)){ debugger(); } #ifdef SERIAL_CATCHALL typedef MultiSerial SerialOutputT; #else - typedef MultiSerial, decltype(MYSERIAL1)), 0> SerialOutputT; + typedef MultiSerial, decltype(MYSERIAL1)), 0> SerialOutputT; #endif - extern SerialOutputT multiSerial; - #define _SERIAL_IMPL multiSerial + extern SerialOutputT multiSerial; + #define _SERIAL_IMPL multiSerial #else - #define _PORT_REDIRECT(n,p) NOOP - #define _PORT_RESTORE(n) NOOP - #define SERIAL_ASSERT(P) NOOP - #define _SERIAL_IMPL MYSERIAL0 + #define _PORT_REDIRECT(n,p) NOOP + #define _PORT_RESTORE(n) NOOP + #define SERIAL_ASSERT(P) NOOP + #define _SERIAL_IMPL MYSERIAL0 #endif #if ENABLED(MEATPACK) extern MeatpackSerial mpSerial; - #define SERIAL_IMPL mpSerial + #define SERIAL_IMPL mpSerial #else - #define SERIAL_IMPL _SERIAL_IMPL + #define SERIAL_IMPL _SERIAL_IMPL #endif #define SERIAL_OUT(WHAT, V...) (void)SERIAL_IMPL.WHAT(V) -#define PORT_REDIRECT(p) _PORT_REDIRECT(1,p) -#define PORT_RESTORE() _PORT_RESTORE(1) -#define SERIAL_PORTMASK(P) _BV(P) +#define PORT_REDIRECT(p) _PORT_REDIRECT(1,p) +#define PORT_RESTORE() _PORT_RESTORE(1) +#define SERIAL_PORTMASK(P) SerialMask::from(P) // // SERIAL_CHAR - Print one or more individual chars diff --git a/Marlin/src/core/serial_base.h b/Marlin/src/core/serial_base.h index 418bb557e7..f8fe3a181d 100644 --- a/Marlin/src/core/serial_base.h +++ b/Marlin/src/core/serial_base.h @@ -22,12 +22,29 @@ #pragma once #include "../inc/MarlinConfigPre.h" -#include "macros.h" #if ENABLED(EMERGENCY_PARSER) #include "../feature/e_parser.h" #endif +// Used in multiple places +// You can build it but not manipulate it. +// There are only few places where it's required to access the underlying member: GCodeQueue, SerialMask and MultiSerial +struct serial_index_t { + // A signed index, where -1 is a special case meaning no action (neither output or input) + int8_t index; + + // Check if the index is within the range [a ... b] + constexpr inline bool within(const int8_t a, const int8_t b) const { return WITHIN(index, a, b); } + constexpr inline bool valid() const { return WITHIN(index, 0, 7); } // At most, 8 bits + + // Construction is either from an index + constexpr serial_index_t(const int8_t index) : index(index) {} + + // Default to "no index" + constexpr serial_index_t() : index(-1) {} +}; + // 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); @@ -79,10 +96,10 @@ struct SerialBase { void end() { static_cast(this)->end(); } /** Check for available data from the port @param index The port index, usually 0 */ - int available(uint8_t index = 0) { return static_cast(this)->available(index); } + int available(serial_index_t index = 0) { return static_cast(this)->available(index); } /** Read a value from the port @param index The port index, usually 0 */ - int read(uint8_t index = 0) { return static_cast(this)->read(index); } + int read(serial_index_t index = 0) { return static_cast(this)->read(index); } // Check if the serial port is connected (usually bypassed) bool connected() { return static_cast(this)->connected(); } // Redirect flush diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index dc2da13501..5e81e9e0e4 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -21,11 +21,32 @@ */ #pragma once -#include "macros.h" #include "serial_base.h" -// Used in multiple places -typedef int8_t serial_index_t; +// A mask containing a bitmap of the serial port to act upon +// This is written to ensure a serial index is never used as a serial mask +class SerialMask { + uint8_t mask; + + // This constructor is private to ensure you can't convert an index to a mask + // The compiler will stop here if you are mixing index and mask in your code. + // If you need to, you'll have to use the explicit static "from" method here + SerialMask(const serial_index_t); + +public: + inline constexpr bool enabled(const SerialMask PortMask) const { return mask & PortMask.mask; } + inline constexpr SerialMask combine(const SerialMask other) const { return SerialMask(mask | other.mask); } + inline constexpr SerialMask operator<< (const int offset) const { return SerialMask(mask << offset); } + static inline SerialMask from(const serial_index_t index) { + if (index.valid()) return SerialMask(_BV(index.index)); + return SerialMask(0); // A invalid index mean no output + } + + constexpr SerialMask(const uint8_t mask) : mask(mask) {} + constexpr SerialMask(const SerialMask & other) : mask(other.mask) {} // Can't use = default here since not all framework support this + + static constexpr uint8_t All = 0xFF; +}; // 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 template @@ -39,10 +60,10 @@ struct BaseSerial : public SerialBase< BaseSerial >, public SerialT { void msgDone() {} // We don't care about indices here, since if one can call us, it's the right index anyway - int available(uint8_t) { return (int)SerialT::available(); } - int read(uint8_t) { return (int)SerialT::read(); } - bool connected() { return CALL_IF_EXISTS(bool, static_cast(this), connected);; } - void flushTX() { CALL_IF_EXISTS(void, static_cast(this), flushTX); } + int available(serial_index_t) { return (int)SerialT::available(); } + int read(serial_index_t) { return (int)SerialT::read(); } + 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; @@ -77,11 +98,10 @@ struct ConditionalSerial : public SerialBase< ConditionalSerial > { bool connected() { return CALL_IF_EXISTS(bool, &out, connected); } void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); } - int available(uint8_t ) { return (int)out.available(); } - int read(uint8_t ) { return (int)out.read(); } - int available() { return (int)out.available(); } - int read() { return (int)out.read(); } - + int available(serial_index_t ) { return (int)out.available(); } + int read(serial_index_t ) { return (int)out.read(); } + int available() { return (int)out.available(); } + int read() { return (int)out.read(); } ConditionalSerial(bool & conditionVariable, SerialT & out, const bool e) : BaseClassT(e), condition(conditionVariable), out(out) {} }; @@ -102,8 +122,8 @@ struct ForwardSerial : public SerialBase< ForwardSerial > { bool connected() { return Private::HasMember_connected::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; } void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); } - int available(uint8_t) { return (int)out.available(); } - int read(uint8_t) { return (int)out.read(); } + int available(serial_index_t) { return (int)out.available(); } + int read(serial_index_t) { return (int)out.read(); } int available() { return (int)out.available(); } int read() { return (int)out.read(); } @@ -130,8 +150,8 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial >, public Seria if (eofHook) eofHook(userPointer); } - int available(uint8_t) { return (int)SerialT::available(); } - int read(uint8_t) { return (int)SerialT::read(); } + int available(serial_index_t) { return (int)SerialT::available(); } + int read(serial_index_t) { return (int)SerialT::read(); } using SerialT::available; using SerialT::read; using SerialT::flush; @@ -170,53 +190,51 @@ template > { typedef SerialBase< MultiSerial > BaseClassT; - uint8_t portMask; + SerialMask portMask; Serial0T & serial0; Serial1T & serial1; - enum Masks { - UsageMask = ((1 << step) - 1), // A bit mask containing as many bits as step - FirstOutputMask = (UsageMask << offset), - SecondOutputMask = (UsageMask << (offset + step)), - AllMask = FirstOutputMask | SecondOutputMask, - }; + static constexpr uint8_t Usage = ((1 << step) - 1); // A bit mask containing as many bits as step + static constexpr uint8_t FirstOutput = (Usage << offset); + static constexpr uint8_t SecondOutput = (Usage << (offset + step)); + static constexpr uint8_t Both = FirstOutput | SecondOutput; NO_INLINE size_t write(uint8_t c) { size_t ret = 0; - if (portMask & FirstOutputMask) ret = serial0.write(c); - if (portMask & SecondOutputMask) ret = serial1.write(c) | ret; + if (portMask.enabled(FirstOutput)) ret = serial0.write(c); + if (portMask.enabled(SecondOutput)) ret = serial1.write(c) | ret; return ret; } NO_INLINE void msgDone() { - if (portMask & FirstOutputMask) serial0.msgDone(); - if (portMask & SecondOutputMask) serial1.msgDone(); + if (portMask.enabled(FirstOutput)) serial0.msgDone(); + if (portMask.enabled(SecondOutput)) serial1.msgDone(); } - int available(uint8_t index) { - if (index >= 0 + offset && index < step + offset) + int available(serial_index_t index) { + if (index.within(0 + offset, step + offset - 1)) return serial0.available(index); - else if (index >= step + offset && index < 2 * step + offset) + else if (index.within(step + offset, 2 * step + offset - 1)) return serial1.available(index); return false; } - int read(uint8_t index) { - if (index >= 0 + offset && index < step + offset) + int read(serial_index_t index) { + if (index.within(0 + offset, step + offset - 1)) return serial0.read(index); - else if (index >= step + offset && index < 2 * step + offset) + else if (index.within(step + offset, 2 * step + offset - 1)) return serial1.read(index); return -1; } void begin(const long br) { - if (portMask & FirstOutputMask) serial0.begin(br); - if (portMask & SecondOutputMask) serial1.begin(br); + if (portMask.enabled(FirstOutput)) serial0.begin(br); + if (portMask.enabled(SecondOutput)) serial1.begin(br); } void end() { - if (portMask & FirstOutputMask) serial0.end(); - if (portMask & SecondOutputMask) serial1.end(); + if (portMask.enabled(FirstOutput)) serial0.end(); + if (portMask.enabled(SecondOutput)) serial1.end(); } bool connected() { bool ret = true; - if (portMask & FirstOutputMask) ret = CALL_IF_EXISTS(bool, &serial0, connected); - if (portMask & SecondOutputMask) ret = ret && CALL_IF_EXISTS(bool, &serial1, connected); + if (portMask.enabled(FirstOutput)) ret = CALL_IF_EXISTS(bool, &serial0, connected); + if (portMask.enabled(SecondOutput)) ret = ret && CALL_IF_EXISTS(bool, &serial1, connected); return ret; } @@ -225,15 +243,15 @@ struct MultiSerial : public SerialBase< MultiSerial> { uint8_t charCount; uint8_t readIndex; - NO_INLINE size_t write(uint8_t c) { return out.write(c); } - void flush() { out.flush(); } - void begin(long br) { out.begin(br); readIndex = 0; } - void end() { out.end(); } + NO_INLINE size_t write(uint8_t c) { return out.write(c); } + void flush() { out.flush(); } + void begin(long br) { out.begin(br); readIndex = 0; } + void end() { out.end(); } - void msgDone() { out.msgDone(); } + void msgDone() { out.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 connected() { return Private::HasMember_connected::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; } + void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); } - int available(uint8_t index) { + int available(serial_index_t index) { // There is a potential issue here with multiserial, since it'll return its decoded buffer whatever the serial index here. // So, instead of doing MeatpackSerial> we should do MultiSerial, MeatpackSerial<...>> // TODO, let's fix this later on @@ -160,7 +160,7 @@ struct MeatpackSerial : public SerialBase > { return charCount; } - int readImpl(const uint8_t index) { + int readImpl(const serial_index_t index) { // Not enough char to make progress? if (charCount == 0 && available(index) == 0) return -1; @@ -168,9 +168,9 @@ struct MeatpackSerial : public SerialBase > { return serialBuffer[readIndex++]; } - int read(uint8_t index) { return readImpl(index); } - int available() { return available(0); } - int read() { return readImpl(0); } + int read(serial_index_t index) { return readImpl(index); } + int available() { return available(0); } + int read() { return readImpl(0); } MeatpackSerial(const bool e, SerialT & out) : BaseClassT(e), out(out) {} }; diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 5f30064b11..4e324e7892 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -1067,7 +1067,7 @@ void GcodeSuite::process_subcommands_now(char * gcode) { static millis_t next_busy_signal_ms = 0; if (!autoreport_paused && host_keepalive_interval && busy_state != NOT_BUSY) { if (PENDING(ms, next_busy_signal_ms)) return; - PORT_REDIRECT(SERIAL_ALL); + PORT_REDIRECT(SerialMask::All); switch (busy_state) { case IN_HANDLER: case IN_PROCESS: diff --git a/Marlin/src/gcode/host/M118.cpp b/Marlin/src/gcode/host/M118.cpp index 9982492f93..d6e591add9 100644 --- a/Marlin/src/gcode/host/M118.cpp +++ b/Marlin/src/gcode/host/M118.cpp @@ -52,7 +52,7 @@ void GcodeSuite::M118() { while (*p == ' ') ++p; } - PORT_REDIRECT(WITHIN(port, 0, NUM_SERIAL) ? (port ? SERIAL_PORTMASK(port - 1) : SERIAL_ALL) : multiSerial.portMask); + PORT_REDIRECT(WITHIN(port, 0, NUM_SERIAL) ? (port ? SERIAL_PORTMASK(port - 1) : SerialMask::All) : multiSerial.portMask); if (hasE) SERIAL_ECHO_START(); if (hasA) SERIAL_ECHOPGM("//"); diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 9b69f9f1fc..a764d80eca 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -240,7 +240,7 @@ void GCodeQueue::RingBuffer::ok_to_send() { CommandLine &command = commands[index_r]; #if HAS_MULTI_SERIAL const serial_index_t serial_ind = command.port; - if (serial_ind < 0) return; + if (!serial_ind.valid()) return; // Optimization here, skip processing if it's not going anywhere PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command #endif if (command.skip_ok) return; @@ -264,15 +264,15 @@ void GCodeQueue::RingBuffer::ok_to_send() { */ void GCodeQueue::flush_and_request_resend(const serial_index_t serial_ind) { #if HAS_MULTI_SERIAL - if (serial_ind < 0) return; // Never mind. Command came from SD or Flash Drive + if (!serial_ind.valid()) return; // Optimization here, skip if the command came from SD or Flash Drive PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command #endif SERIAL_FLUSH(); SERIAL_ECHOPGM(STR_RESEND); - SERIAL_ECHOLN(serial_state[serial_ind].last_N + 1); + SERIAL_ECHOLN(serial_state[serial_ind.index].last_N + 1); } -inline bool serial_data_available(uint8_t index) { +inline bool serial_data_available(serial_index_t index) { const int a = SERIAL_IMPL.available(index); #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE) if (a > RX_BUFFER_SIZE - 2) { @@ -290,15 +290,15 @@ inline bool any_serial_data_available() { return true; } -inline int read_serial(const uint8_t index) { return SERIAL_IMPL.read(index); } +inline int read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); } void GCodeQueue::gcode_line_error(PGM_P const err, const serial_index_t serial_ind) { PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command SERIAL_ERROR_START(); - SERIAL_ECHOLNPAIR_P(err, serial_state[serial_ind].last_N); + SERIAL_ECHOLNPAIR_P(err, serial_state[serial_ind.index].last_N); while (read_serial(serial_ind) != -1) { /* nada */ } // Clear out the RX buffer. Why don't use flush here ? flush_and_request_resend(serial_ind); - serial_state[serial_ind].count = 0; + serial_state[serial_ind.index].count = 0; } FORCE_INLINE bool is_M29(const char * const cmd) { // matches "M29" & "M29 ", but not "M290", etc diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 4757b8c37e..8e87d114eb 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -79,13 +79,13 @@ public: void commit_command(bool skip_ok #if HAS_MULTI_SERIAL - , serial_index_t serial_ind=-1 + , serial_index_t serial_ind = serial_index_t() #endif ); bool enqueue(const char* cmd, bool skip_ok = true #if HAS_MULTI_SERIAL - , serial_index_t serial_ind=-1 + , serial_index_t serial_ind = serial_index_t() #endif ); @@ -197,7 +197,7 @@ public: /** * (Re)Set the current line number for the last received command */ - static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port()].last_N = n; } + static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; } private: diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 1cf700ae26..415fbb6fa7 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -82,7 +82,7 @@ void GcodeSuite::M1001() { // Announce SD file completion { - PORT_REDIRECT(SERIAL_ALL); + PORT_REDIRECT(SerialMask::All); SERIAL_ECHOLNPGM(STR_FILE_PRINTED); } diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index 180c895809..93a7de14a1 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -395,21 +395,21 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va default: return; #if HOTENDS >= 1 case VP_T_E0_Set: - NOMORE(newvalue, HEATER_0_MAXTEMP); + NOMORE(newvalue, (uint16_t)HEATER_0_MAXTEMP); thermalManager.setTargetHotend(newvalue, 0); acceptedvalue = thermalManager.degTargetHotend(0); break; #endif #if HOTENDS >= 2 case VP_T_E1_Set: - NOMORE(newvalue, HEATER_1_MAXTEMP); + NOMORE(newvalue, (uint16_t)HEATER_1_MAXTEMP); thermalManager.setTargetHotend(newvalue, 1); acceptedvalue = thermalManager.degTargetHotend(1); break; #endif #if HAS_HEATED_BED case VP_T_Bed_Set: - NOMORE(newvalue, BED_MAXTEMP); + NOMORE(newvalue, (uint16_t)BED_MAXTEMP); thermalManager.setTargetBed(newvalue); acceptedvalue = thermalManager.degTargetBed(); break; diff --git a/Marlin/src/libs/autoreport.h b/Marlin/src/libs/autoreport.h index 232216578f..a6bc5adbf7 100644 --- a/Marlin/src/libs/autoreport.h +++ b/Marlin/src/libs/autoreport.h @@ -28,8 +28,8 @@ struct AutoReporter { millis_t next_report_ms; uint8_t report_interval; #if HAS_MULTI_SERIAL - serial_index_t report_port_mask; - AutoReporter() : report_port_mask(SERIAL_ALL) {} + SerialMask report_port_mask; + AutoReporter() : report_port_mask(SerialMask::All) {} #endif inline void set_interval(uint8_t seconds, const uint8_t limit=60) { diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a1d5745de4..a000a31de7 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -329,7 +329,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, */ void Temperature::report_fan_speed(const uint8_t target) { if (target >= FAN_COUNT) return; - PORT_REDIRECT(SERIAL_ALL); + PORT_REDIRECT(SerialMask::All); SERIAL_ECHOLNPAIR("M106 P", target, " S", fan_speed[target]); } #endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index c973ba5945..fac14e72a7 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -549,7 +549,7 @@ void openFailed(const char * const fname) { void announceOpen(const uint8_t doing, const char * const path) { if (doing) { - PORT_REDIRECT(SERIAL_ALL); + PORT_REDIRECT(SerialMask::All); SERIAL_ECHO_START(); SERIAL_ECHOPGM("Now "); SERIAL_ECHOPGM_P(doing == 1 ? PSTR("doing") : PSTR("fresh")); @@ -615,7 +615,7 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0* sdpos = 0; { // Don't remove this block, as the PORT_REDIRECT is a RAII - PORT_REDIRECT(SERIAL_ALL); + PORT_REDIRECT(SerialMask::All); SERIAL_ECHOLNPAIR(STR_SD_FILE_OPENED, fname, STR_SD_SIZE, filesize); SERIAL_ECHOLNPGM(STR_SD_FILE_SELECTED); } From 10ec5c7f340cb10590fa4defe594726bc9473e91 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 10 Mar 2021 00:06:00 +0100 Subject: [PATCH 021/311] Fix LPC + TMC boot loop (#21298) --- Marlin/src/MarlinCore.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 689650c6ab..bce091da5f 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1053,6 +1053,10 @@ void setup() { #if HAS_FILAMENT_SENSOR SETUP_RUN(runout.setup()); #endif + + #if HAS_TMC220x + SETUP_RUN(tmc_serial_begin()); + #endif #if ENABLED(PSU_CONTROL) SETUP_LOG("PSU_CONTROL"); @@ -1068,10 +1072,6 @@ void setup() { SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers #endif - #if HAS_TMC220x - SETUP_RUN(tmc_serial_begin()); - #endif - #if HAS_STEPPER_RESET SETUP_RUN(disableStepperDrivers()); #endif From 28a136d7f432546b765efd450eb45960c1ad2c2a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 10 Mar 2021 00:13:12 +0000 Subject: [PATCH 022/311] [cron] Bump distribution date (2021-03-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 be64e830d4..df29952479 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-03-09" + #define STRING_DISTRIBUTION_DATE "2021-03-10" #endif /** From bb6d718e19c7c0e6db743b0bc615b17f121f0073 Mon Sep 17 00:00:00 2001 From: Victor Mateus Oliveira Date: Tue, 9 Mar 2021 20:21:49 -0300 Subject: [PATCH 023/311] fix meat pack internal buffer for multi serial --- Marlin/src/gcode/queue.cpp | 1 + Marlin/src/gcode/sd/M28_M29.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index a764d80eca..0f4169a2c4 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -288,6 +288,7 @@ inline bool any_serial_data_available() { LOOP_L_N(p, NUM_SERIAL) if (serial_data_available(p)) return true; + return false; } inline int read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); } diff --git a/Marlin/src/gcode/sd/M28_M29.cpp b/Marlin/src/gcode/sd/M28_M29.cpp index f34edb6f7c..373938d99b 100644 --- a/Marlin/src/gcode/sd/M28_M29.cpp +++ b/Marlin/src/gcode/sd/M28_M29.cpp @@ -49,7 +49,7 @@ void GcodeSuite::M28() { // Binary transfer mode if ((card.flag.binary_mode = binary_mode)) { SERIAL_ECHO_MSG("Switching to Binary Protocol"); - TERN_(HAS_MULTI_SERIAL, card.transfer_port_index = queue.ring_buffer.command_port()); + TERN_(HAS_MULTI_SERIAL, card.transfer_port_index = queue.ring_buffer.command_port().index); } else card.openFileWrite(p); From b75e682c502c572426cc6aa8110fe5869413e8d0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 Mar 2021 11:31:32 -0600 Subject: [PATCH 024/311] Add binary file transfer test --- buildroot/tests/mks_robin_nano35 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildroot/tests/mks_robin_nano35 b/buildroot/tests/mks_robin_nano35 index 7ab592aaa3..c54cd36655 100755 --- a/buildroot/tests/mks_robin_nano35 +++ b/buildroot/tests/mks_robin_nano35 @@ -42,7 +42,8 @@ use_example_configs Mks/Robin opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 opt_disable TFT_INTERFACE_FSMC TFT_RES_320x240 opt_enable TFT_INTERFACE_SPI TFT_RES_480x320 -exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI" "$3" +opt_enable BINARY_FILE_TRANSFER +exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI + BINARY_FILE_TRANSFER" "$3" # # MKS Robin v2 nano LVGL SPI + TMC From fe0b7700335470f03f5b5b8404b126efca8afbb6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 Mar 2021 11:33:29 -0600 Subject: [PATCH 025/311] Fix serial index types --- Marlin/src/feature/binary_stream.h | 4 ++-- Marlin/src/gcode/queue.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 2 +- Marlin/src/sd/cardreader.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index d092b7152f..80f26cc7ce 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -29,11 +29,11 @@ #include "../libs/heatshrink/heatshrink_decoder.h" #endif -inline bool bs_serial_data_available(const uint8_t index) { +inline bool bs_serial_data_available(const serial_index_t index) { return SERIAL_IMPL.available(index); } -inline int bs_read_serial(const uint8_t index) { +inline int bs_read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 0f4169a2c4..4f676eaeb3 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -393,7 +393,7 @@ void GCodeQueue::get_serial_commands() { * receive buffer (which limits the packet size to MAX_CMD_SIZE). * The receive buffer also limits the packet size for reliable transmission. */ - binaryStream[card.transfer_port_index].receive(serial_state[card.transfer_port_index].line_buffer); + binaryStream[card.transfer_port_index.index].receive(serial_state[card.transfer_port_index.index].line_buffer); return; } #endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index fac14e72a7..a3e0577031 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -70,7 +70,7 @@ char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENA IF_DISABLED(NO_SD_AUTOSTART, uint8_t CardReader::autofile_index); // = 0 #if BOTH(HAS_MULTI_SERIAL, BINARY_FILE_TRANSFER) - int8_t CardReader::transfer_port_index; + serial_index_t CardReader::transfer_port_index; #endif // private: diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 0a89bbba78..f823b79e7a 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -72,9 +72,9 @@ public: // Fast! binary file transfer #if ENABLED(BINARY_FILE_TRANSFER) #if HAS_MULTI_SERIAL - static int8_t transfer_port_index; + static serial_index_t transfer_port_index; #else - static constexpr int8_t transfer_port_index = 0; + static constexpr serial_index_t transfer_port_index = 0; #endif #endif From 2c62886c719c67c9ed9a3d0741020a004633a109 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 Mar 2021 11:35:19 -0600 Subject: [PATCH 026/311] Clean up spaces and words --- Marlin/src/MarlinCore.cpp | 10 +++++----- Marlin/src/gcode/host/M115.cpp | 2 +- Marlin/src/gcode/queue.cpp | 18 ++++++++++-------- Marlin/src/inc/SanityCheck.h | 3 +-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h | 18 +++++++++--------- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index bce091da5f..e1756af511 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -990,14 +990,14 @@ void setup() { #endif #define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0) - MYSERIAL0.begin(BAUDRATE); + MYSERIAL1.begin(BAUDRATE); millis_t serial_connect_timeout = millis() + 1000UL; - while (!MYSERIAL0.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #if HAS_MULTI_SERIAL && !HAS_ETHERNET - MYSERIAL1.begin(BAUDRATE); + MYSERIAL2.begin(BAUDRATE); serial_connect_timeout = millis() + 1000UL; - while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } + while (!MYSERIAL2.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ } #endif SERIAL_ECHOLNPGM("start"); @@ -1053,7 +1053,7 @@ void setup() { #if HAS_FILAMENT_SENSOR SETUP_RUN(runout.setup()); #endif - + #if HAS_TMC220x SETUP_RUN(tmc_serial_begin()); #endif diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 316abc3048..4b7b268688 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -144,7 +144,7 @@ void GcodeSuite::M115() { // COOLER_TEMPERATURE (M143, M193) cap_line(PSTR("COOLER_TEMPERATURE"), ENABLED(HAS_COOLER)); - // MEATPACK Compresson + // MEATPACK Compression cap_line(PSTR("MEATPACK"), ENABLED(MEATPACK)); // Machine Geometry diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 4f676eaeb3..6b48000248 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -272,7 +272,7 @@ void GCodeQueue::flush_and_request_resend(const serial_index_t serial_ind) { SERIAL_ECHOLN(serial_state[serial_ind.index].last_N + 1); } -inline bool serial_data_available(serial_index_t index) { +static bool serial_data_available(serial_index_t index) { const int a = SERIAL_IMPL.available(index); #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE) if (a > RX_BUFFER_SIZE - 2) { @@ -283,13 +283,15 @@ inline bool serial_data_available(serial_index_t index) { return a > 0; } -// Multiserial already handles dispatch to/from multiple ports -inline bool any_serial_data_available() { - LOOP_L_N(p, NUM_SERIAL) - if (serial_data_available(p)) - return true; - return false; -} +#if NO_TIMEOUTS > 0 + // Multiserial already handles dispatch to/from multiple ports + static bool any_serial_data_available() { + LOOP_L_N(p, NUM_SERIAL) + if (serial_data_available(p)) + return true; + return false; + } +#endif inline int read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); } diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index cd9ca84385..8c92cf2c63 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3337,12 +3337,11 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #endif #endif - /** * Sanity Check for MEATPACK and BINARY_FILE_TRANSFER Features */ #if BOTH(MEATPACK, BINARY_FILE_TRANSFER) - #error "Either enable MEATPACK or enable BINARY_FILE_TRANSFER." + #error "Either enable MEATPACK or BINARY_FILE_TRANSFER, not both." #endif /** diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 99e0f0be2a..b9f1074c7a 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -237,7 +237,7 @@ * This board does not have dedicated TMC UART pins. Custom wiring is needed. * You may uncomment one of the options below, or add it to your Configuration.h. * - * When using up to four TMC2209 drivers, hardware serial is recommented on + * When using up to four TMC2209 drivers, hardware serial is recommended on * MSerial0 or MSerial1. * * When using TMC2208 or more than four drivers, SoftwareSerial will be needed, @@ -246,14 +246,14 @@ //#define TMC_HARDWARE_SERIAL #if ENABLED(TMC_HARDWARE_SERIAL) - #define X_HARDWARE_SERIAL MSerial0 - #define X2_HARDWARE_SERIAL MSerial0 - #define Y_HARDWARE_SERIAL MSerial0 - #define Y2_HARDWARE_SERIAL MSerial0 - #define Z_HARDWARE_SERIAL MSerial0 - #define Z2_HARDWARE_SERIAL MSerial0 - #define E0_HARDWARE_SERIAL MSerial0 - #define E1_HARDWARE_SERIAL MSerial0 + #define X_HARDWARE_SERIAL MSerial0 + #define X2_HARDWARE_SERIAL MSerial0 + #define Y_HARDWARE_SERIAL MSerial0 + #define Y2_HARDWARE_SERIAL MSerial0 + #define Z_HARDWARE_SERIAL MSerial0 + #define Z2_HARDWARE_SERIAL MSerial0 + #define E0_HARDWARE_SERIAL MSerial0 + #define E1_HARDWARE_SERIAL MSerial0 #endif //#define TMC_SOFTWARE_SERIAL From dbd28eecc9cd4b5954a4fd1ed0c02bd9788c279b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 Mar 2021 12:05:05 -0600 Subject: [PATCH 027/311] Number serial from 1 to match settings --- Marlin/src/HAL/AVR/HAL.cpp | 2 +- Marlin/src/HAL/AVR/HAL.h | 12 +++---- Marlin/src/HAL/AVR/MarlinSerial.h | 10 +++--- Marlin/src/HAL/DUE/HAL.cpp | 8 ++--- Marlin/src/HAL/DUE/HAL.h | 27 +++++++-------- Marlin/src/HAL/DUE/MarlinSerial.h | 4 +-- Marlin/src/HAL/DUE/MarlinSerialUSB.h | 2 +- .../src/HAL/ESP32/FlushableHardwareSerial.cpp | 2 +- .../src/HAL/ESP32/FlushableHardwareSerial.h | 2 +- Marlin/src/HAL/ESP32/HAL.cpp | 2 +- Marlin/src/HAL/ESP32/HAL.h | 10 +++--- Marlin/src/HAL/ESP32/WebSocketSerial.h | 2 +- Marlin/src/HAL/LINUX/HAL.h | 2 +- Marlin/src/HAL/LINUX/include/serial.h | 2 +- Marlin/src/HAL/LINUX/main.cpp | 4 +-- Marlin/src/HAL/LPC1768/HAL.cpp | 2 +- Marlin/src/HAL/LPC1768/HAL.h | 13 ++++--- Marlin/src/HAL/LPC1768/MarlinSerial.cpp | 4 +-- Marlin/src/HAL/LPC1768/MarlinSerial.h | 4 +-- Marlin/src/HAL/SAMD51/HAL.cpp | 10 +++--- Marlin/src/HAL/SAMD51/HAL.h | 34 +++++++++---------- Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h | 2 +- Marlin/src/HAL/STM32/HAL.cpp | 2 +- Marlin/src/HAL/STM32/HAL.h | 16 ++++----- Marlin/src/HAL/STM32/MarlinSerial.h | 2 +- Marlin/src/HAL/STM32F1/HAL.cpp | 4 +-- Marlin/src/HAL/STM32F1/HAL.h | 14 ++++---- Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp | 6 ++-- Marlin/src/HAL/STM32F1/MarlinSerial.cpp | 6 ++-- Marlin/src/HAL/STM32F1/MarlinSerial.h | 2 +- Marlin/src/HAL/STM32F1/msc_sd.cpp | 2 +- Marlin/src/HAL/STM32F1/msc_sd.h | 2 +- Marlin/src/HAL/TEENSY31_32/HAL.cpp | 2 +- Marlin/src/HAL/TEENSY31_32/HAL.h | 11 +++--- Marlin/src/HAL/TEENSY35_36/HAL.cpp | 2 +- Marlin/src/HAL/TEENSY35_36/HAL.h | 11 +++--- Marlin/src/HAL/TEENSY40_41/HAL.cpp | 2 +- Marlin/src/HAL/TEENSY40_41/HAL.h | 17 +++++----- Marlin/src/core/serial.cpp | 6 ++-- Marlin/src/core/serial.h | 8 ++--- Marlin/src/core/serial_hook.h | 6 ++-- Marlin/src/feature/ethernet.cpp | 2 +- Marlin/src/gcode/config/M575.cpp | 4 +-- Marlin/src/gcode/control/M111.cpp | 8 ++--- Marlin/src/gcode/queue.cpp | 4 +-- .../src/lcd/extui/lib/mks_ui/draw_gcode.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_keyboard.cpp | 2 +- Marlin/src/lcd/extui/malyan_lcd.cpp | 4 +-- .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 2 +- .../src/sd/usb_flashdrive/lib-uhs2/settings.h | 2 +- docs/Serial.md | 4 +-- 51 files changed, 155 insertions(+), 160 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.cpp b/Marlin/src/HAL/AVR/HAL.cpp index 4c45a5d78e..cfa9e47f18 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -25,7 +25,7 @@ #include "HAL.h" #ifdef USBCON - DefaultSerial MSerial(false, Serial); + DefaultSerial1 MSerial0(false, Serial); #ifdef BLUETOOTH BTSerial btSerial(false, bluetoothSerial); #endif diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 5e22ac0836..f6adf1bd31 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -83,25 +83,25 @@ typedef int8_t pin_t; // Serial ports #ifdef USBCON #include "../../core/serial_hook.h" - typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial; - extern DefaultSerial MSerial; + typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; + extern DefaultSerial1 MSerial0; #ifdef BLUETOOTH - typedef ForwardSerial0Type< decltype(bluetoothSerial) > BTSerial; + typedef ForwardSerial1Class< decltype(bluetoothSerial) > BTSerial; extern BTSerial btSerial; #endif - #define MYSERIAL0 TERN(BLUETOOTH, btSerial, MSerial) + #define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0) #else #if !WITHIN(SERIAL_PORT, -1, 3) #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif - #define MYSERIAL0 customizedSerial1 + #define MYSERIAL1 customizedSerial1 #ifdef SERIAL_PORT_2 #if !WITHIN(SERIAL_PORT_2, -1, 3) #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif - #define MYSERIAL1 customizedSerial2 + #define MYSERIAL2 customizedSerial2 #endif #endif diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 9abc3dbed0..ab49e9440a 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 Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT; extern MSerialT customizedSerial1; #ifdef SERIAL_PORT_2 - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT2; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT2; extern MSerialT2 customizedSerial2; #endif @@ -262,7 +262,7 @@ static constexpr bool RX_OVERRUNS = false; }; - typedef Serial0Type< MarlinSerial< MMU2SerialCfg > > MSerialT3; + typedef Serial1Class< MarlinSerial< MMU2SerialCfg > > MSerialT3; extern MSerialT3 mmuSerial; #endif @@ -292,12 +292,12 @@ }; - typedef Serial0Type< MarlinSerial< LCDSerialCfg > > MSerialT4; + typedef Serial1Class< MarlinSerial< LCDSerialCfg > > MSerialT4; extern MSerialT4 lcdSerial; #endif // Use the UART for Bluetooth in AT90USB configurations #if defined(USBCON) && ENABLED(BLUETOOTH) - typedef Serial0Type MSerialT5; + typedef Serial1Class MSerialT5; extern MSerialT5 bluetoothSerial; #endif diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp index 034b86ccb0..0e4caa47ac 100644 --- a/Marlin/src/HAL/DUE/HAL.cpp +++ b/Marlin/src/HAL/DUE/HAL.cpp @@ -107,16 +107,16 @@ uint16_t HAL_adc_get_result() { // Forward the default serial ports #if ANY_SERIAL_IS(0) - DefaultSerial MSerial(false, Serial); + DefaultSerial1 MSerial0(false, Serial); #endif #if ANY_SERIAL_IS(1) - DefaultSerial1 MSerial1(false, Serial1); + DefaultSerial2 MSerial1(false, Serial1); #endif #if ANY_SERIAL_IS(2) - DefaultSerial2 MSerial2(false, Serial2); + DefaultSerial3 MSerial2(false, Serial2); #endif #if ANY_SERIAL_IS(3) - DefaultSerial3 MSerial3(false, Serial3); + DefaultSerial4 MSerial3(false, Serial3); #endif #endif // ARDUINO_ARCH_SAM diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index b1c6a38c0f..095538f6a6 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -38,33 +38,32 @@ #include "../../core/serial_hook.h" -typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial; -typedef ForwardSerial0Type< decltype(Serial1) > DefaultSerial1; -typedef ForwardSerial0Type< decltype(Serial2) > DefaultSerial2; -typedef ForwardSerial0Type< decltype(Serial3) > DefaultSerial3; -extern DefaultSerial MSerial; -extern DefaultSerial1 MSerial1; -extern DefaultSerial2 MSerial2; -extern DefaultSerial3 MSerial3; +typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; +typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; +typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; +typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4; +extern DefaultSerial1 MSerial0; +extern DefaultSerial2 MSerial1; +extern DefaultSerial3 MSerial2; +extern DefaultSerial4 MSerial3; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial -// Define MYSERIAL0/1 before MarlinSerial includes! +// Define MYSERIAL1/2 before MarlinSerial includes! #if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER) - #define MYSERIAL0 customizedSerial1 + #define MYSERIAL1 customizedSerial1 #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER) - #define MYSERIAL1 customizedSerial2 + #define MYSERIAL2 customizedSerial2 #elif WITHIN(SERIAL_PORT_2, 0, 3) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif diff --git a/Marlin/src/HAL/DUE/MarlinSerial.h b/Marlin/src/HAL/DUE/MarlinSerial.h index 7fc21264bb..e74d234b4a 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.h +++ b/Marlin/src/HAL/DUE/MarlinSerial.h @@ -141,11 +141,11 @@ struct MarlinSerialCfg { }; #if SERIAL_PORT >= 0 - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT; extern MSerialT customizedSerial1; #endif #if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT2; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT2; extern MSerialT2 customizedSerial2; #endif diff --git a/Marlin/src/HAL/DUE/MarlinSerialUSB.h b/Marlin/src/HAL/DUE/MarlinSerialUSB.h index f9cea29869..4c299dced5 100644 --- a/Marlin/src/HAL/DUE/MarlinSerialUSB.h +++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.h @@ -50,7 +50,7 @@ struct MarlinSerialUSB { FORCE_INLINE int rxMaxEnqueued() { return 0; } #endif }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; #if SERIAL_PORT == -1 extern MSerialT customizedSerial1; diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp index 9e2f4c1d96..145662215a 100644 --- a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp +++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp @@ -24,6 +24,6 @@ #include "FlushableHardwareSerial.h" -Serial0Type flushableSerial(false, 0); +Serial1Class flushableSerial(false, 0); #endif diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h index d2762c0efa..012dda8626 100644 --- a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h +++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h @@ -31,4 +31,4 @@ public: FlushableHardwareSerial(int uart_nr) : HardwareSerial(uart_nr) {} }; -extern Serial0Type flushableSerial; +extern Serial1Class flushableSerial; diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index ab28595071..365706c3e2 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -41,7 +41,7 @@ #endif #if ENABLED(ESP3D_WIFISUPPORT) - DefaultSerial MSerial(false, Serial2Socket); + DefaultSerial1 MSerial0(false, Serial2Socket); #endif // ------------------------ diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 4d1db571d0..9258f97702 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -51,15 +51,15 @@ extern portMUX_TYPE spinlock; -#define MYSERIAL0 flushableSerial +#define MYSERIAL1 flushableSerial #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) #if ENABLED(ESP3D_WIFISUPPORT) - typedef ForwardSerial0Type< decltype(Serial2Socket) > DefaultSerial; - extern DefaultSerial MSerial; - #define MYSERIAL1 MSerial + typedef ForwardSerial1Class< decltype(Serial2Socket) > DefaultSerial1; + extern DefaultSerial1 MSerial0; + #define MYSERIAL2 MSerial0 #else - #define MYSERIAL1 webSocketSerial + #define MYSERIAL2 webSocketSerial #endif #endif diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.h b/Marlin/src/HAL/ESP32/WebSocketSerial.h index c68792c8c1..924d36f15c 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.h +++ b/Marlin/src/HAL/ESP32/WebSocketSerial.h @@ -81,5 +81,5 @@ public: #endif }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; extern MSerialT webSocketSerial; diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index e4f4dd3fc3..f21e3e2c65 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -61,7 +61,7 @@ uint8_t _getc(); #define SHARED_SERVOS HAS_SERVOS extern MSerialT usb_serial; -#define MYSERIAL0 usb_serial +#define MYSERIAL1 usb_serial #define ST7920_DELAY_1 DELAY_NS(600) #define ST7920_DELAY_2 DELAY_NS(750) diff --git a/Marlin/src/HAL/LINUX/include/serial.h b/Marlin/src/HAL/LINUX/include/serial.h index 2585be25bf..ebae066c3a 100644 --- a/Marlin/src/HAL/LINUX/include/serial.h +++ b/Marlin/src/HAL/LINUX/include/serial.h @@ -115,4 +115,4 @@ struct HalSerial { volatile bool host_connected; }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; diff --git a/Marlin/src/HAL/LINUX/main.cpp b/Marlin/src/HAL/LINUX/main.cpp index c409a83e5d..31f6de98ee 100644 --- a/Marlin/src/HAL/LINUX/main.cpp +++ b/Marlin/src/HAL/LINUX/main.cpp @@ -105,8 +105,8 @@ int main() { std::thread write_serial (write_serial_thread); std::thread read_serial (read_serial_thread); - #ifdef MYSERIAL0 - MYSERIAL0.begin(BAUDRATE); + #ifdef MYSERIAL1 + MYSERIAL1.begin(BAUDRATE); SERIAL_ECHOLNPGM("x86_64 Initialized"); SERIAL_FLUSHTX(); #endif diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index 26a2c0e7db..442c41afe7 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -29,7 +29,7 @@ #include "watchdog.h" #endif -DefaultSerial USBSerial(false, UsbSerial); +DefaultSerial1 USBSerial(false, UsbSerial); uint32_t HAL_adc_reading = 0; diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 1dc4fe6ff9..58f9cb71fb 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -60,26 +60,25 @@ extern "C" volatile uint32_t _millis; #define ST7920_DELAY_3 DELAY_NS(750) #endif -typedef ForwardSerial0Type< decltype(UsbSerial) > DefaultSerial; -extern DefaultSerial USBSerial; +typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1; +extern DefaultSerial1 USBSerial; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial #if SERIAL_PORT == -1 - #define MYSERIAL0 USBSerial + #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 USBSerial + #define MYSERIAL2 USBSerial #elif WITHIN(SERIAL_PORT_2, 0, 3) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp index b0dfc0ae90..be42c7f960 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp @@ -26,7 +26,7 @@ #if ANY_SERIAL_IS(0) MarlinSerial _MSerial(LPC_UART0); - MSerialT MSerial(true, _MSerial); + MSerialT MSerial0(true, _MSerial); extern "C" void UART0_IRQHandler() { _MSerial.IRQHandler(); } #endif #if ANY_SERIAL_IS(1) @@ -51,7 +51,7 @@ // Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro) if (false) {} #if ANY_SERIAL_IS(0) - else if (this == &_MSerial) emergency_parser.update(MSerial.emergency_state, c); + else if (this == &_MSerial) emergency_parser.update(MSerial0.emergency_state, c); #endif #if ANY_SERIAL_IS(1) else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c); diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.h b/Marlin/src/HAL/LPC1768/MarlinSerial.h index 35c9362b9f..489bd8cc6c 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.h +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.h @@ -54,8 +54,8 @@ public: // On LPC176x framework, HardwareSerial does not implement the same interface as Arduino's Serial, so overloads // of 'available' and 'read' method are not used in this multiple inheritance scenario. // Instead, use a ForwardSerial here that adapts the interface. -typedef ForwardSerial0Type MSerialT; -extern MSerialT MSerial; +typedef ForwardSerial1Class MSerialT; +extern MSerialT MSerial0; extern MSerialT MSerial1; extern MSerialT MSerial2; extern MSerialT MSerial3; diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index 4a6100b96b..8dd2fefd0a 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -26,19 +26,19 @@ #ifdef ADAFRUIT_GRAND_CENTRAL_M4 #if ANY_SERIAL_IS(-1) - DefaultSerial MSerial(false, Serial); + DefaultSerial1 MSerial0(false, Serial); #endif #if ANY_SERIAL_IS(0) - DefaultSerial1 MSerial1(false, Serial1); + DefaultSerial2 MSerial1(false, Serial1); #endif #if ANY_SERIAL_IS(1) - DefaultSerial2 MSerial2(false, Serial2); + DefaultSerial3 MSerial2(false, Serial2); #endif #if ANY_SERIAL_IS(2) - DefaultSerial3 MSerial3(false, Serial3); + DefaultSerial4 MSerial3(false, Serial3); #endif #if ANY_SERIAL_IS(3) - DefaultSerial4 MSerial4(false, Serial4); + DefaultSerial5 MSerial4(false, Serial4); #endif #endif diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 7b272af842..de72c476e4 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -32,36 +32,36 @@ #include "MarlinSerial_AGCM4.h" // Serial ports - typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial; - typedef ForwardSerial0Type< decltype(Serial1) > DefaultSerial1; - typedef ForwardSerial0Type< decltype(Serial2) > DefaultSerial2; - typedef ForwardSerial0Type< decltype(Serial3) > DefaultSerial3; - typedef ForwardSerial0Type< decltype(Serial4) > DefaultSerial4; - extern DefaultSerial MSerial; - extern DefaultSerial1 MSerial1; - extern DefaultSerial2 MSerial2; - extern DefaultSerial3 MSerial3; - extern DefaultSerial4 MSerial4; + typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; + typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; + typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; + typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4; + typedef ForwardSerial1Class< decltype(Serial4) > DefaultSerial5; + extern DefaultSerial1 MSerial0; + extern DefaultSerial2 MSerial1; + extern DefaultSerial3 MSerial2; + extern DefaultSerial4 MSerial3; + extern DefaultSerial5 MSerial4; - // MYSERIAL0 required before MarlinSerial includes! + // MYSERIAL1 required before MarlinSerial includes! #define __MSERIAL(X) MSerial##X #define _MSERIAL(X) __MSERIAL(X) #define MSERIAL(X) _MSERIAL(INCREMENT(X)) #if SERIAL_PORT == -1 - #define MYSERIAL0 MSerial + #define MYSERIAL1 MSerial0 #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 MSerial + #define MYSERIAL2 MSerial0 #elif WITHIN(SERIAL_PORT_2, 0, 3) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif @@ -69,7 +69,7 @@ #ifdef MMU2_SERIAL_PORT #if MMU2_SERIAL_PORT == -1 - #define MMU2_SERIAL MSerial + #define MMU2_SERIAL MSerial0 #elif WITHIN(MMU2_SERIAL_PORT, 0, 3) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else @@ -79,7 +79,7 @@ #ifdef LCD_SERIAL_PORT #if LCD_SERIAL_PORT == -1 - #define LCD_SERIAL MSerial + #define LCD_SERIAL MSerial0 #elif WITHIN(LCD_SERIAL_PORT, 0, 3) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else diff --git a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h index b7293415d1..ac5a379398 100644 --- a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h +++ b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h @@ -22,7 +22,7 @@ #include "../../core/serial_hook.h" -typedef Serial0Type UartT; +typedef Serial1Class UartT; extern UartT Serial2; extern UartT Serial3; diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index d13be1a21a..c66f061d91 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -29,7 +29,7 @@ #include "../shared/Delay.h" #ifdef USBCON - DefaultSerial MSerial(false, SerialUSB); + DefaultSerial1 MSerial0(false, SerialUSB); #endif #if ENABLED(SRAM_EEPROM_EMULATION) diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index be0cc30962..ad3a9963d7 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -40,8 +40,8 @@ #ifdef USBCON #include #include "../../core/serial_hook.h" - typedef ForwardSerial0Type< decltype(SerialUSB) > DefaultSerial; - extern DefaultSerial MSerial; + typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1; + extern DefaultSerial1 MSerial0; #endif // ------------------------ @@ -51,18 +51,18 @@ #define MSERIAL(X) _MSERIAL(X) #if SERIAL_PORT == -1 - #define MYSERIAL0 MSerial + #define MYSERIAL1 MSerial0 #elif WITHIN(SERIAL_PORT, 1, 6) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 MSerial + #define MYSERIAL2 MSerial0 #elif WITHIN(SERIAL_PORT_2, 1, 6) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration." #endif @@ -70,7 +70,7 @@ #ifdef MMU2_SERIAL_PORT #if MMU2_SERIAL_PORT == -1 - #define MMU2_SERIAL MSerial + #define MMU2_SERIAL MSerial0 #elif WITHIN(MMU2_SERIAL_PORT, 1, 6) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else @@ -80,7 +80,7 @@ #ifdef LCD_SERIAL_PORT #if LCD_SERIAL_PORT == -1 - #define LCD_SERIAL MSerial + #define LCD_SERIAL MSerial0 #elif WITHIN(LCD_SERIAL_PORT, 1, 6) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else diff --git a/Marlin/src/HAL/STM32/MarlinSerial.h b/Marlin/src/HAL/STM32/MarlinSerial.h index 8cc4f0dd4c..7b0529cfd2 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.h +++ b/Marlin/src/HAL/STM32/MarlinSerial.h @@ -42,7 +42,7 @@ protected: usart_rx_callback_t _rx_callback; }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; extern MSerialT MSerial1; extern MSerialT MSerial2; extern MSerialT MSerial3; diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index 182d9401c1..40452b5d70 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -84,7 +84,7 @@ #if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE USBSerial SerialUSB; - DefaultSerial MSerial(true, SerialUSB); + DefaultSerial1 MSerial0(true, SerialUSB); #if ENABLED(EMERGENCY_PARSER) #include "../libmaple/usb/stm32f1/usb_reg_map.h" @@ -107,7 +107,7 @@ len = usb_cdcacm_peek(buf, total); for (uint32 i = 0; i < len; i++) - emergency_parser.update(MSerial.emergency_state, buf[i + total - len]); + emergency_parser.update(MSerial0.emergency_state, buf[i + total - len]); } #endif #endif diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 30bf60b6e8..4656583590 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -61,11 +61,11 @@ #endif #ifdef SERIAL_USB - typedef ForwardSerial0Type< USBSerial > DefaultSerial; - extern DefaultSerial MSerial; + typedef ForwardSerial1Class< USBSerial > DefaultSerial1; + extern DefaultSerial1 MSerial0; #if !HAS_SD_HOST_DRIVE - #define UsbSerial MSerial + #define UsbSerial MSerial0 #else #define UsbSerial MarlinCompositeSerial #endif @@ -81,9 +81,9 @@ #endif #if SERIAL_PORT == -1 - #define MYSERIAL0 UsbSerial + #define MYSERIAL1 UsbSerial #elif WITHIN(SERIAL_PORT, 1, NUM_UARTS) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #elif NUM_UARTS == 5 #error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." #else @@ -92,9 +92,9 @@ #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 UsbSerial + #define MYSERIAL2 UsbSerial #elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #elif NUM_UARTS == 5 #error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration." #else diff --git a/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp index e6b89f1105..2cb75bb1e9 100644 --- a/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp @@ -44,8 +44,8 @@ static void TXBegin() { #warning "Using POSTMORTEM_DEBUGGING requires a physical U(S)ART hardware in case of severe error." #warning "Disabling the severe error reporting feature currently because the used serial port is not a HW port." #else - // We use MYSERIAL0 here, so we need to figure out how to get the linked register - struct usart_dev* dev = MYSERIAL0.c_dev(); + // We use MYSERIAL1 here, so we need to figure out how to get the linked register + struct usart_dev* dev = MYSERIAL1.c_dev(); // Or use this if removing libmaple // int irq = dev->irq_num; @@ -80,7 +80,7 @@ static void TXBegin() { #define sw_barrier() __asm__ volatile("": : :"memory"); static void TX(char c) { #if WITHIN(SERIAL_PORT, 1, 6) - struct usart_dev* dev = MYSERIAL0.c_dev(); + struct usart_dev* dev = MYSERIAL1.c_dev(); while (!(dev->regs->SR & USART_SR_TXE)) { TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); sw_barrier(); diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp index c404e81b35..a46e3ab3ab 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp @@ -134,12 +134,12 @@ constexpr bool IsSerialClassAllowed(const HardwareSerial&) { return false; } // If you encounter this error, replace SerialX with MSerialX, for example MSerial3. // Non-TMC ports were already validated in HAL.h, so do not require verbose error messages. -#ifdef MYSERIAL0 - CHECK_CFG_SERIAL(MYSERIAL0); -#endif #ifdef MYSERIAL1 CHECK_CFG_SERIAL(MYSERIAL1); #endif +#ifdef MYSERIAL2 + CHECK_CFG_SERIAL(MYSERIAL2); +#endif #ifdef LCD_SERIAL CHECK_CFG_SERIAL(LCD_SERIAL); #endif diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.h b/Marlin/src/HAL/STM32F1/MarlinSerial.h index 692e97e618..dda32fe7a2 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.h +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.h @@ -47,7 +47,7 @@ struct MarlinSerial : public HardwareSerial { #endif }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; extern MSerialT MSerial1; extern MSerialT MSerial2; diff --git a/Marlin/src/HAL/STM32F1/msc_sd.cpp b/Marlin/src/HAL/STM32F1/msc_sd.cpp index 1e2fe88174..7725b2c324 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.cpp +++ b/Marlin/src/HAL/STM32F1/msc_sd.cpp @@ -24,7 +24,7 @@ #define PRODUCT_ID 0x29 USBMassStorage MarlinMSC; -Serial0Type MarlinCompositeSerial(true); +Serial1Class MarlinCompositeSerial(true); #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32F1/msc_sd.h b/Marlin/src/HAL/STM32F1/msc_sd.h index 151287f7a7..f4636bdff7 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.h +++ b/Marlin/src/HAL/STM32F1/msc_sd.h @@ -21,6 +21,6 @@ #include "../../core/serial_hook.h" extern USBMassStorage MarlinMSC; -extern Serial0Type MarlinCompositeSerial; +extern Serial1Class MarlinCompositeSerial; void MSC_SD_init(); diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index 51636d29bf..8a13f1d884 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -31,7 +31,7 @@ #include -DefaultSerial MSerial(false); +DefaultSerial1 MSerial0(false); USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result; diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 5273b38637..cd1c334899 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -51,19 +51,18 @@ #endif #include "../../core/serial_hook.h" -typedef Serial0Type DefaultSerial; -extern DefaultSerial MSerial; -typedef ForwardSerial0Type USBSerialType; +typedef Serial1Class DefaultSerial1; +extern DefaultSerial1 MSerial0; +typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial #if SERIAL_PORT == -1 - #define MYSERIAL0 USBSerial + #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #endif #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index 547681de5f..fe2f79f415 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,7 +31,7 @@ #include -DefaultSerial MSerial(false); +DefaultSerial1 MSerial0(false); USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result, HAL_adc_select; diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 94c514bf62..48fee6b9a9 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -54,19 +54,18 @@ #endif #include "../../core/serial_hook.h" -typedef Serial0Type DefaultSerial; -extern DefaultSerial MSerial; -typedef ForwardSerial0Type USBSerialType; +typedef Serial1Class DefaultSerial1; +extern DefaultSerial1 MSerial0; +typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial #if SERIAL_PORT == -1 - #define MYSERIAL0 USBSerial + #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #endif #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index 26449d7eb2..0fde9da537 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -32,7 +32,7 @@ #include -DefaultSerial MSerial(false); +DefaultSerial1 MSerial0(false); USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result, HAL_adc_select; diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 6aa1e521a4..03a12e1b92 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -56,30 +56,29 @@ #endif #include "../../core/serial_hook.h" -typedef Serial0Type DefaultSerial; -extern DefaultSerial MSerial; -typedef ForwardSerial0Type USBSerialType; +typedef Serial1Class DefaultSerial1; +extern DefaultSerial1 MSerial0; +typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial #if SERIAL_PORT == -1 - #define MYSERIAL0 SerialUSB + #define MYSERIAL1 SerialUSB #elif WITHIN(SERIAL_PORT, 0, 8) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 usbSerial + #define MYSERIAL2 usbSerial #elif SERIAL_PORT_2 == -2 - #define MYSERIAL1 ethernet.telnetClient + #define MYSERIAL2 ethernet.telnetClient #elif WITHIN(SERIAL_PORT_2, 0, 8) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -2 to 8. Please update your configuration." #endif diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 01f850ba56..326baf0c54 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -43,12 +43,12 @@ PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMST #else #if HAS_ETHERNET // Runtime checking of the condition variable - ConditionalSerial serialOut1(ethernet.have_telnet_client, MYSERIAL1, false); // Takes reference here + ConditionalSerial serialOut2(ethernet.have_telnet_client, MYSERIAL2, false); // Takes reference here #else // Don't pay for runtime checking a true variable, instead use the output directly - #define serialOut1 MYSERIAL1 + #define serialOut2 MYSERIAL2 #endif - SerialOutputT multiSerial(MYSERIAL0, serialOut1); + SerialOutputT multiSerial(MYSERIAL1, serialOut2); #endif #endif diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 57e9636be0..87c2a390db 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -69,15 +69,15 @@ extern uint8_t marlin_debug_flags; #ifdef SERIAL_CATCHALL typedef MultiSerial SerialOutputT; #else - typedef MultiSerial, decltype(MYSERIAL1)), 0> SerialOutputT; + typedef MultiSerial, decltype(MYSERIAL2)), 0> SerialOutputT; #endif - extern SerialOutputT multiSerial; - #define _SERIAL_IMPL multiSerial + extern SerialOutputT multiSerial; + #define _SERIAL_IMPL multiSerial #else #define _PORT_REDIRECT(n,p) NOOP #define _PORT_RESTORE(n) NOOP #define SERIAL_ASSERT(P) NOOP - #define _SERIAL_IMPL MYSERIAL0 + #define _SERIAL_IMPL MYSERIAL1 #endif #if ENABLED(MEATPACK) diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index 5e81e9e0e4..c687891fb4 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -257,8 +257,8 @@ struct MultiSerial : public SerialBase< MultiSerial, ConditionalSerial > Serial0Type; +typedef MultiSerial< RuntimeSerial, ConditionalSerial > Serial1Class; ``` To send the same output to 4 serial ports you could nest `MultiSerial` like this: ```cpp -typedef MultiSerial< MultiSerial< BaseSerial, BaseSerial >, MultiSerial< BaseSerial, BaseSerial, 2, 1>, 0, 2> Serial0Type; +typedef MultiSerial< MultiSerial< BaseSerial, BaseSerial >, MultiSerial< BaseSerial, BaseSerial, 2, 1>, 0, 2> Serial1Class; ``` The magical numbers here are the step and offset for computing the serial port. Simplifying the above monster a bit: ```cpp From 9cba3c87ef4ed7155db1a6e0e1664405c92af1e2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 Mar 2021 12:05:27 -0600 Subject: [PATCH 028/311] Update MEATPACK test --- buildroot/tests/FYSETC_S6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/tests/FYSETC_S6 b/buildroot/tests/FYSETC_S6 index ce5442c376..4794e11354 100755 --- a/buildroot/tests/FYSETC_S6 +++ b/buildroot/tests/FYSETC_S6 @@ -9,7 +9,7 @@ set -e # Build examples restore_configs use_example_configs FYSETC/S6 -opt_enable MEATPACK +opt_enable MEATPACK_ON_SERIAL_PORT_1 opt_set Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2130 exec_test $1 $2 "FYSETC S6 Example" "$3" From 048f6b4731366c8e843edac0adff1872e9e6763b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 Mar 2021 12:35:26 -0600 Subject: [PATCH 029/311] Tricked-out declaration --- Marlin/src/HAL/TEENSY35_36/HAL.cpp | 7 ++++++- Marlin/src/HAL/TEENSY35_36/HAL.h | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index fe2f79f415..8640bdfe00 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,7 +31,12 @@ #include -DefaultSerial1 MSerial0(false); +#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false) +#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) +#if WITHIN(SERIAL_PORT, 0, 3) + IMPLEMENT_SERIAL(SERIAL_PORT); +#endif + USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result, HAL_adc_select; diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 48fee6b9a9..e769454b3f 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -54,8 +54,13 @@ #endif #include "../../core/serial_hook.h" -typedef Serial1Class DefaultSerial1; -extern DefaultSerial1 MSerial0; + +#define Serial0 Serial +#define _DECLARE_SERIAL(X) \ + typedef Serial1Class DefaultSerial##X; \ + extern DefaultSerial##X MSerial##X +#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X) + typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; @@ -66,6 +71,7 @@ extern USBSerialType USBSerial; #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) #define MYSERIAL1 MSERIAL(SERIAL_PORT) + DECLARE_SERIAL(SERIAL_PORT); #endif #define HAL_SERVO_LIB libServo From f147a8990a68503cd5eb2bb0fc7b26b7c00efe91 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Wed, 10 Mar 2021 21:22:20 +0100 Subject: [PATCH 030/311] Fix MeatPack with per-serial-port instances (#21306) --- Marlin/Configuration_adv.h | 4 ++- Marlin/src/core/serial.cpp | 29 ++++++++-------- Marlin/src/core/serial.h | 56 +++++++++++++++++++++++------- Marlin/src/feature/meatpack.cpp | 12 ++----- Marlin/src/feature/meatpack.h | 39 ++++++++++----------- Marlin/src/gcode/host/M115.cpp | 2 +- Marlin/src/inc/Conditionals_post.h | 4 +++ Marlin/src/inc/SanityCheck.h | 6 ++-- platformio.ini | 2 +- 9 files changed, 90 insertions(+), 64 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 868b0c239a..9ab3e2d044 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3373,7 +3373,9 @@ //#define GCODE_QUOTED_STRINGS // Support for quoted string parameters #endif -//#define MEATPACK // Support for MeatPack G-code compression (https://github.com/scottmudge/OctoPrint-MeatPack) +// Support for MeatPack G-code compression (https://github.com/scottmudge/OctoPrint-MeatPack) +//#define MEATPACK_ON_SERIAL_PORT_1 +//#define MEATPACK_ON_SERIAL_PORT_2 //#define GCODE_CASE_INSENSITIVE // Accept G-code sent to the firmware in lowercase diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 326baf0c54..dcbfd608bf 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -37,23 +37,22 @@ PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C"); PGMSTR(SP_X_STR, " X"); PGMSTR(SP_Y_STR, " Y"); PGMSTR(SP_Z_STR, " Z"); PGMSTR(SP_E_STR, " E"); PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMSTR(SP_E_LBL, " E:"); -#if HAS_MULTI_SERIAL - #ifdef SERIAL_CATCHALL - SerialOutputT multiSerial(MYSERIAL, SERIAL_CATCHALL); - #else - #if HAS_ETHERNET - // Runtime checking of the condition variable - ConditionalSerial serialOut2(ethernet.have_telnet_client, MYSERIAL2, false); // Takes reference here - #else - // Don't pay for runtime checking a true variable, instead use the output directly - #define serialOut2 MYSERIAL2 - #endif - SerialOutputT multiSerial(MYSERIAL1, serialOut2); - #endif +// Hook Meatpack if it's enabled on the first leaf +#if ENABLED(MEATPACK_ON_SERIAL_PORT_1) + SerialLeafT1 mpSerial1(false, _SERIAL_LEAF_1); +#endif +#if ENABLED(MEATPACK_ON_SERIAL_PORT_2) + SerialLeafT2 mpSerial2(false, _SERIAL_LEAF_2); #endif -#if ENABLED(MEATPACK) - MeatpackSerial mpSerial(false, _SERIAL_IMPL); +// Step 2: For multiserial, handle the second serial port as well +#if HAS_MULTI_SERIAL + #if HAS_ETHERNET + // We need a definition here + SerialLeafT2 msSerial2(ethernet.have_telnet_client, MYSERIAL2, false); + #endif + + SerialOutputT multiSerial(SERIAL_LEAF_1, SERIAL_LEAF_2); #endif void serialprintPGM(PGM_P str) { diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 87c2a390db..2f23e4e3c2 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -24,7 +24,7 @@ #include "../inc/MarlinConfig.h" #include "serial_hook.h" -#if ENABLED(MEATPACK) +#if HAS_MEATPACK #include "../feature/meatpack.h" #endif @@ -62,29 +62,59 @@ extern uint8_t marlin_debug_flags; // // Serial redirection // +// Step 1: Find what's the first serial leaf +#if BOTH(HAS_MULTI_SERIAL, SERIAL_CATCHALL) + #define _SERIAL_LEAF_1 MYSERIAL +#else + #define _SERIAL_LEAF_1 MYSERIAL1 +#endif + +// Hook Meatpack if it's enabled on the first leaf +#if ENABLED(MEATPACK_ON_SERIAL_PORT_1) + typedef MeatpackSerial SerialLeafT1; + extern SerialLeafT1 mpSerial1; + #define SERIAL_LEAF_1 mpSerial1 +#else + #define SERIAL_LEAF_1 _SERIAL_LEAF_1 +#endif + +// Step 2: For multiserial, handle the second serial port as well #if HAS_MULTI_SERIAL #define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p) #define _PORT_RESTORE(n,p) RESTORE(n) #define SERIAL_ASSERT(P) if(multiSerial.portMask!=(P)){ debugger(); } + // If we have a catchall, use that directly #ifdef SERIAL_CATCHALL - typedef MultiSerial SerialOutputT; + #define _SERIAL_LEAF_2 SERIAL_CATCHALL #else - typedef MultiSerial, decltype(MYSERIAL2)), 0> SerialOutputT; + #if HAS_ETHERNET + // We need to create an instance here + typedef ConditionalSerial SerialLeafT2; + extern SerialLeafT2 msSerial2; + #define _SERIAL_LEAF_2 msSerial2 + #else + // Don't create a useless instance here, directly use the existing instance + #define _SERIAL_LEAF_2 MYSERIAL2 + #endif #endif - extern SerialOutputT multiSerial; - #define _SERIAL_IMPL multiSerial + + // Hook Meatpack if it's enabled on the second leaf + #if ENABLED(MEATPACK_ON_SERIAL_PORT_2) + typedef MeatpackSerial SerialLeafT2; + extern SerialLeafT2 mpSerial2; + #define SERIAL_LEAF_2 mpSerial2 + #else + #define SERIAL_LEAF_2 _SERIAL_LEAF_2 + #endif + + typedef MultiSerial SerialOutputT; + extern SerialOutputT multiSerial; + #define SERIAL_IMPL multiSerial #else #define _PORT_REDIRECT(n,p) NOOP #define _PORT_RESTORE(n) NOOP #define SERIAL_ASSERT(P) NOOP - #define _SERIAL_IMPL MYSERIAL1 -#endif - -#if ENABLED(MEATPACK) - extern MeatpackSerial mpSerial; - #define SERIAL_IMPL mpSerial -#else - #define SERIAL_IMPL _SERIAL_IMPL + #define SERIAL_IMPL SERIAL_LEAF_1 #endif #define SERIAL_OUT(WHAT, V...) (void)SERIAL_IMPL.WHAT(V) diff --git a/Marlin/src/feature/meatpack.cpp b/Marlin/src/feature/meatpack.cpp index 7e81dbed79..178831c9bb 100644 --- a/Marlin/src/feature/meatpack.cpp +++ b/Marlin/src/feature/meatpack.cpp @@ -39,7 +39,7 @@ #include "../inc/MarlinConfig.h" -#if ENABLED(MEATPACK) +#if HAS_MEATPACK #include "meatpack.h" MeatPack meatpack; @@ -50,14 +50,6 @@ MeatPack meatpack; #define DEBUG_OUT ENABLED(MP_DEBUG) #include "../core/debug_out.h" -bool MeatPack::cmd_is_next = false; // A command is pending -uint8_t MeatPack::state = 0; // Configuration state OFF -uint8_t MeatPack::second_char = 0; // The unpacked 2nd character from an out-of-sequence packed pair -uint8_t MeatPack::cmd_count = 0, // Counts how many command bytes are received (need 2) - MeatPack::full_char_count = 0, // Counts how many full-width characters are to be received - MeatPack::char_out_count = 0; // Stores number of characters to be read out. -uint8_t MeatPack::char_out_buf[2]; // Output buffer for caching up to 2 characters - // The 15 most-common characters used in G-code, ~90-95% of all G-code uses these characters // Stored in SRAM for performance. uint8_t meatPackLookupTable[16] = { @@ -223,4 +215,4 @@ uint8_t MeatPack::get_result_char(char* const __restrict out) { return res; } -#endif // MEATPACK +#endif // HAS_MEATPACK diff --git a/Marlin/src/feature/meatpack.h b/Marlin/src/feature/meatpack.h index 96004cfeaf..80f4570e03 100644 --- a/Marlin/src/feature/meatpack.h +++ b/Marlin/src/feature/meatpack.h @@ -90,18 +90,18 @@ class MeatPack { static const uint8_t kSpaceCharIdx = 11; static const char kSpaceCharReplace = 'E'; - static bool cmd_is_next; // A command is pending - static uint8_t state; // Configuration state - static uint8_t second_char; // Buffers a character if dealing with out-of-sequence pairs - static uint8_t cmd_count, // Counter of command bytes received (need 2) - full_char_count, // Counter for full-width characters to be received - char_out_count; // Stores number of characters to be read out. - static uint8_t char_out_buf[2]; // Output buffer for caching up to 2 characters + bool cmd_is_next; // A command is pending + uint8_t state; // Configuration state + uint8_t second_char; // Buffers a character if dealing with out-of-sequence pairs + uint8_t cmd_count, // Counter of command bytes received (need 2) + full_char_count, // Counter for full-width characters to be received + char_out_count; // Stores number of characters to be read out. + uint8_t char_out_buf[2]; // Output buffer for caching up to 2 characters public: // Pass in a character rx'd by SD card or serial. Automatically parses command/ctrl sequences, // and will control state internally. - static void handle_rx_char(const uint8_t c, const serial_index_t serial_ind); + void handle_rx_char(const uint8_t c, const serial_index_t serial_ind); /** * After passing in rx'd char using above method, call this to get characters out. @@ -109,24 +109,25 @@ public: * @param out [in] Output pointer for unpacked/processed data. * @return Number of characters returned. Range from 0 to 2. */ - static uint8_t get_result_char(char* const __restrict out); + uint8_t get_result_char(char* const __restrict out); - static void reset_state(); - static void report_state(); - static uint8_t unpack_chars(const uint8_t pk, uint8_t* __restrict const chars_out); - static void handle_command(const MeatPack_Command c); - static void handle_output_char(const uint8_t c); - static void handle_rx_char_inner(const uint8_t c); + void reset_state(); + void report_state(); + uint8_t unpack_chars(const uint8_t pk, uint8_t* __restrict const chars_out); + void handle_command(const MeatPack_Command c); + void handle_output_char(const uint8_t c); + void handle_rx_char_inner(const uint8_t c); + + MeatPack() : cmd_is_next(false), state(0), second_char(0), cmd_count(0), full_char_count(0), char_out_count(0) {} }; -extern MeatPack meatpack; - // Implement the MeatPack serial class so it's transparent to rest of the code template struct MeatpackSerial : public SerialBase > { typedef SerialBase< MeatpackSerial > BaseClassT; SerialT & out; + MeatPack meatpack; char serialBuffer[2]; uint8_t charCount; @@ -143,10 +144,6 @@ struct MeatpackSerial : public SerialBase > { void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); } int available(serial_index_t index) { - // There is a potential issue here with multiserial, since it'll return its decoded buffer whatever the serial index here. - // So, instead of doing MeatpackSerial> we should do MultiSerial, MeatpackSerial<...>> - // TODO, let's fix this later on - if (charCount) return charCount; // The buffer still has data if (out.available(index) <= 0) return 0; // No data to read diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 4b7b268688..cd6fcbaf86 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -145,7 +145,7 @@ void GcodeSuite::M115() { cap_line(PSTR("COOLER_TEMPERATURE"), ENABLED(HAS_COOLER)); // MEATPACK Compression - cap_line(PSTR("MEATPACK"), ENABLED(MEATPACK)); + cap_line(PSTR("MEATPACK"), ENABLED(HAS_MEATPACK)); // Machine Geometry #if ENABLED(M115_GEOMETRY_REPORT) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index e8ed0d5a91..7dc75db1c2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2912,3 +2912,7 @@ #elif NUM_SERIAL > 1 #define HAS_MULTI_SERIAL 1 #endif + +#if ENABLED(MEATPACK_ON_SERIAL_PORT_1) || BOTH(HAS_MULTI_SERIAL, MEATPACK_ON_SERIAL_PORT_2) + #define HAS_MEATPACK 1 +#endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8c92cf2c63..6802bff1dd 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -551,6 +551,8 @@ #error "UNKNOWN_Z_NO_RAISE is replaced by setting Z_IDLE_HEIGHT to Z_MAX_POS." #elif defined(Z_AFTER_DEACTIVATE) #error "Z_AFTER_DEACTIVATE is replaced by Z_IDLE_HEIGHT." +#elif defined(MEATPACK) + #error "MEATPACK is now enabled with MEATPACK_ON_SERIAL_PORT_1, MEATPACK_ON_SERIAL_PORT_2, etc." #endif /** @@ -3340,8 +3342,8 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) /** * Sanity Check for MEATPACK and BINARY_FILE_TRANSFER Features */ -#if BOTH(MEATPACK, BINARY_FILE_TRANSFER) - #error "Either enable MEATPACK or BINARY_FILE_TRANSFER, not both." +#if BOTH(HAS_MEATPACK, BINARY_FILE_TRANSFER) + #error "Either enable MEATPACK_ON_SERIAL_PORT_* or BINARY_FILE_TRANSFER, not both." #endif /** diff --git a/platformio.ini b/platformio.ini index b8235c84fd..3b1604a296 100644 --- a/platformio.ini +++ b/platformio.ini @@ -332,7 +332,7 @@ PCA9632 = src_filter=+ PRINTER_EVENT_LEDS = src_filter=+ TEMP_STAT_LEDS = src_filter=+ MAX7219_DEBUG = src_filter=+ + -MEATPACK = src_filter=+ +HAS_MEATPACK = src_filter=+ MIXING_EXTRUDER = src_filter=+ + HAS_PRUSA_MMU1 = src_filter=+ HAS_PRUSA_MMU2 = src_filter=+ + From 8c512191b2f3c3c937ce12da25b8203b464dfc6d Mon Sep 17 00:00:00 2001 From: Cal1sto <47449942+Cal1sto@users.noreply.github.com> Date: Wed, 10 Mar 2021 21:37:22 +0100 Subject: [PATCH 031/311] Fix TouchMI stow in G34 (#21291) --- Marlin/src/gcode/calibrate/G34_M422.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 50476e8e7c..bee6aaedeb 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -410,9 +410,9 @@ void GcodeSuite::G34() { SERIAL_ECHOLNPAIR_F("Accuracy: ", z_maxdiff); } - // Stow the probe, as the last call to probe.probe_at_point(...) left - // the probe deployed if it was successful. - probe.stow(); + // Stow the probe because the last call to probe.probe_at_point(...) + // leaves the probe deployed when it's successful. + IF_DISABLED(TOUCH_MI_PROBE, probe.stow()); #if ENABLED(HOME_AFTER_G34) // After this operation the z position needs correction From 4d6ebf95fced1393d13f1cf4b43fe789754e3141 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Wed, 10 Mar 2021 12:57:54 -0800 Subject: [PATCH 032/311] Fix LERDGE 'extends' env references (#21305) Co-authored-by: Scott Lahteine --- platformio.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 3b1604a296..11dcecfc99 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1401,7 +1401,7 @@ board_build.firmware = Lerdge_X_firmware_force.bin # [env:LERDGEX_usb_flash_drive] platform = ${env:LERDGEX.platform} -extends = LERDGEX +extends = env:LERDGEX platform_packages = ${stm32_flash_drive.platform_packages} build_flags = ${stm32_flash_drive.build_flags} @@ -1418,7 +1418,7 @@ board_build.firmware = Lerdge_firmware_force.bin # [env:LERDGES_usb_flash_drive] platform = ${env:LERDGES.platform} -extends = LERDGES +extends = env:LERDGES platform_packages = ${stm32_flash_drive.platform_packages} build_flags = ${stm32_flash_drive.build_flags} @@ -1437,7 +1437,7 @@ build_flags = ${lerdge_common.build_flags} # [env:LERDGEK_usb_flash_drive] platform = ${env:LERDGEK.platform} -extends = LERDGEK +extends = env:LERDGEK platform_packages = ${stm32_flash_drive.platform_packages} build_flags = ${stm32_flash_drive.build_flags} From f671e6d1382c0d275e96b3ad67e4fb326cc8807a Mon Sep 17 00:00:00 2001 From: Evgeny Z Date: Thu, 11 Mar 2021 00:02:29 +0300 Subject: [PATCH 033/311] Lerdge-K TMC 2208/9 UART pins (#21299) --- Marlin/src/pins/stm32f4/pins_LERDGE_K.h | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h index fad8d2059e..1bc7bbc99e 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_K.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_K.h @@ -96,6 +96,50 @@ // #define E1_CS_PIN PE4 //#endif +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + */ + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN PB2 + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN PB2 + #endif + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN PE2 + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN PE2 + #endif + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN PE3 + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN PE3 + #endif + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN PE4 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN PE4 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN PE1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN PE1 + #endif + #ifndef EX_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN PE0 + #endif + #ifndef EX_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN PE0 + #endif + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + // // Temperature Sensors // From 8857fc6c4b7dda4bd4a0907050c81183d989c0e9 Mon Sep 17 00:00:00 2001 From: ellensp Date: Thu, 11 Mar 2021 11:02:35 +1300 Subject: [PATCH 034/311] Fix password menu stickiness before first auth (#21295) --- Marlin/src/feature/password/password.cpp | 11 +++++++---- Marlin/src/feature/password/password.h | 4 ++-- Marlin/src/lcd/menu/menu_password.cpp | 13 +++++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Marlin/src/feature/password/password.cpp b/Marlin/src/feature/password/password.cpp index 90bb647118..4e841c243c 100644 --- a/Marlin/src/feature/password/password.cpp +++ b/Marlin/src/feature/password/password.cpp @@ -31,7 +31,7 @@ Password password; // public: -bool Password::is_set, Password::is_locked; +bool Password::is_set, Password::is_locked, Password::did_first_run; // = false uint32_t Password::value, Password::value_entry; // @@ -47,11 +47,14 @@ void Password::lock_machine() { // Authentication check // void Password::authentication_check() { - if (value_entry == value) + if (value_entry == value) { is_locked = false; - else + did_first_run = true; + } + else { + is_locked = true; SERIAL_ECHOLNPGM(STR_WRONG_PASSWORD); - + } TERN_(HAS_LCD_MENU, authentication_done()); } diff --git a/Marlin/src/feature/password/password.h b/Marlin/src/feature/password/password.h index 1382d6df40..829d222e20 100644 --- a/Marlin/src/feature/password/password.h +++ b/Marlin/src/feature/password/password.h @@ -25,10 +25,10 @@ class Password { public: - static bool is_set, is_locked; + static bool is_set, is_locked, did_first_run; static uint32_t value, value_entry; - Password() { is_locked = false; } + Password() {} static void lock_machine(); static void authentication_check(); diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index 80c5c3dc66..590ce48d59 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -44,12 +44,18 @@ static uint8_t digit_no; // Screen for both editing and setting the password // void Password::menu_password_entry() { + ui.defer_status_screen(!did_first_run); // No timeout to status before first auth + START_MENU(); // "Login" or "New Code" STATIC_ITEM_P(authenticating ? GET_TEXT(MSG_LOGIN_REQUIRED) : GET_TEXT(MSG_EDIT_PASSWORD), SS_CENTER|SS_INVERT); - STATIC_ITEM_P(NUL_STR, SS_CENTER|SS_INVERT, string); + STATIC_ITEM_P(NUL_STR, SS_CENTER, string); + + #if HAS_MARLINUI_U8GLIB + STATIC_ITEM_P(NUL_STR, SS_CENTER, ""); + #endif // Make the digit edit item look like a sub-menu PGM_P const label = GET_TEXT(MSG_ENTER_DIGIT); @@ -57,7 +63,7 @@ void Password::menu_password_entry() { MENU_ITEM_ADDON_START(utf8_strlen_P(label) + 1); lcd_put_wchar(' '); lcd_put_wchar('1' + digit_no); - SETCURSOR_X(LCD_WIDTH - 1); + SETCURSOR_X(LCD_WIDTH - 2); lcd_put_wchar('>'); MENU_ITEM_ADDON_END(); @@ -104,7 +110,7 @@ void Password::screen_password_entry() { value_entry = 0; digit_no = 0; editable.uint8 = 0; - memset(string, '-', PASSWORD_LENGTH); + memset(string, '_', PASSWORD_LENGTH); string[PASSWORD_LENGTH] = '\0'; menu_password_entry(); } @@ -120,7 +126,6 @@ void Password::authenticate_user(const screenFunc_t in_succ_scr, const screenFun if (is_set) { authenticating = true; ui.goto_screen(screen_password_entry); - ui.defer_status_screen(); ui.update(); } else { From a73cff8e4fa5c856859093d54b9427d889049734 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 11 Mar 2021 00:13:08 +0000 Subject: [PATCH 035/311] [cron] Bump distribution date (2021-03-11) --- 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 df29952479..8f98dea437 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-03-10" + #define STRING_DISTRIBUTION_DATE "2021-03-11" #endif /** From 03a41021def9513d4a77caf3c82a0733b7686193 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 12 Mar 2021 00:13:16 +0000 Subject: [PATCH 036/311] [cron] Bump distribution date (2021-03-12) --- 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 8f98dea437..c9760f3f69 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-03-11" + #define STRING_DISTRIBUTION_DATE "2021-03-12" #endif /** From 6e1024737d0f74cdc7aed99a9275e071283fe4b7 Mon Sep 17 00:00:00 2001 From: Evgeny Z Date: Fri, 12 Mar 2021 05:12:24 +0300 Subject: [PATCH 037/311] =?UTF-8?q?Lerdge-X=20I=C2=B2C=20EEPROM=20pins,=20?= =?UTF-8?q?size=20(#21322)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f4/pins_LERDGE_X.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h index 974392373f..3a9c286e00 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_X.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_X.h @@ -32,6 +32,9 @@ #define TEMP_TIMER 2 #define I2C_EEPROM +#define I2C_SCL_PIN PB8 +#define I2C_SDA_PIN PB9 +#define MARLIN_EEPROM_SIZE 0x10000 // FM24CL64 F-RAM 64K (8Kx8) // USB Flash Drive support #define HAS_OTG_USB_HOST_SUPPORT From 9dc2712c47f9ce6e5eb0c388a3d50a3a28574c27 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Fri, 12 Mar 2021 12:25:30 +0100 Subject: [PATCH 038/311] Undef unused 2nd serial option(s) (#21331) Co-authored-by: Scott Lahteine --- Marlin/src/inc/Conditionals_post.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 7dc75db1c2..a6567e9714 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2913,6 +2913,9 @@ #define HAS_MULTI_SERIAL 1 #endif -#if ENABLED(MEATPACK_ON_SERIAL_PORT_1) || BOTH(HAS_MULTI_SERIAL, MEATPACK_ON_SERIAL_PORT_2) +#if !HAS_MULTI_SERIAL + #undef MEATPACK_ON_SERIAL_PORT_2 +#endif +#if EITHER(MEATPACK_ON_SERIAL_PORT_1, MEATPACK_ON_SERIAL_PORT_2) #define HAS_MEATPACK 1 #endif From 1affbe2100c32f79d469b059be3eddd364a80431 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Mar 2021 06:54:42 -0600 Subject: [PATCH 039/311] Clean up, optimize ExtUI/TFT code (#21333) --- Marlin/src/feature/bedlevel/bedlevel.cpp | 2 +- Marlin/src/feature/bedlevel/bedlevel.h | 2 +- Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp | 8 +- Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp | 6 +- Marlin/src/lcd/extui/dgus_lcd.cpp | 10 +- Marlin/src/lcd/extui/example.cpp | 8 +- .../lib/anycubic_chiron/FileNavigator.cpp | 2 +- .../extui/lib/anycubic_chiron/chiron_tft.cpp | 5 +- .../extui/lib/anycubic_chiron/chiron_tft.h | 67 ++--- .../lib/anycubic_chiron/chiron_tft_defs.h | 4 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 232 +++++++++--------- .../lib/anycubic_i3mega/anycubic_i3mega_lcd.h | 78 +++--- .../lib/ftdi_eve_touch_ui/marlin_events.cpp | 2 +- .../screens/bed_mesh_screen.h | 2 +- .../screens/stress_test_screen.cpp | 4 +- .../screens/temperature_screen.cpp | 7 +- Marlin/src/lcd/extui/malyan_lcd.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 135 +++++----- Marlin/src/lcd/extui/ui_api.h | 73 +++--- Marlin/src/sd/cardreader.h | 2 - 20 files changed, 319 insertions(+), 332 deletions(-) diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 2ad4ffecaf..3680fbac05 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -98,7 +98,7 @@ TemporaryBedLevelingState::TemporaryBedLevelingState(const bool enable) : saved( #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - void set_z_fade_height(const float zfh, const bool do_report/*=true*/) { + void set_z_fade_height(const float &zfh, const bool do_report/*=true*/) { if (planner.z_fade_height == zfh) return; diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index a33f08ad0e..3e89a08802 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -38,7 +38,7 @@ void set_bed_leveling_enabled(const bool enable=true); void reset_bed_level(); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - void set_z_fade_height(const float zfh, const bool do_report=true); + void set_z_fade_height(const float &zfh, const bool do_report=true); #endif #if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY) diff --git a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp index 06baa4c19d..a424327b08 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp @@ -74,7 +74,7 @@ namespace ExtUI { // into buff. // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(buff, &myDataStruct, sizeof(myDataStruct)); } @@ -84,7 +84,7 @@ namespace ExtUI { // from buff // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } @@ -101,12 +101,12 @@ namespace ExtUI { #if HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) { // Called when any mesh points are updated //SERIAL_ECHOLNPAIR("onMeshUpdate() x:", xpos, " y:", ypos, " z:", zval); } - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) { // Called to indicate a special condition //SERIAL_ECHOLNPAIR("onMeshUpdate() x:", xpos, " y:", ypos, " state:", state); } diff --git a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp index e2bd96068c..939199db93 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp @@ -65,7 +65,7 @@ namespace ExtUI { // into buff. // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(buff, &myDataStruct, sizeof(myDataStruct)); } @@ -75,7 +75,7 @@ namespace ExtUI { // from buff // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } @@ -93,7 +93,7 @@ namespace ExtUI { void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) { // Called when any mesh points are updated } #endif diff --git a/Marlin/src/lcd/extui/dgus_lcd.cpp b/Marlin/src/lcd/extui/dgus_lcd.cpp index 9e6ca1b64c..273a8d2d2a 100644 --- a/Marlin/src/lcd/extui/dgus_lcd.cpp +++ b/Marlin/src/lcd/extui/dgus_lcd.cpp @@ -61,7 +61,7 @@ namespace ExtUI { void onUserConfirmRequired(const char * const msg) { if (msg) { ScreenHandler.sendinfoscreen(PSTR("Please confirm."), nullptr, msg, nullptr, true, true, false, true); - ScreenHandler.SetupConfirmAction(ExtUI::setUserConfirmed); + ScreenHandler.SetupConfirmAction(setUserConfirmed); ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP); } else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP ) { @@ -84,7 +84,7 @@ namespace ExtUI { // into buff. // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(buff, &myDataStruct, sizeof(myDataStruct)); } @@ -94,7 +94,7 @@ namespace ExtUI { // from buff // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } @@ -111,11 +111,11 @@ namespace ExtUI { #if HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) { // Called when any mesh points are updated } - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) { // Called to indicate a special condition } #endif diff --git a/Marlin/src/lcd/extui/example.cpp b/Marlin/src/lcd/extui/example.cpp index dd4b3312eb..415d381dd6 100644 --- a/Marlin/src/lcd/extui/example.cpp +++ b/Marlin/src/lcd/extui/example.cpp @@ -70,7 +70,7 @@ namespace ExtUI { // into buff. // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(buff, &myDataStruct, sizeof(myDataStruct)); } @@ -80,7 +80,7 @@ namespace ExtUI { // from buff // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } @@ -97,11 +97,11 @@ namespace ExtUI { #if HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) { // Called when any mesh points are updated } - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) { // Called to indicate a special condition } #endif diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp index 7d813a6ab0..25847ae96c 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp @@ -73,7 +73,7 @@ namespace Anycubic { // Each time we change folder we reset the file index to 0 and keep track // of the current position as the TFT panel isnt aware of folders trees. if (index > 0) { - --currentindex; // go back a file to take account off the .. we added to the root. + --currentindex; // go back a file to take account of the .. added to the root. if (index > lastindex) currentindex += files; else diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index 97149a407e..aa78fcb539 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -288,7 +288,7 @@ namespace Anycubic { SERIAL_ECHOLNPGM("Select SD file then press resume"); } - void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEN string to the panel + void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel #if ACDEBUG(AC_SOME) SERIAL_ECHOPGM_P(str); #endif @@ -880,6 +880,7 @@ namespace Anycubic { } break; } } -} // namespace + +} // Anycubic #endif // ANYCUBIC_LCD_CHIRON diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h index 267f2fe978..e7bbd3cbbf 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h @@ -32,46 +32,49 @@ #include "chiron_tft_defs.h" #include "../../../../inc/MarlinConfigPre.h" #include "../../ui_api.h" + namespace Anycubic { class ChironTFT { - static printer_state_t printer_state; - static paused_state_t pause_state; - static heater_state_t hotend_state; - static heater_state_t hotbed_state; - static xy_uint8_t selectedmeshpoint; - static char panel_command[MAX_CMND_LEN]; - static uint8_t command_len; - static char selectedfile[MAX_PATH_LEN]; - static float live_Zoffset; - static file_menu_t file_menu; + private: + static printer_state_t printer_state; + static paused_state_t pause_state; + static heater_state_t hotend_state; + static heater_state_t hotbed_state; + static xy_uint8_t selectedmeshpoint; + static char panel_command[MAX_CMND_LEN]; + static uint8_t command_len; + static char selectedfile[MAX_PATH_LEN]; + static float live_Zoffset; + static file_menu_t file_menu; + public: ChironTFT(); - void Startup(); - void IdleLoop(); - void PrinterKilled(PGM_P,PGM_P); - void MediaEvent(media_event_t); - void TimerEvent(timer_event_t); - void FilamentRunout(); - void ConfirmationRequest(const char * const ); - void StatusChange(const char * const ); - void PowerLossRecovery(); + static void Startup(); + static void IdleLoop(); + static void PrinterKilled(PGM_P,PGM_P); + static void MediaEvent(media_event_t); + static void TimerEvent(timer_event_t); + static void FilamentRunout(); + static void ConfirmationRequest(const char * const ); + static void StatusChange(const char * const ); + static void PowerLossRecovery(); private: - void SendtoTFT(PGM_P); - void SendtoTFTLN(PGM_P); - bool ReadTFTCommand(); - int8_t Findcmndpos(const char *, char); - void CheckHeaters(); - void SendFileList(int8_t); - void SelectFile(); - void InjectCommandandWait(PGM_P); - void ProcessPanelRequest(); - void PanelInfo(uint8_t); - void PanelAction(uint8_t); - void PanelProcess(uint8_t); + static void SendtoTFT(PGM_P); + static void SendtoTFTLN(PGM_P); + static bool ReadTFTCommand(); + static int8_t Findcmndpos(const char *, char); + static void CheckHeaters(); + static void SendFileList(int8_t); + static void SelectFile(); + static void InjectCommandandWait(PGM_P); + static void ProcessPanelRequest(); + static void PanelInfo(uint8_t); + static void PanelAction(uint8_t); + static void PanelProcess(uint8_t); }; extern ChironTFT Chiron; -} +} // Anycubic diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h index 7012e98d92..3087d83801 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h @@ -109,6 +109,7 @@ #define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position namespace Anycubic { + enum heater_state_t : uint8_t { AC_heater_off, AC_heater_temp_set, @@ -148,4 +149,5 @@ namespace Anycubic { AC_menu_change_to_file, AC_menu_change_to_command }; -} + +} // Anycubic 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 a990c4c640..95b07f5c68 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 @@ -2,7 +2,7 @@ * anycubic_i3mega_lcd.cpp --- Support for Anycubic i3 Mega TFT * Created by Christian Hopp on 09.12.17. * Improved by David Ramiro - * Converted to ext_iu by John BouAntoun 21 June 2020 + * Converted to ExtUI by John BouAntoun 21 June 2020 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,44 +32,46 @@ #include "../../../../inc/MarlinConfig.h" // command sending macro's with debugging capability -#define SEND_PGM(x) send_P(PSTR(x)) -#define SENDLINE_PGM(x) sendLine_P(PSTR(x)) -#define SEND_PGM_VAL(x,y) (send_P(PSTR(x)), sendLine(i16tostr3rj(y))) -#define SEND(x) send(x) -#define SENDLINE(x) sendLine(x) +#define SEND_PGM(x) send_P(PSTR(x)) +#define SENDLINE_PGM(x) sendLine_P(PSTR(x)) +#define SEND_PGM_VAL(x,y) (send_P(PSTR(x)), sendLine(i16tostr3rj(y))) +#define SEND(x) send(x) +#define SENDLINE(x) sendLine(x) #if ENABLED(ANYCUBIC_LCD_DEBUG) - #define SENDLINE_DBG_PGM(x,y) (sendLine_P(PSTR(x)), SERIAL_ECHOLNPGM(y)) - #define SENDLINE_DBG_PGM_VAL(x,y,z) (sendLine_P(PSTR(x)), SERIAL_ECHOPGM(y), SERIAL_ECHOLN(z)) + #define SENDLINE_DBG_PGM(x,y) (sendLine_P(PSTR(x)), SERIAL_ECHOLNPGM(y)) + #define SENDLINE_DBG_PGM_VAL(x,y,z) (sendLine_P(PSTR(x)), SERIAL_ECHOPGM(y), SERIAL_ECHOLN(z)) #else - #define SENDLINE_DBG_PGM(x,y) sendLine_P(PSTR(x)) - #define SENDLINE_DBG_PGM_VAL(x,y,z) sendLine_P(PSTR(x)) + #define SENDLINE_DBG_PGM(x,y) sendLine_P(PSTR(x)) + #define SENDLINE_DBG_PGM_VAL(x,y,z) sendLine_P(PSTR(x)) #endif AnycubicTFTClass AnycubicTFT; -static void sendNewLine(void) { - LCD_SERIAL.write('\r'); - LCD_SERIAL.write('\n'); -} +char AnycubicTFTClass::TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE]; +int AnycubicTFTClass::TFTbuflen = 0, + AnycubicTFTClass::TFTbufindr = 0, + AnycubicTFTClass::TFTbufindw = 0; +char AnycubicTFTClass::serial3_char; +int AnycubicTFTClass::serial3_count = 0; +char* AnycubicTFTClass::TFTstrchr_pointer; +uint8_t AnycubicTFTClass::SpecialMenu = false; +AnycubicMediaPrintState AnycubicTFTClass::mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; +AnycubicMediaPauseState AnycubicTFTClass::mediaPauseState = AMPAUSESTATE_NOT_PAUSED; -static void send(const char *str) { - LCD_SERIAL.print(str); -} - -static void sendLine(const char *str) { - send(str); - sendNewLine(); -} +char AnycubicTFTClass::SelectedDirectory[30]; +char AnycubicTFTClass::SelectedFile[FILENAME_LENGTH]; +// Serial helpers +static void sendNewLine(void) { LCD_SERIAL.write('\r'); LCD_SERIAL.write('\n'); } +static void send(const char *str) { LCD_SERIAL.print(str); } static void send_P(PGM_P str) { while (const char c = pgm_read_byte(str++)) LCD_SERIAL.write(c); } +static void sendLine(const char *str) { send(str); sendNewLine(); } +static void sendLine_P(PGM_P str) { send_P(str); sendNewLine(); } -static void sendLine_P(PGM_P str) { - send_P(str); - sendNewLine(); -} +using namespace ExtUI; AnycubicTFTClass::AnycubicTFTClass() {} @@ -80,7 +82,7 @@ void AnycubicTFTClass::OnSetup() { LCD_SERIAL.begin(LCD_BAUDRATE); SENDLINE_DBG_PGM("J17", "TFT Serial Debug: Main board reset... J17"); // J17 Main board reset - ExtUI::delay_ms(10); + delay_ms(10); // initialise the state of the key pins running on the tft #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) @@ -95,13 +97,13 @@ void AnycubicTFTClass::OnSetup() { // DoSDCardStateCheck(); SENDLINE_DBG_PGM("J12", "TFT Serial Debug: Ready... J12"); // J12 Ready - ExtUI::delay_ms(10); + delay_ms(10); DoFilamentRunoutCheck(); SelectedFile[0] = 0; #if ENABLED(STARTUP_CHIME) - ExtUI::injectCommands_P(PSTR("M300 P250 S554\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P500 S831")); + injectCommands_P(PSTR("M300 P250 S554\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P500 S831")); #endif #if ENABLED(ANYCUBIC_LCD_DEBUG) SERIAL_ECHOLNPGM("TFT Serial Debug: Finished startup"); @@ -119,8 +121,8 @@ void AnycubicTFTClass::OnCommandScan() { #endif mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; mediaPauseState = AMPAUSESTATE_NOT_PAUSED; - ExtUI::injectCommands_P(PSTR("M84\nM27")); // disable stepper motors and force report of SD status - ExtUI::delay_ms(200); + injectCommands_P(PSTR("M84\nM27")); // disable stepper motors and force report of SD status + delay_ms(200); // tell printer to release resources of print to indicate it is done SENDLINE_DBG_PGM("J14", "TFT Serial Debug: SD Print Stopped... J14"); } @@ -224,8 +226,8 @@ bool AnycubicTFTClass::CodeSeen(char code) { } bool AnycubicTFTClass::IsNozzleHomed() { - const float xPosition = ExtUI::getAxisPosition_mm((ExtUI::axis_t) ExtUI::X); - const float yPosition = ExtUI::getAxisPosition_mm((ExtUI::axis_t) ExtUI::Y); + const float xPosition = getAxisPosition_mm((axis_t) X); + const float yPosition = getAxisPosition_mm((axis_t) Y); return WITHIN(xPosition, X_MIN_POS - 0.1, X_MIN_POS + 0.1) && WITHIN(yPosition, Y_MIN_POS - 0.1, Y_MIN_POS + 0.1); } @@ -246,48 +248,48 @@ void AnycubicTFTClass::HandleSpecialMenu() { switch (SelectedDirectory[2]) { case '1': // "<01ZUp0.1>" SERIAL_ECHOLNPGM("Special Menu: Z Up 0.1"); - ExtUI::injectCommands_P(PSTR("G91\nG1 Z+0.1\nG90")); + injectCommands_P(PSTR("G91\nG1 Z+0.1\nG90")); break; case '2': // "<02ZUp0.02>" SERIAL_ECHOLNPGM("Special Menu: Z Up 0.02"); - ExtUI::injectCommands_P(PSTR("G91\nG1 Z+0.02\nG90")); + injectCommands_P(PSTR("G91\nG1 Z+0.02\nG90")); break; case '3': // "<03ZDn0.02>" SERIAL_ECHOLNPGM("Special Menu: Z Down 0.02"); - ExtUI::injectCommands_P(PSTR("G91\nG1 Z-0.02\nG90")); + injectCommands_P(PSTR("G91\nG1 Z-0.02\nG90")); break; case '4': // "<04ZDn0.1>" SERIAL_ECHOLNPGM("Special Menu: Z Down 0.1"); - ExtUI::injectCommands_P(PSTR("G91\nG1 Z-0.1\nG90")); + injectCommands_P(PSTR("G91\nG1 Z-0.1\nG90")); break; case '5': // "<05PrehtBed>" SERIAL_ECHOLNPGM("Special Menu: Preheat Bed"); - ExtUI::injectCommands_P(PSTR("M140 S65")); + injectCommands_P(PSTR("M140 S65")); break; case '6': // "<06SMeshLvl>" SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling"); - ExtUI::injectCommands_P(PSTR("G29S1")); + injectCommands_P(PSTR("G29S1")); break; case '7': // "<07MeshNPnt>" SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point"); - ExtUI::injectCommands_P(PSTR("G29S2")); + injectCommands_P(PSTR("G29S2")); break; case '8': // "<08HtEndPID>" SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotend PID"); // need to dwell for half a second to give the fan a chance to start before the pid tuning starts - ExtUI::injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); + injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); break; case '9': // "<09HtBedPID>" SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotbed Pid"); - ExtUI::injectCommands_P(PSTR("M303 E-1 S65 C6 U1")); + injectCommands_P(PSTR("M303 E-1 S65 C6 U1")); break; default: @@ -299,12 +301,12 @@ void AnycubicTFTClass::HandleSpecialMenu() { switch (SelectedDirectory[2]) { case '0': // "<10FWDeflts>" SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults"); - ExtUI::injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108")); + injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108")); break; case '1': // "<11SvEEPROM>" SERIAL_ECHOLNPGM("Special Menu: Save EEPROM"); - ExtUI::injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661")); + injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661")); break; default: @@ -316,38 +318,38 @@ void AnycubicTFTClass::HandleSpecialMenu() { switch (SelectedDirectory[2]) { case '1': // "<01PrehtBed>" SERIAL_ECHOLNPGM("Special Menu: Preheat Bed"); - ExtUI::injectCommands_P(PSTR("M140 S65")); + injectCommands_P(PSTR("M140 S65")); break; case '2': // "<02ABL>" SERIAL_ECHOLNPGM("Special Menu: Auto Bed Leveling"); - ExtUI::injectCommands_P(PSTR("G29N")); + injectCommands_P(PSTR("G29N")); break; case '3': // "<03HtendPID>" SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotend PID"); // need to dwell for half a second to give the fan a chance to start before the pid tuning starts - ExtUI::injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); + injectCommands_P(PSTR("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); break; case '4': // "<04HtbedPID>" SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotbed Pid"); - ExtUI::injectCommands_P(PSTR("M303 E-1 S65 C6 U1")); + injectCommands_P(PSTR("M303 E-1 S65 C6 U1")); break; case '5': // "<05FWDeflts>" SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults"); - ExtUI::injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108")); + injectCommands_P(PSTR("M502\nM300 P105 S1661\nM300 P210 S1108")); break; case '6': // "<06SvEEPROM>" SERIAL_ECHOLNPGM("Special Menu: Save EEPROM"); - ExtUI::injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661")); + injectCommands_P(PSTR("M500\nM300 P105 S1108\nM300 P210 S1661")); break; case '7': // <07SendM108> SERIAL_ECHOLNPGM("Special Menu: Send User Confirmation"); - ExtUI::injectCommands_P(PSTR("M108")); + injectCommands_P(PSTR("M108")); break; default: @@ -373,11 +375,11 @@ void AnycubicTFTClass::RenderCurrentFileList() { uint16_t selectedNumber = 0; SelectedDirectory[0] = 0; SelectedFile[0] = 0; - ExtUI::FileList currentFileList; + FileList currentFileList; SENDLINE_PGM("FN "); // Filelist start - if (!ExtUI::isMediaInserted() && !SpecialMenu) { + if (!isMediaInserted() && !SpecialMenu) { SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to render Current File List... J02"); SENDLINE_PGM(""); @@ -462,7 +464,7 @@ void AnycubicTFTClass::RenderSpecialMenu(uint16_t selectedNumber) { } void AnycubicTFTClass::RenderCurrentFolder(uint16_t selectedNumber) { - ExtUI::FileList currentFileList; + FileList currentFileList; uint16_t cnt = selectedNumber; uint16_t max_files; uint16_t dir_files = currentFileList.count(); @@ -514,7 +516,7 @@ void AnycubicTFTClass::OnPrintTimerStarted() { void AnycubicTFTClass::OnPrintTimerPaused() { #if ENABLED(SDSUPPORT) - if (ExtUI::isPrintingFromMedia()) { + if (isPrintingFromMedia()) { mediaPrintingState = AMPRINTSTATE_PAUSED; mediaPauseState = AMPAUSESTATE_PARKING; } @@ -558,38 +560,38 @@ void AnycubicTFTClass::GetCommandFromTFT() { switch (a_command) { case 0: { // A0 GET HOTEND TEMP - float hotendActualTemp = ExtUI::getActualTemp_celsius((ExtUI::extruder_t) (ExtUI::extruder_t) ExtUI::E0); + float hotendActualTemp = getActualTemp_celsius((extruder_t) (extruder_t) E0); SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5)); } break; case 1: { // A1 GET HOTEND TARGET TEMP - float hotendTargetTemp = ExtUI::getTargetTemp_celsius((ExtUI::extruder_t) (ExtUI::extruder_t) ExtUI::E0); + float hotendTargetTemp = getTargetTemp_celsius((extruder_t) (extruder_t) E0); SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5)); } break; case 2: { // A2 GET HOTBED TEMP - float heatedBedActualTemp = ExtUI::getActualTemp_celsius((ExtUI::heater_t) ExtUI::BED); + float heatedBedActualTemp = getActualTemp_celsius((heater_t) BED); SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5)); } break; case 3: { // A3 GET HOTBED TARGET TEMP - float heatedBedTargetTemp = ExtUI::getTargetTemp_celsius((ExtUI::heater_t) ExtUI::BED); + float heatedBedTargetTemp = getTargetTemp_celsius((heater_t) BED); SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5)); } break; case 4: { // A4 GET FAN SPEED - float fanPercent = ExtUI::getActualFan_percent(ExtUI::FAN0); + float fanPercent = getActualFan_percent(FAN0); fanPercent = constrain(fanPercent, 0, 100); SEND_PGM_VAL("A4V ", int(fanPercent)); } break; case 5: { // A5 GET CURRENT COORDINATE - const float xPosition = ExtUI::getAxisPosition_mm(ExtUI::X), - yPosition = ExtUI::getAxisPosition_mm(ExtUI::Y), - zPosition = ExtUI::getAxisPosition_mm(ExtUI::Z); + const float xPosition = getAxisPosition_mm(X), + yPosition = getAxisPosition_mm(Y), + zPosition = getAxisPosition_mm(Z); SEND_PGM("A5V X: "); LCD_SERIAL.print(xPosition); SEND_PGM( " Y: "); LCD_SERIAL.print(yPosition); SEND_PGM( " Z: "); LCD_SERIAL.print(zPosition); @@ -598,10 +600,10 @@ void AnycubicTFTClass::GetCommandFromTFT() { case 6: // A6 GET SD CARD PRINTING STATUS #if ENABLED(SDSUPPORT) - if (ExtUI::isPrintingFromMedia()) { + if (isPrintingFromMedia()) { SEND_PGM("A6V "); - if (ExtUI::isMediaInserted()) - SENDLINE(ui8tostr3rj(ExtUI::getProgress_percent())); + if (isMediaInserted()) + SENDLINE(ui8tostr3rj(getProgress_percent())); else SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to return printing status... J02"); } @@ -611,7 +613,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { break; case 7: { // A7 GET PRINTING TIME - const uint32_t elapsedSeconds = ExtUI::getProgress_seconds_elapsed(); + const uint32_t elapsedSeconds = getProgress_seconds_elapsed(); SEND_PGM("A7V "); if (elapsedSeconds != 0) { // print time const uint32_t elapsedMinutes = elapsedSeconds / 60; @@ -634,14 +636,14 @@ void AnycubicTFTClass::GetCommandFromTFT() { case 9: // A9 pause sd print #if ENABLED(SDSUPPORT) - if (ExtUI::isPrintingFromMedia()) + if (isPrintingFromMedia()) PausePrint(); #endif break; case 10: // A10 resume sd print #if ENABLED(SDSUPPORT) - if (ExtUI::isPrintingFromMediaPaused()) + if (isPrintingFromMediaPaused()) ResumePrint(); #endif break; @@ -656,7 +658,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { case 13: // A13 SELECTION FILE #if ENABLED(SDSUPPORT) - if (ExtUI::isMediaInserted()) { + if (isMediaInserted()) { starpos = (strchr(TFTstrchr_pointer + 4, '*')); if (TFTstrchr_pointer[4] == '/') { strcpy(SelectedDirectory, TFTstrchr_pointer + 5); @@ -685,7 +687,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { case 14: // A14 START PRINTING #if ENABLED(SDSUPPORT) - if (!ExtUI::isPrinting() && strlen(SelectedFile) > 0) + if (!isPrinting() && strlen(SelectedFile) > 0) StartPrint(); #endif break; @@ -698,13 +700,13 @@ void AnycubicTFTClass::GetCommandFromTFT() { unsigned int tempvalue; if (CodeSeen('S')) { tempvalue = constrain(CodeValue(), 0, 275); - ExtUI::setTargetTemp_celsius(tempvalue, (ExtUI::extruder_t) ExtUI::E0); + setTargetTemp_celsius(tempvalue, (extruder_t) E0); } - else if (CodeSeen('C') && !ExtUI::isPrinting()) { - if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10) - ExtUI::injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS + else if (CodeSeen('C') && !isPrinting()) { + if (getAxisPosition_mm(Z) < 10) + injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS tempvalue = constrain(CodeValue(), 0, 275); - ExtUI::setTargetTemp_celsius(tempvalue, (ExtUI::extruder_t) ExtUI::E0); + setTargetTemp_celsius(tempvalue, (extruder_t) E0); } } break; @@ -713,7 +715,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { unsigned int tempbed; if (CodeSeen('S')) { tempbed = constrain(CodeValue(), 0, 100); - ExtUI::setTargetTemp_celsius(tempbed, (ExtUI::heater_t)ExtUI::BED); + setTargetTemp_celsius(tempbed, (heater_t)BED); } } break; @@ -723,18 +725,18 @@ void AnycubicTFTClass::GetCommandFromTFT() { if (CodeSeen('S')) { fanPercent = CodeValue(); fanPercent = constrain(fanPercent, 0, 100); - ExtUI::setTargetFan_percent(fanPercent, ExtUI::FAN0); + setTargetFan_percent(fanPercent, FAN0); } else fanPercent = 100; - ExtUI::setTargetFan_percent(fanPercent, ExtUI::FAN0); + setTargetFan_percent(fanPercent, FAN0); SENDLINE_PGM(""); } break; case 19: // A19 stop stepper drivers - sent on stop extrude command and on turn motors off command - if (!ExtUI::isPrinting()) { + if (!isPrinting()) { quickstop_stepper(); disable_all_steppers(); } @@ -750,23 +752,23 @@ void AnycubicTFTClass::GetCommandFromTFT() { break; case 21: // A21 all home - if (!ExtUI::isPrinting() && !ExtUI::isPrintingFromMediaPaused()) { + if (!isPrinting() && !isPrintingFromMediaPaused()) { if (CodeSeen('X') || CodeSeen('Y') || CodeSeen('Z')) { if (CodeSeen('X')) - ExtUI::injectCommands_P(PSTR("G28X")); + injectCommands_P(PSTR("G28X")); if (CodeSeen('Y')) - ExtUI::injectCommands_P(PSTR("G28Y")); + injectCommands_P(PSTR("G28Y")); if (CodeSeen('Z')) - ExtUI::injectCommands_P(PSTR("G28Z")); + injectCommands_P(PSTR("G28Z")); } else if (CodeSeen('C')) { - ExtUI::injectCommands_P(G28_STR); + injectCommands_P(G28_STR); } } break; case 22: // A22 move X/Y/Z or extrude - if (!ExtUI::isPrinting()) { + if (!isPrinting()) { float coorvalue; unsigned int movespeed = 0; char commandStr[30]; @@ -819,38 +821,38 @@ void AnycubicTFTClass::GetCommandFromTFT() { SERIAL_ECHOPGM("TFT Serial Debug: A22 Move final request with gcode... "); SERIAL_ECHOLN(fullCommandStr); #endif - ExtUI::injectCommands(fullCommandStr); + injectCommands(fullCommandStr); } } SENDLINE_PGM(""); break; case 23: // A23 preheat pla - if (!ExtUI::isPrinting()) { - if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10) - ExtUI::injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS + if (!isPrinting()) { + if (getAxisPosition_mm(Z) < 10) + injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS - ExtUI::setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (ExtUI::heater_t) ExtUI::BED); - ExtUI::setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (ExtUI::extruder_t) ExtUI::E0); + setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (heater_t) BED); + setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (extruder_t) E0); SENDLINE_PGM("OK"); } break; case 24:// A24 preheat abs - if (!ExtUI::isPrinting()) { - if (ExtUI::getAxisPosition_mm(ExtUI::Z) < 10) - ExtUI::injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS + if (!isPrinting()) { + if (getAxisPosition_mm(Z) < 10) + injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS - ExtUI::setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (ExtUI::heater_t) ExtUI::BED); - ExtUI::setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (ExtUI::extruder_t) ExtUI::E0); + setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (heater_t) BED); + setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (extruder_t) E0); SENDLINE_PGM("OK"); } break; case 25: // A25 cool down - if (!ExtUI::isPrinting()) { - ExtUI::setTargetTemp_celsius(0, (ExtUI::heater_t) ExtUI::BED); - ExtUI::setTargetTemp_celsius(0, (ExtUI::extruder_t) ExtUI::E0); + if (!isPrinting()) { + setTargetTemp_celsius(0, (heater_t) BED); + setTargetTemp_celsius(0, (extruder_t) E0); SENDLINE_DBG_PGM("J12", "TFT Serial Debug: Cooling down... J12"); // J12 cool down } @@ -858,9 +860,9 @@ void AnycubicTFTClass::GetCommandFromTFT() { case 26: // A26 refresh SD #if ENABLED(SDSUPPORT) - if (ExtUI::isMediaInserted()) { + if (isMediaInserted()) { if (strlen(SelectedDirectory) > 0) { - ExtUI::FileList currentFileList; + FileList currentFileList; if ((SelectedDirectory[0] == '.') && (SelectedDirectory[1] == '.')) { currentFileList.upDir(); } @@ -914,7 +916,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { void AnycubicTFTClass::DoSDCardStateCheck() { #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) - bool isInserted = ExtUI::isMediaInserted(); + bool isInserted = isMediaInserted(); if (isInserted) SENDLINE_DBG_PGM("J00", "TFT Serial Debug: SD card state changed... isInserted"); else @@ -925,12 +927,12 @@ void AnycubicTFTClass::DoSDCardStateCheck() { void AnycubicTFTClass::DoFilamentRunoutCheck() { #if ENABLED(FILAMENT_RUNOUT_SENSOR) - // NOTE: ExtUI::getFilamentRunoutState() only returns the runout state if the job is printing + // NOTE: getFilamentRunoutState() only returns the runout state if the job is printing // we want to actually check the status of the pin here, regardless of printstate if (READ(FIL_RUNOUT1_PIN)) { if (mediaPrintingState == AMPRINTSTATE_PRINTING || mediaPrintingState == AMPRINTSTATE_PAUSED || mediaPrintingState == AMPRINTSTATE_PAUSE_REQUESTED) { // play tone to indicate filament is out - ExtUI::injectCommands_P(PSTR("\nM300 P200 S1567\nM300 P200 S1174\nM300 P200 S1567\nM300 P200 S1174\nM300 P2000 S1567")); + injectCommands_P(PSTR("\nM300 P200 S1567\nM300 P200 S1174\nM300 P200 S1567\nM300 P200 S1174\nM300 P2000 S1567")); // tell the user that the filament has run out and wait SENDLINE_DBG_PGM("J23", "TFT Serial Debug: Blocking filament prompt... J23"); @@ -944,30 +946,30 @@ void AnycubicTFTClass::DoFilamentRunoutCheck() { void AnycubicTFTClass::StartPrint() { #if ENABLED(SDSUPPORT) - if (!ExtUI::isPrinting() && strlen(SelectedFile) > 0) { + if (!isPrinting() && strlen(SelectedFile) > 0) { #if ENABLED(ANYCUBIC_LCD_DEBUG) SERIAL_ECHOPGM("TFT Serial Debug: About to print file ... "); - SERIAL_ECHO(ExtUI::isPrinting()); + SERIAL_ECHO(isPrinting()); SERIAL_ECHOPGM(" "); SERIAL_ECHOLN(SelectedFile); #endif mediaPrintingState = AMPRINTSTATE_PRINTING; mediaPauseState = AMPAUSESTATE_NOT_PAUSED; - ExtUI::printFile(SelectedFile); + printFile(SelectedFile); } #endif // SDUPPORT } void AnycubicTFTClass::PausePrint() { #if ENABLED(SDSUPPORT) - if (ExtUI::isPrintingFromMedia() && mediaPrintingState != AMPRINTSTATE_STOP_REQUESTED && mediaPauseState == AMPAUSESTATE_NOT_PAUSED) { + if (isPrintingFromMedia() && mediaPrintingState != AMPRINTSTATE_STOP_REQUESTED && mediaPauseState == AMPAUSESTATE_NOT_PAUSED) { mediaPrintingState = AMPRINTSTATE_PAUSE_REQUESTED; mediaPauseState = AMPAUSESTATE_NOT_PAUSED; // need the userconfirm method to update pause state SENDLINE_DBG_PGM("J05", "TFT Serial Debug: SD print pause started... J05"); // J05 printing pause // for some reason pausing the print doesn't retract the extruder so force a manual one here - ExtUI::injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90")); - ExtUI::pausePrint(); + injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90")); + pausePrint(); } #endif } @@ -996,14 +998,14 @@ void AnycubicTFTClass::ResumePrint() { // SENDLINE_DBG_PGM("J05", "TFT Serial Debug: Resume called with heater timeout... J05"); // J05 printing pause // reheat the nozzle - ExtUI::setUserConfirmed(); + setUserConfirmed(); } else { mediaPrintingState = AMPRINTSTATE_PRINTING; mediaPauseState = AMPAUSESTATE_NOT_PAUSED; SENDLINE_DBG_PGM("J04", "TFT Serial Debug: SD print resumed... J04"); // J04 printing form sd card now - ExtUI::resumePrint(); + resumePrint(); } #endif } @@ -1015,8 +1017,8 @@ void AnycubicTFTClass::StopPrint() { SENDLINE_DBG_PGM("J16", "TFT Serial Debug: SD print stop called... J16"); // for some reason stopping the print doesn't retract the extruder so force a manual one here - ExtUI::injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90")); - ExtUI::stopPrint(); + injectCommands_P(PSTR("G91\nG1 E-2 F1800\nG90")); + stopPrint(); #endif } diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.h b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.h index 59050acccb..e34cb2fe69 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.h +++ b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.h @@ -2,7 +2,7 @@ * anycubic_i3mega_lcd.h --- Support for Anycubic i3 Mega TFT * Created by Christian Hopp on 09.12.17. * Improved by David Ramiro - * Converted to ext_iu by John BouAntoun 21 June 2020 + * Converted to ExtUI by John BouAntoun 21 June 2020 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -48,49 +48,47 @@ enum AnycubicMediaPauseState { class AnycubicTFTClass { public: AnycubicTFTClass(); - void OnSetup(); - void OnCommandScan(); - void OnKillTFT(); - void OnSDCardStateChange(bool); - void OnSDCardError(); - void OnFilamentRunout(); - void OnUserConfirmRequired(const char *); - void OnPrintTimerStarted(); - void OnPrintTimerPaused(); - void OnPrintTimerStopped(); + static void OnSetup(); + static void OnCommandScan(); + static void OnKillTFT(); + static void OnSDCardStateChange(bool); + static void OnSDCardError(); + static void OnFilamentRunout(); + static void OnUserConfirmRequired(const char *); + static void OnPrintTimerStarted(); + static void OnPrintTimerPaused(); + static void OnPrintTimerStopped(); private: - char TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE]; - int TFTbuflen=0; - int TFTbufindr = 0; - int TFTbufindw = 0; - char serial3_char; - int serial3_count = 0; - char *TFTstrchr_pointer; - uint8_t SpecialMenu = false; - AnycubicMediaPrintState mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; - AnycubicMediaPauseState mediaPauseState = AMPAUSESTATE_NOT_PAUSED; + static char TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE]; + static int TFTbuflen, TFTbufindr, TFTbufindw; + static char serial3_char; + static int serial3_count; + static char *TFTstrchr_pointer; + static uint8_t SpecialMenu; + static AnycubicMediaPrintState mediaPrintingState; + static AnycubicMediaPauseState mediaPauseState; - float CodeValue(); - bool CodeSeen(char); - bool IsNozzleHomed(); - void RenderCurrentFileList(); - void RenderSpecialMenu(uint16_t); - void RenderCurrentFolder(uint16_t); - void GetCommandFromTFT(); - void CheckSDCardChange(); - void CheckPauseState(); - void CheckPrintCompletion(); - void HandleSpecialMenu(); - void DoSDCardStateCheck(); - void DoFilamentRunoutCheck(); - void StartPrint(); - void PausePrint(); - void ResumePrint(); - void StopPrint(); + static float CodeValue(); + static bool CodeSeen(char); + static bool IsNozzleHomed(); + static void RenderCurrentFileList(); + static void RenderSpecialMenu(uint16_t); + static void RenderCurrentFolder(uint16_t); + static void GetCommandFromTFT(); + static void CheckSDCardChange(); + static void CheckPauseState(); + static void CheckPrintCompletion(); + static void HandleSpecialMenu(); + static void DoSDCardStateCheck(); + static void DoFilamentRunoutCheck(); + static void StartPrint(); + static void PausePrint(); + static void ResumePrint(); + static void StopPrint(); - char SelectedDirectory[30]; - char SelectedFile[FILENAME_LENGTH]; + static char SelectedDirectory[30]; + static char SelectedFile[FILENAME_LENGTH]; }; extern AnycubicTFTClass AnycubicTFT; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp index fc9b5d0a70..902ede025c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp @@ -140,7 +140,7 @@ namespace ExtUI { #if HAS_LEVELING && HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t x, const int8_t y, const float val) { + void onMeshUpdate(const int8_t x, const int8_t y, const float &val) { BedMeshScreen::onMeshUpdate(x, y, val); } 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 index 7aac484cb6..de72d863ae 100644 --- 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 @@ -51,7 +51,7 @@ class BedMeshScreen : public BaseScreen, public CachedScreen 0 ? CEIL(steps) : FLOOR(steps); } - #endif + + #endif // BABYSTEPPING float getZOffset_mm() { return (0.0f @@ -754,7 +744,7 @@ namespace ExtUI { ); } - void setZOffset_mm(const float value) { + void setZOffset_mm(const float &value) { #if HAS_BED_PROBE if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) probe.offset.z = value; @@ -772,7 +762,7 @@ namespace ExtUI { return hotend_offset[extruder - E0][axis]; } - void setNozzleOffset_mm(const float value, const axis_t axis, const extruder_t extruder) { + void setNozzleOffset_mm(const float &value, const axis_t axis, const extruder_t extruder) { if (extruder - E0 >= HOTENDS) return; hotend_offset[extruder - E0][axis] = value; } @@ -790,25 +780,21 @@ namespace ExtUI { #endif // HAS_HOTEND_OFFSET #if HAS_BED_PROBE - float getProbeOffset_mm(const axis_t axis) { - return probe.offset.pos[axis]; - } - void setProbeOffset_mm(const float val, const axis_t axis) { - probe.offset.pos[axis] = val; - } + float getProbeOffset_mm(const axis_t axis) { return probe.offset.pos[axis]; } + void setProbeOffset_mm(const float &val, const axis_t axis) { probe.offset.pos[axis] = val; } #endif #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t axis) { return backlash.distance_mm[axis]; } - void setAxisBacklash_mm(const float value, const axis_t axis) + void setAxisBacklash_mm(const float &value, const axis_t axis) { backlash.distance_mm[axis] = constrain(value,0,5); } float getBacklashCorrection_percent() { return ui8_to_percent(backlash.correction); } - void setBacklashCorrection_percent(const float value) { backlash.correction = map(constrain(value, 0, 100), 0, 100, 0, 255); } + void setBacklashCorrection_percent(const float &value) { backlash.correction = map(constrain(value, 0, 100), 0, 100, 0, 255); } #ifdef BACKLASH_SMOOTHING_MM float getBacklashSmoothing_mm() { return backlash.smoothing_mm; } - void setBacklashSmoothing_mm(const float value) { backlash.smoothing_mm = constrain(value, 0, 999); } + void setBacklashSmoothing_mm(const float &value) { backlash.smoothing_mm = constrain(value, 0, 999); } #endif #endif @@ -824,7 +810,7 @@ namespace ExtUI { #if HAS_MESH bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; } float getMeshPoint(const xy_uint8_t &pos) { return Z_VALUES(pos.x, pos.y); } - void setMeshPoint(const xy_uint8_t &pos, const float zoff) { + void setMeshPoint(const xy_uint8_t &pos, const float &zoff) { if (WITHIN(pos.x, 0, GRID_MAX_POINTS_X) && WITHIN(pos.y, 0, GRID_MAX_POINTS_Y)) { Z_VALUES(pos.x, pos.y) = zoff; TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); @@ -838,6 +824,7 @@ namespace ExtUI { #endif #if ENABLED(PRINTCOUNTER) + char* getFailedPrints_str(char buffer[21]) { strcpy(buffer,i16tostr3left(print_job_timer.getStats().totalPrints - print_job_timer.getStats().finishedPrints)); return buffer; } char* getTotalPrints_str(char buffer[21]) { strcpy(buffer,i16tostr3left(print_job_timer.getStats().totalPrints)); return buffer; } char* getFinishedPrints_str(char buffer[21]) { strcpy(buffer,i16tostr3left(print_job_timer.getStats().finishedPrints)); return buffer; } char* getTotalPrintTime_str(char buffer[21]) { return duration_t(print_job_timer.getStats().printTime).toString(buffer); } @@ -856,14 +843,14 @@ namespace ExtUI { float getPIDValues_Ki(const extruder_t tool) { return unscalePID_i(PID_PARAM(Ki, tool)); } float getPIDValues_Kd(const extruder_t tool) { return unscalePID_d(PID_PARAM(Kd, tool)); } - void setPIDValues(const float p, const float i, const float d, extruder_t tool) { + void setPIDValues(const float &p, const float &i, const float &d, extruder_t tool) { thermalManager.temp_hotend[tool].pid.Kp = p; thermalManager.temp_hotend[tool].pid.Ki = scalePID_i(i); thermalManager.temp_hotend[tool].pid.Kd = scalePID_d(d); thermalManager.updatePID(); } - void startPIDTune(const float temp, extruder_t tool) { + void startPIDTune(const float &temp, extruder_t tool) { thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true); } #endif @@ -873,14 +860,14 @@ namespace ExtUI { float getBedPIDValues_Ki() { return unscalePID_i(thermalManager.temp_bed.pid.Ki); } float getBedPIDValues_Kd() { return unscalePID_d(thermalManager.temp_bed.pid.Kd); } - void setBedPIDValues(const float p, const float i, const float d) { + void setBedPIDValues(const float &p, const float &i, const float &d) { thermalManager.temp_bed.pid.Kp = p; thermalManager.temp_bed.pid.Ki = scalePID_i(i); thermalManager.temp_bed.pid.Kd = scalePID_d(d); thermalManager.updatePID(); } - void startBedPIDTune(const float temp) { + void startBedPIDTune(const float &temp) { thermalManager.PID_autotune(temp, H_BED, 4, true); } #endif @@ -900,7 +887,8 @@ namespace ExtUI { return firmware_name; } - void setTargetTemp_celsius(float value, const heater_t heater) { + void setTargetTemp_celsius(const float &inval, const heater_t heater) { + float value = inval; #ifdef TOUCH_UI_LCD_TEMP_SCALING value *= TOUCH_UI_LCD_TEMP_SCALING; #endif @@ -924,7 +912,8 @@ namespace ExtUI { } } - void setTargetTemp_celsius(float value, const extruder_t extruder) { + void setTargetTemp_celsius(const float &inval, const extruder_t extruder) { + float value = inval; #ifdef TOUCH_UI_LCD_TEMP_SCALING value *= TOUCH_UI_LCD_TEMP_SCALING; #endif @@ -935,7 +924,7 @@ namespace ExtUI { #endif } - void setTargetFan_percent(const float value, const fan_t fan) { + void setTargetFan_percent(const float &value, const fan_t fan) { #if HAS_FAN if (fan < FAN_COUNT) thermalManager.set_fan_speed(fan - FAN0, map(constrain(value, 0, 100), 0, 100, 0, 255)); @@ -945,25 +934,27 @@ namespace ExtUI { #endif } - void setFeedrate_percent(const float value) { - feedrate_percentage = constrain(value, 10, 500); + void setFeedrate_percent(const float &value) { feedrate_percentage = constrain(value, 10, 500); } + + void coolDown() { + #if HAS_HOTEND + HOTEND_LOOP() thermalManager.setTargetHotend(0, e); + #endif + TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0)); + TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); } - bool awaitingUserConfirm() { - return wait_for_user; - } + bool awaitingUserConfirm() { return wait_for_user; } - void setUserConfirmed() { - TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); - } + void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); } void printFile(const char *filename) { UNUSED(filename); - IFSD(card.openAndPrintFile(filename), NOOP); + TERN_(SDSUPPORT, card.openAndPrintFile(filename)); } bool isPrintingFromMediaPaused() { - return IFSD(isPrintingFromMedia() && !IS_SD_PRINTING(), false); + return TERN0(SDSUPPORT, isPrintingFromMedia() && !IS_SD_PRINTING()); } bool isPrintingFromMedia() { @@ -978,16 +969,14 @@ namespace ExtUI { } bool isPrinting() { - return (commandsInQueue() || isPrintingFromMedia() || IFSD(IS_SD_PRINTING(), false)) || print_job_timer.isRunning() || print_job_timer.isPaused(); + return (commandsInQueue() || isPrintingFromMedia() || TERN0(SDSUPPORT, IS_SD_PRINTING())) || print_job_timer.isRunning() || print_job_timer.isPaused(); } bool isPrintingPaused() { return isPrinting() && (isPrintingFromMediaPaused() || print_job_timer.isPaused()); } - bool isMediaInserted() { - return IFSD(IS_SD_INSERTED() && card.isMounted(), false); - } + bool isMediaInserted() { return TERN0(SDSUPPORT, IS_SD_INSERTED() && card.isMounted()); } void pausePrint() { ui.pause_print(); } void resumePrint() { ui.resume_print(); } @@ -1022,27 +1011,27 @@ namespace ExtUI { } const char* FileList::filename() { - return IFSD(card.longest_filename(), ""); + return TERN(SDSUPPORT, card.longest_filename(), ""); } const char* FileList::shortFilename() { - return IFSD(card.filename, ""); + return TERN(SDSUPPORT, card.filename, ""); } const char* FileList::longFilename() { - return IFSD(card.longFilename, ""); + return TERN(SDSUPPORT, card.longFilename, ""); } bool FileList::isDir() { - return IFSD(card.flag.filenameIsDir, false); + return TERN0(SDSUPPORT, card.flag.filenameIsDir); } uint16_t FileList::count() { - return IFSD((num_files = (num_files == 0xFFFF ? card.get_num_Files() : num_files)), 0); + return TERN0(SDSUPPORT, (num_files = (num_files == 0xFFFF ? card.get_num_Files() : num_files))); } bool FileList::isAtRootDir() { - return IFSD(card.flag.workDirIsRoot, true); + return TERN1(SDSUPPORT, card.flag.workDirIsRoot); } void FileList::upDir() { diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index a6cfb82b88..701bf9eb54 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -102,11 +102,11 @@ namespace ExtUI { #if HAS_TRINAMIC_CONFIG float getAxisCurrent_mA(const axis_t); float getAxisCurrent_mA(const extruder_t); - void setAxisCurrent_mA(const float, const axis_t); - void setAxisCurrent_mA(const float, const extruder_t); + void setAxisCurrent_mA(const float&, const axis_t); + void setAxisCurrent_mA(const float&, const extruder_t); int getTMCBumpSensitivity(const axis_t); - void setTMCBumpSensitivity(const float, const axis_t); + void setTMCBumpSensitivity(const float&, const axis_t); #endif float getActualTemp_celsius(const heater_t); @@ -150,10 +150,10 @@ namespace ExtUI { #if HAS_MESH bed_mesh_t& getMeshArray(); float getMeshPoint(const xy_uint8_t &pos); - void setMeshPoint(const xy_uint8_t &pos, const float zval); + void setMeshPoint(const xy_uint8_t &pos, const float &zval); void onMeshLevelingStart(); - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval); - inline void onMeshUpdate(const xy_int8_t &pos, const float zval) { onMeshUpdate(pos.x, pos.y, zval); } + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval); + inline void onMeshUpdate(const xy_int8_t &pos, const float &zval) { onMeshUpdate(pos.x, pos.y, zval); } typedef enum : uint8_t { MESH_START, // Prior to start of probe @@ -178,41 +178,42 @@ namespace ExtUI { char* getFilamentUsed_str(char buffer[21]); #endif - void setTargetTemp_celsius(const float, const heater_t); - void setTargetTemp_celsius(const float, const extruder_t); - void setTargetFan_percent(const float, const fan_t); - void setAxisPosition_mm(const float, const axis_t, const feedRate_t=0); - void setAxisPosition_mm(const float, const extruder_t, const feedRate_t=0); - void setAxisSteps_per_mm(const float, const axis_t); - void setAxisSteps_per_mm(const float, const extruder_t); + void setTargetTemp_celsius(const float&, const heater_t); + void setTargetTemp_celsius(const float&, const extruder_t); + void setTargetFan_percent(const float&, const fan_t); + void coolDown(); + void setAxisPosition_mm(const float&, const axis_t, const feedRate_t=0); + void setAxisPosition_mm(const float&, const extruder_t, const feedRate_t=0); + void setAxisSteps_per_mm(const float&, const axis_t); + void setAxisSteps_per_mm(const float&, const extruder_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const axis_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const extruder_t); - void setAxisMaxAcceleration_mm_s2(const float, const axis_t); - void setAxisMaxAcceleration_mm_s2(const float, const extruder_t); + void setAxisMaxAcceleration_mm_s2(const float&, const axis_t); + void setAxisMaxAcceleration_mm_s2(const float&, const extruder_t); void setFeedrate_mm_s(const feedRate_t); void setMinFeedrate_mm_s(const feedRate_t); void setMinTravelFeedrate_mm_s(const feedRate_t); - void setPrintingAcceleration_mm_s2(const float); - void setRetractAcceleration_mm_s2(const float); - void setTravelAcceleration_mm_s2(const float); - void setFeedrate_percent(const float); + void setPrintingAcceleration_mm_s2(const float&); + void setRetractAcceleration_mm_s2(const float&); + void setTravelAcceleration_mm_s2(const float&); + void setFeedrate_percent(const float&); void setFlow_percent(const int16_t, const extruder_t); bool awaitingUserConfirm(); void setUserConfirmed(); #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t); - void setLinearAdvance_mm_mm_s(const float, const extruder_t); + void setLinearAdvance_mm_mm_s(const float&, const extruder_t); #endif #if HAS_JUNCTION_DEVIATION float getJunctionDeviation_mm(); - void setJunctionDeviation_mm(const float); + void setJunctionDeviation_mm(const float&); #else float getAxisMaxJerk_mm_s(const axis_t); float getAxisMaxJerk_mm_s(const extruder_t); - void setAxisMaxJerk_mm_s(const float, const axis_t); - void setAxisMaxJerk_mm_s(const float, const extruder_t); + void setAxisMaxJerk_mm_s(const float&, const axis_t); + void setAxisMaxJerk_mm_s(const float&, const extruder_t); #endif extruder_t getTool(const uint8_t extruder); @@ -220,7 +221,7 @@ namespace ExtUI { void setActiveTool(const extruder_t, bool no_move); #if ENABLED(BABYSTEPPING) - int16_t mmToWholeSteps(const float mm, const axis_t axis); + int16_t mmToWholeSteps(const float& mm, const axis_t axis); bool babystepAxis_steps(const int16_t steps, const axis_t axis); void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles); @@ -228,28 +229,28 @@ namespace ExtUI { #if HAS_HOTEND_OFFSET float getNozzleOffset_mm(const axis_t, const extruder_t); - void setNozzleOffset_mm(const float, const axis_t, const extruder_t); + void setNozzleOffset_mm(const float&, const axis_t, const extruder_t); void normalizeNozzleOffset(const axis_t axis); #endif float getZOffset_mm(); - void setZOffset_mm(const float); + void setZOffset_mm(const float&); #if HAS_BED_PROBE float getProbeOffset_mm(const axis_t); - void setProbeOffset_mm(const float, const axis_t); + void setProbeOffset_mm(const float&, const axis_t); #endif #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t); - void setAxisBacklash_mm(const float, const axis_t); + void setAxisBacklash_mm(const float&, const axis_t); float getBacklashCorrection_percent(); - void setBacklashCorrection_percent(const float); + void setBacklashCorrection_percent(const float&); #ifdef BACKLASH_SMOOTHING_MM float getBacklashSmoothing_mm(); - void setBacklashSmoothing_mm(const float); + void setBacklashSmoothing_mm(const float&); #endif #endif @@ -261,7 +262,7 @@ namespace ExtUI { #if HAS_FILAMENT_RUNOUT_DISTANCE float getFilamentRunoutDistance_mm(); - void setFilamentRunoutDistance_mm(const float); + void setFilamentRunoutDistance_mm(const float&); #endif #endif @@ -271,7 +272,7 @@ namespace ExtUI { #if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) float getCaseLightBrightness_percent(); - void setCaseLightBrightness_percent(const float); + void setCaseLightBrightness_percent(const float&); #endif #endif @@ -279,16 +280,16 @@ namespace ExtUI { float getPIDValues_Kp(const extruder_t); float getPIDValues_Ki(const extruder_t); float getPIDValues_Kd(const extruder_t); - void setPIDValues(const float, const float, const float, extruder_t); - void startPIDTune(const float, extruder_t); + void setPIDValues(const float&, const float&, const float&, extruder_t); + void startPIDTune(const float&, extruder_t); #endif #if ENABLED(PIDTEMPBED) float getBedPIDValues_Kp(); float getBedPIDValues_Ki(); float getBedPIDValues_Kd(); - void setBedPIDValues(const float, const float, const float); - void startBedPIDTune(const float); + void setBedPIDValues(const float&, const float&, const float&); + void startBedPIDTune(const float&); #endif /** diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index f823b79e7a..4399d9a4b6 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -23,8 +23,6 @@ #include "../inc/MarlinConfig.h" -#define IFSD(A,B) TERN(SDSUPPORT,A,B) - #if ENABLED(SDSUPPORT) extern const char M23_STR[], M24_STR[]; From 8532c2b9b6a228f5884951b28612d28233734a07 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Mar 2021 07:14:33 -0600 Subject: [PATCH 040/311] Fix MarlinSerial typo --- Marlin/src/HAL/AVR/MarlinSerial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index ab49e9440a..d34408b165 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -287,7 +287,7 @@ #else static constexpr unsigned int RX_SIZE = 64; static constexpr unsigned int TX_SIZE = 128; - static constexpr bool RX_OVERRUNS = false + static constexpr bool RX_OVERRUNS = false; #endif }; From 71f261726381e07fa92f2aac07e8253779a4f487 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Mar 2021 08:34:22 -0600 Subject: [PATCH 041/311] Pause SD queue early on M25 (#21317) --- Marlin/src/gcode/host/M115.cpp | 3 +++ Marlin/src/gcode/queue.cpp | 8 +++++++- Marlin/src/gcode/sd/M24_M25.cpp | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index cd6fcbaf86..a518e68cf5 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -120,6 +120,9 @@ void GcodeSuite::M115() { // REPEAT (M808) cap_line(PSTR("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS)); + // SD_WRITE (M928, M28, M29) + cap_line(PSTR("SD_WRITE"), ENABLED(SDSUPPORT) && DISABLED(SDCARD_READONLY)); + // AUTOREPORT_SD_STATUS (M27 extension) cap_line(PSTR("AUTOREPORT_SD_STATUS"), ENABLED(AUTO_REPORT_SD_STATUS)); diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index b093184c91..7845b01ad6 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -567,7 +567,6 @@ void GCodeQueue::get_serial_commands() { const bool is_eol = ISEOL(sd_char); if (is_eol || card_eof) { - // Reset stream state, terminate the buffer, and commit a non-empty command if (!is_eol && sd_count) ++sd_count; // End of file with no newline if (!process_line_done(sd_input_state, command.buffer, sd_count)) { @@ -575,6 +574,13 @@ void GCodeQueue::get_serial_commands() { // 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)); + #if DISABLED(PARK_HEAD_ON_PAUSE) + // When M25 is non-blocking it can still suspend SD commands + // Otherwise the M125 handler needs to know SD printing is active + if (command.buffer[0] == 'M' && command.buffer[1] == '2' && command.buffer[2] == '5' && !NUMERIC(command.buffer[3])) + card.pauseSDPrint(); + #endif + // Put the new command into the buffer (no "ok" sent) ring_buffer.commit_command(true); diff --git a/Marlin/src/gcode/sd/M24_M25.cpp b/Marlin/src/gcode/sd/M24_M25.cpp index 8fb529dcaa..1c98791bce 100644 --- a/Marlin/src/gcode/sd/M24_M25.cpp +++ b/Marlin/src/gcode/sd/M24_M25.cpp @@ -87,6 +87,10 @@ void GcodeSuite::M24() { /** * M25: Pause SD Print + * + * With PARK_HEAD_ON_PAUSE: + * Invoke M125 to store the current position and move to the park + * position. M24 will move the head back before resuming the print. */ void GcodeSuite::M25() { From 604c5dedf473cc962e3a0e52eb82bb18b75da1f2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 6 Mar 2021 01:09:13 -0600 Subject: [PATCH 042/311] MarlinSerial cleanup --- Marlin/src/HAL/AVR/MarlinSerial.h | 33 +++++++++++-------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index d34408b165..31bbaaa531 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -252,13 +252,13 @@ template struct MMU2SerialCfg { static constexpr int PORT = serial; + static constexpr unsigned int RX_SIZE = 32; + static constexpr unsigned int TX_SIZE = 32; static constexpr bool XONOFF = false; static constexpr bool EMERGENCYPARSER = false; static constexpr bool DROPPED_RX = false; static constexpr bool RX_FRAMING_ERRORS = false; static constexpr bool MAX_RX_QUEUED = false; - static constexpr unsigned int RX_SIZE = 32; - static constexpr unsigned int TX_SIZE = 32; static constexpr bool RX_OVERRUNS = false; }; @@ -270,28 +270,17 @@ template struct LCDSerialCfg { - static constexpr int PORT = serial; - static constexpr bool XONOFF = false; - static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER); - static constexpr bool DROPPED_RX = false; - static constexpr bool RX_FRAMING_ERRORS = false; - static constexpr bool MAX_RX_QUEUED = false; - #if HAS_DGUS_LCD - static constexpr unsigned int RX_SIZE = DGUS_RX_BUFFER_SIZE; - static constexpr unsigned int TX_SIZE = DGUS_TX_BUFFER_SIZE; - static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS); - #elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) - static constexpr unsigned int RX_SIZE = 64; - static constexpr unsigned int TX_SIZE = 128; - static constexpr bool RX_OVERRUNS = false; - #else - static constexpr unsigned int RX_SIZE = 64; - static constexpr unsigned int TX_SIZE = 128; - static constexpr bool RX_OVERRUNS = false; - #endif + static constexpr int PORT = serial; + static constexpr unsigned int RX_SIZE = TERN(HAS_DGUS_LCD, DGUS_RX_BUFFER_SIZE, 64); + static constexpr unsigned int TX_SIZE = TERN(HAS_DGUS_LCD, DGUS_TX_BUFFER_SIZE, 128); + static constexpr bool XONOFF = false; + static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER); + static constexpr bool DROPPED_RX = false; + static constexpr bool RX_FRAMING_ERRORS = false; + static constexpr bool MAX_RX_QUEUED = false; + static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS); }; - typedef Serial1Class< MarlinSerial< LCDSerialCfg > > MSerialT4; extern MSerialT4 lcdSerial; #endif From 7f1fa0d1ff28cea68f5982eafab816b438c2ccdb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Mar 2021 09:25:41 -0600 Subject: [PATCH 043/311] Add M207/8/9 reporting (#21335) --- Marlin/src/feature/fwretract.cpp | 76 +++++++++++++++++++ Marlin/src/feature/fwretract.h | 9 +++ .../src/gcode/feature/fwretract/M207-M209.cpp | 36 ++------- Marlin/src/gcode/geometry/M206_M428.cpp | 4 +- Marlin/src/module/settings.cpp | 27 +------ 5 files changed, 98 insertions(+), 54 deletions(-) diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 2a71af11d6..4e57ba0150 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -36,6 +36,8 @@ FWRetract fwretract; // Single instance - this calls the constructor #include "../module/planner.h" #include "../module/stepper.h" +#include "../gcode/parser.h" + #if ENABLED(RETRACT_SYNC_MIXING) #include "mixing.h" #endif @@ -198,4 +200,78 @@ void FWRetract::retract(const bool retracting //*/ } +//extern const char SP_Z_STR[]; + +/** + * M207: Set firmware retraction values + * + * S[+units] retract_length + * W[+units] swap_retract_length (multi-extruder) + * F[units/min] retract_feedrate_mm_s + * Z[units] retract_zraise + */ +void FWRetract::M207() { + if (!parser.seen("FSWZ")) return M207_report(); + if (parser.seen('S')) settings.retract_length = parser.value_axis_units(E_AXIS); + if (parser.seen('F')) settings.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); + if (parser.seen('Z')) settings.retract_zraise = parser.value_linear_units(); + if (parser.seen('W')) settings.swap_retract_length = parser.value_axis_units(E_AXIS); +} + +void FWRetract::M207_report(const bool forReplay/*=false*/) { + if (!forReplay) { SERIAL_ECHO_MSG("; Retract: S F Z"); SERIAL_ECHO_START(); } + SERIAL_ECHOLNPAIR_P( + PSTR(" M207 S"), LINEAR_UNIT(settings.retract_length) + , PSTR(" W"), LINEAR_UNIT(settings.swap_retract_length) + , PSTR(" F"), LINEAR_UNIT(MMS_TO_MMM(settings.retract_feedrate_mm_s)) + , SP_Z_STR, LINEAR_UNIT(settings.retract_zraise) + ); +} + +/** + * M208: Set firmware un-retraction values + * + * S[+units] retract_recover_extra (in addition to M207 S*) + * W[+units] swap_retract_recover_extra (multi-extruder) + * F[units/min] retract_recover_feedrate_mm_s + * R[units/min] swap_retract_recover_feedrate_mm_s + */ +void FWRetract::M208() { + if (!parser.seen("FSRW")) return M208_report(); + if (parser.seen('S')) settings.retract_recover_extra = parser.value_axis_units(E_AXIS); + if (parser.seen('F')) settings.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); + if (parser.seen('R')) settings.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); + if (parser.seen('W')) settings.swap_retract_recover_extra = parser.value_axis_units(E_AXIS); +} + +void FWRetract::M208_report(const bool forReplay/*=false*/) { + if (!forReplay) { SERIAL_ECHO_MSG("; Recover: S F"); SERIAL_ECHO_START(); } + SERIAL_ECHOLNPAIR( + " M208 S", LINEAR_UNIT(settings.retract_recover_extra) + , " W", LINEAR_UNIT(settings.swap_retract_recover_extra) + , " F", LINEAR_UNIT(MMS_TO_MMM(settings.retract_recover_feedrate_mm_s)) + ); +} + +#if ENABLED(FWRETRACT_AUTORETRACT) + + /** + * M209: Enable automatic retract (M209 S1) + * For slicers that don't support G10/11, reversed extrude-only + * moves will be classified as retraction. + */ + void FWRetract::M209() { + if (!parser.seen('S')) return M209_report(); + if (MIN_AUTORETRACT <= MAX_AUTORETRACT) + enable_autoretract(parser.value_bool()); + } + + void FWRetract::M209_report(const bool forReplay/*=false*/) { + if (!forReplay) { SERIAL_ECHO_MSG("; Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); SERIAL_ECHO_START(); } + SERIAL_ECHOLNPAIR(" M209 S", autoretract_enabled); + } + +#endif // FWRETRACT_AUTORETRACT + + #endif // FWRETRACT diff --git a/Marlin/src/feature/fwretract.h b/Marlin/src/feature/fwretract.h index 134851965d..4fa64ad83b 100644 --- a/Marlin/src/feature/fwretract.h +++ b/Marlin/src/feature/fwretract.h @@ -79,6 +79,15 @@ public: , bool swapping = false #endif ); + + static void M207(); + static void M207_report(const bool forReplay=false); + static void M208(); + static void M208_report(const bool forReplay=false); + #if ENABLED(FWRETRACT_AUTORETRACT) + static void M209(); + static void M209_report(const bool forReplay=false); + #endif }; extern FWRetract fwretract; diff --git a/Marlin/src/gcode/feature/fwretract/M207-M209.cpp b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp index 538f16cde6..5793d73f94 100644 --- a/Marlin/src/gcode/feature/fwretract/M207-M209.cpp +++ b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp @@ -29,46 +29,24 @@ /** * M207: Set firmware retraction values - * - * S[+units] retract_length - * W[+units] swap_retract_length (multi-extruder) - * F[units/min] retract_feedrate_mm_s - * Z[units] retract_zraise */ -void GcodeSuite::M207() { - if (parser.seen('S')) fwretract.settings.retract_length = parser.value_axis_units(E_AXIS); - if (parser.seen('F')) fwretract.settings.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); - if (parser.seen('Z')) fwretract.settings.retract_zraise = parser.value_linear_units(); - if (parser.seen('W')) fwretract.settings.swap_retract_length = parser.value_axis_units(E_AXIS); -} +void GcodeSuite::M207() { fwretract.M207(); } /** * M208: Set firmware un-retraction values - * - * S[+units] retract_recover_extra (in addition to M207 S*) - * W[+units] swap_retract_recover_extra (multi-extruder) - * F[units/min] retract_recover_feedrate_mm_s - * R[units/min] swap_retract_recover_feedrate_mm_s */ -void GcodeSuite::M208() { - if (parser.seen('S')) fwretract.settings.retract_recover_extra = parser.value_axis_units(E_AXIS); - if (parser.seen('F')) fwretract.settings.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); - if (parser.seen('R')) fwretract.settings.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS)); - if (parser.seen('W')) fwretract.settings.swap_retract_recover_extra = parser.value_axis_units(E_AXIS); -} +void GcodeSuite::M208() { fwretract.M208(); } #if ENABLED(FWRETRACT_AUTORETRACT) /** * M209: Enable automatic retract (M209 S1) - * For slicers that don't support G10/11, reversed extrude-only - * moves will be classified as retraction. + * + * For slicers that don't support G10/11, reversed + * extruder-only moves can be classified as retraction. */ - void GcodeSuite::M209() { - if (MIN_AUTORETRACT <= MAX_AUTORETRACT && parser.seen('S')) - fwretract.enable_autoretract(parser.value_bool()); - } + void GcodeSuite::M209() { fwretract.M209(); } -#endif // FWRETRACT_AUTORETRACT +#endif #endif // FWRETRACT diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 2a2cdb16ff..ac2420fcc3 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -30,7 +30,7 @@ #include "../../libs/buzzer.h" #include "../../MarlinCore.h" -void m206_report() { +void M206_report() { SERIAL_ECHOLNPAIR_P(PSTR("M206 X"), home_offset.x, SP_Y_STR, home_offset.y, SP_Z_STR, home_offset.z); } @@ -52,7 +52,7 @@ void GcodeSuite::M206() { #endif if (!parser.seen("XYZ")) - m206_report(); + M206_report(); else report_current_position(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index c82ed0eb8f..d38ad51934 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3466,29 +3466,10 @@ void MarlinSettings::reset() { #endif #if ENABLED(FWRETRACT) - - CONFIG_ECHO_HEADING("Retract: S F Z"); - CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_P( - PSTR(" M207 S"), LINEAR_UNIT(fwretract.settings.retract_length) - , PSTR(" W"), LINEAR_UNIT(fwretract.settings.swap_retract_length) - , PSTR(" F"), LINEAR_UNIT(MMS_TO_MMM(fwretract.settings.retract_feedrate_mm_s)) - , SP_Z_STR, LINEAR_UNIT(fwretract.settings.retract_zraise) - ); - - CONFIG_ECHO_HEADING("Recover: S F"); - 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)) - ); - - #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", fwretract.autoretract_enabled); - #endif - - #endif // FWRETRACT + fwretract.M207_report(forReplay); + fwretract.M208_report(forReplay); + TERN_(FWRETRACT_AUTORETRACT, fwretract.M209_report(forReplay)); + #endif /** * Probe Offset From 3107d8a0f4e71bc7853d78d026912582cf185adc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 12 Mar 2021 07:34:44 -0600 Subject: [PATCH 044/311] Tweak opt_set, opt_enable --- buildroot/bin/opt_enable | 4 ++-- buildroot/bin/opt_set | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildroot/bin/opt_enable b/buildroot/bin/opt_enable index fdcb5dae2d..9161299b6e 100755 --- a/buildroot/bin/opt_enable +++ b/buildroot/bin/opt_enable @@ -7,7 +7,7 @@ SED=$(which gsed || which sed) for opt in "$@" ; do # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648 - eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*[[:blank:]]*\(#define \b${opt}\b\)/{s//\2/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || - eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*[[:blank:]]*\(#define \b${opt}\b\)/{s//\2/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || + eval "${SED} -i '/^\([[:blank:]]*\/\/\)*[[:blank:]]*\(#define \b${opt}\b\)/{s//\2/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || + eval "${SED} -i '/^\([[:blank:]]*\/\/\)*[[:blank:]]*\(#define \b${opt}\b\)/{s//\2/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || (echo "ERROR: opt_enable Can't find ${opt}" >&2 && exit 9) done diff --git a/buildroot/bin/opt_set b/buildroot/bin/opt_set index 2a7a676cdc..2e63790c69 100755 --- a/buildroot/bin/opt_set +++ b/buildroot/bin/opt_set @@ -8,8 +8,8 @@ SED=$(which gsed || which sed) ARGC=$# while [[ $# > 1 ]]; do # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648 - eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || - eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || + eval "${SED} -i '/^\([[:blank:]]*\)\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\1\3\4 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || + eval "${SED} -i '/^\([[:blank:]]*\)\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\1\3\4 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || eval "echo '#define ${1} ${2}' >>Marlin/Configuration.h" || (echo "ERROR: opt_set Can't set or add ${1}" >&2 && exit 9) shift 2 From 11343bb0ea8d41d5e4a26c30e2f6e30876b079f6 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 13 Mar 2021 00:16:55 +0000 Subject: [PATCH 045/311] [cron] Bump distribution date (2021-03-13) --- 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 c9760f3f69..96aa83bc6f 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-03-12" + #define STRING_DISTRIBUTION_DATE "2021-03-13" #endif /** From da84b59ee4bfda6b878ec55b9684722a1946a14d Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sat, 13 Mar 2021 08:01:02 -0300 Subject: [PATCH 046/311] No extra build folder for st/jlink upload (#21341) --- buildroot/share/PlatformIO/scripts/common-cxxflags.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/common-cxxflags.py b/buildroot/share/PlatformIO/scripts/common-cxxflags.py index 5c2bde7700..36704af283 100644 --- a/buildroot/share/PlatformIO/scripts/common-cxxflags.py +++ b/buildroot/share/PlatformIO/scripts/common-cxxflags.py @@ -22,10 +22,9 @@ def add_cpu_freq(): # # It will separe release and debug build folders. # It useful when we need keep two live versions: one debug, for debugging, -# other release, for flashing. +# other release, for flashing (when upload is not done automatically by jlink/stlink). # Without this, PIO will recompile everything twice for any small change. -# -if env.GetBuildType() == "debug": +if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink']: env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug' # On some platform, F_CPU is a runtime variable. Since it's used to convert from ns From 911cd1a6d3883716986e7f3cf92fa4266de20d57 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sat, 13 Mar 2021 08:37:49 -0500 Subject: [PATCH 047/311] Custom menu items confirm option (#21338) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 8 +++++++- Marlin/src/lcd/menu/menu_custom.cpp | 15 ++++++++++++++- Marlin/src/lcd/menu/menu_main.cpp | 12 +++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 9ab3e2d044..fb1f79b230 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3455,22 +3455,28 @@ //#define CUSTOM_USER_MENU_TITLE "Custom Commands" #define USER_SCRIPT_DONE "M117 User Script Done" #define USER_SCRIPT_AUDIBLE_FEEDBACK - //#define USER_SCRIPT_RETURN // Return to status screen after a script + //#define USER_SCRIPT_RETURN // Return to status screen after a script + #define CUSTOM_MENU_ONLY_IDLE // Only show custom menu when the machine is idle #define USER_DESC_1 "Home & UBL Info" #define USER_GCODE_1 "G28\nG29W" + //#define USER_CONFIRM_1 // Show a confirmation dialog before this action #define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL #define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) + //#define USER_CONFIRM_2 #define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL #define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) + //#define USER_CONFIRM_3 #define USER_DESC_4 "Heat Bed/Home/Level" #define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29" + //#define USER_CONFIRM_4 #define USER_DESC_5 "Home & Info" #define USER_GCODE_5 "G28\nM503" + //#define USER_CONFIRM_5 #endif /** diff --git a/Marlin/src/lcd/menu/menu_custom.cpp b/Marlin/src/lcd/menu/menu_custom.cpp index f3f946883f..cc1a8a6e80 100644 --- a/Marlin/src/lcd/menu/menu_custom.cpp +++ b/Marlin/src/lcd/menu/menu_custom.cpp @@ -46,7 +46,20 @@ void _lcd_user_gcode(PGM_P const cmd) { void menu_user() { START_MENU(); BACK_ITEM(MSG_MAIN); - #define USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); }); + + #define GCODE_LAMBDA(N) []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); } + #define _USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), GCODE_LAMBDA(N)); + #define _USER_ITEM_CONFIRM(N) \ + SUBMENU_P(PSTR(USER_DESC_##N), []{ \ + MenuItem_confirm::confirm_screen( \ + GCODE_LAMBDA(N), \ + ui.goto_previous_screen, \ + PSTR(USER_DESC_##N "?") \ + ); \ + }) + + #define USER_ITEM(N) do{ if (ENABLED(USER_CONFIRM_##N)) _USER_ITEM_CONFIRM(N); else _USER_ITEM(N); }while(0) + #if HAS_USER_ITEM(1) USER_ITEM(1); #endif diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 1e864e35be..d19e236a84 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -211,11 +211,13 @@ void menu_main() { SUBMENU(MSG_CONFIGURATION, menu_configuration); #if ENABLED(CUSTOM_USER_MENUS) - #ifdef CUSTOM_USER_MENU_TITLE - SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user); - #else - SUBMENU(MSG_USER_MENU, menu_user); - #endif + if (TERN1(CUSTOM_MENU_ONLY_IDLE, !busy)) { + #ifdef CUSTOM_USER_MENU_TITLE + SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user); + #else + SUBMENU(MSG_USER_MENU, menu_user); + #endif + } #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) From 36d3b6aa95b454a7463651e12494b5b33a8b10bf Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 14 Mar 2021 00:13:50 +0000 Subject: [PATCH 048/311] [cron] Bump distribution date (2021-03-14) --- 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 96aa83bc6f..0f327c561b 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-03-13" + #define STRING_DISTRIBUTION_DATE "2021-03-14" #endif /** From b9b9a3115a064acefae1386fcffd6c19a1aa6ead Mon Sep 17 00:00:00 2001 From: XDA-Bam <1209896+XDA-Bam@users.noreply.github.com> Date: Sun, 14 Mar 2021 17:42:25 +0100 Subject: [PATCH 049/311] Update display timing for SKR Pro (#21346) --- Marlin/src/pins/sanguino/pins_MELZI_V2.h | 2 +- Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/sanguino/pins_MELZI_V2.h b/Marlin/src/pins/sanguino/pins_MELZI_V2.h index 275498d558..e0369923c7 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_V2.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_V2.h @@ -29,7 +29,7 @@ #define BOARD_ST7920_DELAY_1 DELAY_NS(0) #endif #ifndef BOARD_ST7920_DELAY_2 - #define BOARD_ST7920_DELAY_2 DELAY_NS(188) + #define BOARD_ST7920_DELAY_2 DELAY_NS(400) #endif #ifndef BOARD_ST7920_DELAY_3 #define BOARD_ST7920_DELAY_3 DELAY_NS(0) 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 863429f2a2..01ba3d72f6 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -441,10 +441,10 @@ // Alter timing for graphical display #if HAS_MARLINUI_U8GLIB #ifndef BOARD_ST7920_DELAY_1 - #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) #endif #ifndef BOARD_ST7920_DELAY_2 - #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #define BOARD_ST7920_DELAY_2 DELAY_NS(90) #endif #ifndef BOARD_ST7920_DELAY_3 #define BOARD_ST7920_DELAY_3 DELAY_NS(600) From cc3e878f90b38bcd9116c1b4e8ff31a4209299e9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 14 Mar 2021 11:43:20 -0500 Subject: [PATCH 050/311] Fix small wired EEPROM (#21337) Co-Authored-By: jafal99 <26922965+jafal99@users.noreply.github.com> --- Marlin/src/HAL/shared/eeprom_if_i2c.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp index da70af2772..299bc34c49 100644 --- a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp +++ b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp @@ -51,6 +51,18 @@ void eeprom_init() { static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRESS); +void _beginTransmission(const uint16_t memoryAddress) { + if (MARLIN_EEPROM_SIZE > 0x4000) { // Use two-byte addressing for EEPROMs >16kb + Wire.beginTransmission(eeprom_device_address); + Wire.write(memoryAddress >> 8); // Address High Byte + } + else { + const uint8_t addr = eeprom_device_address | byte((memoryAddress >> 8) & 0x07); + Wire.beginTransmission(addr); + } + Wire.write(memoryAddress & 0xFF); // Address Low Byte (or only byte for chips <= 16Kb like 24C02/04/08/16) +} + // ------------------------ // Public functions // ------------------------ @@ -58,9 +70,7 @@ static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRE void eeprom_write_byte(uint8_t *pos, unsigned char value) { const unsigned eeprom_address = (unsigned)pos; - Wire.beginTransmission(eeprom_device_address); - Wire.write(int(eeprom_address >> 8)); // MSB - Wire.write(int(eeprom_address & 0xFF)); // LSB + _beginTransmission(eeprom_address); Wire.write(value); Wire.endTransmission(); @@ -72,11 +82,12 @@ void eeprom_write_byte(uint8_t *pos, unsigned char value) { uint8_t eeprom_read_byte(uint8_t *pos) { const unsigned eeprom_address = (unsigned)pos; - Wire.beginTransmission(eeprom_device_address); - Wire.write(int(eeprom_address >> 8)); // MSB - Wire.write(int(eeprom_address & 0xFF)); // LSB + _beginTransmission(eeprom_address); Wire.endTransmission(); - Wire.requestFrom(eeprom_device_address, (byte)1); + + // For EEPROMs <=16Kb the lower address bits are used for 2Kb page address + const int addr = eeprom_device_address | (MARLIN_EEPROM_SIZE <= 0x4000 ? byte((eeprom_address >> 8) & 0x07) : byte(0)); + Wire.requestFrom(addr, byte(1)); return Wire.available() ? Wire.read() : 0xFF; } From d787cd307680c5c4f155ad4643c1137db56bb006 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Sun, 14 Mar 2021 18:11:11 +0100 Subject: [PATCH 051/311] Fix build with Meatpack only on 2nd port (#21336) Co-authored-by: Scott Lahteine --- Marlin/src/HAL/HAL.h | 6 ----- Marlin/src/feature/meatpack.cpp | 1 - Marlin/src/inc/Conditionals_LCD.h | 26 ++++++++++++++----- Marlin/src/inc/Conditionals_adv.h | 7 +++++ Marlin/src/inc/Conditionals_post.h | 13 ---------- .../PlatformIO/scripts/common-dependencies.h | 2 -- 6 files changed, 26 insertions(+), 29 deletions(-) diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index 9eefda8fb1..0cd836af2b 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -29,12 +29,6 @@ #include HAL_PATH(.,HAL.h) -#ifdef SERIAL_PORT_2 - #define NUM_SERIAL 2 -#else - #define NUM_SERIAL 1 -#endif - #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) #ifndef I2C_ADDRESS diff --git a/Marlin/src/feature/meatpack.cpp b/Marlin/src/feature/meatpack.cpp index 178831c9bb..44567ac482 100644 --- a/Marlin/src/feature/meatpack.cpp +++ b/Marlin/src/feature/meatpack.cpp @@ -42,7 +42,6 @@ #if HAS_MEATPACK #include "meatpack.h" -MeatPack meatpack; #define MeatPack_ProtocolVersion "PV01" //#define MP_DEBUG diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e5f7441e77..b9b86a7bf3 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -654,13 +654,6 @@ #define UNUSED_E(E) UNUSED(E) #endif -#if ENABLED(DWIN_CREALITY_LCD) - #define SERIAL_CATCHALL 0 - #ifndef LCD_SERIAL_PORT - #define LCD_SERIAL_PORT 3 // Creality 4.x board - #endif -#endif - /** * The BLTouch Probe emulates a servo probe * and uses "special" angles for its state. @@ -950,6 +943,18 @@ #define HAS_CLASSIC_E_JERK 1 #endif +// +// Serial Port Info +// +#ifdef SERIAL_PORT_2 + #define NUM_SERIAL 2 + #define HAS_MULTI_SERIAL 1 +#elif defined(SERIAL_PORT) + #define NUM_SERIAL 1 +#else + #define NUM_SERIAL 0 + #undef BAUD_RATE_GCODE +#endif #if SERIAL_PORT == -1 || SERIAL_PORT_2 == -1 #define HAS_USB_SERIAL 1 #endif @@ -957,6 +962,13 @@ #define HAS_ETHERNET 1 #endif +#if ENABLED(DWIN_CREALITY_LCD) + #define SERIAL_CATCHALL 0 + #ifndef LCD_SERIAL_PORT + #define LCD_SERIAL_PORT 3 // Creality 4.x board + #endif +#endif + // Fallback Stepper Driver types that don't depend on Configuration_adv.h #ifndef X_DRIVER_TYPE #define X_DRIVER_TYPE A4988 diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 00b9b1faef..490766bd7a 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -542,3 +542,10 @@ #else #define HAS_USER_ITEM(N) 0 #endif + +#if !HAS_MULTI_SERIAL + #undef MEATPACK_ON_SERIAL_PORT_2 +#endif +#if EITHER(MEATPACK_ON_SERIAL_PORT_1, MEATPACK_ON_SERIAL_PORT_2) + #define HAS_MEATPACK 1 +#endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index a6567e9714..fb06a7a3f3 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2906,16 +2906,3 @@ #if BUTTONS_EXIST(EN1, EN2, ENC) #define HAS_ROTARY_ENCODER 1 #endif - -#if !NUM_SERIAL - #undef BAUD_RATE_GCODE -#elif NUM_SERIAL > 1 - #define HAS_MULTI_SERIAL 1 -#endif - -#if !HAS_MULTI_SERIAL - #undef MEATPACK_ON_SERIAL_PORT_2 -#endif -#if EITHER(MEATPACK_ON_SERIAL_PORT_1, MEATPACK_ON_SERIAL_PORT_2) - #define HAS_MEATPACK 1 -#endif diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index ed2f46abae..03fae56fdb 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -26,8 +26,6 @@ * Used by common-dependencies.py */ -#define NUM_SERIAL 1 // Normally provided by HAL/HAL.h - #include "../../../../Marlin/src/inc/MarlinConfig.h" // From 4f6910c131cda52b187f2caa42c9cf2ce0885a5d Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sun, 14 Mar 2021 14:14:09 -0300 Subject: [PATCH 052/311] Script to generate Marlin TFT Images (#21340) --- buildroot/share/scripts/gen-tft-image.py | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 buildroot/share/scripts/gen-tft-image.py diff --git a/buildroot/share/scripts/gen-tft-image.py b/buildroot/share/scripts/gen-tft-image.py new file mode 100644 index 0000000000..d89245fea4 --- /dev/null +++ b/buildroot/share/scripts/gen-tft-image.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# +# Marlin 3D Printer Firmware +# Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] +# +# Based on Sprinter and grbl. +# Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# Generate Marlin TFT Images from bitmaps/PNG/JPG + +import sys,re,struct +from PIL import Image,ImageDraw + +def image2bin(image, output_file): + if output_file.endswith(('.c', '.cpp')): + f = open(output_file, 'wt') + is_cpp = True + f.write("const uint16_t image[%d] = {\n" % (image.size[1] * image.size[0])) + else: + f = open(output_file, 'wb') + is_cpp = False + pixs = image.load() + for y in range(image.size[1]): + for x in range(image.size[0]): + R = pixs[x, y][0] >> 3 + G = pixs[x, y][1] >> 2 + B = pixs[x, y][2] >> 3 + rgb = (R << 11) | (G << 5) | B + if is_cpp: + strHex = '0x{0:04X}, '.format(rgb) + f.write(strHex) + else: + f.write(struct.pack("B", (rgb & 0xFF))) + f.write(struct.pack("B", (rgb >> 8) & 0xFF)) + if is_cpp: + f.write("\n") + if is_cpp: + f.write("};\n") + f.close() + +if len(sys.argv) <= 2: + print("Utility to export a image in Marlin TFT friendly format.") + print("It will dump a raw bin RGB565 image or create a CPP file with an array of 16 bit image pixels.") + print("Usage: gen-tft-image.py INPUT_IMAGE.(png|bmp|jpg) OUTPUT_FILE.(cpp|bin)") + print("Author: rhapsodyv") + exit(1) + +output_img = sys.argv[2] +img = Image.open(sys.argv[1]) +image2bin(img, output_img) From ae8be31247ef0731036935d25b4d571a7f1733a8 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 15 Mar 2021 00:13:36 +0000 Subject: [PATCH 053/311] [cron] Bump distribution date (2021-03-15) --- 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 0f327c561b..fb6f756a84 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-03-14" + #define STRING_DISTRIBUTION_DATE "2021-03-15" #endif /** From c07f99d5e406ef82376ad3baeb246d3e78c9a7e3 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Mon, 15 Mar 2021 02:23:41 +0100 Subject: [PATCH 054/311] Teensy USB / serial followup (#21316) --- Marlin/src/HAL/TEENSY31_32/HAL.cpp | 6 +++++- Marlin/src/HAL/TEENSY31_32/HAL.h | 10 ++++++++-- Marlin/src/HAL/TEENSY35_36/HAL.cpp | 2 +- Marlin/src/HAL/TEENSY35_36/HAL.h | 2 +- Marlin/src/HAL/TEENSY40_41/HAL.cpp | 6 +++++- Marlin/src/HAL/TEENSY40_41/HAL.h | 9 +++++++-- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index 8a13f1d884..7b7202547a 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -31,7 +31,11 @@ #include -DefaultSerial1 MSerial0(false); +#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) +#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) +#if WITHIN(SERIAL_PORT, 0, 3) + IMPLEMENT_SERIAL(SERIAL_PORT); +#endif USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result; diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index cd1c334899..bbfc50a36f 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -51,8 +51,13 @@ #endif #include "../../core/serial_hook.h" -typedef Serial1Class DefaultSerial1; -extern DefaultSerial1 MSerial0; + +#define Serial0 Serial +#define _DECLARE_SERIAL(X) \ + typedef ForwardSerial1Class DefaultSerial##X; \ + extern DefaultSerial##X MSerial##X +#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X) + typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; @@ -62,6 +67,7 @@ extern USBSerialType USBSerial; #if SERIAL_PORT == -1 #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) + DECLARE_SERIAL(SERIAL_PORT); #define MYSERIAL1 MSERIAL(SERIAL_PORT) #endif diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index 8640bdfe00..5d808cd19b 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,7 +31,7 @@ #include -#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false) +#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) IMPLEMENT_SERIAL(SERIAL_PORT); diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index e769454b3f..5b120d852d 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -57,7 +57,7 @@ #define Serial0 Serial #define _DECLARE_SERIAL(X) \ - typedef Serial1Class DefaultSerial##X; \ + typedef ForwardSerial1Class DefaultSerial##X; \ extern DefaultSerial##X MSerial##X #define DECLARE_SERIAL(X) _DECLARE_SERIAL(X) diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index 0fde9da537..1eab3d837e 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -32,7 +32,11 @@ #include -DefaultSerial1 MSerial0(false); +#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) +#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) +#if WITHIN(SERIAL_PORT, 0, 3) + IMPLEMENT_SERIAL(SERIAL_PORT); +#endif USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result, HAL_adc_select; diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 03a12e1b92..ce985dadb9 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -56,8 +56,12 @@ #endif #include "../../core/serial_hook.h" -typedef Serial1Class DefaultSerial1; -extern DefaultSerial1 MSerial0; +#define Serial0 Serial +#define _DECLARE_SERIAL(X) \ + typedef ForwardSerial1Class DefaultSerial##X; \ + extern DefaultSerial##X MSerial##X +#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X) + typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; @@ -67,6 +71,7 @@ extern USBSerialType USBSerial; #if SERIAL_PORT == -1 #define MYSERIAL1 SerialUSB #elif WITHIN(SERIAL_PORT, 0, 8) + DECLARE_SERIAL(SERIAL_PORT); #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration." From 1a23ffd7768483914485f9ea569c5813613eef92 Mon Sep 17 00:00:00 2001 From: "K.3D" <40525619+KA8888@users.noreply.github.com> Date: Mon, 15 Mar 2021 17:02:40 +0100 Subject: [PATCH 055/311] KRATOS32 / K.32 board and LCD controllers (#21334) --- Marlin/Configuration.h | 16 ++- Marlin/src/core/boards.h | 1 + Marlin/src/inc/Conditionals_LCD.h | 8 +- Marlin/src/inc/SanityCheck.h | 4 +- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 2 +- Marlin/src/lcd/dogm/marlinui_DOGM.h | 5 +- Marlin/src/pins/pins.h | 2 + Marlin/src/pins/sam/pins_KRATOS32.h | 179 ++++++++++++++++++++++++++ 8 files changed, 208 insertions(+), 9 deletions(-) create mode 100644 Marlin/src/pins/sam/pins_KRATOS32.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 1098351d4e..726ff1ec0b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2181,6 +2181,11 @@ // //#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +// +// K.3D Full Graphic Smart Controller +// +//#define K3D_FULL_GRAPHIC_SMART_CONTROLLER + // // ReprapWorld Graphical LCD // https://reprapworld.com/?products_details&products_id/1218 @@ -2318,7 +2323,7 @@ //#define OLED_PANEL_TINYBOY2 // -// MKS OLED 1.3" 128×64 FULL GRAPHICS CONTROLLER +// MKS OLED 1.3" 128×64 Full Graphics Controller // https://reprap.org/wiki/MKS_12864OLED // // Tiny, but very sharp OLED display @@ -2327,7 +2332,7 @@ //#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller // -// Zonestar OLED 128×64 FULL GRAPHICS CONTROLLER +// Zonestar OLED 128×64 Full Graphics Controller // //#define ZONESTAR_12864LCD // Graphical (DOGM) with ST7920 controller //#define ZONESTAR_12864OLED // 1.3" OLED with SH1106 controller (default) @@ -2344,10 +2349,15 @@ //#define OVERLORD_OLED // -// FYSETC OLED 2.42" 128×64 FULL GRAPHICS CONTROLLER with WS2812 RGB +// FYSETC OLED 2.42" 128×64 Full Graphics Controller with WS2812 RGB // Where to find : https://www.aliexpress.com/item/4000345255731.html //#define FYSETC_242_OLED_12864 // Uses the SSD1309 controller +// +// K.3D SSD1309 OLED 2.42" 128×64 Full Graphics Controller +// +//#define K3D_242_OLED_CONTROLLER // Software SPI + //============================================================================= //========================== Extensible UI Displays =========================== //============================================================================= diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index cfde52ddb9..f0d967c763 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -279,6 +279,7 @@ #define BOARD_ARCHIM2 3024 // UltiMachine Archim2 (with TMC2130 drivers) #define BOARD_ALLIGATOR 3025 // Alligator Board R2 #define BOARD_CNCONTROLS_15D 3026 // Cartesio CN Controls V15 on DUE +#define BOARD_KRATOS32 3027 // K.3D Kratos32 (Arduino Due Shield) // // SAM3X8C ARM Cortex M3 diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index b9b86a7bf3..fc7eec84ee 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -229,14 +229,18 @@ #define BOARD_ST7920_DELAY_2 DELAY_NS(125) #define BOARD_ST7920_DELAY_3 DELAY_NS(125) -#elif ANY(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, ANET_FULL_GRAPHICS_LCD, ANET_FULL_GRAPHICS_LCD_ALT_WIRING, BQ_LCD_SMART_CONTROLLER) +#elif ANY(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, ANET_FULL_GRAPHICS_LCD, ANET_FULL_GRAPHICS_LCD_ALT_WIRING, BQ_LCD_SMART_CONTROLLER, K3D_FULL_GRAPHIC_SMART_CONTROLLER) #define IS_RRD_FG_SC 1 #elif ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) - // RepRapDiscount LCD or Graphical LCD with rotary click encoder + #define IS_RRD_SC 1 // RepRapDiscount LCD or Graphical LCD with rotary click encoder + +#elif ENABLED(K3D_242_OLED_CONTROLLER) + #define IS_RRD_SC 1 + #define U8GLIB_SSD1309 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 6802bff1dd..5302aac208 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2372,7 +2372,9 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal + ENABLED(ULTIPANEL) \ + ENABLED(ULTRA_LCD) \ + ENABLED(YHCB2004) \ - + ENABLED(ZONESTAR_LCD) + + ENABLED(ZONESTAR_LCD) \ + + ENABLED(K3D_FULL_GRAPHIC_SMART_CONTROLLER) \ + + ENABLED(K3D_242_OLED_CONTROLLER) #error "Please select only one LCD controller option." #endif diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index d2b1ce7740..7334ba5f26 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -256,7 +256,7 @@ void MarlinUI::init_lcd() { OUT_WRITE(LCD_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); // Illuminate after reset or right away #endif - #if ANY(MKS_12864OLED, MKS_12864OLED_SSD1306, FYSETC_242_OLED_12864, ZONESTAR_12864OLED) + #if ANY(MKS_12864OLED, MKS_12864OLED_SSD1306, FYSETC_242_OLED_12864, ZONESTAR_12864OLED, K3D_242_OLED_CONTROLLER) SET_OUTPUT(LCD_PINS_DC); #ifndef LCD_RESET_PIN #define LCD_RESET_PIN LCD_PINS_RS diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.h b/Marlin/src/lcd/dogm/marlinui_DOGM.h index e5862d670f..e3ceb63f96 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.h +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.h @@ -123,9 +123,10 @@ #define U8G_CLASS U8GLIB_SSD1306_128X64 // 8 stripes #endif -#elif ENABLED(FYSETC_242_OLED_12864) +#elif EITHER(FYSETC_242_OLED_12864, K3D_242_OLED_CONTROLLER) - // FYSETC OLED 2.42" 128 × 64 FULL GRAPHICS CONTROLLER + // FYSETC OLED 2.42" 128 × 64 Full Graphics Controller + // or K3D OLED 2.42" 128 × 64 Full Graphics Controller #define FORCE_SOFT_SPI // SW-SPI diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index b8cf695fb5..58a87f2313 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -447,6 +447,8 @@ #include "sam/pins_PRINTRBOARD_G2.h" // SAM3X8C env:DUE_USB #elif MB(CNCONTROLS_15D) #include "sam/pins_CNCONTROLS_15D.h" // SAM3X8E env:DUE env:DUE_USB +#elif MB(KRATOS32) + #include "sam/pins_KRATOS32.h" // SAM3X8E env:DUE env:DUE_USB // // STM32 ARM Cortex-M0 diff --git a/Marlin/src/pins/sam/pins_KRATOS32.h b/Marlin/src/pins/sam/pins_KRATOS32.h new file mode 100644 index 0000000000..f429e56347 --- /dev/null +++ b/Marlin/src/pins/sam/pins_KRATOS32.h @@ -0,0 +1,179 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * KRATOS32 + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "K.3D KRATOS32" + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1F400 // 16KB +#endif + +// +// Servos +// +#define SERVO0_PIN 6 +#define SERVO1_PIN 5 +#define SERVO2_PIN 39 +#define SERVO3_PIN 40 // CAMERA_PIN (extended to the top of the LCD module) +#define SERVO4_PIN 45 // FIL_RUNOUT_PIN + +// +// Limit Switches +// +#define X_MIN_PIN 28 +#define X_MAX_PIN 34 +#define Y_MIN_PIN 30 +#define Y_MAX_PIN 36 +#define Z_MIN_PIN 32 +#define Z_MAX_PIN 38 + +// +// Steppers +// +#define X_STEP_PIN 24 +#define X_DIR_PIN 23 +#define X_ENABLE_PIN 26 +#ifndef X_CS_PIN + #define X_CS_PIN 25 +#endif + +#define Y_STEP_PIN 17 +#define Y_DIR_PIN 16 +#define Y_ENABLE_PIN 22 +#ifndef Y_CS_PIN + #define Y_CS_PIN 27 +#endif + +#define Z_STEP_PIN 2 +#define Z_DIR_PIN 3 +#define Z_ENABLE_PIN 15 +#ifndef Z_CS_PIN + #define Z_CS_PIN 29 +#endif + +#define E0_STEP_PIN 61 +#define E0_DIR_PIN 60 +#define E0_ENABLE_PIN 62 +#ifndef E0_CS_PIN + #define E0_CS_PIN 31 +#endif + +#define E1_STEP_PIN 64 +#define E1_DIR_PIN 63 +#define E1_ENABLE_PIN 65 +#ifndef E1_CS_PIN + #define E1_CS_PIN 37 +#endif + +#define E2_STEP_PIN 68 +#define E2_DIR_PIN 67 +#define E2_ENABLE_PIN 69 +#ifndef E2_CS_PIN + #define E2_CS_PIN 35 +#endif + +#define E3_STEP_PIN 51 +#define E3_DIR_PIN 53 +#define E3_ENABLE_PIN 49 +#ifndef E3_CS_PIN + #define E3_CS_PIN 33 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN 0 // Analog Input +#define TEMP_1_PIN 1 // Analog Input +#define TEMP_2_PIN 2 // Analog Input +#define TEMP_3_PIN 3 // Analog Input +#define TEMP_BED_PIN 4 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 13 +#define HEATER_1_PIN 12 +#define HEATER_2_PIN 11 +#define HEATER_3_PIN 10 +#define HEATER_BED_PIN 7 // BED + +#ifndef FAN_PIN + #define FAN_PIN 9 +#endif +#define FAN1_PIN 8 + +// +// Misc. Functions +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 45 // SERVO4_PIN +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN 59 +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + + #define BTN_EN1 48 + #define BTN_EN2 50 + #define BTN_ENC 46 + + #define SDSS 4 + #define SD_DETECT_PIN 14 + + #define BEEPER_PIN 41 + #define KILL_PIN 66 + + #if IS_RRD_FG_SC + + #define LCD_PINS_RS 42 + #define LCD_PINS_ENABLE 43 + #define LCD_PINS_D4 44 + + #define BTN_BACK 52 + + #elif ENABLED(K3D_242_OLED_CONTROLLER) + + #define LCD_PINS_DC 44 + #define LCD_PINS_RS 42 + #define DOGLCD_CS 52 + #define DOGLCD_MOSI 43 + #define DOGLCD_SCK 47 + #define DOGLCD_A0 LCD_PINS_DC + + #endif + +#endif // HAS_WIRED_LCD From 5ffa6f3331569c8fa0266c1395d7a6a8cf5515f9 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 16 Mar 2021 00:13:07 +0000 Subject: [PATCH 056/311] [cron] Bump distribution date (2021-03-16) --- 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 fb6f756a84..8cc286f342 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-03-15" + #define STRING_DISTRIBUTION_DATE "2021-03-16" #endif /** From dc78e0a2500d17b770e6a3a71730f1047c8a0056 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 16 Mar 2021 17:33:10 -0500 Subject: [PATCH 057/311] Detect extra ENVS in preflight checks (#21361) --- .../PlatformIO/scripts/preflight-checks.py | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 969a82aad2..4499c2bfdc 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -2,33 +2,34 @@ # preflight-checks.py # Check for common issues prior to compiling # -import os,re +import os,re,sys Import("env") -def get_envs_for_board(board): - if board.startswith("BOARD_"): - board = board[6:] - with open(os.path.join("Marlin", "src", "pins", "pins.h"),"r") as f: - board_found = "" - r=re.compile(r"if\s+MB\((.+)\)") - for line in f.readlines(): +def get_envs_for_board(board, envregex): + with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file: + r = re.compile(r"if\s+MB\((.+)\)") + if board.startswith("BOARD_"): + board = board[6:] + + for line in file: mbs = r.findall(line) - if mbs: - board_found = board if board in re.split(r",\s*", mbs[0]) else "" - if board_found and "#include " in line and "env:" in line: - return re.findall(r"env:\w+", line) + if mbs and board in re.split(r",\s*", mbs[0]): + line = file.readline() + found_envs = re.match(r"\s*#include .+" + envregex, line) + if found_envs: + return re.findall(envregex + r"(\w+)", line) return [] -def check_envs(build_env, base_envs, config): - if build_env in base_envs: +def check_envs(build_env, board_envs, config): + if build_env in board_envs: return True ext = config.get(build_env, 'extends', default=None) if ext: if isinstance(ext, str): - return check_envs(ext, base_envs, config) + return check_envs(ext, board_envs, config) elif isinstance(ext, list): for ext_env in ext: - if check_envs(ext_env, base_envs, config): + if check_envs(ext_env, board_envs, config): return True return False @@ -42,15 +43,24 @@ if 'MARLIN_FEATURES' not in env: if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") +if sys.platform == 'win32': + osregex = r"(?:env|win):" +elif sys.platform == 'darwin': + osregex = r"(?:env|mac|uni):" +elif sys.platform == 'linux': + osregex = r"(?:env|lin|uni):" +else: + osregex = r"(?:env):" + build_env = env['PIOENV'] motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] -base_envs = get_envs_for_board(motherboard) +board_envs = get_envs_for_board(motherboard, osregex) config = env.GetProjectConfig() -result = check_envs("env:"+build_env, base_envs, config) +result = check_envs(build_env, board_envs, config) if not result: err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ - (build_env, motherboard, ",".join([e[4:] for e in base_envs if e.startswith("env:")])) + (build_env, motherboard, ",".join([e[4:] for e in board_envs if re.match(r"^" + osregex, e)])) raise SystemExit(err) # From 546e56ef3d28787035e53ec3f55d243c459edaca Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 17 Mar 2021 00:13:28 +0000 Subject: [PATCH 058/311] [cron] Bump distribution date (2021-03-17) --- 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 8cc286f342..a3d28df6f3 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-03-16" + #define STRING_DISTRIBUTION_DATE "2021-03-17" #endif /** From 60607ed18d47ae5a7a51d92f468b044d76bd3187 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Mar 2021 02:39:26 -0500 Subject: [PATCH 059/311] mftest: usage with error --- buildroot/bin/mftest | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index d769ff8cb8..4cecf4f3a5 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -30,7 +30,6 @@ OPTIONS -v --verbose Extra output for debugging. env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41 - " } @@ -58,47 +57,48 @@ while getopts 'abhmruvyn:t:-:' OFLAG; do h) EXIT_USAGE=1 ;; m) USE_MAKE=1 ; bugout "Using make with Docker..." ;; n) case "$OPTARG" in - *[!0-9]*) perror "option requires a number" $OFLAG ; EXIT_USAGE=1 ;; + *[!0-9]*) perror "option requires a number" $OFLAG ; EXIT_USAGE=2 ;; *) CHOICE="$OPTARG" ; bugout "Got a number: $CHOICE" ;; esac ;; - r) REBUILD=1 ; bugout "Rebuilding previous..." ;; + r) REBUILD=1 ; bugout "Rebuilding previous..." ;; t) TESTENV="$OPTARG" ; bugout "Got a target: $TESTENV" ;; - u) AUTO_BUILD=2 ; bugout "Auto-Upload target..." ;; + u) AUTO_BUILD=2 ; bugout "Auto-Upload target..." ;; v) DEBUG=1 ; bugout "Debug ON" ;; - y) BUILD_YES='Y' ; bugout "Build will initiate..." ;; + y) BUILD_YES='Y' ; bugout "Build will initiate..." ;; -) IFS="=" read -r ONAM OVAL <<< "$OPTARG" case "$ONAM" in help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;; autobuild) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;; autoupload) AUTO_BUILD=2 ; bugout "Auto-Upload target..." ;; env) case "$OVAL" in - '') perror "option requires a value" $ONAM ; EXIT_USAGE=1 ;; + '') perror "option requires a value" $ONAM ; EXIT_USAGE=2 ;; *) TESTENV="$OVAL" ; bugout "Got a target: $TESTENV" ;; esac ;; num) case "$OVAL" in [0-9]+) CHOICE="$OVAL" ; bugout "Got a number: $CHOICE" ;; - *) perror "option requires a value" $ONAM ; EXIT_USAGE=1 ;; + *) perror "option requires a value" $ONAM ; EXIT_USAGE=2 ;; esac ;; - rebuild) REBUILD=1 ; bugout "Rebuilding previous..." ;; - make) USE_MAKE=1 ; bugout "Using make with Docker..." ;; -debug|verbose) DEBUG=1 ; bugout "Debug ON" ;; + rebuild) REBUILD=1 ; bugout "Rebuilding previous..." ;; + make) USE_MAKE=1 ; bugout "Using make with Docker..." ;; +debug|verbose) DEBUG=1 ; bugout "Debug ON" ;; build) case "$OVAL" in ''|y|yes) BUILD_YES='Y' ;; n|no) BUILD_YES='N' ;; - *) perror "option value must be y, n, yes, or no" $ONAM ; EXIT_USAGE=1 ;; + *) perror "option value must be y, n, yes, or no" $ONAM ; EXIT_USAGE=2 ;; esac bugout "Build will initiate? ($BUILD_YES)" ;; - *) perror "Unknown flag" "$OPTARG" ; EXIT_USAGE=1 ;; + *) perror "Unknown flag" "$OPTARG" ; EXIT_USAGE=2 ;; esac ;; + *) EXIT_USAGE=2 ;; esac done -((EXIT_USAGE)) && { usage ; exit 1 ; } +((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; } if ((REBUILD)); then bugout "Rebuilding previous..." From 2fc854eda06446c919c46a8e1cd323d5d0e7ad87 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 18 Mar 2021 00:15:21 +0000 Subject: [PATCH 060/311] [cron] Bump distribution date (2021-03-18) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index a3d28df6f3..43094400ea 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-03-17" + #define STRING_DISTRIBUTION_DATE "2021-03-18" #endif /** From de73b9b9345f0d10291d56a801bfc0d8d61a9cf3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Mar 2021 19:24:07 -0500 Subject: [PATCH 061/311] Update setup() description --- Marlin/src/MarlinCore.cpp | 116 +++++++++++++++++++++++++++++--------- 1 file changed, 89 insertions(+), 27 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index e1756af511..158f9e227a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -953,23 +953,92 @@ inline void tmc_standby_setup() { } /** - * Marlin entry-point: Set up before the program loop - * - Set up the kill pin, filament runout, power hold, custom user buttons - * - Start the serial port + * Marlin Firmware entry-point. Abandon Hope All Ye Who Enter Here. + * Setup before the program loop: + * + * - Call any special pre-init set for the board + * - Put TMC drivers into Low Power Standby mode + * - Init the serial ports (so setup can be debugged) + * - Set up the kill and suicide pins + * - Prepare (disable) board JTAG and Debug ports + * - Init serial for a connected MKS TFT with WiFi + * - Install Marlin custom Exception Handlers, if set. + * - Init Marlin's HAL interfaces (for SPI, i2c, etc.) + * - Init some optional hardware and features: + * • MAX Thermocouple pins + * • Duet Smart Effector + * • Filament Runout Sensor + * • TMC220x Stepper Drivers (Serial) + * • PSU control + * • Power-loss Recovery + * • L64XX Stepper Drivers (SPI) + * • Stepper Driver Reset: DISABLE + * • TMC Stepper Drivers (SPI) + * • Run BOARD_INIT if defined + * • ESP WiFi + * - Get the Reset Reason and report it * - Print startup messages and diagnostics - * - Get EEPROM or default settings - * - Initialize managers for: - * • temperature - * • planner - * • watchdog - * • stepper - * • photo pin - * • servos - * • LCD controller - * • Digipot I2C - * • Z probe sled - * • status LEDs - * • Max7219 + * - Calibrate the HAL DELAY for precise timing + * - Init the buzzer, possibly a custom timer + * - Init more optional hardware: + * • Color LED illumination + * • Neopixel illumination + * • Controller Fan + * • Creality DWIN LCD (show boot image) + * • Tare the Probe if possible + * - Mount the (most likely external) SD Card + * - Load settings from EEPROM (or use defaults) + * - Init the Ethernet Port + * - Init Touch Buttons (for emulated DOGLCD) + * - Adjust the (certainly wrong) current position by the home offset + * - Init the Planner::position (steps) based on current (native) position + * - Initialize more managers and peripherals: + * • Temperatures + * • Print Job Timer + * • Endstops and Endstop Interrupts + * • Stepper ISR - Kind of Important! + * • Servos + * • Servo-based Probe + * • Photograph Pin + * • Laser/Spindle tool Power / PWM + * • Coolant Control + * • Bed Probe + * • Stepper Driver Reset: ENABLE + * • Digipot I2C - Stepper driver current control + * • Stepper DAC - Stepper driver current control + * • Solenoid (probe, or for other use) + * • Home Pin + * • Custom User Buttons + * • Red/Blue Status LEDs + * • Case Light + * • Prusa MMU filament changer + * • Fan Multiplexer + * • Mixing Extruder + * • BLTouch Probe + * • I2C Position Encoders + * • Custom I2C Bus handlers + * • Enhanced tools or extruders: + * • Switching Extruder + * • Switching Nozzle + * • Parking Extruder + * • Magnetic Parking Extruder + * • Switching Toolhead + * • Electromagnetic Switching Toolhead + * • Watchdog Timer - Also Kind of Important! + * • Closed Loop Controller + * - Run Startup Commands, if defined + * - Tell host to close Host Prompts + * - Test Trinamic driver connections + * - Init Prusa MMU2 filament changer + * - Init and test BL24Cxx EEPROM + * - Init Creality DWIN encoder, show faux progress bar + * - Reset Status Message / Show Service Messages + * - Init MAX7219 LED Matrix + * - Init Direct Stepping (Klipper-style motion control) + * - Init TFT LVGL UI (with 3D Graphics) + * - Apply Password Lock - Hold for Authentication + * - Open Touch Screen Calibration screen, if not calibrated + * - Set Marlin to RUNNING State */ void setup() { #ifdef BOARD_PREINIT @@ -1311,7 +1380,6 @@ void setup() { #if PIN_EXISTS(STAT_LED_RED) OUT_WRITE(STAT_LED_RED_PIN, LOW); // OFF #endif - #if PIN_EXISTS(STAT_LED_BLUE) OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // OFF #endif @@ -1364,19 +1432,13 @@ void setup() { #endif #endif - #if ENABLED(MAGNETIC_PARKING_EXTRUDER) - SETUP_RUN(mpe_settings_init()); - #endif - #if ENABLED(PARKING_EXTRUDER) SETUP_RUN(pe_solenoid_init()); - #endif - - #if ENABLED(SWITCHING_TOOLHEAD) + #elif ENABLED(MAGNETIC_PARKING_EXTRUDER) + SETUP_RUN(mpe_settings_init()); + #elif ENABLED(SWITCHING_TOOLHEAD) SETUP_RUN(swt_init()); - #endif - - #if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) + #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) SETUP_RUN(est_init()); #endif From 15bda88d0494a12d41e523c9c57dbe1d6cf8eeb2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Mar 2021 19:23:36 -0500 Subject: [PATCH 062/311] Un-pause fans on STOP --- Marlin/src/MarlinCore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 158f9e227a..26ca8305f4 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -889,8 +889,8 @@ void stop() { print_job_timer.stop(); - #if ENABLED(PROBING_FANS_OFF) - if (thermalManager.fans_paused) thermalManager.set_fans_paused(false); // put things back the way they were + #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE) + thermalManager.set_fans_paused(false); // Un-pause fans for safety #endif if (IsRunning()) { From 9823a37362c86f8f722c01af2147075d70234ada Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 16 Mar 2021 15:12:28 -0500 Subject: [PATCH 063/311] E1+ Autotemp and Planner comments --- Marlin/src/lcd/extui/ui_api.cpp | 2 - Marlin/src/module/planner.cpp | 171 +++++++++++++++++++------------- Marlin/src/module/planner.h | 35 +++++-- 3 files changed, 131 insertions(+), 77 deletions(-) diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index d83b921648..97d4ec2b08 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -587,13 +587,11 @@ namespace ExtUI { void setAxisMaxAcceleration_mm_s2(const float &value, const axis_t axis) { planner.set_max_acceleration(axis, value); - planner.reset_acceleration_rates(); } void setAxisMaxAcceleration_mm_s2(const float &value, const extruder_t extruder) { UNUSED_E(extruder); planner.set_max_acceleration(E_AXIS_N(extruder - E0), value); - planner.reset_acceleration_rates(); } #if HAS_FILAMENT_SENSOR diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index dd87a0d24d..c60e9f6cd3 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1248,32 +1248,6 @@ void Planner::recalculate() { recalculate_trapezoids(); } -#if ENABLED(AUTOTEMP) - - void Planner::getHighESpeed() { - static float oldt = 0; - - if (!autotemp_enabled) return; - if (thermalManager.degTargetHotend(0) + 2 < autotemp_min) return; // probably temperature set to zero. - - float high = 0.0; - for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { - block_t* block = &block_buffer[b]; - if (block->steps.x || block->steps.y || block->steps.z) { - const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; - NOLESS(high, se); - } - } - - float t = autotemp_min + high * autotemp_factor; - LIMIT(t, autotemp_min, autotemp_max); - if (t < oldt) t = t * (1 - float(AUTOTEMP_OLDWEIGHT)) + oldt * float(AUTOTEMP_OLDWEIGHT); - oldt = t; - thermalManager.setTargetHotend(t, 0); - } - -#endif // AUTOTEMP - /** * Maintain fans, paste extruder pressure, */ @@ -1398,6 +1372,72 @@ void Planner::check_axes_activity() { #endif } +#if ENABLED(AUTOTEMP) + + #if ENABLED(AUTOTEMP_PROPORTIONAL) + void Planner::_autotemp_update_from_hotend() { + const int16_t target = thermalManager.degTargetHotend(active_extruder); + autotemp_min = target + AUTOTEMP_MIN_P; + autotemp_max = target + AUTOTEMP_MAX_P; + } + #endif + + /** + * Called after changing tools to: + * - Reset or re-apply the default proportional autotemp factor. + * - Enable autotemp if the factor is non-zero. + */ + void Planner::autotemp_update() { + _autotemp_update_from_hotend(); + autotemp_factor = TERN(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P, 0); + autotemp_enabled = autotemp_factor != 0; + } + + /** + * Called by the M104/M109 commands after setting Hotend Temperature + * + */ + void Planner::autotemp_M104_M109() { + _autotemp_update_from_hotend(); + + if (parser.seenval('S')) autotemp_min = parser.value_celsius(); + if (parser.seenval('B')) autotemp_max = parser.value_celsius(); + + // When AUTOTEMP_PROPORTIONAL is enabled, F0 disables autotemp. + // Normally, leaving off F also disables autotemp. + autotemp_factor = parser.seen('F') ? parser.value_float() : TERN(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P, 0); + autotemp_enabled = autotemp_factor != 0; + } + + /** + * Called every so often to adjust the hotend target temperature + * based on the extrusion speed, which is calculated from the blocks + * currently in the planner. + */ + void Planner::getHighESpeed() { + static float oldt = 0; + + if (!autotemp_enabled) return; + if (thermalManager.degTargetHotend(active_extruder) < autotemp_min - 2) return; // Below the min? + + float high = 0.0; + for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { + block_t* block = &block_buffer[b]; + if (block->steps.x || block->steps.y || block->steps.z) { + const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; + NOLESS(high, se); + } + } + + float t = autotemp_min + high * autotemp_factor; + LIMIT(t, autotemp_min, autotemp_max); + if (t < oldt) t *= (1.0f - (AUTOTEMP_OLDWEIGHT)) + oldt * (AUTOTEMP_OLDWEIGHT); + oldt = t; + thermalManager.setTargetHotend(t, active_extruder); + } + +#endif + #if DISABLED(NO_VOLUMETRICS) /** @@ -2959,13 +2999,17 @@ void Planner::reset_acceleration_rates() { TERN_(HAS_LINEAR_E_JERK, recalculate_max_e_jerk()); } -// Recalculate position, steps_to_mm if settings.axis_steps_per_mm changes! +/** + * Recalculate 'position' and 'steps_to_mm'. + * Must be called whenever settings.axis_steps_per_mm changes! + */ void Planner::refresh_positioning() { LOOP_XYZE_N(i) steps_to_mm[i] = 1.0f / settings.axis_steps_per_mm[i]; set_position_mm(current_position); reset_acceleration_rates(); } +// Apply limits to a variable and give a warning if the value was out of range inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_name, const xyze_float_t &max_limit) { const uint8_t lim_axis = axis > E_AXIS ? E_AXIS : axis; const float before = val; @@ -2978,7 +3022,14 @@ inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_n } } -void Planner::set_max_acceleration(const uint8_t axis, float targetValue) { +/** + * For the specified 'axis' set the Maximum Acceleration to the given value (mm/s^2) + * The value may be limited with warning feedback, if configured. + * Calls reset_acceleration_rates to precalculate planner terms in steps. + * + * This hard limit is applied as a block is being added to the planner queue. + */ +void Planner::set_max_acceleration(const uint8_t axis, const float &inMaxAccelMMS2) { #if ENABLED(LIMITED_MAX_ACCEL_EDITING) #ifdef MAX_ACCEL_EDIT_VALUES constexpr xyze_float_t max_accel_edit = MAX_ACCEL_EDIT_VALUES; @@ -2987,15 +3038,21 @@ void Planner::set_max_acceleration(const uint8_t axis, float targetValue) { constexpr xyze_float_t max_accel_edit = DEFAULT_MAX_ACCELERATION; const xyze_float_t max_acc_edit_scaled = max_accel_edit * 2; #endif - limit_and_warn(targetValue, axis, PSTR("Acceleration"), max_acc_edit_scaled); + limit_and_warn(inMaxAccelMMS2, axis, PSTR("Acceleration"), max_acc_edit_scaled); #endif - settings.max_acceleration_mm_per_s2[axis] = targetValue; + settings.max_acceleration_mm_per_s2[axis] = inMaxAccelMMS2; // Update steps per s2 to agree with the units per s2 (since they are used in the planner) reset_acceleration_rates(); } -void Planner::set_max_feedrate(const uint8_t axis, float targetValue) { +/** + * For the specified 'axis' set the Maximum Feedrate to the given value (mm/s) + * The value may be limited with warning feedback, if configured. + * + * This hard limit is applied as a block is being added to the planner queue. + */ +void Planner::set_max_feedrate(const uint8_t axis, const float &inMaxFeedrateMMS) { #if ENABLED(LIMITED_MAX_FR_EDITING) #ifdef MAX_FEEDRATE_EDIT_VALUES constexpr xyze_float_t max_fr_edit = MAX_FEEDRATE_EDIT_VALUES; @@ -3004,13 +3061,20 @@ void Planner::set_max_feedrate(const uint8_t axis, float targetValue) { constexpr xyze_float_t max_fr_edit = DEFAULT_MAX_FEEDRATE; const xyze_float_t max_fr_edit_scaled = max_fr_edit * 2; #endif - limit_and_warn(targetValue, axis, PSTR("Feedrate"), max_fr_edit_scaled); + limit_and_warn(inMaxFeedrateMMS, axis, PSTR("Feedrate"), max_fr_edit_scaled); #endif - settings.max_feedrate_mm_s[axis] = targetValue; + settings.max_feedrate_mm_s[axis] = inMaxFeedrateMMS; } -void Planner::set_max_jerk(const AxisEnum axis, float targetValue) { - #if HAS_CLASSIC_JERK +#if HAS_CLASSIC_JERK + + /** + * For the specified 'axis' set the Maximum Jerk (instant change) to the given value (mm/s) + * The value may be limited with warning feedback, if configured. + * + * This hard limit is applied (to the block start speed) as the block is being added to the planner queue. + */ + void Planner::set_max_jerk(const AxisEnum axis, const float &targetValue) { #if ENABLED(LIMITED_JERK_EDITING) constexpr xyze_float_t max_jerk_edit = #ifdef MAX_JERK_EDIT_VALUES @@ -3023,10 +3087,9 @@ void Planner::set_max_jerk(const AxisEnum axis, float targetValue) { limit_and_warn(targetValue, axis, PSTR("Jerk"), max_jerk_edit); #endif max_jerk[axis] = targetValue; - #else - UNUSED(axis); UNUSED(targetValue); - #endif -} + } + +#endif #if HAS_WIRED_LCD @@ -3069,33 +3132,3 @@ void Planner::set_max_jerk(const AxisEnum axis, float targetValue) { } #endif - -#if ENABLED(AUTOTEMP) - -void Planner::autotemp_update() { - #if ENABLED(AUTOTEMP_PROPORTIONAL) - const int16_t target = thermalManager.degTargetHotend(active_extruder); - autotemp_min = target + AUTOTEMP_MIN_P; - autotemp_max = target + AUTOTEMP_MAX_P; - #endif - autotemp_factor = TERN(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P, 0); - autotemp_enabled = autotemp_factor != 0; -} - - void Planner::autotemp_M104_M109() { - - #if ENABLED(AUTOTEMP_PROPORTIONAL) - const int16_t target = thermalManager.degTargetHotend(active_extruder); - autotemp_min = target + AUTOTEMP_MIN_P; - autotemp_max = target + AUTOTEMP_MAX_P; - #endif - - if (parser.seenval('S')) autotemp_min = parser.value_celsius(); - if (parser.seenval('B')) autotemp_max = parser.value_celsius(); - - // When AUTOTEMP_PROPORTIONAL is enabled, F0 disables autotemp. - // Normally, leaving off F also disables autotemp. - autotemp_factor = parser.seen('F') ? parser.value_float() : TERN(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P, 0); - autotemp_enabled = autotemp_factor != 0; - } -#endif diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index b7ff0ee932..a7aabd9d65 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -460,12 +460,27 @@ class Planner { * Static (class) Methods */ + // Recalculate steps/s^2 accelerations based on mm/s^2 settings static void reset_acceleration_rates(); - static void refresh_positioning(); - static void set_max_acceleration(const uint8_t axis, float targetValue); - static void set_max_feedrate(const uint8_t axis, float targetValue); - static void set_max_jerk(const AxisEnum axis, float targetValue); + /** + * Recalculate 'position' and 'steps_to_mm'. + * Must be called whenever settings.axis_steps_per_mm changes! + */ + static void refresh_positioning(); + + // For an axis set the Maximum Acceleration in mm/s^2 + static void set_max_acceleration(const uint8_t axis, const float &inMaxAccelMMS2); + + // For an axis set the Maximum Feedrate in mm/s + static void set_max_feedrate(const uint8_t axis, const float &inMaxFeedrateMMS); + + // For an axis set the Maximum Jerk (instant change) in mm/s + #if HAS_CLASSIC_JERK + static void set_max_jerk(const AxisEnum axis, const float &inMaxJerkMMS); + #else + static inline void set_max_jerk(const AxisEnum, const float&) {} + #endif #if EXTRUDERS FORCE_INLINE static void refresh_e_factor(const uint8_t e) { @@ -883,9 +898,9 @@ class Planner { #if ENABLED(AUTOTEMP) static float autotemp_min, autotemp_max, autotemp_factor; static bool autotemp_enabled; - static void getHighESpeed(); - static void autotemp_M104_M109(); static void autotemp_update(); + static void autotemp_M104_M109(); + static void getHighESpeed(); #endif #if HAS_LINEAR_E_JERK @@ -898,6 +913,14 @@ class Planner { private: + #if ENABLED(AUTOTEMP) + #if ENABLED(AUTOTEMP_PROPORTIONAL) + static void _autotemp_update_from_hotend(); + #else + static inline void _autotemp_update_from_hotend() {} + #endif + #endif + /** * Get the index of the next / previous block in the ring buffer */ From deaefbf1dcb823f22a8f9edd3fbba069ef9257b9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Mar 2021 02:48:21 -0500 Subject: [PATCH 064/311] Minor E3 V2 dwin cleanup --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index e046bb90f5..97a9fbd4da 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -1469,19 +1469,21 @@ void HMI_PrintSpeed() { } } +#define LAST_AXIS TERN(HAS_HOTEND, E_AXIS, Z_AXIS) + void HMI_MaxFeedspeedXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Feedspeed)) { checkkey = MaxSpeed; EncoderRate.enabled = false; - if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) + if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, LAST_AXIS)) planner.set_max_feedrate(HMI_flag.feedspeed_axis, HMI_ValueStruct.Max_Feedspeed); DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); return; } // MaxFeedspeed limit - if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) + if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, LAST_AXIS)) NOMORE(HMI_ValueStruct.Max_Feedspeed, default_max_feedrate[HMI_flag.feedspeed_axis] * 2); if (HMI_ValueStruct.Max_Feedspeed < MIN_MAXFEEDSPEED) HMI_ValueStruct.Max_Feedspeed = MIN_MAXFEEDSPEED; // MaxFeedspeed value @@ -1495,17 +1497,13 @@ void HMI_MaxAccelerationXYZE() { if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Acceleration)) { checkkey = MaxAcceleration; EncoderRate.enabled = false; - if (HMI_flag.acc_axis == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration); - else if (HMI_flag.acc_axis == Y_AXIS) planner.set_max_acceleration(Y_AXIS, HMI_ValueStruct.Max_Acceleration); - else if (HMI_flag.acc_axis == Z_AXIS) planner.set_max_acceleration(Z_AXIS, HMI_ValueStruct.Max_Acceleration); - #if HAS_HOTEND - else if (HMI_flag.acc_axis == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration); - #endif + if (WITHIN(HMI_flag.acc_axis, X_AXIS, LAST_AXIS)) + planner.set_max_acceleration(HMI_flag.acc_axis, HMI_ValueStruct.Max_Acceleration); DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); return; } // MaxAcceleration limit - if (WITHIN(HMI_flag.acc_axis, X_AXIS, E_AXIS)) + if (WITHIN(HMI_flag.acc_axis, X_AXIS, LAST_AXIS)) NOMORE(HMI_ValueStruct.Max_Acceleration, default_max_acceleration[HMI_flag.acc_axis] * 2); if (HMI_ValueStruct.Max_Acceleration < MIN_MAXACCELERATION) HMI_ValueStruct.Max_Acceleration = MIN_MAXACCELERATION; // MaxAcceleration value @@ -1521,13 +1519,13 @@ void HMI_MaxAccelerationXYZE() { 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)) + if (WITHIN(HMI_flag.jerk_axis, X_AXIS, LAST_AXIS)) 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)) + if (WITHIN(HMI_flag.jerk_axis, X_AXIS, LAST_AXIS)) 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 @@ -1543,13 +1541,13 @@ void HMI_StepXYZE() { 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)) + if (WITHIN(HMI_flag.step_axis, X_AXIS, LAST_AXIS)) 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)) + if (WITHIN(HMI_flag.step_axis, X_AXIS, LAST_AXIS)) NOMORE(HMI_ValueStruct.Max_Step_scaled, 999.9 * MINUNITMULT); NOLESS(HMI_ValueStruct.Max_Step_scaled, MIN_STEP); // Step value From 560448afeddfdea568d74c5be4e48c8b7f5886c7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Mar 2021 21:36:10 -0500 Subject: [PATCH 065/311] Revert "Fix small wired EEPROM (#21337)" Reverting commit cc3e878f90 pending further investigation. --- Marlin/src/HAL/shared/eeprom_if_i2c.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp index 299bc34c49..da70af2772 100644 --- a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp +++ b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp @@ -51,18 +51,6 @@ void eeprom_init() { static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRESS); -void _beginTransmission(const uint16_t memoryAddress) { - if (MARLIN_EEPROM_SIZE > 0x4000) { // Use two-byte addressing for EEPROMs >16kb - Wire.beginTransmission(eeprom_device_address); - Wire.write(memoryAddress >> 8); // Address High Byte - } - else { - const uint8_t addr = eeprom_device_address | byte((memoryAddress >> 8) & 0x07); - Wire.beginTransmission(addr); - } - Wire.write(memoryAddress & 0xFF); // Address Low Byte (or only byte for chips <= 16Kb like 24C02/04/08/16) -} - // ------------------------ // Public functions // ------------------------ @@ -70,7 +58,9 @@ void _beginTransmission(const uint16_t memoryAddress) { void eeprom_write_byte(uint8_t *pos, unsigned char value) { const unsigned eeprom_address = (unsigned)pos; - _beginTransmission(eeprom_address); + Wire.beginTransmission(eeprom_device_address); + Wire.write(int(eeprom_address >> 8)); // MSB + Wire.write(int(eeprom_address & 0xFF)); // LSB Wire.write(value); Wire.endTransmission(); @@ -82,12 +72,11 @@ void eeprom_write_byte(uint8_t *pos, unsigned char value) { uint8_t eeprom_read_byte(uint8_t *pos) { const unsigned eeprom_address = (unsigned)pos; - _beginTransmission(eeprom_address); + Wire.beginTransmission(eeprom_device_address); + Wire.write(int(eeprom_address >> 8)); // MSB + Wire.write(int(eeprom_address & 0xFF)); // LSB Wire.endTransmission(); - - // For EEPROMs <=16Kb the lower address bits are used for 2Kb page address - const int addr = eeprom_device_address | (MARLIN_EEPROM_SIZE <= 0x4000 ? byte((eeprom_address >> 8) & 0x07) : byte(0)); - Wire.requestFrom(addr, byte(1)); + Wire.requestFrom(eeprom_device_address, (byte)1); return Wire.available() ? Wire.read() : 0xFF; } From 6673359d89f5f4194e0de2451e195421bccefd1e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Mar 2021 21:26:25 -0500 Subject: [PATCH 066/311] Move web-ui out of Marlin root folder --- .../web-ui/data}/www/bootstrap.min.css | 0 .../web-ui/data}/www/bootstrap.min.js | 0 .../web-ui/data}/www/bootstrap4-toggle.min.js | 0 .../web-ui/data}/www/chart.lineargauge.js | 0 {data => buildroot/web-ui/data}/www/chart.min.js | 0 .../web-ui/data}/www/filesaver.min.js | 0 {data => buildroot/web-ui/data}/www/index-ie.html | 0 {data => buildroot/web-ui/data}/www/index.html | 0 .../web-ui/data}/www/jquery-3.5.1.slim.min.js | 0 .../web-ui/data}/www/jquery.browser.min.js | 0 .../web-ui/data}/www/marlin-logo-dark.png | Bin {data => buildroot/web-ui/data}/www/marlinui.eot | Bin {data => buildroot/web-ui/data}/www/marlinui.svg | 0 {data => buildroot/web-ui/data}/www/marlinui.ttf | Bin {data => buildroot/web-ui/data}/www/marlinui.woff | Bin {data => buildroot/web-ui/data}/www/moment.min.js | 0 .../web-ui/data}/www/webmarlin-class.js | 0 .../web-ui/data}/www/webmarlin-font.css | 0 {data => buildroot/web-ui/data}/www/webmarlin.css | 0 {data => buildroot/web-ui/data}/www/webmarlin.js | 0 20 files changed, 0 insertions(+), 0 deletions(-) rename {data => buildroot/web-ui/data}/www/bootstrap.min.css (100%) rename {data => buildroot/web-ui/data}/www/bootstrap.min.js (100%) rename {data => buildroot/web-ui/data}/www/bootstrap4-toggle.min.js (100%) rename {data => buildroot/web-ui/data}/www/chart.lineargauge.js (100%) rename {data => buildroot/web-ui/data}/www/chart.min.js (100%) rename {data => buildroot/web-ui/data}/www/filesaver.min.js (100%) rename {data => buildroot/web-ui/data}/www/index-ie.html (100%) rename {data => buildroot/web-ui/data}/www/index.html (100%) rename {data => buildroot/web-ui/data}/www/jquery-3.5.1.slim.min.js (100%) rename {data => buildroot/web-ui/data}/www/jquery.browser.min.js (100%) rename {data => buildroot/web-ui/data}/www/marlin-logo-dark.png (100%) rename {data => buildroot/web-ui/data}/www/marlinui.eot (100%) rename {data => buildroot/web-ui/data}/www/marlinui.svg (100%) rename {data => buildroot/web-ui/data}/www/marlinui.ttf (100%) rename {data => buildroot/web-ui/data}/www/marlinui.woff (100%) rename {data => buildroot/web-ui/data}/www/moment.min.js (100%) rename {data => buildroot/web-ui/data}/www/webmarlin-class.js (100%) rename {data => buildroot/web-ui/data}/www/webmarlin-font.css (100%) rename {data => buildroot/web-ui/data}/www/webmarlin.css (100%) rename {data => buildroot/web-ui/data}/www/webmarlin.js (100%) diff --git a/data/www/bootstrap.min.css b/buildroot/web-ui/data/www/bootstrap.min.css similarity index 100% rename from data/www/bootstrap.min.css rename to buildroot/web-ui/data/www/bootstrap.min.css diff --git a/data/www/bootstrap.min.js b/buildroot/web-ui/data/www/bootstrap.min.js similarity index 100% rename from data/www/bootstrap.min.js rename to buildroot/web-ui/data/www/bootstrap.min.js diff --git a/data/www/bootstrap4-toggle.min.js b/buildroot/web-ui/data/www/bootstrap4-toggle.min.js similarity index 100% rename from data/www/bootstrap4-toggle.min.js rename to buildroot/web-ui/data/www/bootstrap4-toggle.min.js diff --git a/data/www/chart.lineargauge.js b/buildroot/web-ui/data/www/chart.lineargauge.js similarity index 100% rename from data/www/chart.lineargauge.js rename to buildroot/web-ui/data/www/chart.lineargauge.js diff --git a/data/www/chart.min.js b/buildroot/web-ui/data/www/chart.min.js similarity index 100% rename from data/www/chart.min.js rename to buildroot/web-ui/data/www/chart.min.js diff --git a/data/www/filesaver.min.js b/buildroot/web-ui/data/www/filesaver.min.js similarity index 100% rename from data/www/filesaver.min.js rename to buildroot/web-ui/data/www/filesaver.min.js diff --git a/data/www/index-ie.html b/buildroot/web-ui/data/www/index-ie.html similarity index 100% rename from data/www/index-ie.html rename to buildroot/web-ui/data/www/index-ie.html diff --git a/data/www/index.html b/buildroot/web-ui/data/www/index.html similarity index 100% rename from data/www/index.html rename to buildroot/web-ui/data/www/index.html diff --git a/data/www/jquery-3.5.1.slim.min.js b/buildroot/web-ui/data/www/jquery-3.5.1.slim.min.js similarity index 100% rename from data/www/jquery-3.5.1.slim.min.js rename to buildroot/web-ui/data/www/jquery-3.5.1.slim.min.js diff --git a/data/www/jquery.browser.min.js b/buildroot/web-ui/data/www/jquery.browser.min.js similarity index 100% rename from data/www/jquery.browser.min.js rename to buildroot/web-ui/data/www/jquery.browser.min.js diff --git a/data/www/marlin-logo-dark.png b/buildroot/web-ui/data/www/marlin-logo-dark.png similarity index 100% rename from data/www/marlin-logo-dark.png rename to buildroot/web-ui/data/www/marlin-logo-dark.png diff --git a/data/www/marlinui.eot b/buildroot/web-ui/data/www/marlinui.eot similarity index 100% rename from data/www/marlinui.eot rename to buildroot/web-ui/data/www/marlinui.eot diff --git a/data/www/marlinui.svg b/buildroot/web-ui/data/www/marlinui.svg similarity index 100% rename from data/www/marlinui.svg rename to buildroot/web-ui/data/www/marlinui.svg diff --git a/data/www/marlinui.ttf b/buildroot/web-ui/data/www/marlinui.ttf similarity index 100% rename from data/www/marlinui.ttf rename to buildroot/web-ui/data/www/marlinui.ttf diff --git a/data/www/marlinui.woff b/buildroot/web-ui/data/www/marlinui.woff similarity index 100% rename from data/www/marlinui.woff rename to buildroot/web-ui/data/www/marlinui.woff diff --git a/data/www/moment.min.js b/buildroot/web-ui/data/www/moment.min.js similarity index 100% rename from data/www/moment.min.js rename to buildroot/web-ui/data/www/moment.min.js diff --git a/data/www/webmarlin-class.js b/buildroot/web-ui/data/www/webmarlin-class.js similarity index 100% rename from data/www/webmarlin-class.js rename to buildroot/web-ui/data/www/webmarlin-class.js diff --git a/data/www/webmarlin-font.css b/buildroot/web-ui/data/www/webmarlin-font.css similarity index 100% rename from data/www/webmarlin-font.css rename to buildroot/web-ui/data/www/webmarlin-font.css diff --git a/data/www/webmarlin.css b/buildroot/web-ui/data/www/webmarlin.css similarity index 100% rename from data/www/webmarlin.css rename to buildroot/web-ui/data/www/webmarlin.css diff --git a/data/www/webmarlin.js b/buildroot/web-ui/data/www/webmarlin.js similarity index 100% rename from data/www/webmarlin.js rename to buildroot/web-ui/data/www/webmarlin.js From ad907a51e245a908024ff2736f95455d89e9571d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 18 Mar 2021 00:11:06 -0500 Subject: [PATCH 067/311] Followup to planner cleanup --- Marlin/src/module/planner.cpp | 10 +++++----- Marlin/src/module/planner.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index c60e9f6cd3..594671f87a 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -3029,7 +3029,7 @@ inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_n * * This hard limit is applied as a block is being added to the planner queue. */ -void Planner::set_max_acceleration(const uint8_t axis, const float &inMaxAccelMMS2) { +void Planner::set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2) { #if ENABLED(LIMITED_MAX_ACCEL_EDITING) #ifdef MAX_ACCEL_EDIT_VALUES constexpr xyze_float_t max_accel_edit = MAX_ACCEL_EDIT_VALUES; @@ -3052,7 +3052,7 @@ void Planner::set_max_acceleration(const uint8_t axis, const float &inMaxAccelMM * * This hard limit is applied as a block is being added to the planner queue. */ -void Planner::set_max_feedrate(const uint8_t axis, const float &inMaxFeedrateMMS) { +void Planner::set_max_feedrate(const uint8_t axis, float inMaxFeedrateMMS) { #if ENABLED(LIMITED_MAX_FR_EDITING) #ifdef MAX_FEEDRATE_EDIT_VALUES constexpr xyze_float_t max_fr_edit = MAX_FEEDRATE_EDIT_VALUES; @@ -3074,7 +3074,7 @@ void Planner::set_max_feedrate(const uint8_t axis, const float &inMaxFeedrateMMS * * This hard limit is applied (to the block start speed) as the block is being added to the planner queue. */ - void Planner::set_max_jerk(const AxisEnum axis, const float &targetValue) { + void Planner::set_max_jerk(const AxisEnum axis, float inMaxJerkMMS) { #if ENABLED(LIMITED_JERK_EDITING) constexpr xyze_float_t max_jerk_edit = #ifdef MAX_JERK_EDIT_VALUES @@ -3084,9 +3084,9 @@ void Planner::set_max_feedrate(const uint8_t axis, const float &inMaxFeedrateMMS (DEFAULT_ZJERK) * 2, (DEFAULT_EJERK) * 2 } #endif ; - limit_and_warn(targetValue, axis, PSTR("Jerk"), max_jerk_edit); + limit_and_warn(inMaxJerkMMS, axis, PSTR("Jerk"), max_jerk_edit); #endif - max_jerk[axis] = targetValue; + max_jerk[axis] = inMaxJerkMMS; } #endif diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index a7aabd9d65..7ebba1e342 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -470,14 +470,14 @@ class Planner { static void refresh_positioning(); // For an axis set the Maximum Acceleration in mm/s^2 - static void set_max_acceleration(const uint8_t axis, const float &inMaxAccelMMS2); + static void set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2); // For an axis set the Maximum Feedrate in mm/s - static void set_max_feedrate(const uint8_t axis, const float &inMaxFeedrateMMS); + static void set_max_feedrate(const uint8_t axis, float inMaxFeedrateMMS); // For an axis set the Maximum Jerk (instant change) in mm/s #if HAS_CLASSIC_JERK - static void set_max_jerk(const AxisEnum axis, const float &inMaxJerkMMS); + static void set_max_jerk(const AxisEnum axis, float inMaxJerkMMS); #else static inline void set_max_jerk(const AxisEnum, const float&) {} #endif From 1f52112d72a1b05ce673581f4d5e9b9ac06ff795 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 19 Mar 2021 00:13:41 +0000 Subject: [PATCH 068/311] [cron] Bump distribution date (2021-03-19) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 43094400ea..4839037c0e 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-03-18" + #define STRING_DISTRIBUTION_DATE "2021-03-19" #endif /** From b51aed8aa54f41cc5897485d3b34b019ce38343d Mon Sep 17 00:00:00 2001 From: Skorpi08 Date: Fri, 19 Mar 2021 02:51:19 +0100 Subject: [PATCH 069/311] Nextion TFT touch screen (#21324) Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 8 + Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/SanityCheck.h | 1 + .../lcd/extui/lib/nextion/FileNavigator.cpp | 174 +++++ .../src/lcd/extui/lib/nextion/FileNavigator.h | 53 ++ .../src/lcd/extui/lib/nextion/nextion_tft.cpp | 729 ++++++++++++++++++ .../src/lcd/extui/lib/nextion/nextion_tft.h | 62 ++ .../lcd/extui/lib/nextion/nextion_tft_defs.h | 63 ++ Marlin/src/lcd/extui/nextion_lcd.cpp | 117 +++ Marlin/src/lcd/extui/ui_api.cpp | 15 +- Marlin/src/lcd/extui/ui_api.h | 12 + platformio.ini | 2 + 12 files changed, 1235 insertions(+), 3 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/nextion/FileNavigator.cpp create mode 100644 Marlin/src/lcd/extui/lib/nextion/FileNavigator.h create mode 100644 Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp create mode 100644 Marlin/src/lcd/extui/lib/nextion/nextion_tft.h create mode 100644 Marlin/src/lcd/extui/lib/nextion/nextion_tft_defs.h create mode 100644 Marlin/src/lcd/extui/nextion_lcd.cpp diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 726ff1ec0b..ce847c0d65 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2396,6 +2396,14 @@ //#define ANYCUBIC_LCD_DEBUG #endif +// +// 320x240 Nextion 2.8" serial TFT Resistive Touch Screen NX3224T028 +// +//#define NEXTION_TFT +#if ENABLED(NEXTION_TFT) + #define LCD_SERIAL_PORT 1 // Default is 1 for Nextion +#endif + // // Third-party or vendor-customized controller interfaces. // Sources should be installed in 'src/lcd/extui'. diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index fc7eec84ee..fc83a1ff87 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -460,7 +460,7 @@ #endif // Extensible UI serial touch screens. (See src/lcd/extui) -#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) +#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, NEXTION_TFT) #define IS_EXTUI 1 #define EXTENSIBLE_UI #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 5302aac208..af30c6156d 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2353,6 +2353,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal + ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) \ + ENABLED(MAKRPANEL) \ + ENABLED(MALYAN_LCD) \ + + ENABLED(NEXTION_TFT) \ + ENABLED(MKS_LCD12864) \ + ENABLED(OLED_PANEL_TINYBOY2) \ + ENABLED(OVERLORD_OLED) \ diff --git a/Marlin/src/lcd/extui/lib/nextion/FileNavigator.cpp b/Marlin/src/lcd/extui/lib/nextion/FileNavigator.cpp new file mode 100644 index 0000000000..f82ce1f091 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/nextion/FileNavigator.cpp @@ -0,0 +1,174 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* **************************************** + * lcd/extui/lib/nextion/FileNavigator.cpp + * **************************************** + * Extensible_UI implementation for Nextion + * https://github.com/Skorpi08 + * ***************************************/ + +#include "../../../../inc/MarlinConfigPre.h" + +#if ENABLED(NEXTION_TFT) + +#include "FileNavigator.h" +#include "nextion_tft.h" + +using namespace ExtUI; + +#define DEBUG_OUT NEXDEBUGLEVEL +#include "../../../../core/debug_out.h" + +FileList FileNavigator::filelist; // Instance of the Marlin file API +char FileNavigator::currentfoldername[MAX_PATH_LEN]; // Current folder path +uint16_t FileNavigator::lastindex; +uint8_t FileNavigator::folderdepth; +uint16_t FileNavigator::currentindex; // override the panel request + +FileNavigator filenavigator; + +FileNavigator::FileNavigator() { reset(); } + +void FileNavigator::reset() { + currentfoldername[0] = '\0'; + folderdepth = 0; + currentindex = 0; + lastindex = 0; + // Start at root folder + while (!filelist.isAtRootDir()) filelist.upDir(); + refresh(); +} + +void FileNavigator::refresh() { filelist.refresh(); } + +void FileNavigator::getFiles(uint16_t index) { + uint16_t files = 7, fseek = 0, fcnt = 0; + if (index == 0) + currentindex = 0; + else { + // Each time we change folder we reset the file index to 0 and keep track + // of the current position as the TFT panel isn't aware of folder trees. + --currentindex; // go back a file to take account of the .. added to the root. + if (index > lastindex) + currentindex += files + 1; + else if (currentindex >= files) + currentindex -= files - 1; + else + currentindex = 0; + } + lastindex = index; + + #if NEXDEBUG(AC_FILE) + DEBUG_ECHOLNPAIR("index=", index, " currentindex=", currentindex); + #endif + + if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder + nextion.SendtoTFT(PSTR("vis p0,1")); + nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + SEND_VAL("tmpUP", "0"); + files--; + } + else { + nextion.SendtoTFT(PSTR("vis p0,0")); + nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + } + + for (uint16_t seek = currentindex; seek < currentindex + files; seek++) { + if (filelist.seek(seek)) { + nextion.SendtoTFT(PSTR("s")); + LCD_SERIAL.print(fcnt); + nextion.SendtoTFT(PSTR(".txt=\"")); + if (filelist.isDir()) { + LCD_SERIAL.print(filelist.shortFilename()); + nextion.SendtoTFT(PSTR("/\"")); + nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + + nextion.SendtoTFT(PSTR("l")); + LCD_SERIAL.print(fcnt); + nextion.SendtoTFT(PSTR(".txt=\"")); + LCD_SERIAL.print(filelist.filename()); + nextion.SendtoTFT(PSTR("\"")); + nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + SEND_PCO2("l", fcnt, "1055"); + } + else { + LCD_SERIAL.print(currentfoldername); + LCD_SERIAL.print(filelist.shortFilename()); + nextion.SendtoTFT(PSTR("\"")); + nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + + nextion.SendtoTFT(PSTR("l")); + LCD_SERIAL.print(fcnt); + nextion.SendtoTFT(PSTR(".txt=\"")); + LCD_SERIAL.print(filelist.longFilename()); + nextion.SendtoTFT(PSTR("\"")); + nextion.SendtoTFT(PSTR("\xFF\xFF\xFF")); + } + fcnt++; + fseek = seek; + #if NEXDEBUG(AC_FILE) + DEBUG_ECHOLNPAIR("-", seek, " '", filelist.longFilename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n"); + #endif + } + } + SEND_VAL("n0", filelist.count()); + SEND_VAL("n1", fseek + 1); +} + +void FileNavigator::changeDIR(char *folder) { + #if NEXDEBUG(AC_FILE) + DEBUG_ECHOLNPAIR("currentfolder: ", currentfoldername, " New: ", folder); + #endif + if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth + strcat(currentfoldername, folder); + strcat(currentfoldername, "/"); + filelist.changeDir(folder); + refresh(); + folderdepth++; + currentindex = 0; +} + +void FileNavigator::upDIR() { + filelist.upDir(); + refresh(); + folderdepth--; + currentindex = 0; + // Remove the last child folder from the stored path + if (folderdepth == 0) { + currentfoldername[0] = '\0'; + reset(); + } + else { + char *pos = nullptr; + for (uint8_t f = 0; f < folderdepth; f++) + pos = strchr(currentfoldername, '/'); + pos[1] = '\0'; + } + #if NEXDEBUG(AC_FILE) + DEBUG_ECHOLNPAIR("depth: ", folderdepth, " currentfoldername: ", currentfoldername); + #endif +} + +char* FileNavigator::getCurrentFolderName() { return currentfoldername; } + +#endif // NEXTION_TFT diff --git a/Marlin/src/lcd/extui/lib/nextion/FileNavigator.h b/Marlin/src/lcd/extui/lib/nextion/FileNavigator.h new file mode 100644 index 0000000000..1cd29ec671 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/nextion/FileNavigator.h @@ -0,0 +1,53 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/* **************************************** + * lcd/extui/lib/nextion/FileNavigator.cpp + * **************************************** + * Extensible_UI implementation for Nextion + * https://github.com/Skorpi08 + * ***************************************/ + +#include "nextion_tft_defs.h" // for MAX_PATH_LEN +#include "../../ui_api.h" + +using namespace ExtUI; + +class FileNavigator { + public: + FileNavigator(); + static void reset(); + static void getFiles(uint16_t); + static void upDIR(); + static void changeDIR(char *); + static void refresh(); + static char* getCurrentFolderName(); + private: + static FileList filelist; + static char currentfoldername[MAX_PATH_LEN]; + static uint16_t lastindex; + static uint8_t folderdepth; + static uint16_t currentindex; +}; + +extern FileNavigator filenavigator; diff --git a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp new file mode 100644 index 0000000000..12a7bc7cc7 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp @@ -0,0 +1,729 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* **************************************** + * lcd/extui/lib/nextion/nextion_tft.h + * **************************************** + * Extensible_UI implementation for Nextion + * https://github.com/Skorpi08 + * ***************************************/ + +#include "../../../../inc/MarlinConfigPre.h" + +#if ENABLED(NEXTION_TFT) + +#include "../../../../MarlinCore.h" +#include "../../../../feature/pause.h" +#include "../../../../gcode/queue.h" +#include "../../../../libs/numtostr.h" +#include "../../../../sd/cardreader.h" +#include "FileNavigator.h" +#include "nextion_tft.h" + +#define DEBUG_OUT NEXDEBUGLEVEL +#include "../../../../core/debug_out.h" + +char NextionTFT::selectedfile[MAX_PATH_LEN]; +char NextionTFT::nextion_command[MAX_CMND_LEN]; +uint8_t NextionTFT::command_len; + +bool last_homed = 0, last_homedX = 0, last_homedY = 0, last_homedZ = 0; +float last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999, last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999; +float last_get_axis_position_mmX = 999, last_get_axis_position_mmY = 999, last_get_axis_position_mmZ = 999; +float last_extruder_advance_K = 999; +uint8_t last_active_extruder = 99, last_fan_speed = 99, last_print_speed = 99, last_flow_speed = 99, last_progress = 99; +uint8_t last_printer_state = 99, last_IDEX_Mode = 99; +uint32_t layer = 0, last_layer = 99; + +NextionTFT nextion; + +NextionTFT::NextionTFT() {} + +void NextionTFT::Startup() { + selectedfile[0] = '\0'; + nextion_command[0] = '\0'; + command_len = 0; + LCD_SERIAL.begin(115200); + + SEND_VAL("tmppage.connected", 0); + delay_ms(100); + SEND_VAL("tmppage.connected", 1); + + SEND_VALasTXT("tmppage.marlin", SHORT_BUILD_VERSION); + SEND_VALasTXT("tmppage.compiled", __DATE__ " / " __TIME__); + SEND_VALasTXT("tmppage.extruder", EXTRUDERS); + SEND_VALasTXT("tmppage.printer", MACHINE_NAME); + SEND_VALasTXT("tmppage.author", STRING_CONFIG_H_AUTHOR); + SEND_VALasTXT("tmppage.released", STRING_DISTRIBUTION_DATE); + SEND_VALasTXT("tmppage.bedx", X_BED_SIZE); + SEND_VALasTXT("tmppage.bedy", Y_BED_SIZE); + SEND_VALasTXT("tmppage.bedz", Z_MAX_POS); + + DEBUG_ECHOLNPAIR("Nextion Debug Level ", NEXDEBUGLEVEL); +} + +void NextionTFT::IdleLoop() { + if (ReadTFTCommand()) { + ProcessPanelRequest(); + command_len = 0; + } + UpdateOnChange(); +} + +void NextionTFT::PrinterKilled(PGM_P error, PGM_P component) { + SEND_TXT_END("page error"); + SEND_TXT("t3", "Error"); + SEND_TXT_P("t4", component); + SEND_TXT_P("t5", error); + SEND_TXT("t6", "Need reset"); +} + +void NextionTFT::PrintFinished() { + SEND_TXT_END("page printfinished"); +} + +void NextionTFT::ConfirmationRequest(const char *const msg) { + SEND_VALasTXT("tmppage.M117", msg); + #if NEXDEBUG(N_MARLIN) + DEBUG_ECHOLNPAIR("ConfirmationRequest() ", msg, " printer_state:", printer_state); + #endif +} + +void NextionTFT::StatusChange(const char *const msg) { + #if NEXDEBUG(N_MARLIN) + DEBUG_ECHOLNPAIR("StatusChange() ", msg, "\nprinter_state:", printer_state); + #endif + SEND_VALasTXT("tmppage.M117", msg); +} + +void NextionTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel + #if NEXDEBUG(N_SOME) + DEBUG_ECHOPGM_P(str); + #endif + while (const char c = pgm_read_byte(str++)) + LCD_SERIAL.write(c); +} + +bool NextionTFT::ReadTFTCommand() { + bool command_ready = false; + while ((LCD_SERIAL.available() > 0) && (command_len < MAX_CMND_LEN)) { + nextion_command[command_len] = LCD_SERIAL.read(); + if (nextion_command[command_len] == 10) { + command_ready = true; + break; + } + command_len++; + } + + if (command_ready) { + nextion_command[command_len] = 0x00; + if (nextion_command[0] == 'G' || nextion_command[0] == 'M' || nextion_command[0] == 'T') + injectCommands(nextion_command); + #if NEXDEBUG(N_ALL) + DEBUG_ECHOLNPAIR("< ", nextion_command); + #endif + #if NEXDEBUG(N_SOME) + uint8_t req = atoi(&nextion_command[1]); + if (req > 7 && req != 20) + DEBUG_ECHOLNPAIR( "> ", nextion_command[0], + "\n> ", nextion_command[1], + "\n> ", nextion_command[2], + "\n> ", nextion_command[3], + "\nprinter_state:", printer_state); + #endif + } + return command_ready; +} + +void NextionTFT::SendFileList(int8_t startindex) { + // respond to panel request for 7 files starting at index + #if NEXDEBUG(N_INFO) + DEBUG_ECHOLNPAIR("## SendFileList ## ", startindex); + #endif + filenavigator.getFiles(startindex); +} + +void NextionTFT::SelectFile() { + strncpy(selectedfile, nextion_command + 4, command_len - 4); + selectedfile[command_len - 5] = '\0'; + #if NEXDEBUG(N_FILE) + DEBUG_ECHOLNPAIR_F(" Selected File: ", selectedfile); + #endif + switch (selectedfile[0]) { + case '/': // Valid file selected + //SEND_TXT("tmppage.M117", msg_sd_file_open_success); + break; + case '<': // .. (go up folder level) + filenavigator.upDIR(); + SendFileList(0); + break; + default: // enter sub folder + filenavigator.changeDIR(selectedfile); + SendFileList(0); + break; + } +} + +void NextionTFT::_format_time(char *outstr, uint32_t time) { + const uint8_t hrs = time / 3600, + min = (time / 60) % 60, + sec = time % 60; + if (hrs) + sprintf_P(outstr, PSTR("%02d:%02dm"), hrs, min); + else + sprintf_P(outstr, PSTR("%02d:%02ds"), min, sec); +} + +void NextionTFT::ProcessPanelRequest() { + // Break these up into logical blocks as its easier to navigate than one huge switch case! + if (nextion_command[0] == 'X') { + int8_t req = atoi(&nextion_command[1]); + + // Information requests + if (req <= 49) + PanelInfo(req); + + // Simple Actions + else if (req >= 50) + PanelAction(req); + } +} + +#define SEND_NA(A) SEND_TXT(A, "n/a") + +void NextionTFT::PanelInfo(uint8_t req) { + switch (req) { + case 0: break; + + case 1: // Get SD Card list + if (!isPrinting()) { + if (!isMediaInserted()) safe_delay(500); + if (!isMediaInserted()) { // Make sure the card is removed + //SEND_TXT("tmppage.M117", msg_no_sd_card); + } + else if (nextion_command[3] == 'S') + SendFileList(atoi(&nextion_command[4])); + } + break; + + case 2: // Printer Info + if (!isPrinting()) { + SEND_VAL("tmppage.connected", 1); + SEND_VALasTXT("tmppage.marlin", SHORT_BUILD_VERSION); + SEND_VALasTXT("tmppage.compiled", __DATE__ " / " __TIME__); + SEND_VALasTXT("tmppage.extruder", EXTRUDERS); + SEND_VALasTXT("tmppage.printer", MACHINE_NAME); + SEND_VALasTXT("tmppage.author", STRING_CONFIG_H_AUTHOR); + SEND_VALasTXT("tmppage.released", STRING_DISTRIBUTION_DATE); + SEND_VALasTXT("tmppage.bedx", X_BED_SIZE); + SEND_VALasTXT("tmppage.bedy", Y_BED_SIZE); + SEND_VALasTXT("tmppage.bedz", Z_MAX_POS); + SEND_TEMP("tmppage.t0", ui8tostr3rj(getActualTemp_celsius(E0)), " / ", ui8tostr3rj(getTargetTemp_celsius(E0))); + SEND_TEMP("tmppage.t1", ui8tostr3rj(getActualTemp_celsius(E1)), " / ", ui8tostr3rj(getTargetTemp_celsius(E1))); + SEND_TEMP("tmppage.t2", ui8tostr3rj(getActualTemp_celsius(BED)), " / ", ui8tostr3rj(getTargetTemp_celsius(BED))); + SEND_VALasTXT("tmppage.tool", getActiveTool()); + SEND_VALasTXT("tmppage.fan", ui8tostr3rj(getActualFan_percent(FAN0))); + SEND_VALasTXT("tmppage.speed", getFeedrate_percent()); + SEND_VALasTXT("tmppage.flow", getFlowPercentage(getActiveTool())); + SEND_VALasTXT("tmppage.progress", ui8tostr3rj(getProgress_percent())); + SEND_VALasTXT("tmppage.layer", layer); + SEND_VALasTXT("tmppage.x", getAxisPosition_mm(X)); + SEND_VALasTXT("tmppage.y", getAxisPosition_mm(Y)); + SEND_VALasTXT("tmppage.z", getAxisPosition_mm(Z)); + SEND_VAL("tmppage.homed", isPositionKnown()); + SEND_VAL("tmppage.homedx", isAxisPositionKnown(X)); + SEND_VAL("tmppage.homedy", isAxisPositionKnown(Y)); + SEND_VAL("tmppage.homedz", isAxisPositionKnown(Z)); + #if ENABLED(DUAL_X_CARRIAGE) + SEND_VAL("tmppage.idexmode", getIDEX_Mode()); + #endif + SEND_TXT("tmppage.M117", msg_welcome); + } + break; + + case 23: // Linear Advance + #if ENABLED(LIN_ADVANCE) + SEND_VALasTXT("linadvance", getLinearAdvance_mm_mm_s(getActiveTool())); + #else + SEND_NA("linadvance"); + #endif + break; + + case 24: // TMC Motor Current + #if HAS_TRINAMIC_CONFIG + #define SEND_TRINAMIC_CURR(A, B) SEND_VALasTXT(A, getAxisCurrent_mA(B)) + #else + #define SEND_TRINAMIC_CURR(A, B) SEND_NA(A) + #endif + SEND_TRINAMIC_CURR("x", X); + SEND_TRINAMIC_CURR("x2", X2); + SEND_TRINAMIC_CURR("y", Y); + SEND_TRINAMIC_CURR("y2", Y2); + SEND_TRINAMIC_CURR("z", Z); + SEND_TRINAMIC_CURR("z2", Z2); + SEND_TRINAMIC_CURR("e", E0); + SEND_TRINAMIC_CURR("e1", E1); + break; + + case 25: // TMC Bump Sensitivity + #if HAS_TRINAMIC_CONFIG + #define SEND_TRINAMIC_BUMP(A, B) SEND_VALasTXT(A, getTMCBumpSensitivity(B)) + #else + #define SEND_TRINAMIC_BUMP(A, B) SEND_NA(A) + #endif + SEND_TRINAMIC_BUMP("x", X); + SEND_TRINAMIC_BUMP("x2", X2); + SEND_TRINAMIC_BUMP("y", Y); + SEND_TRINAMIC_BUMP("y2", Y2); + SEND_TRINAMIC_BUMP("z", Z); + SEND_TRINAMIC_BUMP("z2", Z2); + break; + + case 26: // TMC Hybrid Threshold Speed + #if 0 && BOTH(HAS_TRINAMIC_CONFIG, HYBRID_THRESHOLD) + #define SEND_TRINAMIC_THRS(A, B) SEND_VALasTXT(A, getAxisPWMthrs(B)) + #else + #define SEND_TRINAMIC_THRS(A, B) SEND_NA(A) + #endif + SEND_TRINAMIC_THRS("x", X); + SEND_TRINAMIC_THRS("x2", X2); + SEND_TRINAMIC_THRS("y", Y); + SEND_TRINAMIC_THRS("y2", Y2); + SEND_TRINAMIC_THRS("z", Z); + SEND_TRINAMIC_THRS("z2", Z2); + SEND_TRINAMIC_THRS("e", E0); + SEND_TRINAMIC_THRS("e1", E1); + break; + + case 27: // Printcounter + #if ENABLED(PRINTCOUNTER) + char buffer[21]; + #define SEND_PRINT_INFO(A, B) SEND_VALasTXT(A, B(buffer)) + #else + #define SEND_PRINT_INFO(A, B) SEND_NA(A) + #endif + SEND_PRINT_INFO("t5", getTotalPrints_str); + SEND_PRINT_INFO("t3", getFinishedPrints_str); + SEND_PRINT_INFO("t4", getFailedPrints_str); + SEND_PRINT_INFO("t6", getTotalPrintTime_str); + SEND_PRINT_INFO("t7", getLongestPrint_str); + SEND_PRINT_INFO("t8", getFilamentUsed_str); + break; + + case 28: // Filament laod/unload + #if ENABLED(ADVANCED_PAUSE_FEATURE) + #define SEND_PAUSE_INFO(A, B) SEND_VALasTXT(A, fc_settings[getActiveTool()].B) + #else + #define SEND_PAUSE_INFO(A, B) SEND_NA(A) + #endif + SEND_PAUSE_INFO("filamentin", load_length); + SEND_PAUSE_INFO("filamentout", unload_length); + break; + + case 29: // Preheat + #if PREHEAT_COUNT + if (!isPrinting()) { + // Preheat PLA + if (nextion_command[4] == 'P') { + SEND_VALasTXT("pe", getMaterial_preset_E(0)); + #if HAS_HEATED_BED + SEND_VALasTXT("pb", getMaterial_preset_B(0)); + #endif + } + + // Preheat ABS + if (nextion_command[4] == 'A') { + SEND_VALasTXT("ae", getMaterial_preset_E(1)); + #if HAS_HEATED_BED + SEND_VALasTXT("ab", getMaterial_preset_B(1)); + #endif + } + + // Preheat PETG + if (nextion_command[4] == 'G') { + #ifdef PREHEAT_3_TEMP_HOTEND + SEND_VALasTXT("ge", getMaterial_preset_E(2)); + #if HAS_HEATED_BED + SEND_VALasTXT("gb", getMaterial_preset_B(2)); + #endif + #endif + } + } + #endif + break; + + case 30: // Velocity + SEND_VALasTXT("x", getAxisMaxFeedrate_mm_s(X)); + SEND_VALasTXT("y", getAxisMaxFeedrate_mm_s(Y)); + SEND_VALasTXT("z", getAxisMaxFeedrate_mm_s(Z)); + SEND_VALasTXT("e", getAxisMaxFeedrate_mm_s(getActiveTool())); + SEND_VALasTXT("min", getMinFeedrate_mm_s()); + SEND_VALasTXT("tmin", getMinTravelFeedrate_mm_s()); + break; + + case 31: // Jerk + #if ENABLED(CLASSIC_JERK) + #define SEND_JERK_INFO(A, B) SEND_VALasTXT(A, getAxisMaxJerk_mm_s(B)) + #else + #define SEND_JERK_INFO(A, B) SEND_NA(A) + //SEND_VALasTXT("x", getJunctionDeviation_mm()); + SEND_TXT("tmppage.M117", "classic Jerk not enabled"); + #endif + SEND_JERK_INFO("x", X); + SEND_JERK_INFO("y", Y); + SEND_JERK_INFO("z", Z); + SEND_JERK_INFO("e", getActiveTool()); + break; + + case 32: // Steps-per-mm + SEND_VALasTXT("x", getAxisSteps_per_mm(X)); + SEND_VALasTXT("y", getAxisSteps_per_mm(Y)); + SEND_VALasTXT("z", getAxisSteps_per_mm(Z)); + SEND_VALasTXT("e0", getAxisSteps_per_mm(E0)); + SEND_VALasTXT("e1", getAxisSteps_per_mm(E1)); + break; + + case 33: // Acceleration + SEND_VALasTXT("x", ui16tostr5rj(getAxisMaxAcceleration_mm_s2(X))); + SEND_VALasTXT("y", ui16tostr5rj(getAxisMaxAcceleration_mm_s2(Y))); + SEND_VALasTXT("z", ui16tostr5rj(getAxisMaxAcceleration_mm_s2(Z))); + SEND_VALasTXT("e", ui16tostr5rj(getAxisMaxAcceleration_mm_s2(getActiveTool()))); + SEND_VALasTXT("print", ui16tostr5rj(getPrintingAcceleration_mm_s2())); + SEND_VALasTXT("retract", ui16tostr5rj(getRetractAcceleration_mm_s2())); + SEND_VALasTXT("travel", ui16tostr5rj(getTravelAcceleration_mm_s2())); + break; + + case 34: // Dual X carriage offset + #if ENABLED(DUAL_X_CARRIAGE) + #define SEND_IDEX_INFO(A, B) SEND_VALasTXT(A, getNozzleOffset_mm(B, getActiveTool())) + #else + #define SEND_IDEX_INFO(A, B) SEND_NA(A) + #endif + SEND_IDEX_INFO("x", X); + SEND_IDEX_INFO("y", Y); + SEND_IDEX_INFO("z", Z); + break; + + case 35: // Probe offset + #if HAS_PROBE_XY_OFFSET + #define SEND_PROBE_INFO(A, B) SEND_VALasTXT(A, getProbeOffset_mm(B)) + #else + #define SEND_PROBE_INFO(A, B) SEND_NA(A) + #endif + SEND_PROBE_INFO("x", X); + SEND_PROBE_INFO("y", Y); + SEND_VALasTXT("z", getZOffset_mm()); + break; + + case 36: // Endstop Info + #if HAS_X_MIN + SEND_VALasTXT("x1", READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); + #endif + #if HAS_X_MAX + SEND_VALasTXT("x2", READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); + #endif + #if HAS_Y_MIN + SEND_VALasTXT("y1", READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); + #endif + #if HAS_Z_MIN + SEND_VALasTXT("z1", READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); + #endif + #if HAS_Z_MAX + SEND_VALasTXT("z2", READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); + #endif + #if HAS_Z2_MIN + SEND_VALasTXT("z2", READ(Z2_MIN_PIN) != Z2_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); + #endif + #if HAS_Z2_MAX + SEND_VALasTXT("z2", READ(Z2_MAX_PIN) != Z2_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); + #endif + #if HAS_BED_PROBE + //SEND_VALasTXT("bltouch", READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING ? "triggered" : "open"); + #else + SEND_NA("bltouch"); + #endif + break; + + case 37: // PID + #if ENABLED(PIDTEMP) + #define SEND_PID_INFO_0(A, B) SEND_VALasTXT(A, getPIDValues_K##B(E0)) + #else + #define SEND_PID_INFO_0(A, B) SEND_NA(A) + #endif + #if BOTH(PIDTEMP, HAS_MULTI_EXTRUDER) + #define SEND_PID_INFO_1(A, B) SEND_VALasTXT(A, getPIDValues_K##B(E1)) + #else + #define SEND_PID_INFO_1(A, B) SEND_NA(A) + #endif + #if ENABLED(PIDTEMPBED) + #define SEND_PID_INFO_BED(A, B) SEND_VALasTXT(A, getBedPIDValues_K##B()) + #else + #define SEND_PID_INFO_BED(A, B) SEND_NA(A) + #endif + SEND_PID_INFO_0("p0", p); + SEND_PID_INFO_0("i0", i); + SEND_PID_INFO_0("d0", d); + + SEND_PID_INFO_1("p1", p); + SEND_PID_INFO_1("i1", i); + SEND_PID_INFO_1("d1", d); + + SEND_PID_INFO_BED("hbp", p); + SEND_PID_INFO_BED("hbi", i); + SEND_PID_INFO_BED("hbd", d); + break; + } +} + +void NextionTFT::PanelAction(uint8_t req) { + switch (req) { + + case 50: // Pause SD print + //if (isPrintingFromMedia()) { + //SEND_TXT("tmppage.M117", "Paused"); + pausePrint(); + SEND_TXT_END("qpause.picc=29"); + //} + break; + + case 51: // Resume SD Print + resumePrint(); + SEND_TXT_END("qpause.picc=28"); + break; + + case 52: // Stop SD print + //if (isPrintingFromMedia()) { + stopPrint(); + SEND_TXT_END("page prepare"); + //} + break; + + case 54: // A13 Select file + SelectFile(); + break; + + case 65: // Cool Down + if (!isPrinting()) coolDown(); + break; + + case 66: // Refresh SD + if (!isPrinting()) { + injectCommands_P(PSTR("M21")); + filenavigator.reset(); + } + break; + + case 56: // Set Fan, Flow, Print Speed + switch (nextion_command[4]) { + case 'S': setTargetFan_percent(atof(&nextion_command[5]), FAN0); break; + case 'P': setFeedrate_percent(atoi(&nextion_command[5])); break; + case 'F': setFlow_percent(atoi(&nextion_command[5]), getActiveTool()); break; + } + break; + + case 57: // Disable Motors + if (!isPrinting()) { + disable_all_steppers(); // from marlincore.h + SEND_TXT("tmppage.M117", "Motors disabled"); + } + break; + + case 58: // Load/Unload Filament + #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) + if (canMove(getActiveTool())) { + switch (nextion_command[4]) { + case 'L': injectCommands_P(PSTR("M701")); break; + case 'U': injectCommands_P(PSTR("M702")); break; + } + } + else { + SEND_TXT("tmppage.M117", "Preheat first"); + SEND_TXT_END("page preheat"); + } + #else + SEND_TXT("tmppage.M117", "Filament loading disabled"); + #endif + break; + + case 63: // Preheat // Temps defined in configuration.h + #if PREHEAT_COUNT + if (!isPrinting()) switch (nextion_command[4]) { + // Preheat PLA + case 'P': + #if HAS_HEATED_BED + setTargetTemp_celsius(getMaterial_preset_B(0), BED); + #endif + setTargetTemp_celsius(getMaterial_preset_E(0), getActiveTool()); + break; + + // Preheat ABS + case 'A': + #if HAS_HEATED_BED + setTargetTemp_celsius(getMaterial_preset_B(1), BED); + #endif + setTargetTemp_celsius(getMaterial_preset_E(1), getActiveTool()); + break; + + // Preheat PETG + case 'G': + #if HAS_HEATED_BED + setTargetTemp_celsius(getMaterial_preset_B(2), BED); + #endif + setTargetTemp_celsius(getMaterial_preset_E(2), getActiveTool()); + break; + } + #else + SEND_TXT("tmppage.M117", "Preheat disabled"); + #endif + break; + } +} + +void NextionTFT::UpdateOnChange() { + const millis_t ms = millis(); + static millis_t next_event_ms = 0; + // tmppage Temperature + if (!WITHIN(last_degHotend0 - getActualTemp_celsius(E0), -0.2, 0.2) || !WITHIN(last_degTargetHotend0 - getTargetTemp_celsius(E0), -0.5, 0.5)) { + SEND_TEMP("tmppage.t0", ui8tostr3rj(getActualTemp_celsius(E0)), " / ", ui8tostr3rj(getTargetTemp_celsius(E0))); + last_degHotend0 = getActualTemp_celsius(E0); + last_degTargetHotend0 = getTargetTemp_celsius(E0); + } + + if (!WITHIN(last_degHotend1 - getActualTemp_celsius(E1), -0.2, 0.2) || !WITHIN(last_degTargetHotend1 - getTargetTemp_celsius(E1), -0.5, 0.5)) { + SEND_TEMP("tmppage.t1", ui8tostr3rj(getActualTemp_celsius(E1)), " / ", ui8tostr3rj(getTargetTemp_celsius(E1))); + last_degHotend1 = getActualTemp_celsius(E1); + last_degTargetHotend1 = getTargetTemp_celsius(E1); + } + + if (!WITHIN(last_degBed - getActualTemp_celsius(BED), -0.2, 0.2) || !WITHIN(last_degTargetBed - getTargetTemp_celsius(BED), -0.5, 0.5)) { + SEND_TEMP("tmppage.t2", ui8tostr3rj(getActualTemp_celsius(BED)), " / ", ui8tostr3rj(getTargetTemp_celsius(BED))); + last_degBed = getActualTemp_celsius(BED); + last_degTargetBed = getTargetTemp_celsius(BED); + } + + // tmppage Tool + if (last_active_extruder != getActiveTool()) { + SEND_VALasTXT("tmppage.tool", getActiveTool()); + last_active_extruder = getActiveTool(); + } + + // tmppage Fan Speed + if (last_fan_speed != getActualFan_percent(FAN0)) { + SEND_VALasTXT("tmppage.fan", ui8tostr3rj(getActualFan_percent(FAN0))); + last_fan_speed = getActualFan_percent(FAN0); + } + + // tmppage Print Speed + if (last_print_speed != getFeedrate_percent()) { + SEND_VALasTXT("tmppage.speed", ui8tostr3rj(getFeedrate_percent())); + last_print_speed = getFeedrate_percent(); + } + + // tmppage Flow + if (last_flow_speed != getFlowPercentage(getActiveTool())) { + SEND_VALasTXT("tmppage.flow", getFlowPercentage(getActiveTool())); + last_flow_speed = getFlowPercentage(getActiveTool()); + } + + // tmppage Progress + Layer + Time + if (isPrinting()) { + + if (ELAPSED(ms, next_event_ms)) { + next_event_ms = ms + 1000; + #if ENABLED(SHOW_REMAINING_TIME) + const uint32_t remaining = getProgress_seconds_remaining(); + char remaining_str[10]; + _format_time(remaining_str, remaining); + SEND_VALasTXT("tmppage.remaining", remaining_str); + #endif + const uint32_t elapsed = getProgress_seconds_elapsed(); + char elapsed_str[10]; + _format_time(elapsed_str, elapsed); + SEND_VALasTXT("tmppage.elapsed", elapsed_str); + } + + if (last_progress != getProgress_percent()) { + SEND_VALasTXT("tmppage.progress", ui8tostr3rj(getProgress_percent())); + last_progress = getProgress_percent(); + } + + if (last_get_axis_position_mmZ < getAxisPosition_mm(Z)) { + layer++; + SEND_VALasTXT("tmppage.layer", layer); + } + + if (last_get_axis_position_mmZ > getAxisPosition_mm(Z)) { + layer--; + SEND_VALasTXT("tmppage.layer", layer); + } + } + + // tmppage Axis + if (!WITHIN(last_get_axis_position_mmX - getAxisPosition_mm(X), -0.1, 0.1)) { + if (ELAPSED(ms, next_event_ms)) { + next_event_ms = ms + 30; + SEND_VALasTXT("tmppage.x", getAxisPosition_mm(X)); + last_get_axis_position_mmX = getAxisPosition_mm(X); + } + } + + if (!WITHIN(last_get_axis_position_mmY - getAxisPosition_mm(Y), -0.1, 0.1)) { + if (ELAPSED(ms, next_event_ms)) { + next_event_ms = ms + 30; + SEND_VALasTXT("tmppage.y", getAxisPosition_mm(Y)); + last_get_axis_position_mmY = getAxisPosition_mm(Y); + } + } + + if (!WITHIN(last_get_axis_position_mmZ - getAxisPosition_mm(Z), -0.1, 0.1)) { + SEND_VALasTXT("tmppage.z", getAxisPosition_mm(Z)); + last_get_axis_position_mmZ = getAxisPosition_mm(Z); + } + + // tmppage homed + if (last_homed != isPositionKnown()) { + SEND_VAL("tmppage.homed", isPositionKnown()); + last_homed = isPositionKnown(); + } + if (last_homedX != isAxisPositionKnown(X)) { + SEND_VAL("tmppage.homedx", isAxisPositionKnown(X)); + last_homedX = isAxisPositionKnown(X); + } + if (last_homedY != isAxisPositionKnown(Y)) { + SEND_VAL("tmppage.homedy", isAxisPositionKnown(Y)); + last_homedY = isAxisPositionKnown(Y); + } + if (last_homedZ != isAxisPositionKnown(Z)) { + SEND_VAL("tmppage.homedz", isAxisPositionKnown(Z)); + last_homedZ = isAxisPositionKnown(Z); + } + + // tmppage IDEX Mode + #if ENABLED(DUAL_X_CARRIAGE) + if (last_IDEX_Mode != getIDEX_Mode()) { + SEND_VAL("tmppage.idexmode", getIDEX_Mode()); + last_IDEX_Mode = getIDEX_Mode(); + } + #endif +} + +#endif // NEXTION_TFT diff --git a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.h b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.h new file mode 100644 index 0000000000..9197fcc2c6 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.h @@ -0,0 +1,62 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/* **************************************** + * lcd/extui/lib/nextion/nextion_tft.h + * **************************************** + * Extensible_UI implementation for Nextion + * https://github.com/Skorpi08 + * ***************************************/ + +#include "nextion_tft_defs.h" +#include "../../../../inc/MarlinConfigPre.h" +#include "../../ui_api.h" + +class NextionTFT { + private: + static uint8_t command_len; + static char nextion_command[MAX_CMND_LEN]; + static char selectedfile[MAX_PATH_LEN]; + + public: + NextionTFT(); + static void Startup(); + static void IdleLoop(); + static void PrinterKilled(PGM_P, PGM_P); + static void ConfirmationRequest(const char * const ); + static void StatusChange(const char * const ); + static void SendtoTFT(PGM_P); + static void UpdateOnChange(); + static void PrintFinished(); + static void PanelInfo(uint8_t); + + private: + static bool ReadTFTCommand(); + static void SendFileList(int8_t); + static void SelectFile(); + static void ProcessPanelRequest(); + static void PanelAction(uint8_t); + static void _format_time(char *, uint32_t); +}; + +extern NextionTFT nextion; diff --git a/Marlin/src/lcd/extui/lib/nextion/nextion_tft_defs.h b/Marlin/src/lcd/extui/lib/nextion/nextion_tft_defs.h new file mode 100644 index 0000000000..75f70fc985 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/nextion/nextion_tft_defs.h @@ -0,0 +1,63 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/* **************************************** + * lcd/extui/lib/nextion/nextion_tft_defs.h + * **************************************** + * Extensible_UI implementation for Nextion + * https://github.com/Skorpi08 + * ***************************************/ + +#include "../../../../inc/MarlinConfigPre.h" + +//#define NEXDEBUGLEVEL 255 +#if NEXDEBUGLEVEL + // Bit-masks for selective debug: + enum NexDebugMask : uint8_t { + N_INFO = _BV(0), + N_ACTION = _BV(1), + N_FILE = _BV(2), + N_PANEL = _BV(3), + N_MARLIN = _BV(4), + N_SOME = _BV(5), + N_ALL = _BV(6) + }; + #define NEXDEBUG(M) (((M) & NEXDEBUGLEVEL) == M) // Debug flag macro +#else + #define NEXDEBUG(M) false +#endif + +#define MAX_FOLDER_DEPTH 4 // Limit folder depth TFT has a limit for the file path +#define MAX_CMND_LEN 16 * MAX_FOLDER_DEPTH // Maximum Length for a Panel command +#define MAX_PATH_LEN 16 * MAX_FOLDER_DEPTH // Maximum number of characters in a SD file path + + // TFT panel commands +#define msg_welcome MACHINE_NAME " Ready." + +#define SEND_TEMP(x,y,t,z) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(PSTR(t)), LCD_SERIAL.print(z), nextion.SendtoTFT(PSTR("\"\xFF\xFF\xFF"))) +#define SEND_VAL(x,y) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".val=")), LCD_SERIAL.print(y), nextion.SendtoTFT(PSTR("\xFF\xFF\xFF"))) +#define SEND_TXT(x,y) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".txt=\"")), nextion.SendtoTFT(PSTR(y)), nextion.SendtoTFT(PSTR("\"\xFF\xFF\xFF"))) +#define SEND_TXT_P(x,y) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".txt=\"")), nextion.SendtoTFT(y), nextion.SendtoTFT(PSTR("\"\xFF\xFF\xFF"))) +#define SEND_VALasTXT(x,y) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(PSTR("\"\xFF\xFF\xFF"))) +#define SEND_TXT_END(x) (nextion.SendtoTFT(PSTR(x)), nextion.SendtoTFT(PSTR("\xFF\xFF\xFF"))) +#define SEND_PCO2(x,y,z) (nextion.SendtoTFT(PSTR(x)), LCD_SERIAL.print(y), nextion.SendtoTFT(PSTR(".pco=")), nextion.SendtoTFT(PSTR(z)), nextion.SendtoTFT(PSTR("\xFF\xFF\xFF"))) diff --git a/Marlin/src/lcd/extui/nextion_lcd.cpp b/Marlin/src/lcd/extui/nextion_lcd.cpp new file mode 100644 index 0000000000..fa45f4ef51 --- /dev/null +++ b/Marlin/src/lcd/extui/nextion_lcd.cpp @@ -0,0 +1,117 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * lcd/extui/nextion_lcd.cpp + * + * Nextion TFT support for Marlin + */ + +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(NEXTION_TFT) + +#include "ui_api.h" +#include "lib/nextion/nextion_tft.h" + +namespace ExtUI { + + void onStartup() { nextion.Startup(); } + void onIdle() { nextion.IdleLoop(); } + void onPrinterKilled(PGM_P const error, PGM_P const component) { nextion.PrinterKilled(error,component); } + void onMediaInserted() {} + void onMediaError() {} + void onMediaRemoved() {} + void onPlayTone(const uint16_t frequency, const uint16_t duration) {} + void onPrintTimerStarted() {} + void onPrintTimerPaused() {} + void onPrintTimerStopped() {} + void onFilamentRunout(const extruder_t) {} + void onUserConfirmRequired(const char * const msg) { nextion.ConfirmationRequest(msg); } + void onStatusChanged(const char * const msg) { nextion.StatusChange(msg); } + + void onHomingStart() {} + void onHomingComplete() {} + void onPrintFinished() { nextion.PrintFinished(); } + + void onFactoryReset() {} + + void onStoreSettings(char *buff) { + // Called when saving to EEPROM (i.e. M500). If the ExtUI needs + // permanent data to be stored, it can write up to eeprom_data_size bytes + // into buff. + + // Example: + // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // memcpy(buff, &myDataStruct, sizeof(myDataStruct)); + } + + void onLoadSettings(const char *buff) { + // Called while loading settings from EEPROM. If the ExtUI + // needs to retrieve data, it should copy up to eeprom_data_size bytes + // from buff + + // Example: + // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); + } + + void onConfigurationStoreWritten(bool success) { + // Called after the entire EEPROM has been written, + // whether successful or not. + } + + void onConfigurationStoreRead(bool success) { + // Called after the entire EEPROM has been read, + // whether successful or not. + } + + #if HAS_MESH + void onMeshLevelingStart() {} + + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + // Called when any mesh points are updated + } + + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) { + // Called to indicate a special condition + } + #endif + + #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLossResume() { + // Called on resume from power-loss + } + #endif + + #if HAS_PID_HEATING + void onPidTuning(const result_t rst) { + // Called for temperature PID tuning result + nextion.PanelInfo(37); + } + #endif + + void onSteppersDisabled() {} + void onSteppersEnabled() {} +} + +#endif // NEXTION_TFT diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 97d4ec2b08..73e5bc092d 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -651,6 +651,17 @@ namespace ExtUI { void setAxisMaxJerk_mm_s(const float &value, const extruder_t) { planner.set_max_jerk(E_AXIS, value); } #endif + #if ENABLED(DUAL_X_CARRIAGE) + uint8_t getIDEX_Mode() { return dual_x_carriage_mode; } + #endif + + #if PREHEAT_COUNT + uint16_t getMaterial_preset_E(const uint16_t index) { return ui.material_preset[index].hotend_temp; } + #if HAS_HEATED_BED + uint16_t getMaterial_preset_B(const uint16_t index) { return ui.material_preset[index].bed_temp; } + #endif + #endif + feedRate_t getFeedrate_mm_s() { return feedrate_mm_s; } int16_t getFlowPercentage(const extruder_t extr) { return planner.flow_percentage[extr]; } feedRate_t getMinFeedrate_mm_s() { return planner.settings.min_feedrate_mm_s; } @@ -663,8 +674,8 @@ namespace ExtUI { void setMinFeedrate_mm_s(const feedRate_t fr) { planner.settings.min_feedrate_mm_s = fr; } void setMinTravelFeedrate_mm_s(const feedRate_t fr) { planner.settings.min_travel_feedrate_mm_s = fr; } void setPrintingAcceleration_mm_s2(const float &acc) { planner.settings.acceleration = acc; } - void setRetractAcceleration_mm_s2(const float &acc) { planner.settings.retract_acceleration = acc; } - void setTravelAcceleration_mm_s2(const float &acc) { planner.settings.travel_acceleration = acc; } + void setRetractAcceleration_mm_s2(const float &acc) { planner.settings.retract_acceleration = acc; } + void setTravelAcceleration_mm_s2(const float &acc) { planner.settings.travel_acceleration = acc; } #if ENABLED(BABYSTEPPING) diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 701bf9eb54..380d311517 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -139,6 +139,17 @@ namespace ExtUI { uint32_t getProgress_seconds_elapsed(); + #if PREHEAT_COUNT + uint16_t getMaterial_preset_E(const uint16_t); + #if HAS_HEATED_BED + uint16_t getMaterial_preset_B(const uint16_t); + #endif + #endif + + #if ENABLED(DUAL_X_CARRIAGE) + uint8_t getIDEX_Mode(); + #endif + #if ENABLED(SHOW_REMAINING_TIME) inline uint32_t getProgress_seconds_remaining() { return ui.get_remaining_time(); } #endif @@ -171,6 +182,7 @@ namespace ExtUI { #endif #if ENABLED(PRINTCOUNTER) + char* getFailedPrints_str(char buffer[21]); char* getTotalPrints_str(char buffer[21]); char* getFinishedPrints_str(char buffer[21]); char* getTotalPrintTime_str(char buffer[21]); diff --git a/platformio.ini b/platformio.ini index 11dcecfc99..941426d732 100644 --- a/platformio.ini +++ b/platformio.ini @@ -59,6 +59,7 @@ default_src_filter = + - - + - - - - - + - - - - - - @@ -289,6 +290,7 @@ HAS_MENU_TRAMMING = src_filter=+ HAS_MENU_UBL = src_filter=+ ANYCUBIC_LCD_CHIRON = src_filter=+ + ANYCUBIC_LCD_I3MEGA = src_filter=+ + +NEXTION_TFT = src_filter=+ + HAS_DGUS_LCD = src_filter=+ + DGUS_LCD_UI_FYSETC = src_filter=+ DGUS_LCD_UI_HIPRECY = src_filter=+ From 790bba155639cff44ca950639f4d685c16998bf5 Mon Sep 17 00:00:00 2001 From: ellensp Date: Fri, 19 Mar 2021 18:05:30 +1300 Subject: [PATCH 070/311] Fix preflight motherboard target check (#21372) Co-authored-by: Scott Lahteine --- .../PlatformIO/scripts/preflight-checks.py | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 4499c2bfdc..2ad1562a31 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -5,8 +5,18 @@ import os,re,sys Import("env") -def get_envs_for_board(board, envregex): +def get_envs_for_board(board): with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file: + + if sys.platform == 'win32': + envregex = r"(?:env|win):" + elif sys.platform == 'darwin': + envregex = r"(?:env|mac|uni):" + elif sys.platform == 'linux': + envregex = r"(?:env|lin|uni):" + else: + envregex = r"(?:env):" + r = re.compile(r"if\s+MB\((.+)\)") if board.startswith("BOARD_"): board = board[6:] @@ -17,7 +27,8 @@ def get_envs_for_board(board, envregex): line = file.readline() found_envs = re.match(r"\s*#include .+" + envregex, line) if found_envs: - return re.findall(envregex + r"(\w+)", line) + envlist = re.findall(envregex + r"(\w+)", line) + return [ "env:"+s for s in envlist ] return [] def check_envs(build_env, board_envs, config): @@ -43,24 +54,15 @@ if 'MARLIN_FEATURES' not in env: if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") -if sys.platform == 'win32': - osregex = r"(?:env|win):" -elif sys.platform == 'darwin': - osregex = r"(?:env|mac|uni):" -elif sys.platform == 'linux': - osregex = r"(?:env|lin|uni):" -else: - osregex = r"(?:env):" - build_env = env['PIOENV'] motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] -board_envs = get_envs_for_board(motherboard, osregex) +board_envs = get_envs_for_board(motherboard) config = env.GetProjectConfig() -result = check_envs(build_env, board_envs, config) +result = check_envs("env:"+build_env, board_envs, config) if not result: err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ - (build_env, motherboard, ",".join([e[4:] for e in board_envs if re.match(r"^" + osregex, e)])) + ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) raise SystemExit(err) # From d4ab2024f50152f06223c3ab63a7a93b95b4b887 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 18 Mar 2021 15:59:48 -0500 Subject: [PATCH 071/311] Fix bool++ warning --- Marlin/src/feature/encoder_i2c.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index cf5ebfd012..abaa93f767 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -47,7 +47,7 @@ void I2CPositionEncoder::init(const uint8_t address, const AxisEnum axis) { encoderAxis = axis; i2cAddress = address; - initialized++; + initialized = true; SERIAL_ECHOLNPAIR("Setting up encoder on ", AS_CHAR(axis_codes[encoderAxis]), " axis, addr = ", address); @@ -209,8 +209,7 @@ void I2CPositionEncoder::set_homed() { delay(10); zeroOffset = get_raw_count(); - homed++; - trusted++; + homed = trusted = true; #ifdef I2CPE_DEBUG SERIAL_CHAR(axis_codes[encoderAxis]); From 38b44e3fc9cb96866f9c25058667888ae43cfc0c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Mar 2021 23:55:55 -0500 Subject: [PATCH 072/311] HAL eeprom cleanup --- Marlin/src/HAL/STM32F1/eeprom_if_iic.cpp | 2 +- Marlin/src/HAL/shared/eeprom_if.h | 2 +- Marlin/src/HAL/shared/eeprom_if_i2c.cpp | 17 ++++--- Marlin/src/HAL/shared/eeprom_if_spi.cpp | 57 +++++++++++------------- 4 files changed, 37 insertions(+), 41 deletions(-) diff --git a/Marlin/src/HAL/STM32F1/eeprom_if_iic.cpp b/Marlin/src/HAL/STM32F1/eeprom_if_iic.cpp index ccc3fc537f..78b7af0b04 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_if_iic.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_if_iic.cpp @@ -40,7 +40,7 @@ void eeprom_init() { BL24CXX::init(); } // Public functions // ------------------------ -void eeprom_write_byte(uint8_t *pos, unsigned char value) { +void eeprom_write_byte(uint8_t *pos, uint8_t value) { const unsigned eeprom_address = (unsigned)pos; return BL24CXX::writeOneByte(eeprom_address, value); } diff --git a/Marlin/src/HAL/shared/eeprom_if.h b/Marlin/src/HAL/shared/eeprom_if.h index e44da801df..e496de2a03 100644 --- a/Marlin/src/HAL/shared/eeprom_if.h +++ b/Marlin/src/HAL/shared/eeprom_if.h @@ -25,5 +25,5 @@ // EEPROM // void eeprom_init(); -void eeprom_write_byte(uint8_t *pos, unsigned char value); +void eeprom_write_byte(uint8_t *pos, uint8_t value); uint8_t eeprom_read_byte(uint8_t *pos); diff --git a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp index da70af2772..f6dd33b7c4 100644 --- a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp +++ b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp @@ -55,12 +55,15 @@ static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRE // Public functions // ------------------------ -void eeprom_write_byte(uint8_t *pos, unsigned char value) { +static void _eeprom_begin(uint8_t * const pos) { const unsigned eeprom_address = (unsigned)pos; - Wire.beginTransmission(eeprom_device_address); - Wire.write(int(eeprom_address >> 8)); // MSB - Wire.write(int(eeprom_address & 0xFF)); // LSB + Wire.write(int(eeprom_address >> 8)); // Address High + Wire.write(int(eeprom_address & 0xFF)); // Address Low +} + +void eeprom_write_byte(uint8_t *pos, uint8_t value) { + _eeprom_begin(pos); Wire.write(value); Wire.endTransmission(); @@ -70,11 +73,7 @@ void eeprom_write_byte(uint8_t *pos, unsigned char value) { } uint8_t eeprom_read_byte(uint8_t *pos) { - const unsigned eeprom_address = (unsigned)pos; - - Wire.beginTransmission(eeprom_device_address); - Wire.write(int(eeprom_address >> 8)); // MSB - Wire.write(int(eeprom_address & 0xFF)); // LSB + _eeprom_begin(pos); Wire.endTransmission(); Wire.requestFrom(eeprom_device_address, (byte)1); return Wire.available() ? Wire.read() : 0xFF; diff --git a/Marlin/src/HAL/shared/eeprom_if_spi.cpp b/Marlin/src/HAL/shared/eeprom_if_spi.cpp index a341fef9de..e162f6fedc 100644 --- a/Marlin/src/HAL/shared/eeprom_if_spi.cpp +++ b/Marlin/src/HAL/shared/eeprom_if_spi.cpp @@ -43,44 +43,41 @@ void eeprom_init() {} #define EEPROM_WRITE_DELAY 7 #endif -uint8_t eeprom_read_byte(uint8_t* pos) { - uint8_t v; - uint8_t eeprom_temp[3]; - - // set read location - // begin transmission from device - eeprom_temp[0] = CMD_READ; - eeprom_temp[1] = ((unsigned)pos>>8) & 0xFF; // addr High - eeprom_temp[2] = (unsigned)pos& 0xFF; // addr Low - WRITE(SPI_EEPROM1_CS, HIGH); - WRITE(SPI_EEPROM1_CS, LOW); +static void _eeprom_begin(uint8_t * const pos, const uint8_t cmd) { + const uint8_t eeprom_temp[3] = { + cmd, + (unsigned(pos) >> 8) & 0xFF, // Address High + unsigned(pos) & 0xFF // Address Low + }; + WRITE(SPI_EEPROM1_CS, HIGH); // Usually free already + WRITE(SPI_EEPROM1_CS, LOW); // Activate the Bus spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 3); + // Leave the Bus in-use +} + +uint8_t eeprom_read_byte(uint8_t* pos) { + _eeprom_begin(pos, CMD_READ); // Set read location and begin transmission + + const uint8_t v = spiRec(SPI_CHAN_EEPROM1); // After READ a value sits on the Bus + + WRITE(SPI_EEPROM1_CS, HIGH); // Done with device - v = spiRec(SPI_CHAN_EEPROM1); - WRITE(SPI_EEPROM1_CS, HIGH); return v; } -void eeprom_write_byte(uint8_t* pos, uint8_t value) { - uint8_t eeprom_temp[3]; - - /*write enable*/ - eeprom_temp[0] = CMD_WREN; +void eeprom_write_byte(uint8_t *pos, uint8_t value) { + const uint8_t eeprom_temp = CMD_WREN; WRITE(SPI_EEPROM1_CS, LOW); - spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 1); - WRITE(SPI_EEPROM1_CS, HIGH); - delay(1); + spiSend(SPI_CHAN_EEPROM1, &eeprom_temp, 1); // Write Enable - /*write addr*/ - eeprom_temp[0] = CMD_WRITE; - eeprom_temp[1] = ((unsigned)pos>>8) & 0xFF; //addr High - eeprom_temp[2] = (unsigned)pos & 0xFF; //addr Low - WRITE(SPI_EEPROM1_CS, LOW); - spiSend(SPI_CHAN_EEPROM1, eeprom_temp, 3); + WRITE(SPI_EEPROM1_CS, HIGH); // Done with the Bus + delay(1); // For a small amount of time - spiSend(SPI_CHAN_EEPROM1, value); - WRITE(SPI_EEPROM1_CS, HIGH); - delay(EEPROM_WRITE_DELAY); // wait for page write to complete + _eeprom_begin(pos, CMD_WRITE); // Set write address and begin transmission + + spiSend(SPI_CHAN_EEPROM1, value); // Send the value to be written + WRITE(SPI_EEPROM1_CS, HIGH); // Done with the Bus + delay(EEPROM_WRITE_DELAY); // Give page write time to complete } #endif // USE_SHARED_EEPROM From 5573d98ecca3d721b9fe6259dcab96783416ce5a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 20 Mar 2021 00:13:15 +0000 Subject: [PATCH 073/311] [cron] Bump distribution date (2021-03-20) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 4839037c0e..6d14c41121 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-03-19" + #define STRING_DISTRIBUTION_DATE "2021-03-20" #endif /** From d0ea2b286739379ff2524ecc1c8dcbb057e98c0b Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 21 Mar 2021 00:14:12 +0000 Subject: [PATCH 074/311] [cron] Bump distribution date (2021-03-21) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 6d14c41121..f23171ff77 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-03-20" + #define STRING_DISTRIBUTION_DATE "2021-03-21" #endif /** From fb9502e0fbb1e6114da1f1f9a18f69e457d95fab Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 22 Mar 2021 00:13:40 +0000 Subject: [PATCH 075/311] [cron] Bump distribution date (2021-03-22) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index f23171ff77..3f812d9143 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-03-21" + #define STRING_DISTRIBUTION_DATE "2021-03-22" #endif /** From 26db51fa9ddee1c99d62c36322b7cfb3aab68483 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 23 Mar 2021 00:13:33 +0000 Subject: [PATCH 076/311] [cron] Bump distribution date (2021-03-23) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 3f812d9143..2f91dfd927 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-03-22" + #define STRING_DISTRIBUTION_DATE "2021-03-23" #endif /** From 3e7d830f570ece878f18732072de1b34156cdd66 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Mon, 22 Mar 2021 23:51:03 -0600 Subject: [PATCH 077/311] Mesh Editor for FTDI Eve Touch UI (#21381) --- .../ftdi_eve_lib/extended/grid_layout.h | 13 +++ .../ftdi_eve_lib/extras/adjuster_widget.cpp | 54 +++++++++ .../ftdi_eve_lib/extras/adjuster_widget.h | 32 ++++++ .../ftdi_eve_touch_ui/language/language_en.h | 1 - .../screens/bed_mesh_screen.cpp | 103 ++++++++++++------ .../screens/bed_mesh_screen.h | 15 ++- .../screens/leveling_menu.cpp | 8 +- Marlin/src/lcd/extui/ui_api.cpp | 20 ++++ Marlin/src/lcd/extui/ui_api.h | 1 + 9 files changed, 205 insertions(+), 42 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h index 82bb8abf7f..47aec24d83 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/grid_layout.h @@ -87,6 +87,19 @@ cmd.cmd(LINE_WIDTH(16)); \ } +// Routines for subdividing a grid within a box (x,y,w,h) + +#define SUB_GRID_W(W) ((W)*w/SUB_COLS) +#define SUB_GRID_H(H) ((H)*h/SUB_ROWS) +#define SUB_GRID_X(X) (SUB_GRID_W((X)-1) + x) +#define SUB_GRID_Y(Y) (SUB_GRID_H((Y)-1) + y) +#define SUB_X(X) (SUB_GRID_X(X) + MARGIN_L) +#define SUB_Y(Y) (SUB_GRID_Y(Y) + MARGIN_T) +#define SUB_W(W) (SUB_GRID_W(W) - MARGIN_L - MARGIN_R) +#define SUB_H(H) (SUB_GRID_H(H) - MARGIN_T - MARGIN_B) +#define SUB_POS(X,Y) SUB_X(X), SUB_Y(Y) +#define SUB_SIZE(W,H) SUB_W(W), SUB_H(H) + namespace FTDI { #if ENABLED(TOUCH_UI_PORTRAIT) constexpr uint16_t display_width = Vsize; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp new file mode 100644 index 0000000000..084c9c014f --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp @@ -0,0 +1,54 @@ +/*********************** + * adjuster_widget.cpp * + ***********************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2021 - 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: . * + ****************************************************************************/ + +#include "../ftdi_eve_lib.h" +#include "../extended/grid_layout.h" + +#include "adjuster_widget.h" + +#define SUB_COLS 9 +#define SUB_ROWS 1 +#define VAL_POS SUB_POS(1,1), SUB_SIZE(5,1) +#define INC_POS SUB_POS(6,1), SUB_SIZE(2,1) +#define DEC_POS SUB_POS(8,1), SUB_SIZE(2,1) + +void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) { + if (what & BACKGROUND) + cmd.tag(0).button(VAL_POS, F(""), FTDI::OPT_FLAT); + + if (what & FOREGROUND) { + char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)]; + if (isnan(value)) + strcpy_P(str, PSTR("-")); + else + dtostrf(value, width, precision, str); + + if (units) { + strcat_P(str, PSTR(" ")); + strcat_P(str, (const char*) units); + } + + cmd.tag(0) + .text(VAL_POS, str) + .tag(tag ).button(INC_POS, F("-")) + .tag(tag+1).button(DEC_POS, F("+")); + } +} diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h new file mode 100644 index 0000000000..c48e37f620 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h @@ -0,0 +1,32 @@ +/********************* + * adjuster_widget.h * + *********************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2021 - 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 +#include "../extended/screen_types.h" + +void draw_adjuster( + CommandProcessor& cmd, + int16_t x, int16_t y, int16_t w, int16_t h, + uint8_t tag, + float value, progmem_str units = nullptr, + int8_t width = 5, uint8_t precision = 1, + draw_mode_t what = BOTH +); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h index e57858aa3f..f6603e514a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h @@ -144,7 +144,6 @@ namespace Language_en { PROGMEM Language_Str MSG_BED_MAPPING_DONE = u8"Bed mapping finished"; PROGMEM Language_Str MSG_BED_MAPPING_INCOMPLETE = u8"Not all points probed"; PROGMEM Language_Str MSG_LEVELING = u8"Leveling"; - PROGMEM Language_Str MSG_SHOW_MESH = u8"Show Bed Mesh"; #if ENABLED(TOUCH_UI_LULZBOT_BIO) PROGMEM Language_Str MSG_MOVE_TO_HOME = u8"Move to Home"; 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 6de573da8c..c87329ebe2 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 @@ -25,21 +25,24 @@ #ifdef FTDI_BED_MESH_SCREEN +#include "../ftdi_eve_lib/extras/adjuster_widget.h" + using namespace FTDI; using namespace Theme; using namespace ExtUI; constexpr static BedMeshScreenData &mydata = screen_data.BedMeshScreen; +constexpr static float gaugeThickness = 0.25; #if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_COLS 2 + #define GRID_COLS 3 #define GRID_ROWS 10 - #define MESH_POS BTN_POS(1, 2), BTN_SIZE(2,5) - #define MESSAGE_POS BTN_POS(1, 7), BTN_SIZE(2,1) + #define MESH_POS BTN_POS(1, 2), BTN_SIZE(3,5) + #define MESSAGE_POS BTN_POS(1, 7), BTN_SIZE(3,1) #define Z_LABEL_POS BTN_POS(1, 8), BTN_SIZE(1,1) - #define Z_VALUE_POS BTN_POS(2, 8), BTN_SIZE(1,1) - #define OKAY_POS BTN_POS(1,10), BTN_SIZE(2,1) + #define Z_VALUE_POS BTN_POS(2, 8), BTN_SIZE(2,1) + #define OKAY_POS BTN_POS(1,10), BTN_SIZE(3,1) #else #define GRID_COLS 5 #define GRID_ROWS 5 @@ -198,12 +201,12 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI:: if (opts & USE_HIGHLIGHT) { const uint8_t tag = mydata.highlightedTag; - uint8_t x, y; - if (tagToPoint(tag, x, y)) { + xy_uint8_t pt; + if (tagToPoint(tag, pt)) { cmd.cmd(COLOR_A(128)) .cmd(POINT_SIZE(basePointSize * 6)) .cmd(BEGIN(POINTS)) - .tag(tag).cmd(VERTEX2F(TRANSFORM(x, y, HEIGHT(x, y)))); + .tag(tag).cmd(VERTEX2F(TRANSFORM(pt.x, pt.y, HEIGHT(pt.x, pt.y)))); } } cmd.cmd(END()); @@ -214,43 +217,68 @@ uint8_t BedMeshScreen::pointToTag(uint8_t x, uint8_t y) { return y * (GRID_MAX_POINTS_X) + x + 10; } -bool BedMeshScreen::tagToPoint(uint8_t tag, uint8_t &x, uint8_t &y) { +bool BedMeshScreen::tagToPoint(uint8_t tag, xy_uint8_t &pt) { if (tag < 10) return false; - x = (tag - 10) % (GRID_MAX_POINTS_X); - y = (tag - 10) / (GRID_MAX_POINTS_X); + pt.x = (tag - 10) % (GRID_MAX_POINTS_X); + pt.y = (tag - 10) / (GRID_MAX_POINTS_X); return true; } void BedMeshScreen::onEntry() { mydata.highlightedTag = 0; + mydata.zAdjustment = 0; mydata.count = GRID_MAX_POINTS; mydata.message = mydata.MSG_NONE; BaseScreen::onEntry(); } -float BedMeshScreen::getHightlightedValue() { - if (mydata.highlightedTag) { - xy_uint8_t pt; - tagToPoint(mydata.highlightedTag, pt.x, pt.y); - return ExtUI::getMeshPoint(pt); +float BedMeshScreen::getHighlightedValue(bool nanAsZero) { + xy_uint8_t pt; + if (tagToPoint(mydata.highlightedTag, pt)) { + const float val = ExtUI::getMeshPoint(pt); + return (isnan(val) && nanAsZero) ? 0 : val; } return NAN; } -void BedMeshScreen::drawHighlightedPointValue() { - char str[16]; - const float val = getHightlightedValue(); - const bool isGood = !isnan(val); - if (isGood) - dtostrf(val, 5, 3, str); - else - strcpy_P(str, PSTR("-")); +void BedMeshScreen::setHighlightedValue(float value) { + xy_uint8_t pt; + if (tagToPoint(mydata.highlightedTag, pt)) + ExtUI::setMeshPoint(pt, value); +} +void BedMeshScreen::moveToHighlightedValue() { + xy_uint8_t pt; + if (tagToPoint(mydata.highlightedTag, pt)) + ExtUI::moveToMeshPoint(pt, gaugeThickness + mydata.zAdjustment); +} + +void BedMeshScreen::adjustHighlightedValue(float increment) { + mydata.zAdjustment += increment; + moveToHighlightedValue(); +} + +void BedMeshScreen::saveAdjustedHighlightedValue() { + if(mydata.zAdjustment) { + BedMeshScreen::setHighlightedValue(BedMeshScreen::getHighlightedValue(true) + mydata.zAdjustment); + mydata.zAdjustment = 0; + } +} + +void BedMeshScreen::changeHighlightedValue(uint8_t tag) { + saveAdjustedHighlightedValue(); + mydata.highlightedTag = tag; + moveToHighlightedValue(); +} + +void BedMeshScreen::drawHighlightedPointValue() { CommandProcessor cmd; cmd.font(Theme::font_medium) + .colors(normal_btn) .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z)) - .text(Z_VALUE_POS, str) - .colors(action_btn) + .font(font_small); + draw_adjuster(cmd, Z_VALUE_POS, 2, getHighlightedValue(true) + mydata.zAdjustment, GET_TEXT_F(MSG_UNITS_MM), 4, 3); + cmd.colors(action_btn) .tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY)) .tag(0); @@ -292,19 +320,23 @@ void BedMeshScreen::onRedraw(draw_mode_t what) { } } -bool BedMeshScreen::onTouchStart(uint8_t tag) { - mydata.highlightedTag = tag; - return true; -} - bool BedMeshScreen::onTouchEnd(uint8_t tag) { + constexpr float increment = 0.01; switch (tag) { case 1: + saveAdjustedHighlightedValue(); + injectCommands_P(PSTR("G29 S1")); GOTO_PREVIOUS(); return true; + case 2: adjustHighlightedValue(-increment); break; + case 3: adjustHighlightedValue( increment); break; default: - return false; + if (tag >= 10) + changeHighlightedValue(tag); + else + return false; } + return true; } void BedMeshScreen::onMeshUpdate(const int8_t, const int8_t, const float) { @@ -341,4 +373,11 @@ void BedMeshScreen::startMeshProbe() { injectCommands_P(PSTR(BED_LEVELING_COMMANDS)); } +void BedMeshScreen::showMeshEditor() { + SpinnerDialogBox::enqueueAndWait_P(ExtUI::isMachineHomed() ? F("M420 S1") : F("G28\nM420 S1")); + // After the spinner, go to this screen. + current_screen.forget(); + PUSH_SCREEN(BedMeshScreen); +} + #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 index de72d863ae..804bb57ad0 100644 --- 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 @@ -32,6 +32,7 @@ struct BedMeshScreenData { } message; uint8_t count; uint8_t highlightedTag; + float zAdjustment; }; class BedMeshScreen : public BaseScreen, public CachedScreen { @@ -45,18 +46,22 @@ class BedMeshScreen : public BaseScreen, public CachedScreen Date: Tue, 23 Mar 2021 06:57:50 +0100 Subject: [PATCH 078/311] Update Hungarian language (#21407) --- Marlin/src/lcd/language/language_hu.h | 221 ++++++++++++++------------ 1 file changed, 115 insertions(+), 106 deletions(-) diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index e29b75fb35..b2c1d30f33 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -22,12 +22,15 @@ #pragma once /** - * Magyar + * Hungarian / Magyar + * + * LCD Menu Messages. See also https://marlinfw.org/docs/development/lcd_language.html + * Hungarian translation by AntoszHUN. I am constantly improving and updating the translation. + * Translation last updated: 21/03/2021 - 21:00 * * LCD Menü Üzenetek. Lásd még https://marlinfw.org/docs/development/lcd_language.html - * Marlin 2.0.x bugfix Magyar fordítása. A fordítást folyamatosan javítom és frissítem. - * A Magyar fordítást készítette: AntoszHUN - * A Fordítás utolsó frissítése: 2021.03.06. - 08:00 + * A Magyar fordítást készítette: AntoszHUN. A fordítást folyamatosan javítom és frissítem. + * A Fordítás utolsó frissítése: 2021.03.21. - 21:00 */ namespace Language_hu { @@ -45,7 +48,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_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"); @@ -59,15 +62,15 @@ namespace Language_hu { 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"); - PROGMEM Language_Str MSG_AUTO_HOME = _UxGT("X-Y-Z Auto kezdöpont"); - PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("X Kezdöpont"); - 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_AUTO_HOME = _UxGT("X-Y-Z auto kezdöpont"); + PROGMEM Language_Str MSG_AUTO_HOME_X = _UxGT("X kezdöpont"); + 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_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("X-Y-Z Kezdöpont"); + PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("X-Y-Z 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"); PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Szintezés kész!"); @@ -106,7 +109,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Orsó telj."); PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Lézer váltás"); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Impulzus teszt ms"); - PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Tűz impulzus"); + PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Tüz impulzus"); PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Orsóváltás"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Orsó előre"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Orsó hátra"); @@ -120,7 +123,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_LEVEL_BED = _UxGT("Ágy szintezése"); PROGMEM Language_Str MSG_LEVEL_CORNERS = _UxGT("Sarok szint"); PROGMEM Language_Str MSG_LEVEL_CORNERS_RAISE = _UxGT("Ágy emelése a szonda váltásig"); - PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Minden sarok tolerancián belül. Szint jó"); + PROGMEM Language_Str MSG_LEVEL_CORNERS_IN_RANGE = _UxGT("Minden sarok tolerancián belül. Szint jó."); PROGMEM Language_Str MSG_LEVEL_CORNERS_GOOD_POINTS = _UxGT("Jó pontok: "); PROGMEM Language_Str MSG_LEVEL_CORNERS_LAST_Z = _UxGT("Utolsó Z: "); PROGMEM Language_Str MSG_NEXT_CORNER = _UxGT("Következö sarok"); @@ -130,24 +133,24 @@ namespace Language_hu { PROGMEM Language_Str MSG_PROBING_MESH = _UxGT("Próbapont"); 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_MESH_EDIT_Z = _UxGT("Z érték"); 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_TEST = _UxGT("M48 Szonda 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_IDEX_MENU = _UxGT("IDEX mód"); 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_AUTOPARK = _UxGT("Automata 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"); PROGMEM Language_Str MSG_IDEX_MODE_FULL_CTRL = _UxGT("Teljes felügyelet"); - PROGMEM Language_Str MSG_IDEX_DUPE_GAP = _UxGT("X-Hézag másolása"); - PROGMEM Language_Str MSG_HOTEND_OFFSET_X = _UxGT("2. fúvóka X"); - PROGMEM Language_Str MSG_HOTEND_OFFSET_Y = _UxGT("2. fúvóka Y"); - PROGMEM Language_Str MSG_HOTEND_OFFSET_Z = _UxGT("2. fúvóka Z"); + PROGMEM Language_Str MSG_IDEX_DUPE_GAP = _UxGT("X-hézag másolása"); + PROGMEM Language_Str MSG_HOTEND_OFFSET_X = _UxGT("2. fej X"); + PROGMEM Language_Str MSG_HOTEND_OFFSET_Y = _UxGT("2. fej Y"); + PROGMEM Language_Str MSG_HOTEND_OFFSET_Z = _UxGT("2. fej 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_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"); @@ -155,12 +158,12 @@ namespace Language_hu { PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Mérés"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Üres ágyat mérj"); PROGMEM Language_Str MSG_UBL_MOVING_TO_NEXT = _UxGT("Továbblépés"); - PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("UBL Aktívál"); - PROGMEM Language_Str MSG_UBL_DEACTIVATE_MESH = _UxGT("UBL Deaktívál"); + PROGMEM Language_Str MSG_UBL_ACTIVATE_MESH = _UxGT("UBL aktívál"); + PROGMEM Language_Str MSG_UBL_DEACTIVATE_MESH = _UxGT("UBL deaktívál"); PROGMEM Language_Str MSG_UBL_SET_TEMP_BED = _UxGT("Ágy höfok"); PROGMEM Language_Str MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Ágy höfok"); - PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = _UxGT("Fúvóka höfok"); - PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Fúvóka höfok"); + PROGMEM Language_Str MSG_UBL_SET_TEMP_HOTEND = _UxGT("Fej höfok"); + PROGMEM Language_Str MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Fej höfok"); PROGMEM Language_Str MSG_UBL_MESH_EDIT = _UxGT("Háló szerkesztés"); PROGMEM Language_Str MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Egyéni háló szerkesztés"); PROGMEM Language_Str MSG_UBL_FINE_TUNE_MESH = _UxGT("Finomított háló"); @@ -174,8 +177,8 @@ namespace Language_hu { 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"); + PROGMEM Language_Str MSG_G26_HEATING_BED = _UxGT("G26 Ágy fütés"); + PROGMEM Language_Str MSG_G26_HEATING_NOZZLE = _UxGT("G26 Fej fütés"); PROGMEM Language_Str MSG_G26_MANUAL_PRIME = _UxGT("Kézi alapozás..."); PROGMEM Language_Str MSG_G26_FIXED_LENGTH = _UxGT("Fix hosszúságú alap"); PROGMEM Language_Str MSG_G26_PRIME_DONE = _UxGT("Alapozás kész"); @@ -192,7 +195,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_HOST = _UxGT("Host kimenet"); PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_CSV = _UxGT("CSV kimenet"); PROGMEM Language_Str MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Nyomtató bizt.mentés"); - PROGMEM Language_Str MSG_UBL_INFO_UBL = _UxGT("UBL Infó kimenet"); + PROGMEM Language_Str MSG_UBL_INFO_UBL = _UxGT("UBL infó kimenet"); PROGMEM Language_Str MSG_UBL_FILLIN_AMOUNT = _UxGT("Kitöltési költség"); PROGMEM Language_Str MSG_UBL_MANUAL_FILLIN = _UxGT("Kézi kitöltés"); PROGMEM Language_Str MSG_UBL_SMART_FILLIN = _UxGT("Okos kitöltés"); @@ -208,10 +211,10 @@ namespace Language_hu { PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Háló %i betöltve"); PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Háló %i mentve"); PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Nincs tároló"); - PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Hiba: UBL Mentés"); - PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Hiba: UBL Visszaáll"); - PROGMEM Language_Str MSG_UBL_Z_OFFSET = _UxGT("Z-Eltolás: "); - PROGMEM Language_Str MSG_UBL_Z_OFFSET_STOPPED = _UxGT("Z-Eltolás leállítva"); + PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Hiba: UBL mentés"); + PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Hiba: UBL visszaáll."); + PROGMEM Language_Str MSG_UBL_Z_OFFSET = _UxGT("Z-eltolás: "); + PROGMEM Language_Str MSG_UBL_Z_OFFSET_STOPPED = _UxGT("Z-eltolás leállítva"); PROGMEM Language_Str MSG_UBL_STEP_BY_STEP_MENU = _UxGT("Lépésröl lépésre UBL"); PROGMEM Language_Str MSG_UBL_1_BUILD_COLD_MESH = _UxGT("1. Hideg háló készítés"); PROGMEM Language_Str MSG_UBL_2_SMART_FILLIN = _UxGT("2. Inteligens kitöltés"); @@ -221,7 +224,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6. Minden finomítása"); PROGMEM Language_Str MSG_UBL_7_SAVE_MESH = _UxGT("7. Ágy háló mentése"); - PROGMEM Language_Str MSG_LED_CONTROL = _UxGT("LED Vezérlés"); + PROGMEM Language_Str MSG_LED_CONTROL = _UxGT("LED vezérlés"); PROGMEM Language_Str MSG_LEDS = _UxGT("Világítás"); PROGMEM Language_Str MSG_LED_PRESETS = _UxGT("Beállított színek"); PROGMEM Language_Str MSG_SET_LEDS_RED = _UxGT("Piros"); @@ -235,7 +238,7 @@ namespace Language_hu { 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("LED-ek #2"); - PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Fény #2 Megadott"); + 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"); @@ -245,13 +248,13 @@ namespace Language_hu { PROGMEM Language_Str MSG_LED_BRIGHTNESS = _UxGT("Fényerö"); PROGMEM Language_Str MSG_MOVING = _UxGT("Mozgás..."); - PROGMEM Language_Str MSG_FREE_XY = _UxGT("XY Szabad"); - PROGMEM Language_Str MSG_MOVE_X = _UxGT("X Mozgás"); - PROGMEM Language_Str MSG_MOVE_Y = _UxGT("Y Mozgás"); - PROGMEM Language_Str MSG_MOVE_Z = _UxGT("Z Mozgás"); + PROGMEM Language_Str MSG_FREE_XY = _UxGT("XY szabad"); + PROGMEM Language_Str MSG_MOVE_X = _UxGT("X mozgás"); + PROGMEM Language_Str MSG_MOVE_Y = _UxGT("Y mozgás"); + PROGMEM Language_Str MSG_MOVE_Z = _UxGT("Z mozgás"); 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_HOTEND_TOO_COLD = _UxGT("A fej túl hideg"); PROGMEM Language_Str MSG_MOVE_N_MM = _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"); @@ -261,18 +264,21 @@ namespace Language_hu { PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Mozgás 0.1mm"); PROGMEM Language_Str MSG_SPEED = _UxGT("Sebesség"); PROGMEM Language_Str MSG_BED_Z = _UxGT("Z ágy"); - PROGMEM Language_Str MSG_NOZZLE = _UxGT("Fúvóka"); - PROGMEM Language_Str MSG_NOZZLE_N = _UxGT("Fúvóka ~"); + PROGMEM Language_Str MSG_NOZZLE = _UxGT("Fej"); + PROGMEM Language_Str MSG_NOZZLE_N = _UxGT("Fej ~"); PROGMEM Language_Str MSG_NOZZLE_PARKED = _UxGT("Fej parkolva"); PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Fej készenlétbe"); PROGMEM Language_Str MSG_BED = _UxGT("Ágy"); PROGMEM Language_Str MSG_CHAMBER = _UxGT("Burkolat"); + PROGMEM Language_Str MSG_COOLER = _UxGT("Lézer hütövíz"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Hütö kapcsoló"); + PROGMEM Language_Str MSG_LASER = _UxGT("Lézer"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Hütés sebesség"); PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Hütés sebesség ="); PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Tárolt hütés ="); PROGMEM Language_Str MSG_EXTRA_FAN_SPEED = _UxGT("Extra hütés sebesség"); PROGMEM Language_Str MSG_EXTRA_FAN_SPEED_N = _UxGT("Extra hütés sebesség ="); - PROGMEM Language_Str MSG_CONTROLLER_FAN = _UxGT("Hűtésvezérlés"); + PROGMEM Language_Str MSG_CONTROLLER_FAN = _UxGT("Hütésvezérlés"); PROGMEM Language_Str MSG_CONTROLLER_FAN_IDLE_SPEED = _UxGT("Alapjárat"); PROGMEM Language_Str MSG_CONTROLLER_FAN_AUTO_ON = _UxGT("Automatikus mód"); PROGMEM Language_Str MSG_CONTROLLER_FAN_SPEED = _UxGT("Aktív sebesség"); @@ -286,9 +292,9 @@ namespace Language_hu { PROGMEM Language_Str MSG_AUTOTEMP = _UxGT("Automata höfok"); PROGMEM Language_Str MSG_LCD_ON = _UxGT("Be"); PROGMEM Language_Str MSG_LCD_OFF = _UxGT("Ki"); - PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("PID Hangolás"); - PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("PID Hangolás *"); - PROGMEM Language_Str MSG_PID_AUTOTUNE_DONE = _UxGT("PID Hangolás kész"); + PROGMEM Language_Str MSG_PID_AUTOTUNE = _UxGT("PID hangolás"); + PROGMEM Language_Str MSG_PID_AUTOTUNE_E = _UxGT("PID hangolás *"); + PROGMEM Language_Str MSG_PID_AUTOTUNE_DONE = _UxGT("PID hangolás kész"); PROGMEM Language_Str MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Hangolási hiba. Rossz adagoló."); PROGMEM Language_Str MSG_PID_TEMP_TOO_HIGH = _UxGT("Hangolási hiba. Magas hömérséklet."); PROGMEM Language_Str MSG_PID_TIMEOUT = _UxGT("Hangolási hiba! Idötúllépés."); @@ -296,10 +302,10 @@ namespace Language_hu { PROGMEM Language_Str MSG_SELECT_E = _UxGT("Kiválaszt *"); PROGMEM Language_Str MSG_ACC = _UxGT("Gyorsítás"); PROGMEM Language_Str MSG_JERK = _UxGT("Rántás"); - PROGMEM Language_Str MSG_VA_JERK = LCD_STR_A _UxGT(" Ránt. Seb."); - PROGMEM Language_Str MSG_VB_JERK = LCD_STR_B _UxGT(" Ránt. Seb."); - PROGMEM Language_Str MSG_VC_JERK = LCD_STR_C _UxGT(" Ránt. Seb."); - PROGMEM Language_Str MSG_VE_JERK = _UxGT("E Ránt. Seb."); + PROGMEM Language_Str MSG_VA_JERK = LCD_STR_A _UxGT(" Ránt. seb."); + PROGMEM Language_Str MSG_VB_JERK = LCD_STR_B _UxGT(" Ránt. seb."); + PROGMEM Language_Str MSG_VC_JERK = LCD_STR_C _UxGT(" Ránt. seb."); + PROGMEM Language_Str MSG_VE_JERK = _UxGT("E ránt. seb."); PROGMEM Language_Str MSG_JUNCTION_DEVIATION = _UxGT("Csomopont eltérés"); PROGMEM Language_Str MSG_VELOCITY = _UxGT("Sebesség"); PROGMEM Language_Str MSG_VMAX_A = _UxGT("Max sebesség ") LCD_STR_A; @@ -331,25 +337,25 @@ namespace Language_hu { 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_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"); PROGMEM Language_Str MSG_FILAMENT_LOAD = _UxGT("Betöltés mm"); PROGMEM Language_Str MSG_ADVANCE_K = _UxGT("Haladó K"); PROGMEM Language_Str MSG_ADVANCE_K_E = _UxGT("Haladó K *"); - PROGMEM Language_Str MSG_CONTRAST = _UxGT("LCD Kontraszt"); + PROGMEM Language_Str MSG_CONTRAST = _UxGT("LCD kontraszt"); PROGMEM Language_Str MSG_STORE_EEPROM = _UxGT("Mentés EEPROM"); PROGMEM Language_Str MSG_LOAD_EEPROM = _UxGT("Betöltés EEPROM"); PROGMEM Language_Str MSG_RESTORE_DEFAULTS = _UxGT("Alapértelmezett"); - PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("EEPROM Inicializálás"); + PROGMEM Language_Str MSG_INIT_EEPROM = _UxGT("EEPROM inicializálás"); PROGMEM Language_Str MSG_ERR_EEPROM_CRC = _UxGT("Hiba: EEPROM CRC"); - PROGMEM Language_Str MSG_ERR_EEPROM_INDEX = _UxGT("Hiba: EEPROM Index"); - PROGMEM Language_Str MSG_ERR_EEPROM_VERSION = _UxGT("Hiba: EEPROM Verzió"); + PROGMEM Language_Str MSG_ERR_EEPROM_INDEX = _UxGT("Hiba: EEPROM index"); + PROGMEM Language_Str MSG_ERR_EEPROM_VERSION = _UxGT("Hiba: EEPROM verzió"); PROGMEM Language_Str MSG_SETTINGS_STORED = _UxGT("Beállítások mentve"); PROGMEM Language_Str MSG_MEDIA_UPDATE = _UxGT("Tároló frissítés"); PROGMEM Language_Str MSG_RESET_PRINTER = _UxGT("Nyomtató újraindítása"); PROGMEM Language_Str MSG_REFRESH = LCD_STR_REFRESH _UxGT("Frissítés"); - PROGMEM Language_Str MSG_INFO_SCREEN = _UxGT(""); + 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"); @@ -390,24 +396,24 @@ namespace Language_hu { PROGMEM Language_Str MSG_KILLED = _UxGT("HALOTT! "); PROGMEM Language_Str MSG_STOPPED = _UxGT("MEGÁLLT! "); PROGMEM Language_Str MSG_CONTROL_RETRACT = _UxGT("Visszahúzás mm"); - PROGMEM Language_Str MSG_CONTROL_RETRACT_SWAP = _UxGT("Visszahúzás Cs. mm"); + PROGMEM Language_Str MSG_CONTROL_RETRACT_SWAP = _UxGT("Visszahúzás cs. mm"); PROGMEM Language_Str MSG_CONTROL_RETRACTF = _UxGT("Viszahúzás"); 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_RECOVER_SWAP = _UxGT("Csere.visszah.helyre mm"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Visszahúzás V"); PROGMEM Language_Str MSG_CONTROL_RETRACT_RECOVER_SWAPF = _UxGT("S Vissza.h V"); - PROGMEM Language_Str MSG_AUTORETRACT = _UxGT("Auto Visszah."); + PROGMEM Language_Str MSG_AUTORETRACT = _UxGT("Auto visszah."); PROGMEM Language_Str MSG_FILAMENT_SWAP_LENGTH = _UxGT("Visszahúzás távolság"); PROGMEM Language_Str MSG_FILAMENT_SWAP_EXTRA = _UxGT("Extra csere"); PROGMEM Language_Str MSG_FILAMENT_PURGE_LENGTH = _UxGT("Tisztítási távolság"); PROGMEM Language_Str MSG_TOOL_CHANGE = _UxGT("Szerszámcsere"); - PROGMEM Language_Str MSG_TOOL_CHANGE_ZLIFT = _UxGT("Z Emelés"); + PROGMEM Language_Str MSG_TOOL_CHANGE_ZLIFT = _UxGT("Z emelés"); PROGMEM Language_Str MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Fösebesség"); - PROGMEM Language_Str MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Visszah. Sebesség"); + PROGMEM Language_Str MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Visszah. sebesség"); PROGMEM Language_Str MSG_FILAMENT_PARK_ENABLED = _UxGT("Fej parkolás"); PROGMEM Language_Str MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Visszav.visszah. sebesség"); - PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("FAN Sebesség"); + PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("FAN sebesség"); PROGMEM Language_Str MSG_SINGLENOZZLE_FAN_TIME = _UxGT("FAN idö"); PROGMEM Language_Str MSG_TOOL_MIGRATION_ON = _UxGT("Auto BE"); PROGMEM Language_Str MSG_TOOL_MIGRATION_OFF = _UxGT("Auto KI"); @@ -415,8 +421,8 @@ namespace Language_hu { PROGMEM Language_Str MSG_TOOL_MIGRATION_AUTO = _UxGT("Automata csere"); PROGMEM Language_Str MSG_TOOL_MIGRATION_END = _UxGT("Utolsó adagoló"); PROGMEM Language_Str MSG_TOOL_MIGRATION_SWAP = _UxGT("Csere *"); - PROGMEM Language_Str MSG_FILAMENTCHANGE = _UxGT("Szál csere"); - PROGMEM Language_Str MSG_FILAMENTCHANGE_E = _UxGT("Szál csere *"); + PROGMEM Language_Str MSG_FILAMENTCHANGE = _UxGT("Szálcsere"); + PROGMEM Language_Str MSG_FILAMENTCHANGE_E = _UxGT("Szálcsere *"); PROGMEM Language_Str MSG_FILAMENTLOAD = _UxGT("Szál betöltés"); PROGMEM Language_Str MSG_FILAMENTLOAD_E = _UxGT("Szál betöltés *"); PROGMEM Language_Str MSG_FILAMENTUNLOAD = _UxGT("Szál eltávolítás"); @@ -436,23 +442,23 @@ namespace Language_hu { PROGMEM Language_Str MSG_BLTOUCH_5V_MODE = _UxGT("5V-Mód"); PROGMEM Language_Str MSG_BLTOUCH_OD_MODE = _UxGT("OD-Mód"); PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE = _UxGT("Módok"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_5V = _UxGT("BLTouch 5V Mód"); - PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_OD = _UxGT("BLTouch OD Mód"); + PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_5V = _UxGT("BLTouch 5V mód"); + PROGMEM Language_Str MSG_BLTOUCH_MODE_STORE_OD = _UxGT("BLTouch OD mód"); PROGMEM Language_Str MSG_BLTOUCH_MODE_ECHO = _UxGT("Jelentés"); 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 eltolás 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-Probe használ"); - PROGMEM Language_Str MSG_MANUAL_STOW = _UxGT("Z-Probe elhelyezés"); + PROGMEM Language_Str MSG_MANUAL_DEPLOY = _UxGT("Z-Szonda telepítés"); + PROGMEM Language_Str MSG_MANUAL_STOW = _UxGT("Z-Szonda 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("X Szonda eltolás"); - PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Y Szonda eltolás"); - PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Z Szonda eltolás"); - PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED = _UxGT("Fúvóka az ágyhoz"); + PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("X szonda eltolás"); + PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Y szonda eltolás"); + PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Z szonda eltolás"); + PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED = _UxGT("Fej 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"); @@ -463,9 +469,11 @@ namespace Language_hu { 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"); + PROGMEM Language_Str MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Hütés kimaradás"); + PROGMEM Language_Str MSG_COOLING_FAILED = _UxGT("Hütés sikertelen"); + 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Ó LEÁLLT"); PROGMEM Language_Str MSG_PLEASE_RESET = _UxGT("Indítsd újra!"); PROGMEM Language_Str MSG_SHORT_DAY = _UxGT("n"); // Csak egy karakter PROGMEM Language_Str MSG_SHORT_HOUR = _UxGT("ó"); // Csak egy karakter @@ -478,15 +486,16 @@ namespace Language_hu { 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_LASER_COOLING = _UxGT("Lézer hütés..."); PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Delta kalibráció"); - PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("X Kalibrálás"); - PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Y Kalibrálás"); - PROGMEM Language_Str MSG_DELTA_CALIBRATE_Z = _UxGT("Z Kalibrálás"); + PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("X kalibrálás"); + PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Y kalibrálás"); + PROGMEM Language_Str MSG_DELTA_CALIBRATE_Z = _UxGT("Z kalibrálás"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_CENTER = _UxGT("Központ kalibrálás"); PROGMEM Language_Str MSG_DELTA_SETTINGS = _UxGT("Delta beállítások"); PROGMEM Language_Str MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto kalibráció"); PROGMEM Language_Str MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Delta magasság kalib."); - PROGMEM Language_Str MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Z Eltolás"); + PROGMEM Language_Str MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Z eltolás"); PROGMEM Language_Str MSG_DELTA_DIAG_ROD = _UxGT("Diag rúd"); PROGMEM Language_Str MSG_DELTA_HEIGHT = _UxGT("Magasság"); PROGMEM Language_Str MSG_DELTA_RADIUS = _UxGT("Sugár"); @@ -505,7 +514,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_INFO_PROTOCOL = _UxGT("Protokol"); 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_HOTEND_IDLE_TIMEOUT = _UxGT("Fej ü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"); @@ -529,10 +538,10 @@ namespace Language_hu { PROGMEM Language_Str MSG_INFO_MAX_TEMP = _UxGT("Max höfok"); PROGMEM Language_Str MSG_INFO_PSU = _UxGT("PSU"); PROGMEM Language_Str MSG_DRIVE_STRENGTH = _UxGT("Meghajtási erö"); - PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X Meghajtó %"); - PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y Meghajtó %"); - PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z Meghajtó %"); - PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E Meghajtó %"); + PROGMEM Language_Str MSG_DAC_PERCENT_X = _UxGT("X meghajtó %"); + PROGMEM Language_Str MSG_DAC_PERCENT_Y = _UxGT("Y meghajtó %"); + PROGMEM Language_Str MSG_DAC_PERCENT_Z = _UxGT("Z meghajtó %"); + PROGMEM Language_Str MSG_DAC_PERCENT_E = _UxGT("E meghajtó %"); PROGMEM Language_Str MSG_ERROR_TMC = _UxGT("TMC CSATLAKOZÁSI HIBA"); PROGMEM Language_Str MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM írása"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEADER = _UxGT("NYOMTATÓSZÁL CSERE"); @@ -542,7 +551,7 @@ namespace Language_hu { PROGMEM Language_Str MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("FOLYTATÁSI OPCIÓ:"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Tisztítsd meg"); PROGMEM Language_Str MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Folytatás"); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Fúvóka: "); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Fej: "); PROGMEM Language_Str MSG_RUNOUT_SENSOR = _UxGT("Túlfutás szenzor"); PROGMEM Language_Str MSG_RUNOUT_DISTANCE_MM = _UxGT("Túlfutás táv. mm"); PROGMEM Language_Str MSG_KILL_HOMING_FAILED = _UxGT("Tájolási hiba"); @@ -550,13 +559,13 @@ namespace Language_hu { PROGMEM Language_Str MSG_MMU2_CHOOSE_FILAMENT_HEADER = _UxGT("SZÁLVÁLASZTÁS"); PROGMEM Language_Str MSG_MMU2_MENU = _UxGT("MMU"); - PROGMEM Language_Str MSG_KILL_MMU2_FIRMWARE = _UxGT("MMU Szoftver feltöltése!"); - PROGMEM Language_Str MSG_MMU2_NOT_RESPONDING = _UxGT("MMU Figyelmeztetés."); + PROGMEM Language_Str MSG_KILL_MMU2_FIRMWARE = _UxGT("MMU szoftver feltöltése!"); + PROGMEM Language_Str MSG_MMU2_NOT_RESPONDING = _UxGT("MMU figyelmeztetés."); PROGMEM Language_Str MSG_MMU2_RESUME = _UxGT("Nyomtatás folytatása"); PROGMEM Language_Str MSG_MMU2_RESUMING = _UxGT("Folytatás..."); PROGMEM Language_Str MSG_MMU2_LOAD_FILAMENT = _UxGT("Szál betöltése"); PROGMEM Language_Str MSG_MMU2_LOAD_ALL = _UxGT("Összes betöltése"); - PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("Fúvóka betöltése"); + PROGMEM Language_Str MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("Fej betöltése"); PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT = _UxGT("Szál kiadása"); PROGMEM Language_Str MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Szál kiadása ~"); PROGMEM Language_Str MSG_MMU2_UNLOAD_FILAMENT = _UxGT("Kiadja a szálat"); @@ -565,8 +574,8 @@ namespace Language_hu { PROGMEM Language_Str MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Szál kiadása...."); PROGMEM Language_Str MSG_MMU2_ALL = _UxGT("Mind"); PROGMEM Language_Str MSG_MMU2_FILAMENT_N = _UxGT("Nyomtatószál ~"); - PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("MMU Újraindítás"); - PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("MMU Újraindul..."); + PROGMEM Language_Str MSG_MMU2_RESET = _UxGT("MMU újraindítás"); + PROGMEM Language_Str MSG_MMU2_RESETTING = _UxGT("MMU újraindul..."); PROGMEM Language_Str MSG_MMU2_EJECT_RECOVER = _UxGT("Eltávolít, kattint"); PROGMEM Language_Str MSG_MIX = _UxGT("Kever"); @@ -615,10 +624,10 @@ namespace Language_hu { #if LCD_HEIGHT >= 4 PROGMEM Language_Str MSG_ADVANCED_PAUSE_WAITING = _UxGT(MSG_2_LINE("Nyomj gombot", "nyomtatás folytatáshoz")); PROGMEM Language_Str MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_1_LINE("Parkolás...")); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_INIT = _UxGT(MSG_3_LINE("Várj míg", "szál csere", "indítás")); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_INIT = _UxGT(MSG_3_LINE("Várj míg", "szálcsere", "indítás")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_INSERT = _UxGT(MSG_3_LINE("Szál behelyezés", "majd nyomj gombot", "a folytatáshoz")); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEAT = _UxGT(MSG_2_LINE("Nyomj gombot", "a fúvóka fűtéséhez")); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEATING = _UxGT(MSG_2_LINE("Fúvóka fűtése", "Kérlek várj...")); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEAT = _UxGT(MSG_2_LINE("Nyomj gombot", "a fej fütéséhez")); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEATING = _UxGT(MSG_2_LINE("Fej fütése", "Kérlek várj...")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_UNLOAD = _UxGT(MSG_2_LINE("Várj a", "szál kiadására")); 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")); @@ -629,15 +638,15 @@ namespace Language_hu { PROGMEM Language_Str MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_1_LINE("Parkolás...")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_INIT = _UxGT(MSG_1_LINE("Kérlek várj...")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_INSERT = _UxGT(MSG_1_LINE("Behelyez majd katt")); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEAT = _UxGT(MSG_1_LINE("Katt a fűtéshez")); - PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEATING = _UxGT(MSG_1_LINE("Fűtés...")); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEAT = _UxGT(MSG_1_LINE("Katt a fütéshez")); + PROGMEM Language_Str MSG_FILAMENT_CHANGE_HEATING = _UxGT(MSG_1_LINE("Fütés...")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_UNLOAD = _UxGT(MSG_1_LINE("Kiadás...")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_LOAD = _UxGT(MSG_1_LINE("Betöltés...")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_PURGE = _UxGT(MSG_1_LINE("Tisztítás...")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_CONT_PURGE = _UxGT(MSG_1_LINE("Katt ha kész")); PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_1_LINE("Folytatás...")); #endif - PROGMEM Language_Str MSG_TMC_DRIVERS = _UxGT("TMC Meghajtók"); + PROGMEM Language_Str MSG_TMC_DRIVERS = _UxGT("TMC meghajtók"); PROGMEM Language_Str MSG_TMC_CURRENT = _UxGT("Meghajtó áram"); PROGMEM Language_Str MSG_TMC_HYBRID_THRS = _UxGT("Hibrid küszöbérték"); PROGMEM Language_Str MSG_TMC_HOMING_THRS = _UxGT("Motoros kezdöpont"); @@ -652,19 +661,19 @@ 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"); #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."); + PROGMEM Language_Str MSG_HEATER_TIMEOUT = _UxGT("Tétlenségi idökorlát, a hömérséklet csökkent. Nyomd 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"); + 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_REHEAT = _UxGT("Újrafüt"); + PROGMEM Language_Str MSG_REHEATING = _UxGT("Újrafütés..."); - PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Szonda varázsló"); - PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING = _UxGT("Z Referencia mérés"); - PROGMEM Language_Str MSG_PROBE_WIZARD_MOVING = _UxGT("Menjen a próba pontra"); + PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z szonda varázsló"); + PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING = _UxGT("Z referencia mérés"); + PROGMEM Language_Str MSG_PROBE_WIZARD_MOVING = _UxGT("Menj a próba pontra"); PROGMEM Language_Str MSG_SOUND = _UxGT("Hang"); From 2b621eb45d1b904165c414ee1711ad121c0a1c53 Mon Sep 17 00:00:00 2001 From: Sola <42537573+solawc@users.noreply.github.com> Date: Tue, 23 Mar 2021 13:58:52 +0800 Subject: [PATCH 079/311] Fix MKS H43 sensorless homing (#21388) --- Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 4 ++-- Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index bfa518446d..78865bbfd6 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -36,7 +36,7 @@ #include "../../../../marlinui.h" #if ENABLED(HAS_STEALTHCHOP) - #include "../../../../module/stepper/trinamic.h" + #include "../../../../../module/stepper/trinamic.h" #endif #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) @@ -746,9 +746,9 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // SDCard File listing + VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), #if ENABLED(SDSUPPORT) VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr), - VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr), VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index 577171a135..bf2b05dcbf 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -1246,6 +1246,9 @@ void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { uint16_t val_t = swap16(*(uint16_t*)val_ptr); + if (!print_job_timer.isPaused() && !queue.ring_buffer.empty()) + return; + switch (val_t) { case 0: #if HOTENDS >= 1 @@ -1497,7 +1500,7 @@ bool DGUSScreenHandler::loop() { static bool booted = false; if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT))) { booted = true; - #if ANY_AXIS_HAS(STEALTHCHOP) + #if USE_SENSORLESS #if AXIS_HAS_STEALTHCHOP(X) tmc_x_step = stepperX.homing_threshold(); #endif From 50a6ffa9528d7d7419855cce631f95a7e19d5d6a Mon Sep 17 00:00:00 2001 From: mihtjel Date: Tue, 23 Mar 2021 07:00:22 +0100 Subject: [PATCH 080/311] Fix macros that call macros crashing (#21383) When macros call macros, the null termination should remain in place until the macro is completed, and only then put back. Otherwise, the macro handler interprets this as setting the macro called to a new value. --- Marlin/src/gcode/gcode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 4e324e7892..6290d7a1d5 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -1048,8 +1048,8 @@ void GcodeSuite::process_subcommands_now(char * gcode) { char * const delim = strchr(gcode, '\n'); // Get address of next newline if (delim) *delim = '\0'; // Replace with nul parser.parse(gcode); // Parse the current command - if (delim) *delim = '\n'; // Put back the newline process_parsed_command(true); // Process it + if (delim) *delim = '\n'; // Put back the newline if (!delim) break; // Last command? gcode = delim + 1; // Get the next command } From 22fc59ab5973aa91cc2fed68792dce521cc70c93 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Mar 2021 01:03:32 -0500 Subject: [PATCH 081/311] Minor process_subcommands_now followup --- Marlin/src/gcode/gcode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 6290d7a1d5..aa206bfeba 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -1049,8 +1049,8 @@ void GcodeSuite::process_subcommands_now(char * gcode) { if (delim) *delim = '\0'; // Replace with nul parser.parse(gcode); // Parse the current command process_parsed_command(true); // Process it - if (delim) *delim = '\n'; // Put back the newline if (!delim) break; // Last command? + *delim = '\n'; // Put back the newline gcode = delim + 1; // Get the next command } parser.parse(saved_cmd); // Restore the parser state From eee726ec7dfa774677e86d84573e04524eff64be Mon Sep 17 00:00:00 2001 From: Marcio T Date: Tue, 23 Mar 2021 00:45:51 -0600 Subject: [PATCH 082/311] UBL - Hilbert space-filling curve probing sequence (#21387) --- Marlin/Configuration.h | 2 + Marlin/src/feature/bedlevel/ubl/ubl.h | 5 ++ Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 58 +++++++++++++++++++-- buildroot/tests/mega2560 | 2 +- 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index ce847c0d65..339dae7702 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1478,6 +1478,8 @@ #define GRID_MAX_POINTS_X 10 // Don't use more than 15 points per axis, implementation limited. #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X + //#define UBL_HILBERT_CURVE // Use Hilbert distribution for less travel when probing multiple points + #define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle #define UBL_SAVE_ACTIVE_ON_M500 // Save the currently active mesh in the current slot on M500 diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index d5da43a6a2..0c4667eed8 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -98,6 +98,11 @@ public: static void display_map(const int) _O0; static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0; static mesh_index_pair find_furthest_invalid_mesh_point() _O0; + #if ENABLED(UBL_HILBERT_CURVE) + static void check_if_missing(mesh_index_pair &pt, int x, int y); + static void hilbert(mesh_index_pair &pt, int8_t x, int8_t y, int8_t xi, int8_t xj, int8_t yi, int8_t yj, uint8_t n); + static mesh_index_pair find_next_mesh_point(); + #endif static void reset(); static void invalidate(); static void set_all_mesh_points_to_value(const float value); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 8c70feb661..3ea777fd9a 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -757,9 +757,11 @@ void unified_bed_leveling::shift_mesh_height() { } #endif - best = do_furthest - ? find_furthest_invalid_mesh_point() - : find_closest_mesh_point_of_type(INVALID, nearby, true); + best = do_furthest ? find_furthest_invalid_mesh_point() + : TERN(UBL_HILBERT_CURVE, + next_point_in_grid(), + find_closest_mesh_point_of_type(INVALID, nearby, true) + ); if (best.pos.x >= 0) { // mesh point found and is reachable by probe TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START)); @@ -1298,6 +1300,56 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh return closest; } +#if ENABLED(UBL_HILBERT_CURVE) + + constexpr int8_t to_fix(int8_t v) { return v << 1; } + constexpr int8_t to_int(int8_t v) { return v >> 1; } + constexpr uint8_t log2(uint8_t n) { return (n > 1) ? 1 + log2(n >> 1) : 0; } + constexpr uint8_t order(uint8_t n) { return uint8_t(log2(n - 1)) + 1; } + + void unified_bed_leveling::hilbert(mesh_index_pair &pt, int8_t x, int8_t y, int8_t xi, int8_t xj, int8_t yi, int8_t yj, uint8_t n) { + /* Hilbert space filling curve implementation + * + * x and y are the coordinates of the bottom left corner + * xi & xj are the i & j components of the unit x vector of the frame + * similarly yi and yj + * + * From: http://www.fundza.com/algorithmic/space_filling/hilbert/basics/index.html + */ + if (n <= 0) + check_if_missing(pt, to_int(x+(xi+yi)/2),to_int(y+(xj+yj)/2)); + else { + hilbert(pt, x, y, yi/2, yj/2, xi/2, xj/2, n-1); + hilbert(pt, x+xi/2, y+xj/2, xi/2, xj/2, yi/2, yj/2, n-1); + hilbert(pt, x+xi/2+yi/2, y+xj/2+yj/2, xi/2, xj/2, yi/2, yj/2, n-1); + hilbert(pt, x+xi/2+yi, y+xj/2+yj, -yi/2, -yj/2, -xi/2, -xj/2, n-1); + } + } + + void unified_bed_leveling::check_if_missing(mesh_index_pair &pt, int x, int y) { + if ( pt.distance < 0 + && x < GRID_MAX_POINTS_X + && y < GRID_MAX_POINTS_Y + && isnan(z_values[x][y]) + && probe.can_reach(mesh_index_to_xpos(x), mesh_index_to_ypos(y)) + ) { + pt.pos.set(x, y); + pt.distance = 1; + } + } + + mesh_index_pair unified_bed_leveling::find_next_mesh_point() { + mesh_index_pair pt; + pt.invalidate(); + pt.distance = -99999.9f; + constexpr uint8_t ord = order(_MAX(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y)); + constexpr uint8_t dim = _BV(ord); + hilbert(pt, to_fix(0), to_fix(0), to_fix(dim), to_fix(0), to_fix(0), to_fix(dim), ord); + return pt; + } + +#endif // UBL_HILBERT_CURVE + /** * 'Smart Fill': Scan from the outward edges of the mesh towards the center. * If an invalid location is found, use the next two points (if valid) to diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index d961ab4eff..e3209899ce 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -36,7 +36,7 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE jp_kana \ opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \ SDSUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \ - Z_PROBE_SLED AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \ + Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \ NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL \ From 10c14bcc05a85d3f012d90f9963d97c72b1296d6 Mon Sep 17 00:00:00 2001 From: ellensp Date: Tue, 23 Mar 2021 19:47:07 +1300 Subject: [PATCH 083/311] Check NOZZLE_CLEAN_FEATURE settings (#21332) Co-authored-by: Scott Lahteine --- .github/workflows/test-builds.yml | 1 + Marlin/src/inc/SanityCheck.h | 15 +++++++++++++++ buildroot/tests/LPC1768 | 4 +++- buildroot/tests/LPC1769 | 4 +++- buildroot/tests/STM32F103RE | 4 +++- buildroot/tests/teensy35 | 4 +++- buildroot/tests/teensy41 | 4 +++- 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index 7549e3defc..7b7052e0e1 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -98,6 +98,7 @@ jobs: # Non-working environment tests #- at90usb1286_cdc #- STM32F103CB_malyan + #- STM32F103RE #- mks_robin_mini steps: diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index af30c6156d..d8111c18da 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3349,6 +3349,21 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #error "Either enable MEATPACK_ON_SERIAL_PORT_* or BINARY_FILE_TRANSFER, not both." #endif +/** + * Sanity check for unique start and stop values in NOZZLE_CLEAN_FEATURE + */ +#if ENABLED(NOZZLE_CLEAN_FEATURE) + constexpr xyz_pos_t start_xyz[8] = NOZZLE_CLEAN_START_POINT, + end_xyz[8] = NOZZLE_CLEAN_END_POINT; + #define _CLEAN_ASSERT(N) static_assert(N >= HOTENDS || end_xyz[N].x != start_xyz[N].x || TERN(NOZZLE_CLEAN_NO_Y, false, end_xyz[N].y != start_xyz[N].y), \ + "NOZZLE_CLEAN Start and End must be made different on HOTEND " STRINGIFY(N)) + _CLEAN_ASSERT(0); _CLEAN_ASSERT(1); + _CLEAN_ASSERT(2); _CLEAN_ASSERT(3); + _CLEAN_ASSERT(4); _CLEAN_ASSERT(5); + _CLEAN_ASSERT(6); _CLEAN_ASSERT(7); + #undef _CLEAN_ASSERT +#endif + /** * Sanity check for valid stepper driver types */ diff --git a/buildroot/tests/LPC1768 b/buildroot/tests/LPC1768 index a6829e85ea..eef0857dac 100755 --- a/buildroot/tests/LPC1768 +++ b/buildroot/tests/LPC1768 @@ -34,7 +34,9 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EEB \ EXTRUDERS 2 TEMP_SENSOR_1 -1 TEMP_SENSOR_BED 5 \ GRID_MAX_POINTS_X 16 \ NOZZLE_TO_PROBE_OFFSET '{ 0, 0, 0 }' \ - NOZZLE_CLEAN_MIN_TEMP 170 + NOZZLE_CLEAN_MIN_TEMP 170 \ + NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \ + NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }" 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 \ diff --git a/buildroot/tests/LPC1769 b/buildroot/tests/LPC1769 index 5ca7114543..f0dab630e5 100755 --- a/buildroot/tests/LPC1769 +++ b/buildroot/tests/LPC1769 @@ -15,7 +15,9 @@ exec_test $1 $2 "Azteeg X5GT Example Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_SMOOTHIEBOARD \ EXTRUDERS 2 TEMP_SENSOR_1 -1 TEMP_SENSOR_BED 5 \ - GRID_MAX_POINTS_X 16 + GRID_MAX_POINTS_X 16 \ + NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \ + NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }" opt_enable TFTGLCD_PANEL_SPI SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \ FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET LEVEL_CORNERS_USE_PROBE LEVEL_CORNERS_VERIFY_RAISED \ diff --git a/buildroot/tests/STM32F103RE b/buildroot/tests/STM32F103RE index 426f87d21b..641f1fa56c 100755 --- a/buildroot/tests/STM32F103RE +++ b/buildroot/tests/STM32F103RE @@ -10,7 +10,9 @@ set -e # Build with the default configurations # restore_configs -opt_set MOTHERBOARD BOARD_STM32F103RE SERIAL_PORT -1 EXTRUDERS 2 +opt_set MOTHERBOARD BOARD_STM32F103RE SERIAL_PORT -1 EXTRUDERS 2 \ + NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \ + NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }" opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT \ PAREN_COMMENTS GCODE_MOTION_MODES SINGLENOZZLE TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_PARK \ BAUD_RATE_GCODE GCODE_MACROS NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE diff --git a/buildroot/tests/teensy35 b/buildroot/tests/teensy35 index c9731665c5..36a261a6ae 100755 --- a/buildroot/tests/teensy35 +++ b/buildroot/tests/teensy35 @@ -17,7 +17,9 @@ restore_configs opt_set MOTHERBOARD BOARD_TEENSY35_36 \ EXTRUDERS 2 TEMP_SENSOR_0 1 TEMP_SENSOR_1 5 TEMP_SENSOR_BED 1 \ I2C_SLAVE_ADDRESS 63 \ - GRID_MAX_POINTS_X 16 + GRID_MAX_POINTS_X 16 \ + NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \ + NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }" opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \ FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE SOUND_MENU_ITEM \ FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ diff --git a/buildroot/tests/teensy41 b/buildroot/tests/teensy41 index 6074b5dc5f..55e7e6eae2 100755 --- a/buildroot/tests/teensy41 +++ b/buildroot/tests/teensy41 @@ -17,7 +17,9 @@ restore_configs opt_set MOTHERBOARD BOARD_TEENSY41 \ EXTRUDERS 2 TEMP_SENSOR_0 1 TEMP_SENSOR_1 5 TEMP_SENSOR_BED 1 \ I2C_SLAVE_ADDRESS 63 \ - GRID_MAX_POINTS_X 16 + GRID_MAX_POINTS_X 16 \ + NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \ + NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }" opt_enable EXTENSIBLE_UI LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \ FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \ FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ From dd92c8e927ba6146b06f486ef5356ea30cd87f6e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Mar 2021 05:54:41 -0500 Subject: [PATCH 084/311] Followup to UBL Hilbert --- 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 3ea777fd9a..bcda183366 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -759,7 +759,7 @@ void unified_bed_leveling::shift_mesh_height() { best = do_furthest ? find_furthest_invalid_mesh_point() : TERN(UBL_HILBERT_CURVE, - next_point_in_grid(), + find_next_mesh_point(), find_closest_mesh_point_of_type(INVALID, nearby, true) ); From df1ef496d1a88996cb1156fe933df59c6aaecbac Mon Sep 17 00:00:00 2001 From: borland1 Date: Tue, 23 Mar 2021 06:21:11 -0700 Subject: [PATCH 085/311] Main / Config Custom Submenus (#18177) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 98 +++++++---- Marlin/src/inc/Conditionals_adv.h | 2 +- Marlin/src/inc/SanityCheck.h | 105 +----------- .../screens/custom_user_menus.cpp | 4 +- .../ftdi_eve_touch_ui/screens/main_menu.cpp | 14 +- .../lib/ftdi_eve_touch_ui/screens/screens.h | 8 +- .../lcd/extui/lib/mks_ui/tft_Language_en.h | 12 +- .../lcd/extui/lib/mks_ui/tft_Language_fr.h | 12 +- .../lcd/extui/lib/mks_ui/tft_Language_it.h | 12 +- .../lcd/extui/lib/mks_ui/tft_Language_ru.h | 12 +- .../lcd/extui/lib/mks_ui/tft_Language_s_cn.h | 12 +- .../lcd/extui/lib/mks_ui/tft_Language_sp.h | 12 +- .../lcd/extui/lib/mks_ui/tft_Language_t_cn.h | 12 +- Marlin/src/lcd/language/language_cz.h | 2 +- Marlin/src/lcd/language/language_de.h | 2 +- Marlin/src/lcd/language/language_en.h | 2 +- Marlin/src/lcd/language/language_es.h | 2 +- Marlin/src/lcd/language/language_fr.h | 2 +- Marlin/src/lcd/language/language_gl.h | 2 +- Marlin/src/lcd/language/language_it.h | 2 +- Marlin/src/lcd/language/language_jp_kana.h | 2 +- Marlin/src/lcd/language/language_pl.h | 2 +- Marlin/src/lcd/language/language_pt_br.h | 2 +- Marlin/src/lcd/language/language_ro.h | 2 +- Marlin/src/lcd/language/language_ru.h | 2 +- Marlin/src/lcd/language/language_sk.h | 2 +- Marlin/src/lcd/language/language_tr.h | 2 +- Marlin/src/lcd/language/language_uk.h | 2 +- Marlin/src/lcd/language/language_vi.h | 2 +- Marlin/src/lcd/language/language_zh_CN.h | 2 +- Marlin/src/lcd/language/language_zh_TW.h | 2 +- Marlin/src/lcd/menu/menu_configuration.cpp | 152 +++++++++++++++++ Marlin/src/lcd/menu/menu_custom.cpp | 141 ---------------- Marlin/src/lcd/menu/menu_main.cpp | 156 +++++++++++++++++- .../PlatformIO/scripts/common-dependencies.h | 3 - buildroot/tests/mega2560 | 4 +- 36 files changed, 440 insertions(+), 367 deletions(-) delete mode 100644 Marlin/src/lcd/menu/menu_custom.cpp diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index fb1f79b230..328056cb84 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3415,6 +3415,71 @@ #define GCODE_MACROS_SLOT_SIZE 50 // Maximum length of a single macro #endif +/** + * User-defined menu items to run custom G-code. + * Up to 25 may be defined, but the actual number is LCD-dependent. + */ + +// Custom Menu: Main Menu +//#define CUSTOM_MENU_MAIN +#if ENABLED(CUSTOM_MENU_MAIN) + //#define CUSTOM_MENU_MAIN_TITLE "Custom Commands" + #define CUSTOM_MENU_MAIN_SCRIPT_DONE "M117 User Script Done" + #define CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK + //#define CUSTOM_MENU_MAIN_SCRIPT_RETURN // Return to status screen after a script + #define CUSTOM_MENU_MAIN_ONLY_IDLE // Only show custom menu when the machine is idle + + #define MAIN_MENU_ITEM_1_DESC "Home & UBL Info" + #define MAIN_MENU_ITEM_1_GCODE "G28\nG29 W" + //#define MAIN_MENU_ITEM_1_CONFIRM // Show a confirmation dialog before this action + + #define MAIN_MENU_ITEM_2_DESC "Preheat for " PREHEAT_1_LABEL + #define MAIN_MENU_ITEM_2_GCODE "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) + //#define MAIN_MENU_ITEM_2_CONFIRM + + //#define MAIN_MENU_ITEM_3_DESC "Preheat for " PREHEAT_2_LABEL + //#define MAIN_MENU_ITEM_3_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) + //#define MAIN_MENU_ITEM_3_CONFIRM + + //#define MAIN_MENU_ITEM_4_DESC "Heat Bed/Home/Level" + //#define MAIN_MENU_ITEM_4_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29" + //#define MAIN_MENU_ITEM_4_CONFIRM + + //#define MAIN_MENU_ITEM_5_DESC "Home & Info" + //#define MAIN_MENU_ITEM_5_GCODE "G28\nM503" + //#define MAIN_MENU_ITEM_5_CONFIRM +#endif + +// Custom Menu: Configuration Menu +//#define CUSTOM_MENU_CONFIG +#if ENABLED(CUSTOM_MENU_CONFIG) + //#define CUSTOM_MENU_CONFIG_TITLE "Custom Commands" + #define CUSTOM_MENU_CONFIG_SCRIPT_DONE "M117 Wireless Script Done" + #define CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK + //#define CUSTOM_MENU_CONFIG_SCRIPT_RETURN // Return to status screen after a script + #define CUSTOM_MENU_CONFIG_ONLY_IDLE // Only show custom menu when the machine is idle + + #define CONFIG_MENU_ITEM_1_DESC "Wifi ON" + #define CONFIG_MENU_ITEM_1_GCODE "M118 [ESP110] WIFI-STA pwd=12345678" + //#define CONFIG_MENU_ITEM_1_CONFIRM // Show a confirmation dialog before this action + + #define CONFIG_MENU_ITEM_2_DESC "Bluetooth ON" + #define CONFIG_MENU_ITEM_2_GCODE "M118 [ESP110] BT pwd=12345678" + //#define CONFIG_MENU_ITEM_2_CONFIRM + + //#define CONFIG_MENU_ITEM_3_DESC "Radio OFF" + //#define CONFIG_MENU_ITEM_3_GCODE "M118 [ESP110] OFF pwd=12345678" + //#define CONFIG_MENU_ITEM_3_CONFIRM + + //#define CONFIG_MENU_ITEM_4_DESC "Wifi ????" + //#define CONFIG_MENU_ITEM_4_GCODE "M118 ????" + //#define CONFIG_MENU_ITEM_4_CONFIRM + + //#define CONFIG_MENU_ITEM_5_DESC "Wifi ????" + //#define CONFIG_MENU_ITEM_5_GCODE "M118 ????" + //#define CONFIG_MENU_ITEM_5_CONFIRM +#endif + /** * User-defined buttons to run custom G-code. * Up to 25 may be defined. @@ -3446,39 +3511,6 @@ #endif #endif -/** - * 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) - //#define CUSTOM_USER_MENU_TITLE "Custom Commands" - #define USER_SCRIPT_DONE "M117 User Script Done" - #define USER_SCRIPT_AUDIBLE_FEEDBACK - //#define USER_SCRIPT_RETURN // Return to status screen after a script - #define CUSTOM_MENU_ONLY_IDLE // Only show custom menu when the machine is idle - - #define USER_DESC_1 "Home & UBL Info" - #define USER_GCODE_1 "G28\nG29W" - //#define USER_CONFIRM_1 // Show a confirmation dialog before this action - - #define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL - #define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) - //#define USER_CONFIRM_2 - - #define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL - #define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) - //#define USER_CONFIRM_3 - - #define USER_DESC_4 "Heat Bed/Home/Level" - #define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29" - //#define USER_CONFIRM_4 - - #define USER_DESC_5 "Home & Info" - #define USER_GCODE_5 "G28\nM503" - //#define USER_CONFIRM_5 -#endif - /** * Host Action Commands * diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 490766bd7a..5ef0efa968 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -536,7 +536,7 @@ (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == (N)) || \ (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N)) -#if ENABLED(CUSTOM_USER_MENUS) +#if BOTH(HAS_TFT_LVGL_UI, CUSTOM_MENU_MAIN) #define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N)) #define HAS_USER_ITEM(V...) DO(HAS,||,V) #else diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index d8111c18da..a7f726c4b2 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -553,6 +553,8 @@ #error "Z_AFTER_DEACTIVATE is replaced by Z_IDLE_HEIGHT." #elif defined(MEATPACK) #error "MEATPACK is now enabled with MEATPACK_ON_SERIAL_PORT_1, MEATPACK_ON_SERIAL_PORT_2, etc." +#elif defined(CUSTOM_USER_MENUS) + #error "CUSTOM_USER_MENUS has been replaced by CUSTOM_MENU_MAIN and CUSTOM_MENU_CONFIG." #endif /** @@ -2986,109 +2988,6 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #error "GCODE_MACROS_SLOTS must be a number from 1 to 10." #endif -#if ENABLED(CUSTOM_USER_MENUS) - #ifdef USER_GCODE_1 - constexpr char _chr1 = USER_GCODE_1[strlen(USER_GCODE_1) - 1]; - static_assert(_chr1 != '\n' && _chr1 != '\r', "USER_GCODE_1 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_2 - constexpr char _chr2 = USER_GCODE_2[strlen(USER_GCODE_2) - 1]; - static_assert(_chr2 != '\n' && _chr2 != '\r', "USER_GCODE_2 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_3 - constexpr char _chr3 = USER_GCODE_3[strlen(USER_GCODE_3) - 1]; - static_assert(_chr3 != '\n' && _chr3 != '\r', "USER_GCODE_3 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_4 - constexpr char _chr4 = USER_GCODE_4[strlen(USER_GCODE_4) - 1]; - static_assert(_chr4 != '\n' && _chr4 != '\r', "USER_GCODE_4 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_5 - constexpr char _chr5 = USER_GCODE_5[strlen(USER_GCODE_5) - 1]; - static_assert(_chr5 != '\n' && _chr5 != '\r', "USER_GCODE_5 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_6 - constexpr char _chr6 = USER_GCODE_6[strlen(USER_GCODE_6) - 1]; - static_assert(_chr6 != '\n' && _chr6 != '\r', "USER_GCODE_6 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_7 - constexpr char _chr7 = USER_GCODE_7[strlen(USER_GCODE_7) - 1]; - static_assert(_chr7 != '\n' && _chr7 != '\r', "USER_GCODE_7 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_8 - constexpr char _chr8 = USER_GCODE_8[strlen(USER_GCODE_8) - 1]; - static_assert(_chr8 != '\n' && _chr8 != '\r', "USER_GCODE_8 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_9 - constexpr char _chr9 = USER_GCODE_9[strlen(USER_GCODE_9) - 1]; - static_assert(_chr9 != '\n' && _chr9 != '\r', "USER_GCODE_9 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_10 - constexpr char _chr10 = USER_GCODE_10[strlen(USER_GCODE_10) - 1]; - static_assert(_chr10 != '\n' && _chr10 != '\r', "USER_GCODE_10 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_11 - constexpr char _chr11 = USER_GCODE_11[strlen(USER_GCODE_11) - 1]; - static_assert(_chr11 != '\n' && _chr11 != '\r', "USER_GCODE_11 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_12 - constexpr char _chr12 = USER_GCODE_12[strlen(USER_GCODE_12) - 1]; - static_assert(_chr12 != '\n' && _chr12 != '\r', "USER_GCODE_12 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_13 - constexpr char _chr13 = USER_GCODE_13[strlen(USER_GCODE_13) - 1]; - static_assert(_chr13 != '\n' && _chr13 != '\r', "USER_GCODE_13 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_14 - constexpr char _chr14 = USER_GCODE_14[strlen(USER_GCODE_14) - 1]; - static_assert(_chr14 != '\n' && _chr14 != '\r', "USER_GCODE_14 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_15 - constexpr char _chr15 = USER_GCODE_15[strlen(USER_GCODE_15) - 1]; - static_assert(_chr15 != '\n' && _chr15 != '\r', "USER_GCODE_15 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_16 - constexpr char _chr16 = USER_GCODE_16[strlen(USER_GCODE_16) - 1]; - static_assert(_chr16 != '\n' && _chr16 != '\r', "USER_GCODE_16 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_17 - constexpr char _chr17 = USER_GCODE_17[strlen(USER_GCODE_17) - 1]; - static_assert(_chr17 != '\n' && _chr17 != '\r', "USER_GCODE_17 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_18 - constexpr char _chr18 = USER_GCODE_18[strlen(USER_GCODE_18) - 1]; - static_assert(_chr18 != '\n' && _chr18 != '\r', "USER_GCODE_18 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_19 - constexpr char _chr19 = USER_GCODE_19[strlen(USER_GCODE_19) - 1]; - static_assert(_chr19 != '\n' && _chr19 != '\r', "USER_GCODE_19 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_20 - constexpr char _chr20 = USER_GCODE_20[strlen(USER_GCODE_20) - 1]; - static_assert(_chr20 != '\n' && _chr20 != '\r', "USER_GCODE_20 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_21 - constexpr char _chr21 = USER_GCODE_21[strlen(USER_GCODE_21) - 1]; - static_assert(_chr21 != '\n' && _chr21 != '\r', "USER_GCODE_21 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_22 - constexpr char _chr22 = USER_GCODE_22[strlen(USER_GCODE_22) - 1]; - static_assert(_chr22 != '\n' && _chr22 != '\r', "USER_GCODE_22 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_23 - constexpr char _chr23 = USER_GCODE_23[strlen(USER_GCODE_23) - 1]; - static_assert(_chr23 != '\n' && _chr23 != '\r', "USER_GCODE_23 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_24 - constexpr char _chr24 = USER_GCODE_24[strlen(USER_GCODE_24) - 1]; - static_assert(_chr24 != '\n' && _chr24 != '\r', "USER_GCODE_24 cannot have a newline at the end. Please remove it."); - #endif - #ifdef USER_GCODE_25 - constexpr char _chr25 = USER_GCODE_25[strlen(USER_GCODE_25) - 1]; - static_assert(_chr25 != '\n' && _chr25 != '\r', "USER_GCODE_25 cannot have a newline at the end. Please remove it."); - #endif -#endif - #if ENABLED(BACKLASH_COMPENSATION) #ifndef BACKLASH_DISTANCE_MM #error "BACKLASH_COMPENSATION requires BACKLASH_DISTANCE_MM." 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 ea175706f7..d5d1abdf9d 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 @@ -30,8 +30,8 @@ using namespace ExtUI; using namespace Theme; #define _ITEM_TAG(N) (10+N) -#define _USER_DESC(N) USER_DESC_##N -#define _USER_GCODE(N) USER_GCODE_##N +#define _USER_DESC(N) MAIN_MENU_ITEM_##N##_DESC +#define _USER_GCODE(N) MAIN_MENU_ITEM_##N##_GCODE #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; 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 b7914d629b..53d6306175 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 @@ -41,9 +41,9 @@ void MainMenu::onRedraw(draw_mode_t what) { #define GRID_COLS 2 #define ABOUT_PRINTER_POS BTN_POS(1,1), BTN_SIZE(2,1) #define ADVANCED_SETTINGS_POS BTN_POS(1,2), BTN_SIZE(2,1) - #if ENABLED(CUSTOM_USER_MENUS) + #if ENABLED(CUSTOM_MENU_MAIN) #define FILAMENTCHANGE_POS BTN_POS(1,3), BTN_SIZE(1,1) - #define CUSTOM_USER_MENUS_POS BTN_POS(2,3), BTN_SIZE(1,1) + #define CUSTOM_MENU_POS BTN_POS(2,3), BTN_SIZE(1,1) #else #define FILAMENTCHANGE_POS BTN_POS(1,3), BTN_SIZE(2,1) #endif @@ -63,10 +63,10 @@ void MainMenu::onRedraw(draw_mode_t what) { #define CLEAN_NOZZLE_POS BTN_POS(4,2), BTN_SIZE(3,1) #define MOVE_AXIS_POS BTN_POS(1,3), BTN_SIZE(3,1) #define DISABLE_STEPPERS_POS BTN_POS(4,3), BTN_SIZE(3,1) - #if ENABLED(CUSTOM_USER_MENUS) + #if ENABLED(CUSTOM_MENU_MAIN) #define TEMPERATURE_POS BTN_POS(1,4), BTN_SIZE(2,1) #define FILAMENTCHANGE_POS BTN_POS(3,4), BTN_SIZE(2,1) - #define CUSTOM_USER_MENUS_POS BTN_POS(5,4), BTN_SIZE(2,1) + #define CUSTOM_MENU_POS BTN_POS(5,4), BTN_SIZE(2,1) #else #define TEMPERATURE_POS BTN_POS(1,4), BTN_SIZE(3,1) #define FILAMENTCHANGE_POS BTN_POS(4,4), BTN_SIZE(3,1) @@ -91,8 +91,8 @@ void MainMenu::onRedraw(draw_mode_t what) { .enabled(TERN_(HAS_LEVELING, 1)) .tag( 9).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING)) .tag(10).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU)) - #if ENABLED(CUSTOM_USER_MENUS) - .tag(11).button(CUSTOM_USER_MENUS_POS, GET_TEXT_F(MSG_USER_MENU)) + #if ENABLED(CUSTOM_MENU_MAIN) + .tag(11).button(CUSTOM_MENU_POS, GET_TEXT_F(MSG_CUSTOM_COMMANDS)) #endif .colors(action_btn) .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); @@ -117,7 +117,7 @@ bool MainMenu::onTouchEnd(uint8_t tag) { case 9: GOTO_SCREEN(LevelingMenu); break; #endif case 10: GOTO_SCREEN(AboutScreen); break; - #if ENABLED(CUSTOM_USER_MENUS) + #if ENABLED(CUSTOM_MENU_MAIN) case 11: GOTO_SCREEN(CustomUserMenus); break; #endif 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 61d702ebaf..3e69a3ad2f 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,8 +22,6 @@ #pragma once -#if ENABLED(TOUCH_UI_FTDI_EVE) - #include "../ftdi_eve_lib/ftdi_eve_lib.h" #include "../language/language.h" #include "../theme/theme.h" @@ -107,7 +105,7 @@ enum { #if ENABLED(SDSUPPORT) FILES_SCREEN_CACHE, #endif - #if ENABLED(CUSTOM_USER_MENUS) + #if ENABLED(CUSTOM_MENU_MAIN) CUSTOM_USER_MENUS_SCREEN_CACHE, #endif CHANGE_FILAMENT_SCREEN_CACHE, @@ -248,7 +246,7 @@ enum { #include "files_screen.h" #endif -#if ENABLED(CUSTOM_USER_MENUS) +#if ENABLED(CUSTOM_MENU_MAIN) #include "custom_user_menus.h" #endif @@ -262,5 +260,3 @@ enum { #if NUM_LANGUAGES > 1 #include "language_menu.h" #endif - -#endif // TOUCH_UI_FTDI_EVE 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 fd5780e1d8..12a57bd548 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 @@ -728,9 +728,9 @@ #define EEPROM_READ_TIPS_EN "Read settings from EEPROM?" #define EEPROM_REVERT_TIPS_EN "Revert settings to factory defaults?" -#define MORE_CUSTOM1_TEXT_EN USER_DESC_1 -#define MORE_CUSTOM2_TEXT_EN USER_DESC_2 -#define MORE_CUSTOM3_TEXT_EN USER_DESC_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_CUSTOM1_TEXT_EN MAIN_MENU_ITEM_1_DESC +#define MORE_CUSTOM2_TEXT_EN MAIN_MENU_ITEM_2_DESC +#define MORE_CUSTOM3_TEXT_EN MAIN_MENU_ITEM_3_DESC +#define MORE_CUSTOM4_TEXT_EN MAIN_MENU_ITEM_4_DESC +#define MORE_CUSTOM5_TEXT_EN MAIN_MENU_ITEM_5_DESC +#define MORE_CUSTOM6_TEXT_EN MAIN_MENU_ITEM_6_DESC 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 9440b8b0eb..f0b19d4e02 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 @@ -260,9 +260,9 @@ #define EEPROM_READ_TIPS_FR "Lire les paramètres de l'EEPROM?" #define EEPROM_REVERT_TIPS_FR "Rétablir les paramètres par défaut d'usine?" -#define MORE_CUSTOM1_TEXT_FR USER_DESC_1 -#define MORE_CUSTOM2_TEXT_FR USER_DESC_2 -#define MORE_CUSTOM3_TEXT_FR USER_DESC_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_CUSTOM1_TEXT_FR MAIN_MENU_ITEM_1_DESC +#define MORE_CUSTOM2_TEXT_FR MAIN_MENU_ITEM_2_DESC +#define MORE_CUSTOM3_TEXT_FR MAIN_MENU_ITEM_3_DESC +#define MORE_CUSTOM4_TEXT_FR MAIN_MENU_ITEM_4_DESC +#define MORE_CUSTOM5_TEXT_FR MAIN_MENU_ITEM_5_DESC +#define MORE_CUSTOM6_TEXT_FR MAIN_MENU_ITEM_6_DESC 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 9b88de3df4..b74842afef 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 @@ -257,9 +257,9 @@ #define EEPROM_READ_TIPS_IT "Leggi le impostazioni dalla EEPROM?" #define EEPROM_REVERT_TIPS_IT "Ripristinare le impostazioni predefinite?" -#define MORE_CUSTOM1_TEXT_IT USER_DESC_1 -#define MORE_CUSTOM2_TEXT_IT USER_DESC_2 -#define MORE_CUSTOM3_TEXT_IT USER_DESC_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_CUSTOM1_TEXT_IT MAIN_MENU_ITEM_1_DESC +#define MORE_CUSTOM2_TEXT_IT MAIN_MENU_ITEM_2_DESC +#define MORE_CUSTOM3_TEXT_IT MAIN_MENU_ITEM_3_DESC +#define MORE_CUSTOM4_TEXT_IT MAIN_MENU_ITEM_4_DESC +#define MORE_CUSTOM5_TEXT_IT MAIN_MENU_ITEM_5_DESC +#define MORE_CUSTOM6_TEXT_IT MAIN_MENU_ITEM_6_DESC 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 1989eaef1b..50e32ac05c 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 @@ -255,12 +255,12 @@ #define EEPROM_SETTINGS_READ_RU "Чтение настроек из EEPROM" #define EEPROM_SETTINGS_REVERT_RU "Bосстановить заводские настройки по умолчанию" -#define MORE_CUSTOM1_TEXT_RU USER_DESC_1 -#define MORE_CUSTOM2_TEXT_RU USER_DESC_2 -#define MORE_CUSTOM3_TEXT_RU USER_DESC_3 -#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_CUSTOM1_TEXT_RU MAIN_MENU_ITEM_1_DESC +#define MORE_CUSTOM2_TEXT_RU MAIN_MENU_ITEM_2_DESC +#define MORE_CUSTOM3_TEXT_RU MAIN_MENU_ITEM_3_DESC +#define MORE_CUSTOM4_TEXT_RU MAIN_MENU_ITEM_4_DESC +#define MORE_CUSTOM5_TEXT_RU MAIN_MENU_ITEM_5_DESC +#define MORE_CUSTOM6_TEXT_RU MAIN_MENU_ITEM_6_DESC #define EEPROM_STORE_TIPS_RU "Cохранить настройки в EEPROM?" #define EEPROM_READ_TIPS_RU "читать настройки из EEPROM?" 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 cc1a870339..f204933e25 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 @@ -495,9 +495,9 @@ #define EEPROM_READ_TIPS_CN "是否使用EEPROM参数?" #define EEPROM_REVERT_TIPS_CN "是否恢复默认参数?" -#define MORE_CUSTOM1_TEXT_CN USER_DESC_1 -#define MORE_CUSTOM2_TEXT_CN USER_DESC_2 -#define MORE_CUSTOM3_TEXT_CN USER_DESC_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_CUSTOM1_TEXT_CN MAIN_MENU_ITEM_1_DESC +#define MORE_CUSTOM2_TEXT_CN MAIN_MENU_ITEM_2_DESC +#define MORE_CUSTOM3_TEXT_CN MAIN_MENU_ITEM_3_DESC +#define MORE_CUSTOM4_TEXT_CN MAIN_MENU_ITEM_4_DESC +#define MORE_CUSTOM5_TEXT_CN MAIN_MENU_ITEM_5_DESC +#define MORE_CUSTOM6_TEXT_CN MAIN_MENU_ITEM_6_DESC 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 4654abddee..a75bc69ab7 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 @@ -266,9 +266,9 @@ #define EEPROM_READ_TIPS_SP "Leer la configuración de EEPROM?" #define EEPROM_REVERT_TIPS_SP "Revert settings to factory defaults?" -#define MORE_CUSTOM1_TEXT_SP USER_DESC_1 -#define MORE_CUSTOM2_TEXT_SP USER_DESC_2 -#define MORE_CUSTOM3_TEXT_SP USER_DESC_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_CUSTOM1_TEXT_SP MAIN_MENU_ITEM_1_DESC +#define MORE_CUSTOM2_TEXT_SP MAIN_MENU_ITEM_2_DESC +#define MORE_CUSTOM3_TEXT_SP MAIN_MENU_ITEM_3_DESC +#define MORE_CUSTOM4_TEXT_SP MAIN_MENU_ITEM_4_DESC +#define MORE_CUSTOM5_TEXT_SP MAIN_MENU_ITEM_5_DESC +#define MORE_CUSTOM6_TEXT_SP MAIN_MENU_ITEM_6_DESC 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 8057a3110e..76da2de907 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 @@ -493,9 +493,9 @@ #define EEPROM_READ_TIPS_T_CN "是否使用EEPROM參數?" #define EEPROM_REVERT_TIPS_T_CN "是否恢復默認參數?" -#define MORE_CUSTOM1_TEXT_T_CN USER_DESC_1 -#define MORE_CUSTOM2_TEXT_T_CN USER_DESC_2 -#define MORE_CUSTOM3_TEXT_T_CN USER_DESC_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_CUSTOM1_TEXT_T_CN MAIN_MENU_ITEM_1_DESC +#define MORE_CUSTOM2_TEXT_T_CN MAIN_MENU_ITEM_2_DESC +#define MORE_CUSTOM3_TEXT_T_CN MAIN_MENU_ITEM_3_DESC +#define MORE_CUSTOM4_TEXT_T_CN MAIN_MENU_ITEM_4_DESC +#define MORE_CUSTOM5_TEXT_T_CN MAIN_MENU_ITEM_5_DESC +#define MORE_CUSTOM6_TEXT_T_CN MAIN_MENU_ITEM_6_DESC diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index adcbba7720..c434f5493b 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -119,7 +119,7 @@ namespace Language_cz { PROGMEM Language_Str MSG_MESH_Y = _UxGT("Index Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Hodnota Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Vlastní příkazy"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Vlastní příkazy"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 test sondy"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 bod"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Odchylka"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 68791d9eaa..ebc2445b11 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -112,7 +112,7 @@ namespace Language_de { 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-Wert"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Benutzer-Menü"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Benutzer-Menü"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Sondentest"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Punkt"); PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Zu weit draußen"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 72f262c687..a37f5aa790 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -140,7 +140,7 @@ namespace Language_en { 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 Value"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Custom Commands"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Custom Commands"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Probe Test"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Point"); PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Probe out of bounds"); diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 58559a4ff5..b2d83aa05b 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -115,7 +115,7 @@ namespace Language_es { PROGMEM Language_Str MSG_MESH_X = _UxGT("Índice X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Índice Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Valor Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Com. Personalizados"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Com. Personalizados"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Probar Sonda"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Punto"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Desviación"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 031db358bd..bdd91d3b29 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -113,7 +113,7 @@ namespace Language_fr { 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("Valeur Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Commandes perso"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Commandes perso"); PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Mesure point"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("Ecart sonde Z M48"); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index d0ec16b35f..5745ce1eb8 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -112,7 +112,7 @@ namespace Language_gl { PROGMEM Language_Str MSG_MESH_X = _UxGT("Índice X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Índice Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Valor Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Comandos Personaliz."); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Comandos Personaliz."); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Probar Sonda"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Punto"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Desviación"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 5bfb6aa9aa..be54d5035d 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -138,7 +138,7 @@ namespace Language_it { PROGMEM Language_Str MSG_MESH_X = _UxGT("Indice X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Indice Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Valore di Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Comandi personaliz."); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Comandi personaliz."); PROGMEM Language_Str MSG_M48_TEST = _UxGT("Test sonda M48"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("Punto M48"); PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Sonda oltre i limiti"); diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index 8431d86d1c..e0028e22a2 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -246,7 +246,7 @@ namespace Language_jp_kana { PROGMEM Language_Str MSG_BACK = _UxGT("モドリ"); PROGMEM Language_Str MSG_VELOCITY = _UxGT("ソクド"); PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("ステップ/mm"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("ユーザーコマンド"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("ユーザーコマンド"); PROGMEM Language_Str MSG_PRINT_PAUSED = _UxGT("プリントガイチジテイシサレマシタ"); PROGMEM Language_Str MSG_PRINTING = _UxGT("プリントチュウ..."); } diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index bf7d32e222..9004722cfc 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -109,7 +109,7 @@ namespace Language_pl { PROGMEM Language_Str MSG_MESH_X = _UxGT("Indeks X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Indeks Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Wartość Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Własne Polecenia"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Własne Polecenia"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Test sondy"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Punky"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Odchylenie"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index 4ddf424b3d..642a7d9203 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -103,7 +103,7 @@ namespace Language_pt_br { PROGMEM Language_Str MSG_MESH_X = _UxGT("Índice X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Índice Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Valor Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Comando customizado"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Comando customizado"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Teste de sonda"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Ponto"); PROGMEM Language_Str MSG_IDEX_MENU = _UxGT("Modo IDEX"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index bd7e1b7a64..a34717acb5 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -111,7 +111,7 @@ namespace Language_ro { 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("Valoare Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Comenzi Personalizate"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Comenzi Personalizate"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Probe Test"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Point"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Deviation"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index b3176c0a54..a10f47ef8e 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -139,7 +139,7 @@ namespace Language_ru { PROGMEM Language_Str MSG_MESH_X = _UxGT("Индекс X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Индекс Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Значение Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Свои команды"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Свои команды"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 тест Z-зонда"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Отклонение"); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index a9df28382e..2e851842e4 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -140,7 +140,7 @@ namespace Language_sk { 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("Hodnota Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Vlastné príkazy"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Vlastné príkazy"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Test sondy"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Bod"); PROGMEM Language_Str MSG_M48_OUT_OF_BOUNDS = _UxGT("Sonda mimo hraníc"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index a7a4056c0b..9d711ff376 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -114,7 +114,7 @@ namespace Language_tr { PROGMEM Language_Str MSG_MESH_X = _UxGT("İndeks X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("İndeks Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Z Değeri"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Özel Komutlar"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Özel Komutlar"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 Prob Testi"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 Nokta"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("Sapma"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 069ad7066d..be0e420a42 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -151,7 +151,7 @@ namespace Language_uk { PROGMEM Language_Str MSG_MESH_X = _UxGT("Індекс X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("Індекс Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Значення Z"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Власні команди"); + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Власні команди"); PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 тест зонду"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 точка"); diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index fad32507ce..f0b7f732ed 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -96,7 +96,7 @@ namespace Language_vi { PROGMEM Language_Str MSG_MESH_X = _UxGT("Mục lục X"); // Index X PROGMEM Language_Str MSG_MESH_Y = _UxGT("Mục lục Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Giá trị Z"); // Z Value - PROGMEM Language_Str MSG_USER_MENU = _UxGT("Các lệnh tự chọn"); // Custom Commands + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("Các lệnh tự chọn"); // Custom Commands PROGMEM Language_Str MSG_UBL_DOING_G29 = _UxGT("Đang chạy G29"); // Doing G29 PROGMEM Language_Str MSG_UBL_TOOLS = _UxGT("Công cụ UBL"); // UBL tools PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("San Lấp Bàn Thống Nhất (UBL)"); // Unified Bed Leveling diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index 5e7c5e7cb5..98f7704efc 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -109,7 +109,7 @@ namespace Language_zh_CN { PROGMEM Language_Str MSG_MESH_X = _UxGT("索引X"); PROGMEM Language_Str MSG_MESH_Y = _UxGT("索引Y"); PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Z 值"); - PROGMEM Language_Str MSG_USER_MENU = _UxGT("定制命令"); // "Custom Commands" + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("定制命令"); // "Custom Commands" PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48探测"); PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48点"); PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("M48偏差"); diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index f86b15351f..0ada34a476 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -107,7 +107,7 @@ namespace Language_zh_TW { PROGMEM Language_Str MSG_MESH_X = _UxGT("索引 X"); //"Index X" PROGMEM Language_Str MSG_MESH_Y = _UxGT("索引 Y"); //"Index Y" PROGMEM Language_Str MSG_MESH_EDIT_Z = _UxGT("Z 值"); //"Z Value" - PROGMEM Language_Str MSG_USER_MENU = _UxGT("自定命令"); // "Custom Commands" + PROGMEM Language_Str MSG_CUSTOM_COMMANDS = _UxGT("自定命令"); // "Custom Commands" PROGMEM Language_Str MSG_M48_TEST = _UxGT("M48 探測測試"); //"M48 Probe Test" PROGMEM Language_Str MSG_M48_POINT = _UxGT("M48 探測點"); //"M48 Point" PROGMEM Language_Str MSG_M48_DEVIATION = _UxGT("偏差"); //"Deviation" diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 179a2c2d55..71f09a5aee 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -338,6 +338,148 @@ void menu_advanced_settings(); #endif +#if ENABLED(CUSTOM_MENU_CONFIG) + + void _lcd_custom_menus_configuration_gcode(PGM_P const cmd) { + queue.inject_P(cmd); + TERN_(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); + TERN_(CUSTOM_MENU_CONFIG_SCRIPT_RETURN, ui.return_to_status()); + } + + void custom_menus_configuration() { + START_MENU(); + BACK_ITEM(MSG_MAIN); + + #define HAS_CUSTOM_ITEM_CONF(N) (defined(CONFIG_MENU_ITEM_##N##_DESC) && defined(CONFIG_MENU_ITEM_##N##_GCODE)) + + #define CUSTOM_TEST_CONF(N) do{ \ + constexpr char c = CONFIG_MENU_ITEM_##N##_GCODE[strlen(CONFIG_MENU_ITEM_##N##_GCODE) - 1]; \ + static_assert(c != '\n' && c != '\r', "CONFIG_MENU_ITEM_" STRINGIFY(N) "_GCODE cannot have a newline at the end. Please remove it."); \ + }while(0) + + #ifdef CUSTOM_MENU_CONFIG_SCRIPT_DONE + #define _DONE_SCRIPT "\n" CUSTOM_MENU_CONFIG_SCRIPT_DONE + #else + #define _DONE_SCRIPT "" + #endif + #define GCODE_LAMBDA_CONF(N) []{ _lcd_custom_menus_configuration_gcode(PSTR(CONFIG_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } + #define _CUSTOM_ITEM_CONF(N) ACTION_ITEM_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_CONF(N)); + #define _CUSTOM_ITEM_CONF_CONFIRM(N) \ + SUBMENU_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), []{ \ + MenuItem_confirm::confirm_screen( \ + GCODE_LAMBDA_CONF(N), \ + ui.goto_previous_screen, \ + PSTR(CONFIG_MENU_ITEM_##N##_DESC "?") \ + ); \ + }) + + #define CUSTOM_ITEM_CONF(N) do{ if (ENABLED(CONFIG_MENU_ITEM_##N##_CONFIRM)) _CUSTOM_ITEM_CONF_CONFIRM(N); else _CUSTOM_ITEM_CONF(N); }while(0) + + #if HAS_CUSTOM_ITEM_CONF(1) + CUSTOM_TEST_CONF(1); + CUSTOM_ITEM_CONF(1); + #endif + #if HAS_CUSTOM_ITEM_CONF(2) + CUSTOM_TEST_CONF(2); + CUSTOM_ITEM_CONF(2); + #endif + #if HAS_CUSTOM_ITEM_CONF(3) + CUSTOM_TEST_CONF(3); + CUSTOM_ITEM_CONF(3); + #endif + #if HAS_CUSTOM_ITEM_CONF(4) + CUSTOM_TEST_CONF(4); + CUSTOM_ITEM_CONF(4); + #endif + #if HAS_CUSTOM_ITEM_CONF(5) + CUSTOM_TEST_CONF(5); + CUSTOM_ITEM_CONF(5); + #endif + #if HAS_CUSTOM_ITEM_CONF(6) + CUSTOM_TEST_CONF(6); + CUSTOM_ITEM_CONF(6); + #endif + #if HAS_CUSTOM_ITEM_CONF(7) + CUSTOM_TEST_CONF(7); + CUSTOM_ITEM_CONF(7); + #endif + #if HAS_CUSTOM_ITEM_CONF(8) + CUSTOM_TEST_CONF(8); + CUSTOM_ITEM_CONF(8); + #endif + #if HAS_CUSTOM_ITEM_CONF(9) + CUSTOM_TEST_CONF(9); + CUSTOM_ITEM_CONF(9); + #endif + #if HAS_CUSTOM_ITEM_CONF(10) + CUSTOM_TEST_CONF(10); + CUSTOM_ITEM_CONF(10); + #endif + #if HAS_CUSTOM_ITEM_CONF(11) + CUSTOM_TEST_CONF(11); + CUSTOM_ITEM_CONF(11); + #endif + #if HAS_CUSTOM_ITEM_CONF(12) + CUSTOM_TEST_CONF(12); + CUSTOM_ITEM_CONF(12); + #endif + #if HAS_CUSTOM_ITEM_CONF(13) + CUSTOM_TEST_CONF(13); + CUSTOM_ITEM_CONF(13); + #endif + #if HAS_CUSTOM_ITEM_CONF(14) + CUSTOM_TEST_CONF(14); + CUSTOM_ITEM_CONF(14); + #endif + #if HAS_CUSTOM_ITEM_CONF(15) + CUSTOM_TEST_CONF(15); + CUSTOM_ITEM_CONF(15); + #endif + #if HAS_CUSTOM_ITEM_CONF(16) + CUSTOM_TEST_CONF(16); + CUSTOM_ITEM_CONF(16); + #endif + #if HAS_CUSTOM_ITEM_CONF(17) + CUSTOM_TEST_CONF(17); + CUSTOM_ITEM_CONF(17); + #endif + #if HAS_CUSTOM_ITEM_CONF(18) + CUSTOM_TEST_CONF(18); + CUSTOM_ITEM_CONF(18); + #endif + #if HAS_CUSTOM_ITEM_CONF(19) + CUSTOM_TEST_CONF(19); + CUSTOM_ITEM_CONF(19); + #endif + #if HAS_CUSTOM_ITEM_CONF(20) + CUSTOM_TEST_CONF(20); + CUSTOM_ITEM_CONF(20); + #endif + #if HAS_CUSTOM_ITEM_CONF(21) + CUSTOM_TEST_CONF(21); + CUSTOM_ITEM_CONF(21); + #endif + #if HAS_CUSTOM_ITEM_CONF(22) + CUSTOM_TEST_CONF(22); + CUSTOM_ITEM_CONF(22); + #endif + #if HAS_CUSTOM_ITEM_CONF(23) + CUSTOM_TEST_CONF(23); + CUSTOM_ITEM_CONF(23); + #endif + #if HAS_CUSTOM_ITEM_CONF(24) + CUSTOM_TEST_CONF(24); + CUSTOM_ITEM_CONF(24); + #endif + #if HAS_CUSTOM_ITEM_CONF(25) + CUSTOM_TEST_CONF(25); + CUSTOM_ITEM_CONF(25); + #endif + END_MENU(); + } + +#endif // CUSTOM_MENU_CONFIG + void menu_configuration() { const bool busy = printer_busy(); @@ -351,6 +493,16 @@ void menu_configuration() { SUBMENU(MSG_DEBUG_MENU, menu_debug); #endif + #if ENABLED(CUSTOM_MENU_CONFIG) + if (TERN1(CUSTOM_MENU_CONFIG_ONLY_IDLE, !busy)) { + #ifdef CUSTOM_MENU_CONFIG_TITLE + SUBMENU_P(PSTR(CUSTOM_MENU_CONFIG_TITLE), custom_menus_configuration); + #else + SUBMENU(MSG_CUSTOM_COMMANDS, custom_menus_configuration); + #endif + } + #endif + SUBMENU(MSG_ADVANCED_SETTINGS, menu_advanced_settings); #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/lcd/menu/menu_custom.cpp b/Marlin/src/lcd/menu/menu_custom.cpp deleted file mode 100644 index cc1a8a6e80..0000000000 --- a/Marlin/src/lcd/menu/menu_custom.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/** - * 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 . - * - */ - -// -// Custom User Menu -// - -#include "../../inc/MarlinConfigPre.h" - -#if BOTH(HAS_LCD_MENU, CUSTOM_USER_MENUS) - -#include "menu_item.h" -#include "../../gcode/queue.h" - -#ifdef USER_SCRIPT_DONE - #define _DONE_SCRIPT "\n" USER_SCRIPT_DONE -#else - #define _DONE_SCRIPT "" -#endif - -void _lcd_user_gcode(PGM_P const cmd) { - queue.inject_P(cmd); - TERN_(USER_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); - TERN_(USER_SCRIPT_RETURN, ui.return_to_status()); -} - -void menu_user() { - START_MENU(); - BACK_ITEM(MSG_MAIN); - - #define GCODE_LAMBDA(N) []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); } - #define _USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), GCODE_LAMBDA(N)); - #define _USER_ITEM_CONFIRM(N) \ - SUBMENU_P(PSTR(USER_DESC_##N), []{ \ - MenuItem_confirm::confirm_screen( \ - GCODE_LAMBDA(N), \ - ui.goto_previous_screen, \ - PSTR(USER_DESC_##N "?") \ - ); \ - }) - - #define USER_ITEM(N) do{ if (ENABLED(USER_CONFIRM_##N)) _USER_ITEM_CONFIRM(N); else _USER_ITEM(N); }while(0) - - #if HAS_USER_ITEM(1) - USER_ITEM(1); - #endif - #if HAS_USER_ITEM(2) - USER_ITEM(2); - #endif - #if HAS_USER_ITEM(3) - USER_ITEM(3); - #endif - #if HAS_USER_ITEM(4) - USER_ITEM(4); - #endif - #if HAS_USER_ITEM(5) - USER_ITEM(5); - #endif - #if HAS_USER_ITEM(6) - USER_ITEM(6); - #endif - #if HAS_USER_ITEM(7) - USER_ITEM(7); - #endif - #if HAS_USER_ITEM(8) - USER_ITEM(8); - #endif - #if HAS_USER_ITEM(9) - USER_ITEM(9); - #endif - #if HAS_USER_ITEM(10) - USER_ITEM(10); - #endif - #if HAS_USER_ITEM(11) - USER_ITEM(11); - #endif - #if HAS_USER_ITEM(12) - USER_ITEM(12); - #endif - #if HAS_USER_ITEM(13) - USER_ITEM(13); - #endif - #if HAS_USER_ITEM(14) - USER_ITEM(14); - #endif - #if HAS_USER_ITEM(15) - USER_ITEM(15); - #endif - #if HAS_USER_ITEM(16) - USER_ITEM(16); - #endif - #if HAS_USER_ITEM(17) - USER_ITEM(17); - #endif - #if HAS_USER_ITEM(18) - USER_ITEM(18); - #endif - #if HAS_USER_ITEM(19) - USER_ITEM(19); - #endif - #if HAS_USER_ITEM(20) - USER_ITEM(20); - #endif - #if HAS_USER_ITEM(21) - USER_ITEM(21); - #endif - #if HAS_USER_ITEM(22) - USER_ITEM(22); - #endif - #if HAS_USER_ITEM(23) - USER_ITEM(23); - #endif - #if HAS_USER_ITEM(24) - USER_ITEM(24); - #endif - #if HAS_USER_ITEM(25) - USER_ITEM(25); - #endif - END_MENU(); -} - -#endif // HAS_LCD_MENU && CUSTOM_USER_MENUS diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index d19e236a84..525b8c8a70 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -68,10 +68,6 @@ void menu_motion(); void menu_temperature(); void menu_configuration(); -#if ENABLED(CUSTOM_USER_MENUS) - void menu_user(); -#endif - #if HAS_POWER_MONITOR void menu_power_monitor(); #endif @@ -105,6 +101,148 @@ void menu_configuration(); void menu_language(); #endif +#if ENABLED(CUSTOM_MENU_MAIN) + + void _lcd_custom_menu_main_gcode(PGM_P const cmd) { + queue.inject_P(cmd); + TERN_(MAIN_MENU_ITEM_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); + TERN_(MAIN_MENU_ITEM_SCRIPT_RETURN, ui.return_to_status()); + } + + void custom_menus_main() { + START_MENU(); + BACK_ITEM(MSG_MAIN); + + #define HAS_CUSTOM_ITEM_MAIN(N) (defined(MAIN_MENU_ITEM_##N##_DESC) && defined(MAIN_MENU_ITEM_##N##_GCODE)) + + #define CUSTOM_TEST_MAIN(N) do{ \ + constexpr char c = MAIN_MENU_ITEM_##N##_GCODE[strlen(MAIN_MENU_ITEM_##N##_GCODE) - 1]; \ + static_assert(c != '\n' && c != '\r', "MAIN_MENU_ITEM_" STRINGIFY(N) "_GCODE cannot have a newline at the end. Please remove it."); \ + }while(0) + + #ifdef MAIN_MENU_ITEM_SCRIPT_DONE + #define _DONE_SCRIPT "\n" MAIN_MENU_ITEM_SCRIPT_DONE + #else + #define _DONE_SCRIPT "" + #endif + #define GCODE_LAMBDA_MAIN(N) []{ _lcd_custom_menu_main_gcode(PSTR(MAIN_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } + #define _CUSTOM_ITEM_MAIN(N) ACTION_ITEM_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_MAIN(N)); + #define _CUSTOM_ITEM_MAIN_CONFIRM(N) \ + SUBMENU_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), []{ \ + MenuItem_confirm::confirm_screen( \ + GCODE_LAMBDA_MAIN(N), \ + ui.goto_previous_screen, \ + PSTR(MAIN_MENU_ITEM_##N##_DESC "?") \ + ); \ + }) + + #define CUSTOM_ITEM_MAIN(N) do{ if (ENABLED(MAIN_MENU_ITEM_##N##_CONFIRM)) _CUSTOM_ITEM_MAIN_CONFIRM(N); else _CUSTOM_ITEM_MAIN(N); }while(0) + + #if HAS_CUSTOM_ITEM_MAIN(1) + CUSTOM_TEST_MAIN(1); + CUSTOM_ITEM_MAIN(1); + #endif + #if HAS_CUSTOM_ITEM_MAIN(2) + CUSTOM_TEST_MAIN(2); + CUSTOM_ITEM_MAIN(2); + #endif + #if HAS_CUSTOM_ITEM_MAIN(3) + CUSTOM_TEST_MAIN(3); + CUSTOM_ITEM_MAIN(3); + #endif + #if HAS_CUSTOM_ITEM_MAIN(4) + CUSTOM_TEST_MAIN(4); + CUSTOM_ITEM_MAIN(4); + #endif + #if HAS_CUSTOM_ITEM_MAIN(5) + CUSTOM_TEST_MAIN(5); + CUSTOM_ITEM_MAIN(5); + #endif + #if HAS_CUSTOM_ITEM_MAIN(6) + CUSTOM_TEST_MAIN(6); + CUSTOM_ITEM_MAIN(6); + #endif + #if HAS_CUSTOM_ITEM_MAIN(7) + CUSTOM_TEST_MAIN(7); + CUSTOM_ITEM_MAIN(7); + #endif + #if HAS_CUSTOM_ITEM_MAIN(8) + CUSTOM_TEST_MAIN(8); + CUSTOM_ITEM_MAIN(8); + #endif + #if HAS_CUSTOM_ITEM_MAIN(9) + CUSTOM_TEST_MAIN(9); + CUSTOM_ITEM_MAIN(9); + #endif + #if HAS_CUSTOM_ITEM_MAIN(10) + CUSTOM_TEST_MAIN(10); + CUSTOM_ITEM_MAIN(10); + #endif + #if HAS_CUSTOM_ITEM_MAIN(11) + CUSTOM_TEST_MAIN(11); + CUSTOM_ITEM_MAIN(11); + #endif + #if HAS_CUSTOM_ITEM_MAIN(12) + CUSTOM_TEST_MAIN(12); + CUSTOM_ITEM_MAIN(12); + #endif + #if HAS_CUSTOM_ITEM_MAIN(13) + CUSTOM_TEST_MAIN(13); + CUSTOM_ITEM_MAIN(13); + #endif + #if HAS_CUSTOM_ITEM_MAIN(14) + CUSTOM_TEST_MAIN(14); + CUSTOM_ITEM_MAIN(14); + #endif + #if HAS_CUSTOM_ITEM_MAIN(15) + CUSTOM_TEST_MAIN(15); + CUSTOM_ITEM_MAIN(15); + #endif + #if HAS_CUSTOM_ITEM_MAIN(16) + CUSTOM_TEST_MAIN(16); + CUSTOM_ITEM_MAIN(16); + #endif + #if HAS_CUSTOM_ITEM_MAIN(17) + CUSTOM_TEST_MAIN(17); + CUSTOM_ITEM_MAIN(17); + #endif + #if HAS_CUSTOM_ITEM_MAIN(18) + CUSTOM_TEST_MAIN(18); + CUSTOM_ITEM_MAIN(18); + #endif + #if HAS_CUSTOM_ITEM_MAIN(19) + CUSTOM_TEST_MAIN(19); + CUSTOM_ITEM_MAIN(19); + #endif + #if HAS_CUSTOM_ITEM_MAIN(20) + CUSTOM_TEST_MAIN(20); + CUSTOM_ITEM_MAIN(20); + #endif + #if HAS_CUSTOM_ITEM_MAIN(21) + CUSTOM_TEST_MAIN(21); + CUSTOM_ITEM_MAIN(21); + #endif + #if HAS_CUSTOM_ITEM_MAIN(22) + CUSTOM_TEST_MAIN(22); + CUSTOM_ITEM_MAIN(22); + #endif + #if HAS_CUSTOM_ITEM_MAIN(23) + CUSTOM_TEST_MAIN(23); + CUSTOM_ITEM_MAIN(23); + #endif + #if HAS_CUSTOM_ITEM_MAIN(24) + CUSTOM_TEST_MAIN(24); + CUSTOM_ITEM_MAIN(24); + #endif + #if HAS_CUSTOM_ITEM_MAIN(25) + CUSTOM_TEST_MAIN(25); + CUSTOM_ITEM_MAIN(25); + #endif + END_MENU(); + } + +#endif // CUSTOM_MENU_MAIN + void menu_main() { const bool busy = printingIsActive() #if ENABLED(SDSUPPORT) @@ -210,12 +348,12 @@ void menu_main() { SUBMENU(MSG_CONFIGURATION, menu_configuration); - #if ENABLED(CUSTOM_USER_MENUS) - if (TERN1(CUSTOM_MENU_ONLY_IDLE, !busy)) { - #ifdef CUSTOM_USER_MENU_TITLE - SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user); + #if ENABLED(CUSTOM_MENU_MAIN) + if (TERN1(CUSTOM_MENU_MAIN_ONLY_IDLE, !busy)) { + #ifdef CUSTOM_MENU_MAIN_TITLE + SUBMENU_P(PSTR(CUSTOM_MENU_MAIN_TITLE), custom_menus_main); #else - SUBMENU(MSG_USER_MENU, menu_user); + SUBMENU(MSG_CUSTOM_COMMANDS, custom_menus_main); #endif } #endif diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index 03fae56fdb..9ab437dd0b 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -67,9 +67,6 @@ #if ENABLED(CANCEL_OBJECTS) #define HAS_MENU_CANCELOBJECT #endif - #if ENABLED(CUSTOM_USER_MENUS) - #define HAS_MENU_CUSTOM - #endif #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) #define HAS_MENU_DELTA_CALIBRATE #endif diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index e3209899ce..4498492ba5 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -21,7 +21,7 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE fr \ 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 SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ 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 \ + EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL @@ -37,7 +37,7 @@ opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI SHOW_CUS LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \ SDSUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \ Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \ - EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \ + EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \ NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL \ SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \ From cfa6c7d45ba72d1a0b26e6308191e008dcd0d9c9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 19 Mar 2021 16:34:10 -0500 Subject: [PATCH 086/311] Improve max temp / target --- Marlin/Configuration.h | 1 + Marlin/src/gcode/host/M360.cpp | 2 +- Marlin/src/gcode/parser.h | 6 ++---- Marlin/src/inc/Conditionals_post.h | 12 +++++++++--- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 8 +------- Marlin/src/lcd/extui/ui_api.cpp | 6 +++--- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/lcd/menu/menu_filament.cpp | 2 +- Marlin/src/lcd/menu/menu_temperature.cpp | 16 ++++++++-------- Marlin/src/lcd/menu/menu_tune.cpp | 6 +++--- Marlin/src/lcd/menu/menu_ubl.cpp | 2 +- Marlin/src/lcd/tft/touch.cpp | 10 +++++----- Marlin/src/module/settings.cpp | 4 ++-- Marlin/src/module/temperature.cpp | 7 ++++--- Marlin/src/module/temperature.h | 15 +++++---------- 15 files changed, 47 insertions(+), 52 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 339dae7702..c9c83f9bb6 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -484,6 +484,7 @@ */ #define HOTEND_OVERSHOOT 15 // (°C) Forbid temperatures over MAXTEMP - OVERSHOOT #define BED_OVERSHOOT 10 // (°C) Forbid temperatures over MAXTEMP - OVERSHOOT +#define COOLER_OVERSHOOT 2 // (°C) Forbid temperatures closer than OVERSHOOT //=========================================================================== //============================= PID Settings ================================ diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index 50a4e45426..f3c242526d 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -177,7 +177,7 @@ void GcodeSuite::M360() { config_line_e(e, PSTR("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]); config_line_e(e, PSTR("Acceleration"), planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]); config_line_e(e, PSTR("Diameter"), TERN(NO_VOLUMETRICS, DEFAULT_NOMINAL_FILAMENT_DIA, planner.filament_size[e])); - config_line_e(e, PSTR("MaxTemp"), thermalManager.heater_maxtemp[e]); + config_line_e(e, PSTR("MaxTemp"), thermalManager.hotend_maxtemp[e]); } #endif } diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 5a31a9943e..221500e076 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -390,15 +390,13 @@ public: } } - #define TEMP_UNIT(N) parser.to_temp_units(N) - #else // !TEMPERATURE_UNITS_SUPPORT + static inline float to_temp_units(int16_t c) { return (float)c; } + static inline float value_celsius() { return value_float(); } static inline float value_celsius_diff() { return value_float(); } - #define TEMP_UNIT(N) (N) - #endif // !TEMPERATURE_UNITS_SUPPORT static inline feedRate_t value_feedrate() { return MMM_TO_MMS(value_linear_units()); } diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index fb06a7a3f3..1cd7e5f0e9 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2025,11 +2025,17 @@ #undef PIDTEMPBED #endif -#if HAS_HEATED_BED || HAS_TEMP_CHAMBER - #define BED_OR_CHAMBER 1 -#endif #if HAS_TEMP_COOLER && PIN_EXISTS(COOLER) #define HAS_COOLER 1 + #ifndef COOLER_OVERSHOOT + #define COOLER_OVERSHOOT 2 + #endif + #define COOLER_MIN_TARGET (COOLER_MINTEMP + (COOLER_OVERSHOOT)) + #define COOLER_MAX_TARGET (COOLER_MAXTEMP - (COOLER_OVERSHOOT)) +#endif + +#if HAS_HEATED_BED || HAS_TEMP_CHAMBER + #define BED_OR_CHAMBER 1 #endif #if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER #define HAS_TEMP_SENSOR 1 diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 97a9fbd4da..c77e1ebd10 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -112,12 +112,6 @@ #define MAX_PRINT_SPEED 999 #define MIN_PRINT_SPEED 10 -// Temp limits -#if HAS_HOTEND - #define MAX_E_TEMP (HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT)) - #define MIN_E_TEMP HEATER_0_MINTEMP -#endif - #if HAS_HEATED_BED #define MIN_BED_TEMP BED_MINTEMP #endif @@ -1357,7 +1351,7 @@ void HMI_Move_Z() { return; } // E_Temp limit - LIMIT(HMI_ValueStruct.E_Temp, MIN_E_TEMP, MAX_E_TEMP); + LIMIT(HMI_ValueStruct.E_Temp, HEATER_0_MINTEMP, thermalManager.hotend_max_target(0)); // E_Temp value DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 90f9e0b0bf..9e5e0b6a62 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -924,7 +924,7 @@ namespace ExtUI { enableHeater(heater); switch (heater) { #if HAS_HEATED_CHAMBER - case CHAMBER: thermalManager.setTargetChamber(LROUND(constrain(value, 0, CHAMBER_MAXTEMP - 10))); break; + case CHAMBER: thermalManager.setTargetChamber(LROUND(constrain(value, 0, CHAMBER_MAX_TARGET))); break; #endif #if HAS_COOLER case COOLER: thermalManager.setTargetCooler(LROUND(constrain(value, 0, COOLER_MAXTEMP))); break; @@ -935,7 +935,7 @@ namespace ExtUI { default: { #if HAS_HOTEND const int16_t e = heater - H0; - thermalManager.setTargetHotend(LROUND(constrain(value, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT)), e); + thermalManager.setTargetHotend(LROUND(constrain(value, 0, thermalManager.hotend_max_target(e))), e); #endif } break; } @@ -949,7 +949,7 @@ namespace ExtUI { #if HAS_HOTEND const int16_t e = extruder - E0; enableHeater(extruder); - thermalManager.setTargetHotend(LROUND(constrain(value, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT)), e); + thermalManager.setTargetHotend(LROUND(constrain(value, 0, thermalManager.hotend_max_target(e))), e); #endif } diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index aab93c3bdd..b6d55a5de6 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -315,7 +315,7 @@ void menu_backlash(); #if ENABLED(PID_AUTOTUNE_MENU) #define HOTEND_PID_EDIT_MENU_ITEMS(N) \ _HOTEND_PID_EDIT_MENU_ITEMS(N); \ - EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, thermalManager.heater_maxtemp[N] - HOTEND_OVERSHOOT, []{ _lcd_autotune(heater_id_t(MenuItemBase::itemIndex)); }); + EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, thermalManager.hotend_max_target(N), []{ _lcd_autotune(heater_id_t(MenuItemBase::itemIndex)); }); #else #define HOTEND_PID_EDIT_MENU_ITEMS(N) _HOTEND_PID_EDIT_MENU_ITEMS(N); #endif diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 19601d678e..8df2af1dd0 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -95,7 +95,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { ACTION_ITEM_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M, _change_filament_with_preset); #endif EDIT_ITEM_FAST_N(int3, extruder, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[extruder].target, - EXTRUDE_MINTEMP, thermalManager.heater_maxtemp[extruder] - HOTEND_OVERSHOOT, + EXTRUDE_MINTEMP, thermalManager.hotend_max_target(extruder), _change_filament_with_custom ); END_MENU(); diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 3a9906ddeb..8caf87d33b 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -47,11 +47,11 @@ // "Temperature" submenu items // -void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t indb) { +void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb) { UNUSED(e); UNUSED(indh); UNUSED(indb); #if HAS_HOTEND if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) - setTargetHotend(_MIN(thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, ui.material_preset[indh].hotend_temp), e); + setTargetHotend(_MIN(thermalManager.hotend_max_target(e), ui.material_preset[indh].hotend_temp), e); #endif #if HAS_HEATED_BED if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp); @@ -70,7 +70,7 @@ void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t i void do_preheat_end_m() { _preheat_end(editable.int8, 0); } #endif #if HAS_HEATED_BED - inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(-1, -1, m); } + inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(0, -1, m); } #endif #if HAS_COOLER inline void _precool_laser(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); } @@ -163,15 +163,15 @@ void menu_temperature() { // Nozzle [1-5]: // #if HOTENDS == 1 - EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT), []{ thermalManager.start_watching_hotend(0); }); + EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); }); #elif HAS_MULTI_HOTEND HOTEND_LOOP() - EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.heater_maxtemp[e] - (HOTEND_OVERSHOOT), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); + EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.hotend_max_target(e), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); #endif #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) LOOP_S_L_N(e, 1, EXTRUDERS) - EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - (HOTEND_OVERSHOOT)); + EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0)); #endif // @@ -185,7 +185,7 @@ void menu_temperature() { // Chamber: // #if HAS_HEATED_CHAMBER - EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber); + EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAX_TARGET, thermalManager.start_watching_chamber); #endif // @@ -194,7 +194,7 @@ void menu_temperature() { #if HAS_COOLER editable.state = cooler.is_enabled(); EDIT_ITEM(bool, MSG_COOLER(TOGGLE), &cooler.state, []{ if (editable.state) cooler.disable(); else cooler.enable(); }); - EDIT_ITEM_FAST(int3, MSG_COOLER, &thermalManager.temp_cooler.target, COOLER_MINTEMP + 2, COOLER_MAXTEMP - 2, thermalManager.start_watching_cooler); + EDIT_ITEM_FAST(int3, MSG_COOLER, &thermalManager.temp_cooler.target, COOLER_MIN_TARGET, COOLER_MAX_TARGET, thermalManager.start_watching_cooler); #endif // diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 0fbb57f2ac..feabae437d 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -126,15 +126,15 @@ void menu_tune() { // Nozzle [1-4]: // #if HOTENDS == 1 - EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(0); }); + EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); }); #elif HAS_MULTI_HOTEND HOTEND_LOOP() - EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); + EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, thermalManager.hotend_max_target(e), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); #endif #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) LOOP_S_L_N(e, 1, EXTRUDERS) - EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - HOTEND_OVERSHOOT); + EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0)); #endif // diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 79bedb9ea5..6c6076cf74 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -126,7 +126,7 @@ void _lcd_ubl_custom_mesh() { START_MENU(); BACK_ITEM(MSG_UBL_BUILD_MESH_MENU); #if HAS_HOTEND - EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT); + EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0)); #endif #if HAS_HEATED_BED EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, BED_MAX_TARGET); diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 29dd088c99..e8a01e889b 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -186,25 +186,25 @@ void Touch::touch(touch_control_t *control) { ui.clear_lcd(); if (heater >= 0) { // HotEnd #if HOTENDS == 1 - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE), &thermalManager.temp_hotend[0].target, 0, thermalManager.heater_maxtemp[0] - 15, []{ thermalManager.start_watching_hotend(0); }); + MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE), &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); }); #else MenuItemBase::itemIndex = heater; - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE_N), &thermalManager.temp_hotend[heater].target, 0, thermalManager.heater_maxtemp[heater] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); + MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE_N), &thermalManager.temp_hotend[heater].target, 0, thermalManager.hotend_max_target(heater), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); #endif } #if HAS_HEATED_BED else if (heater == H_BED) { - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_BED), &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed); + MenuItem_int3::action((const char *)GET_TEXT_F(MSG_BED), &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed); } #endif #if HAS_HEATED_CHAMBER else if (heater == H_CHAMBER) { - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_CHAMBER), &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber); + MenuItem_int3::action((const char *)GET_TEXT_F(MSG_CHAMBER), &thermalManager.temp_chamber.target, 0, CHAMBER_MAX_TARGET, thermalManager.start_watching_chamber); } #endif #if HAS_COOLER else if (heater == H_COOLER) { - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_COOLER), &thermalManager.temp_cooler.target, 0, COOLER_MAXTEMP - 8, thermalManager.start_watching_cooler); + MenuItem_int3::action((const char *)GET_TEXT_F(MSG_COOLER), &thermalManager.temp_cooler.target, 0, COOLER_MAX_TARGET, thermalManager.start_watching_cooler); } #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index d38ad51934..bf10902c60 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3386,10 +3386,10 @@ void MarlinSettings::reset() { SERIAL_ECHOLNPAIR_P( PSTR(" M145 S"), i #if HAS_HOTEND - , PSTR(" H"), TEMP_UNIT(ui.material_preset[i].hotend_temp) + , PSTR(" H"), parser.to_temp_units(ui.material_preset[i].hotend_temp) #endif #if HAS_HEATED_BED - , SP_B_STR, TEMP_UNIT(ui.material_preset[i].bed_temp) + , SP_B_STR, parser.to_temp_units(ui.material_preset[i].bed_temp) #endif #if HAS_FAN , PSTR(" F"), ui.material_preset[i].fan_speed diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a000a31de7..16553193ec 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -253,7 +253,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if HAS_HOTEND hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 } - const uint16_t Temperature::heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); + const uint16_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); #endif #if ENABLED(AUTO_POWER_E_FANS) @@ -267,6 +267,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if ENABLED(AUTO_POWER_COOLER_FAN) uint8_t Temperature::coolerfan_speed; // = 0 #endif + #if HAS_FAN uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } @@ -552,7 +553,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL); - if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - HOTEND_OVERSHOOT)) { + if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); return; @@ -1512,7 +1513,7 @@ void Temperature::manage_heater() { if (cooler.is_enabled()) { flag_cooler_state = true; // used to allow M106 fan control when cooler is disabled - if (temp_cooler.target == 0) temp_cooler.target = COOLER_MINTEMP; + if (temp_cooler.target == 0) temp_cooler.target = COOLER_MIN_TARGET; if (ELAPSED(ms, next_cooler_check_ms)) { next_cooler_check_ms = ms + COOLER_CHECK_INTERVAL; if (temp_cooler.celsius > temp_cooler.target) { diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index e69183f6f5..abd2eabac2 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -323,7 +323,8 @@ class Temperature { #if HAS_HOTEND #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) static hotend_info_t temp_hotend[HOTEND_TEMPS]; - static const uint16_t heater_maxtemp[HOTENDS]; + static const uint16_t hotend_maxtemp[HOTENDS]; + FORCE_INLINE static uint16_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif TERN_(HAS_HEATED_BED, static bed_info_t temp_bed); TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe); @@ -639,7 +640,7 @@ class Temperature { start_preheat_time(ee); #endif TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on()); - temp_hotend[ee].target = _MIN(celsius, temp_range[ee].maxtemp - HOTEND_OVERSHOOT); + temp_hotend[ee].target = _MIN(celsius, hotend_max_target(ee)); start_watching_hotend(ee); } @@ -785,13 +786,7 @@ class Temperature { #if HAS_COOLER static void setTargetCooler(const int16_t celsius) { - temp_cooler.target = - #ifdef COOLER_MAXTEMP - _MIN(celsius, COOLER_MAXTEMP - 10) - #else - celsius - #endif - ; + temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET); start_watching_cooler(); } #endif @@ -878,7 +873,7 @@ class Temperature { TERN_(HAS_DISPLAY, static void set_heating_message(const uint8_t e)); #if HAS_LCD_MENU && HAS_TEMPERATURE - static void lcd_preheat(const int16_t e, const int8_t indh, const int8_t indb); + static void lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb); #endif private: From f7aaa2e1c758dae56fb0d3dbb743a1c5c04245d2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 19 Mar 2021 16:39:05 -0500 Subject: [PATCH 087/311] Add typedef extra_fan_t --- Marlin/src/lcd/menu/menu_item.h | 2 +- Marlin/src/module/temperature.cpp | 21 ++++++++++++++------- Marlin/src/module/temperature.h | 5 +++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 6873f209b4..945a892799 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -473,7 +473,7 @@ class MenuItem_bool : public MenuEditItemBase { #define _FAN_EDIT_ITEMS(F,L) do{ \ editable.uint8 = thermalManager.fan_speed[F]; \ EDIT_ITEM_FAST_N(percent, F, MSG_##L, &editable.uint8, 0, 255, on_fan_update); \ - EDIT_EXTRA_FAN_SPEED(percent, F, MSG_EXTRA_##L, &thermalManager.new_fan_speed[F], 3, 255); \ + EDIT_EXTRA_FAN_SPEED(percent, F, MSG_EXTRA_##L, &thermalManager.extra_fan_speed[F].speed, 3, 255); \ }while(0) #if FAN_COUNT > 1 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 16553193ec..dd7a36a82a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -273,19 +273,26 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } #if ENABLED(EXTRA_FAN_SPEED) - uint8_t Temperature::old_fan_speed[FAN_COUNT], Temperature::new_fan_speed[FAN_COUNT]; - void Temperature::set_temp_fan_speed(const uint8_t fan, const uint16_t tmp_temp) { - switch (tmp_temp) { + Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT]; + + /** + * Handle the M106 P T command: + * T1 = Restore fan speed saved on the last T2 + * T2 = Save the fan speed, then set to the last T<3-255> value + * T<3-255> = Set the "extra fan speed" + */ + void Temperature::set_temp_fan_speed(const uint8_t fan, const uint16_t command_or_speed) { + switch (command_or_speed) { case 1: - set_fan_speed(fan, old_fan_speed[fan]); + set_fan_speed(fan, extra_fan_speed[fan].saved); break; case 2: - old_fan_speed[fan] = fan_speed[fan]; - set_fan_speed(fan, new_fan_speed[fan]); + extra_fan_speed[fan].saved = fan_speed[fan]; + set_fan_speed(fan, extra_fan_speed[fan].speed); break; default: - new_fan_speed[fan] = _MIN(tmp_temp, 255U); + extra_fan_speed[fan].speed = _MIN(command_or_speed, 255U); break; } } diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index abd2eabac2..38270fc9c4 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -561,8 +561,9 @@ class Temperature { } #if ENABLED(EXTRA_FAN_SPEED) - static uint8_t old_fan_speed[FAN_COUNT], new_fan_speed[FAN_COUNT]; - static void set_temp_fan_speed(const uint8_t fan, const uint16_t tmp_temp); + typedef struct { uint8_t saved, speed; } extra_fan_t; + static extra_fan_t extra_fan_speed[FAN_COUNT]; + static void set_temp_fan_speed(const uint8_t fan, const uint16_t command_or_speed); #endif #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE) From 58f0330d3f51115dbc8cda792105fe66d4c61241 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 19 Mar 2021 16:41:47 -0500 Subject: [PATCH 088/311] MKS / E3V2 LCD code cleanup --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 6 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 72 ++-- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 13 +- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 4 +- .../extui/lib/dgus/mks/DGUSScreenHandler.cpp | 325 +++++++----------- .../extui/lib/dgus/mks/DGUSScreenHandler.h | 1 + .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 29 +- .../extui/lib/mks_ui/draw_filament_change.cpp | 12 +- .../lib/mks_ui/draw_filament_settings.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_number_key.cpp | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 6 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 44 ++- 12 files changed, 210 insertions(+), 308 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 15b3d8bfb3..653a384120 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -571,9 +571,9 @@ FORCE_INLINE void _draw_bed_status(const bool blink) { #if ENABLED(LCD_PROGRESS_BAR) void MarlinUI::draw_progress_bar(const uint8_t percent) { - const int16_t tix = (int16_t)(percent * (LCD_WIDTH) * 3) / 100, - cel = tix / 3, - rem = tix % 3; + const int16_t tix = int16_t(percent * (LCD_WIDTH) * 3) / 100, + cel = tix / 3, + rem = tix % 3; uint8_t i = LCD_WIDTH; char msg[LCD_WIDTH + 1], b = ' '; msg[LCD_WIDTH] = '\0'; diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index c77e1ebd10..60a22f22f1 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -102,19 +102,11 @@ #define DWIN_FONT_HEAD font10x20 #define MENU_CHAR_LIMIT 24 -#define STATUS_Y 360 - -// Fan speed limit -#define FANON 255 -#define FANOFF 0 +#define STATUS_Y 360 // Print speed limit -#define MAX_PRINT_SPEED 999 -#define MIN_PRINT_SPEED 10 - -#if HAS_HEATED_BED - #define MIN_BED_TEMP BED_MINTEMP -#endif +#define MIN_PRINT_SPEED 10 +#define MAX_PRINT_SPEED 999 // Feedspeed limit (max feedspeed = DEFAULT_MAX_FEEDRATE * 2) #define MIN_MAXFEEDSPEED 1 @@ -883,11 +875,11 @@ void Draw_Tune_Menu() { #if HAS_HOTEND Draw_Menu_Line(TUNE_CASE_TEMP, ICON_HotendTemp); - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.degTargetHotend(0)); #endif #if HAS_HEATED_BED Draw_Menu_Line(TUNE_CASE_BED, ICON_BedTemp); - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.degTargetBed()); #endif #if HAS_FAN Draw_Menu_Line(TUNE_CASE_FAN, ICON_FanSpeed); @@ -1394,7 +1386,7 @@ void HMI_Move_Z() { return; } // Bed_Temp limit - LIMIT(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP, BED_MAX_TARGET); + LIMIT(HMI_ValueStruct.Bed_Temp, BED_MINTEMP, 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); } @@ -1438,7 +1430,7 @@ void HMI_Move_Z() { return; } // Fan_speed limit - LIMIT(HMI_ValueStruct.Fan_speed, FANOFF, FANON); + LIMIT(HMI_ValueStruct.Fan_speed, 0, 255); // Fan_speed value DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } @@ -1882,9 +1874,9 @@ void Draw_Status_Area(const bool with_update) { #if HAS_HOTEND DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.degHotend(0)); DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.degTargetHotend(0)); DWIN_ICON_Show(ICON, ICON_StepE, 112, 417); DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]); @@ -1893,9 +1885,9 @@ void Draw_Status_Area(const bool with_update) { #if HAS_HEATED_BED DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.degBed()); DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.degTargetBed()); #endif DWIN_ICON_Show(ICON, ICON_Speed, 113, 383); @@ -2157,8 +2149,8 @@ void HMI_SelectFile() { #if FAN_COUNT > 0 // All fans on for Ender 3 v2 ? // The slicer should manage this for us. - // for (uint8_t i = 0; i < FAN_COUNT; i++) - // thermalManager.fan_speed[i] = FANON; + //for (uint8_t i = 0; i < FAN_COUNT; i++) + // thermalManager.fan_speed[i] = 255; #endif Goto_PrintProcess(); @@ -2539,11 +2531,11 @@ void Draw_Temperature_Menu() { #define _TMENU_ICON(N) Draw_Menu_Line(++i, ICON_SetEndTemp + (N) - 1) #if HAS_HOTEND _TMENU_ICON(TEMP_CASE_TEMP); - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_hotend[0].target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.degTargetHotend(0)); #endif #if HAS_HEATED_BED _TMENU_ICON(TEMP_CASE_BED); - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_bed.target); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.degTargetBed()); #endif #if HAS_FAN _TMENU_ICON(TEMP_CASE_FAN); @@ -2711,7 +2703,7 @@ void HMI_AxisMove() { case 4: // Extruder // window tips #ifdef PREVENT_COLD_EXTRUSION - if (thermalManager.temp_hotend[0].celsius < EXTRUDE_MINTEMP) { + if (thermalManager.degHotend(0) < EXTRUDE_MINTEMP) { HMI_flag.ETempTooLow_flag = true; Popup_Window_ETempTooLow(); DWIN_UpdateLCD(); @@ -2752,16 +2744,16 @@ void HMI_Temperature() { #if HAS_HOTEND case TEMP_CASE_TEMP: // Nozzle temperature checkkey = ETemp; - HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); + HMI_ValueStruct.E_Temp = thermalManager.degTargetHotend(0); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp); EncoderRate.enabled = true; break; #endif #if HAS_HEATED_BED case TEMP_CASE_BED: // Bed temperature checkkey = BedTemp; - HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target); + HMI_ValueStruct.Bed_Temp = thermalManager.degTargetBed(); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp); EncoderRate.enabled = true; break; #endif @@ -2769,7 +2761,7 @@ void HMI_Temperature() { case TEMP_CASE_FAN: // Fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed); EncoderRate.enabled = true; break; #endif @@ -2801,7 +2793,7 @@ void HMI_Temperature() { #ifdef USE_STRING_HEADINGS Draw_Title("PLA Settings"); // TODO: GET_TEXT_F #else - DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings" + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings" #endif #ifdef USE_STRING_TITLES DWIN_Draw_Label(MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); @@ -2817,7 +2809,7 @@ void HMI_Temperature() { #else DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_TEMP)); DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP)); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp #if HAS_HEATED_BED DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3); DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3); @@ -2828,7 +2820,7 @@ void HMI_Temperature() { DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN)); // PLA fan speed #endif #if ENABLED(EEPROM_SETTINGS) - DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration + DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration #endif #endif } @@ -3285,22 +3277,22 @@ void HMI_Tune() { case TUNE_CASE_SPEED: // Print speed checkkey = PrintSpeed; HMI_ValueStruct.print_speed = feedrate_percentage; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), feedrate_percentage); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), HMI_ValueStruct.print_speed); EncoderRate.enabled = true; break; #if HAS_HOTEND case TUNE_CASE_TEMP: // Nozzle temp checkkey = ETemp; - HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); + HMI_ValueStruct.E_Temp = thermalManager.degTargetHotend(0); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), HMI_ValueStruct.E_Temp); EncoderRate.enabled = true; break; #endif #if HAS_HEATED_BED case TUNE_CASE_BED: // Bed temp checkkey = BedTemp; - HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); + HMI_ValueStruct.Bed_Temp = thermalManager.degTargetBed(); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), HMI_ValueStruct.Bed_Temp); EncoderRate.enabled = true; break; #endif @@ -3308,7 +3300,7 @@ void HMI_Tune() { case TUNE_CASE_FAN: // Fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); + DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), HMI_ValueStruct.Fan_speed); EncoderRate.enabled = true; break; #endif @@ -3626,8 +3618,8 @@ void EachMomentUpdate() { if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) { HMI_flag.pause_action = false; #if ENABLED(PAUSE_HEAT) - TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.temp_hotend[0].target); - TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.temp_bed.target); + TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.degTargetHotend(0)); + TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.degTargetBed()); thermalManager.disable_all_heaters(); #endif queue.inject_P(PSTR("G1 F1200 X0 Y0")); 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 95b07f5c68..aa08f683f7 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 @@ -560,32 +560,31 @@ void AnycubicTFTClass::GetCommandFromTFT() { switch (a_command) { case 0: { // A0 GET HOTEND TEMP - float hotendActualTemp = getActualTemp_celsius((extruder_t) (extruder_t) E0); + const float hotendActualTemp = getActualTemp_celsius(E0); SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5)); } break; case 1: { // A1 GET HOTEND TARGET TEMP - float hotendTargetTemp = getTargetTemp_celsius((extruder_t) (extruder_t) E0); + const float hotendTargetTemp = getTargetTemp_celsius(E0); SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5)); } break; case 2: { // A2 GET HOTBED TEMP - float heatedBedActualTemp = getActualTemp_celsius((heater_t) BED); + const float heatedBedActualTemp = getActualTemp_celsius(BED); SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5)); } break; case 3: { // A3 GET HOTBED TARGET TEMP - float heatedBedTargetTemp = getTargetTemp_celsius((heater_t) BED); + const float heatedBedTargetTemp = getTargetTemp_celsius(BED); SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5)); } break; case 4: { // A4 GET FAN SPEED - float fanPercent = getActualFan_percent(FAN0); - fanPercent = constrain(fanPercent, 0, 100); - SEND_PGM_VAL("A4V ", int(fanPercent)); + const float fanPercent = getActualFan_percent(FAN0); + SEND_PGM_VAL("A4V ", int(LIMIT(fanPercent, 0, 100))); } break; case 5: { // A5 GET CURRENT COORDINATE diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index 78865bbfd6..9f436a356c 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -764,8 +764,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr), VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr), #if ENABLED(BABYSTEPPING) - VPHELPER(VP_SD_Print_LiveAdjustZ,nullptr, ScreenHandler.HandleLiveAdjustZ, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), - VPHELPER(VP_ZOffset_DE_DIS,&z_offset_add,nullptr, &ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), + VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>), + VPHELPER(VP_ZOffset_DE_DIS, &z_offset_add, nullptr, &ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), #endif #if HAS_BED_PROBE VPHELPER(VP_OFFSET_X, &probe.offset.x, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index bf2b05dcbf..0efb70b686 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -111,7 +111,7 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var void DGUSScreenHandler::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) { if (var.memadr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); + const uint16_t value = swap16(*(uint16_t*)val_ptr); DEBUG_ECHOLNPAIR("FAN value get:", value); *(uint8_t*)var.memadr = map(constrain(value, 0, 255), 0, 255, 0, 255); DEBUG_ECHOLNPAIR("FAN value change:", *(uint8_t*)var.memadr); @@ -314,7 +314,7 @@ void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t target = swap16(*(uint16_t *)val_ptr); + const uint16_t target = swap16(*(uint16_t *)val_ptr); DEBUG_ECHOLNPAIR(" back = 0x%x", target); switch (target) { } @@ -330,7 +330,7 @@ void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("ctrl turn off\n"); - uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = swap16(*(uint16_t *)val_ptr); switch (value) { case 0 ... 1: DGUSAutoTurnOff = (bool)value; break; default: break; @@ -339,7 +339,7 @@ void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("MinExtrudeTempChange DistanceChange"); - uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = swap16(*(uint16_t *)val_ptr); thermalManager.extrude_min_temp = value; min_ex_temp = value; settings.save(); @@ -347,7 +347,7 @@ void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("Zoffset DistanceChange"); - uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = swap16(*(uint16_t *)val_ptr); float val_distance = 0; switch (value) { case 0: val_distance = 0.01; break; @@ -365,7 +365,7 @@ void DGUSScreenHandler::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) } void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t eep_flag = swap16(*(uint16_t *)val_ptr); + const uint16_t eep_flag = swap16(*(uint16_t *)val_ptr); switch (eep_flag) { case 0: settings.save(); @@ -383,7 +383,7 @@ void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t z_value = swap16(*(uint16_t *)val_ptr); + const uint16_t z_value = swap16(*(uint16_t *)val_ptr); switch (z_value) { case 0: Z_distance = 0.01; break; case 1: Z_distance = 0.1; break; @@ -410,7 +410,7 @@ void DGUSScreenHandler::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t lag_flag = swap16(*(uint16_t *)val_ptr); + const uint16_t lag_flag = swap16(*(uint16_t *)val_ptr); switch (lag_flag) { case MKS_SimpleChinese: DGUS_LanguageDisplay(MKS_SimpleChinese); @@ -435,7 +435,7 @@ void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) #endif void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t lev_but = swap16(*(uint16_t *)val_ptr); + const uint16_t lev_but = swap16(*(uint16_t *)val_ptr); #if ENABLED(MESH_BED_LEVELING) auto cs = getCurrentScreen(); #endif @@ -482,7 +482,7 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr); + const uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr); switch (mesh_dist) { case 0: mesh_adj_distance = 0.01; break; case 1: mesh_adj_distance = 0.1; break; @@ -493,7 +493,7 @@ void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { #if ENABLED(MESH_BED_LEVELING) - uint16_t mesh_value = swap16(*(uint16_t *)val_ptr); + const uint16_t mesh_value = swap16(*(uint16_t *)val_ptr); // static uint8_t a_first_level = 1; char cmd_buf[30]; float offset = mesh_adj_distance; @@ -586,20 +586,16 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { + const uint16_t lcd_value = swap16(*(uint16_t *)val_ptr); - uint16_t lcd_value = swap16(*(uint16_t *)val_ptr); + lcd_default_light = constrain(lcd_value, 10, 100); - if (lcd_value > 100) lcd_value = 100; - else if (lcd_value < 10) lcd_value = 10; - - lcd_default_light = lcd_value; - - const uint16_t lcd_data[2] = {lcd_default_light, lcd_default_light}; + const uint16_t lcd_data[2] = { lcd_default_light, lcd_default_light }; dgusdisplay.WriteVariable(0x0082, &lcd_data, 5, true); } void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) { - int16_t point_value = swap16(*(uint16_t *)val_ptr); + const int16_t point_value = swap16(*(uint16_t *)val_ptr); int16_t level_x_pos, level_y_pos; char buf_level[32] = {0}; @@ -686,7 +682,7 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt #define mks_max(a, b) ((a) > (b)) ? (a) : (b) void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) { #if EITHER(HAS_TRINAMIC_CONFIG, HAS_STEALTHCHOP) - uint16_t tmc_value = swap16(*(uint16_t*)val_ptr); + const uint16_t tmc_value = swap16(*(uint16_t*)val_ptr); #endif switch (var.VP) { @@ -930,7 +926,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) { - int16_t value_pos = swap16(*(int16_t*)val_ptr); + const int16_t value_pos = swap16(*(int16_t*)val_ptr); switch (var.VP) { case VP_X_PARK_POS: x_park_pos = value_pos; break; @@ -939,75 +935,76 @@ void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) { default: break; } skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); - int16_t value_raw = swap16(*(int16_t*)val_ptr); - - DEBUG_ECHOLNPAIR_F("value:", value_raw); + const int16_t value_raw = swap16(*(int16_t*)val_ptr); + DEBUG_ECHOLNPAIR_F("value_raw:", value_raw); *(int16_t*)var.memadr = value_raw; settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const float value = (float)value_raw; DEBUG_ECHOLNPAIR("value_raw:", value_raw); - float value = (float)value_raw; + DEBUG_ECHOLNPAIR_F("value:", value); + ExtUI::axis_t axis; switch (var.VP) { + default: return; case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break; case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; - default: return; } - DEBUG_ECHOLNPAIR_F("value:", value); ExtUI::setAxisSteps_per_mm(value, axis); DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const float value = (float)value_raw; + DEBUG_ECHOLNPAIR("value_raw:", value_raw); - float value = (float)value_raw; + DEBUG_ECHOLNPAIR_F("value:", value); + ExtUI::extruder_t extruder; switch (var.VP) { default: return; - #if HOTENDS >= 1 - case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; - #endif - #if HOTENDS >= 2 - #endif - case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; + #if HAS_HOTEND + case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break; + #endif + #if HAS_MULTI_HOTEND + case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break; + #endif } - DEBUG_ECHOLNPAIR_F("value:", value); ExtUI::setAxisSteps_per_mm(value, extruder); DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS"); - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const float value = (float)value_raw; + DEBUG_ECHOLNPAIR("value_raw:", value_raw); - float value = (float)value_raw; + DEBUG_ECHOLNPAIR_F("value:", value); + ExtUI::axis_t axis; switch (var.VP) { case VP_X_MAX_SPEED: axis = ExtUI::axis_t::X; break; @@ -1015,59 +1012,57 @@ void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *va case VP_Z_MAX_SPEED: axis = ExtUI::axis_t::Z; break; default: return; } - DEBUG_ECHOLNPAIR_F("value:", value); - // ExtUI::setAxisSteps_per_mm(value,extruder); ExtUI::setAxisMaxFeedrate_mm_s(value, axis); DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS"); - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const float value = (float)value_raw; + DEBUG_ECHOLNPAIR("value_raw:", value_raw); - float value = (float)value_raw; + DEBUG_ECHOLNPAIR_F("value:", value); + ExtUI::extruder_t extruder; switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_MAX_SPEED: extruder = ExtUI::extruder_t::E0; break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND #endif case VP_E1_MAX_SPEED: extruder = ExtUI::extruder_t::E1; break; } - DEBUG_ECHOLNPAIR_F("value:", value); - // ExtUI::setAxisSteps_per_mm(value,extruder); ExtUI::setAxisMaxFeedrate_mm_s(value, extruder); DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS"); - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const float value = (float)value_raw; + DEBUG_ECHOLNPAIR("value_raw:", value_raw); - float value = (float)value_raw; + DEBUG_ECHOLNPAIR_F("value:", value); + ExtUI::axis_t axis; switch (var.VP) { + default: return; case VP_X_ACC_MAX_SPEED: axis = ExtUI::axis_t::X; break; case VP_Y_ACC_MAX_SPEED: axis = ExtUI::axis_t::Y; break; case VP_Z_ACC_MAX_SPEED: axis = ExtUI::axis_t::Z; break; - default: return; } - DEBUG_ECHOLNPAIR_F("value:", value); ExtUI::setAxisMaxAcceleration_mm_s2(value, axis); DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { @@ -1079,76 +1074,66 @@ void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void ExtUI::extruder_t extruder; switch (var.VP) { default: return; - #if HOTENDS >= 1 - case VP_E0_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E0; settings.load(); break; - #endif - #if HOTENDS >= 2 - #endif - case VP_E1_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E1; settings.load(); break; + #if HAS_HOTEND + case VP_E0_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E0; settings.load(); break; + #endif + #if HAS_MULTI_HOTEND + case VP_E1_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E1; settings.load(); break; + #endif } DEBUG_ECHOLNPAIR_F("value:", value); - // ExtUI::setAxisSteps_per_mm(value,extruder); ExtUI::setAxisMaxAcceleration_mm_s2(value, extruder); DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value_travel = swap16(*(uint16_t*)val_ptr); - float value = (float)value_travel; - planner.settings.travel_acceleration = value; + planner.settings.travel_acceleration = (float)value_travel; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value_t = swap16(*(uint16_t*)val_ptr); - float value = (float)value_t; - planner.settings.min_feedrate_mm_s = value; + planner.settings.min_feedrate_mm_s = (float)value_t; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value_t_f = swap16(*(uint16_t*)val_ptr); - float value = (float)value_t_f; - planner.settings.min_travel_feedrate_mm_s = value; + planner.settings.min_travel_feedrate_mm_s = (float)value_t_f; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value_acc = swap16(*(uint16_t*)val_ptr); - float value = (float)value_acc; - planner.settings.acceleration = value; + planner.settings.acceleration = (float)value_acc; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr); + const uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr); thermalManager.extrude_min_temp = value_ex_min_temp; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } #if HAS_PID_HEATING void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t rawvalue = swap16(*(uint16_t*)val_ptr); + const uint16_t rawvalue = swap16(*(uint16_t*)val_ptr); DEBUG_ECHOLNPAIR("V1:", rawvalue); - float value = (float)rawvalue / 10; + const float value = 1.0f * rawvalue; DEBUG_ECHOLNPAIR("V2:", value); float newvalue = 0; switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_PID_P: newvalue = value; break; case VP_E0_PID_I: newvalue = scalePID_i(value); break; case VP_E0_PID_D: newvalue = scalePID_d(value); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_PID_P: newvalue = value; break; case VP_E1_PID_I: newvalue = scalePID_i(value); break; case VP_E1_PID_D: newvalue = scalePID_d(value); break; @@ -1224,7 +1209,6 @@ void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) distanceFilament = value; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) { @@ -1237,137 +1221,65 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ FilamentSpeed = value_len; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } -void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("Load Filament"); - char buf[40]; - - uint16_t val_t = swap16(*(uint16_t*)val_ptr); +void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) { + #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) + uint8_t swap_tool = 0; + #endif + #if HAS_HOTEND + uint8_t hotend_too_cold = 0; + #endif if (!print_job_timer.isPaused() && !queue.ring_buffer.empty()) return; + char buf[40]; + const uint16_t val_t = swap16(*(uint16_t*)val_ptr); switch (val_t) { + default: break; case 0: - #if HOTENDS >= 1 - if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) { - if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp) - thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); - SetupConfirmAction(nullptr); - GotoScreen(DGUSLCD_SCREEN_POPUP); - } - else { - queue.enqueue_now_P(PSTR("T0")); - queue.enqueue_now_P(PSTR("G91")); - snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60); - queue.enqueue_one_now(buf); - queue.enqueue_now_P(PSTR("G90")); - } + #if HAS_HOTEND + if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; else swap_tool = 1; #endif break; - case 1: - #if HOTENDS >= 2 - if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) { - if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp) - thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); - SetupConfirmAction(nullptr); - GotoScreen(DGUSLCD_SCREEN_POPUP); - } - else { - queue.enqueue_now_P(PSTR("T1")); - queue.enqueue_now_P(PSTR("G91")); - snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60); - queue.enqueue_one_now(buf); - queue.enqueue_now_P(PSTR("G90")); - } + #if HAS_MULTI_HOTEND + if (thermalManager.tooColdToExtrude(1)) hotend_too_cold = 2; else swap_tool = 2; + #elif ENABLED(SINGLENOZZLE) + if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; else swap_tool = 2; #endif - #if ENABLED(SINGLENOZZLE) - if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) { - if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp) - thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); - SetupConfirmAction(nullptr); - GotoScreen(DGUSLCD_SCREEN_POPUP); - } - else { - queue.enqueue_now_P(PSTR("T1")); - queue.enqueue_now_P(PSTR("G91")); - snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60); - queue.enqueue_one_now(buf); - queue.enqueue_now_P(PSTR("G90")); - } - #endif - break; - - default: break; } + + #if HAS_HOTEND + if (hotend_too_cold) { + if (thermalManager.targetTooColdToExtrude(hotend_too_cold - 1)) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, hotend_too_cold - 1); + sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); + SetupConfirmAction(nullptr); + GotoScreen(DGUSLCD_SCREEN_POPUP); + } + #endif + + #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) + if (swap_tool) { + queue.enqueue_now_P(swap_tool == 2 ? PSTR("T1") : PSTR("T0")); + queue.enqueue_now_P(PSTR("G91")); + snprintf_P(buf, 40, PSTR("G1 E%d F%d"), (int)distanceFilament * filamentDir, FilamentSpeed * 60); + queue.enqueue_one_now(buf); + queue.enqueue_now_P(PSTR("G90")); + } + #endif +} + +void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("Load Filament"); + MKS_FilamentLoadUnload(var, val_ptr, 1); } void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("UnLoad Filament"); - char buf[40]; - uint16_t val_t = swap16(*(uint16_t*)val_ptr); - switch (val_t) { - case 0: - #if HOTENDS >= 1 - if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) { - if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp) - thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); - SetupConfirmAction(nullptr); - GotoScreen(DGUSLCD_SCREEN_POPUP); - } - else { - queue.enqueue_now_P(PSTR("T0")); - queue.enqueue_now_P(PSTR("G91")); - snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60); - queue.enqueue_one_now(buf); - queue.enqueue_now_P(PSTR("G90")); - } - #endif - break; - case 1: - #if HOTENDS >= 2 - if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) { - if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp) - thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); - SetupConfirmAction(nullptr); - GotoScreen(DGUSLCD_SCREEN_POPUP); - } - else { - queue.enqueue_now_P(PSTR("T1")); - queue.enqueue_now_P(PSTR("G91")); - snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60); - queue.enqueue_one_now(buf); - queue.enqueue_now_P(PSTR("G90")); - } - #endif - - #if ENABLED(SINGLENOZZLE) - if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) { - if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp) - thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0); - sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true); - SetupConfirmAction(nullptr); - GotoScreen(DGUSLCD_SCREEN_POPUP); - } - else { - queue.enqueue_now_P(PSTR("T1")); - queue.enqueue_now_P(PSTR("G91")); - snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60); - queue.enqueue_one_now(buf); - queue.enqueue_now_P(PSTR("G90")); - } - #endif - break; - } + MKS_FilamentLoadUnload(var, val_ptr, -1); } #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) @@ -1378,17 +1290,15 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) uint8_t e_temp = 0; filament_data.heated = false; uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); - if (preheat_option <= 8) { // Load filament type - filament_data.action = 1; - } - else if (preheat_option >= 10) { // Unload filament type + if (preheat_option >= 10) { // Unload filament type preheat_option -= 10; filament_data.action = 2; filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH; } - else { // Cancel filament operation + else if (preheat_option <= 8) // Load filament type + filament_data.action = 1; + else // Cancel filament operation filament_data.action = 0; - } switch (preheat_option) { case 0: // Load PLA @@ -1416,10 +1326,10 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) } if (filament_data.action == 0) { // Go back to utility screen - #if HOTENDS >= 1 + #if HAS_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); #endif GotoScreen(DGUSLCD_SCREEN_UTILITY); @@ -1427,13 +1337,13 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) else { // Go to the preheat screen to show the heating progress switch (var.VP) { default: return; - #if HOTENDS >= 1 + #if HAS_HOTEND case VP_E0_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E0; thermalManager.setTargetHotend(e_temp, filament_data.extruder); break; #endif - #if HOTENDS >= 2 + #if HAS_MULTI_HOTEND case VP_E1_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E1; thermalManager.setTargetHotend(e_temp, filament_data.extruder); @@ -1475,6 +1385,7 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder); } } + #endif // DGUS_FILAMENT_LOADUNLOAD bool DGUSScreenHandler::loop() { diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h index 15e232e413..bfec3c4572 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h @@ -149,6 +149,7 @@ public: // Hook for filament load and unload static void HandleFilamentLoadUnload(DGUS_VP_Variable &var); + static void MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir); static void MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr); static void MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr); static void MKS_LOAD_UNLOAD_IDLE(); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index 5d02f79fd1..767d9c6738 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -514,13 +514,13 @@ void filament_dialog_handle() { queue.inject(public_buf_m); } - if ( ((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1) - || ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper)) - && uiCfg.filament_load_heat_flg - ) { - uiCfg.filament_load_heat_flg = false; - lv_clear_dialog(); - lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); + if (uiCfg.filament_load_heat_flg) { + const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; + if (abs(diff) < 2 || diff > 0) { + uiCfg.filament_load_heat_flg = false; + lv_clear_dialog(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); + } } if (uiCfg.filament_loading_completed) { @@ -529,13 +529,14 @@ void filament_dialog_handle() { lv_clear_dialog(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED); } - if (((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1) - || ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper)) - && uiCfg.filament_unload_heat_flg - ) { - uiCfg.filament_unload_heat_flg = false; - lv_clear_dialog(); - lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); + + if (uiCfg.filament_unload_heat_flg) { + const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; + if (abs(diff) < 2 || diff > 0) { + uiCfg.filament_unload_heat_flg = false; + lv_clear_dialog(); + lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); + } } if (uiCfg.filament_unloading_completed) { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp index e12a4b82cf..56a776c79e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -51,15 +51,15 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_FILAMNT_IN: uiCfg.filament_load_heat_flg = true; if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1) - || (gCfgItems.filament_limit_temper <= thermalManager.degHotend(uiCfg.extruderIndex))) { + || (gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex))) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); } else { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT); - if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) { - thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex); + if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) { + thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex); thermalManager.start_watching_hotend(uiCfg.extruderIndex); } } @@ -68,7 +68,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { uiCfg.filament_unload_heat_flg = true; if (thermalManager.degTargetHotend(uiCfg.extruderIndex) && ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1) - || ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temper)) + || ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp)) ) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); @@ -76,8 +76,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { else { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT); - if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) { - thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex); + if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) { + thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex); thermalManager.start_watching_hotend(uiCfg.extruderIndex); } filament_sprayer_temp(); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp index 128989a27c..553cb29895 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp @@ -107,7 +107,7 @@ void lv_draw_filament_settings() { 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_FILAMENT_SET_DOWN, true); } else { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temp); lv_screen_menu_item_1_edit(scr, machine_menu.FilamentTemperature, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_TEMP, 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_FILAMENT_SET_UP, true); 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 d001175915..91a1fce28d 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 @@ -261,7 +261,7 @@ static void disp_key_value() { sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_speed); break; case filament_temp: - sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temper); + sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temp); break; case x_sensitivity: #if X_SENSORLESS @@ -505,7 +505,7 @@ static void set_value_confirm() { update_spi_flash(); break; case filament_temp: - gCfgItems.filament_limit_temper = atoi(key_value); + gCfgItems.filament_limit_temp = atoi(key_value); update_spi_flash(); break; case x_sensitivity: 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 9b7fea0a45..12e060aa01 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -143,7 +143,7 @@ void gCfgItems_init() { gCfgItems.filamentchange_load_speed = 1000; gCfgItems.filamentchange_unload_length = 200; gCfgItems.filamentchange_unload_speed = 1000; - gCfgItems.filament_limit_temper = 200; + gCfgItems.filament_limit_temp = 200; gCfgItems.encoder_enable = true; @@ -226,8 +226,8 @@ void ui_cfg_init() { uiCfg.cloud_port = 10086; #endif - uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0 / gCfgItems.filamentchange_load_speed) + 0.5); - uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0 / gCfgItems.filamentchange_unload_speed) + 0.5); + uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0f / gCfgItems.filamentchange_load_speed) + 0.5f); + uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0f / gCfgItems.filamentchange_unload_speed) + 0.5f); } void update_spi_flash() { 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 4b0ce2b4d8..a7f219965a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -184,29 +184,27 @@ extern char public_buf_m[100]; extern char public_buf_l[30]; typedef struct { - uint32_t spi_flash_flag; - uint8_t disp_rotation_180; - bool multiple_language; - uint8_t language; - uint8_t leveling_mode; - bool from_flash_pic; - bool finish_power_off; - bool pause_reprint; - uint8_t wifi_mode_sel; - uint8_t fileSysType; - uint8_t wifi_type; - bool cloud_enable, - encoder_enable; - int levelingPos[5][2]; - int filamentchange_load_length, - filamentchange_load_speed, - filamentchange_unload_length, - filamentchange_unload_speed, - filament_limit_temper; - float pausePosX, - pausePosY, - pausePosZ; - uint32_t curFilesize; + uint32_t spi_flash_flag; + uint8_t disp_rotation_180; + bool multiple_language; + uint8_t language; + uint8_t leveling_mode; + bool from_flash_pic; + bool finish_power_off; + bool pause_reprint; + uint8_t wifi_mode_sel; + uint8_t fileSysType; + uint8_t wifi_type; + bool cloud_enable, + encoder_enable; + int levelingPos[5][2]; + int filamentchange_load_length, + filamentchange_load_speed, + filamentchange_unload_length, + filamentchange_unload_speed; + int16_t filament_limit_temp; + float pausePosX, pausePosY, pausePosZ; + uint32_t curFilesize; } CFG_ITMES; typedef struct { From a8ea6e646301756f138373112479713f0dfbe4dc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Mar 2021 10:55:30 -0500 Subject: [PATCH 089/311] Max temp/target followup --- Marlin/src/lcd/menu/menu_advanced.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index b6d55a5de6..463433685e 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -261,8 +261,8 @@ void menu_backlash(); // #if BOTH(AUTOTEMP, HAS_TEMP_HOTEND) EDIT_ITEM(bool, MSG_AUTOTEMP, &planner.autotemp_enabled); - EDIT_ITEM(float3, MSG_MIN, &planner.autotemp_min, 0, float(HEATER_0_MAXTEMP) - HOTEND_OVERSHOOT); - EDIT_ITEM(float3, MSG_MAX, &planner.autotemp_max, 0, float(HEATER_0_MAXTEMP) - HOTEND_OVERSHOOT); + EDIT_ITEM(int3, MSG_MIN, &planner.autotemp_min, 0, thermalManager.hotend_max_target(0)); + EDIT_ITEM(int3, MSG_MAX, &planner.autotemp_max, 0, thermalManager.hotend_max_target(0)); EDIT_ITEM(float42_52, MSG_FACTOR, &planner.autotemp_factor, 0, 10); #endif From 07c24e72ac0deba0a9229a3cbcd8694279b102ab Mon Sep 17 00:00:00 2001 From: MarlinFirmware Date: Wed, 24 Mar 2021 00:13:49 +0000 Subject: [PATCH 090/311] [cron] Bump distribution date (2021-03-24) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 2f91dfd927..7d3f6d8a64 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-03-23" + #define STRING_DISTRIBUTION_DATE "2021-03-24" #endif /** From e5ff55a1be7646b6159e6dedac50bfbe57e6dfa0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 24 Mar 2021 04:11:43 -0500 Subject: [PATCH 091/311] Add typedef celsius_t (#21374) --- Marlin/src/core/types.h | 6 + Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/pause.cpp | 5 +- Marlin/src/feature/pause.h | 2 +- Marlin/src/feature/powerloss.cpp | 8 +- Marlin/src/feature/powerloss.h | 4 +- Marlin/src/gcode/bedlevel/G26.cpp | 4 +- Marlin/src/gcode/lcd/M145.cpp | 6 +- Marlin/src/gcode/parser.h | 61 +++++---- Marlin/src/gcode/temp/M104_M109.cpp | 6 +- Marlin/src/gcode/temp/M140_M190.cpp | 6 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 10 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 19 ++- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 22 ++-- .../lcd/dogm/status_screen_lite_ST7920.cpp | 32 ++--- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 26 ++-- Marlin/src/lcd/dwin/e3v2/dwin.h | 4 +- .../lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 10 +- .../extui/lib/dgus/fysetc/DGUSDisplayDef.cpp | 6 +- .../extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp | 10 +- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 6 +- .../extui/lib/dgus/origin/DGUSDisplayDef.cpp | 4 +- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 4 +- Marlin/src/lcd/marlinui.h | 6 +- Marlin/src/lcd/menu/menu_configuration.cpp | 4 +- Marlin/src/lcd/tft/ui_320x240.cpp | 6 +- Marlin/src/lcd/tft/ui_480x320.cpp | 6 +- Marlin/src/module/motion.cpp | 6 +- Marlin/src/module/motion.h | 14 +-- Marlin/src/module/planner.cpp | 8 +- Marlin/src/module/planner.h | 3 +- Marlin/src/module/temperature.cpp | 110 +++++++--------- Marlin/src/module/temperature.h | 118 +++++++----------- Marlin/src/module/thermistor/thermistors.h | 2 +- 35 files changed, 252 insertions(+), 298 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 20519e1888..d77dba38d9 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -72,6 +72,12 @@ struct IF { typedef L type; }; // typedef float feedRate_t; +// +// celsius_t is the native unit of temperature. Signed to handle a disconnected thermistor value (-14). +// For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100 +// +typedef int16_t celsius_t; + // Conversion macros #define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f) #define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index a1bec36e45..d4238400c7 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -775,7 +775,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { bool response = false; mmu_print_saved = false; xyz_pos_t resume_position; - int16_t resume_hotend_temp = thermalManager.degTargetHotend(active_extruder); + celsius_t resume_hotend_temp = thermalManager.degTargetHotend(active_extruder); KEEPALIVE_STATE(PAUSED_FOR_USER); diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index a6a28925ed..5f3338139a 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -555,7 +555,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep * - Send host action for resume, if configured * - Resume the current SD print job, if any */ -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) { +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*/, const celsius_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:", max_beep_count, " targetTemp:", targetTemp DXC_SAY); @@ -577,9 +577,8 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le thermalManager.reset_hotend_idle_timer(e); } - if (targetTemp > thermalManager.degTargetHotend(active_extruder)) { + if (targetTemp > thermalManager.degTargetHotend(active_extruder)) thermalManager.setTargetHotend(targetTemp, active_extruder); - } // Load the new filament load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_SAME DXC_PASS); diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index 7e58d4564e..4ab33ac519 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -90,7 +90,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS); void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, - const int8_t max_beep_count=0, int16_t targetTemp=0 DXC_PARAMS); + const int8_t max_beep_count=0, const celsius_t targetTemp=0 DXC_PARAMS); bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, const bool show_lcd=false, const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS); diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 1bb3a7e915..cc45d6ecf0 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -201,10 +201,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/ #endif #if EXTRUDERS - HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target; + HOTEND_LOOP() info.target_temperature[e] = thermalManager.degTargetHotend(e); #endif - TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.temp_bed.target); + TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.degTargetBed()); #if HAS_FAN COPY(info.fan_speed, thermalManager.fan_speed); @@ -343,7 +343,7 @@ void PrintJobRecovery::resume() { #endif #if HAS_HEATED_BED - const int16_t bt = info.target_temperature_bed; + const celsius_t bt = info.target_temperature_bed; if (bt) { // Restore the bed temperature sprintf_P(cmd, PSTR("M190 S%i"), bt); @@ -354,7 +354,7 @@ void PrintJobRecovery::resume() { // Restore all hotend temperatures #if HAS_HOTEND HOTEND_LOOP() { - const int16_t et = info.target_temperature[e]; + const celsius_t et = info.target_temperature[e]; if (et) { #if HAS_MULTI_HOTEND sprintf_P(cmd, PSTR("T%i S"), e); diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 25581e1723..12d11b141e 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -66,8 +66,8 @@ typedef struct { float filament_size[EXTRUDERS]; #endif - TERN_(HAS_HOTEND, int16_t target_temperature[HOTENDS]); - TERN_(HAS_HEATED_BED, int16_t target_temperature_bed); + TERN_(HAS_HOTEND, celsius_t target_temperature[HOTENDS]); + TERN_(HAS_HEATED_BED, celsius_t target_temperature_bed); TERN_(HAS_FAN, uint8_t fan_speed[FAN_COUNT]); TERN_(HAS_LEVELING, float fade); diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index ed29959055..0468b79363 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -533,7 +533,7 @@ void GcodeSuite::G26() { #if HAS_HEATED_BED // Get a temperature from 'I' or 'B' - int16_t bedtemp = 0; + celsius_t bedtemp = 0; // Use the 'I' index if temperature presets are defined #if PREHEAT_COUNT @@ -616,7 +616,7 @@ void GcodeSuite::G26() { g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3); // Scale up by nozzle size // Get a temperature from 'I' or 'H' - int16_t noztemp = 0; + celsius_t noztemp = 0; // Accept 'I' if temperature presets are defined #if PREHEAT_COUNT diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index 84a7e75aa4..d6a57d2215 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -27,6 +27,10 @@ #include "../gcode.h" #include "../../lcd/marlinui.h" +#if HAS_HOTEND + #include "../../module/temperature.h" +#endif + /** * M145: Set the heatup state for a material in the LCD menu * @@ -43,7 +47,7 @@ void GcodeSuite::M145() { preheat_t &mat = ui.material_preset[material]; #if HAS_HOTEND if (parser.seenval('H')) - mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP) - (HOTEND_OVERSHOOT)); + mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0)); #endif #if HAS_HEATED_BED if (parser.seenval('B')) diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 221500e076..b21c930cfa 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -352,50 +352,45 @@ public: static inline PGM_P temp_units_name() { return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius"); } - static inline float to_temp_units(const float &f) { + static inline float to_temp_units(celsius_t c) { switch (input_temp_units) { - case TEMPUNIT_F: - return f * 0.5555555556f + 32; - case TEMPUNIT_K: - return f + 273.15f; - case TEMPUNIT_C: default: - return f; + case TEMPUNIT_C: return c; + case TEMPUNIT_K: return c + 273.15f; + case TEMPUNIT_F: return c * 0.5555555556f + 32; } } #endif // HAS_LCD_MENU && !DISABLE_M503 - static inline float value_celsius() { - const float f = value_float(); + static inline celsius_t value_celsius() { + float f = value_float(); switch (input_temp_units) { - case TEMPUNIT_F: - return (f - 32) * 0.5555555556f; - case TEMPUNIT_K: - return f - 273.15f; - case TEMPUNIT_C: default: - return f; + case TEMPUNIT_C: break; + case TEMPUNIT_K: f -= 273.15f; + case TEMPUNIT_F: f = (f - 32) * 0.5555555556f; } + return LROUND(f + 0.5f); } - static inline float value_celsius_diff() { + static inline celsius_t value_celsius_diff() { + float f = value_float(); switch (input_temp_units) { - case TEMPUNIT_F: - return value_float() * 0.5555555556f; - case TEMPUNIT_C: - case TEMPUNIT_K: default: - return value_float(); + case TEMPUNIT_C: + case TEMPUNIT_K: break; + case TEMPUNIT_F: f *= 0.5555555556f; } + return LROUND(f + 0.5f); } #else // !TEMPERATURE_UNITS_SUPPORT static inline float to_temp_units(int16_t c) { return (float)c; } - static inline float value_celsius() { return value_float(); } - static inline float value_celsius_diff() { return value_float(); } + static inline celsius_t value_celsius() { return value_int(); } + static inline celsius_t value_celsius_diff() { return value_int(); } #endif // !TEMPERATURE_UNITS_SUPPORT @@ -404,16 +399,16 @@ public: void unknown_command_warning(); // Provide simple value accessors with default option - static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } - static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } - static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } - static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } - static inline int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } - static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } - static inline int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } - static inline uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } - static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } - static inline float celsiusval(const char c, const float dval=0) { return seenval(c) ? value_celsius() : dval; } + static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } + static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } + static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } + static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } + static inline int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } + static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } + static inline int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } + static inline uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } + static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } + static inline celsius_t celsiusval(const char c, const float dval=0) { return seenval(c) ? value_celsius() : dval; } #if ENABLED(MARLIN_DEV_MODE) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index 07e46e1775..fe1e834656 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -69,7 +69,7 @@ void GcodeSuite::M104() { #endif bool got_temp = false; - int16_t temp = 0; + celsius_t temp = 0; // Accept 'I' if temperature presets are defined #if PREHEAT_COUNT @@ -145,7 +145,7 @@ void GcodeSuite::M109() { #endif bool got_temp = false; - int16_t temp = 0; + celsius_t temp = 0; // Accept 'I' if temperature presets are defined #if PREHEAT_COUNT @@ -161,7 +161,7 @@ void GcodeSuite::M109() { if (!got_temp) { no_wait_for_cooling = parser.seenval('S'); got_temp = no_wait_for_cooling || parser.seenval('R'); - if (got_temp) temp = int16_t(parser.value_celsius()); + if (got_temp) temp = parser.value_celsius(); } if (got_temp) { diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 9a1a0287d9..3aed878a03 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -44,7 +44,7 @@ void GcodeSuite::M140() { if (DEBUGGING(DRYRUN)) return; bool got_temp = false; - int16_t temp = 0; + celsius_t temp = 0; // Accept 'I' if temperature presets are defined #if PREHEAT_COUNT @@ -94,7 +94,7 @@ void GcodeSuite::M190() { if (DEBUGGING(DRYRUN)) return; bool got_temp = false; - int16_t temp = 0; + celsius_t temp = 0; // Accept 'I' if temperature presets are defined #if PREHEAT_COUNT @@ -110,7 +110,7 @@ void GcodeSuite::M190() { if (!got_temp) { no_wait_for_cooling = parser.seenval('S'); got_temp = no_wait_for_cooling || parser.seenval('R'); - if (got_temp) temp = int16_t(parser.value_celsius()); + if (got_temp) temp = parser.value_celsius(); } if (!got_temp) return; diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 653a384120..3f4cc23aba 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -520,15 +520,15 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) { #if HAS_HEATED_BED const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0); - const float t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)), - t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); + const celsius_t t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)), + t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); #else - const float t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); + const celsius_t t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); #endif if (prefix >= 0) lcd_put_wchar(prefix); - lcd_put_u8str(i16tostr3rj(t1 + 0.5)); + lcd_put_u8str(i16tostr3rj(t1)); lcd_put_wchar('/'); #if !HEATER_IDLE_HANDLER @@ -541,7 +541,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr } else #endif - lcd_put_u8str(i16tostr3left(t2 + 0.5)); + lcd_put_u8str(i16tostr3left(t2)); if (prefix >= 0) { lcd_put_wchar(LCD_STR_DEGREE[0]); diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 44128cc9f8..fd72f94862 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -434,33 +434,32 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p uint8_t pic_hot_bits; #if HAS_HEATED_BED const bool isBed = heater_id < 0; - const float t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)); - const float t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); + const celsius_t t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)), + t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); #else - const float t1 = thermalManager.degHotend(heater_id); - const float t2 = thermalManager.degTargetHotend(heater_id); + const celsius_t t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); #endif #if HOTENDS < 2 if (heater_id == H_E0) { lcd.setCursor(2, 5); lcd.print(prefix); //HE - lcd.setCursor(1, 6); lcd.print(i16tostr3rj(t1 + 0.5)); + lcd.setCursor(1, 6); lcd.print(i16tostr3rj(t1)); lcd.setCursor(1, 7); } else { lcd.setCursor(6, 5); lcd.print(prefix); //BED - lcd.setCursor(6, 6); lcd.print(i16tostr3rj(t1 + 0.5)); + lcd.setCursor(6, 6); lcd.print(i16tostr3rj(t1)); lcd.setCursor(6, 7); } #else if (heater_id > H_BED) { - lcd.setCursor(heater_id * 4, 5); lcd.print(prefix); //HE1 or HE2 or HE3 - lcd.setCursor(heater_id * 4, 6); lcd.print(i16tostr3rj(t1 + 0.5)); + lcd.setCursor(heater_id * 4, 5); lcd.print(prefix); // HE1 or HE2 or HE3 + lcd.setCursor(heater_id * 4, 6); lcd.print(i16tostr3rj(t1)); lcd.setCursor(heater_id * 4, 7); } else { lcd.setCursor(13, 5); lcd.print(prefix); //BED - lcd.setCursor(13, 6); lcd.print(i16tostr3rj(t1 + 0.5)); + lcd.setCursor(13, 6); lcd.print(i16tostr3rj(t1)); lcd.setCursor(13, 7); } #endif // HOTENDS <= 1 @@ -475,7 +474,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p } else #endif // !HEATER_IDLE_HANDLER - lcd.print(i16tostr3rj(t2 + 0.5)); + lcd.print(i16tostr3rj(t2)); switch (heater_id) { case H_BED: pic_hot_bits = ICON_BED; break; diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 892ab5218b..7d97a1cdcf 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -187,7 +187,7 @@ #define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1) #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) -FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) { +FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) { const char *str = i16tostr3rj(temp); const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]); @@ -206,8 +206,8 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id); - const float temp = thermalManager.degHotend(heater_id), - target = thermalManager.degTargetHotend(heater_id); + const celsius_t temp = thermalManager.degHotend(heater_id), + target = thermalManager.degTargetHotend(heater_id); #if DISABLED(STATUS_HOTEND_ANIM) #define STATIC_HOTEND true @@ -277,11 +277,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons #else constexpr bool dodraw = true; #endif - if (dodraw) _draw_centered_temp(target + 0.5, tx, 7); + if (dodraw) _draw_centered_temp(target, tx, 7); } if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) - _draw_centered_temp(temp + 0.5f, tx, 28); + _draw_centered_temp(temp, tx, 28); if (STATIC_HOTEND && HOTEND_DOT && PAGE_CONTAINS(17, 19)) { u8g.setColorIndex(0); // set to white on black @@ -303,8 +303,8 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons const uint8_t tx = STATUS_BED_TEXT_X; - const float temp = thermalManager.degBed(), - target = thermalManager.degTargetBed(); + const celsius_t temp = thermalManager.degBed(), + target = thermalManager.degTargetBed(); #if ENABLED(STATUS_HEAT_PERCENT) || DISABLED(STATUS_BED_ANIM) const bool isHeat = BED_ALT(); @@ -350,11 +350,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons #else constexpr bool dodraw = true; #endif - if (dodraw) _draw_centered_temp(target + 0.5, tx, 7); + if (dodraw) _draw_centered_temp(target, tx, 7); } if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) - _draw_centered_temp(temp + 0.5f, tx, 28); + _draw_centered_temp(temp, tx, 28); if (STATIC_BED && BED_DOT && PAGE_CONTAINS(17, 19)) { u8g.setColorIndex(0); // set to white on black @@ -370,10 +370,10 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons FORCE_INLINE void _draw_chamber_status() { #if HAS_HEATED_CHAMBER if (PAGE_UNDER(7)) - _draw_centered_temp(thermalManager.degTargetChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 7); + _draw_centered_temp(thermalManager.degTargetChamber(), STATUS_CHAMBER_TEXT_X, 7); #endif if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) - _draw_centered_temp(thermalManager.degChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 28); + _draw_centered_temp(thermalManager.degChamber(), STATUS_CHAMBER_TEXT_X, 28); } #endif diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index a538121d2c..dcb65f676d 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -691,15 +691,15 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { // We only add the target temperatures to the checksum // because the actual temps fluctuate so by updating // them only during blinks we gain a bit of stability. - const bool blink = ui.get_blink(); - const uint16_t feedrate_perc = feedrate_percentage; - const uint16_t fs = thermalManager.scaledFanSpeed(0); - const int16_t extruder_1_target = thermalManager.degTargetHotend(0); + const bool blink = ui.get_blink(); + const uint16_t feedrate_perc = feedrate_percentage; + const uint16_t fs = thermalManager.scaledFanSpeed(0); + const celsius_t extruder_1_target = thermalManager.degTargetHotend(0); #if HAS_MULTI_HOTEND - const int16_t extruder_2_target = thermalManager.degTargetHotend(1); + const celsius_t extruder_2_target = thermalManager.degTargetHotend(1); #endif #if HAS_HEATED_BED - const int16_t bed_target = thermalManager.degTargetBed(); + const celsius_t bed_target = thermalManager.degTargetBed(); #endif static uint16_t last_checksum = 0; const uint16_t checksum = blink ^ feedrate_perc ^ fs ^ extruder_1_target @@ -712,19 +712,19 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { if (forceUpdate || indicators_changed()) { - const bool blink = ui.get_blink(); - const duration_t elapsed = print_job_timer.duration(); - duration_t remaining = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time()); - const uint16_t feedrate_perc = feedrate_percentage; - const int16_t extruder_1_temp = thermalManager.degHotend(0), - extruder_1_target = thermalManager.degTargetHotend(0); + const bool blink = ui.get_blink(); + const duration_t elapsed = print_job_timer.duration(); + duration_t remaining = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time()); + const uint16_t feedrate_perc = feedrate_percentage; + const celsius_t extruder_1_temp = thermalManager.degHotend(0), + extruder_1_target = thermalManager.degTargetHotend(0); #if HAS_MULTI_HOTEND - const int16_t extruder_2_temp = thermalManager.degHotend(1), - extruder_2_target = thermalManager.degTargetHotend(1); + const celsius_t extruder_2_temp = thermalManager.degHotend(1), + extruder_2_target = thermalManager.degTargetHotend(1); #endif #if HAS_HEATED_BED - const int16_t bed_temp = thermalManager.degBed(), - bed_target = thermalManager.degTargetBed(); + const celsius_t bed_temp = thermalManager.degBed(), + bed_target = thermalManager.degTargetBed(); #endif draw_extruder_1_temp(extruder_1_temp, extruder_1_target, forceUpdate); diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 60a22f22f1..0e9b93525d 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -1578,20 +1578,22 @@ void _draw_xyz_position(const bool force) { void update_variable() { #if HAS_HOTEND - static float _hotendtemp = 0; - const bool _new_hotend_temp = _hotendtemp != thermalManager.temp_hotend[0].celsius; - if (_new_hotend_temp) _hotendtemp = thermalManager.temp_hotend[0].celsius; - static int16_t _hotendtarget = 0; - const bool _new_hotend_target = _hotendtarget != thermalManager.temp_hotend[0].target; - if (_new_hotend_target) _hotendtarget = thermalManager.temp_hotend[0].target; + static celsius_t _hotendtemp = 0, _hotendtarget = 0; + const celsius_t hc = thermalManager.degHotend(0), + ht = thermalManager.degTargetHotend(0); + const bool _new_hotend_temp = _hotendtemp != hc, + _new_hotend_target = _hotendtarget != ht; + if (_new_hotend_temp) _hotendtemp = hc; + if (_new_hotend_target) _hotendtarget = ht; #endif #if HAS_HEATED_BED - static float _bedtemp = 0; - const bool _new_bed_temp = _bedtemp != thermalManager.temp_bed.celsius; - if (_new_bed_temp) _bedtemp = thermalManager.temp_bed.celsius; - static int16_t _bedtarget = 0; - const bool _new_bed_target = _bedtarget != thermalManager.temp_bed.target; - if (_new_bed_target) _bedtarget = thermalManager.temp_bed.target; + static celsius_t _bedtemp = 0, _bedtarget = 0; + const celsius_t bc = thermalManager.degBed(), + bt = thermalManager.degTargetBed(); + const bool _new_bed_temp = _bedtemp != bc, + _new_bed_target = _bedtarget != bt; + if (_new_bed_temp) _bedtemp = bc; + if (_new_bed_target) _bedtarget = bt; #endif #if HAS_FAN static uint8_t _fanspeed = 0; diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index 217127ed11..9e0cda86c2 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -234,8 +234,8 @@ extern char print_filename[16]; extern millis_t dwin_heat_time; typedef struct { - TERN_(HAS_HOTEND, int16_t E_Temp = 0); - TERN_(HAS_HEATED_BED, int16_t Bed_Temp = 0); + TERN_(HAS_HOTEND, celsius_t E_Temp = 0); + TERN_(HAS_HEATED_BED, celsius_t Bed_Temp = 0); TERN_(HAS_FAN, int16_t Fan_speed = 0); int16_t print_speed = 100; float Max_Feedspeed = 0; diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index 93a7de14a1..473fcb954c 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -388,28 +388,28 @@ void DGUSScreenHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr } void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t newvalue = swap16(*(uint16_t*)val_ptr); - uint16_t acceptedvalue; + celsius_t newvalue = swap16(*(uint16_t*)val_ptr); + celsius_t acceptedvalue; switch (var.VP) { default: return; #if HOTENDS >= 1 case VP_T_E0_Set: - NOMORE(newvalue, (uint16_t)HEATER_0_MAXTEMP); + NOMORE(newvalue, HEATER_0_MAXTEMP); thermalManager.setTargetHotend(newvalue, 0); acceptedvalue = thermalManager.degTargetHotend(0); break; #endif #if HOTENDS >= 2 case VP_T_E1_Set: - NOMORE(newvalue, (uint16_t)HEATER_1_MAXTEMP); + NOMORE(newvalue, HEATER_1_MAXTEMP); thermalManager.setTargetHotend(newvalue, 1); acceptedvalue = thermalManager.degTargetHotend(1); break; #endif #if HAS_HEATED_BED case VP_T_Bed_Set: - NOMORE(newvalue, (uint16_t)BED_MAXTEMP); + NOMORE(newvalue, BED_MAXTEMP); thermalManager.setTargetBed(newvalue); acceptedvalue = thermalManager.degTargetBed(); break; diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp index 467444c214..ee0a1c749f 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp @@ -367,7 +367,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Temperature Data #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), @@ -388,7 +388,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), @@ -400,7 +400,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp index 536640ec95..d3c4510fb3 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp @@ -364,13 +364,13 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr), #endif - { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, + { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr - { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay }, + { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay }, // Temperature Data #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), @@ -391,7 +391,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), @@ -399,7 +399,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index 9f436a356c..25e1670740 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -548,7 +548,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // Temperature Data #if HOTENDS >= 1 - VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), @@ -573,7 +573,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), @@ -593,7 +593,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp index 8d89de3e33..e232bf9b96 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp @@ -216,7 +216,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #endif #if HOTENDS >= 2 - VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), @@ -227,7 +227,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif #endif #if HAS_HEATED_BED - VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index 767d9c6738..3fed4cc385 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -515,7 +515,7 @@ void filament_dialog_handle() { } if (uiCfg.filament_load_heat_flg) { - const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; + const celsius_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; if (abs(diff) < 2 || diff > 0) { uiCfg.filament_load_heat_flg = false; lv_clear_dialog(); @@ -531,7 +531,7 @@ void filament_dialog_handle() { } if (uiCfg.filament_unload_heat_flg) { - const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; + const celsius_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; if (abs(diff) < 2 || diff > 0) { uiCfg.filament_unload_heat_flg = false; lv_clear_dialog(); 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 a7f219965a..3098a6666c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -202,7 +202,7 @@ typedef struct { filamentchange_load_speed, filamentchange_unload_length, filamentchange_unload_speed; - int16_t filament_limit_temp; + celsius_t filament_limit_temp; float pausePosX, pausePosY, pausePosZ; uint32_t curFilesize; } CFG_ITMES; @@ -244,7 +244,7 @@ typedef struct { filament_loading_time_cnt, filament_unloading_time_cnt; float move_dist; - float hotendTargetTempBak; + celsius_t hotendTargetTempBak; float current_x_position_bak, current_y_position_bak, current_z_position_bak, diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 1c9e80c75e..6f5703e622 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -110,9 +110,9 @@ #if PREHEAT_COUNT typedef struct { - TERN_(HAS_HOTEND, uint16_t hotend_temp); - TERN_(HAS_HEATED_BED, uint16_t bed_temp ); - TERN_(HAS_FAN, uint16_t fan_speed ); + TERN_(HAS_HOTEND, celsius_t hotend_temp); + TERN_(HAS_HEATED_BED, celsius_t bed_temp ); + TERN_(HAS_FAN, uint16_t fan_speed ); } preheat_t; #endif diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 71f09a5aee..7ef49f0cf8 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -325,10 +325,10 @@ void menu_advanced_settings(); EDIT_ITEM_N(percent, m, MSG_FAN_SPEED, &editable.uint8, 0, 255, []{ ui.material_preset[MenuItemBase::itemIndex].fan_speed = editable.uint8; }); #endif #if HAS_TEMP_HOTEND - EDIT_ITEM(uint16_3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - HOTEND_OVERSHOOT); + EDIT_ITEM(int3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - (HOTEND_OVERSHOOT)); #endif #if HAS_HEATED_BED - EDIT_ITEM(uint16_3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET); + EDIT_ITEM(int3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET); #endif #if ENABLED(EEPROM_SETTINGS) ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index fb82188645..37a44f51b4 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -114,7 +114,7 @@ void MarlinUI::draw_kill_screen() { void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { MarlinImage image = imgHotEnd; uint16_t Color; - float currentTemperature, targetTemperature; + celsius_t currentTemperature, targetTemperature; if (Heater >= 0) { // HotEnd currentTemperature = thermalManager.degHotend(Heater); @@ -175,13 +175,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { tft.add_image(0, 18, image, Color); - tft_string.set((uint8_t *)i16tostr3rj(currentTemperature + 0.5)); + tft_string.set((uint8_t *)i16tostr3rj(currentTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(64) + 2, 72, Color, tft_string); if (targetTemperature >= 0) { - tft_string.set((uint8_t *)i16tostr3rj(targetTemperature + 0.5)); + tft_string.set((uint8_t *)i16tostr3rj(targetTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(64) + 2, 8, Color, tft_string); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 164785a229..81e4603ea4 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -114,7 +114,7 @@ void MarlinUI::draw_kill_screen() { void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { MarlinImage image = imgHotEnd; uint16_t Color; - float currentTemperature, targetTemperature; + celsius_t currentTemperature, targetTemperature; if (Heater >= 0) { // HotEnd currentTemperature = thermalManager.degHotend(Heater); @@ -168,13 +168,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { tft.add_image(8, 28, image, Color); - tft_string.set((uint8_t *)i16tostr3rj(currentTemperature + 0.5)); + tft_string.set((uint8_t *)i16tostr3rj(currentTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string); if (targetTemperature >= 0) { - tft_string.set((uint8_t *)i16tostr3rj(targetTemperature + 0.5)); + tft_string.set((uint8_t *)i16tostr3rj(targetTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 2f4f5e283a..b0a4890e07 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -940,11 +940,11 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { DualXMode dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; float inactive_extruder_x = X2_MAX_POS, // Used in mode 0 & 1 - duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // Used in mode 2 + duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // Used in mode 2 & 3 xyz_pos_t raised_parked_position; // Used in mode 1 - bool active_extruder_parked = false; // Used in mode 1 & 2 + bool active_extruder_parked = false; // Used in mode 1, 2 & 3 millis_t delayed_move_time = 0; // Used in mode 1 - int16_t duplicate_extruder_temp_offset = 0; // Used in mode 2 + celsius_t duplicate_extruder_temp_offset = 0; // Used in mode 2 & 3 bool idex_mirrored_mode = false; // Used in mode 3 float x_home_pos(const uint8_t extruder) { diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 0328d015a4..7b8d2f2018 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -463,13 +463,13 @@ FORCE_INLINE bool all_axes_trusted() { return xyz_bits == }; extern DualXMode dual_x_carriage_mode; - extern float inactive_extruder_x, // Used in mode 0 & 1 - duplicate_extruder_x_offset; // Used in mode 2 & 3 - extern xyz_pos_t raised_parked_position; // Used in mode 1 - extern bool active_extruder_parked; // Used in mode 1, 2 & 3 - extern millis_t delayed_move_time; // Used in mode 1 - extern int16_t duplicate_extruder_temp_offset; // Used in mode 2 & 3 - extern bool idex_mirrored_mode; // Used in mode 3 + extern float inactive_extruder_x, // Used in mode 0 & 1 + duplicate_extruder_x_offset; // Used in mode 2 & 3 + extern xyz_pos_t raised_parked_position; // Used in mode 1 + extern bool active_extruder_parked; // Used in mode 1, 2 & 3 + extern millis_t delayed_move_time; // Used in mode 1 + extern celsius_t duplicate_extruder_temp_offset; // Used in mode 2 & 3 + extern bool idex_mirrored_mode; // Used in mode 3 FORCE_INLINE bool idex_is_duplicating() { return dual_x_carriage_mode >= DXC_DUPLICATION_MODE; } diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 594671f87a..8c320925be 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -197,9 +197,9 @@ float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step skew_factor_t Planner::skew_factor; // Initialized by settings.load() #if ENABLED(AUTOTEMP) - float Planner::autotemp_max = 250, - Planner::autotemp_min = 210, - Planner::autotemp_factor = 0.1f; + celsius_t Planner::autotemp_max = 250, + Planner::autotemp_min = 210; + float Planner::autotemp_factor = 0.1f; bool Planner::autotemp_enabled = false; #endif @@ -1376,7 +1376,7 @@ void Planner::check_axes_activity() { #if ENABLED(AUTOTEMP_PROPORTIONAL) void Planner::_autotemp_update_from_hotend() { - const int16_t target = thermalManager.degTargetHotend(active_extruder); + const celsius_t target = thermalManager.degTargetHotend(active_extruder); autotemp_min = target + AUTOTEMP_MIN_P; autotemp_max = target + AUTOTEMP_MAX_P; } diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 7ebba1e342..769967d4a6 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -896,7 +896,8 @@ class Planner { #endif #if ENABLED(AUTOTEMP) - static float autotemp_min, autotemp_max, autotemp_factor; + static celsius_t autotemp_min, autotemp_max; + static float autotemp_factor; static bool autotemp_enabled; static void autotemp_update(); static void autotemp_M104_M109(); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index dd7a36a82a..6d1f3bd0a3 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -253,7 +253,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if HAS_HOTEND hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 } - const uint16_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); + const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); #endif #if ENABLED(AUTO_POWER_E_FANS) @@ -368,12 +368,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if HAS_HEATED_BED 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 = TEMP_SENSOR_BED_RAW_LO_TEMP; - #endif - #ifdef BED_MAXTEMP - int16_t Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; - #endif + int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, + Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); #endif @@ -383,12 +379,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if HAS_HEATED_CHAMBER millis_t next_cool_check_ms_2 = 0; float old_temp = 9999; - #ifdef CHAMBER_MINTEMP - int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP; - #endif - #ifdef CHAMBER_MAXTEMP - int16_t Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; - #endif + int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, + Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0}); IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms); #endif @@ -400,12 +392,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, bool flag_cooler_state; //bool flag_cooler_excess = false; float previous_temp = 9999; - #ifdef COOLER_MINTEMP - int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP; - #endif - #ifdef COOLER_MAXTEMP - int16_t Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; - #endif + int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, + Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; #if WATCH_COOLER cooler_watch_t Temperature::watch_cooler{0}; #endif @@ -419,7 +407,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if ENABLED(PREVENT_COLD_EXTRUSION) bool Temperature::allow_cold_extrude = false; - int16_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP; + celsius_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP; #endif // private: @@ -429,7 +417,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #endif #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - uint16_t Temperature::redundant_temperature_raw = 0; + celsius_t Temperature::redundant_temperature_raw = 0; float Temperature::redundant_temperature = 0.0; #endif @@ -474,7 +462,7 @@ volatile bool Temperature::raw_temps_ready = false; #endif #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) - uint16_t Temperature::singlenozzle_temp[EXTRUDERS]; + celsius_t Temperature::singlenozzle_temp[EXTRUDERS]; #if HAS_FAN uint8_t Temperature::singlenozzle_fan_speed[EXTRUDERS]; #endif @@ -1566,22 +1554,22 @@ void Temperature::manage_heater() { * Bisect search for the range of the 'raw' value, then interpolate * proportionally between the under and over values. */ -#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \ - uint8_t l = 0, r = LEN, m; \ - for (;;) { \ - m = (l + r) >> 1; \ - if (!m) return int16_t(pgm_read_word(&TBL[0].celsius)); \ - if (m == l || m == r) return int16_t(pgm_read_word(&TBL[LEN-1].celsius)); \ - int16_t v00 = pgm_read_word(&TBL[m-1].value), \ - v10 = pgm_read_word(&TBL[m-0].value); \ - if (raw < v00) r = m; \ - else if (raw > v10) l = m; \ - else { \ - const int16_t v01 = int16_t(pgm_read_word(&TBL[m-1].celsius)), \ - v11 = int16_t(pgm_read_word(&TBL[m-0].celsius)); \ - return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \ - } \ - } \ +#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \ + uint8_t l = 0, r = LEN, m; \ + for (;;) { \ + m = (l + r) >> 1; \ + if (!m) return celsius_t(pgm_read_word(&TBL[0].celsius)); \ + if (m == l || m == r) return celsius_t(pgm_read_word(&TBL[LEN-1].celsius)); \ + int16_t v00 = pgm_read_word(&TBL[m-1].value), \ + v10 = pgm_read_word(&TBL[m-0].value); \ + if (raw < v00) r = m; \ + else if (raw > v10) l = m; \ + else { \ + const celsius_t v01 = celsius_t(pgm_read_word(&TBL[m-1].celsius)), \ + v11 = celsius_t(pgm_read_word(&TBL[m-0].celsius)); \ + return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \ + } \ + } \ }while(0) #if HAS_USER_THERMISTORS @@ -1663,7 +1651,7 @@ void Temperature::manage_heater() { SERIAL_EOL(); } - float Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) { + celsius_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) { //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB) // static uint32_t clocks_total = 0; // static uint32_t calls = 0; @@ -1712,7 +1700,7 @@ void Temperature::manage_heater() { #if HAS_HOTEND // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. - float Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) { + celsius_t 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(e); @@ -1821,7 +1809,7 @@ void Temperature::manage_heater() { #if HAS_HEATED_BED // For bed temperature measurement. - float Temperature::analog_to_celsius_bed(const int raw) { + celsius_t Temperature::analog_to_celsius_bed(const int raw) { #if TEMP_SENSOR_BED_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BED, raw); #elif TEMP_SENSOR_BED_IS_THERMISTOR @@ -1839,7 +1827,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_CHAMBER // For chamber temperature measurement. - float Temperature::analog_to_celsius_chamber(const int raw) { + celsius_t Temperature::analog_to_celsius_chamber(const int raw) { #if TEMP_SENSOR_CHAMBER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_CHAMBER, raw); #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR @@ -1857,7 +1845,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_COOLER // For cooler temperature measurement. - float Temperature::analog_to_celsius_cooler(const int raw) { + celsius_t Temperature::analog_to_celsius_cooler(const int raw) { #if TEMP_SENSOR_COOLER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_COOLER, raw); #elif TEMP_SENSOR_COOLER_IS_THERMISTOR @@ -1875,7 +1863,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_PROBE // For probe temperature measurement. - float Temperature::analog_to_celsius_probe(const int raw) { + celsius_t Temperature::analog_to_celsius_probe(const int raw) { #if TEMP_SENSOR_PROBE_IS_CUSTOM return user_thermistor_to_deg_c(CTI_PROBE, raw); #elif TEMP_SENSOR_PROBE_IS_THERMISTOR @@ -2191,13 +2179,13 @@ void Temperature::init() { #if HAS_HOTEND #define _TEMP_MIN_E(NR) do{ \ - 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))); \ + const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, 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(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \ + const celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, 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); \ @@ -2257,30 +2245,18 @@ void Temperature::init() { #endif // HAS_HOTEND #if HAS_HEATED_BED - #ifdef BED_MINTEMP - while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR); - #endif - #ifdef BED_MAXTEMP - while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR); - #endif - #endif // HAS_HEATED_BED + while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR); + while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR); + #endif #if HAS_HEATED_CHAMBER - #ifdef CHAMBER_MINTEMP - while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR); - #endif - #ifdef CHAMBER_MAXTEMP - while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR); - #endif + while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR); + while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR); #endif #if HAS_COOLER - #ifdef COOLER_MINTEMP - while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR); - #endif - #ifdef COOLER_MAXTEMP - while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR); - #endif + while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR); + while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR); #endif TERN_(PROBING_HEATERS_OFF, paused = false); @@ -2345,7 +2321,7 @@ void Temperature::init() { * * TODO: Embed the last 3 parameters during init, if not less optimal */ - void Temperature::tr_state_machine_t::run(const float ¤t, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) { + void Temperature::tr_state_machine_t::run(const float ¤t, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) { #if HEATER_IDLE_HANDLER // Convert the given heater_id_t to an idle array index @@ -2554,7 +2530,7 @@ void Temperature::disable_all_heaters() { #if HAS_MULTI_MAX_TC // Needed to return the correct temp when this is called between readings - static uint16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; + static celsius_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) diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 38270fc9c4..c9e3575257 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -179,7 +179,7 @@ enum ADCSensorState : char { typedef struct TempInfo { uint16_t acc; int16_t raw; - float celsius; + celsius_t celsius; inline void reset() { acc = 0; } inline void sample(const uint16_t s) { acc += s; } inline void update() { raw = acc; } @@ -187,7 +187,7 @@ typedef struct TempInfo { // A PWM heater with temperature sensor typedef struct HeaterInfo : public TempInfo { - int16_t target; + celsius_t target; uint8_t soft_pwm_amount; } heater_info_t; @@ -228,14 +228,14 @@ struct PIDHeaterInfo : public HeaterInfo { // Heater watch handling template struct HeaterWatch { - uint16_t target; + celsius_t target; millis_t next_ms; inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); } inline bool elapsed() { return elapsed(millis()); } - inline void restart(const int16_t curr, const int16_t tgt) { + inline void restart(const celsius_t curr, const celsius_t tgt) { if (tgt) { - const int16_t newtarget = curr + INCREASE; + const celsius_t newtarget = curr + INCREASE; if (newtarget < tgt - HYSTERESIS - 1) { target = newtarget; next_ms = millis() + SEC_TO_MS(PERIOD); @@ -261,8 +261,8 @@ struct HeaterWatch { // Temperature sensor read value ranges typedef struct { int16_t raw_min, raw_max; } raw_range_t; -typedef struct { int16_t mintemp, maxtemp; } celsius_range_t; -typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t; +typedef struct { celsius_t mintemp, maxtemp; } celsius_range_t; +typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t; #define THERMISTOR_ABS_ZERO_C -273.15f // bbbbrrrrr cold ! #define THERMISTOR_RESISTANCE_NOMINAL_C 25.0f // mmmmm comfortable @@ -323,8 +323,8 @@ class Temperature { #if HAS_HOTEND #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) static hotend_info_t temp_hotend[HOTEND_TEMPS]; - static const uint16_t hotend_maxtemp[HOTENDS]; - FORCE_INLINE static uint16_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } + static const celsius_t hotend_maxtemp[HOTENDS]; + FORCE_INLINE static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif TERN_(HAS_HEATED_BED, static bed_info_t temp_bed); TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe); @@ -342,8 +342,8 @@ class Temperature { #if ENABLED(PREVENT_COLD_EXTRUSION) static bool allow_cold_extrude; - static int16_t extrude_min_temp; - FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } + static celsius_t extrude_min_temp; + FORCE_INLINE static bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) { return tooCold(degHotend(HOTEND_INDEX)); } @@ -359,7 +359,7 @@ class Temperature { FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } #if ENABLED(SINGLENOZZLE_STANDBY_FAN) - static uint16_t singlenozzle_temp[EXTRUDERS]; + static celsius_t singlenozzle_temp[EXTRUDERS]; #if HAS_FAN static uint8_t singlenozzle_fan_speed[EXTRUDERS]; #endif @@ -411,7 +411,7 @@ class Temperature { #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) static uint16_t redundant_temperature_raw; - static float redundant_temperature; + static celsius_t redundant_temperature; #endif #if ENABLED(PID_EXTRUSION_SCALING) @@ -424,34 +424,19 @@ class Temperature { #if HAS_HEATED_BED TERN_(WATCH_BED, static bed_watch_t watch_bed); IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); - #ifdef BED_MINTEMP - static int16_t mintemp_raw_BED; - #endif - #ifdef BED_MAXTEMP - static int16_t maxtemp_raw_BED; - #endif + static int16_t mintemp_raw_BED, maxtemp_raw_BED; #endif #if HAS_HEATED_CHAMBER TERN_(WATCH_CHAMBER, static chamber_watch_t watch_chamber); TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms); - #ifdef CHAMBER_MINTEMP - static int16_t mintemp_raw_CHAMBER; - #endif - #ifdef CHAMBER_MAXTEMP - static int16_t maxtemp_raw_CHAMBER; - #endif + static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; #endif #if HAS_COOLER TERN_(WATCH_COOLER, static cooler_watch_t watch_cooler); static millis_t next_cooler_check_ms, cooler_fan_flush_ms; - #ifdef COOLER_MINTEMP - static int16_t mintemp_raw_COOLER; - #endif - #ifdef COOLER_MAXTEMP - static int16_t maxtemp_raw_COOLER; - #endif + static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER; #endif #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED @@ -488,7 +473,7 @@ class Temperature { static user_thermistor_t user_thermistor[USER_THERMISTORS]; static void log_user_thermistor(const uint8_t t_index, const bool eprom=false); static void reset_user_thermistors(); - static float user_thermistor_to_deg_c(const uint8_t t_index, const int raw); + static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw); static bool set_pull_up_res(int8_t t_index, float value) { //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false; if (!WITHIN(value, 1, 1000000)) return false; @@ -516,19 +501,19 @@ class Temperature { #endif #if HAS_HOTEND - static float analog_to_celsius_hotend(const int raw, const uint8_t e); + static celsius_t analog_to_celsius_hotend(const int raw, const uint8_t e); #endif #if HAS_HEATED_BED - static float analog_to_celsius_bed(const int raw); + static celsius_t analog_to_celsius_bed(const int raw); #endif #if HAS_TEMP_PROBE - static float analog_to_celsius_probe(const int raw); + static celsius_t analog_to_celsius_probe(const int raw); #endif #if HAS_TEMP_CHAMBER - static float analog_to_celsius_chamber(const int raw); + static celsius_t analog_to_celsius_chamber(const int raw); #endif #if HAS_TEMP_COOLER - static float analog_to_celsius_cooler(const int raw); + static celsius_t analog_to_celsius_cooler(const int raw); #endif #if HAS_FAN @@ -620,7 +605,7 @@ class Temperature { } #endif - FORCE_INLINE static int16_t degTargetHotend(const uint8_t E_NAME) { + FORCE_INLINE static celsius_t degTargetHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target); } @@ -632,7 +617,7 @@ class Temperature { #if HAS_HOTEND - static void setTargetHotend(const int16_t celsius, const uint8_t E_NAME) { + static void setTargetHotend(const celsius_t celsius, const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; #ifdef MILLISECONDS_PREHEAT_TIME if (celsius == 0) @@ -678,12 +663,12 @@ class Temperature { #if HAS_HEATED_BED #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawBedTemp() { return temp_bed.raw; } + FORCE_INLINE static int16_t rawBedTemp() { return temp_bed.raw; } #endif - FORCE_INLINE static float degBed() { return temp_bed.celsius; } - FORCE_INLINE static int16_t degTargetBed() { return temp_bed.target; } - FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } - FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } + FORCE_INLINE static celsius_t degBed() { return temp_bed.celsius; } + FORCE_INLINE static celsius_t degTargetBed() { return temp_bed.target; } + FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } + FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } #if WATCH_BED static void start_watching_bed(); @@ -691,15 +676,9 @@ class Temperature { static inline void start_watching_bed() {} #endif - static void setTargetBed(const int16_t celsius) { + static void setTargetBed(const celsius_t celsius) { TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on()); - temp_bed.target = - #ifdef BED_MAX_TARGET - _MIN(celsius, BED_MAX_TARGET) - #else - celsius - #endif - ; + temp_bed.target = _MIN(celsius, BED_MAX_TARGET); start_watching_bed(); } @@ -735,14 +714,13 @@ class Temperature { #if HAS_TEMP_CHAMBER #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; } + FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; } #endif - FORCE_INLINE static float degChamber() { return temp_chamber.celsius; } + FORCE_INLINE static float degChamber() { return temp_chamber.celsius; } #if HAS_HEATED_CHAMBER - FORCE_INLINE static int16_t degTargetChamber() { return temp_chamber.target; } - FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } - FORCE_INLINE static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } - + FORCE_INLINE static celsius_t degTargetChamber() { return temp_chamber.target; } + FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } + FORCE_INLINE static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } static bool wait_for_chamber(const bool no_wait_for_cooling=true); #endif #endif @@ -754,27 +732,21 @@ class Temperature { #endif #if HAS_HEATED_CHAMBER - static void setTargetChamber(const int16_t celsius) { - temp_chamber.target = - #ifdef CHAMBER_MAXTEMP - _MIN(celsius, CHAMBER_MAXTEMP - 10) - #else - celsius - #endif - ; + static void setTargetChamber(const celsius_t celsius) { + temp_chamber.target = _MIN(celsius, CHAMBER_MAX_TARGET); start_watching_chamber(); } #endif #if HAS_TEMP_COOLER #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; } + FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; } #endif - FORCE_INLINE static float degCooler() { return temp_cooler.celsius; } + FORCE_INLINE static float degCooler() { return temp_cooler.celsius; } #if HAS_COOLER - FORCE_INLINE static int16_t degTargetCooler() { return temp_cooler.target; } - FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } - FORCE_INLINE static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } + FORCE_INLINE static celsius_t degTargetCooler() { return temp_cooler.target; } + FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } + FORCE_INLINE static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } static bool wait_for_cooler(const bool no_wait_for_cooling=true); #endif #endif @@ -786,7 +758,7 @@ class Temperature { #endif #if HAS_COOLER - static void setTargetCooler(const int16_t celsius) { + static void setTargetCooler(const celsius_t celsius) { temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET); start_watching_cooler(); } @@ -945,7 +917,7 @@ class Temperature { millis_t timer = 0; TRState state = TRInactive; float running_temp; - void run(const float ¤t, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc); + void run(const float ¤t, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc); } tr_state_machine_t; static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY]; diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index f0ec289dfe..0871844e39 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -44,7 +44,7 @@ #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_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n) -typedef struct { int16_t value, celsius; } temp_entry_t; +typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; // Pt1000 and Pt100 handling // From 155dea6f14d18f6b0f272cb2718ba4c28f3afe1d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Mar 2021 23:58:53 -0500 Subject: [PATCH 092/311] Tweak mf helper scripts --- buildroot/bin/mftest | 14 ++++++++------ buildroot/share/git/mfqp | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 4cecf4f3a5..906e2abf87 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -28,6 +28,7 @@ OPTIONS -a --autobuild PIO Build using the MOTHERBOARD environment. -u --autoupload PIO Upload using the MOTHERBOARD environment. -v --verbose Extra output for debugging. + -s --silent Silence build output from PlatformIO. env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41 " @@ -62,6 +63,7 @@ while getopts 'abhmruvyn:t:-:' OFLAG; do esac ;; r) REBUILD=1 ; bugout "Rebuilding previous..." ;; + s) SILENT_FLAG="-s" ;; t) TESTENV="$OPTARG" ; bugout "Got a target: $TESTENV" ;; u) AUTO_BUILD=2 ; bugout "Auto-Upload target..." ;; v) DEBUG=1 ; bugout "Debug ON" ;; @@ -105,8 +107,8 @@ if ((REBUILD)); then # Build with the last-built env [[ -f "$STATE_FILE" ]] || { errout "No previous (-r) build state found." ; exit 1 ; } read TESTENV <"$STATE_FILE" - pio run -s -d . -e $TESTENV - exit + pio run $SILENT_FLAG -d . -e $TESTENV + exit 0 fi case $TESTENV in @@ -189,12 +191,12 @@ if ((AUTO_BUILD)); then if ((AUTO_BUILD == 2)); then echo "Uploading environment $TARGET for board $MB ($BNUM)..." ; echo - pio run -t upload -e $TARGET + pio run $SILENT_FLAG -t upload -e $TARGET else echo "Building environment $TARGET for board $MB ($BNUM)..." ; echo - pio run -s -e $TARGET + pio run $SILENT_FLAG -e $TARGET fi - exit + exit 0 fi # @@ -306,6 +308,6 @@ fi [[ $BUILD_YES == 'Y' || $BUILD_YES == 'Yes' ]] && { ((USE_MAKE)) && make tests-single-local TEST_TARGET=$TESTENV ONLY_TEST=$CHOICE - ((USE_MAKE)) || pio run -s -d . -e $TESTENV + ((USE_MAKE)) || pio run $SILENT_FLAG -d . -e $TESTENV echo "$TESTENV" >"$STATE_FILE" } diff --git a/buildroot/share/git/mfqp b/buildroot/share/git/mfqp index 5650d08252..f0c4446a21 100755 --- a/buildroot/share/git/mfqp +++ b/buildroot/share/git/mfqp @@ -4,7 +4,7 @@ # # - git add . # - git commit --amend -# - ghpc +# - git push -f # MFINFO=$(mfinfo "$@") || exit 1 @@ -17,6 +17,7 @@ IND=6 while [ $IND -lt ${#INFO[@]} ]; do ARG=${INFO[$IND]} case "$ARG" in + -f|--force ) FORCE=1 ;; -h|--help ) USAGE=1 ;; * ) USAGE=1 ; echo "unknown option: $ARG" ;; esac @@ -25,6 +26,6 @@ done [[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; } -[[ $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; } +[[ $FORCE != 1 && $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; } git add . && git commit --amend && git push -f From 8fca37f3737e66150c1ed5b5793e2c48dd108b23 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Mar 2021 23:54:23 -0500 Subject: [PATCH 093/311] Misc LCD cleanup --- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 35 +- .../extui/lib/mks_ui/draw_level_settings.cpp | 4 +- .../lcd/extui/lib/mks_ui/draw_manuaLevel.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_number_key.cpp | 392 ++++-------------- ...ngs.cpp => draw_tramming_pos_settings.cpp} | 36 +- ...ettings.h => draw_tramming_pos_settings.h} | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 24 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 4 +- .../lcd/extui/lib/mks_ui/tft_Language_en.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_t_cn.h | 2 +- .../extui/lib/mks_ui/tft_multi_language.cpp | 8 +- .../lcd/extui/lib/mks_ui/tft_multi_language.h | 2 +- Marlin/src/lcd/menu/menu_bed_corners.cpp | 7 +- 15 files changed, 151 insertions(+), 375 deletions(-) rename Marlin/src/lcd/extui/lib/mks_ui/{draw_manual_level_pos_settings.cpp => draw_tramming_pos_settings.cpp} (80%) rename Marlin/src/lcd/extui/lib/mks_ui/{draw_manual_level_pos_settings.h => draw_tramming_pos_settings.h} (91%) diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 7334ba5f26..a3b14d8609 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -574,6 +574,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #if EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) + // + // Draw knob rotation => Z motion key for: + // - menu.cpp:lcd_babystep_zoffset + // - menu_ubl.cpp:_lcd_mesh_fine_tune + // + const unsigned char cw_bmp[] PROGMEM = { B00000000,B11111110,B00000000, B00000011,B11111111,B10000000, @@ -672,28 +678,23 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop old_zvalue = zvalue; } - #if ENABLED(OVERLAY_GFX_REVERSE) - const unsigned char *rot_up = ccw_bmp, *rot_down = cw_bmp; - #else - const unsigned char *rot_up = cw_bmp, *rot_down = ccw_bmp; - #endif + const unsigned char *rot_up = TERN(OVERLAY_GFX_REVERSE, ccw_bmp, cw_bmp), + *rot_down = TERN(OVERLAY_GFX_REVERSE, cw_bmp, ccw_bmp); - #if ENABLED(USE_BIG_EDIT_FONT) - const int left = 0, right = 45, nozzle = 95; - #else - const int left = 5, right = 90, nozzle = 60; - #endif + const int left = TERN(USE_BIG_EDIT_FONT, 0, 5), + right = TERN(USE_BIG_EDIT_FONT, 45, 90), + nozzle = TERN(USE_BIG_EDIT_FONT, 95, 60); - // Draw a representation of the nozzle - if (PAGE_CONTAINS(3, 16)) u8g.drawBitmapP(nozzle + 6, 4 - dir, 2, 12, nozzle_bmp); - if (PAGE_CONTAINS(20, 20)) u8g.drawBitmapP(nozzle + 0, 20, 3, 1, offset_bedline_bmp); + // Draw nozzle lowered or raised according to direction moved + if (PAGE_CONTAINS( 3, 16)) u8g.drawBitmapP(nozzle + 6, 4 - dir, 2, 12, nozzle_bmp); + if (PAGE_CONTAINS(20, 20)) u8g.drawBitmapP(nozzle + 0, 20 , 3, 1, offset_bedline_bmp); // Draw cw/ccw indicator and up/down arrows. if (PAGE_CONTAINS(47, 62)) { - u8g.drawBitmapP(right + 0, 48 - dir, 2, 13, up_arrow_bmp); - u8g.drawBitmapP(left + 0, 49 - dir, 2, 13, down_arrow_bmp); - u8g.drawBitmapP(left + 13, 47, 3, 16, rot_down); - u8g.drawBitmapP(right + 13, 47, 3, 16, rot_up); + u8g.drawBitmapP(right + 0, 48 - dir, 2, 13, up_arrow_bmp); + u8g.drawBitmapP(left + 0, 49 - dir, 2, 13, down_arrow_bmp); + u8g.drawBitmapP(left + 13, 47 , 3, 16, rot_down); + u8g.drawBitmapP(right + 13, 47 , 3, 16, rot_up); } } 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 b5c1890309..015c95a68f 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 @@ -46,7 +46,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { draw_return_ui(); break; case ID_LEVEL_POSITION: - lv_draw_manual_level_pos_settings(); + lv_draw_tramming_pos_settings(); break; case ID_LEVEL_COMMAND: keyboard_value = autoLevelGcodeCommand; @@ -62,7 +62,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_draw_level_settings() { scr = lv_screen_create(LEVELING_PARA_UI, machine_menu.LevelingParaConfTitle); - lv_screen_menu_item(scr, machine_menu.LevelingManuPosConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_LEVEL_POSITION, 0); + lv_screen_menu_item(scr, machine_menu.TrammingPosConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_LEVEL_POSITION, 0); lv_screen_menu_item(scr, machine_menu.LevelingAutoCommandConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_LEVEL_COMMAND, 1); #if HAS_BED_PROBE lv_screen_menu_item(scr, machine_menu.LevelingAutoZoffsetConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_LEVEL_ZOFFSET, 2); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp index 039591b03e..9734dd94ae 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp @@ -54,7 +54,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { queue.inject_P(G28_STR); } const int ind = obj->mks_obj_id - ID_M_POINT1; - sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), (int)gCfgItems.levelingPos[ind][0], (int)gCfgItems.levelingPos[ind][1]); + sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), (int)gCfgItems.trammingPos[ind][X_AXIS], (int)gCfgItems.trammingPos[ind][Y_AXIS]); queue.inject(public_buf_l); } break; 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 91a1fce28d..092dcce083 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 @@ -204,44 +204,44 @@ static void disp_key_value() { 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]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[0][X_AXIS]); break; case level_pos_y1: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[0][1]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[0][Y_AXIS]); break; case level_pos_x2: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[1][0]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[1][X_AXIS]); break; case level_pos_y2: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[1][1]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[1][Y_AXIS]); break; case level_pos_x3: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[2][0]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[2][X_AXIS]); break; case level_pos_y3: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[2][1]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[2][Y_AXIS]); break; case level_pos_x4: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[3][0]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[3][X_AXIS]); break; case level_pos_y4: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[3][1]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[3][Y_AXIS]); break; case level_pos_x5: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[4][0]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[4][X_AXIS]); break; case level_pos_y5: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[4][1]); + sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[4][Y_AXIS]); break; #if HAS_BED_PROBE case x_offset: #if HAS_PROBE_XY_OFFSET - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(probe.offset.x, 1, 3, str_1)); + 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("%s"), dtostrf(probe.offset.y, 1, 3, str_1)); + sprintf_P(public_buf_m, PSTR("%s"), dtostrf(probe.offset.y, 1, 3, str_1)); #endif break; case z_offset: @@ -295,194 +295,87 @@ static void disp_key_value() { } static void set_value_confirm() { - #if HAS_TRINAMIC_CONFIG - uint16_t current_mA; - #endif switch (value) { - case PrintAcceleration: - planner.settings.acceleration = atof(key_value); - break; - case RetractAcceleration: - planner.settings.retract_acceleration = atof(key_value); - break; - case TravelAcceleration: - planner.settings.travel_acceleration = atof(key_value); - break; - case XAcceleration: - planner.settings.max_acceleration_mm_per_s2[X_AXIS] = atof(key_value); - break; - case YAcceleration: - planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = atof(key_value); - break; - case ZAcceleration: - planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = atof(key_value); - break; - case E0Acceleration: - planner.settings.max_acceleration_mm_per_s2[E_AXIS] = atof(key_value); - break; - case E1Acceleration: - planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)] = atof(key_value); - break; - case XMaxFeedRate: - planner.settings.max_feedrate_mm_s[X_AXIS] = atof(key_value); - break; - case YMaxFeedRate: - planner.settings.max_feedrate_mm_s[Y_AXIS] = atof(key_value); - break; - case ZMaxFeedRate: - planner.settings.max_feedrate_mm_s[Z_AXIS] = atof(key_value); - break; - case E0MaxFeedRate: - planner.settings.max_feedrate_mm_s[E_AXIS] = atof(key_value); - break; - case E1MaxFeedRate: - planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); - break; - case XJerk: - #if HAS_CLASSIC_JERK - planner.max_jerk[X_AXIS] = atof(key_value); - #endif - break; - case YJerk: - #if HAS_CLASSIC_JERK - planner.max_jerk[Y_AXIS] = atof(key_value); - #endif - break; - case ZJerk: - #if HAS_CLASSIC_JERK - planner.max_jerk[Z_AXIS] = atof(key_value); - #endif - break; - case EJerk: - #if HAS_CLASSIC_JERK - planner.max_jerk[E_AXIS] = atof(key_value); - #endif - break; - case Xstep: - planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); - planner.refresh_positioning(); - break; - case Ystep: - planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); - planner.refresh_positioning(); - break; - case Zstep: - planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); - planner.refresh_positioning(); - break; - case E0step: - planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value); - planner.refresh_positioning(); - break; - case E1step: - planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); - planner.refresh_positioning(); - break; + case PrintAcceleration: planner.settings.acceleration = atof(key_value); break; + case RetractAcceleration: planner.settings.retract_acceleration = atof(key_value); break; + case TravelAcceleration: planner.settings.travel_acceleration = atof(key_value); break; + case XAcceleration: planner.settings.max_acceleration_mm_per_s2[X_AXIS] = atof(key_value); break; + case YAcceleration: planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = atof(key_value); break; + case ZAcceleration: planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = atof(key_value); break; + case E0Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS] = atof(key_value); break; + case E1Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)] = atof(key_value); break; + case XMaxFeedRate: planner.settings.max_feedrate_mm_s[X_AXIS] = atof(key_value); break; + case YMaxFeedRate: planner.settings.max_feedrate_mm_s[Y_AXIS] = atof(key_value); break; + case ZMaxFeedRate: planner.settings.max_feedrate_mm_s[Z_AXIS] = atof(key_value); break; + case E0MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS] = atof(key_value); break; + case E1MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); break; + case XJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[X_AXIS] = atof(key_value)); break; + case YJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Y_AXIS] = atof(key_value)); break; + case ZJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Z_AXIS] = atof(key_value)); break; + case EJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[E_AXIS] = atof(key_value)); break; + case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); planner.refresh_positioning(); break; + case Ystep: planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); planner.refresh_positioning(); break; + case Zstep: planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); planner.refresh_positioning(); break; + case E0step: planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value); planner.refresh_positioning(); break; + case E1step: planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); planner.refresh_positioning(); break; case Xcurrent: #if AXIS_IS_TMC(X) - current_mA = atoi(key_value); - stepperX.rms_current(current_mA); + stepperX.rms_current(atoi(key_value)); #endif break; case Ycurrent: #if AXIS_IS_TMC(Y) - current_mA = atoi(key_value); - stepperY.rms_current(current_mA); + stepperY.rms_current(atoi(key_value)); #endif break; case Zcurrent: #if AXIS_IS_TMC(Z) - current_mA = atoi(key_value); - stepperZ.rms_current(current_mA); + stepperZ.rms_current(atoi(key_value)); #endif break; case E0current: #if AXIS_IS_TMC(E0) - current_mA = atoi(key_value); - stepperE0.rms_current(current_mA); + stepperE0.rms_current(atoi(key_value)); #endif break; case E1current: #if AXIS_IS_TMC(E1) - current_mA = atoi(key_value); - stepperE1.rms_current(current_mA); + stepperE1.rms_current(atoi(key_value)); #endif break; - case pause_pos_x: - gCfgItems.pausePosX = atof(key_value); - update_spi_flash(); - break; - case pause_pos_y: - gCfgItems.pausePosY = atof(key_value); - update_spi_flash(); - break; - case pause_pos_z: - gCfgItems.pausePosZ = atof(key_value); - update_spi_flash(); - break; - case level_pos_x1: - gCfgItems.levelingPos[0][0] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_y1: - gCfgItems.levelingPos[0][1] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_x2: - gCfgItems.levelingPos[1][0] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_y2: - gCfgItems.levelingPos[1][1] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_x3: - gCfgItems.levelingPos[2][0] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_y3: - gCfgItems.levelingPos[2][1] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_x4: - gCfgItems.levelingPos[3][0] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_y4: - gCfgItems.levelingPos[3][1] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_x5: - gCfgItems.levelingPos[4][0] = atoi(key_value); - update_spi_flash(); - break; - case level_pos_y5: - gCfgItems.levelingPos[4][1] = atoi(key_value); - update_spi_flash(); - break; + case pause_pos_x: gCfgItems.pausePosX = atof(key_value); update_spi_flash(); break; + case pause_pos_y: gCfgItems.pausePosY = atof(key_value); update_spi_flash(); break; + case pause_pos_z: gCfgItems.pausePosZ = atof(key_value); update_spi_flash(); break; + case level_pos_x1: gCfgItems.trammingPos[0][X_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_y1: gCfgItems.trammingPos[0][Y_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_x2: gCfgItems.trammingPos[1][X_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_y2: gCfgItems.trammingPos[1][Y_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_x3: gCfgItems.trammingPos[2][X_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_y3: gCfgItems.trammingPos[2][Y_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_x4: gCfgItems.trammingPos[3][X_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_y4: gCfgItems.trammingPos[3][Y_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_x5: gCfgItems.trammingPos[4][X_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_y5: gCfgItems.trammingPos[4][Y_AXIS] = atoi(key_value); update_spi_flash(); break; #if HAS_BED_PROBE - case x_offset: + case x_offset: { #if HAS_PROBE_XY_OFFSET - float x; - x = atof(key_value); + const float x = atof(key_value); if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE)) probe.offset.x = x; #endif - break; - case y_offset: + } break; + case y_offset: { #if HAS_PROBE_XY_OFFSET - float y; - y = atof(key_value); + const float y = atof(key_value); if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE)) probe.offset.y = y; #endif - break; - case z_offset: - float z; - z = atof(key_value); + } break; + case z_offset: { + const float z = atof(key_value); if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) probe.offset.z = z; - break; + } break; #endif case load_length: gCfgItems.filamentchange_load_length = atoi(key_value); @@ -508,26 +401,10 @@ static void set_value_confirm() { gCfgItems.filament_limit_temp = atoi(key_value); update_spi_flash(); break; - case x_sensitivity: - #if X_SENSORLESS - stepperX.homing_threshold(atoi(key_value)); - #endif - break; - case y_sensitivity: - #if Y_SENSORLESS - stepperY.homing_threshold(atoi(key_value)); - #endif - break; - case z_sensitivity: - #if Z_SENSORLESS - stepperZ.homing_threshold(atoi(key_value)); - #endif - break; - case z2_sensitivity: - #if Z2_SENSORLESS - stepperZ2.homing_threshold(atoi(key_value)); - #endif - break; + case x_sensitivity: TERN_(X_SENSORLESS, stepperX.homing_threshold(atoi(key_value))); break; + case y_sensitivity: TERN_(Y_SENSORLESS, stepperY.homing_threshold(atoi(key_value))); break; + case z_sensitivity: TERN_(Z_SENSORLESS, stepperZ.homing_threshold(atoi(key_value))); break; + case z2_sensitivity: TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(atoi(key_value))); break; } gcode.process_subcommands_now_P(PSTR("M500")); } @@ -535,81 +412,9 @@ static void set_value_confirm() { 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_NUM_KEY1: + case ID_NUM_KEY1 ... ID_NUM_KEY0: if (cnt <= 10) { - key_value[cnt] = (char)'1'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY2: - if (cnt <= 10) { - key_value[cnt] = (char)'2'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY3: - if (cnt <= 10) { - key_value[cnt] = (char)'3'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY4: - if (cnt <= 10) { - key_value[cnt] = (char)'4'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY5: - if (cnt <= 10) { - key_value[cnt] = (char)'5'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY6: - if (cnt <= 10) { - key_value[cnt] = (char)'6'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY7: - if (cnt <= 10) { - key_value[cnt] = (char)'7'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY8: - if (cnt <= 10) { - key_value[cnt] = (char)'8'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY9: - if (cnt <= 10) { - key_value[cnt] = (char)'9'; - lv_label_set_text(labelValue, key_value); - lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); - cnt++; - } - break; - case ID_NUM_KEY0: - if (cnt <= 10) { - key_value[cnt] = (char)'0'; + key_value[cnt] = (obj->mks_obj_id == ID_NUM_KEY0) ? (char)'0' : char('1' + obj->mks_obj_id - ID_NUM_KEY1); lv_label_set_text(labelValue, key_value); lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); cnt++; @@ -662,55 +467,22 @@ void lv_draw_number_key() { buttonValue = lv_btn_create(scr, 92, 40, 296, 40, event_handler, ID_NUM_KEY1, &style_num_text); labelValue = lv_label_create_empty(buttonValue); - lv_obj_t *NumberKey_1 = lv_btn_create(scr, 92, 90, 68, 40, event_handler, ID_NUM_KEY1, &style_num_key_pre); - lv_obj_t *labelKey_1 = lv_label_create_empty(NumberKey_1); - lv_label_set_text(labelKey_1, machine_menu.key_1); - lv_obj_align(labelKey_1, NumberKey_1, LV_ALIGN_CENTER, 0, 0); + #define DRAW_NUMBER_KEY(N,X,Y) \ + lv_obj_t *NumberKey_##N = lv_btn_create(scr, X, Y, 68, 40, event_handler, ID_NUM_KEY##N, &style_num_key_pre); \ + lv_obj_t *labelKey_##N = lv_label_create_empty(NumberKey_##N); \ + lv_label_set_text(labelKey_##N, machine_menu.key_##N); \ + lv_obj_align(labelKey_##N, NumberKey_##N, LV_ALIGN_CENTER, 0, 0) - lv_obj_t *NumberKey_2 = lv_btn_create(scr, 168, 90, 68, 40, event_handler, ID_NUM_KEY2, &style_num_key_pre); - lv_obj_t *labelKey_2 = lv_label_create_empty(NumberKey_2); - lv_label_set_text(labelKey_2, machine_menu.key_2); - lv_obj_align(labelKey_2, NumberKey_2, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *NumberKey_3 = lv_btn_create(scr, 244, 90, 68, 40, event_handler, ID_NUM_KEY3, &style_num_key_pre); - lv_obj_t *labelKey_3 = lv_label_create_empty(NumberKey_3); - lv_label_set_text(labelKey_3, machine_menu.key_3); - lv_obj_align(labelKey_3, NumberKey_3, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *NumberKey_4 = lv_btn_create(scr, 92, 140, 68, 40, event_handler, ID_NUM_KEY4, &style_num_key_pre); - lv_obj_t *labelKey_4 = lv_label_create_empty(NumberKey_4); - lv_label_set_text(labelKey_4, machine_menu.key_4); - lv_obj_align(labelKey_4, NumberKey_4, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *NumberKey_5 = lv_btn_create(scr, 168, 140, 68, 40, event_handler, ID_NUM_KEY5, &style_num_key_pre); - lv_obj_t *labelKey_5 = lv_label_create_empty(NumberKey_5); - lv_label_set_text(labelKey_5, machine_menu.key_5); - lv_obj_align(labelKey_5, NumberKey_5, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *NumberKey_6 = lv_btn_create(scr, 244, 140, 68, 40, event_handler, ID_NUM_KEY6, &style_num_key_pre); - lv_obj_t *labelKey_6 = lv_label_create_empty(NumberKey_6); - lv_label_set_text(labelKey_6, machine_menu.key_6); - lv_obj_align(labelKey_6, NumberKey_6, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *NumberKey_7 = lv_btn_create(scr, 92, 190, 68, 40, event_handler, ID_NUM_KEY7, &style_num_key_pre); - lv_obj_t *labelKey_7 = lv_label_create_empty(NumberKey_7); - lv_label_set_text(labelKey_7, machine_menu.key_7); - lv_obj_align(labelKey_7, NumberKey_7, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *NumberKey_8 = lv_btn_create(scr, 168, 190, 68, 40, event_handler, ID_NUM_KEY8, &style_num_key_pre); - lv_obj_t *labelKey_8 = lv_label_create_empty(NumberKey_8); - lv_label_set_text(labelKey_8, machine_menu.key_8); - lv_obj_align(labelKey_8, NumberKey_8, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *NumberKey_9 = lv_btn_create(scr, 244, 190, 68, 40, event_handler, ID_NUM_KEY9, &style_num_key_pre); - lv_obj_t *labelKey_9 = lv_label_create_empty(NumberKey_9); - lv_label_set_text(labelKey_9, machine_menu.key_9); - lv_obj_align(labelKey_9, NumberKey_9, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *NumberKey_0 = lv_btn_create(scr, 92, 240, 68, 40, event_handler, ID_NUM_KEY0, &style_num_key_pre); - lv_obj_t *labelKey_0 = lv_label_create_empty(NumberKey_0); - lv_label_set_text(labelKey_0, machine_menu.key_0); - lv_obj_align(labelKey_0, NumberKey_0, LV_ALIGN_CENTER, 0, 0); + DRAW_NUMBER_KEY(1, 92, 90); + DRAW_NUMBER_KEY(2, 168, 90); + DRAW_NUMBER_KEY(3, 244, 90); + DRAW_NUMBER_KEY(4, 92, 140); + DRAW_NUMBER_KEY(5, 168, 140); + DRAW_NUMBER_KEY(6, 244, 140); + DRAW_NUMBER_KEY(7, 92, 190); + DRAW_NUMBER_KEY(8, 168, 190); + DRAW_NUMBER_KEY(9, 244, 190); + DRAW_NUMBER_KEY(0, 92, 240); lv_obj_t *KeyBack = lv_btn_create(scr, 320, 90, 68, 40, event_handler, ID_NUM_BACK, &style_num_key_pre); lv_obj_t *labelKeyBack = lv_label_create_empty(KeyBack); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp similarity index 80% rename from Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp rename to Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp index 6cbd703f9c..d5307232d6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp @@ -53,7 +53,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_MANUAL_POS_RETURN: uiCfg.para_ui_page = false; - lv_clear_manual_level_pos_settings(); + lv_clear_tramming_pos_settings(); draw_return_ui(); return; case ID_MANUAL_POS_X1: @@ -88,46 +88,46 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { break; case ID_MANUAL_POS_UP: uiCfg.para_ui_page = false; - lv_clear_manual_level_pos_settings(); - lv_draw_manual_level_pos_settings(); + lv_clear_tramming_pos_settings(); + lv_draw_tramming_pos_settings(); return; case ID_MANUAL_POS_DOWN: uiCfg.para_ui_page = true; - lv_clear_manual_level_pos_settings(); - lv_draw_manual_level_pos_settings(); + lv_clear_tramming_pos_settings(); + lv_draw_tramming_pos_settings(); return; } - lv_clear_manual_level_pos_settings(); + lv_clear_tramming_pos_settings(); lv_draw_number_key(); } -void lv_draw_manual_level_pos_settings() { +void lv_draw_tramming_pos_settings() { char buf2[50]; scr = lv_screen_create(MANUAL_LEVELING_POSIGION_UI, machine_menu.LevelingParaConfTitle); if (!uiCfg.para_ui_page) { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[0][1]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[0][X_AXIS]); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[0][Y_AXIS]); lv_screen_menu_item_2_edit(scr, leveling_menu.position1, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y1, 0, buf2, ID_MANUAL_POS_X1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][0]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[1][1]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[1][X_AXIS]); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[1][Y_AXIS]); lv_screen_menu_item_2_edit(scr, leveling_menu.position2, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MANUAL_POS_Y2, 1, buf2, ID_MANUAL_POS_X2, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][0]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[2][1]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[2][X_AXIS]); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[2][Y_AXIS]); lv_screen_menu_item_2_edit(scr, leveling_menu.position3, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MANUAL_POS_Y3, 2, buf2, ID_MANUAL_POS_X3, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][0]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[3][1]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[3][X_AXIS]); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[3][Y_AXIS]); lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_MANUAL_POS_Y4, 3, buf2, ID_MANUAL_POS_X4, 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_MANUAL_POS_DOWN, true); } else { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][0]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[4][1]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[4][X_AXIS]); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[4][Y_AXIS]); lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y5, 0, buf2, ID_MANUAL_POS_X5, 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_MANUAL_POS_UP, true); @@ -136,7 +136,7 @@ void lv_draw_manual_level_pos_settings() { 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_MANUAL_POS_RETURN, true); } -void lv_clear_manual_level_pos_settings() { +void lv_clear_tramming_pos_settings() { #if HAS_ROTARY_ENCODER if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.h similarity index 91% rename from Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h rename to Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.h index 83fd225bd3..3ebb8ae731 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_manual_level_pos_settings(); -extern void lv_clear_manual_level_pos_settings(); +extern void lv_draw_tramming_pos_settings(); +extern void lv_clear_tramming_pos_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ 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 12e060aa01..0c574b1e15 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -125,16 +125,16 @@ void gCfgItems_init() { gCfgItems.pausePosX = -1; gCfgItems.pausePosY = -1; gCfgItems.pausePosZ = 5; - gCfgItems.levelingPos[0][0] = X_MIN_POS + 30; - gCfgItems.levelingPos[0][1] = Y_MIN_POS + 30; - gCfgItems.levelingPos[1][0] = X_MAX_POS - 30; - gCfgItems.levelingPos[1][1] = Y_MIN_POS + 30; - gCfgItems.levelingPos[2][0] = X_MAX_POS - 30; - gCfgItems.levelingPos[2][1] = Y_MAX_POS - 30; - gCfgItems.levelingPos[3][0] = X_MIN_POS + 30; - gCfgItems.levelingPos[3][1] = Y_MAX_POS - 30; - gCfgItems.levelingPos[4][0] = X_BED_SIZE / 2; - gCfgItems.levelingPos[4][1] = Y_BED_SIZE / 2; + gCfgItems.trammingPos[0][X_AXIS] = X_MIN_POS + 30; + gCfgItems.trammingPos[0][Y_AXIS] = Y_MIN_POS + 30; + gCfgItems.trammingPos[1][X_AXIS] = X_MAX_POS - 30; + gCfgItems.trammingPos[1][Y_AXIS] = Y_MIN_POS + 30; + gCfgItems.trammingPos[2][X_AXIS] = X_MAX_POS - 30; + gCfgItems.trammingPos[2][Y_AXIS] = Y_MAX_POS - 30; + gCfgItems.trammingPos[3][X_AXIS] = X_MIN_POS + 30; + gCfgItems.trammingPos[3][Y_AXIS] = Y_MAX_POS - 30; + gCfgItems.trammingPos[4][X_AXIS] = X_BED_SIZE / 2; + gCfgItems.trammingPos[4][Y_AXIS] = Y_BED_SIZE / 2; gCfgItems.cloud_enable = false; gCfgItems.wifi_mode_sel = STA_MODEL; gCfgItems.fileSysType = FILE_SYS_SD; @@ -994,7 +994,7 @@ void clear_cur_ui() { case LEVELING_SETTIGNS_UI: break; case LEVELING_PARA_UI: lv_clear_level_settings(); break; case DELTA_LEVELING_PARA_UI: break; - case MANUAL_LEVELING_POSIGION_UI: lv_clear_manual_level_pos_settings(); break; + case MANUAL_LEVELING_POSIGION_UI: lv_clear_tramming_pos_settings(); break; case MAXFEEDRATE_UI: lv_clear_max_feedrate_settings(); break; case STEPS_UI: lv_clear_step_settings(); break; case ACCELERATION_UI: lv_clear_acceleration_settings(); break; @@ -1099,7 +1099,7 @@ void draw_return_ui() { case LEVELING_SETTIGNS_UI: break; case LEVELING_PARA_UI: lv_draw_level_settings(); break; case DELTA_LEVELING_PARA_UI: break; - case MANUAL_LEVELING_POSIGION_UI: lv_draw_manual_level_pos_settings(); break; + case MANUAL_LEVELING_POSIGION_UI: lv_draw_tramming_pos_settings(); break; case MAXFEEDRATE_UI: lv_draw_max_feedrate_settings(); break; case STEPS_UI: lv_draw_step_settings(); break; case ACCELERATION_UI: lv_draw_acceleration_settings(); break; 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 3098a6666c..0690e59570 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -69,7 +69,7 @@ #include "draw_max_feedrate_settings.h" #include "draw_tmc_step_mode_settings.h" #include "draw_level_settings.h" -#include "draw_manual_level_pos_settings.h" +#include "draw_tramming_pos_settings.h" #include "draw_auto_level_offset_settings.h" #include "draw_filament_change.h" #include "draw_filament_settings.h" @@ -197,7 +197,7 @@ typedef struct { uint8_t wifi_type; bool cloud_enable, encoder_enable; - int levelingPos[5][2]; + int trammingPos[5][2]; // XY int filamentchange_load_length, filamentchange_load_speed, filamentchange_unload_length, 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 12a57bd548..104e1fdcaf 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 @@ -99,7 +99,7 @@ #define LEVELING_CONF_TITLE_EN "Machine Settings>Leveling settings" #define LEVELING_PARA_CONF_EN "Leveling settings" -#define LEVELING_MANUAL_POS_EN "Manual leveling coordinate settings" +#define TRAMMING_POS_EN "Manual leveling coordinate settings" #define LEVELING_AUTO_COMMAND_EN "AutoLeveling command settings" #define LEVELING_AUTO_ZOFFSET_EN "Nozzle-to-probe offsets settings" 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 50e32ac05c..f6b3231737 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 @@ -283,7 +283,7 @@ #define LEVELING_CONF_TITLE_RU "Hастройки принтера>Hастройки уровня" #define LEVELING_PARA_CONF_RU "настройки уровня" -#define LEVELING_MANUAL_POS_RU "настройки координат для уровня" +#define TRAMMING_POS_RU "настройки координат для уровня" #define LEVELING_AUTO_COMMAND_RU "настройки комманд увтоуровня" #define LEVELING_AUTO_ZOFFSET_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 f204933e25..b50761fde0 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 @@ -84,7 +84,7 @@ #define LEVELING_CONF_TITLE_CN "机器参数>调平设置" #define LEVELING_PARA_CONF_CN "调平设置" -#define LEVELING_MANUAL_POS_CN "手动调平坐标设置" +#define TRAMMING_POS_CN "手动调平坐标设置" #define LEVELING_AUTO_COMMAND_CN "自动调平指令设置" #define LEVELING_AUTO_ZOFFSET_CN "挤出头与调平开关偏移设置" 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 76da2de907..3f58a9afd2 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 @@ -84,7 +84,7 @@ #define LEVELING_CONF_TITLE_T_CN "機器參數>調平設置" #define LEVELING_PARA_CONF_T_CN "調平設置" -#define LEVELING_MANUAL_POS_T_CN "手動調平坐標設置" +#define TRAMMING_POS_T_CN "手動調平坐標設置" #define LEVELING_AUTO_COMMAND_T_CN "自動調平指令設置" #define LEVELING_AUTO_ZOFFSET_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 5ee184571f..7caae5cd3a 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 @@ -119,7 +119,7 @@ void machine_setting_disp() { machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_CN; machine_menu.LevelingParaConf = LEVELING_PARA_CONF_CN; - machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_CN; + machine_menu.TrammingPosConf = TRAMMING_POS_CN; machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_CN; machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_CN; @@ -347,7 +347,7 @@ void machine_setting_disp() { machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_T_CN; machine_menu.LevelingParaConf = LEVELING_PARA_CONF_T_CN; - machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_T_CN; + machine_menu.TrammingPosConf = TRAMMING_POS_T_CN; machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_T_CN; machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_T_CN; @@ -576,7 +576,7 @@ void machine_setting_disp() { machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_EN; machine_menu.LevelingParaConf = LEVELING_PARA_CONF_EN; - machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_EN; + machine_menu.TrammingPosConf = TRAMMING_POS_EN; machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_EN; machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_EN; @@ -1708,7 +1708,7 @@ void disp_language_init() { machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_RU; machine_menu.LevelingParaConf = LEVELING_PARA_CONF_RU; - machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_RU; + machine_menu.TrammingPosConf = TRAMMING_POS_RU; machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_RU; machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_RU; 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 731b2eaecd..82d3e18f74 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 @@ -103,7 +103,7 @@ typedef struct machine_common_disp{ const char *LevelingParaConfTitle; const char *LevelingParaConf; - const char *LevelingManuPosConf; + const char *TrammingPosConf; const char *LevelingAutoCommandConf; const char *LevelingAutoZoffsetConf; diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 0dae8dbf41..4cfb4e411b 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -296,8 +296,11 @@ static inline void _lcd_level_bed_corners_get_next_position() { } while (good_points < nr_edge_points); // loop until all points within tolerance - TERN_(BLTOUCH_HS_MODE, do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP)); // Do clearance in HIGH SPEED MODE at the very end - TERN_(BLTOUCH_HS_MODE, bltouch.stow()); // Stow in HIGH SPEED MODE at the very end + #if ENABLED(BLTOUCH_HS_MODE) + // In HIGH SPEED MODE do clearance and stow at the very end + do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); + bltouch.stow(); + #endif ui.goto_screen(_lcd_draw_level_prompt); // prompt for bed leveling ui.set_selection(true); From da4b6896f7e4f102d8c2164e7aecf22cf2922fe2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 24 Mar 2021 03:28:48 -0500 Subject: [PATCH 094/311] Group UBL parameters, add comments --- Marlin/src/feature/bedlevel/ubl/ubl.h | 35 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 335 ++++++++++---------- Marlin/src/gcode/bedlevel/M420.cpp | 6 +- Marlin/src/lcd/marlinui.h | 10 +- Marlin/src/lcd/menu/menu_ubl.cpp | 46 +-- 5 files changed, 223 insertions(+), 209 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 0c4667eed8..67a9b0a60e 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -45,23 +45,26 @@ struct mesh_index_pair; typedef int16_t mesh_store_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; #endif +typedef struct { + bool C_seen; + int8_t V_verbosity, + P_phase, + R_repetition, + KLS_storage_slot, + T_map_type; + float B_shim_thickness, + C_constant; + xy_pos_t XY_pos; + xy_bool_t XY_seen; + #if HAS_BED_PROBE + int grid_size; + #endif +} G29_parameters_t; + class unified_bed_leveling { private: - static int g29_verbose_level, - g29_phase_value, - g29_repetition_cnt, - g29_storage_slot, - g29_map_type; - static bool g29_c_flag; - static float g29_card_thickness, - g29_constant; - static xy_pos_t g29_pos; - static xy_bool_t xy_seen; - - #if HAS_BED_PROBE - static int g29_grid_size; - #endif + static G29_parameters_t param; #if IS_NEWPANEL static void move_z_with_encoder(const float &multiplier); @@ -71,7 +74,7 @@ private: static void fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) _O0; #endif - static bool g29_parameter_parsing() _O0; + static bool G29_parse_parameters() _O0; static void shift_mesh_height(); static void probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) _O0; static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3); @@ -129,7 +132,7 @@ public: static inline void steppers_were_disabled() {} #endif - static volatile int16_t encoder_diff; // Volatile because buttons may changed it at interrupt time + static volatile int16_t encoder_diff; // Volatile because buttons may change it at interrupt time unified_bed_leveling(); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index bcda183366..42a3018561 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -71,21 +71,6 @@ #define SIZE_OF_LITTLE_RAISE 1 #define BIG_RAISE_NOT_NEEDED 0 -int unified_bed_leveling::g29_verbose_level, - unified_bed_leveling::g29_phase_value, - unified_bed_leveling::g29_repetition_cnt, - unified_bed_leveling::g29_storage_slot = 0, - unified_bed_leveling::g29_map_type; -bool unified_bed_leveling::g29_c_flag; -float unified_bed_leveling::g29_card_thickness = 0, - unified_bed_leveling::g29_constant = 0; -xy_bool_t unified_bed_leveling::xy_seen; -xy_pos_t unified_bed_leveling::g29_pos; - -#if HAS_BED_PROBE - int unified_bed_leveling::g29_grid_size; -#endif - /** * G29: Unified Bed Leveling by Roxy * @@ -309,10 +294,12 @@ xy_pos_t unified_bed_leveling::g29_pos; * features of all three systems combined. */ +G29_parameters_t unified_bed_leveling::param; + void unified_bed_leveling::G29() { bool probe_deployed = false; - if (g29_parameter_parsing()) return; // Abort on parameter error + if (G29_parse_parameters()) return; // Abort on parameter error const int8_t p_val = parser.intval('P', -1); const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J'); @@ -326,33 +313,29 @@ void unified_bed_leveling::G29() { TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); } - // Invalidate Mesh Points. This command is a little bit asymmetrical because - // it directly specifies the repetition count and does not use the 'R' parameter. + // Invalidate one or more nearby mesh points, possibly all. if (parser.seen('I')) { - uint8_t cnt = 0; - g29_repetition_cnt = parser.has_value() ? parser.value_int() : 1; - if (g29_repetition_cnt >= GRID_MAX_POINTS) { - set_all_mesh_points_to_value(NAN); - } - else { - while (g29_repetition_cnt--) { - if (cnt > 20) { cnt = 0; idle(); } - const mesh_index_pair closest = find_closest_mesh_point_of_type(REAL, g29_pos); - const xy_int8_t &cpos = closest.pos; - if (cpos.x < 0) { - // No more REAL mesh points to invalidate, so we ASSUME the user - // meant to invalidate the ENTIRE mesh, which cannot be done with - // find_closest_mesh_point loop which only returns REAL points. - set_all_mesh_points_to_value(NAN); - SERIAL_ECHOLNPGM("Entire Mesh invalidated.\n"); - break; // No more invalid Mesh Points to populate - } - z_values[cpos.x][cpos.y] = NAN; - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, 0.0f)); - cnt++; + int16_t count = parser.has_value() ? parser.value_int() : 1; + bool invalidate_all = count >= GRID_MAX_POINTS; + if (!invalidate_all) { + while (count--) { + if ((count & 0x0F) == 0x0F) idle(); + const mesh_index_pair closest = find_closest_mesh_point_of_type(REAL, param.XY_pos); + // No more REAL mesh points to invalidate? Assume the user meant + // to invalidate the ENTIRE mesh, which can't be done with + // find_closest_mesh_point (which only returns REAL points). + if (closest.pos.x < 0) { invalidate_all = true; break; } + z_values[closest.pos.x][closest.pos.y] = NAN; + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(closest.pos, 0.0f)); } } - SERIAL_ECHOLNPGM("Locations invalidated.\n"); + if (invalidate_all) { + invalidate(); + SERIAL_ECHOPGM("Entire Mesh"); + } + else + SERIAL_ECHOPGM("Locations"); + SERIAL_ECHOLNPGM(" invalidated.\n"); } if (parser.seen('Q')) { @@ -364,11 +347,7 @@ void unified_bed_leveling::G29() { SERIAL_ECHOLNPGM("Loading test_pattern values.\n"); switch (test_pattern) { - #if ENABLED(UBL_DEVEL_DEBUGGING) - case -1: - g29_eeprom_dump(); - break; - #endif + case -1: TERN_(UBL_DEVEL_DEBUGGING, g29_eeprom_dump()); break; case 0: GRID_LOOP(x, y) { // Create a bowl shape similar to a poorly-calibrated Delta @@ -395,7 +374,7 @@ void unified_bed_leveling::G29() { // Allow the user to specify the height because 10mm is a little extreme in some cases. for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++) // Create a rectangular raised area in for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) { // the center of the bed - z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f; + z_values[x][y] += parser.seen('C') ? param.C_constant : 9.99f; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); } break; @@ -406,7 +385,7 @@ void unified_bed_leveling::G29() { if (parser.seen('J')) { save_ubl_active_state_and_disable(); - tilt_mesh_based_on_probed_grid(g29_grid_size == 0); // Zero size does 3-Point + tilt_mesh_based_on_probed_grid(param.grid_size == 0); // Zero size does 3-Point restore_ubl_active_state_and_leave(); #if ENABLED(UBL_G29_J_RECENTER) do_blocking_move_to_xy(0.5f * ((MESH_MIN_X) + (MESH_MAX_X)), 0.5f * ((MESH_MIN_Y) + (MESH_MAX_Y))); @@ -418,12 +397,12 @@ void unified_bed_leveling::G29() { #endif // HAS_BED_PROBE if (parser.seen('P')) { - if (WITHIN(g29_phase_value, 0, 1) && storage_slot == -1) { + if (WITHIN(param.P_phase, 0, 1) && storage_slot == -1) { storage_slot = 0; SERIAL_ECHOLNPGM("Default storage slot 0 selected."); } - switch (g29_phase_value) { + switch (param.P_phase) { case 0: // // Zero Mesh Data @@ -442,13 +421,13 @@ void unified_bed_leveling::G29() { invalidate(); SERIAL_ECHOLNPGM("Mesh invalidated. Probing mesh."); } - if (g29_verbose_level > 1) { - SERIAL_ECHOPAIR("Probing around (", g29_pos.x); + if (param.V_verbosity > 1) { + SERIAL_ECHOPAIR("Probing around (", param.XY_pos.x); SERIAL_CHAR(','); - SERIAL_DECIMAL(g29_pos.y); + SERIAL_DECIMAL(param.XY_pos.y); SERIAL_ECHOLNPGM(").\n"); } - const xy_pos_t near_probe_xy = g29_pos + probe.offset_xy; + const xy_pos_t near_probe_xy = param.XY_pos + probe.offset_xy; probe_entire_mesh(near_probe_xy, parser.seen('T'), parser.seen('E'), parser.seen('U')); report_current_position(); @@ -465,7 +444,7 @@ void unified_bed_leveling::G29() { SERIAL_ECHOLNPGM("Manually probing unreachable points."); do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES); - if (parser.seen('C') && !xy_seen) { + if (parser.seen('C') && !param.XY_seen) { /** * Use a good default location for the path. @@ -474,7 +453,7 @@ void unified_bed_leveling::G29() { * It may make sense to have Delta printers default to the center of the bed. * Until that is decided, this can be forced with the X and Y parameters. */ - g29_pos.set( + param.XY_pos.set( #if IS_KINEMATIC X_HOME_POS, Y_HOME_POS #else @@ -485,21 +464,21 @@ void unified_bed_leveling::G29() { } if (parser.seen('B')) { - g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness(); - if (ABS(g29_card_thickness) > 1.5f) { + param.B_shim_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness(); + if (ABS(param.B_shim_thickness) > 1.5f) { SERIAL_ECHOLNPGM("?Error in Business Card measurement."); return; } probe_deployed = true; } - if (!position_is_reachable(g29_pos)) { + if (!position_is_reachable(param.XY_pos)) { SERIAL_ECHOLNPGM("XY outside printable radius."); return; } const float height = parser.floatval('H', Z_CLEARANCE_BETWEEN_PROBES); - manually_probe_remaining_mesh(g29_pos, height, g29_card_thickness, parser.seen('T')); + manually_probe_remaining_mesh(param.XY_pos, height, param.B_shim_thickness, parser.seen('T')); SERIAL_ECHOLNPGM("G29 P2 finished."); @@ -521,23 +500,23 @@ void unified_bed_leveling::G29() { * - Allow 'G29 P3' to choose a 'reasonable' constant. */ - if (g29_c_flag) { - if (g29_repetition_cnt >= GRID_MAX_POINTS) { - set_all_mesh_points_to_value(g29_constant); + if (param.C_seen) { + if (param.R_repetition >= GRID_MAX_POINTS) { + set_all_mesh_points_to_value(param.C_constant); } else { - while (g29_repetition_cnt--) { // this only populates reachable mesh points near - const mesh_index_pair closest = find_closest_mesh_point_of_type(INVALID, g29_pos); + while (param.R_repetition--) { // this only populates reachable mesh points near + const mesh_index_pair closest = find_closest_mesh_point_of_type(INVALID, param.XY_pos); const xy_int8_t &cpos = closest.pos; if (cpos.x < 0) { // No more REAL INVALID mesh points to populate, so we ASSUME // user meant to populate ALL INVALID mesh points to value - GRID_LOOP(x, y) if (isnan(z_values[x][y])) z_values[x][y] = g29_constant; + GRID_LOOP(x, y) if (isnan(z_values[x][y])) z_values[x][y] = param.C_constant; break; // No more invalid Mesh Points to populate } else { - z_values[cpos.x][cpos.y] = g29_constant; - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, g29_constant)); + z_values[cpos.x][cpos.y] = param.C_constant; + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, param.C_constant)); } } } @@ -571,14 +550,14 @@ void unified_bed_leveling::G29() { case 4: // Fine Tune (i.e., Edit) the Mesh #if HAS_LCD_MENU - fine_tune_mesh(g29_pos, parser.seen('T')); + fine_tune_mesh(param.XY_pos, parser.seen('T')); #else SERIAL_ECHOLNPGM("?P4 is only available when an LCD is present."); return; #endif break; - case 5: adjust_mesh_to_mean(g29_c_flag, g29_constant); break; + case 5: adjust_mesh_to_mean(param.C_seen, param.C_constant); break; case 6: shift_mesh_height(); break; } @@ -608,7 +587,7 @@ void unified_bed_leveling::G29() { // if (parser.seen('L')) { // Load Current Mesh Data - g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot; + param.KLS_storage_slot = parser.has_value() ? parser.value_int() : storage_slot; int16_t a = settings.calc_num_meshes(); @@ -617,13 +596,13 @@ void unified_bed_leveling::G29() { return; } - if (!WITHIN(g29_storage_slot, 0, a - 1)) { + if (!WITHIN(param.KLS_storage_slot, 0, a - 1)) { SERIAL_ECHOLNPAIR("?Invalid storage slot.\n?Use 0 to ", a - 1); return; } - settings.load_mesh(g29_storage_slot); - storage_slot = g29_storage_slot; + settings.load_mesh(param.KLS_storage_slot); + storage_slot = param.KLS_storage_slot; SERIAL_ECHOLNPGM("Done."); } @@ -633,9 +612,9 @@ void unified_bed_leveling::G29() { // if (parser.seen('S')) { // Store (or Save) Current Mesh Data - g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot; + param.KLS_storage_slot = parser.has_value() ? parser.value_int() : storage_slot; - if (g29_storage_slot == -1) // Special case, the user wants to 'Export' the mesh to the + if (param.KLS_storage_slot == -1) // Special case, the user wants to 'Export' the mesh to the return report_current_mesh(); // host program to be saved on the user's computer int16_t a = settings.calc_num_meshes(); @@ -645,19 +624,19 @@ void unified_bed_leveling::G29() { goto LEAVE; } - if (!WITHIN(g29_storage_slot, 0, a - 1)) { + if (!WITHIN(param.KLS_storage_slot, 0, a - 1)) { SERIAL_ECHOLNPAIR("?Invalid storage slot.\n?Use 0 to ", a - 1); goto LEAVE; } - settings.store_mesh(g29_storage_slot); - storage_slot = g29_storage_slot; + settings.store_mesh(param.KLS_storage_slot); + storage_slot = param.KLS_storage_slot; SERIAL_ECHOLNPGM("Done."); } if (parser.seen('T')) - display_map(g29_map_type); + display_map(param.T_map_type); LEAVE: @@ -682,7 +661,12 @@ void unified_bed_leveling::G29() { return; } -void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) { +/** + * M420 C + * G29 P5 C : Adjust Mesh To Mean (and subtract the given offset). + * Find the mean average and shift the mesh to center on that value. + */ +void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float offset) { float sum = 0; int n = 0; GRID_LOOP(x, y) @@ -710,23 +694,27 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float val if (cflag) GRID_LOOP(x, y) if (!isnan(z_values[x][y])) { - z_values[x][y] -= mean + value; + z_values[x][y] -= mean + offset; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); } } +/** + * G29 P6 C : Shift Mesh Height by a uniform constant. + */ void unified_bed_leveling::shift_mesh_height() { GRID_LOOP(x, y) if (!isnan(z_values[x][y])) { - z_values[x][y] += g29_constant; + z_values[x][y] += param.C_constant; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); } } #if HAS_BED_PROBE /** - * Probe all invalidated locations of the mesh that can be reached by the probe. - * This attempts to fill in locations closest to the nozzle's start location first. + * G29 P1 T V : Probe Entire Mesh + * Probe all invalidated locations of the mesh that can be reached by the probe. + * This attempts to fill in locations closest to the nozzle's start location first. */ void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &nearby, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) { probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW @@ -739,7 +727,7 @@ void unified_bed_leveling::shift_mesh_height() { mesh_index_pair best; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_START)); do { - if (do_ubl_mesh_map) display_map(g29_map_type); + if (do_ubl_mesh_map) display_map(param.T_map_type); const int point_num = (GRID_MAX_POINTS) - count + 1; SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, "."); @@ -767,7 +755,7 @@ void unified_bed_leveling::shift_mesh_height() { TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START)); const float measured_z = probe.probe_at_point( best.meshpos(), - stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level + stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity ); z_values[best.pos.x][best.pos.y] = measured_z; #if ENABLED(EXTENSIBLE_UI) @@ -798,11 +786,20 @@ void unified_bed_leveling::shift_mesh_height() { #endif // HAS_BED_PROBE +void set_message_with_feedback(PGM_P const msg_P) { + #if HAS_LCD_MENU + ui.set_status_P(msg_P); + ui.quick_feedback(); + #else + UNUSED(msg_P); + #endif +} + #if HAS_LCD_MENU typedef void (*clickFunc_t)(); - bool click_and_hold(const clickFunc_t func=nullptr) { + bool _click_and_hold(const clickFunc_t func=nullptr) { if (ui.button_pressed()) { ui.quick_feedback(false); // Preserve button state for click-and-hold const millis_t nxt = millis() + 1500UL; @@ -834,7 +831,8 @@ void unified_bed_leveling::shift_mesh_height() { float unified_bed_leveling::measure_point_with_encoder() { KEEPALIVE_STATE(PAUSED_FOR_USER); - move_z_with_encoder(0.01f); + const float z_step = 0.01f; + move_z_with_encoder(z_step); return current_position.z; } @@ -866,7 +864,7 @@ void unified_bed_leveling::shift_mesh_height() { const float thickness = ABS(z1 - z2); - if (g29_verbose_level > 1) { + if (param.V_verbosity > 1) { SERIAL_ECHOPAIR_F("Business Card is ", thickness, 4); SERIAL_ECHOLNPGM("mm thick."); } @@ -876,6 +874,11 @@ void unified_bed_leveling::shift_mesh_height() { return thickness; } + /** + * G29 P2 : Manually Probe Remaining Mesh Points. + * Move to INVALID points and + * NOTE: Blocks the G-code queue and captures Marlin UI during use. + */ void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) { ui.capture(); @@ -907,7 +910,7 @@ void unified_bed_leveling::shift_mesh_height() { KEEPALIVE_STATE(PAUSED_FOR_USER); ui.capture(); - if (do_ubl_mesh_map) display_map(g29_map_type); // show user where we're probing + if (do_ubl_mesh_map) display_map(param.T_map_type); // Show user where we're probing if (parser.seen('B')) { SERIAL_ECHOPGM_P(GET_TEXT(MSG_UBL_BC_INSERT)); @@ -918,45 +921,38 @@ void unified_bed_leveling::shift_mesh_height() { LCD_MESSAGEPGM(MSG_UBL_BC_INSERT2); } - const float z_step = 0.01f; // existing behavior: 0.01mm per click, occasionally step - //const float z_step = planner.steps_to_mm[Z_AXIS]; // approx one step each click - + const float z_step = 0.01f; // 0.01mm per encoder tick, occasionally step move_z_with_encoder(z_step); - if (click_and_hold()) { + if (_click_and_hold([]{ SERIAL_ECHOLNPGM("\nMesh only partially populated."); do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); - return restore_ubl_active_state_and_leave(); - } + })) return restore_ubl_active_state_and_leave(); + // Store the Z position minus the shim height z_values[lpos.x][lpos.y] = current_position.z - thick; + + // Tell the external UI to update TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, z_values[lpos.x][lpos.y])); - if (g29_verbose_level > 2) + if (param.V_verbosity > 2) SERIAL_ECHOLNPAIR_F("Mesh Point Measured at: ", z_values[lpos.x][lpos.y], 6); SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } while (location.valid()); - if (do_ubl_mesh_map) display_map(g29_map_type); // show user where we're probing + if (do_ubl_mesh_map) display_map(param.T_map_type); // show user where we're probing restore_ubl_active_state_and_leave(); do_blocking_move_to_xy_z(pos, Z_CLEARANCE_DEPLOY_PROBE); } - inline void set_message_with_feedback(PGM_P const msg_P) { - ui.set_status_P(msg_P); - ui.quick_feedback(); - } - - void abort_fine_tune() { - ui.return_to_status(); - do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES); - set_message_with_feedback(GET_TEXT(MSG_EDITING_STOPPED)); - } - + /** + * G29 P4 : Mesh Fine-Tuning. Go to point(s) and adjust values with the LCD. + * NOTE: Blocks the G-code queue and captures Marlin UI during use. + */ void unified_bed_leveling::fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) { - if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified - g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided. + if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified + param.R_repetition = 1; // do exactly one mesh location. Otherwise use what the parser decided. #if ENABLED(UBL_MESH_EDIT_MOVES_Z) const float h_offset = parser.seenval('H') ? parser.value_linear_units() : MANUAL_PROBE_START_Z; @@ -984,7 +980,7 @@ void unified_bed_leveling::shift_mesh_height() { const xy_int8_t &lpos = location.pos; #if IS_TFTGLCD_PANEL - lcd_mesh_edit_setup(0); // Change current screen before calling ui.ubl_plot + ui.ubl_mesh_edit_start(0); // Change current screen before calling ui.ubl_plot safe_delay(50); #endif @@ -1009,7 +1005,7 @@ void unified_bed_leveling::shift_mesh_height() { KEEPALIVE_STATE(PAUSED_FOR_USER); - if (do_ubl_mesh_map) display_map(g29_map_type); // Display the current point + if (do_ubl_mesh_map) display_map(param.T_map_type); // Display the current point #if IS_TFTGLCD_PANEL ui.ubl_plot(lpos.x, lpos.y); // update plot screen @@ -1021,13 +1017,13 @@ void unified_bed_leveling::shift_mesh_height() { if (isnan(new_z)) new_z = 0; // Invalid points begin at 0 new_z = FLOOR(new_z * 1000) * 0.001f; // Chop off digits after the 1000ths place - lcd_mesh_edit_setup(new_z); + ui.ubl_mesh_edit_start(new_z); SET_SOFT_ENDSTOP_LOOSE(true); do { idle(); - new_z = lcd_mesh_edit(); + new_z = ui.ubl_mesh_value(); TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } while (!ui.button_pressed()); @@ -1036,17 +1032,27 @@ void unified_bed_leveling::shift_mesh_height() { if (!lcd_map_control) ui.return_to_status(); // Just editing a single point? Return to status - if (click_and_hold(abort_fine_tune)) break; // Button held down? Abort editing + // Button held down? Abort editing + if (_click_and_hold([]{ + ui.return_to_status(); + do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES); + set_message_with_feedback(GET_TEXT(MSG_EDITING_STOPPED)); + })) break; + + // TODO: Disable leveling here so the Z value becomes the 'native' Z value. z_values[lpos.x][lpos.y] = new_z; // Save the updated Z value + + // TODO: Re-enable leveling here so Z is correctly based on the updated mesh. + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, new_z)); serial_delay(20); // No switch noise ui.refresh(); - } while (lpos.x >= 0 && --g29_repetition_cnt > 0); + } while (lpos.x >= 0 && --param.R_repetition > 0); - if (do_ubl_mesh_map) display_map(g29_map_type); + if (do_ubl_mesh_map) display_map(param.T_map_type); restore_ubl_active_state_and_leave(); do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); @@ -1062,25 +1068,28 @@ void unified_bed_leveling::shift_mesh_height() { #endif // HAS_LCD_MENU -bool unified_bed_leveling::g29_parameter_parsing() { +/** + * Parse and validate most G29 parameters, store for use by G29 functions. + */ +bool unified_bed_leveling::G29_parse_parameters() { bool err_flag = false; - TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29))); + set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29)); - g29_constant = 0; - g29_repetition_cnt = 0; + param.C_constant = 0; + param.R_repetition = 0; if (parser.seen('R')) { - g29_repetition_cnt = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS; - NOMORE(g29_repetition_cnt, GRID_MAX_POINTS); - if (g29_repetition_cnt < 1) { + param.R_repetition = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS; + NOMORE(param.R_repetition, GRID_MAX_POINTS); + if (param.R_repetition < 1) { SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n"); return UBL_ERR; } } - g29_verbose_level = parser.seen('V') ? parser.value_int() : 0; - if (!WITHIN(g29_verbose_level, 0, 4)) { + param.V_verbosity = parser.seen('V') ? parser.value_int() : 0; + if (!WITHIN(param.V_verbosity, 0, 4)) { SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).\n"); err_flag = true; } @@ -1095,8 +1104,8 @@ bool unified_bed_leveling::g29_parameter_parsing() { else #endif { - g29_phase_value = pv; - if (!WITHIN(g29_phase_value, 0, 6)) { + param.P_phase = pv; + if (!WITHIN(param.P_phase, 0, 6)) { SERIAL_ECHOLNPGM("?(P)hase value invalid (0-6).\n"); err_flag = true; } @@ -1105,8 +1114,8 @@ bool unified_bed_leveling::g29_parameter_parsing() { if (parser.seen('J')) { #if HAS_BED_PROBE - g29_grid_size = parser.has_value() ? parser.value_int() : 0; - if (g29_grid_size && !WITHIN(g29_grid_size, 2, 9)) { + param.grid_size = parser.has_value() ? parser.value_int() : 0; + if (param.grid_size && !WITHIN(param.grid_size, 2, 9)) { SERIAL_ECHOLNPGM("?Invalid grid size (J) specified (2-9).\n"); err_flag = true; } @@ -1116,12 +1125,12 @@ bool unified_bed_leveling::g29_parameter_parsing() { #endif } - xy_seen.x = parser.seenval('X'); - float sx = xy_seen.x ? parser.value_float() : current_position.x; - xy_seen.y = parser.seenval('Y'); - float sy = xy_seen.y ? parser.value_float() : current_position.y; + param.XY_seen.x = parser.seenval('X'); + float sx = param.XY_seen.x ? parser.value_float() : current_position.x; + param.XY_seen.y = parser.seenval('Y'); + float sy = param.XY_seen.y ? parser.value_float() : current_position.y; - if (xy_seen.x != xy_seen.y) { + if (param.XY_seen.x != param.XY_seen.y) { SERIAL_ECHOLNPGM("Both X & Y locations must be specified.\n"); err_flag = true; } @@ -1132,7 +1141,7 @@ bool unified_bed_leveling::g29_parameter_parsing() { if (err_flag) return UBL_ERR; - g29_pos.set(sx, sy); + param.XY_pos.set(sx, sy); /** * Activate or deactivate UBL @@ -1154,8 +1163,8 @@ bool unified_bed_leveling::g29_parameter_parsing() { } // Set global 'C' flag and its value - if ((g29_c_flag = parser.seen('C'))) - g29_constant = parser.value_float(); + if ((param.C_seen = parser.seen('C'))) + param.C_constant = parser.value_float(); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) if (parser.seenval('F')) { @@ -1168,8 +1177,8 @@ bool unified_bed_leveling::g29_parameter_parsing() { } #endif - g29_map_type = parser.intval('T'); - if (!WITHIN(g29_map_type, 0, 2)) { + param.T_map_type = parser.intval('T'); + if (!WITHIN(param.T_map_type, 0, 2)) { SERIAL_ECHOLNPGM("Invalid map type.\n"); return UBL_ERR; } @@ -1187,7 +1196,7 @@ void unified_bed_leveling::save_ubl_active_state_and_disable() { ubl_state_recursion_chk++; if (ubl_state_recursion_chk != 1) { SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row."); - TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR))); + set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR)); return; } #endif @@ -1200,7 +1209,7 @@ void unified_bed_leveling::restore_ubl_active_state_and_leave() { #if ENABLED(UBL_DEVEL_DEBUGGING) if (--ubl_state_recursion_chk) { SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times."); - TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR))); + set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR)); return; } #endif @@ -1411,8 +1420,8 @@ void unified_bed_leveling::smart_fill_mesh() { void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) { const float x_min = probe.min_x(), x_max = probe.max_x(), y_min = probe.min_y(), y_max = probe.max_y(), - dx = (x_max - x_min) / (g29_grid_size - 1), - dy = (y_max - y_min) / (g29_grid_size - 1); + dx = (x_max - x_min) / (param.grid_size - 1), + dy = (y_max - y_min) / (param.grid_size - 1); xy_float_t points[3]; probe.get_three_points(points); @@ -1431,7 +1440,7 @@ void unified_bed_leveling::smart_fill_mesh() { SERIAL_ECHOLNPGM("Tilting mesh (1/3)"); TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); - measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level); + measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity); if (isnan(measured_z)) abort_flag = true; else { @@ -1439,7 +1448,7 @@ void unified_bed_leveling::smart_fill_mesh() { #ifdef VALIDATE_MESH_TILT z1 = measured_z; #endif - if (g29_verbose_level > 3) { + if (param.V_verbosity > 3) { serial_spaces(16); SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z); } @@ -1450,7 +1459,7 @@ void unified_bed_leveling::smart_fill_mesh() { SERIAL_ECHOLNPGM("Tilting mesh (2/3)"); TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); - measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level); + measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, param.V_verbosity); #ifdef VALIDATE_MESH_TILT z2 = measured_z; #endif @@ -1458,7 +1467,7 @@ void unified_bed_leveling::smart_fill_mesh() { abort_flag = true; else { measured_z -= get_z_correction(points[1]); - if (g29_verbose_level > 3) { + if (param.V_verbosity > 3) { serial_spaces(16); SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z); } @@ -1470,7 +1479,7 @@ void unified_bed_leveling::smart_fill_mesh() { SERIAL_ECHOLNPGM("Tilting mesh (3/3)"); TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); - measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level); + measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, param.V_verbosity); #ifdef VALIDATE_MESH_TILT z3 = measured_z; #endif @@ -1478,7 +1487,7 @@ void unified_bed_leveling::smart_fill_mesh() { abort_flag = true; else { measured_z -= get_z_correction(points[2]); - if (g29_verbose_level > 3) { + if (param.V_verbosity > 3) { serial_spaces(16); SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z); } @@ -1498,20 +1507,20 @@ void unified_bed_leveling::smart_fill_mesh() { bool zig_zag = false; - const uint16_t total_points = sq(g29_grid_size); + const uint16_t total_points = sq(param.grid_size); uint16_t point_num = 1; xy_pos_t rpos; - LOOP_L_N(ix, g29_grid_size) { + LOOP_L_N(ix, param.grid_size) { rpos.x = x_min + ix * dx; - LOOP_L_N(iy, g29_grid_size) { - rpos.y = y_min + dy * (zig_zag ? g29_grid_size - 1 - iy : iy); + LOOP_L_N(iy, param.grid_size) { + rpos.y = y_min + dy * (zig_zag ? param.grid_size - 1 - iy : iy); if (!abort_flag) { SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n"); TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points)); - measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling + measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling abort_flag = isnan(measured_z); @@ -1534,7 +1543,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F(" final >>>---> ", measured_z, 7); - if (g29_verbose_level > 3) { + if (param.V_verbosity > 3) { serial_spaces(16); SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z); } @@ -1557,7 +1566,7 @@ void unified_bed_leveling::smart_fill_mesh() { vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1).get_normal(); - if (g29_verbose_level > 2) { + if (param.V_verbosity > 2) { SERIAL_ECHOPAIR_F("bed plane normal = [", normal.x, 7); SERIAL_CHAR(','); SERIAL_ECHO_F(normal.y, 7); @@ -1721,7 +1730,7 @@ void unified_bed_leveling::smart_fill_mesh() { SERIAL_ECHOLNPAIR_F("Fade Height M420 Z", planner.z_fade_height, 4); #endif - adjust_mesh_to_mean(g29_c_flag, g29_constant); + adjust_mesh_to_mean(param.C_seen, param.C_constant); #if HAS_BED_PROBE SERIAL_ECHOLNPAIR_F("Probe Offset M851 Z", probe.offset.z, 7); @@ -1819,17 +1828,17 @@ void unified_bed_leveling::smart_fill_mesh() { return; } - if (!parser.has_value() || !WITHIN(g29_storage_slot, 0, a - 1)) { + if (!parser.has_value() || !WITHIN(parser.value_int(), 0, a - 1)) { SERIAL_ECHOLNPAIR("?Invalid storage slot.\n?Use 0 to ", a - 1); return; } - g29_storage_slot = parser.value_int(); + param.KLS_storage_slot = parser.value_int(); float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - settings.load_mesh(g29_storage_slot, &tmp_z_values); + settings.load_mesh(param.KLS_storage_slot, &tmp_z_values); - SERIAL_ECHOLNPAIR("Subtracting mesh in slot ", g29_storage_slot, " from current mesh."); + SERIAL_ECHOLNPAIR("Subtracting mesh in slot ", param.KLS_storage_slot, " from current mesh."); GRID_LOOP(x, y) { z_values[x][y] -= tmp_z_values[x][y]; diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 96122c18f8..55b14c19dc 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -156,16 +156,16 @@ void GcodeSuite::M420() { GRID_LOOP(x, y) mesh_sum += Z_VALUES(x, y); const float zmean = mesh_sum / float(GRID_MAX_POINTS); - #else + #else // midrange - // Find the low and high mesh values + // Find the low and high mesh values. float lo_val = 100, hi_val = -100; GRID_LOOP(x, y) { const float z = Z_VALUES(x, y); NOMORE(lo_val, z); NOLESS(hi_val, z); } - // Take the mean of the lowest and highest + // Get the midrange plus C value. (The median may be better.) const float zmean = (lo_val + hi_val) / 2.0 + cval; #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 6f5703e622..a18a3384af 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -85,11 +85,6 @@ typedef void (*screenFunc_t)(); typedef void (*menuAction_t)(); - #if ENABLED(AUTO_BED_LEVELING_UBL) - void lcd_mesh_edit_setup(const float &initial); - float lcd_mesh_edit(); - #endif - #endif // HAS_LCD_MENU #endif // HAS_WIRED_LCD @@ -488,6 +483,11 @@ public: static void ubl_plot(const uint8_t x_plot, const uint8_t y_plot); #endif + #if ENABLED(AUTO_BED_LEVELING_UBL) + static void ubl_mesh_edit_start(const float &initial); + static float ubl_mesh_value(); + #endif + static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr); #elif HAS_WIRED_LCD diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 6c6076cf74..565e6725a7 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -56,12 +56,24 @@ inline float rounded_mesh_value() { return float(rounded - (rounded % 5L)) / 1000; } -static void _lcd_mesh_fine_tune(PGM_P const msg) { +/** + * This screen displays the temporary mesh value and updates it based on encoder + * movement. While this screen is active ubl.fine_tune_mesh sits in a loop getting + * the current value via ubl_mesh_value, moves the Z axis, and updates the mesh + * value until the encoder button is pressed. + * + * - Update the 'mesh_edit_accumulator' from encoder rotation + * - Draw the mesh value (with draw_edit_screen) + * - Draw the graphical overlay, if enabled. + * - Update the 'refresh' state according to the display type + */ +void _lcd_mesh_fine_tune(PGM_P const msg) { + constexpr float mesh_edit_step = 1.0f / 200.0f; ui.defer_status_screen(); if (ubl.encoder_diff) { mesh_edit_accumulator += TERN(IS_TFTGLCD_PANEL, - ubl.encoder_diff * 0.005f / ENCODER_PULSES_PER_STEP, - ubl.encoder_diff > 0 ? 0.005f : -0.005f + ubl.encoder_diff * mesh_edit_step / ENCODER_PULSES_PER_STEP, + ubl.encoder_diff > 0 ? mesh_edit_step : -mesh_edit_step ); ubl.encoder_diff = 0; IF_DISABLED(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT)); @@ -77,29 +89,19 @@ static void _lcd_mesh_fine_tune(PGM_P const msg) { } // -// Called external to the menu system to acquire the result of an edit. +// Init mesh editing and go to the fine tuning screen (ubl.fine_tune_mesh) +// To capture encoder events UBL will also call ui.capture and ui.release. // -float lcd_mesh_edit() { return rounded_mesh_value(); } - -void lcd_mesh_edit_setup(const float &initial) { - TERN_(HAS_GRAPHICAL_TFT, ui.clear_lcd()); +void MarlinUI::ubl_mesh_edit_start(const float &initial) { + TERN_(HAS_GRAPHICAL_TFT, clear_lcd()); mesh_edit_accumulator = initial; - ui.goto_screen([]{ _lcd_mesh_fine_tune(GET_TEXT(MSG_MESH_EDIT_Z)); }); + goto_screen([]{ _lcd_mesh_fine_tune(GET_TEXT(MSG_MESH_EDIT_Z)); }); } -void _lcd_z_offset_edit() { - _lcd_mesh_fine_tune(GET_TEXT(MSG_UBL_Z_OFFSET)); -} - -float lcd_z_offset_edit() { - ui.goto_screen(_lcd_z_offset_edit); - return rounded_mesh_value(); -} - -void lcd_z_offset_edit_setup(const float &initial) { - mesh_edit_accumulator = initial; - ui.goto_screen(_lcd_z_offset_edit); -} +// +// Get the mesh value within a Z adjustment loop (ubl.fine_tune_mesh) +// +float MarlinUI::ubl_mesh_value() { return rounded_mesh_value(); } /** * UBL Build Custom Mesh Command From 2d2291d00eab6159de24eb7ff74001b1d6dd29e4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 24 Mar 2021 05:40:28 -0500 Subject: [PATCH 095/311] More IntelliSense-friendly declarations --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 4 +- Marlin/src/feature/caselight.h | 10 +- Marlin/src/feature/joystick.h | 16 +- Marlin/src/feature/meatpack.cpp | 4 +- Marlin/src/feature/mixing.h | 9 +- Marlin/src/feature/powerloss.h | 40 ++- Marlin/src/feature/tmc_util.h | 16 +- Marlin/src/gcode/bedlevel/G35.cpp | 4 +- Marlin/src/gcode/calibrate/G33.cpp | 4 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 4 +- Marlin/src/gcode/gcode.h | 336 +++++++++++++----- Marlin/src/gcode/queue.h | 14 +- .../lcd/dogm/status_screen_lite_ST7920.cpp | 4 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 8 +- Marlin/src/lcd/dwin/e3v2/dwin.h | 24 +- .../lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 4 +- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 4 +- Marlin/src/lcd/extui/ui_api.cpp | 76 ++-- Marlin/src/lcd/marlinui.cpp | 4 +- Marlin/src/lcd/marlinui.h | 20 +- Marlin/src/lcd/menu/game/game.h | 16 +- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 4 +- Marlin/src/lcd/menu/menu_probe_offset.cpp | 4 +- Marlin/src/libs/nozzle.cpp | 12 +- Marlin/src/module/endstops.h | 12 +- Marlin/src/module/planner.cpp | 4 +- Marlin/src/module/planner.h | 4 +- Marlin/src/module/servo.cpp | 4 +- Marlin/src/module/stepper.cpp | 4 +- Marlin/src/module/temperature.h | 84 +++-- Marlin/src/module/tool_change.h | 8 +- Marlin/src/sd/cardreader.cpp | 4 +- 32 files changed, 562 insertions(+), 203 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 42a3018561..06b91002b8 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -303,7 +303,9 @@ void unified_bed_leveling::G29() { const int8_t p_val = parser.intval('P', -1); const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J'); - TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder); + #if ENABLED(HAS_MULTI_HOTEND) + const uint8_t old_tool_index = active_extruder; + #endif // Check for commands that require the printer to be homed if (may_move) { diff --git a/Marlin/src/feature/caselight.h b/Marlin/src/feature/caselight.h index 25bcb486fa..05385ad0cb 100644 --- a/Marlin/src/feature/caselight.h +++ b/Marlin/src/feature/caselight.h @@ -34,7 +34,9 @@ class CaseLight { public: static bool on; - TERN_(CASELIGHT_USES_BRIGHTNESS, static uint8_t brightness); + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + static uint8_t brightness; + #endif static bool pin_is_pwm() { return TERN0(NEED_CASE_LIGHT_PIN, PWM_PIN(CASE_LIGHT_PIN)); } static bool has_brightness() { return TERN0(CASELIGHT_USES_BRIGHTNESS, TERN(CASE_LIGHT_USE_NEOPIXEL, true, pin_is_pwm())); } @@ -50,8 +52,10 @@ public: static inline void update_brightness() { update(false); } static inline void update_enabled() { update(true); } -private: - TERN_(CASE_LIGHT_IS_COLOR_LED, static LEDColor color); + #if ENABLED(CASE_LIGHT_IS_COLOR_LED) + private: + static LEDColor color; + #endif }; extern CaseLight caselight; diff --git a/Marlin/src/feature/joystick.h b/Marlin/src/feature/joystick.h index e8e218b2f9..d1c4fbd314 100644 --- a/Marlin/src/feature/joystick.h +++ b/Marlin/src/feature/joystick.h @@ -32,11 +32,19 @@ class Joystick { friend class Temperature; private: - TERN_(HAS_JOY_ADC_X, static temp_info_t x); - TERN_(HAS_JOY_ADC_Y, static temp_info_t y); - TERN_(HAS_JOY_ADC_Z, static temp_info_t z); + #if ENABLED(HAS_JOY_ADC_X) + static temp_info_t x; + #endif + #if ENABLED(HAS_JOY_ADC_Y) + static temp_info_t y; + #endif + #if ENABLED(HAS_JOY_ADC_Z) + static temp_info_t z; + #endif public: - TERN_(JOYSTICK_DEBUG, static void report()); + #if ENABLED(JOYSTICK_DEBUG) + static void report(); + #endif static void calculate(xyz_float_t &norm_jog); static void inject_jog_moves(); }; diff --git a/Marlin/src/feature/meatpack.cpp b/Marlin/src/feature/meatpack.cpp index 44567ac482..0742f82350 100644 --- a/Marlin/src/feature/meatpack.cpp +++ b/Marlin/src/feature/meatpack.cpp @@ -57,7 +57,9 @@ uint8_t meatPackLookupTable[16] = { '\0' // Unused. 0b1111 indicates a literal character }; -TERN_(MP_DEBUG, uint8_t chars_decoded = 0); // Log the first 64 bytes after each reset +#if ENABLED(MP_DEBUG) + uint8_t chars_decoded = 0; // Log the first 64 bytes after each reset +#endif void MeatPack::reset_state() { state = 0; diff --git a/Marlin/src/feature/mixing.h b/Marlin/src/feature/mixing.h index 65d1f1bf95..5de039985d 100644 --- a/Marlin/src/feature/mixing.h +++ b/Marlin/src/feature/mixing.h @@ -61,9 +61,6 @@ enum MixTool { #define MAX_VTOOLS TERN(HAS_MIXER_SYNC_CHANNEL, 254, 255) static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must be <= " STRINGIFY(MAX_VTOOLS) "!"); -#define MIXER_BLOCK_FIELD mixer_comp_t b_color[MIXING_STEPPERS] -#define MIXER_POPULATE_BLOCK() mixer.populate_block(block->b_color) -#define MIXER_STEPPER_SETUP() mixer.stepper_setup(current_block->b_color) #define MIXER_STEPPER_LOOP(VAR) for (uint_fast8_t VAR = 0; VAR < MIXING_STEPPERS; VAR++) #if ENABLED(GRADIENT_MIX) @@ -73,9 +70,11 @@ static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must mixer_comp_t color[MIXING_STEPPERS]; // The current gradient color float start_z, end_z; // Region for gradient int8_t start_vtool, end_vtool; // Start and end virtual tools - mixer_perc_t start_mix[MIXING_STEPPERS], // Start and end mixes from those tools + mixer_perc_t start_mix[MIXING_STEPPERS], // Start and end mixes from those tools end_mix[MIXING_STEPPERS]; - TERN_(GRADIENT_VTOOL, int8_t vtool_index); // Use this virtual tool number as index + #if ENABLED(GRADIENT_VTOOL) + int8_t vtool_index; // Use this virtual tool number as index + #endif } gradient_t; #endif diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 12d11b141e..7c09c0f3cf 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -55,22 +55,38 @@ typedef struct { float zraise; // Repeat information - TERN_(GCODE_REPEAT_MARKERS, Repeat stored_repeat); + #if ENABLED(GCODE_REPEAT_MARKERS) + Repeat stored_repeat; + #endif - TERN_(HAS_HOME_OFFSET, xyz_pos_t home_offset); - TERN_(HAS_POSITION_SHIFT, xyz_pos_t position_shift); - TERN_(HAS_MULTI_EXTRUDER, uint8_t active_extruder); + #if ENABLED(HAS_HOME_OFFSET) + xyz_pos_t home_offset; + #endif + #if ENABLED(HAS_POSITION_SHIFT) + xyz_pos_t position_shift; + #endif + #if ENABLED(HAS_MULTI_EXTRUDER) + uint8_t active_extruder; + #endif #if DISABLED(NO_VOLUMETRICS) bool volumetric_enabled; float filament_size[EXTRUDERS]; #endif - TERN_(HAS_HOTEND, celsius_t target_temperature[HOTENDS]); - TERN_(HAS_HEATED_BED, celsius_t target_temperature_bed); - TERN_(HAS_FAN, uint8_t fan_speed[FAN_COUNT]); + #if ENABLED(HAS_HOTEND) + celsius_t target_temperature[HOTENDS]; + #endif + #if ENABLED(HAS_HEATED_BED) + celsius_t target_temperature_bed; + #endif + #if ENABLED(HAS_FAN) + uint8_t fan_speed[FAN_COUNT]; + #endif - TERN_(HAS_LEVELING, float fade); + #if ENABLED(HAS_LEVELING) + float fade; + #endif #if ENABLED(FWRETRACT) float retract[EXTRUDERS], retract_hop; @@ -80,7 +96,9 @@ typedef struct { #if ENABLED(MIXING_EXTRUDER) //uint_fast8_t selected_vtool; //mixer_comp_t color[NR_MIXING_VIRTUAL_TOOLS][MIXING_STEPPERS]; - TERN_(GRADIENT_MIX, gradient_t gradient); + #if ENABLED(GRADIENT_MIX) + gradient_t gradient; + #endif #endif // SD Filename and position @@ -97,7 +115,9 @@ typedef struct { struct { bool dryrun:1; // M111 S8 bool allow_cold_extrusion:1; // M302 P1 - TERN_(HAS_LEVELING, bool leveling:1); + #if ENABLED(HAS_LEVELING) + bool leveling:1; + #endif } flag; uint8_t valid_foot; diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index b21b89f68b..1767313ba2 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -70,9 +70,15 @@ class TMCStorage { } struct { - TERN_(HAS_STEALTHCHOP, bool stealthChop_enabled = false); - TERN_(HYBRID_THRESHOLD, uint8_t hybrid_thrs = 0); - TERN_(USE_SENSORLESS, int16_t homing_thrs = 0); + #if ENABLED(HAS_STEALTHCHOP) + bool stealthChop_enabled = false; + #endif + #if ENABLED(HYBRID_THRESHOLD) + uint8_t hybrid_thrs = 0; + #endif + #if ENABLED(USE_SENSORLESS) + int16_t homing_thrs = 0; + #endif } stored; }; @@ -363,7 +369,9 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z struct slow_homing_t { xy_ulong_t acceleration; - TERN_(HAS_CLASSIC_JERK, xy_float_t jerk_xy); + #if ENABLED(HAS_CLASSIC_JERK) + xy_float_t jerk_xy; + #endif }; #endif diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 88f02e6de2..0fab747618 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -72,7 +72,9 @@ void GcodeSuite::G35() { // Disable the leveling matrix before auto-aligning #if HAS_LEVELING - TERN_(RESTORE_LEVELING_AFTER_G35, const bool leveling_was_active = planner.leveling_active); + #if ENABLED(RESTORE_LEVELING_AFTER_G35) + const bool leveling_was_active = planner.leveling_active; + #endif set_bed_leveling_enabled(false); #endif diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 5530bc7089..902711397d 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -63,7 +63,9 @@ enum CalEnum : char { // the 7 main calibration points - #define LOOP_CAL_RAD(VAR) LOOP_CAL_PT(VAR, __A, _7P_STEP) #define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP) -TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder); +#if ENABLED(HAS_MULTI_HOTEND) + const uint8_t old_tool_index = active_extruder; +#endif float lcd_probe_pt(const xy_pos_t &xy); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index bee6aaedeb..d2075fedce 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -130,7 +130,9 @@ void GcodeSuite::G34() { // Disable the leveling matrix before auto-aligning #if HAS_LEVELING - TERN_(RESTORE_LEVELING_AFTER_G34, const bool leveling_was_active = planner.leveling_active); + #if ENABLED(RESTORE_LEVELING_AFTER_G34) + const bool leveling_was_active = planner.leveling_active; + #endif set_bed_leveling_enabled(false); #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 52570ff83f..7ea2489584 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -418,24 +418,34 @@ public: private: - TERN_(MARLIN_DEV_MODE, static void D(const int16_t dcode)); + #if ENABLED(MARLIN_DEV_MODE) + static void D(const int16_t dcode); + #endif static void G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move=false)); - TERN_(ARC_SUPPORT, static void G2_G3(const bool clockwise)); + #if ENABLED(ARC_SUPPORT) + static void G2_G3(const bool clockwise); + #endif static void G4(); - TERN_(BEZIER_CURVE_SUPPORT, static void G5()); + #if ENABLED(BEZIER_CURVE_SUPPORT) + static void G5(); + #endif - TERN_(DIRECT_STEPPING, static void G6()); + #if ENABLED(DIRECT_STEPPING) + static void G6(); + #endif #if ENABLED(FWRETRACT) static void G10(); static void G11(); #endif - TERN_(NOZZLE_CLEAN_FEATURE, static void G12()); + #if ENABLED(NOZZLE_CLEAN_FEATURE) + static void G12(); + #endif #if ENABLED(CNC_WORKSPACE_PLANES) static void G17(); @@ -448,9 +458,13 @@ private: static void G21(); #endif - TERN_(G26_MESH_VALIDATION, static void G26()); + #if ENABLED(G26_MESH_VALIDATION) + static void G26(); + #endif - TERN_(NOZZLE_PARK_FEATURE, static void G27()); + #if ENABLED(NOZZLE_PARK_FEATURE) + static void G27(); + #endif static void G28(); @@ -474,19 +488,29 @@ private: #endif #endif - TERN_(DELTA_AUTO_CALIBRATION, static void G33()); + #if ENABLED(DELTA_AUTO_CALIBRATION) + static void G33(); + #endif #if ANY(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION) static void G34(); #endif - TERN_(Z_STEPPER_AUTO_ALIGN, static void M422()); + #if ENABLED(Z_STEPPER_AUTO_ALIGN) + static void M422(); + #endif - TERN_(ASSISTED_TRAMMING, static void G35()); + #if ENABLED(ASSISTED_TRAMMING) + static void G35(); + #endif - TERN_(G38_PROBE_TARGET, static void G38(const int8_t subcode)); + #if ENABLED(G38_PROBE_TARGET) + static void G38(const int8_t subcode); + #endif - TERN_(HAS_MESH, static void G42()); + #if ENABLED(HAS_MESH) + static void G42(); + #endif #if ENABLED(CNC_COORDINATE_SYSTEMS) static void G53(); @@ -498,20 +522,28 @@ private: static void G59(); #endif - TERN_(PROBE_TEMP_COMPENSATION, static void G76()); + #if ENABLED(PROBE_TEMP_COMPENSATION) + static void G76(); + #endif #if SAVED_POSITIONS static void G60(); static void G61(); #endif - TERN_(GCODE_MOTION_MODES, static void G80()); + #if ENABLED(GCODE_MOTION_MODES) + static void G80(); + #endif static void G92(); - TERN_(CALIBRATION_GCODE, static void G425()); + #if ENABLED(CALIBRATION_GCODE) + static void G425(); + #endif - TERN_(HAS_RESUME_CONTINUE, static void M0_M1()); + #if ENABLED(HAS_RESUME_CONTINUE) + static void M0_M1(); + #endif #if HAS_CUTTER static void M3_M4(const bool is_M4); @@ -519,14 +551,22 @@ private: #endif #if ENABLED(COOLANT_CONTROL) - TERN_(COOLANT_MIST, static void M7()); - TERN_(COOLANT_FLOOD, static void M8()); + #if ENABLED(COOLANT_MIST) + static void M7(); + #endif + #if ENABLED(COOLANT_FLOOD) + static void M8(); + #endif static void M9(); #endif - TERN_(EXTERNAL_CLOSED_LOOP_CONTROLLER, static void M12()); + #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) + static void M12(); + #endif - TERN_(EXPECTED_PRINTER_CHECK, static void M16()); + #if ENABLED(EXPECTED_PRINTER_CHECK) + static void M16(); + #endif static void M17(); @@ -549,27 +589,43 @@ private: static void M31(); #if ENABLED(SDSUPPORT) - TERN_(HAS_MEDIA_SUBCALLS, static void M32()); - TERN_(LONG_FILENAME_HOST_SUPPORT, static void M33()); + #if ENABLED(HAS_MEDIA_SUBCALLS) + static void M32(); + #endif + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + static void M33(); + #endif #if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE) static void M34(); #endif #endif - TERN_(DIRECT_PIN_CONTROL, static void M42()); - TERN_(PINS_DEBUGGING, static void M43()); + #if ENABLED(DIRECT_PIN_CONTROL) + static void M42(); + #endif + #if ENABLED(PINS_DEBUGGING) + static void M43(); + #endif - TERN_(Z_MIN_PROBE_REPEATABILITY_TEST, static void M48()); + #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) + static void M48(); + #endif - TERN_(LCD_SET_PROGRESS_MANUALLY, static void M73()); + #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + static void M73(); + #endif static void M75(); static void M76(); static void M77(); - TERN_(PRINTCOUNTER, static void M78()); + #if ENABLED(PRINTCOUNTER) + static void M78(); + #endif - TERN_(PSU_CONTROL, static void M80()); + #if ENABLED(PSU_CONTROL) + static void M80(); + #endif static void M81(); static void M82(); @@ -577,7 +633,9 @@ private: static void M85(); static void M92(); - TERN_(M100_FREE_MEMORY_WATCHER, static void M100()); + #if ENABLED(M100_FREE_MEMORY_WATCHER) + static void M100(); + #endif #if EXTRUDERS static void M104(); @@ -595,13 +653,17 @@ private: static void M108(); static void M112(); static void M410(); - TERN_(HOST_PROMPT_SUPPORT, static void M876()); + #if ENABLED(HOST_PROMPT_SUPPORT) + static void M876(); + #endif #endif static void M110(); static void M111(); - TERN_(HOST_KEEPALIVE_FEATURE, static void M113()); + #if ENABLED(HOST_KEEPALIVE_FEATURE) + static void M113(); + #endif static void M114(); static void M115(); @@ -611,7 +673,9 @@ private: static void M120(); static void M121(); - TERN_(PARK_HEAD_ON_PAUSE, static void M125()); + #if ENABLED(PARK_HEAD_ON_PAUSE) + static void M125(); + #endif #if ENABLED(BARICUDA) #if HAS_HEATER_1 @@ -643,9 +707,13 @@ private: static void M145(); #endif - TERN_(TEMPERATURE_UNITS_SUPPORT, static void M149()); + #if ENABLED(TEMPERATURE_UNITS_SUPPORT) + static void M149(); + #endif - TERN_(HAS_COLOR_LEDS, static void M150()); + #if ENABLED(HAS_COLOR_LEDS) + static void M150(); + #endif #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR) static void M155(); @@ -654,8 +722,12 @@ private: #if ENABLED(MIXING_EXTRUDER) static void M163(); static void M164(); - TERN_(DIRECT_MIXING_IN_G1, static void M165()); - TERN_(GRADIENT_MIX, static void M166()); + #if ENABLED(DIRECT_MIXING_IN_G1) + static void M165(); + #endif + #if ENABLED(GRADIENT_MIX) + static void M166(); + #endif #endif static void M200(); @@ -669,19 +741,27 @@ private: static void M204(); static void M205(); - TERN_(HAS_M206_COMMAND, static void M206()); + #if ENABLED(HAS_M206_COMMAND) + static void M206(); + #endif #if ENABLED(FWRETRACT) static void M207(); static void M208(); - TERN_(FWRETRACT_AUTORETRACT, static void M209()); + #if ENABLED(FWRETRACT_AUTORETRACT) + static void M209(); + #endif #endif static void M211(); - TERN_(HAS_MULTI_EXTRUDER, static void M217()); + #if ENABLED(HAS_MULTI_EXTRUDER) + static void M217(); + #endif - TERN_(HAS_HOTEND_OFFSET, static void M218()); + #if ENABLED(HAS_HOTEND_OFFSET) + static void M218(); + #endif static void M220(); @@ -689,11 +769,17 @@ private: static void M221(); #endif - TERN_(DIRECT_PIN_CONTROL, static void M226()); + #if ENABLED(DIRECT_PIN_CONTROL) + static void M226(); + #endif - TERN_(PHOTO_GCODE, static void M240()); + #if ENABLED(PHOTO_GCODE) + static void M240(); + #endif - TERN_(HAS_LCD_CONTRAST, static void M250()); + #if ENABLED(HAS_LCD_CONTRAST) + static void M250(); + #endif #if ENABLED(EXPERIMENTAL_I2CBUS) static void M260(); @@ -702,33 +788,55 @@ private: #if HAS_SERVOS static void M280(); - TERN_(EDITABLE_SERVO_ANGLES, static void M281()); + #if ENABLED(EDITABLE_SERVO_ANGLES) + static void M281(); + #endif #endif - TERN_(BABYSTEPPING, static void M290()); + #if ENABLED(BABYSTEPPING) + static void M290(); + #endif - TERN_(HAS_BUZZER, static void M300()); + #if ENABLED(HAS_BUZZER) + static void M300(); + #endif - TERN_(PIDTEMP, static void M301()); + #if ENABLED(PIDTEMP) + static void M301(); + #endif - TERN_(PREVENT_COLD_EXTRUSION, static void M302()); + #if ENABLED(PREVENT_COLD_EXTRUSION) + static void M302(); + #endif - TERN_(HAS_PID_HEATING, static void M303()); + #if ENABLED(HAS_PID_HEATING) + static void M303(); + #endif - TERN_(PIDTEMPBED, static void M304()); + #if ENABLED(PIDTEMPBED) + static void M304(); + #endif - TERN_(HAS_USER_THERMISTORS, static void M305()); + #if ENABLED(HAS_USER_THERMISTORS) + static void M305(); + #endif - TERN_(PIDTEMPCHAMBER, static void M309()); + #if ENABLED(PIDTEMPCHAMBER) + static void M309(); + #endif #if HAS_MICROSTEPS static void M350(); static void M351(); #endif - TERN_(CASE_LIGHT_ENABLE, static void M355()); + #if ENABLED(CASE_LIGHT_ENABLE) + static void M355(); + #endif - TERN_(REPETIER_GCODE_M360, static void M360()); + #if ENABLED(REPETIER_GCODE_M360) + static void M360(); + #endif #if ENABLED(MORGAN_SCARA) static bool M360(); @@ -750,7 +858,9 @@ private: static void M402(); #endif - TERN_(HAS_PRUSA_MMU2, static void M403()); + #if ENABLED(HAS_PRUSA_MMU2) + static void M403(); + #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) static void M404(); @@ -759,22 +869,34 @@ private: static void M407(); #endif - TERN_(HAS_FILAMENT_SENSOR, static void M412()); + #if ENABLED(HAS_FILAMENT_SENSOR) + static void M412(); + #endif - TERN_(HAS_MULTI_LANGUAGE, static void M414()); + #if ENABLED(HAS_MULTI_LANGUAGE) + static void M414(); + #endif #if HAS_LEVELING static void M420(); static void M421(); #endif - TERN_(BACKLASH_GCODE, static void M425()); + #if ENABLED(BACKLASH_GCODE) + static void M425(); + #endif - TERN_(HAS_M206_COMMAND, static void M428()); + #if ENABLED(HAS_M206_COMMAND) + static void M428(); + #endif - TERN_(HAS_POWER_MONITOR, static void M430()); + #if ENABLED(HAS_POWER_MONITOR) + static void M430(); + #endif - TERN_(CANCEL_OBJECTS, static void M486()); + #if ENABLED(CANCEL_OBJECTS) + static void M486(); + #endif static void M500(); static void M501(); @@ -782,17 +904,27 @@ private: #if DISABLED(DISABLE_M503) static void M503(); #endif - TERN_(EEPROM_SETTINGS, static void M504()); + #if ENABLED(EEPROM_SETTINGS) + static void M504(); + #endif #if ENABLED(PASSWORD_FEATURE) static void M510(); - TERN_(PASSWORD_UNLOCK_GCODE, static void M511()); - TERN_(PASSWORD_CHANGE_GCODE, static void M512()); + #if ENABLED(PASSWORD_UNLOCK_GCODE) + static void M511(); + #endif + #if ENABLED(PASSWORD_CHANGE_GCODE) + static void M512(); + #endif #endif - TERN_(SDSUPPORT, static void M524()); + #if ENABLED(SDSUPPORT) + static void M524(); + #endif - TERN_(SD_ABORT_ON_ENDSTOP_HIT, static void M540()); + #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) + static void M540(); + #endif #if HAS_ETHERNET static void M552(); @@ -800,16 +932,22 @@ private: static void M554(); #endif - TERN_(BAUD_RATE_GCODE, static void M575()); + #if ENABLED(BAUD_RATE_GCODE) + static void M575(); + #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) static void M600(); static void M603(); #endif - TERN_(HAS_DUPLICATION_MODE, static void M605()); + #if ENABLED(HAS_DUPLICATION_MODE) + static void M605(); + #endif - TERN_(IS_KINEMATIC, static void M665()); + #if ENABLED(IS_KINEMATIC) + static void M665(); + #endif #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS static void M666(); @@ -824,13 +962,21 @@ private: static void M702(); #endif - TERN_(GCODE_REPEAT_MARKERS, static void M808()); + #if ENABLED(GCODE_REPEAT_MARKERS) + static void M808(); + #endif - TERN_(GCODE_MACROS, static void M810_819()); + #if ENABLED(GCODE_MACROS) + static void M810_819(); + #endif - TERN_(HAS_BED_PROBE, static void M851()); + #if ENABLED(HAS_BED_PROBE) + static void M851(); + #endif - TERN_(SKEW_CORRECTION_GCODE, static void M852()); + #if ENABLED(SKEW_CORRECTION_GCODE) + static void M852(); + #endif #if ENABLED(I2C_POSITION_ENCODERS) FORCE_INLINE static void M860() { I2CPEM.M860(); } @@ -850,18 +996,26 @@ private: static void M871(); #endif - TERN_(LIN_ADVANCE, static void M900()); + #if ENABLED(LIN_ADVANCE) + static void M900(); + #endif #if HAS_TRINAMIC_CONFIG static void M122(); static void M906(); - TERN_(HAS_STEALTHCHOP, static void M569()); + #if ENABLED(HAS_STEALTHCHOP) + static void M569(); + #endif #if ENABLED(MONITOR_DRIVER_STATUS) static void M911(); static void M912(); #endif - TERN_(HYBRID_THRESHOLD, static void M913()); - TERN_(USE_SENSORLESS, static void M914()); + #if ENABLED(HYBRID_THRESHOLD) + static void M913(); + #endif + #if ENABLED(USE_SENSORLESS) + static void M914(); + #endif #endif #if HAS_L64XX @@ -883,18 +1037,26 @@ private: #endif #endif - TERN_(SDSUPPORT, static void M928()); + #if ENABLED(SDSUPPORT) + static void M928(); + #endif - TERN_(MAGNETIC_PARKING_EXTRUDER, static void M951()); + #if ENABLED(MAGNETIC_PARKING_EXTRUDER) + static void M951(); + #endif - TERN_(TOUCH_SCREEN_CALIBRATION, static void M995()); + #if ENABLED(TOUCH_SCREEN_CALIBRATION) + static void M995(); + #endif #if BOTH(HAS_SPI_FLASH, SDSUPPORT) static void M993(); static void M994(); #endif - TERN_(PLATFORM_M997_SUPPORT, static void M997()); + #if ENABLED(PLATFORM_M997_SUPPORT) + static void M997(); + #endif static void M999(); @@ -903,11 +1065,17 @@ private: static void M1000(); #endif - TERN_(SDSUPPORT, static void M1001()); + #if ENABLED(SDSUPPORT) + static void M1001(); + #endif - TERN_(MAX7219_GCODE, static void M7219()); + #if ENABLED(MAX7219_GCODE) + static void M7219(); + #endif - TERN_(CONTROLLER_FAN_EDITABLE, static void M710()); + #if ENABLED(CONTROLLER_FAN_EDITABLE) + static void M710(); + #endif static void T(const int8_t tool_index); diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 8e87d114eb..4d3ccb364e 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -40,9 +40,9 @@ public: * M110 N sets the current line number. */ long last_N; - int count; //!< Number of characters read in the current line of serial input - char line_buffer[MAX_CMD_SIZE]; //!< The current line accumulator - uint8_t input_state; //!< The input state + int count; //!< Number of characters read in the current line of serial input + char line_buffer[MAX_CMD_SIZE]; //!< The current line accumulator + uint8_t input_state; //!< The input state }; static SerialState serial_state[NUM_SERIAL]; //!< Serial states for each serial port @@ -57,9 +57,11 @@ public: * command and hands off execution to individual handler functions. */ struct CommandLine { - char buffer[MAX_CMD_SIZE]; //!< The command buffer - bool skip_ok; //!< Skip sending ok when command is processed? - TERN_(HAS_MULTI_SERIAL, serial_index_t port); //!< Serial port the command was received on + char buffer[MAX_CMD_SIZE]; //!< The command buffer + bool skip_ok; //!< Skip sending ok when command is processed? + #if ENABLED(HAS_MULTI_SERIAL) + serial_index_t port; //!< Serial port the command was received on + #endif }; /** diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index dcb65f676d..a2dfb74a57 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -536,7 +536,9 @@ void ST7920_Lite_Status_Screen::draw_heat_icon(const bool whichIcon, const bool static struct { bool E1_show_target : 1; bool E2_show_target : 1; - TERN_(HAS_HEATED_BED, bool bed_show_target : 1); + #if ENABLED(HAS_HEATED_BED) + bool bed_show_target : 1; + #endif } display_state = { true, true, TERN_(HAS_HEATED_BED, true) }; diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 0e9b93525d..d543ff0508 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -180,8 +180,12 @@ static uint8_t _card_percent = 0; static uint16_t _remain_time = 0; #if ENABLED(PAUSE_HEAT) - TERN_(HAS_HOTEND, uint16_t resume_hotend_temp = 0); - TERN_(HAS_HEATED_BED, uint16_t resume_bed_temp = 0); + #if ENABLED(HAS_HOTEND) + uint16_t resume_hotend_temp = 0; + #endif + #if ENABLED(HAS_HEATED_BED) + uint16_t resume_bed_temp = 0; + #endif #endif #if HAS_ZOFFSET_ITEM diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index 9e0cda86c2..dd2d1cbc01 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -234,9 +234,15 @@ extern char print_filename[16]; extern millis_t dwin_heat_time; typedef struct { - TERN_(HAS_HOTEND, celsius_t E_Temp = 0); - TERN_(HAS_HEATED_BED, celsius_t Bed_Temp = 0); - TERN_(HAS_FAN, int16_t Fan_speed = 0); + #if ENABLED(HAS_HOTEND) + celsius_t E_Temp = 0; + #endif + #if ENABLED(HAS_HEATED_BED) + celsius_t Bed_Temp = 0; + #endif + #if ENABLED(HAS_FAN) + int16_t Fan_speed = 0; + #endif int16_t print_speed = 100; float Max_Feedspeed = 0; float Max_Acceleration = 0; @@ -312,9 +318,15 @@ void HMI_Move_E(); void HMI_Zoffset(); -TERN_(HAS_HOTEND, void HMI_ETemp()); -TERN_(HAS_HEATED_BED, void HMI_BedTemp()); -TERN_(HAS_FAN, void HMI_FanSpeed()); +#if ENABLED(HAS_HOTEND) + void HMI_ETemp(); +#endif +#if ENABLED(HAS_HEATED_BED) + void HMI_BedTemp(); +#endif +#if ENABLED(HAS_FAN) + void HMI_FanSpeed(); +#endif void HMI_PrintSpeed(); diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index 473fcb954c..a585ef670a 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -624,7 +624,9 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr DEBUG_ECHOLNPGM("HandlePreheat"); uint8_t e_temp = 0; - TERN_(HAS_HEATED_BED, uint8_t bed_temp = 0); + #if ENABLED(HAS_HEATED_BED) + uint8_t bed_temp = 0; + #endif const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); switch (preheat_option) { default: 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 2cc6d19cc5..e9e501ae5f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -49,7 +49,9 @@ static lv_obj_t *labelPause, *labelStop, *labelOperat; static lv_obj_t *bar1, *bar1ValueText; static lv_obj_t *buttonPause, *buttonOperat, *buttonStop; -TERN_(HAS_MULTI_EXTRUDER, static lv_obj_t *labelExt2); +#if ENABLED(HAS_MULTI_EXTRUDER) + static lv_obj_t *labelExt2; +#endif #if HAS_HEATED_BED static lv_obj_t* labelBed; diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 9e5e0b6a62..cfd48e5dd9 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -103,8 +103,12 @@ namespace ExtUI { static struct { uint8_t printer_killed : 1; - TERN_(JOYSTICK, uint8_t jogging : 1); - TERN_(SDSUPPORT, uint8_t was_sd_printing : 1); + #if ENABLED(JOYSTICK) + uint8_t jogging : 1; + #endif + #if ENABLED(SDSUPPORT) + uint8_t was_sd_printing : 1; + #endif } flags; #ifdef __SAM3X8E__ @@ -175,8 +179,12 @@ namespace ExtUI { #if HAS_HEATED_BED case BED: thermalManager.reset_bed_idle_timer(); return; #endif - TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return); // Chamber has no idle timer - TERN_(HAS_COOLER, case COOLER: return); // Cooler has no idle timer + #if ENABLED(HAS_HEATED_CHAMBER) + case CHAMBER: return; // Chamber has no idle timer + #endif + #if ENABLED(HAS_COOLER) + case COOLER: return; // Cooler has no idle timer + #endif default: TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0)); break; @@ -234,8 +242,12 @@ namespace ExtUI { bool isHeaterIdle(const heater_t heater) { #if HEATER_IDLE_HANDLER switch (heater) { - TERN_(HAS_HEATED_BED, case BED: return thermalManager.heater_idle[thermalManager.IDLE_INDEX_BED].timed_out); - TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return false); // Chamber has no idle timer + #if ENABLED(HAS_HEATED_BED) + case BED: return thermalManager.heater_idle[thermalManager.IDLE_INDEX_BED].timed_out; + #endif + #if ENABLED(HAS_HEATED_CHAMBER) + case CHAMBER: return false; // Chamber has no idle timer + #endif default: return TERN0(HAS_HOTEND, thermalManager.heater_idle[heater - H0].timed_out); } @@ -253,8 +265,12 @@ namespace ExtUI { float getActualTemp_celsius(const heater_t heater) { switch (heater) { - TERN_(HAS_HEATED_BED, case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed())); - TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degChamber())); + #if ENABLED(HAS_HEATED_BED) + case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed()); + #endif + #if ENABLED(HAS_HEATED_CHAMBER) + case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degChamber()); + #endif default: return GET_TEMP_ADJUSTMENT(thermalManager.degHotend(heater - H0)); } } @@ -265,8 +281,12 @@ namespace ExtUI { float getTargetTemp_celsius(const heater_t heater) { switch (heater) { - TERN_(HAS_HEATED_BED, case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed())); - TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetChamber())); + #if ENABLED(HAS_HEATED_BED) + case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed()); + #endif + #if ENABLED(HAS_HEATED_CHAMBER) + case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetChamber()); + #endif default: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(heater - H0)); } } @@ -294,13 +314,13 @@ namespace ExtUI { } float getAxisPosition_mm(const axis_t axis) { - return TERN_(JOYSTICK, flags.jogging ? destination[axis] :) current_position[axis]; + return TERN0(JOYSTICK, flags.jogging) ? destination[axis] : current_position[axis]; } float getAxisPosition_mm(const extruder_t extruder) { const extruder_t old_tool = getActiveTool(); setActiveTool(extruder, true); - const float epos = TERN_(JOYSTICK, flags.jogging ? destination.e :) current_position.e; + const float epos = TERN0(JOYSTICK, flags.jogging) ? destination.e : current_position.e; setActiveTool(old_tool, true); return epos; } @@ -491,14 +511,30 @@ namespace ExtUI { int getTMCBumpSensitivity(const axis_t axis) { switch (axis) { - TERN_(X_SENSORLESS, case X: return stepperX.homing_threshold()); - TERN_(X2_SENSORLESS, case X2: return stepperX2.homing_threshold()); - TERN_(Y_SENSORLESS, case Y: return stepperY.homing_threshold()); - TERN_(Y2_SENSORLESS, case Y2: return stepperY2.homing_threshold()); - TERN_(Z_SENSORLESS, case Z: return stepperZ.homing_threshold()); - TERN_(Z2_SENSORLESS, case Z2: return stepperZ2.homing_threshold()); - TERN_(Z3_SENSORLESS, case Z3: return stepperZ3.homing_threshold()); - TERN_(Z4_SENSORLESS, case Z4: return stepperZ4.homing_threshold()); + #if ENABLED(X_SENSORLESS) + case X: return stepperX.homing_threshold(); + #endif + #if ENABLED(X2_SENSORLESS) + case X2: return stepperX2.homing_threshold(); + #endif + #if ENABLED(Y_SENSORLESS) + case Y: return stepperY.homing_threshold(); + #endif + #if ENABLED(Y2_SENSORLESS) + case Y2: return stepperY2.homing_threshold(); + #endif + #if ENABLED(Z_SENSORLESS) + case Z: return stepperZ.homing_threshold(); + #endif + #if ENABLED(Z2_SENSORLESS) + case Z2: return stepperZ2.homing_threshold(); + #endif + #if ENABLED(Z3_SENSORLESS) + case Z3: return stepperZ3.homing_threshold(); + #endif + #if ENABLED(Z4_SENSORLESS) + case Z4: return stepperZ4.homing_threshold(); + #endif default: return 0; } } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 88566713a4..0be30efad8 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -688,7 +688,9 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { xyze_pos_t ManualMove::all_axes_destination = { 0 }; bool ManualMove::processing = false; #endif - TERN_(MULTI_MANUAL, int8_t ManualMove::e_index = 0); + #if ENABLED(MULTI_MANUAL) + int8_t ManualMove::e_index = 0; + #endif AxisEnum ManualMove::axis = NO_AXIS; /** diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index a18a3384af..490d78401e 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -105,9 +105,15 @@ #if PREHEAT_COUNT typedef struct { - TERN_(HAS_HOTEND, celsius_t hotend_temp); - TERN_(HAS_HEATED_BED, celsius_t bed_temp ); - TERN_(HAS_FAN, uint16_t fan_speed ); + #if ENABLED(HAS_HOTEND) + celsius_t hotend_temp; + #endif + #if ENABLED(HAS_HEATED_BED) + celsius_t bed_temp; + #endif + #if ENABLED(HAS_FAN) + uint16_t fan_speed; + #endif } preheat_t; #endif @@ -123,10 +129,14 @@ static int8_t constexpr e_index = 0; #endif static millis_t start_time; - TERN_(IS_KINEMATIC, static xyze_pos_t all_axes_destination); + #if ENABLED(IS_KINEMATIC) + static xyze_pos_t all_axes_destination; + #endif public: static float menu_scale; - TERN_(IS_KINEMATIC, static float offset); + #if ENABLED(IS_KINEMATIC) + static float offset; + #endif template void set_destination(const T& dest) { #if IS_KINEMATIC diff --git a/Marlin/src/lcd/menu/game/game.h b/Marlin/src/lcd/menu/game/game.h index cba79e4f28..999aa78100 100644 --- a/Marlin/src/lcd/menu/game/game.h +++ b/Marlin/src/lcd/menu/game/game.h @@ -53,10 +53,18 @@ // Pool game data to save SRAM union MarlinGameData { - TERN_(MARLIN_BRICKOUT, brickout_data_t brickout); - TERN_(MARLIN_INVADERS, invaders_data_t invaders); - TERN_(MARLIN_SNAKE, snake_data_t snake); - TERN_(MARLIN_MAZE, maze_data_t maze); + #if ENABLED(MARLIN_BRICKOUT) + brickout_data_t brickout; + #endif + #if ENABLED(MARLIN_INVADERS) + invaders_data_t invaders; + #endif + #if ENABLED(MARLIN_SNAKE) + snake_data_t snake; + #endif + #if ENABLED(MARLIN_MAZE) + maze_data_t maze; + #endif }; extern MarlinGameData marlin_game_data; diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index a86ae74fce..ef9f2246c2 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -119,7 +119,9 @@ void lcd_delta_settings() { } void menu_delta_calibrate() { - TERN_(DELTA_CALIBRATION_MENU, const bool all_homed = all_axes_homed()); // Acquire ahead of loop + #if ENABLED(DELTA_CALIBRATION_MENU) + const bool all_homed = all_axes_homed(); // Acquire ahead of loop + #endif START_MENU(); BACK_ITEM(MSG_MAIN); diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index 3b3fa0fd2a..1d62ada327 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -42,7 +42,9 @@ // Global storage float z_offset_backup, calculated_z_offset, z_offset_ref; -TERN_(HAS_LEVELING, bool leveling_was_active); +#if ENABLED(HAS_LEVELING) + bool leveling_was_active; +#endif inline void z_clearance_move() { do_z_clearance( diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 4277e8d8d0..c56f45c70b 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -46,7 +46,9 @@ Nozzle nozzle; * @param strokes number of strokes to execute */ void Nozzle::stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes) { - TERN_(NOZZLE_CLEAN_GOBACK, const xyz_pos_t oldpos = current_position); + #if ENABLED(NOZZLE_CLEAN_GOBACK) + const xyz_pos_t oldpos = current_position; + #endif // Move to the starting point #if ENABLED(NOZZLE_CLEAN_NO_Z) @@ -86,7 +88,9 @@ Nozzle nozzle; const xy_pos_t diff = end - start; if (!diff.x || !diff.y) return; - TERN_(NOZZLE_CLEAN_GOBACK, const xyz_pos_t back = current_position); + #if ENABLED(NOZZLE_CLEAN_GOBACK) + const xyz_pos_t back = current_position; + #endif #if ENABLED(NOZZLE_CLEAN_NO_Z) do_blocking_move_to_xy(start); @@ -129,7 +133,9 @@ Nozzle nozzle; void Nozzle::circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const float &radius) { if (strokes == 0) return; - TERN_(NOZZLE_CLEAN_GOBACK, const xyz_pos_t back = current_position); + #if ENABLED(NOZZLE_CLEAN_GOBACK) + const xyz_pos_t back = current_position; + #endif TERN(NOZZLE_CLEAN_NO_Z, do_blocking_move_to_xy, do_blocking_move_to)(start); LOOP_L_N(s, strokes) diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index c0cc9cdb8e..13e814aa1f 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -46,9 +46,15 @@ class Endstops { public: #if HAS_EXTRA_ENDSTOPS typedef uint16_t esbits_t; - TERN_(X_DUAL_ENDSTOPS, static float x2_endstop_adj); - TERN_(Y_DUAL_ENDSTOPS, static float y2_endstop_adj); - TERN_(Z_MULTI_ENDSTOPS, static float z2_endstop_adj); + #if ENABLED(X_DUAL_ENDSTOPS) + static float x2_endstop_adj; + #endif + #if ENABLED(Y_DUAL_ENDSTOPS) + static float y2_endstop_adj; + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) + static float z2_endstop_adj; + #endif #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 static float z3_endstop_adj; #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 8c320925be..84c93e5296 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2019,9 +2019,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Bail if this is a zero-length block if (block->step_event_count < MIN_STEPS_PER_SEGMENT) return false; - #if ENABLED(MIXING_EXTRUDER) - MIXER_POPULATE_BLOCK(); - #endif + TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color)) TERN_(HAS_CUTTER, block->cutter_power = cutter.power); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 769967d4a6..24c814e851 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -170,7 +170,9 @@ typedef struct block_t { static constexpr uint8_t extruder = 0; #endif - TERN_(MIXING_EXTRUDER, MIXER_BLOCK_FIELD); // Normalized color for the mixing steppers + #if ENABLED(MIXING_EXTRUDER) + mixer_comp_t b_color[MIXING_STEPPERS]; // Normalized color for the mixing steppers + #endif // Settings for the trapezoid generator uint32_t accelerate_until, // The index of the step event on which to stop acceleration diff --git a/Marlin/src/module/servo.cpp b/Marlin/src/module/servo.cpp index 27e5a2af2e..9b71dd390f 100644 --- a/Marlin/src/module/servo.cpp +++ b/Marlin/src/module/servo.cpp @@ -32,7 +32,9 @@ HAL_SERVO_LIB servo[NUM_SERVOS]; -TERN_(EDITABLE_SERVO_ANGLES, uint16_t servo_angles[NUM_SERVOS][2]); +#if ENABLED(EDITABLE_SERVO_ANGLES) + uint16_t servo_angles[NUM_SERVOS][2]; +#endif void servo_init() { #if NUM_SERVOS >= 1 && HAS_SERVO_0 diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 466f4f333a..77fa6539bc 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2130,9 +2130,7 @@ uint32_t Stepper::block_phase_isr() { accelerate_until = current_block->accelerate_until << oversampling; decelerate_after = current_block->decelerate_after << oversampling; - #if ENABLED(MIXING_EXTRUDER) - MIXER_STEPPER_SETUP(); - #endif + TERN_(MIXING_EXTRUDER, mixer.stepper_setup(current_block->b_color)) TERN_(HAS_MULTI_EXTRUDER, stepper_extruder = current_block->extruder); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c9e3575257..8092f1f7e2 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -326,14 +326,28 @@ class Temperature { static const celsius_t hotend_maxtemp[HOTENDS]; FORCE_INLINE static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif - TERN_(HAS_HEATED_BED, static bed_info_t temp_bed); - TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe); - TERN_(HAS_TEMP_CHAMBER, static chamber_info_t temp_chamber); - TERN_(HAS_TEMP_COOLER, static cooler_info_t temp_cooler); + #if ENABLED(HAS_HEATED_BED) + static bed_info_t temp_bed; + #endif + #if ENABLED(HAS_TEMP_PROBE) + static probe_info_t temp_probe; + #endif + #if ENABLED(HAS_TEMP_CHAMBER) + static chamber_info_t temp_chamber; + #endif + #if ENABLED(HAS_TEMP_COOLER) + static cooler_info_t temp_cooler; + #endif - TERN_(AUTO_POWER_E_FANS, static uint8_t autofan_speed[HOTENDS]); - TERN_(AUTO_POWER_CHAMBER_FAN, static uint8_t chamberfan_speed); - TERN_(AUTO_POWER_COOLER_FAN, static uint8_t coolerfan_speed); + #if ENABLED(AUTO_POWER_E_FANS) + static uint8_t autofan_speed[HOTENDS]; + #endif + #if ENABLED(AUTO_POWER_CHAMBER_FAN) + static uint8_t chamberfan_speed; + #endif + #if ENABLED(AUTO_POWER_COOLER_FAN) + static uint8_t coolerfan_speed; + #endif #if ENABLED(FAN_SOFT_PWM) static uint8_t soft_pwm_amount_fan[FAN_COUNT], @@ -403,11 +417,15 @@ class Temperature { private: - TERN_(EARLY_WATCHDOG, static bool inited); // If temperature controller is running + #if ENABLED(EARLY_WATCHDOG) + static bool inited; // If temperature controller is running + #endif static volatile bool raw_temps_ready; - TERN_(WATCH_HOTENDS, static hotend_watch_t watch_hotend[HOTENDS]); + #if ENABLED(WATCH_HOTENDS) + static hotend_watch_t watch_hotend[HOTENDS]; + #endif #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) static uint16_t redundant_temperature_raw; @@ -419,22 +437,30 @@ class Temperature { static lpq_ptr_t lpq_ptr; #endif - TERN_(HAS_HOTEND, static temp_range_t temp_range[HOTENDS]); + #if ENABLED(HAS_HOTEND) + static temp_range_t temp_range[HOTENDS]; + #endif #if HAS_HEATED_BED - TERN_(WATCH_BED, static bed_watch_t watch_bed); + #if ENABLED(WATCH_BED) + static bed_watch_t watch_bed; + #endif IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); static int16_t mintemp_raw_BED, maxtemp_raw_BED; #endif #if HAS_HEATED_CHAMBER - TERN_(WATCH_CHAMBER, static chamber_watch_t watch_chamber); + #if ENABLED(WATCH_CHAMBER) + static chamber_watch_t watch_chamber; + #endif TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms); static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; #endif #if HAS_COOLER - TERN_(WATCH_COOLER, static cooler_watch_t watch_cooler); + #if ENABLED(WATCH_COOLER) + static cooler_watch_t watch_cooler; + #endif static millis_t next_cooler_check_ms, cooler_fan_flush_ms; static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER; #endif @@ -447,9 +473,13 @@ class Temperature { static millis_t preheat_end_time[HOTENDS]; #endif - TERN_(HAS_AUTO_FAN, static millis_t next_auto_fan_check_ms); + #if ENABLED(HAS_AUTO_FAN) + static millis_t next_auto_fan_check_ms; + #endif - TERN_(PROBING_HEATERS_OFF, static bool paused); + #if ENABLED(PROBING_HEATERS_OFF) + static bool paused; + #endif public: #if HAS_ADC_BUTTONS @@ -457,7 +487,9 @@ class Temperature { static uint16_t ADCKey_count; #endif - TERN_(PID_EXTRUSION_SCALING, static int16_t lpq_len); + #if ENABLED(PID_EXTRUSION_SCALING) + static int16_t lpq_len; + #endif /** * Instance Methods @@ -534,7 +566,9 @@ class Temperature { static constexpr inline uint8_t fanPercent(const uint8_t speed) { return ui8_to_percent(speed); } - TERN_(ADAPTIVE_FAN_SLOWING, static uint8_t fan_speed_scaler[FAN_COUNT]); + #if ENABLED(ADAPTIVE_FAN_SLOWING) + static uint8_t fan_speed_scaler[FAN_COUNT]; + #endif static inline uint8_t scaledFanSpeed(const uint8_t target, const uint8_t fs) { UNUSED(target); // Potentially unused! @@ -843,7 +877,9 @@ class Temperature { #endif #endif - TERN_(HAS_DISPLAY, static void set_heating_message(const uint8_t e)); + #if ENABLED(HAS_DISPLAY) + static void set_heating_message(const uint8_t e); + #endif #if HAS_LCD_MENU && HAS_TEMPERATURE static void lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb); @@ -866,9 +902,15 @@ class Temperature { static void checkExtruderAutoFans(); - TERN_(HAS_HOTEND, static float get_pid_output_hotend(const uint8_t e)); - TERN_(PIDTEMPBED, static float get_pid_output_bed()); - TERN_(PIDTEMPCHAMBER, static float get_pid_output_chamber()); + #if ENABLED(HAS_HOTEND) + static float get_pid_output_hotend(const uint8_t e); + #endif + #if ENABLED(PIDTEMPBED) + static float get_pid_output_bed(); + #endif + #if ENABLED(PIDTEMPCHAMBER) + static float get_pid_output_chamber(); + #endif static void _temp_error(const heater_id_t e, PGM_P const serial_msg, PGM_P const lcd_msg); static void min_temp_error(const heater_id_t e); diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index 5361451c82..a97b09fd89 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -109,9 +109,11 @@ #endif -TERN_(ELECTROMAGNETIC_SWITCHING_TOOLHEAD, void est_init()); - -TERN_(SWITCHING_TOOLHEAD, void swt_init()); +#if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) + void est_init(); +#elif ENABLED(SWITCHING_TOOLHEAD) + void swt_init(); +#endif /** * Perform a tool-change, which may result in moving the diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index a3e0577031..53053e88dc 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -1084,7 +1084,9 @@ void CardReader::cdroot() { #if DISABLED(SDSORT_USES_RAM) selectFileByIndex(o1); // Pre-fetch the first entry and save it strcpy(name1, longest_filename()); // so the loop only needs one fetch - TERN_(HAS_FOLDER_SORTING, bool dir1 = flag.filenameIsDir); + #if ENABLED(HAS_FOLDER_SORTING) + bool dir1 = flag.filenameIsDir; + #endif #endif for (uint16_t j = 0; j < i; ++j) { From 3ced55aa930076c912bad5df2ec5b4376a0eaba9 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Wed, 24 Mar 2021 13:32:08 +0100 Subject: [PATCH 096/311] Optimize MarlinSettings with template methods (#21426) --- Marlin/src/module/settings.cpp | 23 ++++++------------ Marlin/src/module/settings.h | 44 +++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index bf10902c60..d98ee3c218 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -572,13 +572,6 @@ void MarlinSettings::postprocess() { #if ENABLED(EEPROM_SETTINGS) - #define EEPROM_START() if (!persistentStore.access_start()) { SERIAL_ECHO_MSG("No EEPROM."); return false; } \ - int eeprom_index = EEPROM_OFFSET - #define EEPROM_FINISH() persistentStore.access_finish() - #define EEPROM_SKIP(VAR) (eeprom_index += sizeof(VAR)) - #define EEPROM_WRITE(VAR) do{ persistentStore.write_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc); }while(0) - #define EEPROM_READ(VAR) do{ persistentStore.read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc, !validating); }while(0) - #define EEPROM_READ_ALWAYS(VAR) do{ persistentStore.read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR), &working_crc); }while(0) #define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_ERROR_MSG(ERR); eeprom_error = true; } }while(0) #if ENABLED(DEBUG_EEPROM_READWRITE) @@ -594,6 +587,8 @@ void MarlinSettings::postprocess() { const char version[4] = EEPROM_VERSION; bool MarlinSettings::eeprom_error, MarlinSettings::validating; + int MarlinSettings::eeprom_index; + uint16_t MarlinSettings::working_crc; bool MarlinSettings::size_error(const uint16_t size) { if (size != datasize()) { @@ -610,9 +605,7 @@ void MarlinSettings::postprocess() { float dummyf = 0; char ver[4] = "ERR"; - uint16_t working_crc = 0; - - EEPROM_START(); + if (!EEPROM_START(EEPROM_OFFSET)) return false; eeprom_error = false; @@ -1456,9 +1449,7 @@ void MarlinSettings::postprocess() { * M501 - Retrieve Configuration */ bool MarlinSettings::_load() { - uint16_t working_crc = 0; - - EEPROM_START(); + if (!EEPROM_START(EEPROM_OFFSET)) return false; char stored_ver[4]; EEPROM_READ_ALWAYS(stored_ver); @@ -1496,10 +1487,10 @@ void MarlinSettings::postprocess() { uint32_t tmp1[XYZ + esteppers]; float tmp2[XYZ + esteppers]; feedRate_t tmp3[XYZ + esteppers]; - EEPROM_READ(tmp1); // max_acceleration_mm_per_s2 + EEPROM_READ((uint8_t *)tmp1, sizeof(tmp1)); // max_acceleration_mm_per_s2 EEPROM_READ(planner.settings.min_segment_time_us); - EEPROM_READ(tmp2); // axis_steps_per_mm - EEPROM_READ(tmp3); // max_feedrate_mm_s + EEPROM_READ((uint8_t *)tmp2, sizeof(tmp2)); // axis_steps_per_mm + EEPROM_READ((uint8_t *)tmp3, sizeof(tmp3)); // max_feedrate_mm_s if (!validating) LOOP_XYZE_N(i) { const bool in = (i < esteppers + XYZ); diff --git a/Marlin/src/module/settings.h b/Marlin/src/module/settings.h index b213de93a4..967d49c073 100644 --- a/Marlin/src/module/settings.h +++ b/Marlin/src/module/settings.h @@ -76,12 +76,15 @@ class MarlinSettings { //static void delete_mesh(); // necessary if we have a MAT //static void defrag_meshes(); // " #endif - #else + + #else // !EEPROM_SETTINGS + FORCE_INLINE static bool load() { reset(); report(); return true; } FORCE_INLINE static void first_load() { (void)load(); } - #endif + + #endif // !EEPROM_SETTINGS #if DISABLED(DISABLE_M503) static void report(const bool forReplay=false); @@ -105,7 +108,42 @@ class MarlinSettings { static bool _load(); static bool size_error(const uint16_t size); - #endif + + static int eeprom_index; + static uint16_t working_crc; + + static bool EEPROM_START(int eeprom_offset) { + if (!persistentStore.access_start()) { SERIAL_ECHO_MSG("No EEPROM."); return false; } + eeprom_index = eeprom_offset; + working_crc = 0; + return true; + } + + static void EEPROM_FINISH(void) { persistentStore.access_finish(); } + + template + static void EEPROM_SKIP(const T &VAR) { eeprom_index += sizeof(VAR); } + + template + static void EEPROM_WRITE(const T &VAR) { + persistentStore.write_data(eeprom_index, (const uint8_t *) &VAR, sizeof(VAR), &working_crc); + } + + template + static void EEPROM_READ(T &VAR) { + persistentStore.read_data(eeprom_index, (uint8_t *) &VAR, sizeof(VAR), &working_crc, !validating); + } + + static void EEPROM_READ(uint8_t *VAR, size_t sizeof_VAR) { + persistentStore.read_data(eeprom_index, VAR, sizeof_VAR, &working_crc, !validating); + } + + template + static void EEPROM_READ_ALWAYS(T &VAR) { + persistentStore.read_data(eeprom_index, (uint8_t *) &VAR, sizeof(VAR), &working_crc); + } + + #endif // EEPROM_SETTINGS }; extern MarlinSettings settings; From e7596d92c79134e342e2a3d5e6981fc562925231 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Wed, 24 Mar 2021 13:45:43 +0100 Subject: [PATCH 097/311] Update Anet V1.0 display timing (#21425) --- Marlin/src/pins/sanguino/pins_ANET_10.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/sanguino/pins_ANET_10.h b/Marlin/src/pins/sanguino/pins_ANET_10.h index fb1b6dbb3c..ac8fa80eb8 100644 --- a/Marlin/src/pins/sanguino/pins_ANET_10.h +++ b/Marlin/src/pins/sanguino/pins_ANET_10.h @@ -191,7 +191,7 @@ #define BTN_EN1 11 #define BTN_EN2 10 #define BTN_ENC 16 - #define BOARD_ST7920_DELAY_1 DELAY_NS(0) + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) #define BOARD_ST7920_DELAY_2 DELAY_NS(63) #define BOARD_ST7920_DELAY_3 DELAY_NS(125) #endif From fd8207dd9a1368c6bb75acd5fead76e6fbc0830f Mon Sep 17 00:00:00 2001 From: kpishere Date: Wed, 24 Mar 2021 10:14:11 -0400 Subject: [PATCH 098/311] Misc build fixes (#21413) Co-authored-by: Scott Lahteine --- Marlin/src/core/bug_on.h | 3 ++- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 2 +- Marlin/src/pins/ramps/pins_RAMPS.h | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Marlin/src/core/bug_on.h b/Marlin/src/core/bug_on.h index 8869be8d28..dc32f0385a 100644 --- a/Marlin/src/core/bug_on.h +++ b/Marlin/src/core/bug_on.h @@ -30,7 +30,8 @@ #define BUG_ON(V...) do { SERIAL_ECHOPAIR(ONLY_FILENAME, __LINE__, ": "); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0) #elif ENABLED(MARLIN_DEV_MODE) // Don't stop the CPU here, but at least dump the bug on the serial port - #define BUG_ON(V...) do { SERIAL_ECHOPAIR(ONLY_FILENAME, __LINE__, ": BUG!\n"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0) + //#define BUG_ON(V...) do { SERIAL_ECHOPAIR(ONLY_FILENAME, __LINE__, ": BUG!\n"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0) + #define BUG_ON(V...) NOOP #else // Release mode, let's ignore the bug #define BUG_ON(V...) NOOP diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index c16338a692..c4c6eb1423 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -98,7 +98,7 @@ void GcodeSuite::G29() { // For each G29 S2... if (mbl_probe_index == 0) { // Move close to the bed before the first point - do_blocking_move_to_z(0); + do_blocking_move_to_z(MANUAL_PROBE_START_Z); } else { // Save Z for the previous mesh position diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 805c92d71a..f30a235626 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -45,6 +45,10 @@ * 7 | 11 */ +#if ENABLED(AZSMZ_12864) && DISABLED(ALLOW_SAM3X8E) + #error "No pins defined for RAMPS with AZSMZ_12864." +#endif + #include "env_validate.h" // Custom flags and defines for the build @@ -720,9 +724,6 @@ #elif ENABLED(AZSMZ_12864) // Pins only defined for RAMPS_SMART currently - #if DISABLED(IS_RAMPS_SMART) - #error "No pins defined for RAMPS with AZSMZ_12864." - #endif #elif IS_TFTGLCD_PANEL From d172c71376d3adf199e8de90593a135e6f49e427 Mon Sep 17 00:00:00 2001 From: ldursw <37294448+ldursw@users.noreply.github.com> Date: Wed, 24 Mar 2021 11:30:19 -0300 Subject: [PATCH 099/311] Fix SDIO buffer alignment (#21396) --- Marlin/src/feature/binary_stream.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index 80f26cc7ce..4bfa3998f1 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -39,7 +39,12 @@ inline int bs_read_serial(const serial_index_t index) { #if ENABLED(BINARY_STREAM_COMPRESSION) static heatshrink_decoder hsd; - static uint8_t decode_buffer[512] = {}; + #ifdef BOTH(ARDUINO_ARCH_STM32F1, SDIO_SUPPORT) + // STM32 requires a word-aligned buffer for SD card transfers via DMA + static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {}; + #else + static uint8_t decode_buffer[512] = {}; + #endif #endif class SDFileTransferProtocol { From 930752d46e6aacb484ea89dacae6baf823d78d62 Mon Sep 17 00:00:00 2001 From: Miguel Risco-Castillo Date: Wed, 24 Mar 2021 10:12:57 -0500 Subject: [PATCH 100/311] Ender 3 V2 Status Line (#21369) Co-authored-by: Scott Lahteine --- Marlin/src/MarlinCore.cpp | 3 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 10 ++--- Marlin/src/feature/cancel_object.cpp | 2 +- Marlin/src/feature/pause.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 8 ++-- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 5 ++- Marlin/src/gcode/calibrate/G34_M422.cpp | 6 +-- Marlin/src/gcode/calibrate/M48.cpp | 4 +- Marlin/src/gcode/temp/M104_M109.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 9 ++++- Marlin/src/lcd/dwin/e3v2/dwin.h | 1 + Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/lcdprint.h | 1 - Marlin/src/lcd/marlinui.cpp | 41 ++++++++++++--------- Marlin/src/module/endstops.cpp | 4 +- Marlin/src/module/motion.cpp | 4 +- Marlin/src/module/temperature.cpp | 4 +- Marlin/src/module/temperature.h | 2 +- Marlin/src/module/tool_change.cpp | 2 +- 20 files changed, 66 insertions(+), 47 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 26ca8305f4..738f9a8d78 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -76,7 +76,6 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "lcd/dwin/e3v2/dwin.h" - #include "lcd/dwin/dwin_lcd.h" #include "lcd/dwin/e3v2/rotary_encoder.h" #endif @@ -1476,7 +1475,9 @@ void setup() { #if ENABLED(DWIN_CREALITY_LCD) Encoder_Configuration(); HMI_Init(); + DWIN_JPG_CacheTo1(Language_English); HMI_StartFrame(true); + DWIN_StatusChanged(GET_TEXT(WELCOME_MSG)); #endif #if HAS_SERVICE_INTERVALS && DISABLED(DWIN_CREALITY_LCD) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 06b91002b8..c1f824714c 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -733,7 +733,7 @@ void unified_bed_leveling::shift_mesh_height() { const int point_num = (GRID_MAX_POINTS) - count + 1; 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))); + TERN_(HAS_STATUS_MESSAGE, 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 if (ui.button_pressed()) { @@ -1440,7 +1440,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (do_3_pt_leveling) { SERIAL_ECHOLNPGM("Tilting mesh (1/3)"); - TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity); if (isnan(measured_z)) @@ -1459,7 +1459,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (!abort_flag) { SERIAL_ECHOLNPGM("Tilting mesh (2/3)"); - TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, param.V_verbosity); #ifdef VALIDATE_MESH_TILT @@ -1479,7 +1479,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (!abort_flag) { SERIAL_ECHOLNPGM("Tilting mesh (3/3)"); - TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, param.V_verbosity); #ifdef VALIDATE_MESH_TILT @@ -1520,7 +1520,7 @@ void unified_bed_leveling::smart_fill_mesh() { if (!abort_flag) { SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n"); - TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points)); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points)); measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling diff --git a/Marlin/src/feature/cancel_object.cpp b/Marlin/src/feature/cancel_object.cpp index e2e429ea10..1f92ac5843 100644 --- a/Marlin/src/feature/cancel_object.cpp +++ b/Marlin/src/feature/cancel_object.cpp @@ -43,7 +43,7 @@ void CancelObject::set_active_object(const int8_t obj) { else skipping = false; - #if HAS_DISPLAY + #if HAS_STATUS_MESSAGE if (active_object >= 0) ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object)); else diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 5f3338139a..a934b0ead0 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -652,7 +652,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le // Resume the print job timer if it was running if (print_job_timer.isPaused()) print_job_timer.start(); - TERN_(HAS_DISPLAY, ui.reset_status()); + TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); TERN_(HAS_LCD_MENU, ui.return_to_status()); } diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index e642c1ccf2..a746b86108 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -41,7 +41,7 @@ #include "../../../module/temperature.h" #endif -#if HAS_DISPLAY +#if HAS_STATUS_MESSAGE #include "../../../lcd/marlinui.h" #endif @@ -638,7 +638,7 @@ G29_TYPE GcodeSuite::G29() { if (TERN0(IS_KINEMATIC, !probe.can_reach(probePos))) continue; 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))); + TERN_(HAS_STATUS_MESSAGE, 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); @@ -683,7 +683,7 @@ G29_TYPE GcodeSuite::G29() { LOOP_L_N(i, 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))); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i + 1))); // Retain the last probe position probePos = points[i]; @@ -706,7 +706,7 @@ G29_TYPE GcodeSuite::G29() { #endif // AUTO_BED_LEVELING_3POINT - TERN_(HAS_DISPLAY, ui.reset_status()); + TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); // Stow the probe. No raise for FIX_MOUNTED_PROBE. if (probe.stow()) { diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index c4c6eb1423..278a39b4f8 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -122,6 +122,7 @@ void GcodeSuite::G29() { // After recording the last point, activate home and activate mbl_probe_index = -1; SERIAL_ECHOLNPGM("Mesh probing done."); + TERN_(HAS_STATUS_MESSAGE, ui.set_status(GET_TEXT(MSG_MESH_DONE))); BUZZ(100, 659); BUZZ(100, 698); @@ -180,8 +181,10 @@ void GcodeSuite::G29() { } // switch(state) - if (state == MeshNext) + if (state == MeshNext) { SERIAL_ECHOLNPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS), " of ", GRID_MAX_POINTS); + if (mbl_probe_index > 0) TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), _MIN(mbl_probe_index, GRID_MAX_POINTS), int(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 d2075fedce..a97283b3e7 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -190,7 +190,7 @@ void GcodeSuite::G34() { bool adjustment_reverse = false; #endif - #if HAS_DISPLAY + #if HAS_STATUS_MESSAGE PGM_P const msg_iteration = GET_TEXT(MSG_ITERATION); const uint8_t iter_str_len = strlen_P(msg_iteration); #endif @@ -204,7 +204,7 @@ void GcodeSuite::G34() { const int iter = iteration + 1; SERIAL_ECHOLNPAIR("\nG34 Iteration: ", iter); - #if HAS_DISPLAY + #if HAS_STATUS_MESSAGE char str[iter_str_len + 2 + 1]; sprintf_P(str, msg_iteration, iter); ui.set_status(str); @@ -290,7 +290,7 @@ void GcodeSuite::G34() { , " Z3-Z1=", ABS(z_measured[2] - z_measured[0]) #endif ); - #if HAS_DISPLAY + #if HAS_STATUS_MESSAGE char fstr1[10]; #if NUM_Z_STEPPER_DRIVERS == 2 char msg[6 + (6 + 5) * 1 + 1]; diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 0c6176173c..0c3da13bf9 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -142,7 +142,7 @@ void GcodeSuite::M48() { float sample_sum = 0.0; LOOP_L_N(n, n_samples) { - #if HAS_WIRED_LCD + #if HAS_STATUS_MESSAGE // Display M48 progress in the status bar ui.status_printf_P(0, PSTR(S_FMT ": %d/%d"), GET_TEXT(MSG_M48_POINT), int(n + 1), int(n_samples)); #endif @@ -257,7 +257,7 @@ void GcodeSuite::M48() { SERIAL_ECHOLNPGM("Finished!"); dev_report(verbose_level > 0, mean, sigma, min, max, true); - #if HAS_WIRED_LCD + #if HAS_STATUS_MESSAGE // Display M48 results in the status bar char sigma_str[8]; ui.status_printf_P(0, PSTR(S_FMT ": %s"), GET_TEXT(MSG_M48_DEVIATION), dtostrf(sigma, 2, 6, sigma_str)); diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index fe1e834656..e54f784153 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -185,7 +185,7 @@ void GcodeSuite::M109() { thermalManager.auto_job_check_timer(true, true); #endif - #if HAS_DISPLAY + #if HAS_STATUS_MESSAGE if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) thermalManager.set_heating_message(target_extruder); #endif diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index fc83a1ff87..af902481f3 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -481,7 +481,7 @@ #endif #endif -#if EITHER(HAS_DISPLAY, GLOBAL_STATUS_MESSAGE) +#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD, GLOBAL_STATUS_MESSAGE) #define HAS_STATUS_MESSAGE 1 #endif diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index d543ff0508..87ad93cf1d 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -402,7 +402,7 @@ void Draw_Title(const __FlashStringHelper * title) { } void Clear_Menu_Area() { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y); + DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y - 1); } void Clear_Main_Window() { @@ -3794,4 +3794,11 @@ void DWIN_CompletedLeveling() { if (checkkey == Leveling) Goto_MainMenu(); } +void DWIN_StatusChanged(const char *text) { + DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); + const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(text) * MENU_CHR_W) / 2; + DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Blue, x, STATUS_Y + 2, F(text)); + DWIN_UpdateLCD(); +} + #endif // DWIN_CREALITY_LCD diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index dd2d1cbc01..7f7c007eed 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -377,6 +377,7 @@ void HMI_Init(); void DWIN_Update(); void EachMomentUpdate(); void DWIN_HandleScreen(); +void DWIN_StatusChanged(const char *text); inline void DWIN_StartHoming() { HMI_flag.home_flag = true; } diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index a37f5aa790..78d446dd99 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -522,6 +522,7 @@ namespace Language_en { PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Bilinear Leveling"); PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling"); PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Mesh Leveling"); + PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Mesh probing done"); PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Printer Stats"); PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Board Info"); PROGMEM Language_Str MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistors"); diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index b7732d3198..90ffa14ad1 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -105,7 +105,6 @@ #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_COL_X_RJ(len), LCD_ROW_Y(row)) #define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr) #define SETCURSOR_X_RJ(len) SETCURSOR_RJ(len, _lcdLineNr) -#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) int lcd_glyph_height(); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 0be30efad8..4133e04832 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -44,9 +44,16 @@ MarlinUI ui; #include "../gcode/queue.h" #include "fontutils.h" #include "../sd/cardreader.h" - #if EITHER(EXTENSIBLE_UI, DWIN_CREALITY_LCD) - #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) - #endif +#endif + +#if ENABLED(DWIN_CREALITY_LCD) + #include "../module/printcounter.h" + #include "../MarlinCore.h" + #include "dwin/e3v2/dwin.h" +#endif + +#if HAS_STATUS_MESSAGE + #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) #endif #if LCD_HAS_WAIT_FOR_MOVE @@ -55,25 +62,24 @@ MarlinUI ui; constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; -#if HAS_WIRED_LCD - #if ENABLED(STATUS_MESSAGE_SCROLLING) - uint8_t MarlinUI::status_scroll_offset; // = 0 - constexpr uint8_t MAX_MESSAGE_LENGTH = _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH)); +#if HAS_STATUS_MESSAGE + #if HAS_WIRED_LCD + #if ENABLED(STATUS_MESSAGE_SCROLLING) + uint8_t MarlinUI::status_scroll_offset; // = 0 + constexpr uint8_t MAX_MESSAGE_LENGTH = _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH)); + #else + constexpr uint8_t MAX_MESSAGE_LENGTH = MAX_LANG_CHARSIZE * (LCD_WIDTH); + #endif #else - constexpr uint8_t MAX_MESSAGE_LENGTH = MAX_LANG_CHARSIZE * (LCD_WIDTH); + constexpr uint8_t MAX_MESSAGE_LENGTH = 63; #endif -#elif EITHER(EXTENSIBLE_UI, DWIN_CREALITY_LCD) - constexpr uint8_t MAX_MESSAGE_LENGTH = 63; -#endif - -#if EITHER(HAS_WIRED_LCD, EXTENSIBLE_UI) - uint8_t MarlinUI::alert_level; // = 0 char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; + uint8_t MarlinUI::alert_level; // = 0 #endif #if ENABLED(LCD_SET_PROGRESS_MANUALLY) MarlinUI::progress_t MarlinUI::progress_override; // = 0 - #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) + #if ENABLED(USE_M73_REMAINING_TIME) uint32_t MarlinUI::remaining_time; #endif #endif @@ -1461,6 +1467,7 @@ void MarlinUI::update() { #endif TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message)); + TERN_(DWIN_CREALITY_LCD, DWIN_StatusChanged(status_message)); } #if ENABLED(STATUS_MESSAGE_SCROLLING) @@ -1581,7 +1588,7 @@ void MarlinUI::update() { #endif -#else // !HAS_DISPLAY +#elif !HAS_STATUS_MESSAGE // && !HAS_DISPLAY // // Send the status line as a host notification @@ -1596,7 +1603,7 @@ void MarlinUI::update() { TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(message), UNUSED(message)); } -#endif // !HAS_DISPLAY +#endif // !HAS_DISPLAY && !HAS_STATUS_MESSAGE #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 4192b444bb..e11c4605e4 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -360,7 +360,7 @@ void Endstops::event_handler() { if (hit_state == prev_hit_state) return; prev_hit_state = hit_state; if (hit_state) { - #if HAS_WIRED_LCD + #if HAS_STATUS_MESSAGE char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' '; #define _SET_STOP_CHAR(A,C) (chr## A = C) #else @@ -391,7 +391,7 @@ void Endstops::event_handler() { #endif SERIAL_EOL(); - TERN_(HAS_WIRED_LCD, ui.status_printf_P(0, PSTR(S_FMT " %c %c %c %c"), GET_TEXT(MSG_LCD_ENDSTOPS), chrX, chrY, chrZ, chrP)); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %c %c %c %c"), GET_TEXT(MSG_LCD_ENDSTOPS), chrX, chrY, chrZ, chrP)); #if BOTH(SD_ABORT_ON_ENDSTOP_HIT, SDSUPPORT) if (planner.abort_on_endstop_hit) { diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index b0a4890e07..28ad9cf761 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -51,7 +51,7 @@ #include "../feature/bltouch.h" #endif -#if HAS_DISPLAY +#if HAS_STATUS_MESSAGE #include "../lcd/marlinui.h" #endif @@ -1144,7 +1144,7 @@ void prepare_line_to_destination() { ); SERIAL_ECHO_START(); SERIAL_ECHOLN(msg); - TERN_(HAS_DISPLAY, ui.set_status(msg)); + TERN_(HAS_STATUS_MESSAGE, ui.set_status(msg)); return true; } return false; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 6d1f3bd0a3..da792db833 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2495,7 +2495,7 @@ void Temperature::disable_all_heaters() { if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) { setTargetHotend(singlenozzle_temp[new_tool], 0); TERN_(AUTOTEMP, planner.autotemp_update()); - TERN_(HAS_DISPLAY, set_heating_message(0)); + TERN_(HAS_STATUS_MESSAGE, set_heating_message(0)); (void)wait_for_hotend(0, false); // Wait for heating or cooling } } @@ -3492,7 +3492,7 @@ void Temperature::tick() { } #endif - #if HAS_HOTEND && HAS_DISPLAY + #if HAS_HOTEND && HAS_STATUS_MESSAGE void Temperature::set_heating_message(const uint8_t e) { const bool heating = isHeatingHotend(e); ui.status_printf_P(0, diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 8092f1f7e2..ec603b5217 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -877,7 +877,7 @@ class Temperature { #endif #endif - #if ENABLED(HAS_DISPLAY) + #if HAS_STATUS_MESSAGE static void set_heating_message(const uint8_t e); #endif diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 0ed3d15b45..71dd6d40ec 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1262,7 +1262,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #if HAS_MULTI_HOTEND thermalManager.setTargetHotend(thermalManager.temp_hotend[active_extruder].target, migration_extruder); TERN_(AUTOTEMP, planner.autotemp_update()); - TERN_(HAS_DISPLAY, thermalManager.set_heating_message(0)); + TERN_(HAS_STATUS_MESSAGE, thermalManager.set_heating_message(0)); thermalManager.wait_for_hotend(active_extruder); #endif From 3ae892bf91566abcda3b3d54577175b5f50683ea Mon Sep 17 00:00:00 2001 From: Bryan Hunwardsen Date: Wed, 24 Mar 2021 10:05:46 -0700 Subject: [PATCH 101/311] SKR E3 Mini V2.0 Fan Bug Fix (#21079) Co-authored-by: Scott Lahteine --- Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index af2821f809..c51e7f48d9 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -23,6 +23,8 @@ #define SKR_MINI_E3_V2 +#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 + // Onboard I2C EEPROM #if NO_EEPROM_SELECTED #define I2C_EEPROM From 30e7e2c2766d7dbbe0144344287994f1969dfadd Mon Sep 17 00:00:00 2001 From: Martijn Bosgraaf Date: Wed, 24 Mar 2021 18:21:11 +0100 Subject: [PATCH 102/311] Extend M106/M107 for better laser module support (#16082) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 12 ++ Marlin/src/gcode/temp/M106_M107.cpp | 18 ++- Marlin/src/inc/SanityCheck.h | 11 ++ Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 4 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 2 +- Marlin/src/lcd/marlinui.cpp | 29 ++-- Marlin/src/lcd/marlinui.h | 2 + Marlin/src/module/planner.cpp | 143 +++++++++++------- Marlin/src/module/planner.h | 27 +++- Marlin/src/module/stepper.cpp | 15 +- Marlin/src/module/temperature.cpp | 2 +- .../src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h | 6 +- .../src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 6 +- buildroot/tests/ARMED | 1 + 14 files changed, 189 insertions(+), 89 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 328056cb84..a7af076155 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3217,6 +3217,18 @@ #endif #endif +/** + * Synchronous Laser Control with M106/M107 + * + * Marlin normally applies M106/M107 fan speeds at a time "soon after" processing + * a planner block. This is too inaccurate for a PWM/TTL laser attached to the fan + * header (as with some add-on laser kits). Enable this option to set fan/laser + * speeds with much more exact timing for improved print fidelity. + * + * NOTE: This option sacrifices some cooling fan speed options. + */ +//#define LASER_SYNCHRONOUS_M106_M107 + /** * Coolant Control * diff --git a/Marlin/src/gcode/temp/M106_M107.cpp b/Marlin/src/gcode/temp/M106_M107.cpp index b7d64c99ea..3ce08aafb6 100644 --- a/Marlin/src/gcode/temp/M106_M107.cpp +++ b/Marlin/src/gcode/temp/M106_M107.cpp @@ -28,6 +28,10 @@ #include "../../module/motion.h" #include "../../module/temperature.h" +#if ENABLED(LASER_SYNCHRONOUS_M106_M107) + #include "../../module/planner.h" +#endif + #if PREHEAT_COUNT #include "../../lcd/marlinui.h" #endif @@ -82,6 +86,8 @@ void GcodeSuite::M106() { // Set speed, with constraint thermalManager.set_fan_speed(pfan, speed); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); + if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating thermalManager.set_fan_speed(1 - pfan, speed); } @@ -92,12 +98,14 @@ void GcodeSuite::M106() { */ void GcodeSuite::M107() { const uint8_t pfan = parser.byteval('P', _ALT_P); - if (pfan < _CNT_P) { - thermalManager.set_fan_speed(pfan, 0); + if (pfan >= _CNT_P) return; - if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating - thermalManager.set_fan_speed(1 - pfan, 0); - } + thermalManager.set_fan_speed(pfan, 0); + + if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating + thermalManager.set_fan_speed(1 - pfan, 0); + + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); } #endif // HAS_FAN diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a7f726c4b2..704163e2b2 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1217,6 +1217,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "To use BED_LIMIT_SWITCHING you must disable PIDTEMPBED." #endif +/** + * Synchronous M106/M107 checks + */ +#if ENABLED(LASER_SYNCHRONOUS_M106_M107) + #if FAN_KICKSTART_TIME + #error "FAN_KICKSTART_TIME must be 0 with LASER_SYNCHRONOUS_M106_M107 (because the laser will always come on at FULL power)." + #elif FAN_MIN_PWM + #error "FAN_MIN_PWM must be 0 with LASER_SYNCHRONOUS_M106_M107 (otherwise the laser will never turn OFF)." + #endif +#endif + /** * Chamber Heating Options - PID vs Limit Switching */ diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index fd72f94862..e645a76611 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -760,7 +760,7 @@ void MarlinUI::draw_status_screen() { #endif #endif // HAS_HEATED_BED - #if FAN_COUNT > 0 + #if HAS_FAN uint16_t spd = thermalManager.fan_speed[0]; #if ENABLED(ADAPTIVE_FAN_SLOWING) @@ -783,7 +783,7 @@ void MarlinUI::draw_status_screen() { else picBits &= ~ICON_FAN; - #endif // FAN_COUNT > 0 + #endif // HAS_FAN // // Line 9, 10 - icons diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 87ad93cf1d..b86e7cbe60 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -2152,7 +2152,7 @@ void HMI_SelectFile() { card.openAndPrintFile(card.filename); - #if FAN_COUNT > 0 + #if HAS_FAN // All fans on for Ender 3 v2 ? // The slicer should manage this for us. //for (uint8_t i = 0; i < FAN_COUNT; i++) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 4133e04832..8fef36e25a 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -22,6 +22,8 @@ #include "../inc/MarlinConfig.h" +#include "../MarlinCore.h" // for printingIsPaused + #ifdef LED_BACKLIGHT_TIMEOUT #include "../feature/leds/leds.h" #endif @@ -39,21 +41,21 @@ MarlinUI ui; #if HAS_DISPLAY - #include "../module/printcounter.h" - #include "../MarlinCore.h" #include "../gcode/queue.h" #include "fontutils.h" #include "../sd/cardreader.h" #endif #if ENABLED(DWIN_CREALITY_LCD) - #include "../module/printcounter.h" - #include "../MarlinCore.h" #include "dwin/e3v2/dwin.h" #endif -#if HAS_STATUS_MESSAGE - #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) +#if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL + #define BASIC_PROGRESS_BAR 1 +#endif + +#if ANY(HAS_DISPLAY, HAS_STATUS_MESSAGE, BASIC_PROGRESS_BAR) + #include "../module/printcounter.h" #endif #if LCD_HAS_WAIT_FOR_MOVE @@ -535,7 +537,7 @@ bool MarlinUI::get_blink() { * This is very display-dependent, so the lcd implementation draws this. */ -#if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL +#if BASIC_PROGRESS_BAR millis_t MarlinUI::progress_bar_ms; // = 0 #if PROGRESS_MSG_EXPIRE > 0 millis_t MarlinUI::expire_status_ms; // = 0 @@ -546,7 +548,7 @@ void MarlinUI::status_screen() { TERN_(HAS_LCD_MENU, ENCODER_RATE_MULTIPLY(false)); - #if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL + #if BASIC_PROGRESS_BAR // // HD44780 implements the following message blinking and @@ -586,7 +588,7 @@ void MarlinUI::status_screen() { #endif // PROGRESS_MSG_EXPIRE - #endif // LCD_PROGRESS_BAR + #endif // BASIC_PROGRESS_BAR #if HAS_LCD_MENU if (use_click()) { @@ -1353,6 +1355,7 @@ void MarlinUI::update() { /** * Reset the status message */ + void MarlinUI::reset_status(const bool no_welcome) { #if SERVICE_INTERVAL_1 > 0 static PGMSTR(service1, "> " SERVICE_NAME_1 "!"); @@ -1438,9 +1441,9 @@ void MarlinUI::update() { void MarlinUI::finish_status(const bool persist) { - #if HAS_SPI_LCD + #if HAS_WIRED_LCD - #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE) > 0) + #if !(BASIC_PROGRESS_BAR && (PROGRESS_MSG_EXPIRE) > 0) UNUSED(persist); #endif @@ -1448,7 +1451,7 @@ void MarlinUI::update() { const millis_t ms = millis(); #endif - #if ENABLED(LCD_PROGRESS_BAR) + #if BASIC_PROGRESS_BAR progress_bar_ms = ms; #if PROGRESS_MSG_EXPIRE > 0 expire_status_ms = persist ? 0 : ms + PROGRESS_MSG_EXPIRE; @@ -1462,7 +1465,7 @@ void MarlinUI::update() { #if ENABLED(STATUS_MESSAGE_SCROLLING) status_scroll_offset = 0; #endif - #else // HAS_SPI_LCD + #else // HAS_WIRED_LCD UNUSED(persist); #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 490d78401e..cc08284d17 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -56,6 +56,8 @@ #include "../module/motion.h" // for active_extruder #endif +#define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) + #if HAS_WIRED_LCD enum LCDViewAction : uint8_t { diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 84c93e5296..b20d1e273b 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1015,8 +1015,8 @@ void Planner::reverse_pass() { // Perform the reverse pass block_t *current = &block_buffer[block_index]; - // Only consider non sync and page blocks - if (!TEST(current->flag, BLOCK_BIT_SYNC_POSITION) && !IS_PAGE(current)) { + // Only consider non sync-and-page blocks + if (!(current->flag & BLOCK_MASK_SYNC) && !IS_PAGE(current)) { reverse_pass_kernel(current, next); next = current; } @@ -1111,7 +1111,7 @@ void Planner::forward_pass() { block = &block_buffer[block_index]; // Skip SYNC and page blocks - if (!TEST(block->flag, BLOCK_BIT_SYNC_POSITION) && !IS_PAGE(block)) { + if (!(block->flag & BLOCK_MASK_SYNC) && !IS_PAGE(block)) { // If there's no previous block or the previous block is not // BUSY (thus, modifiable) run the forward_pass_kernel. Otherwise, // the previous block became BUSY, so assume the current block's @@ -1147,7 +1147,7 @@ void Planner::recalculate_trapezoids() { block_t *prev = &block_buffer[prev_index]; // If not dealing with a sync block, we are done. The last block is not a SYNC block - if (!TEST(prev->flag, BLOCK_BIT_SYNC_POSITION)) break; + if (!(prev->flag & BLOCK_MASK_SYNC)) break; // Examine the previous block. This and all following are SYNC blocks head_block_index = prev_index; @@ -1161,7 +1161,7 @@ void Planner::recalculate_trapezoids() { next = &block_buffer[block_index]; // Skip sync and page blocks - if (!TEST(next->flag, BLOCK_BIT_SYNC_POSITION) && !IS_PAGE(next)) { + if (!(next->flag & BLOCK_MASK_SYNC) && !IS_PAGE(next)) { next_entry_speed = SQRT(next->entry_speed_sqr); if (block) { @@ -1248,6 +1248,63 @@ void Planner::recalculate() { recalculate_trapezoids(); } +#if HAS_FAN && DISABLED(LASER_SYNCHRONOUS_M106_M107) + #define HAS_TAIL_FAN_SPEED 1 +#endif + +/** + * Apply fan speeds + */ +#if HAS_FAN + + void Planner::sync_fan_speeds(uint8_t (&fan_speed)[FAN_COUNT]) { + + #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255 + #define CALC_FAN_SPEED(f) (fan_speed[f] ? map(fan_speed[f], 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM) + #else + #define CALC_FAN_SPEED(f) (fan_speed[f] ?: FAN_OFF_PWM) + #endif + + #if ENABLED(FAN_SOFT_PWM) + #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F); + #elif ENABLED(FAST_PWM_FAN) + #define _FAN_SET(F) set_pwm_duty(FAN##F##_PIN, CALC_FAN_SPEED(F)); + #else + #define _FAN_SET(F) analogWrite(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); + #endif + #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0) + + const millis_t ms = millis(); + TERN_(HAS_FAN0, FAN_SET(0)); + TERN_(HAS_FAN1, FAN_SET(1)); + TERN_(HAS_FAN2, FAN_SET(2)); + TERN_(HAS_FAN3, FAN_SET(3)); + TERN_(HAS_FAN4, FAN_SET(4)); + TERN_(HAS_FAN5, FAN_SET(5)); + TERN_(HAS_FAN6, FAN_SET(6)); + TERN_(HAS_FAN7, FAN_SET(7)); + } + + #if FAN_KICKSTART_TIME + + void Planner::kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f) { + static millis_t fan_kick_end[FAN_COUNT] = { 0 }; + if (fan_speed[f]) { + if (fan_kick_end[f] == 0) { + fan_kick_end[f] = ms + FAN_KICKSTART_TIME; + fan_speed[f] = 255; + } + else if (PENDING(ms, fan_kick_end[f])) + fan_speed[f] = 255; + } + else + fan_kick_end[f] = 0; + } + + #endif + +#endif // HAS_FAN + /** * Maintain fans, paste extruder pressure, */ @@ -1257,7 +1314,7 @@ void Planner::check_axes_activity() { xyze_bool_t axis_active = { false }; #endif - #if HAS_FAN + #if HAS_TAIL_FAN_SPEED uint8_t tail_fan_speed[FAN_COUNT]; #endif @@ -1272,13 +1329,12 @@ void Planner::check_axes_activity() { if (has_blocks_queued()) { - #if HAS_FAN || ENABLED(BARICUDA) + #if EITHER(HAS_TAIL_FAN_SPEED, BARICUDA) block_t *block = &block_buffer[block_buffer_tail]; #endif - #if HAS_FAN - FANS_LOOP(i) - tail_fan_speed[i] = thermalManager.scaledFanSpeed(i, block->fan_speed[i]); + #if HAS_TAIL_FAN_SPEED + FANS_LOOP(i) tail_fan_speed[i] = thermalManager.scaledFanSpeed(i, block->fan_speed[i]); #endif #if ENABLED(BARICUDA) @@ -1300,9 +1356,8 @@ void Planner::check_axes_activity() { TERN_(HAS_CUTTER, cutter.refresh()); - #if HAS_FAN - FANS_LOOP(i) - tail_fan_speed[i] = thermalManager.scaledFanSpeed(i); + #if HAS_TAIL_FAN_SPEED + FANS_LOOP(i) tail_fan_speed[i] = thermalManager.scaledFanSpeed(i); #endif #if ENABLED(BARICUDA) @@ -1321,48 +1376,11 @@ void Planner::check_axes_activity() { // // Update Fan speeds + // Only if synchronous M106/M107 is disabled // - #if HAS_FAN - - #if FAN_KICKSTART_TIME > 0 - static millis_t fan_kick_end[FAN_COUNT] = { 0 }; - #define KICKSTART_FAN(f) \ - if (tail_fan_speed[f]) { \ - millis_t ms = millis(); \ - if (fan_kick_end[f] == 0) { \ - fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \ - tail_fan_speed[f] = 255; \ - } else if (PENDING(ms, fan_kick_end[f])) \ - tail_fan_speed[f] = 255; \ - } else fan_kick_end[f] = 0 - #else - #define KICKSTART_FAN(f) NOOP - #endif - - #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255 - #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? map(tail_fan_speed[f], 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM) - #else - #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ?: FAN_OFF_PWM) - #endif - - #if ENABLED(FAN_SOFT_PWM) - #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F); - #elif ENABLED(FAST_PWM_FAN) - #define _FAN_SET(F) set_pwm_duty(FAN##F##_PIN, CALC_FAN_SPEED(F)); - #else - #define _FAN_SET(F) analogWrite(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); - #endif - #define FAN_SET(F) do{ KICKSTART_FAN(F); _FAN_SET(F); }while(0) - - TERN_(HAS_FAN0, FAN_SET(0)); - TERN_(HAS_FAN1, FAN_SET(1)); - TERN_(HAS_FAN2, FAN_SET(2)); - TERN_(HAS_FAN3, FAN_SET(3)); - TERN_(HAS_FAN4, FAN_SET(4)); - TERN_(HAS_FAN5, FAN_SET(5)); - TERN_(HAS_FAN6, FAN_SET(6)); - TERN_(HAS_FAN7, FAN_SET(7)); - #endif // HAS_FAN + #if HAS_TAIL_FAN_SPEED + sync_fan_speeds(tail_fan_speed); + #endif TERN_(AUTOTEMP, getHighESpeed()); @@ -2675,9 +2693,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move, /** * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position + * Add a block to the buffer that just updates the position, + * or in case of LASER_SYNCHRONOUS_M106_M107 the fan PWM */ -void Planner::buffer_sync_block() { +void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_flag)) { + #if DISABLED(LASER_SYNCHRONOUS_M106_M107) + constexpr uint8_t sync_flag = BLOCK_FLAG_SYNC_POSITION; + #endif + // Wait for the next available block uint8_t next_buffer_head; block_t * const block = get_next_free_block(next_buffer_head); @@ -2685,10 +2708,14 @@ void Planner::buffer_sync_block() { // Clear block memset(block, 0, sizeof(block_t)); - block->flag = BLOCK_FLAG_SYNC_POSITION; + block->flag = sync_flag; block->position = position; + #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107) + FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; + #endif + // If this is the first added movement, reload the delay, otherwise, cancel it. if (block_buffer_head == block_buffer_tail) { // If it was the first queued block, restart the 1st block delivery delay, to @@ -2876,7 +2903,7 @@ bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, con block->flag = BLOCK_FLAG_IS_PAGE; - #if FAN_COUNT > 0 + #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 24c814e851..da9e202cdf 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -102,6 +102,11 @@ enum BlockFlagBit : char { #if ENABLED(DIRECT_STEPPING) , BLOCK_BIT_IS_PAGE #endif + + // Sync the fan speeds from the block + #if ENABLED(LASER_SYNCHRONOUS_M106_M107) + , BLOCK_BIT_SYNC_FANS + #endif }; enum BlockFlag : char { @@ -112,8 +117,13 @@ enum BlockFlag : char { #if ENABLED(DIRECT_STEPPING) , BLOCK_FLAG_IS_PAGE = _BV(BLOCK_BIT_IS_PAGE) #endif + #if ENABLED(LASER_SYNCHRONOUS_M106_M107) + , BLOCK_FLAG_SYNC_FANS = _BV(BLOCK_BIT_SYNC_FANS) + #endif }; +#define BLOCK_MASK_SYNC ( BLOCK_FLAG_SYNC_POSITION | TERN0(LASER_SYNCHRONOUS_M106_M107, BLOCK_FLAG_SYNC_FANS) ) + #if ENABLED(LASER_POWER_INLINE) typedef struct { @@ -499,6 +509,16 @@ class Planner { // Manage fans, paste pressure, etc. static void check_axes_activity(); + // Apply fan speeds + #if HAS_FAN + static void sync_fan_speeds(uint8_t (&fan_speed)[FAN_COUNT]); + #if FAN_KICKSTART_TIME + static void kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f); + #else + FORCE_INLINE static void kickstart_fan(uint8_t (&)[FAN_COUNT], const millis_t &, const uint8_t) {} + #endif + #endif + #if ENABLED(FILAMENT_WIDTH_SENSOR) void apply_filament_width_sensor(const int8_t encoded_ratio); @@ -721,9 +741,12 @@ class Planner { /** * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position + * Add a block to the buffer that just updates the position or in + * case of LASER_SYNCHRONOUS_M106_M107 the fan pwm */ - static void buffer_sync_block(); + static void buffer_sync_block( + TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_flag=BLOCK_FLAG_SYNC_POSITION) + ); #if IS_KINEMATIC private: diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 77fa6539bc..49eca7047c 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1988,9 +1988,18 @@ uint32_t Stepper::block_phase_isr() { // Anything in the buffer? if ((current_block = planner.get_current_block())) { - // Sync block? Sync the stepper counts and return - while (TEST(current_block->flag, BLOCK_BIT_SYNC_POSITION)) { - _set_position(current_block->position); + // Sync block? Sync the stepper counts or fan speeds and return + while (current_block->flag & BLOCK_MASK_SYNC) { + + #if ENABLED(LASER_SYNCHRONOUS_M106_M107) + const bool is_sync_fans = TEST(current_block->flag, BLOCK_BIT_SYNC_FANS); + if (is_sync_fans) planner.sync_fan_speeds(current_block->fan_speed); + #else + constexpr bool is_sync_fans = false; + #endif + + if (!is_sync_fans) _set_position(current_block->position); + discard_current_block(); // Try to get a new block diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index da792db833..a9b7ab13eb 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -197,7 +197,7 @@ #endif #if HAS_SERVOS - #include "./servo.h" + #include "servo.h" #endif #if ANY(TEMP_SENSOR_0_IS_THERMISTOR, TEMP_SENSOR_1_IS_THERMISTOR, TEMP_SENSOR_2_IS_THERMISTOR, TEMP_SENSOR_3_IS_THERMISTOR, \ diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h index f9e85c4919..726e9a6586 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h @@ -322,7 +322,8 @@ #define TFT_BUFFER_SIZE 14400 -#elif HAS_SPI_LCD +#elif HAS_WIRED_LCD + #define BEEPER_PIN PC5 #define BTN_ENC PE13 #define LCD_PINS_ENABLE PD13 @@ -358,4 +359,5 @@ #define BOARD_ST7920_DELAY_3 DELAY_NS(600) #endif // !MKS_MINI_12864 -#endif // HAS_SPI_LCD + +#endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index f2ddfc2b52..1000326dad 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -327,7 +327,8 @@ //#define TFT_DRIVER ST7796 #define TFT_BUFFER_SIZE 14400 -#elif HAS_SPI_LCD +#elif HAS_WIRED_LCD + #define BEEPER_PIN PC5 #define BTN_ENC PE13 #define LCD_PINS_ENABLE PD13 @@ -369,4 +370,5 @@ #endif #endif // !MKS_MINI_12864 -#endif // HAS_SPI_LCD + +#endif // HAS_WIRED_LCD diff --git a/buildroot/tests/ARMED b/buildroot/tests/ARMED index 8764d47e84..7b9fef1eeb 100755 --- a/buildroot/tests/ARMED +++ b/buildroot/tests/ARMED @@ -12,6 +12,7 @@ set -e restore_configs use_example_configs ArmEd opt_set X_DRIVER_TYPE TMC2130 Y_DRIVER_TYPE TMC2208 +opt_enable LASER_SYNCHRONOUS_M106_M107 exec_test $1 $2 "ArmEd Example Configuration with mixed TMC Drivers" "$3" # clean up From 832059967c4cfbd48d82282c2e700b8d4b805492 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 22 Mar 2021 23:58:03 -0500 Subject: [PATCH 103/311] Comment, clean up some PlatformIO scripts --- buildroot/share/PlatformIO/ldscripts/lerdge.ld | 6 +++--- buildroot/share/PlatformIO/scripts/openblt.py | 7 ++++--- .../share/PlatformIO/scripts/stm32_bootloader.py | 14 +++++++++++++- .../PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld | 6 +++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/buildroot/share/PlatformIO/ldscripts/lerdge.ld b/buildroot/share/PlatformIO/ldscripts/lerdge.ld index aa0b1dd9cb..f36ebcdea1 100644 --- a/buildroot/share/PlatformIO/ldscripts/lerdge.ld +++ b/buildroot/share/PlatformIO/ldscripts/lerdge.ld @@ -40,9 +40,9 @@ _Min_Stack_Size = 0x400;; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE -CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K } /* Define output sections */ diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 2911a28e78..01cd9c9ef2 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -1,5 +1,6 @@ -# Generate the firmware as OpenBLT needs - +# +# Convert the ELF to an SREC file suitable for some bootloaders +# import os,sys from os.path import join @@ -10,5 +11,5 @@ env.AddPostAction( env.VerboseAction(" ".join([ "$OBJCOPY", "-O", "srec", "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\"" - ]), "Building " + join("$BUILD_DIR","${PROGNAME}.srec")) + ]), "Building " + join("$BUILD_DIR", "${PROGNAME}.srec")) ) diff --git a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py index bbec61750c..1ceff84b8f 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -7,18 +7,28 @@ Import("env") from SCons.Script import DefaultEnvironment board = DefaultEnvironment().BoardConfig() +# +# Copy the firmware.bin file to build.firmware, no encryption +# def noencrypt(source, target, env): firmware = os.path.join(target[0].dir.path, board.get("build.firmware")) shutil.copy(target[0].path, firmware) +# +# For build.offset define LD_FLASH_OFFSET, used by ldscript.ld +# if 'offset' in board.get("build").keys(): LD_FLASH_OFFSET = board.get("build.offset") + # Remove an existing VECT_TAB_OFFSET from CPPDEFINES for define in env['CPPDEFINES']: if define[0] == "VECT_TAB_OFFSET": env['CPPDEFINES'].remove(define) + + # Replace VECT_TAB_OFFSET with our LD_FLASH_OFFSET env['CPPDEFINES'].append(("VECT_TAB_OFFSET", LD_FLASH_OFFSET)) + # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json) maximum_ram_size = board.get("upload.maximum_ram_size") for i, flag in enumerate(env["LINKFLAGS"]): @@ -27,7 +37,9 @@ if 'offset' in board.get("build").keys(): if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) +# +# Only copy the file if there's no encrypt +# board_keys = board.get("build").keys() -# Only copy file if there's no encryptation if 'firmware' in board_keys and not 'encrypt' in board_keys: env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld index 19eec62fba..aa685e8111 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld @@ -58,9 +58,9 @@ _Min_Stack_Size = 0x400; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE -CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K -FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET } /* Define output sections */ From b59a4331fa05c41ea2004f959ae3d75a36bc5dd5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Mar 2021 22:43:47 -0500 Subject: [PATCH 104/311] Update common-cxxflags.py comment --- buildroot/share/PlatformIO/scripts/common-cxxflags.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/common-cxxflags.py b/buildroot/share/PlatformIO/scripts/common-cxxflags.py index 36704af283..856a246fba 100644 --- a/buildroot/share/PlatformIO/scripts/common-cxxflags.py +++ b/buildroot/share/PlatformIO/scripts/common-cxxflags.py @@ -20,10 +20,10 @@ def add_cpu_freq(): # Useful for JTAG debugging # -# It will separe release and debug build folders. -# It useful when we need keep two live versions: one debug, for debugging, -# other release, for flashing (when upload is not done automatically by jlink/stlink). -# Without this, PIO will recompile everything twice for any small change. +# It will separate release and debug build folders. +# It useful to keep two live versions: a debug version for debugging and another for +# release, for flashing when upload is not done automatically by jlink/stlink. +# Without this, PIO needs to recompile everything twice for any small change. if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink']: env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug' From 589bb921aeaac73c5056d7adfa157412b5ebe273 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Mar 2021 22:39:13 -0500 Subject: [PATCH 105/311] Tweak disabled variant options --- .../variants/BIGTREE_GTR_V1/hal_conf_extra.h | 68 +++++++++--------- .../BIGTREE_SKR_PRO_1v1/hal_conf_extra.h | 68 +++++++++--------- .../FYSETC_CHEETAH_V20/hal_conf_custom.h | 64 ++++++++--------- .../variants/MARLIN_F4x7Vx/hal_conf_extra.h | 72 +++++++++---------- 4 files changed, 136 insertions(+), 136 deletions(-) diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h index f7f9e23e99..cbce513d1b 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h @@ -16,37 +16,37 @@ //#define HAL_UART_MODULE_ENABLED // by default //#define HAL_PCD_MODULE_ENABLED // Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) -#undef HAL_SD_MODULE_ENABLED -#undef HAL_DAC_MODULE_ENABLED -#undef HAL_FLASH_MODULE_ENABLED -#undef HAL_CAN_MODULE_ENABLED -#undef HAL_CAN_LEGACY_MODULE_ENABLED -#undef HAL_CEC_MODULE_ENABLED -#undef HAL_CRYP_MODULE_ENABLED -#undef HAL_DCMI_MODULE_ENABLED -#undef HAL_DMA2D_MODULE_ENABLED -#undef HAL_ETH_MODULE_ENABLED -#undef HAL_NAND_MODULE_ENABLED -#undef HAL_NOR_MODULE_ENABLED -#undef HAL_PCCARD_MODULE_ENABLED -#undef HAL_SRAM_MODULE_ENABLED -#undef HAL_SDRAM_MODULE_ENABLED -#undef HAL_HASH_MODULE_ENABLED -#undef HAL_EXTI_MODULE_ENABLED -#undef HAL_SMBUS_MODULE_ENABLED -#undef HAL_I2S_MODULE_ENABLED -#undef HAL_IWDG_MODULE_ENABLED -#undef HAL_LTDC_MODULE_ENABLED -#undef HAL_DSI_MODULE_ENABLED -#undef HAL_QSPI_MODULE_ENABLED -#undef HAL_RNG_MODULE_ENABLED -#undef HAL_SAI_MODULE_ENABLED -#undef HAL_IRDA_MODULE_ENABLED -#undef HAL_SMARTCARD_MODULE_ENABLED -#undef HAL_WWDG_MODULE_ENABLED -//#undef HAL_HCD_MODULE_ENABLED -#undef HAL_FMPI2C_MODULE_ENABLED -#undef HAL_SPDIFRX_MODULE_ENABLED -#undef HAL_DFSDM_MODULE_ENABLED -#undef HAL_LPTIM_MODULE_ENABLED -#undef HAL_MMC_MODULE_ENABLED +//#define HAL_SD_MODULE_ENABLED +//#define HAL_DAC_MODULE_ENABLED +//#define HAL_FLASH_MODULE_ENABLED +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED +//#define HAL_EXTI_MODULE_ENABLED +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h index f7f9e23e99..cbce513d1b 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h @@ -16,37 +16,37 @@ //#define HAL_UART_MODULE_ENABLED // by default //#define HAL_PCD_MODULE_ENABLED // Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) -#undef HAL_SD_MODULE_ENABLED -#undef HAL_DAC_MODULE_ENABLED -#undef HAL_FLASH_MODULE_ENABLED -#undef HAL_CAN_MODULE_ENABLED -#undef HAL_CAN_LEGACY_MODULE_ENABLED -#undef HAL_CEC_MODULE_ENABLED -#undef HAL_CRYP_MODULE_ENABLED -#undef HAL_DCMI_MODULE_ENABLED -#undef HAL_DMA2D_MODULE_ENABLED -#undef HAL_ETH_MODULE_ENABLED -#undef HAL_NAND_MODULE_ENABLED -#undef HAL_NOR_MODULE_ENABLED -#undef HAL_PCCARD_MODULE_ENABLED -#undef HAL_SRAM_MODULE_ENABLED -#undef HAL_SDRAM_MODULE_ENABLED -#undef HAL_HASH_MODULE_ENABLED -#undef HAL_EXTI_MODULE_ENABLED -#undef HAL_SMBUS_MODULE_ENABLED -#undef HAL_I2S_MODULE_ENABLED -#undef HAL_IWDG_MODULE_ENABLED -#undef HAL_LTDC_MODULE_ENABLED -#undef HAL_DSI_MODULE_ENABLED -#undef HAL_QSPI_MODULE_ENABLED -#undef HAL_RNG_MODULE_ENABLED -#undef HAL_SAI_MODULE_ENABLED -#undef HAL_IRDA_MODULE_ENABLED -#undef HAL_SMARTCARD_MODULE_ENABLED -#undef HAL_WWDG_MODULE_ENABLED -//#undef HAL_HCD_MODULE_ENABLED -#undef HAL_FMPI2C_MODULE_ENABLED -#undef HAL_SPDIFRX_MODULE_ENABLED -#undef HAL_DFSDM_MODULE_ENABLED -#undef HAL_LPTIM_MODULE_ENABLED -#undef HAL_MMC_MODULE_ENABLED +//#define HAL_SD_MODULE_ENABLED +//#define HAL_DAC_MODULE_ENABLED +//#define HAL_FLASH_MODULE_ENABLED +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED +//#define HAL_EXTI_MODULE_ENABLED +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h index 1b9df2b47a..6c56b97a74 100644 --- a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h @@ -33,55 +33,55 @@ extern "C" { */ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED #define HAL_CRC_MODULE_ENABLED -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED //#define HAL_DAC_MODULE_ENABLED -/* #define HAL_DCMI_MODULE_ENABLED */ +//#define HAL_DCMI_MODULE_ENABLED #define HAL_DMA_MODULE_ENABLED -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED #define HAL_FLASH_MODULE_ENABLED -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -/* #define HAL_SDRAM_MODULE_ENABLED */ -/* #define HAL_HASH_MODULE_ENABLED */ +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED -/* #define HAL_EXTI_MODULE_ENABLED */ +//#define HAL_EXTI_MODULE_ENABLED #define HAL_I2C_MODULE_ENABLED -/* #define HAL_SMBUS_MODULE_ENABLED */ -/* #define HAL_I2S_MODULE_ENABLED */ +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED #define HAL_IWDG_MODULE_ENABLED -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED #define HAL_PWR_MODULE_ENABLED -/* #define HAL_QSPI_MODULE_ENABLED */ +//#define HAL_QSPI_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED -/* #define HAL_RNG_MODULE_ENABLED */ +//#define HAL_RNG_MODULE_ENABLED #define HAL_RTC_MODULE_ENABLED -/* #define HAL_SAI_MODULE_ENABLED */ +//#define HAL_SAI_MODULE_ENABLED //#define HAL_SD_MODULE_ENABLED #define HAL_SPI_MODULE_ENABLED #define HAL_TIM_MODULE_ENABLED -/* #define HAL_UART_MODULE_ENABLED */ -/* #define HAL_USART_MODULE_ENABLED */ -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ +//#define HAL_UART_MODULE_ENABLED +//#define HAL_USART_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED #define HAL_CORTEX_MODULE_ENABLED #ifndef HAL_PCD_MODULE_ENABLED #define HAL_PCD_MODULE_ENABLED //Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) #endif -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED /* ########################## HSE/HSI Values adaptation ##################### */ /** diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h index d3c2f6bd02..abac2b08b3 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h @@ -36,53 +36,53 @@ */ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED -// #define HAL_CAN_MODULE_ENABLED -/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +//#define HAL_CAN_MODULE_ENABLED +#define HAL_CAN_LEGACY_MODULE_ENABLED #define HAL_CRC_MODULE_ENABLED -// #define HAL_CEC_MODULE_ENABLED -// #define HAL_CRYP_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED #define HAL_DAC_MODULE_ENABLED -// #define HAL_DCMI_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED #define HAL_DMA_MODULE_ENABLED -// #define HAL_DMA2D_MODULE_ENABLED -// #define HAL_ETH_MODULE_ENABLED -// #define HAL_FLASH_MODULE_ENABLED -// #define HAL_NAND_MODULE_ENABLED -// #define HAL_NOR_MODULE_ENABLED -// #define HAL_PCCARD_MODULE_ENABLED -// #define HAL_SRAM_MODULE_ENABLED -// #define HAL_SDRAM_MODULE_ENABLED -// #define HAL_HASH_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_FLASH_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED -// #define HAL_EXTI_MODULE_ENABLED +//#define HAL_EXTI_MODULE_ENABLED #define HAL_I2C_MODULE_ENABLED -// #define HAL_SMBUS_MODULE_ENABLED -// #define HAL_I2S_MODULE_ENABLED -// #define HAL_IWDG_MODULE_ENABLED -// #define HAL_LTDC_MODULE_ENABLED -// #define HAL_DSI_MODULE_ENABLED +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED #define HAL_PWR_MODULE_ENABLED -// #define HAL_QSPI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED -// #define HAL_RNG_MODULE_ENABLED -// #define HAL_RTC_MODULE_ENABLED -// #define HAL_SAI_MODULE_ENABLED -// #define HAL_SD_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_RTC_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_SD_MODULE_ENABLED #define HAL_SPI_MODULE_ENABLED #define HAL_TIM_MODULE_ENABLED -// #define HAL_UART_MODULE_ENABLED +//#define HAL_UART_MODULE_ENABLED #define HAL_USART_MODULE_ENABLED -// #define HAL_IRDA_MODULE_ENABLED -// #define HAL_SMARTCARD_MODULE_ENABLED -// #define HAL_WWDG_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED #define HAL_CORTEX_MODULE_ENABLED -// #define HAL_PCD_MODULE_ENABLED -// #define HAL_HCD_MODULE_ENABLED -// #define HAL_FMPI2C_MODULE_ENABLED -// #define HAL_SPDIFRX_MODULE_ENABLED -// #define HAL_DFSDM_MODULE_ENABLED -// #define HAL_LPTIM_MODULE_ENABLED -// #define HAL_MMC_MODULE_ENABLED +//#define HAL_PCD_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED /* ########################## HSE/HSI Values adaptation ##################### */ /** From de1161536bb25743266564d0ecba2554ccbef48e Mon Sep 17 00:00:00 2001 From: MarlinFirmware Date: Thu, 25 Mar 2021 00:27:01 +0000 Subject: [PATCH 106/311] [cron] Bump distribution date (2021-03-25) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 7d3f6d8a64..8ed540d0f6 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-03-24" + #define STRING_DISTRIBUTION_DATE "2021-03-25" #endif /** From cfdeab70cdacc9949eadc23b91d8e7c2a1fe63d8 Mon Sep 17 00:00:00 2001 From: espr14 Date: Thu, 25 Mar 2021 04:39:10 +0100 Subject: [PATCH 107/311] Endstops always on after delta homing (#21442) --- Marlin/src/module/delta.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index a1676b3ba3..2312e1a012 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -253,7 +253,7 @@ void home_delta() { planner.synchronize(); // Re-enable stealthChop if used. Disable diag1 pin on driver. - #if ENABLED(SENSORLESS_HOMING) + #if ENABLED(SENSORLESS_HOMING) && DISABLED(ENDSTOPS_ALWAYS_ON_DEFAULT) TERN_(X_SENSORLESS, end_sensorless_homing_per_axis(X_AXIS, stealth_states_x)); TERN_(Y_SENSORLESS, end_sensorless_homing_per_axis(Y_AXIS, stealth_states_y)); TERN_(Z_SENSORLESS, end_sensorless_homing_per_axis(Z_AXIS, stealth_states_z)); From e989bf3b0ed79156c094f6e298b5ff326a53e3fb Mon Sep 17 00:00:00 2001 From: espr14 Date: Thu, 25 Mar 2021 04:39:29 +0100 Subject: [PATCH 108/311] Endstops always on in G28 (#21441) --- Marlin/src/gcode/calibrate/G28.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 9470678872..73bfc3bdc6 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -102,7 +102,7 @@ current_position.set(0.0, 0.0); - #if ENABLED(SENSORLESS_HOMING) + #if ENABLED(SENSORLESS_HOMING) && DISABLED(ENDSTOPS_ALWAYS_ON_DEFAULT) tmc_disable_stallguard(stepperX, stealth_states.x); tmc_disable_stallguard(stepperY, stealth_states.y); #if AXIS_HAS_STALLGUARD(X2) From 69c6ffa90b017d31bf70dc174c716232ca2752ee Mon Sep 17 00:00:00 2001 From: ldursw <37294448+ldursw@users.noreply.github.com> Date: Thu, 25 Mar 2021 00:40:48 -0300 Subject: [PATCH 109/311] Followup to SDIO patch (#21440) --- Marlin/src/feature/binary_stream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index 4bfa3998f1..b5d68196ae 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -39,7 +39,7 @@ inline int bs_read_serial(const serial_index_t index) { #if ENABLED(BINARY_STREAM_COMPRESSION) static heatshrink_decoder hsd; - #ifdef BOTH(ARDUINO_ARCH_STM32F1, SDIO_SUPPORT) + #if BOTH(ARDUINO_ARCH_STM32F1, SDIO_SUPPORT) // STM32 requires a word-aligned buffer for SD card transfers via DMA static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {}; #else From 8bf6b190ff074ae9aa76734389cf7612a1e0fb0c Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Thu, 25 Mar 2021 04:56:48 +0100 Subject: [PATCH 110/311] Optimize LSF for size, efficiency (#21443) --- Marlin/src/libs/least_squares_fit.cpp | 26 +++++++++++++------------- Marlin/src/libs/least_squares_fit.h | 4 +--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Marlin/src/libs/least_squares_fit.cpp b/Marlin/src/libs/least_squares_fit.cpp index c7593c049f..aac21c0192 100644 --- a/Marlin/src/libs/least_squares_fit.cpp +++ b/Marlin/src/libs/least_squares_fit.cpp @@ -46,23 +46,23 @@ int finish_incremental_LSF(struct linear_fit_data *lsf) { if (N == 0.0) return 1; - lsf->xbar /= N; - lsf->ybar /= N; - lsf->zbar /= N; - lsf->x2bar = lsf->x2bar / N - sq(lsf->xbar); - lsf->y2bar = lsf->y2bar / N - sq(lsf->ybar); - lsf->z2bar = lsf->z2bar / N - sq(lsf->zbar); - lsf->xybar = lsf->xybar / N - lsf->xbar * lsf->ybar; - lsf->yzbar = lsf->yzbar / N - lsf->ybar * lsf->zbar; - lsf->xzbar = lsf->xzbar / N - lsf->xbar * lsf->zbar; - const float DD = lsf->x2bar * lsf->y2bar - sq(lsf->xybar); + const float RN = 1.0f / N, + xbar = lsf->xbar * RN, + ybar = lsf->ybar * RN, + zbar = lsf->zbar * RN, + x2bar = lsf->x2bar * RN - sq(xbar), + y2bar = lsf->y2bar * RN - sq(ybar), + xybar = lsf->xybar * RN - xbar * ybar, + yzbar = lsf->yzbar * RN - ybar * zbar, + xzbar = lsf->xzbar * RN - xbar * zbar, + DD = x2bar * y2bar - sq(xybar); if (ABS(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy)) return 1; - lsf->A = (lsf->yzbar * lsf->xybar - lsf->xzbar * lsf->y2bar) / DD; - lsf->B = (lsf->xzbar * lsf->xybar - lsf->yzbar * lsf->x2bar) / DD; - lsf->D = -(lsf->zbar + lsf->A * lsf->xbar + lsf->B * lsf->ybar); + lsf->A = (yzbar * xybar - xzbar * y2bar) / DD; + lsf->B = (xzbar * xybar - yzbar * x2bar) / DD; + lsf->D = -(zbar + lsf->A * xbar + lsf->B * ybar); return 0; } diff --git a/Marlin/src/libs/least_squares_fit.h b/Marlin/src/libs/least_squares_fit.h index 44ca8afc76..dbbab0a55e 100644 --- a/Marlin/src/libs/least_squares_fit.h +++ b/Marlin/src/libs/least_squares_fit.h @@ -37,7 +37,7 @@ struct linear_fit_data { float xbar, ybar, zbar, - x2bar, y2bar, z2bar, + x2bar, y2bar, xybar, xzbar, yzbar, max_absx, max_absy, A, B, D, N; @@ -56,7 +56,6 @@ inline void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const lsf->zbar += wz; lsf->x2bar += wx * x; lsf->y2bar += wy * y; - lsf->z2bar += wz * z; lsf->xybar += wx * y; lsf->xzbar += wx * z; lsf->yzbar += wy * z; @@ -74,7 +73,6 @@ inline void incremental_LSF(struct linear_fit_data *lsf, const float &x, const f lsf->zbar += z; lsf->x2bar += sq(x); lsf->y2bar += sq(y); - lsf->z2bar += sq(z); lsf->xybar += x * y; lsf->xzbar += x * z; lsf->yzbar += y * z; From 84b961cb20a4f0b2c1ad67a71d6c507a12f9da2a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 25 Mar 2021 16:19:03 -0500 Subject: [PATCH 111/311] Define HW serial ports needed for TMC UART (#21446) --- Marlin/src/HAL/DUE/HAL.cpp | 8 +- Marlin/src/HAL/DUE/MarlinSerial.h | 2 +- Marlin/src/HAL/LPC1768/MarlinSerial.cpp | 19 ++-- Marlin/src/HAL/LPC1768/inc/SanityCheck.h | 8 +- Marlin/src/HAL/SAMD51/HAL.cpp | 10 +- Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp | 6 +- Marlin/src/HAL/STM32/MarlinSerial.cpp | 4 - Marlin/src/inc/Conditionals_adv.h | 6 -- Marlin/src/inc/Conditionals_post.h | 106 +++++++++++++++++++ buildroot/share/extras/header.h | 2 +- 10 files changed, 134 insertions(+), 37 deletions(-) diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp index 0e4caa47ac..249535723f 100644 --- a/Marlin/src/HAL/DUE/HAL.cpp +++ b/Marlin/src/HAL/DUE/HAL.cpp @@ -106,16 +106,16 @@ uint16_t HAL_adc_get_result() { } // Forward the default serial ports -#if ANY_SERIAL_IS(0) +#if USING_HW_SERIAL0 DefaultSerial1 MSerial0(false, Serial); #endif -#if ANY_SERIAL_IS(1) +#if USING_HW_SERIAL1 DefaultSerial2 MSerial1(false, Serial1); #endif -#if ANY_SERIAL_IS(2) +#if USING_HW_SERIAL2 DefaultSerial3 MSerial2(false, Serial2); #endif -#if ANY_SERIAL_IS(3) +#if USING_HW_SERIAL3 DefaultSerial4 MSerial3(false, Serial3); #endif diff --git a/Marlin/src/HAL/DUE/MarlinSerial.h b/Marlin/src/HAL/DUE/MarlinSerial.h index e74d234b4a..0fb15cf8ad 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.h +++ b/Marlin/src/HAL/DUE/MarlinSerial.h @@ -140,7 +140,7 @@ struct MarlinSerialCfg { static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED); }; -#if SERIAL_PORT >= 0 +#if defined(SERIAL_PORT) && SERIAL_PORT >= 0 typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT; extern MSerialT customizedSerial1; #endif diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp index be42c7f960..f35328d22f 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp @@ -21,25 +21,26 @@ */ #ifdef TARGET_LPC1768 -#include "../../inc/MarlinConfigPre.h" #include "MarlinSerial.h" -#if ANY_SERIAL_IS(0) +#include "../../inc/MarlinConfig.h" + +#if USING_HW_SERIAL0 MarlinSerial _MSerial(LPC_UART0); MSerialT MSerial0(true, _MSerial); extern "C" void UART0_IRQHandler() { _MSerial.IRQHandler(); } #endif -#if ANY_SERIAL_IS(1) +#if USING_HW_SERIAL1 MarlinSerial _MSerial1((LPC_UART_TypeDef *) LPC_UART1); MSerialT MSerial1(true, _MSerial1); extern "C" void UART1_IRQHandler() { _MSerial1.IRQHandler(); } #endif -#if ANY_SERIAL_IS(2) +#if USING_HW_SERIAL2 MarlinSerial _MSerial2(LPC_UART2); MSerialT MSerial2(true, _MSerial2); extern "C" void UART2_IRQHandler() { _MSerial2.IRQHandler(); } #endif -#if ANY_SERIAL_IS(3) +#if USING_HW_SERIAL3 MarlinSerial _MSerial3(LPC_UART3); MSerialT MSerial3(true, _MSerial3); extern "C" void UART3_IRQHandler() { _MSerial3.IRQHandler(); } @@ -50,16 +51,16 @@ bool MarlinSerial::recv_callback(const char c) { // Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro) if (false) {} - #if ANY_SERIAL_IS(0) + #if USING_HW_SERIAL0 else if (this == &_MSerial) emergency_parser.update(MSerial0.emergency_state, c); #endif - #if ANY_SERIAL_IS(1) + #if USING_HW_SERIAL1 else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c); #endif - #if ANY_SERIAL_IS(2) + #if USING_HW_SERIAL2 else if (this == &_MSerial2) emergency_parser.update(MSerial2.emergency_state, c); #endif - #if ANY_SERIAL_IS(3) + #if USING_HW_SERIAL3 else if (this == &_MSerial3) emergency_parser.update(MSerial3.emergency_state, c); #endif return true; diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index dda1c640fa..a6286ba6f4 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 ANY_SERIAL_IS(0) +#if USING_HW_SERIAL0 #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 ANY_SERIAL_IS(1) +#if USING_HW_SERIAL1 #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 ANY_SERIAL_IS(2) +#if USING_HW_SERIAL2 #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 ANY_SERIAL_IS(3) +#if USING_HW_SERIAL3 #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/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index 8dd2fefd0a..39167fc467 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -25,19 +25,19 @@ #include #ifdef ADAFRUIT_GRAND_CENTRAL_M4 - #if ANY_SERIAL_IS(-1) + #if USING_HW_SERIALUSB DefaultSerial1 MSerial0(false, Serial); #endif - #if ANY_SERIAL_IS(0) + #if USING_HW_SERIAL0 DefaultSerial2 MSerial1(false, Serial1); #endif - #if ANY_SERIAL_IS(1) + #if USING_HW_SERIAL1 DefaultSerial3 MSerial2(false, Serial2); #endif - #if ANY_SERIAL_IS(2) + #if USING_HW_SERIAL2 DefaultSerial4 MSerial3(false, Serial3); #endif - #if ANY_SERIAL_IS(3) + #if USING_HW_SERIAL3 DefaultSerial5 MSerial4(false, Serial4); #endif #endif diff --git a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp index 3f43585cf2..a16ea2f758 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 ANY_SERIAL_IS(1) +#if USING_HW_SERIAL1 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 ANY_SERIAL_IS(2) +#if USING_HW_SERIAL2 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 ANY_SERIAL_IS(3) +#if USING_HW_SERIAL3 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/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp index cfb13f5bb5..132c602a0c 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp @@ -28,7 +28,6 @@ #ifndef USART4 #define USART4 UART4 #endif - #ifndef USART5 #define USART5 UART5 #endif @@ -43,15 +42,12 @@ #if defined(SERIAL_PORT) && SERIAL_PORT >= 0 DECLARE_SERIAL_PORT_EXP(SERIAL_PORT) #endif - #if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2) #endif - #if defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT >= 0 DECLARE_SERIAL_PORT_EXP(MMU2_SERIAL_PORT) #endif - #if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0 DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT) #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 5ef0efa968..2177dc4861 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -530,12 +530,6 @@ #define NEED_LSF 1 #endif -// Flag the indexed serial ports that are in use -#define ANY_SERIAL_IS(N) (defined(SERIAL_PORT) && SERIAL_PORT == (N)) || \ - (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || \ - (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == (N)) || \ - (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N)) - #if BOTH(HAS_TFT_LVGL_UI, CUSTOM_MENU_MAIN) #define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N)) #define HAS_USER_ITEM(V...) DO(HAS,||,V) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 1cd7e5f0e9..84e9cf8955 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1838,6 +1838,112 @@ #define HAS_TMC_SW_SERIAL 1 #endif +// +// Set USING_HW_SERIALn flags for used Serial Ports +// + +// ... HW_SerialX +#define _SERIAL_ID(P) _CAT(HW_,P) + +// ... (HW_Serial1 == HW_SerialX || HW_Serial1 == HW_MSerialX) +#define _TMC_UART_IS(P,N) ( _SERIAL_ID(P##_HARDWARE_SERIAL) == _SERIAL_ID(Serial##N) || _SERIAL_ID(P) == _SERIAL_ID(MSerial##N) ) +#define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && _TMC_UART_IS(A, N)) + +// Flag the indexed hardware serial ports in use +#define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \ + || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \ + || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \ + || (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == N) ) + +// Flag the named hardware serial ports in use +#define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \ + || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \ + || TMC_UART_IS(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \ + || TMC_UART_IS(E0, N) || TMC_UART_IS(E1, N) || TMC_UART_IS(E2, N) || TMC_UART_IS(E3, N) || TMC_UART_IS(E4, N) ) + +#define HW_Serial 501 +#define HW_Serial0 502 +#define HW_Serial1 503 +#define HW_Serial2 504 +#define HW_Serial3 505 +#define HW_Serial4 506 +#define HW_Serial5 507 +#define HW_Serial6 508 +#define HW_MSerial0 509 +#define HW_MSerial1 510 +#define HW_MSerial2 511 +#define HW_MSerial3 512 +#define HW_MSerial4 513 +#define HW_MSerial5 514 +#define HW_MSerial6 515 +#define HW_MSerial7 516 +#define HW_MSerial8 517 +#define HW_MSerial9 518 +#define HW_MSerial10 519 + +#if CONF_SERIAL_IS(-1) + #define USING_HW_SERIALUSB 1 +#endif +#if ANY_SERIAL_IS(0) + #define USING_HW_SERIAL0 1 +#endif +#if ANY_SERIAL_IS(1) + #define USING_HW_SERIAL1 1 +#endif +#if ANY_SERIAL_IS(2) + #define USING_HW_SERIAL2 1 +#endif +#if ANY_SERIAL_IS(3) + #define USING_HW_SERIAL3 1 +#endif +#if ANY_SERIAL_IS(4) + #define USING_HW_SERIAL4 1 +#endif +#if ANY_SERIAL_IS(5) + #define USING_HW_SERIAL5 1 +#endif +#if ANY_SERIAL_IS(6) + #define USING_HW_SERIAL6 1 +#endif +#if ANY_SERIAL_IS(7) + #define USING_HW_SERIAL7 1 +#endif +#if ANY_SERIAL_IS(8) + #define USING_HW_SERIAL8 1 +#endif +#if ANY_SERIAL_IS(9) + #define USING_HW_SERIAL9 1 +#endif +#if ANY_SERIAL_IS(10) + #define USING_HW_SERIAL10 1 +#endif + +#undef HW_Serial +#undef HW_Serial0 +#undef HW_Serial1 +#undef HW_Serial2 +#undef HW_Serial3 +#undef HW_Serial4 +#undef HW_Serial5 +#undef HW_Serial6 +#undef HW_MSerial0 +#undef HW_MSerial1 +#undef HW_MSerial2 +#undef HW_MSerial3 +#undef HW_MSerial4 +#undef HW_MSerial5 +#undef HW_MSerial6 +#undef HW_MSerial7 +#undef HW_MSerial8 +#undef HW_MSerial9 +#undef HW_MSerial10 + +#undef _SERIAL_ID +#undef _TMC_UART_IS +#undef TMC_UART_IS +#undef CONF_SERIAL_IS +#undef ANY_SERIAL_IS + // // Endstops and bed probe // diff --git a/buildroot/share/extras/header.h b/buildroot/share/extras/header.h index 5d2c73dfbe..e40471dfac 100644 --- a/buildroot/share/extras/header.h +++ b/buildroot/share/extras/header.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm From 704b8cd83c507675d6f71621e1c35172779ac9d1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 25 Mar 2021 16:49:04 -0500 Subject: [PATCH 112/311] Apply TMC UART to STM32, simplify --- Marlin/src/HAL/DUE/MarlinSerial.cpp | 2 +- Marlin/src/HAL/STM32/MarlinSerial.cpp | 39 ++++++++++++++++++++------- Marlin/src/inc/Conditionals_post.h | 8 +----- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Marlin/src/HAL/DUE/MarlinSerial.cpp b/Marlin/src/HAL/DUE/MarlinSerial.cpp index 50b84c0b1d..5b333fbeb5 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerial.cpp @@ -476,7 +476,7 @@ void MarlinSerial::flushTX() { // If not using the USB port as serial port -#if SERIAL_PORT >= 0 +#if defined(SERIAL_PORT) && SERIAL_PORT >= 0 template class MarlinSerial< MarlinSerialCfg >; MSerialT customizedSerial1(MarlinSerialCfg::EMERGENCYPARSER); #endif diff --git a/Marlin/src/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp index 132c602a0c..265e8b5ab6 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp @@ -37,19 +37,38 @@ MSerialT MSerial ## ser_num (true, USART ## ser_num, &_rx_complete_irq_ ## ser_num); \ void _rx_complete_irq_ ## ser_num (serial_t * obj) { MSerial ## ser_num ._rx_complete_irq(obj); } -#define DECLARE_SERIAL_PORT_EXP(ser_num) DECLARE_SERIAL_PORT(ser_num) - -#if defined(SERIAL_PORT) && SERIAL_PORT >= 0 - DECLARE_SERIAL_PORT_EXP(SERIAL_PORT) +#if USING_HW_SERIAL1 + DECLARE_SERIAL_PORT(1) #endif -#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 - DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2) +#if USING_HW_SERIAL2 + DECLARE_SERIAL_PORT(2) #endif -#if defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT >= 0 - DECLARE_SERIAL_PORT_EXP(MMU2_SERIAL_PORT) +#if USING_HW_SERIAL3 + DECLARE_SERIAL_PORT(3) #endif -#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0 - DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT) +#if USING_HW_SERIAL4 + DECLARE_SERIAL_PORT(4) +#endif +#if USING_HW_SERIAL5 + DECLARE_SERIAL_PORT(5) +#endif +#if USING_HW_SERIAL6 + DECLARE_SERIAL_PORT(6) +#endif +#if USING_HW_SERIAL7 + DECLARE_SERIAL_PORT(7) +#endif +#if USING_HW_SERIAL8 + DECLARE_SERIAL_PORT(8) +#endif +#if USING_HW_SERIAL9 + DECLARE_SERIAL_PORT(9) +#endif +#if USING_HW_SERIAL10 + DECLARE_SERIAL_PORT(10) +#endif +#if USING_HW_SERIALLP1 + DECLARE_SERIAL_PORT(LP1) #endif void MarlinSerial::begin(unsigned long baud, uint8_t config) { diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 84e9cf8955..2433050528 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1842,13 +1842,6 @@ // Set USING_HW_SERIALn flags for used Serial Ports // -// ... HW_SerialX -#define _SERIAL_ID(P) _CAT(HW_,P) - -// ... (HW_Serial1 == HW_SerialX || HW_Serial1 == HW_MSerialX) -#define _TMC_UART_IS(P,N) ( _SERIAL_ID(P##_HARDWARE_SERIAL) == _SERIAL_ID(Serial##N) || _SERIAL_ID(P) == _SERIAL_ID(MSerial##N) ) -#define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && _TMC_UART_IS(A, N)) - // Flag the indexed hardware serial ports in use #define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \ || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \ @@ -1856,6 +1849,7 @@ || (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == N) ) // Flag the named hardware serial ports in use +#define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N)) #define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \ || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \ || TMC_UART_IS(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \ From 8a67846872d1748611c0a32a246310df7ffc4d6a Mon Sep 17 00:00:00 2001 From: Tomas Rimkus Date: Fri, 26 Mar 2021 01:16:45 +0100 Subject: [PATCH 113/311] Avoid watchdog reset in all wired EEPROMs (#21436) Co-authored-by: Scott Lahteine --- Marlin/src/HAL/AVR/eeprom.cpp | 6 +++--- Marlin/src/HAL/DUE/eeprom_flash.cpp | 7 +++---- Marlin/src/HAL/DUE/eeprom_wired.cpp | 7 +++---- Marlin/src/HAL/LPC1768/eeprom_wired.cpp | 12 ++++-------- Marlin/src/HAL/SAMD51/eeprom_wired.cpp | 5 +++-- Marlin/src/HAL/STM32/eeprom_wired.cpp | 11 ++++------- Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp | 9 +++------ Marlin/src/HAL/STM32F1/eeprom_wired.cpp | 6 +++--- Marlin/src/HAL/TEENSY31_32/eeprom.cpp | 14 +++++++------- Marlin/src/HAL/TEENSY35_36/eeprom.cpp | 6 +++--- Marlin/src/HAL/TEENSY40_41/eeprom.cpp | 14 +++++++------- 11 files changed, 43 insertions(+), 54 deletions(-) diff --git a/Marlin/src/HAL/AVR/eeprom.cpp b/Marlin/src/HAL/AVR/eeprom.cpp index ee2a73e410..8d084dec7f 100644 --- a/Marlin/src/HAL/AVR/eeprom.cpp +++ b/Marlin/src/HAL/AVR/eeprom.cpp @@ -40,13 +40,13 @@ bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t * const p = (uint8_t * const)pos; uint8_t v = *value; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; diff --git a/Marlin/src/HAL/DUE/eeprom_flash.cpp b/Marlin/src/HAL/DUE/eeprom_flash.cpp index 209a5161ae..738f44acc9 100644 --- a/Marlin/src/HAL/DUE/eeprom_flash.cpp +++ b/Marlin/src/HAL/DUE/eeprom_flash.cpp @@ -976,14 +976,13 @@ bool PersistentStore::access_start() { ee_Init(); return true; } bool PersistentStore::access_finish() { ee_Flush(); return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t * const p = (uint8_t * const)pos; uint8_t v = *value; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != ee_Read(uint32_t(p))) { + if (v != ee_Read(uint32_t(p))) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! ee_Write(uint32_t(p), v); - delay(2); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (ee_Read(uint32_t(p)) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; diff --git a/Marlin/src/HAL/DUE/eeprom_wired.cpp b/Marlin/src/HAL/DUE/eeprom_wired.cpp index b488c36f16..557a2f2cff 100644 --- a/Marlin/src/HAL/DUE/eeprom_wired.cpp +++ b/Marlin/src/HAL/DUE/eeprom_wired.cpp @@ -42,14 +42,13 @@ bool PersistentStore::access_start() { eeprom_init(); return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t * const p = (uint8_t * const)pos; uint8_t v = *value; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); - delay(2); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; diff --git a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp b/Marlin/src/HAL/LPC1768/eeprom_wired.cpp index d94aba6119..f9286a74ac 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_wired.cpp @@ -42,25 +42,22 @@ bool PersistentStore::access_start() { eeprom_init(); return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t v = *value; - - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! uint8_t * const p = (uint8_t * const)pos; - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; } } - crc16(crc, &v, 1); pos++; value++; - }; - + } return false; } @@ -68,7 +65,6 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t do { // Read from external EEPROM const uint8_t c = eeprom_read_byte((uint8_t*)pos); - if (writing) *value = c; crc16(crc, &c, 1); pos++; diff --git a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp index d9a0225a7a..3481fe539c 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp @@ -41,12 +41,13 @@ bool PersistentStore::access_start() { eeprom_init(); return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { const uint8_t v = *value; uint8_t * const p = (uint8_t * const)pos; - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); - delay(2); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; diff --git a/Marlin/src/HAL/STM32/eeprom_wired.cpp b/Marlin/src/HAL/STM32/eeprom_wired.cpp index ad54c12c47..6aa2f1d360 100644 --- a/Marlin/src/HAL/STM32/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32/eeprom_wired.cpp @@ -43,25 +43,22 @@ bool PersistentStore::access_start() { eeprom_init(); return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t v = *value; - - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! uint8_t * const p = (uint8_t * const)pos; - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; } } - crc16(crc, &v, 1); pos++; value++; - }; - + } return false; } diff --git a/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp b/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp index a6395698aa..4e25bc69da 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp @@ -19,14 +19,13 @@ * along with this program. If not, see . * */ +#ifdef __STM32F1__ /** * PersistentStore for Arduino-style EEPROM interface * with simple implementations supplied by Marlin. */ -#ifdef __STM32F1__ - #include "../../inc/MarlinConfig.h" #if ENABLED(IIC_BL24CXX_EEPROM) @@ -48,13 +47,11 @@ bool PersistentStore::access_start() { eeprom_init(); return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { - size_t written = 0; + uint16_t written = 0; while (size--) { uint8_t v = *value; uint8_t * const p = (uint8_t * const)pos; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { diff --git a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp b/Marlin/src/HAL/STM32F1/eeprom_wired.cpp index 16cfc24af6..0ad69065cf 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_wired.cpp @@ -52,13 +52,13 @@ bool PersistentStore::access_start() { } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t * const p = (uint8_t * const)pos; uint8_t v = *value; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; diff --git a/Marlin/src/HAL/TEENSY31_32/eeprom.cpp b/Marlin/src/HAL/TEENSY31_32/eeprom.cpp index f2ae5dd534..85febebebc 100644 --- a/Marlin/src/HAL/TEENSY31_32/eeprom.cpp +++ b/Marlin/src/HAL/TEENSY31_32/eeprom.cpp @@ -18,14 +18,14 @@ */ #ifdef __MK20DX256__ -#include "../../inc/MarlinConfig.h" - -#if USE_WIRED_EEPROM - /** * HAL PersistentStore for Teensy 3.2 (MK20DX256) */ +#include "../../inc/MarlinConfig.h" + +#if USE_WIRED_EEPROM + #include "../shared/eeprom_api.h" #include @@ -38,13 +38,13 @@ bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t * const p = (uint8_t * const)pos; uint8_t v = *value; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; diff --git a/Marlin/src/HAL/TEENSY35_36/eeprom.cpp b/Marlin/src/HAL/TEENSY35_36/eeprom.cpp index 8cd6b4ff41..b80e93b536 100644 --- a/Marlin/src/HAL/TEENSY35_36/eeprom.cpp +++ b/Marlin/src/HAL/TEENSY35_36/eeprom.cpp @@ -42,13 +42,13 @@ bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t * const p = (uint8_t * const)pos; uint8_t v = *value; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; diff --git a/Marlin/src/HAL/TEENSY40_41/eeprom.cpp b/Marlin/src/HAL/TEENSY40_41/eeprom.cpp index fe2de388a7..3cd376edce 100644 --- a/Marlin/src/HAL/TEENSY40_41/eeprom.cpp +++ b/Marlin/src/HAL/TEENSY40_41/eeprom.cpp @@ -22,14 +22,14 @@ */ #ifdef __IMXRT1062__ -#include "../../inc/MarlinConfig.h" - -#if USE_WIRED_EEPROM - /** * HAL PersistentStore for Teensy 4.0 (IMXRT1062DVL6A) / 4.1 (IMXRT1062DVJ6A) */ +#include "../../inc/MarlinConfig.h" + +#if USE_WIRED_EEPROM + #include "../shared/eeprom_api.h" #include @@ -42,13 +42,13 @@ bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; while (size--) { uint8_t * const p = (uint8_t * const)pos; uint8_t v = *value; - // EEPROM has only ~100,000 write cycles, - // so only write bytes that have changed! - if (v != eeprom_read_byte(p)) { + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true; From c55d53daa649c93d71a314726fd287c056975a23 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 26 Mar 2021 00:31:14 +0000 Subject: [PATCH 114/311] [cron] Bump distribution date (2021-03-26) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 8ed540d0f6..08ded6d031 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-03-25" + #define STRING_DISTRIBUTION_DATE "2021-03-26" #endif /** From 241d2e3fa38aad0396d29a339def244bc23ea47b Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Thu, 25 Mar 2021 21:44:35 -0400 Subject: [PATCH 115/311] Fix for YHCB2004 (#21450) --- Marlin/src/pins/mega/pins_GT2560_V3.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/mega/pins_GT2560_V3.h b/Marlin/src/pins/mega/pins_GT2560_V3.h index 65642464d9..11824fae4a 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3.h @@ -158,12 +158,15 @@ #if ENABLED(YHCB2004) #ifndef YHCB2004_CLK #define YHCB2004_CLK 5 + #define DIO52 YHCB2004_CLK #endif #ifndef YHCB2004_MOSI - #define YHCB2004_MOSI 21 + #define YHCB2004_MOSI 36 + #define DIO51 YHCB2004_MOSI #endif #ifndef YHCB2004_MISO - #define YHCB2004_MISO 36 + #define YHCB2004_MISO 21 + #define DIO50 YHCB2004_MISO #endif #elif HAS_WIRED_LCD #ifndef LCD_PINS_RS @@ -206,4 +209,4 @@ #ifndef BTN_ENC #define BTN_ENC 19 #endif -#endif +#endif \ No newline at end of file From 532df198da6a9cadb441a1993b4b482e69e317ce Mon Sep 17 00:00:00 2001 From: Leoric Date: Fri, 26 Mar 2021 23:41:55 +0300 Subject: [PATCH 116/311] MKS UI: Monitor state when idle (#21452) Co-authored-by: Scott Lahteine --- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 7 + Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h | 5 - .../lcd/extui/lib/mks_ui/draw_printing.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 184 ++++++++++++------ .../extui/lib/mks_ui/tft_multi_language.cpp | 6 +- .../lcd/extui/lib/mks_ui/tft_multi_language.h | 1 + 6 files changed, 141 insertions(+), 64 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index 3fed4cc385..c4ae6e221d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -65,6 +65,13 @@ extern uint32_t upload_time; extern uint32_t upload_size; extern bool temps_update_flag; +//#define CANCEL_ON_RIGHT // Put 'Cancel' on the right (as it was before) + +#define BTN_OK_X TERN(CANCEL_ON_RIGHT, 100, 280) +#define BTN_CANCEL_X TERN(CANCEL_ON_RIGHT, 280, 100) +#define BTN_OK_Y 180 +#define BTN_CANCEL_Y 180 + static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; if (DIALOG_IS(TYPE_PRINT_FILE)) { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h index c43a79a141..38f5fa0635 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h @@ -74,11 +74,6 @@ enum { DIALOG_TRANSFER_NO_DEVICE }; -#define BTN_OK_X 100 -#define BTN_OK_Y 180 -#define BTN_CANCEL_X 280 -#define BTN_CANCEL_Y 180 - extern void lv_draw_dialog(uint8_t type); extern void lv_clear_dialog(); extern void filament_sprayer_temp(); 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 e9e501ae5f..70c57f4af8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -222,7 +222,7 @@ void disp_bed_temp() { } void disp_fan_speed() { - sprintf_P(public_buf_l, PSTR("%3d"), thermalManager.fan_speed[0]); + sprintf_P(public_buf_l, PSTR("%d%%"), thermalManager.fanPercent(thermalManager.fan_speed[0])); lv_label_set_text(labelFan, public_buf_l); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 7554f746ca..acdfa24f1b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -42,32 +42,36 @@ #include +#define ICON_POS_Y 38 +#define TARGET_LABEL_MOD_Y -36 +#define LABEL_MOD_Y 30 +#define SECOND_EXT_MOD_Y 100 + extern lv_group_t* g; static lv_obj_t *scr; +static lv_obj_t *labelExt1, *labelExt1Target, *labelFan; + +#if HAS_MULTI_EXTRUDER + static lv_obj_t *labelExt2, *labelExt2Target; +#endif + +#if HAS_HEATED_BED + static lv_obj_t *labelBed, *labelBedTarget; +#endif + #if ENABLED(MKS_TEST) uint8_t curent_disp_ui = 0; #endif -enum { - ID_TOOL = 1, - ID_SET, - ID_PRINT -}; +enum { ID_TOOL = 1, ID_SET, ID_PRINT }; static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; lv_clear_ready_print(); - switch (obj->mks_obj_id) { - case ID_TOOL: - lv_draw_tool(); - break; - case ID_SET: - lv_draw_set(); - break; - case ID_PRINT: - lv_draw_print_file(); - break; + case ID_TOOL: lv_draw_tool(); break; + case ID_SET: lv_draw_set(); break; + case ID_PRINT: lv_draw_print_file(); break; } } @@ -98,14 +102,14 @@ void disp_det_error() { lv_obj_t *e1, *e2, *e3, *bed; void mks_disp_test() { char buf[30] = {0}; - sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("e1:%d"), thermalManager.degHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND - sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("e2:%d"), thermalManager.degHotend(1)); lv_label_set_text(e2, buf); #endif #if HAS_HEATED_BED - sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.temp_bed.celsius); + sprintf_P(buf, PSTR("bed:%d"), thermalManager.degBed()); lv_label_set_text(bed, buf); #endif } @@ -130,53 +134,123 @@ void lv_draw_ready_print() { lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); } - #if 1 - e1 = lv_label_create_empty(scr); - lv_obj_set_pos(e1, 20, 20); - sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(0)); - lv_label_set_text(e1, buf); - #if HAS_MULTI_HOTEND - e2 = lv_label_create_empty(scr); - lv_obj_set_pos(e2, 20, 45); - sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(1)); - lv_label_set_text(e2, buf); - #endif + e1 = lv_label_create_empty(scr); + lv_obj_set_pos(e1, 20, 20); + sprintf_P(buf, PSTR("e1: %d"), thermalManager.degHotend(0)); + lv_label_set_text(e1, buf); - #if HAS_HEATED_BED - bed = lv_label_create_empty(scr); - lv_obj_set_pos(bed, 20, 95); - sprintf_P(buf, PSTR("bed: %d"), (int)thermalManager.temp_bed.celsius); - lv_label_set_text(bed, buf); - #endif + #if HAS_MULTI_HOTEND + e2 = lv_label_create_empty(scr); + lv_obj_set_pos(e2, 20, 45); + sprintf_P(buf, PSTR("e1: %d"), thermalManager.degHotend(1)); + lv_label_set_text(e2, buf); + #endif - limit_info = lv_label_create_empty(scr); + #if HAS_HEATED_BED + bed = lv_label_create_empty(scr); + lv_obj_set_pos(bed, 20, 95); + sprintf_P(buf, PSTR("bed: %d"), thermalManager.degBed()); + lv_label_set_text(bed, buf); + #endif - lv_style_copy(&limit_style, &lv_style_scr); - limit_style.body.main_color.full = 0x0000; - limit_style.body.grad_color.full = 0x0000; - limit_style.text.color.full = 0xffff; - lv_obj_set_style(limit_info, &limit_style); + limit_info = lv_label_create_empty(scr); - lv_obj_set_pos(limit_info, 20, 120); - lv_label_set_text(limit_info, " "); + lv_style_copy(&limit_style, &lv_style_scr); + limit_style.body.main_color.full = 0x0000; + limit_style.body.grad_color.full = 0x0000; + limit_style.text.color.full = 0xFFFF; + lv_obj_set_style(limit_info, &limit_style); - det_info = lv_label_create_empty(scr); + lv_obj_set_pos(limit_info, 20, 120); + lv_label_set_text(limit_info, " "); - lv_style_copy(&det_style, &lv_style_scr); - det_style.body.main_color.full = 0x0000; - det_style.body.grad_color.full = 0x0000; - det_style.text.color.full = 0xffff; - lv_obj_set_style(det_info, &det_style); + det_info = lv_label_create_empty(scr); - lv_obj_set_pos(det_info, 20, 145); - lv_label_set_text(det_info, " "); - #endif // if 1 + lv_style_copy(&det_style, &lv_style_scr); + det_style.body.main_color.full = 0x0000; + det_style.body.grad_color.full = 0x0000; + det_style.text.color.full = 0xFFFF; + lv_obj_set_style(det_info, &det_style); + lv_obj_set_pos(det_info, 20, 145); + lv_label_set_text(det_info, " "); } else { - lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 90, event_handler, ID_TOOL); - lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 90, event_handler, ID_SET); - lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 90, event_handler, ID_PRINT); + lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 180, event_handler, ID_TOOL); + lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 180, event_handler, ID_SET); + lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 180, event_handler, ID_PRINT); + + // Monitoring + lv_obj_t *buttonExt1 = lv_img_create(scr, NULL); + #if HAS_MULTI_EXTRUDER + lv_obj_t *buttonExt2 = lv_img_create(scr, NULL); + #endif + #if HAS_HEATED_BED + lv_obj_t *buttonBedstate = lv_img_create(scr, NULL); + #endif + lv_obj_t *buttonFanstate = lv_img_create(scr, NULL); + + lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin"); + #if HAS_MULTI_EXTRUDER + lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin"); + #endif + #if HAS_HEATED_BED + lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin"); + #endif + lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin"); + + lv_obj_set_pos(buttonExt1, 55, ICON_POS_Y); + #if HAS_MULTI_EXTRUDER + lv_obj_set_pos(buttonExt2, 55, ICON_POS_Y + SECOND_EXT_MOD_Y); + #endif + #if HAS_HEATED_BED + lv_obj_set_pos(buttonBedstate, 210, ICON_POS_Y); + #endif + lv_obj_set_pos(buttonFanstate, 380, ICON_POS_Y); + + labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); + labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); + + #if HAS_MULTI_EXTRUDER + labelExt2 = lv_label_create(scr, 55, LABEL_MOD_Y + SECOND_EXT_MOD_Y, nullptr); + labelExt2Target = lv_label_create(scr, 55, LABEL_MOD_Y + SECOND_EXT_MOD_Y, nullptr); + #endif + + #if HAS_HEATED_BED + labelBed = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr); + labelBedTarget = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr); + #endif + + labelFan = lv_label_create(scr, 380, 80, nullptr); + + sprintf_P(buf, PSTR("%d"), thermalManager.degHotend(0)); + lv_label_set_text(labelExt1, buf); + lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); + sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(0)); + lv_label_set_text(labelExt1Target, buf); + lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); + + #if HAS_MULTI_EXTRUDER + sprintf_P(buf, PSTR("%d"), thermalManager.degHotend(1)); + lv_label_set_text(labelExt2, buf); + lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); + sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(1)); + lv_label_set_text(labelExt2Target, buf); + lv_obj_align(labelExt2Target, buttonExt2, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); + #endif + + #if HAS_HEATED_BED + sprintf_P(buf, PSTR("%d"), thermalManager.degBed()); + lv_label_set_text(labelBed, buf); + lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); + sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetBed()); + lv_label_set_text(labelBedTarget, buf); + lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); + #endif + + sprintf_P(buf, PSTR("%d%%"), thermalManager.fanPercent(thermalManager.fan_speed[0])); + lv_label_set_text(labelFan, buf); + lv_obj_align(labelFan, buttonFanstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); } #if ENABLED(TOUCH_SCREEN_CALIBRATION) 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 7caae5cd3a..20b7d5f606 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 @@ -815,9 +815,9 @@ void disp_language_init() { wifi_menu.disconnected = WIFI_DISCONNECTED_TEXT; wifi_menu.exception = WIFI_EXCEPTION_TEXT; - printing_menu.temp1 = TEXT_VALUE; - printing_menu.temp2 = TEXT_VALUE; - printing_menu.bed_temp = TEXT_VALUE; + printing_menu.temp1 = TEXT_VALUE_TARGET; + printing_menu.temp2 = TEXT_VALUE_TARGET; + printing_menu.bed_temp = TEXT_VALUE_TARGET; filament_menu.stat_temp = TEXT_VALUE; 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 82d3e18f74..61c46a648f 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 @@ -748,6 +748,7 @@ extern eeprom_def eeprom_menu; /*****************************************/ // #define TEXT_VALUE "%d/%d" +#define TEXT_VALUE_TARGET "%d -> %d" #define TEXT_VALUE_T ": %d℃" #define TEXT_VALUE_mm ": %dmm" From 5991836e1fdd73f7a668cfc4221bfe3017a2580d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 27 Mar 2021 00:32:48 +0000 Subject: [PATCH 117/311] [cron] Bump distribution date (2021-03-27) --- 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 08ded6d031..bfec7939bf 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-03-26" + #define STRING_DISTRIBUTION_DATE "2021-03-27" #endif /** From 5d0e6c21aa54d5b6439dfa2f57daadd2be973505 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 28 Mar 2021 00:34:16 +0000 Subject: [PATCH 118/311] [cron] Bump distribution date (2021-03-28) --- 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 bfec7939bf..d3190bb612 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-03-27" + #define STRING_DISTRIBUTION_DATE "2021-03-28" #endif /** From c45b91aa94c7008e3fd8ea297df57948af9158a3 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Sat, 27 Mar 2021 21:57:12 -0600 Subject: [PATCH 119/311] Refactor Hilbert curve. Enhance Touch UI Bed Level Screen. (#21453) --- Marlin/src/feature/bedlevel/hilbert_curve.cpp | 112 +++++++++++++ Marlin/src/feature/bedlevel/hilbert_curve.h | 32 ++++ Marlin/src/feature/bedlevel/ubl/ubl.h | 5 - Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 158 +++++++++--------- .../ftdi_eve_lib/extras/adjuster_widget.cpp | 41 ++--- .../ftdi_eve_lib/extras/adjuster_widget.h | 7 + .../ftdi_eve_touch_ui/language/language_en.h | 5 +- .../screens/bed_mesh_screen.cpp | 21 ++- .../screens/bed_mesh_screen.h | 2 + .../screens/leveling_menu.cpp | 67 +++++--- .../ftdi_eve_touch_ui/screens/tune_menu.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 31 ++-- platformio.ini | 2 + 13 files changed, 341 insertions(+), 144 deletions(-) create mode 100644 Marlin/src/feature/bedlevel/hilbert_curve.cpp create mode 100644 Marlin/src/feature/bedlevel/hilbert_curve.h diff --git a/Marlin/src/feature/bedlevel/hilbert_curve.cpp b/Marlin/src/feature/bedlevel/hilbert_curve.cpp new file mode 100644 index 0000000000..6150226e0b --- /dev/null +++ b/Marlin/src/feature/bedlevel/hilbert_curve.cpp @@ -0,0 +1,112 @@ +/********************* + * hilbert_curve.cpp * + *********************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2021 - SynDaver Labs, 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: . * + ****************************************************************************/ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(UBL_HILBERT_CURVE) + +#include "bedlevel.h" +#include "hilbert_curve.h" + +constexpr int8_t to_fix(int8_t v) { return v * 2; } +constexpr int8_t to_int(int8_t v) { return v / 2; } +constexpr uint8_t log2(uint8_t n) { return (n > 1) ? 1 + log2(n >> 1) : 0; } +constexpr uint8_t order(uint8_t n) { return uint8_t(log2(n - 1)) + 1; } +constexpr uint8_t ord = order(_MAX(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y)); +constexpr uint8_t dim = _BV(ord); + +static inline bool eval_candidate(int8_t x, int8_t y, hilbert_curve::callback_ptr func, void *data) { + // The print bed likely has fewer points than the full Hilbert + // curve, so cull unecessary points + return x < GRID_MAX_POINTS_X && y < GRID_MAX_POINTS_Y ? func(x, y, data) : false; +} + +bool hilbert_curve::hilbert(int8_t x, int8_t y, int8_t xi, int8_t xj, int8_t yi, int8_t yj, uint8_t n, hilbert_curve::callback_ptr func, void *data) { + /** + * Hilbert space-filling curve implementation + * + * x and y : coordinates of the bottom left corner + * xi and xj : i and j components of the unit x vector of the frame + * yi and yj : i and j components of the unit y vector of the frame + * + * From: http://www.fundza.com/algorithmic/space_filling/hilbert/basics/index.html + */ + if (n) + return hilbert(x, y, yi/2, yj/2, xi/2, xj/2, n-1, func, data) || + hilbert(x+xi/2, y+xj/2, xi/2, xj/2, yi/2, yj/2, n-1, func, data) || + hilbert(x+xi/2+yi/2, y+xj/2+yj/2, xi/2, xj/2, yi/2, yj/2, n-1, func, data) || + hilbert(x+xi/2+yi, y+xj/2+yj, -yi/2, -yj/2, -xi/2, -xj/2, n-1, func, data); + else + return eval_candidate(to_int(x+(xi+yi)/2), to_int(y+(xj+yj)/2), func, data); +} + +/** + * Calls func(x, y, data) for all points in the Hilbert curve. + * If that function returns true, the search is terminated. + */ +bool hilbert_curve::search(hilbert_curve::callback_ptr func, void *data) { + return hilbert(to_fix(0), to_fix(0),to_fix(dim), to_fix(0), to_fix(0), to_fix(dim), ord, func, data); +} + +/* Helper function for starting the search at a particular point */ + +typedef struct { + uint8_t x, y; + bool found_1st; + hilbert_curve::callback_ptr func; + void *data; +} search_from_t; + +static bool search_from_helper(uint8_t x, uint8_t y, void *data) { + search_from_t *d = (search_from_t *) data; + if (d->x == x && d->y == y) + d->found_1st = true; + return d->found_1st ? d->func(x, y, d->data) : false; +} + +/** + * Same as search, except start at a specific grid intersection point. + */ +bool hilbert_curve::search_from(uint8_t x, uint8_t y, hilbert_curve::callback_ptr func, void *data) { + search_from_t d; + d.x = x; + d.y = y; + d.found_1st = false; + d.func = func; + d.data = data; + // Call twice to allow search to wrap back to the beginning and picked up points prior to the start. + return search(search_from_helper, &d) || search(search_from_helper, &d); +} + +/** + * Like search_from, but takes a bed position and starts from the nearest + * point on the Hilbert curve. + */ +bool hilbert_curve::search_from_closest(const xy_pos_t &pos, hilbert_curve::callback_ptr func, void *data) { + // Find closest grid intersection + uint8_t grid_x = LROUND(float(pos.x - MESH_MIN_X) / MESH_X_DIST); + uint8_t grid_y = LROUND(float(pos.y - MESH_MIN_Y) / MESH_Y_DIST); + LIMIT(grid_x, 0, GRID_MAX_POINTS_X); + LIMIT(grid_y, 0, GRID_MAX_POINTS_Y); + return search_from(grid_x, grid_y, func, data); +} + +#endif // UBL_HILBERT_CURVE diff --git a/Marlin/src/feature/bedlevel/hilbert_curve.h b/Marlin/src/feature/bedlevel/hilbert_curve.h new file mode 100644 index 0000000000..a5dce8a22d --- /dev/null +++ b/Marlin/src/feature/bedlevel/hilbert_curve.h @@ -0,0 +1,32 @@ +/******************* + * hilbert_curve.h * + *******************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2021 - SynDaver Labs, 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 + +class hilbert_curve { + public: + typedef bool (*callback_ptr)(uint8_t x, uint8_t y, void *data); + static bool search(callback_ptr func, void *data); + static bool search_from(uint8_t x, uint8_t y, callback_ptr func, void *data); + static bool search_from_closest(const xy_pos_t &pos, callback_ptr func, void *data); + private: + static bool hilbert(int8_t x, int8_t y, int8_t xi, int8_t xj, int8_t yi, int8_t yj, uint8_t n, callback_ptr func, void *data); +}; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 67a9b0a60e..56de4e45ba 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -101,11 +101,6 @@ public: static void display_map(const int) _O0; static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0; static mesh_index_pair find_furthest_invalid_mesh_point() _O0; - #if ENABLED(UBL_HILBERT_CURVE) - static void check_if_missing(mesh_index_pair &pt, int x, int y); - static void hilbert(mesh_index_pair &pt, int8_t x, int8_t y, int8_t xi, int8_t xj, int8_t yi, int8_t yj, uint8_t n); - static mesh_index_pair find_next_mesh_point(); - #endif static void reset(); static void invalidate(); static void set_all_mesh_points_to_value(const float value); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index c1f824714c..2003e9b6f5 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -49,6 +49,10 @@ #include "../../../lcd/extui/ui_api.h" #endif +#if ENABLED(UBL_HILBERT_CURVE) + #include "../hilbert_curve.h" +#endif + #include #define UBL_G29_P31 @@ -747,11 +751,9 @@ void unified_bed_leveling::shift_mesh_height() { } #endif - best = do_furthest ? find_furthest_invalid_mesh_point() - : TERN(UBL_HILBERT_CURVE, - find_next_mesh_point(), - find_closest_mesh_point_of_type(INVALID, nearby, true) - ); + best = do_furthest + ? find_furthest_invalid_mesh_point() + : find_closest_mesh_point_of_type(INVALID, nearby, true); if (best.pos.x >= 0) { // mesh point found and is reachable by probe TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START)); @@ -1269,97 +1271,93 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { return farthest; } -mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const xy_pos_t &pos, const bool probe_relative/*=false*/, MeshFlags *done_flags/*=nullptr*/) { - mesh_index_pair closest; - closest.invalidate(); - closest.distance = -99999.9f; +#if ENABLED(UBL_HILBERT_CURVE) - // Get the reference position, either nozzle or probe - const xy_pos_t ref = probe_relative ? pos + probe.offset_xy : pos; + typedef struct { + MeshPointType type; + MeshFlags *done_flags; + bool probe_relative; + mesh_index_pair closest; + } find_closest_t; - float best_so_far = 99999.99f; - - GRID_LOOP(i, j) { - if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL)) - || (type == SET_IN_BITMAP && !done_flags->marked(i, j)) + static bool test_func(uint8_t i, uint8_t j, void *data) { + find_closest_t *d = (find_closest_t*)data; + if ( (d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL)) + || (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j)) ) { // Found a Mesh Point of the specified type! - const xy_pos_t mpos = { mesh_index_to_xpos(i), mesh_index_to_ypos(j) }; + const xy_pos_t mpos = { ubl.mesh_index_to_xpos(i), ubl.mesh_index_to_ypos(j) }; // If using the probe as the reference there are some unreachable locations. // Also for round beds, there are grid points outside the bed the nozzle can't reach. // Prune them from the list and ignore them till the next Phase (manual nozzle probing). - if (!(probe_relative ? probe.can_reach(mpos) : position_is_reachable(mpos))) - continue; - - // Reachable. Check if it's the best_so_far location to the nozzle. - - const xy_pos_t diff = current_position - mpos; - const float distance = (ref - mpos).magnitude() + diff.magnitude() * 0.1f; - - // factor in the distance from the current location for the normal case - // so the nozzle isn't running all over the bed. - if (distance < best_so_far) { - best_so_far = distance; // Found a closer location with the desired value type. - closest.pos.set(i, j); - closest.distance = best_so_far; - } - } - } // GRID_LOOP - - return closest; -} - -#if ENABLED(UBL_HILBERT_CURVE) - - constexpr int8_t to_fix(int8_t v) { return v << 1; } - constexpr int8_t to_int(int8_t v) { return v >> 1; } - constexpr uint8_t log2(uint8_t n) { return (n > 1) ? 1 + log2(n >> 1) : 0; } - constexpr uint8_t order(uint8_t n) { return uint8_t(log2(n - 1)) + 1; } - - void unified_bed_leveling::hilbert(mesh_index_pair &pt, int8_t x, int8_t y, int8_t xi, int8_t xj, int8_t yi, int8_t yj, uint8_t n) { - /* Hilbert space filling curve implementation - * - * x and y are the coordinates of the bottom left corner - * xi & xj are the i & j components of the unit x vector of the frame - * similarly yi and yj - * - * From: http://www.fundza.com/algorithmic/space_filling/hilbert/basics/index.html - */ - if (n <= 0) - check_if_missing(pt, to_int(x+(xi+yi)/2),to_int(y+(xj+yj)/2)); - else { - hilbert(pt, x, y, yi/2, yj/2, xi/2, xj/2, n-1); - hilbert(pt, x+xi/2, y+xj/2, xi/2, xj/2, yi/2, yj/2, n-1); - hilbert(pt, x+xi/2+yi/2, y+xj/2+yj/2, xi/2, xj/2, yi/2, yj/2, n-1); - hilbert(pt, x+xi/2+yi, y+xj/2+yj, -yi/2, -yj/2, -xi/2, -xj/2, n-1); + if (!(d->probe_relative ? probe.can_reach(mpos) : position_is_reachable(mpos))) + return false; + d->closest.pos.set(i, j); + return true; } + return false; } - void unified_bed_leveling::check_if_missing(mesh_index_pair &pt, int x, int y) { - if ( pt.distance < 0 - && x < GRID_MAX_POINTS_X - && y < GRID_MAX_POINTS_Y - && isnan(z_values[x][y]) - && probe.can_reach(mesh_index_to_xpos(x), mesh_index_to_ypos(y)) +#endif + +mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const xy_pos_t &pos, const bool probe_relative/*=false*/, MeshFlags *done_flags/*=nullptr*/) { + + #if ENABLED(UBL_HILBERT_CURVE) + + find_closest_t d; + d.type = type; + d.done_flags = done_flags; + d.probe_relative = probe_relative; + d.closest.invalidate(); + hilbert_curve::search_from_closest(pos, test_func, &d); + return d.closest; + + #else + + mesh_index_pair closest; + closest.invalidate(); + closest.distance = -99999.9f; + + // Get the reference position, either nozzle or probe + const xy_pos_t ref = probe_relative ? pos + probe.offset_xy : pos; + + float best_so_far = 99999.99f; + + GRID_LOOP(i, j) { + if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL)) + || (type == SET_IN_BITMAP && !done_flags->marked(i, j)) ) { - pt.pos.set(x, y); - pt.distance = 1; + // Found a Mesh Point of the specified type! + const xy_pos_t mpos = { mesh_index_to_xpos(i), mesh_index_to_ypos(j) }; + + // If using the probe as the reference there are some unreachable locations. + // Also for round beds, there are grid points outside the bed the nozzle can't reach. + // Prune them from the list and ignore them till the next Phase (manual nozzle probing). + + if (!(probe_relative ? probe.can_reach(mpos) : position_is_reachable(mpos))) + continue; + + // Reachable. Check if it's the best_so_far location to the nozzle. + + const xy_pos_t diff = current_position - mpos; + const float distance = (ref - mpos).magnitude() + diff.magnitude() * 0.1f; + + // factor in the distance from the current location for the normal case + // so the nozzle isn't running all over the bed. + if (distance < best_so_far) { + best_so_far = distance; // Found a closer location with the desired value type. + closest.pos.set(i, j); + closest.distance = best_so_far; + } } - } + } // GRID_LOOP - mesh_index_pair unified_bed_leveling::find_next_mesh_point() { - mesh_index_pair pt; - pt.invalidate(); - pt.distance = -99999.9f; - constexpr uint8_t ord = order(_MAX(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y)); - constexpr uint8_t dim = _BV(ord); - hilbert(pt, to_fix(0), to_fix(0), to_fix(dim), to_fix(0), to_fix(0), to_fix(dim), ord); - return pt; - } + return closest; -#endif // UBL_HILBERT_CURVE + #endif +} /** * 'Smart Fill': Scan from the outward edges of the mesh towards the center. diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp index 084c9c014f..ef3cb565d2 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp @@ -30,25 +30,28 @@ #define INC_POS SUB_POS(6,1), SUB_SIZE(2,1) #define DEC_POS SUB_POS(8,1), SUB_SIZE(2,1) -void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) { - if (what & BACKGROUND) - cmd.tag(0).button(VAL_POS, F(""), FTDI::OPT_FLAT); +void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) { + char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)]; + if (isnan(value)) + strcpy_P(str, PSTR("-")); + else + dtostrf(value, width, precision, str); - if (what & FOREGROUND) { - char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)]; - if (isnan(value)) - strcpy_P(str, PSTR("-")); - else - dtostrf(value, width, precision, str); + if (units) { + strcat_P(str, PSTR(" ")); + strcat_P(str, (const char*) units); + } - if (units) { - strcat_P(str, PSTR(" ")); - strcat_P(str, (const char*) units); - } - - cmd.tag(0) - .text(VAL_POS, str) - .tag(tag ).button(INC_POS, F("-")) - .tag(tag+1).button(DEC_POS, F("+")); - } + cmd.text(VAL_POS, str); +} + +void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) { + if (what & BACKGROUND) + cmd.tag(0).button(VAL_POS, F(""), FTDI::OPT_FLAT); + + if (what & FOREGROUND) { + draw_adjuster_value(cmd, x, y, w, h, value, units, width, precision); + cmd.tag(tag ).button(INC_POS, F("-")) + .tag(tag+1).button(DEC_POS, F("+")); + } } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h index c48e37f620..9b5cab0dfb 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h @@ -22,6 +22,13 @@ #pragma once #include "../extended/screen_types.h" +void draw_adjuster_value( + CommandProcessor& cmd, + int16_t x, int16_t y, int16_t w, int16_t h, + float value, progmem_str units = nullptr, + int8_t width = 5, uint8_t precision = 1 +); + void draw_adjuster( CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h index f6603e514a..c34d5b7756 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h @@ -140,10 +140,13 @@ namespace Language_en { PROGMEM Language_Str MSG_TOUCH_CALIBRATION_START = u8"Release to begin screen calibration"; PROGMEM Language_Str MSG_TOUCH_CALIBRATION_PROMPT = u8"Touch the dots to calibrate"; - PROGMEM Language_Str MSG_AUTOLEVEL_X_AXIS = u8"Level X Axis"; PROGMEM Language_Str MSG_BED_MAPPING_DONE = u8"Bed mapping finished"; PROGMEM Language_Str MSG_BED_MAPPING_INCOMPLETE = u8"Not all points probed"; PROGMEM Language_Str MSG_LEVELING = u8"Leveling"; + PROGMEM Language_Str MSG_AXIS_LEVELING = u8"Axis Leveling"; + PROGMEM Language_Str MSG_PROBE_BED = u8"Probe Mesh"; + PROGMEM Language_Str MSG_SHOW_MESH = u8"View Mesh"; + PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test"; #if ENABLED(TOUCH_UI_LULZBOT_BIO) PROGMEM Language_Str MSG_MOVE_TO_HOME = u8"Move to Home"; 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 c87329ebe2..053f4ebd72 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 @@ -225,6 +225,7 @@ bool BedMeshScreen::tagToPoint(uint8_t tag, xy_uint8_t &pt) { } void BedMeshScreen::onEntry() { + mydata.allowEditing = true; mydata.highlightedTag = 0; mydata.zAdjustment = 0; mydata.count = GRID_MAX_POINTS; @@ -259,16 +260,16 @@ void BedMeshScreen::adjustHighlightedValue(float increment) { } void BedMeshScreen::saveAdjustedHighlightedValue() { - if(mydata.zAdjustment) { + if (mydata.zAdjustment) { BedMeshScreen::setHighlightedValue(BedMeshScreen::getHighlightedValue(true) + mydata.zAdjustment); mydata.zAdjustment = 0; } } void BedMeshScreen::changeHighlightedValue(uint8_t tag) { - saveAdjustedHighlightedValue(); + if (mydata.allowEditing) saveAdjustedHighlightedValue(); mydata.highlightedTag = tag; - moveToHighlightedValue(); + if (mydata.allowEditing) moveToHighlightedValue(); } void BedMeshScreen::drawHighlightedPointValue() { @@ -277,7 +278,12 @@ void BedMeshScreen::drawHighlightedPointValue() { .colors(normal_btn) .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z)) .font(font_small); - draw_adjuster(cmd, Z_VALUE_POS, 2, getHighlightedValue(true) + mydata.zAdjustment, GET_TEXT_F(MSG_UNITS_MM), 4, 3); + + if (mydata.allowEditing) + draw_adjuster(cmd, Z_VALUE_POS, 2, getHighlightedValue(true) + mydata.zAdjustment, GET_TEXT_F(MSG_UNITS_MM), 4, 3); + else + draw_adjuster_value(cmd, Z_VALUE_POS, getHighlightedValue(true) + mydata.zAdjustment, GET_TEXT_F(MSG_UNITS_MM), 4, 3); + cmd.colors(action_btn) .tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY)) .tag(0); @@ -347,6 +353,7 @@ 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: + mydata.allowEditing = false; mydata.count = 0; mydata.message = mydata.MSG_NONE; break; @@ -369,10 +376,16 @@ void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::pr void BedMeshScreen::startMeshProbe() { GOTO_SCREEN(BedMeshScreen); + mydata.allowEditing = false; mydata.count = 0; injectCommands_P(PSTR(BED_LEVELING_COMMANDS)); } +void BedMeshScreen::showMesh() { + GOTO_SCREEN(BedMeshScreen); + mydata.allowEditing = false; +} + void BedMeshScreen::showMeshEditor() { SpinnerDialogBox::enqueueAndWait_P(ExtUI::isMachineHomed() ? F("M420 S1") : F("G28\nM420 S1")); // After the spinner, go to this 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 index 804bb57ad0..21a7a73729 100644 --- 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 @@ -33,6 +33,7 @@ struct BedMeshScreenData { uint8_t count; uint8_t highlightedTag; float zAdjustment; + bool allowEditing; }; class BedMeshScreen : public BaseScreen, public CachedScreen { @@ -63,5 +64,6 @@ class BedMeshScreen : public BaseScreen, public CachedScreen - - + - - - - - - + - - - - - - @@ -306,6 +307,7 @@ AUTO_BED_LEVELING_BILINEAR = src_filter=+ AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ MESH_BED_LEVELING = src_filter=+ + AUTO_BED_LEVELING_UBL = src_filter=+ + +UBL_HILBERT_CURVE = src_filter=+ BACKLASH_COMPENSATION = src_filter=+ BARICUDA = src_filter=+ + BINARY_FILE_TRANSFER = src_filter=+ + From 001c77d1f7b5f9d6069494a5cb7aae976231fd09 Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Sun, 28 Mar 2021 20:27:02 -0400 Subject: [PATCH 120/311] YHCB2004 pins followup (#21472) --- Marlin/src/pins/mega/pins_GT2560_V3.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/src/pins/mega/pins_GT2560_V3.h b/Marlin/src/pins/mega/pins_GT2560_V3.h index 11824fae4a..dd2d1d0f65 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3.h @@ -157,16 +157,16 @@ #if ENABLED(YHCB2004) #ifndef YHCB2004_CLK - #define YHCB2004_CLK 5 - #define DIO52 YHCB2004_CLK + #define YHCB2004_CLK 5 + #define DIO52 YHCB2004_CLK #endif #ifndef YHCB2004_MOSI - #define YHCB2004_MOSI 36 - #define DIO51 YHCB2004_MOSI + #define YHCB2004_MOSI 21 + #define DIO50 YHCB2004_MOSI #endif #ifndef YHCB2004_MISO - #define YHCB2004_MISO 21 - #define DIO50 YHCB2004_MISO + #define YHCB2004_MISO 36 + #define DIO51 YHCB2004_MISO #endif #elif HAS_WIRED_LCD #ifndef LCD_PINS_RS @@ -209,4 +209,4 @@ #ifndef BTN_ENC #define BTN_ENC 19 #endif -#endif \ No newline at end of file +#endif From 8f509b0ae0827510a32d39e3788bc43a8ab7a2fd Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 29 Mar 2021 00:45:48 +0000 Subject: [PATCH 121/311] [cron] Bump distribution date (2021-03-29) --- 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 d3190bb612..86f557bd52 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-03-28" + #define STRING_DISTRIBUTION_DATE "2021-03-29" #endif /** From ccdbffbf3f599f0860c643647ce6c40f1eb5a4cd Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Mon, 29 Mar 2021 01:41:56 -0500 Subject: [PATCH 122/311] Laser Coolant Flow Meter / Safety Shutdown (#21431) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 15 ++ Marlin/src/core/language.h | 1 + Marlin/src/feature/cooler.cpp | 22 ++- Marlin/src/feature/cooler.h | 95 ++++++++-- Marlin/src/feature/spindle_laser.h | 5 +- Marlin/src/gcode/gcode.cpp | 11 ++ Marlin/src/inc/SanityCheck.h | 4 + Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 93 +++++++--- Marlin/src/lcd/dogm/dogm_Statusscreen.h | 182 +++++++++++++------- Marlin/src/lcd/dogm/status/cooler.h | 94 +++++++--- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 80 +++++---- Marlin/src/lcd/language/language_en.h | 3 +- Marlin/src/lcd/marlinui.cpp | 6 + Marlin/src/lcd/marlinui.h | 5 + Marlin/src/lcd/menu/menu_temperature.cpp | 14 +- Marlin/src/libs/numtostr.cpp | 9 + Marlin/src/libs/numtostr.h | 3 + Marlin/src/module/temperature.cpp | 19 +- buildroot/tests/mega2560 | 20 +++ platformio.ini | 4 +- 20 files changed, 512 insertions(+), 173 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a7af076155..d3ad971e6d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -204,6 +204,20 @@ #endif #endif +// +// Laser Coolant Flow Meter +// +//#define LASER_COOLANT_FLOW_METER +#if ENABLED(LASER_COOLANT_FLOW_METER) + #define FLOWMETER_PIN 20 // Requires an external interrupt-enabled pin (e.g., RAMPS 2,3,18,19,20,21) + #define FLOWMETER_PPL 5880 // (pulses/liter) Flow meter pulses-per-liter on the input pin + #define FLOWMETER_INTERVAL 1000 // (ms) Flow rate calculation interval in milliseconds + #define FLOWMETER_SAFETY // Prevent running the laser without the minimum flow rate set below + #if ENABLED(FLOWMETER_SAFETY) + #define FLOWMETER_MIN_LITERS_PER_MINUTE 1.5 // (liters/min) Minimum flow required when enabled + #endif +#endif + /** * Thermal Protection provides additional protection to your printer from damage * and fire. Marlin always includes safe min and max temperature ranges which @@ -1539,6 +1553,7 @@ #define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating //#define STATUS_CUTTER_ANIM // Use a second bitmap to indicate spindle / laser active //#define STATUS_COOLER_ANIM // Use a second bitmap to indicate laser cooling + //#define STATUS_FLOWMETER_ANIM // Use multiple bitmaps to indicate coolant flow //#define STATUS_ALT_BED_BITMAP // Use the alternative bed bitmap //#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap //#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 71e8ea524c..de29535f87 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -130,6 +130,7 @@ #define STR_COUNT_A " Count A:" #define STR_WATCHDOG_FIRED "Watchdog timeout. Reset required." #define STR_ERR_KILLED "Printer halted. kill() called!" +#define STR_FLOWMETER_FAULT "Coolant flow fault. Flowmeter safety is active. Attention required." #define STR_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)" #define STR_ERR_SERIAL_MISMATCH "Serial status mismatch" #define STR_BUSY_PROCESSING "busy: processing" diff --git a/Marlin/src/feature/cooler.cpp b/Marlin/src/feature/cooler.cpp index 03640df487..a1f25c5fad 100644 --- a/Marlin/src/feature/cooler.cpp +++ b/Marlin/src/feature/cooler.cpp @@ -27,11 +27,21 @@ #include "cooler.h" Cooler cooler; -uint16_t Cooler::flowrate; // Flow meter reading in liters, 0 will result in shutdown if equiped -uint8_t Cooler::mode = 0; // 0 = CO2 Liquid cooling, 1 = Laser Diode TEC Heatsink Cooling -uint16_t Cooler::capacity; // Cooling capacity in watts -uint16_t Cooler::load; // Cooling load in watts -bool Cooler::flowmeter = false; -bool Cooler::state = false; // on = true, off = false +uint8_t Cooler::mode = 0; +uint16_t Cooler::capacity; +uint16_t Cooler::load; +bool Cooler::enabled = false; +#if ENABLED(LASER_COOLANT_FLOW_METER) + bool Cooler::flowmeter = false; + millis_t Cooler::flowmeter_next_ms; // = 0 + volatile uint16_t Cooler::flowpulses; + float Cooler::flowrate; #endif + +#if ENABLED(FLOWMETER_SAFETY) + bool Cooler::flowsafety_enabled = true; + bool Cooler::fault = false; +#endif + +#endif // HAS_COOLER diff --git a/Marlin/src/feature/cooler.h b/Marlin/src/feature/cooler.h index 42a95ccb63..1e24c729f3 100644 --- a/Marlin/src/feature/cooler.h +++ b/Marlin/src/feature/cooler.h @@ -21,30 +21,91 @@ */ #pragma once -#include +#include "../inc/MarlinConfigPre.h" -#define _MSG_COOLER(M) MSG_COOLER_##M -#define MSG_COOLER(M) _MSG_COOLER(M) +#ifndef FLOWMETER_PPL + #define FLOWMETER_PPL 5880 // Pulses per liter +#endif +#ifndef FLOWMETER_INTERVAL + #define FLOWMETER_INTERVAL 1000 // milliseconds +#endif // Cooling device class Cooler { public: - static uint16_t flowrate; // Flow meter reading in liters, 0 will result in shutdown if equiped - static uint8_t mode; // 0 = CO2 Liquid cooling, 1 = Laser Diode TEC Heatsink Cooling - static uint16_t capacity; // Cooling capacity in watts - static uint16_t load; // Cooling load in watts - static bool flowmeter; - static bool state; // on = true, off = false + static uint16_t capacity; // Cooling capacity in watts + static uint16_t load; // Cooling load in watts - static bool is_enabled() { return state; } - static void enable() { state = true; } - static void disable() { state = false; } - static void set_mode(const uint8_t m) { mode = m; } - static void set_flowmeter(const bool sflag) { flowmeter = sflag; } - static uint16_t get_flowrate() { return flowrate; } - static void update_flowrate(uint16_t flow) { flowrate = flow; } - //static void init() { set_state(false); } + static bool enabled; + static void enable() { enabled = true; } + static void disable() { enabled = false; } + static void toggle() { enabled = !enabled; } + + static uint8_t mode; // 0 = CO2 Liquid cooling, 1 = Laser Diode TEC Heatsink Cooling + static void set_mode(const uint8_t m) { mode = m; } + + #if ENABLED(LASER_COOLANT_FLOW_METER) + static float flowrate; // Flow meter reading in liters-per-minute. + static bool flowmeter; // Flag to monitor the flow + static volatile uint16_t flowpulses; // Flowmeter IRQ pulse count + static millis_t flowmeter_next_ms; // Next time at which to calculate flow + + static void set_flowmeter(const bool sflag) { + if (flowmeter != sflag) { + flowmeter = sflag; + if (sflag) { + flowpulses = 0; + flowmeter_next_ms = millis() + FLOWMETER_INTERVAL; + } + } + } + + // To calculate flow we only need to count pulses + static void flowmeter_ISR() { flowpulses++; } + + // Enable / Disable the flow meter interrupt + static void flowmeter_interrupt_enable() { + attachInterrupt(digitalPinToInterrupt(FLOWMETER_PIN), flowmeter_ISR, RISING); + } + static void flowmeter_interrupt_disable() { + detachInterrupt(digitalPinToInterrupt(FLOWMETER_PIN)); + } + + // Enable / Disable the flow meter interrupt + static void flowmeter_enable() { set_flowmeter(true); flowpulses = 0; flowmeter_interrupt_enable(); } + static void flowmeter_disable() { set_flowmeter(false); flowmeter_interrupt_disable(); flowpulses = 0; } + + // Get the total flow (in liters per minute) since the last reading + static void calc_flowrate() { + //flowmeter_interrupt_disable(); + // const uint16_t pulses = flowpulses; + //flowmeter_interrupt_enable(); + flowrate = flowpulses * 60.0f * (1000.0f / (FLOWMETER_INTERVAL)) * (1000.0f / (FLOWMETER_PPL)); + flowpulses = 0; + } + + // Userland task to update the flow meter + static void flowmeter_task(const millis_t ms=millis()) { + if (!flowmeter) // !! The flow meter must always be on !! + flowmeter_enable(); // Init and prime + if (ELAPSED(ms, flowmeter_next_ms)) { + calc_flowrate(); + flowmeter_next_ms = ms + FLOWMETER_INTERVAL; + } + } + + #if ENABLED(FLOWMETER_SAFETY) + static bool fault; // Flag that the cooler is in a fault state + static bool flowsafety_enabled; // Flag to disable the cutter if flow rate is too low + static void flowsafety_toggle() { flowsafety_enabled = !flowsafety_enabled; } + static bool check_flow_too_low() { + const bool too_low = flowsafety_enabled && flowrate < (FLOWMETER_MIN_LITERS_PER_MINUTE); + if (too_low) fault = true; + return too_low; + } + #endif + #endif }; extern Cooler cooler; diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index d50bc7eb42..b3d008851c 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -215,8 +215,7 @@ public: static inline void disable() { isReady = false; set_enabled(false); } #if HAS_LCD_MENU - - static inline void enable_with_dir(const bool reverse) { + static inline void enable_with_dir(const bool reverse) { isReady = true; const uint8_t ocr = TERN(SPINDLE_LASER_PWM, upower_to_ocr(menuPower), 255); if (menuPower) @@ -245,8 +244,8 @@ public: * If not set defaults to 80% power */ static inline void test_fire_pulse() { - enable_forward(); // Turn Laser on (Spindle speak but same funct) TERN_(USE_BEEPER, buzzer.tone(30, 3000)); + enable_forward(); // Turn Laser on (Spindle speak but same funct) delay(testPulse); // Delay for time set by user in pulse ms menu screen. disable(); // Turn laser off } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index aa206bfeba..cdf11e870b 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -57,6 +57,10 @@ GcodeSuite gcode; #include "../feature/spindle_laser.h" #endif +#if ENABLED(FLOWMETER_SAFETY) + #include "../feature/cooler.h" +#endif + #if ENABLED(PASSWORD_FEATURE) #include "../feature/password/password.h" #endif @@ -278,6 +282,13 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { } #endif + #if ENABLED(FLOWMETER_SAFETY) + if (cooler.fault) { + SERIAL_ECHO_MSG(STR_FLOWMETER_FAULT); + return; + } + #endif + // Handle a known G, M, or T switch (parser.command_letter) { case 'G': switch (parser.codenum) { diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 704163e2b2..6ed0f53245 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1895,6 +1895,10 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_COOLER requires LASER_FEATURE and TEMP_COOLER_PIN." #endif +#if ENABLED(LASER_COOLANT_FLOW_METER) && !(PIN_EXISTS(FLOWMETER) && ENABLED(LASER_FEATURE)) + #error "LASER_COOLANT_FLOW_METER requires FLOWMETER_PIN and LASER_FEATURE." +#endif + #if ENABLED(CHAMBER_FAN) && !(defined(CHAMBER_FAN_MODE) && WITHIN(CHAMBER_FAN_MODE, 0, 2)) #error "CHAMBER_FAN_MODE must be between 0 and 2." #endif diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 3f4cc23aba..683c1c0884 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -46,6 +46,10 @@ #include "../../gcode/parser.h" #endif +#if HAS_COOLER || HAS_FLOWMETER + #include "../../feature/cooler.h" +#endif + #if ENABLED(AUTO_BED_LEVELING_UBL) #include "../../feature/bedlevel/bedlevel.h" #endif @@ -517,6 +521,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const lcd_put_u8str(value); } + FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) { #if HAS_HEATED_BED const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0); @@ -550,6 +555,43 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr } } +#if HAS_COOLER +FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { + const float t1 = thermalManager.degCooler(), t2 = thermalManager.degTargetCooler(); + + if (prefix >= 0) lcd_put_wchar(prefix); + + lcd_put_u8str(i16tostr3rj(t1 + 0.5)); + lcd_put_wchar('/'); + + #if !HEATER_IDLE_HANDLER + UNUSED(blink); + #else + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { + lcd_put_wchar(' '); + if (t2 >= 10) lcd_put_wchar(' '); + if (t2 >= 100) lcd_put_wchar(' '); + } + else + #endif + lcd_put_u8str(i16tostr3left(t2 + 0.5)); + + if (prefix >= 0) { + lcd_put_wchar(LCD_STR_DEGREE[0]); + lcd_put_wchar(' '); + if (t2 < 10) lcd_put_wchar(' '); + } +} +#endif + +#if HAS_FLOWMETER + FORCE_INLINE void _draw_flowmeter_status() { + lcd_put_u8str("~ "); + lcd_put_u8str(ftostr11ns(cooler.flowrate)); + lcd_put_wchar('L'); + } +#endif + FORCE_INLINE void _draw_bed_status(const bool blink) { _draw_heater_status(H_BED, TERN0(HAS_LEVELING, blink && planner.leveling_active) ? '_' : LCD_STR_BEDTEMP[0], blink); } @@ -747,17 +789,19 @@ void MarlinUI::draw_status_screen() { // // Hotend 0 Temperature // - _draw_heater_status(H_E0, -1, blink); + #if HAS_HOTEND + _draw_heater_status(H_E0, -1, blink); - // - // Hotend 1 or Bed Temperature - // - #if HAS_MULTI_HOTEND - lcd_moveto(8, 0); - _draw_heater_status(H_E1, LCD_STR_THERMOMETER[0], blink); - #elif HAS_HEATED_BED - lcd_moveto(8, 0); - _draw_bed_status(blink); + // + // Hotend 1 or Bed Temperature + // + #if HAS_MULTI_HOTEND + lcd_moveto(8, 0); + _draw_heater_status(H_E1, LCD_STR_THERMOMETER[0], blink); + #elif HAS_HEATED_BED + lcd_moveto(8, 0); + _draw_bed_status(blink); + #endif #endif #else // LCD_WIDTH >= 20 @@ -765,17 +809,26 @@ void MarlinUI::draw_status_screen() { // // Hotend 0 Temperature // - _draw_heater_status(H_E0, LCD_STR_THERMOMETER[0], blink); + #if HAS_HOTEND + _draw_heater_status(H_E0, LCD_STR_THERMOMETER[0], blink); - // - // Hotend 1 or Bed Temperature - // - #if HAS_MULTI_HOTEND - lcd_moveto(10, 0); - _draw_heater_status(H_E1, LCD_STR_THERMOMETER[0], blink); - #elif HAS_HEATED_BED - lcd_moveto(10, 0); - _draw_bed_status(blink); + // + // Hotend 1 or Bed Temperature + // + #if HAS_MULTI_HOTEND + lcd_moveto(10, 0); + _draw_heater_status(H_E1, LCD_STR_THERMOMETER[0], blink); + #elif HAS_HEATED_BED + lcd_moveto(10, 0); + _draw_bed_status(blink); + #endif + #endif + + #if HAS_COOLER + _draw_cooler_status('*', blink); + #endif + #if HAS_FLOWMETER + _draw_flowmeter_status(); #endif #endif // LCD_WIDTH >= 20 diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index d0dc288613..396b05b084 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -77,9 +77,12 @@ #ifndef STATUS_CUTTER_WIDTH #define STATUS_CUTTER_WIDTH 0 #endif + #ifndef STATUS_CUTTER_BYTEWIDTH + #define STATUS_CUTTER_BYTEWIDTH BW(STATUS_CUTTER_WIDTH) + #endif // -// Laser Cooler +// Laser cooler // #if !STATUS_COOLER_WIDTH && HAS_COOLER #include "status/cooler.h" @@ -87,6 +90,24 @@ #ifndef STATUS_COOLER_WIDTH #define STATUS_COOLER_WIDTH 0 #endif +#ifndef STATUS_COOLER_BYTEWIDTH + #define STATUS_COOLER_BYTEWIDTH BW(STATUS_COOLER_WIDTH) +#endif + +// +// Laser Flowmeter +// +#if !STATUS_FLOWMETER_WIDTH && HAS_FLOWMETER + #include "status/cooler.h" +#endif +#ifndef STATUS_FLOWMETER_WIDTH + #define STATUS_FLOWMETER_WIDTH 0 +#endif +#ifndef STATUS_FLOWMETER_BYTEWIDTH + #define STATUS_FLOWMETER_BYTEWIDTH BW(STATUS_FLOWMETER_WIDTH) +#endif + + // // Bed @@ -425,46 +446,45 @@ // // Cutter Bitmap Properties // -#ifndef STATUS_CUTTER_BYTEWIDTH - #define STATUS_CUTTER_BYTEWIDTH BW(STATUS_CUTTER_WIDTH) -#endif -#if STATUS_CUTTER_WIDTH +#if HAS_CUTTER + #if STATUS_CUTTER_WIDTH - #ifndef STATUS_CUTTER_X - #define STATUS_CUTTER_X (LCD_PIXEL_WIDTH - (STATUS_CUTTER_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH) * 8) - #endif - - #ifndef STATUS_CUTTER_HEIGHT - #ifdef STATUS_CUTTER_ANIM - #define STATUS_CUTTER_HEIGHT(S) ((S) ? sizeof(status_cutter_on_bmp) / (STATUS_CUTTER_BYTEWIDTH) : sizeof(status_cutter_bmp) / (STATUS_CUTTER_BYTEWIDTH)) - #else - #define STATUS_CUTTER_HEIGHT(S) (sizeof(status_cutter_bmp) / (STATUS_CUTTER_BYTEWIDTH)) + #ifndef STATUS_CUTTER_X + #define STATUS_CUTTER_X (LCD_PIXEL_WIDTH - (STATUS_CUTTER_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH) * 8) #endif - #endif - #ifndef STATUS_CUTTER_Y - #define STATUS_CUTTER_Y(S) 4 - #endif + #ifndef STATUS_CUTTER_HEIGHT + #ifdef STATUS_CUTTER_ANIM + #define STATUS_CUTTER_HEIGHT(S) ((S) ? sizeof(status_cutter_on_bmp) / (STATUS_CUTTER_BYTEWIDTH) : sizeof(status_cutter_bmp) / (STATUS_CUTTER_BYTEWIDTH)) + #else + #define STATUS_CUTTER_HEIGHT(S) (sizeof(status_cutter_bmp) / (STATUS_CUTTER_BYTEWIDTH)) + #endif + #endif - #ifndef STATUS_CUTTER_TEXT_X - #define STATUS_CUTTER_TEXT_X (STATUS_CUTTER_X -1) - #endif + #ifndef STATUS_CUTTER_Y + #define STATUS_CUTTER_Y(S) 4 + #endif - #ifndef STATUS_CUTTER_TEXT_Y - #define STATUS_CUTTER_TEXT_Y 28 - #endif + #ifndef STATUS_CUTTER_TEXT_X + #define STATUS_CUTTER_TEXT_X (STATUS_CUTTER_X -1) + #endif + + #ifndef STATUS_CUTTER_TEXT_Y + #define STATUS_CUTTER_TEXT_Y 28 + #endif - static_assert( - sizeof(status_cutter_bmp) == (STATUS_CUTTER_BYTEWIDTH) * (STATUS_CUTTER_HEIGHT(0)), - "Status cutter bitmap (status_cutter_bmp) dimensions don't match data." - ); - #ifdef STATUS_CUTTER_ANIM static_assert( - sizeof(status_cutter_on_bmp) == (STATUS_CUTTER_BYTEWIDTH) * (STATUS_CUTTER_HEIGHT(1)), - "Status cutter bitmap (status_cutter_on_bmp) dimensions don't match data." + sizeof(status_cutter_bmp) == (STATUS_CUTTER_BYTEWIDTH) * (STATUS_CUTTER_HEIGHT(0)), + "Status cutter bitmap (status_cutter_bmp) dimensions don't match data." ); - #endif + #ifdef STATUS_CUTTER_ANIM + static_assert( + sizeof(status_cutter_on_bmp) == (STATUS_CUTTER_BYTEWIDTH) * (STATUS_CUTTER_HEIGHT(1)), + "Status cutter bitmap (status_cutter_on_bmp) dimensions don't match data." + ); + #endif + #endif #endif // @@ -511,42 +531,72 @@ // // Cooler Bitmap Properties // -#ifndef STATUS_COOLER_BYTEWIDTH - #define STATUS_COOLER_BYTEWIDTH BW(STATUS_COOLER_WIDTH) -#endif -#if STATUS_COOLER_WIDTH +#if HAS_COOLER + #if STATUS_COOLER_WIDTH - #ifndef STATUS_COOLER_X - #define STATUS_COOLER_X (LCD_PIXEL_WIDTH - (STATUS_COOLER_BYTEWIDTH + STATUS_FAN_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH) * 8) - #endif + #ifndef STATUS_COOLER_X + #define STATUS_COOLER_X (LCD_PIXEL_WIDTH - (STATUS_COOLER_BYTEWIDTH + STATUS_FAN_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH) * 8) + #endif - #ifndef STATUS_COOLER_HEIGHT + #ifndef STATUS_COOLER_HEIGHT + #define STATUS_COOLER_HEIGHT(S) (sizeof(status_cooler_bmp1) / (STATUS_COOLER_BYTEWIDTH)) + #endif + + #ifndef STATUS_COOLER_Y + #define STATUS_COOLER_Y(S) (18 - STATUS_COOLER_HEIGHT(S)) + #endif + + #ifndef STATUS_COOLER_TEXT_X + #define STATUS_COOLER_TEXT_X (STATUS_COOLER_X + 8) + #endif + + static_assert( + sizeof(status_cooler_bmp1) == (STATUS_COOLER_BYTEWIDTH) * (STATUS_COOLER_HEIGHT(0)), + "Status cooler bitmap (status_cooler_bmp1) dimensions don't match data." + ); #ifdef STATUS_COOLER_ANIM - #define STATUS_COOLER_HEIGHT(S) ((S) ? sizeof(status_cooler_on_bmp) / (STATUS_COOLER_BYTEWIDTH) : sizeof(status_cooler_bmp) / (STATUS_COOLER_BYTEWIDTH)) - #else - #define STATUS_COOLER_HEIGHT(S) (sizeof(status_cooler_bmp) / (STATUS_COOLER_BYTEWIDTH)) + static_assert( + sizeof(status_cooler_bmp2) == (STATUS_COOLER_BYTEWIDTH) * (STATUS_COOLER_HEIGHT(1)), + "Status cooler bitmap (status_cooler_bmp2) dimensions don't match data." + ); + #endif + + #endif +#endif + +// +// Flowmeter Bitmap Properties +// +#if HAS_FLOWMETER + #if STATUS_FLOWMETER_WIDTH + + #ifndef STATUS_FLOWMETER_X + #define STATUS_FLOWMETER_X (LCD_PIXEL_WIDTH - (STATUS_FLOWMETER_BYTEWIDTH + STATUS_FAN_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH + STATUS_COOLER_BYTEWIDTH) * 8) + #endif + + #ifndef STATUS_FLOWMETER_HEIGHT + #define STATUS_FLOWMETER_HEIGHT(S) (sizeof(status_flowmeter_bmp1) / (STATUS_FLOWMETER_BYTEWIDTH)) + #endif + + #ifndef STATUS_FLOWMETER_Y + #define STATUS_FLOWMETER_Y(S) (20 - STATUS_FLOWMETER_HEIGHT(S)) + #endif + + #ifndef STATUS_FLOWMETER_TEXT_X + #define STATUS_FLOWMETER_TEXT_X (STATUS_FLOWMETER_X + 8) + #endif + + static_assert( + sizeof(status_flowmeter_bmp1) == (STATUS_FLOWMETER_BYTEWIDTH) * STATUS_FLOWMETER_HEIGHT(0), + "Status flowmeter bitmap (status_flowmeter_bmp1) dimensions don't match data." + ); + #ifdef STATUS_COOLER_ANIM + static_assert( + sizeof(status_flowmeter_bmp2) == (STATUS_FLOWMETER_BYTEWIDTH) * STATUS_FLOWMETER_HEIGHT(1), + "Status flowmeter bitmap (status_flowmeter_bmp2) dimensions don't match data." + ); #endif #endif - - #ifndef STATUS_COOLER_Y - #define STATUS_COOLER_Y(S) (18 - STATUS_COOLER_HEIGHT(S)) - #endif - - #ifndef STATUS_COOLER_TEXT_X - #define STATUS_COOLER_TEXT_X (STATUS_COOLER_X + 8) - #endif - - static_assert( - sizeof(status_cooler_bmp) == (STATUS_COOLER_BYTEWIDTH) * (STATUS_COOLER_HEIGHT(0)), - "Status cooler bitmap (status_cooler_bmp) dimensions don't match data." - ); - #ifdef STATUS_COOLER_ANIM - static_assert( - sizeof(status_cooler_on_bmp) == (STATUS_COOLER_BYTEWIDTH) * (STATUS_COOLER_HEIGHT(1)), - "Status cooler bitmap (status_cooler_on_bmp) dimensions don't match data." - ); - #endif - #endif // @@ -639,6 +689,9 @@ #if HAS_COOLER #define DO_DRAW_COOLER 1 #endif +#if HAS_FLOWMETER + #define DO_DRAW_FLOWMETER 1 +#endif #if HAS_TEMP_CHAMBER && STATUS_CHAMBER_WIDTH && HOTENDS <= 4 #define DO_DRAW_CHAMBER 1 @@ -661,6 +714,9 @@ #if BOTH(DO_DRAW_COOLER, STATUS_COOLER_ANIM) #define ANIM_COOLER 1 #endif +#if BOTH(DO_DRAW_FLOWMETER, STATUS_FLOWMETER_ANIM) + #define ANIM_FLOWMETER 1 +#endif #if ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER || ANIM_CUTTER #define ANIM_HBCC 1 #endif diff --git a/Marlin/src/lcd/dogm/status/cooler.h b/Marlin/src/lcd/dogm/status/cooler.h index 4e59e237a2..0d72efea72 100644 --- a/Marlin/src/lcd/dogm/status/cooler.h +++ b/Marlin/src/lcd/dogm/status/cooler.h @@ -24,12 +24,9 @@ // // lcd/dogm/status/cooler.h - Status Screen Laser Cooler bitmaps // - -#define STATUS_COOLER_WIDTH 16 - -#ifdef STATUS_COOLER_ANIM - - const unsigned char status_cooler_on_bmp[] PROGMEM = { +#if HAS_COOLER + #define STATUS_COOLER_WIDTH 16 + const unsigned char status_cooler_bmp2[] PROGMEM = { B00010000,B00001000, B00010010,B01001001, B01010100,B00101010, @@ -47,24 +44,71 @@ B00000010,B10100000, B00000100,B10010000 }; - + const unsigned char status_cooler_bmp1[] PROGMEM = { + B00010000,B00001000, + B00010010,B01001001, + B01010100,B00101010, + B00101000,B00010100, + B11000111,B01100011, + B00101000,B00010100, + B01010100,B00101010, + B10010000,B10001001, + B00010000,B10000000, + B00000100,B10010000, + B00000010,B10100000, + B00000001,B01000000, + B00011110,B00111100, + B00000001,B01000000, + B00000010,B10100000, + B00000100,B10010000 + }; +#endif + +#if HAS_FLOWMETER + #define STATUS_FLOWMETER_WIDTH 24 + const unsigned char status_flowmeter_bmp2[] PROGMEM = { + B00000001,B11111000,B00000000, + B00000110,B00000110,B00000000, + B00001000,B01100001,B00000000, + B00010000,B01100000,B10000000, + B00100000,B01100000,B01000000, + B00100000,B01100000,B01000000, + B01000000,B01100000,B00100000, + B01000000,B01100000,B00100000, + B01011111,B11111111,B10100000, + B01011111,B11111111,B10100000, + B01000000,B01100000,B00100000, + B01000000,B01100000,B00100000, + B00100000,B01100000,B01000000, + B00100000,B01100000,B01000000, + B00010000,B01100000,B10000000, + B00001000,B01100001,B00000000, + B00000110,B00000110,B00000000, + B00000001,B11111000,B00000000, + B00000000,B01100000,B00000000, + B00011111,B11111111,B10000000 + }; + const unsigned char status_flowmeter_bmp1[] PROGMEM = { + B00000001,B11111000,B00000000, + B00000110,B00000110,B00000000, + B00001000,B00000001,B00000000, + B00010100,B00000010,B10000000, + B00101110,B00000111,B01000000, + B00100111,B00001110,B01000000, + B01000011,B10011100,B00100000, + B01000001,B11111000,B00100000, + B01000000,B11110000,B00100000, + B01000000,B11110000,B00100000, + B01000001,B11111000,B00100000, + B01000011,B10011100,B00100000, + B00100111,B00001110,B01000000, + B00101110,B00000111,B01000000, + B00010100,B00000010,B10000000, + B00001000,B00000001,B00000000, + B00000110,B00000110,B00000000, + B00000001,B11111000,B00000000, + B00000000,B01100000,B00000000, + B00011111,B11111111,B10000000 + }; #endif -const unsigned char status_cooler_bmp[] PROGMEM = { - B00010000,B00001000, - B00010010,B01001001, - B01010100,B00101010, - B00101000,B00010100, - B11000111,B01100011, - B00101000,B00010100, - B01010100,B00101010, - B10010000,B10001001, - B00010000,B10000000, - B00000100,B10010000, - B00000010,B10100000, - B00000001,B01000000, - B00011110,B00111100, - B00000001,B01000000, - B00000010,B10100000, - B00000100,B10010000 -}; diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 7d97a1cdcf..2ec462c34a 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -53,6 +53,10 @@ #include "../../feature/spindle_laser.h" #endif +#if HAS_COOLER || HAS_FLOWMETER + #include "../../feature/cooler.h" +#endif + #if HAS_POWER_MONITOR #include "../../feature/power_monitor.h" #endif @@ -83,40 +87,34 @@ #if ANIM_HBCC enum HeatBits : uint8_t { - HEATBIT_HOTEND, - HEATBIT_BED = HOTENDS, - HEATBIT_CHAMBER, - HEATBIT_COOLER, - HEATBIT_CUTTER + DRAWBIT_HOTEND, + DRAWBIT_BED = HOTENDS, + DRAWBIT_CHAMBER, + DRAWBIT_CUTTER }; - IF<(HEATBIT_CUTTER > 7), uint16_t, uint8_t>::type heat_bits; + IF<(DRAWBIT_CUTTER > 7), uint16_t, uint8_t>::type draw_bits; #endif #if ANIM_HOTEND - #define HOTEND_ALT(N) TEST(heat_bits, HEATBIT_HOTEND + N) + #define HOTEND_ALT(N) TEST(draw_bits, DRAWBIT_HOTEND + N) #else #define HOTEND_ALT(N) false #endif #if ANIM_BED - #define BED_ALT() TEST(heat_bits, HEATBIT_BED) + #define BED_ALT() TEST(draw_bits, DRAWBIT_BED) #else #define BED_ALT() false #endif #if ANIM_CHAMBER - #define CHAMBER_ALT() TEST(heat_bits, HEATBIT_CHAMBER) + #define CHAMBER_ALT() TEST(draw_bits, DRAWBIT_CHAMBER) #else #define CHAMBER_ALT() false #endif #if ANIM_CUTTER - #define CUTTER_ALT(N) TEST(heat_bits, HEATBIT_CUTTER) + #define CUTTER_ALT(N) TEST(draw_bits, DRAWBIT_CUTTER) #else #define CUTTER_ALT() false #endif -#if ANIM_COOLER - #define COOLER_ALT(N) TEST(heat_bits, HEATBIT_COOLER) -#else - #define COOLER_ALT() false -#endif #if DO_DRAW_HOTENDS #define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE))) @@ -194,6 +192,15 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co lcd_put_wchar(LCD_STR_DEGREE[0]); } +#if DO_DRAW_FLOWMETER + FORCE_INLINE void _draw_centered_flowrate(const float flow, const uint8_t tx, const uint8_t ty) { + const char *str = ftostr11ns(flow); + const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; + lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]); + lcd_put_u8str("L"); + } +#endif + #if DO_DRAW_HOTENDS // Draw hotend bitmap with current and target temperatures @@ -384,6 +391,13 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co } #endif +#if DO_DRAW_FLOWMETER + FORCE_INLINE void _draw_flowmeter_status() { + if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) + _draw_centered_flowrate(cooler.flowrate, STATUS_FLOWMETER_TEXT_X, 28); + } +#endif + // // Before homing, blink '123' <-> '???'. // Homed but unknown... '123' <-> ' '. @@ -451,17 +465,14 @@ void MarlinUI::draw_status_screen() { #if ANIM_HBCC uint8_t new_bits = 0; #if ANIM_HOTEND - HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, HEATBIT_HOTEND + e); + HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, DRAWBIT_HOTEND + e); #endif - if (TERN0(ANIM_BED, thermalManager.isHeatingBed())) SBI(new_bits, HEATBIT_BED); + if (TERN0(ANIM_BED, thermalManager.isHeatingBed())) SBI(new_bits, DRAWBIT_BED); #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER - if (thermalManager.isHeatingChamber()) SBI(new_bits, HEATBIT_CHAMBER); + if (thermalManager.isHeatingChamber()) SBI(new_bits, DRAWBIT_CHAMBER); #endif - #if DO_DRAW_COOLER && HAS_COOLER - if (thermalManager.isLaserCooling()) SBI(new_bits, HEATBIT_COOLER); - #endif - if (TERN0(ANIM_CUTTER, cutter.enabled())) SBI(new_bits, HEATBIT_CUTTER); - heat_bits = new_bits; + if (TERN0(ANIM_CUTTER, cutter.enabled())) SBI(new_bits, DRAWBIT_CUTTER); + draw_bits = new_bits; #endif const xyz_pos_t lpos = current_position.asLogical(); @@ -646,17 +657,21 @@ void MarlinUI::draw_status_screen() { // Laser Cooler #if DO_DRAW_COOLER - #if ANIM_COOLER - #define COOLER_BITMAP(S) ((S) ? status_cooler_bmp : status_cooler_on_bmp) - #else - #define COOLER_BITMAP(S) status_cooler_bmp - #endif - const uint8_t coolery = STATUS_COOLER_Y(COOLER_ALT()), - coolerh = STATUS_COOLER_HEIGHT(COOLER_ALT()); + const uint8_t coolery = STATUS_COOLER_Y(status_cooler_bmp1), + coolerh = STATUS_COOLER_HEIGHT(status_cooler_bmp1); if (PAGE_CONTAINS(coolery, coolery + coolerh - 1)) - u8g.drawBitmapP(STATUS_COOLER_X, coolery, STATUS_COOLER_BYTEWIDTH, coolerh, COOLER_BITMAP(COOLER_ALT())); + u8g.drawBitmapP(STATUS_COOLER_X, coolery, STATUS_COOLER_BYTEWIDTH, coolerh, blink && cooler.enabled ? status_cooler_bmp2 : status_cooler_bmp1); #endif + // Laser Cooler Flow Meter + #if DO_DRAW_FLOWMETER + const uint8_t flowmetery = STATUS_FLOWMETER_Y(status_flowmeter_bmp1), + flowmeterh = STATUS_FLOWMETER_HEIGHT(status_flowmeter_bmp1); + if (PAGE_CONTAINS(flowmetery, flowmetery + flowmeterh - 1)) + u8g.drawBitmapP(STATUS_FLOWMETER_X, flowmetery, STATUS_FLOWMETER_BYTEWIDTH, flowmeterh, blink && cooler.flowpulses ? status_flowmeter_bmp2 : status_flowmeter_bmp1); + #endif + + // Heated Bed TERN_(DO_DRAW_BED, _draw_bed_status(blink)); @@ -666,6 +681,9 @@ void MarlinUI::draw_status_screen() { // Cooler TERN_(DO_DRAW_COOLER, _draw_cooler_status()); + // Flowmeter + TERN_(DO_DRAW_FLOWMETER, _draw_flowmeter_status()); + // Fan, if a bitmap was provided #if DO_DRAW_FAN if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) { diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 78d446dd99..81450d7385 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -116,10 +116,10 @@ namespace Language_en { PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Toggle Laser"); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Test Pulse ms"); PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Fire Pulse"); + PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Coolant Flow Fault"); PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Toggle Spindle"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Spindle Forward"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Spindle Reverse"); - PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Switch Power On"); PROGMEM Language_Str MSG_SWITCH_PS_OFF = _UxGT("Switch Power Off"); PROGMEM Language_Str MSG_EXTRUDE = _UxGT("Extrude"); @@ -278,6 +278,7 @@ namespace Language_en { PROGMEM Language_Str MSG_CHAMBER = _UxGT("Enclosure"); PROGMEM Language_Str MSG_COOLER = _UxGT("Laser Coolant"); PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Toggle Cooler"); + PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Flow Safety"); PROGMEM Language_Str MSG_LASER = _UxGT("Laser"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Fan Speed"); PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Fan Speed ~"); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 8fef36e25a..4d457dc6aa 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1513,6 +1513,12 @@ void MarlinUI::update() { TERN_(HAS_LCD_MENU, return_to_status()); } + void MarlinUI::flow_fault() { + LCD_ALERTMESSAGEPGM(MSG_FLOWMETER_FAULT); + TERN_(HAS_BUZZER, buzz(1000, 440)); + TERN_(HAS_LCD_MENU, return_to_status()); + } + #if ANY(PARK_HEAD_ON_PAUSE, SDSUPPORT) #include "../gcode/queue.h" #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index cc08284d17..f85771f562 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -43,6 +43,10 @@ #define HAS_ENCODER_ACTION 1 #endif +#if HAS_STATUS_MESSAGE + #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) +#endif + #if E_MANUAL > 1 #define MULTI_MANUAL 1 #endif @@ -311,6 +315,7 @@ public: static void abort_print(); static void pause_print(); static void resume_print(); + static void flow_fault(); #if HAS_WIRED_LCD diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 8caf87d33b..fb47c22ce9 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -35,7 +35,7 @@ #include "../../module/motion.h" #endif -#if HAS_COOLER +#if HAS_COOLER || HAS_FLOWMETER #include "../../feature/cooler.h" #endif @@ -192,11 +192,19 @@ void menu_temperature() { // Cooler: // #if HAS_COOLER - editable.state = cooler.is_enabled(); - EDIT_ITEM(bool, MSG_COOLER(TOGGLE), &cooler.state, []{ if (editable.state) cooler.disable(); else cooler.enable(); }); + bool cstate = cooler.enabled; + EDIT_ITEM(bool, MSG_COOLER_TOGGLE, &cstate, cooler.toggle); EDIT_ITEM_FAST(int3, MSG_COOLER, &thermalManager.temp_cooler.target, COOLER_MIN_TARGET, COOLER_MAX_TARGET, thermalManager.start_watching_cooler); #endif + // + // Flow Meter Safety Shutdown: + // + #if ENABLED(FLOWMETER_SAFETY) + bool fstate = cooler.flowsafety_enabled; + EDIT_ITEM(bool, MSG_FLOWMETER_SAFETY, &fstate, cooler.flowsafety_toggle); + #endif + // // Fan Speed: // diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index 90696e9ad3..283734faab 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -177,6 +177,15 @@ const char* i16tostr4signrj(const int16_t i) { return &conv[3]; } +// Convert unsigned float to string with 1.1 format +const char* ftostr11ns(const float &f) { + const long i = UINTFLOAT(f, 1); + conv[4] = DIGIMOD(i, 10); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 1); + return &conv[4]; +} + // Convert unsigned float to string with 1.23 format const char* ftostr12ns(const float &f) { const long i = UINTFLOAT(f, 2); diff --git a/Marlin/src/libs/numtostr.h b/Marlin/src/libs/numtostr.h index 40c298af42..54cebab252 100644 --- a/Marlin/src/libs/numtostr.h +++ b/Marlin/src/libs/numtostr.h @@ -61,6 +61,9 @@ const char* i16tostr3left(const int16_t xx); // Convert signed int to rj string with _123, -123, _-12, or __-1 format const char* i16tostr4signrj(const int16_t x); +// Convert unsigned float to string with 1.2 format +const char* ftostr11ns(const float &x); + // Convert unsigned float to string with 1.23 format const char* ftostr12ns(const float &x); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a9b7ab13eb..5a8704d3ba 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -35,7 +35,7 @@ #include "endstops.h" #include "planner.h" -#if HAS_COOLER +#if HAS_COOLER || HAS_FLOWMETER #include "../feature/cooler.h" #include "../feature/spindle_laser.h" #endif @@ -52,6 +52,10 @@ #include "../lcd/extui/ui_api.h" #endif +#if ENABLED(HOST_PROMPT_SUPPORT) + #include "../feature/host_actions.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 @@ -1506,7 +1510,7 @@ void Temperature::manage_heater() { static bool flag_cooler_state; // = false - if (cooler.is_enabled()) { + if (cooler.enabled) { flag_cooler_state = true; // used to allow M106 fan control when cooler is disabled if (temp_cooler.target == 0) temp_cooler.target = COOLER_MIN_TARGET; if (ELAPSED(ms, next_cooler_check_ms)) { @@ -1542,8 +1546,19 @@ void Temperature::manage_heater() { #if ENABLED(THERMAL_PROTECTION_COOLER) tr_state_machine[RUNAWAY_IND_COOLER].run(temp_cooler.celsius, temp_cooler.target, H_COOLER, THERMAL_PROTECTION_COOLER_PERIOD, THERMAL_PROTECTION_COOLER_HYSTERESIS); #endif + #endif // HAS_COOLER + #if HAS_FLOWMETER + cooler.flowmeter_task(ms); + #if ENABLED(FLOWMETER_SAFETY) + if (cutter.enabled() && cooler.check_flow_too_low()) { + cutter.disable(); + ui.flow_fault(); + } + #endif + #endif + UNUSED(ms); } diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 4498492ba5..3c8f720238 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -167,6 +167,26 @@ exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" #opt_enable LCM1602 #exec_test $1 $2 "Stuff" "$3" +# +# Test Laser features with 12864 LCD +# +restore_configs +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 +opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ + LASER_FEATURE LASER_COOLANT_FLOW_METER + +exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Cooler | Flowmeter | 12864 LCD " "$3" + +# +# Test Laser features with 44780 LCD +# +restore_configs +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 +opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ + LASER_FEATURE LASER_COOLANT_FLOW_METER + +exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Cooler | Flowmeter | 44780 LCD " "$3" + # # Language files test with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER # diff --git a/platformio.ini b/platformio.ini index 82c11c2b6d..26b27bbf99 100644 --- a/platformio.ini +++ b/platformio.ini @@ -82,6 +82,7 @@ default_src_filter = + - - + - - - - - + - - - - - - - @@ -198,7 +199,6 @@ default_src_filter = + - - + - - - - - - - - @@ -411,7 +411,7 @@ SDSUPPORT = src_filter=+ + GCODE_REPEAT_MARKERS = src_filter=+ + HAS_EXTRUDERS = src_filter=+ + -HAS_COOLER = src_filter=- +HAS_COOLER = src_filter=+ + AUTO_REPORT_TEMPERATURES = src_filter=+ INCH_MODE_SUPPORT = src_filter=+ TEMPERATURE_UNITS_SUPPORT = src_filter=+ From 33ccf1b9310ad2f1100d67346404a2e91a7b205a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Mar 2021 01:49:35 -0500 Subject: [PATCH 123/311] Adjust mfconfig script --- buildroot/share/git/mfconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index 3fd5e399cc..fe99d6b247 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -83,7 +83,7 @@ if [[ $ACTION == "init" ]]; then TEMP=$( mktemp -d ) ; cp -R config $TEMP # Make sure we're not on the 'BASE' branch... - git checkout master >/dev/null 2>&1 || exit + git checkout init-repo >/dev/null 2>&1 || exit # Create 'BASE' as a copy of 'init-repo' (README, LICENSE, etc.) git branch -D BASE 2>/dev/null From a335cf2edf66db08ab12d3800784b58ad992f6a9 Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Mon, 29 Mar 2021 11:19:38 +0300 Subject: [PATCH 124/311] Fix MKS LVGL UI Main screen / print buttons (#21468) --- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 2 +- .../extui/lib/mks_ui/draw_filament_change.cpp | 10 ++-- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 8 +-- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 58 ++++++++++++------- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 46 +++++++-------- .../lcd/extui/lib/mks_ui/draw_ready_print.h | 1 + Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 6 +- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 12 ++-- 9 files changed, 82 insertions(+), 63 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index c4ae6e221d..c4056f392a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -486,7 +486,7 @@ void lv_draw_dialog(uint8_t type) { void filament_sprayer_temp() { char buf[20] = {0}; - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, uiCfg.extruderIndex < 1 ? extrude_menu.ext1 : extrude_menu.ext2); strcat_P(public_buf_l, PSTR(": ")); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index 43ed214199..056e2e5d54 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -195,7 +195,7 @@ void disp_ext_speed() { void disp_hotend_temp() { char buf[20] = {0}; - sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, extrude_menu.temp_value, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, extrude_menu.temper_text); strcat(public_buf_l, buf); lv_label_set_text(tempText, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp index 56a776c79e..296359bc53 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -50,8 +50,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_FILAMNT_IN: uiCfg.filament_load_heat_flg = true; - if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1) - || (gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex))) { + if (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1 + || gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex)) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); } @@ -67,8 +67,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_FILAMNT_OUT: uiCfg.filament_unload_heat_flg = true; if (thermalManager.degTargetHotend(uiCfg.extruderIndex) - && ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1) - || ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp)) + && (abs((int)(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1 + || thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp) ) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); @@ -154,7 +154,7 @@ void disp_filament_temp() { public_buf_l[0] = '\0'; strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); 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 73a0808e9c..d23ed0b05f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -76,7 +76,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_P_DEC: if (uiCfg.curTempType == 0) { - if ((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat) + if (thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat) thermalManager.temp_hotend[uiCfg.extruderIndex].target -= uiCfg.stepHeat; else thermalManager.setTargetHotend(0, uiCfg.extruderIndex); @@ -84,7 +84,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } #if HAS_HEATED_BED else { - if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat) + if (thermalManager.degTargetBed() > uiCfg.stepHeat) thermalManager.temp_bed.target -= uiCfg.stepHeat; else thermalManager.setTargetBed(0); @@ -217,12 +217,12 @@ void disp_desire_temp() { if (uiCfg.curTempType == 0) { strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); } #if HAS_HEATED_BED else { strcat(public_buf_l, preheat_menu.hotbed); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); + sprintf(buf, preheat_menu.value_state, thermalManager.degBed(), thermalManager.degTargetBed()); } #endif strcat_P(public_buf_l, PSTR(": ")); 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 70c57f4af8..9bd120ce15 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -47,7 +47,7 @@ static lv_obj_t *scr; static lv_obj_t *labelExt1, *labelFan, *labelZpos, *labelTime; static lv_obj_t *labelPause, *labelStop, *labelOperat; static lv_obj_t *bar1, *bar1ValueText; -static lv_obj_t *buttonPause, *buttonOperat, *buttonStop; +static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonExt2, *buttonBedstate, *buttonFanstate, *buttonZpos; #if ENABLED(HAS_MULTI_EXTRUDER) static lv_obj_t *labelExt2; @@ -60,7 +60,11 @@ static lv_obj_t *buttonPause, *buttonOperat, *buttonStop; enum { ID_PAUSE = 1, ID_STOP, - ID_OPTION + ID_OPTION, + ID_TEMP_EXT, + ID_TEMP_BED, + ID_BABYSTEP, + ID_FAN }; bool once_flag; // = false @@ -100,7 +104,6 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } #endif break; - case ID_STOP: lv_clear_printing(); lv_draw_dialog(DIALOG_TYPE_STOP); @@ -109,6 +112,24 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { lv_clear_printing(); lv_draw_operation(); break; + case ID_TEMP_EXT: + uiCfg.curTempType = 0; + lv_clear_printing(); + lv_draw_preHeat(); + break; + case ID_TEMP_BED: + uiCfg.curTempType = 1; + lv_clear_printing(); + lv_draw_preHeat(); + break; + case ID_BABYSTEP: + lv_clear_printing(); + lv_draw_baby_stepping(); + break; + case ID_FAN: + lv_clear_printing(); + lv_draw_fan(); + break; } } @@ -118,33 +139,23 @@ void lv_draw_printing() { scr = lv_screen_create(PRINTING_UI); // Create image buttons - lv_obj_t *buttonExt1 = lv_img_create(scr, nullptr); - lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin"); - lv_obj_set_pos(buttonExt1, 205, 136); + buttonExt1 = lv_imgbtn_create(scr, "F:/bmp_ext1_state.bin", 206, 136, event_handler, ID_TEMP_EXT); #if HAS_MULTI_EXTRUDER - lv_obj_t *buttonExt2 = lv_img_create(scr, nullptr); - lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin"); - lv_obj_set_pos(buttonExt2, 350, 136); + buttonExt2 = lv_imgbtn_create(scr, "F:/bmp_ext2_state.bin", 350, 136, event_handler, ID_TEMP_EXT); #endif #if HAS_HEATED_BED - lv_obj_t *buttonBedstate = lv_img_create(scr, nullptr); - lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin"); - lv_obj_set_pos(buttonBedstate, 205, 186); + buttonBedstate = lv_imgbtn_create(scr, "F:/bmp_bed_state.bin", 206, 186, event_handler, ID_TEMP_BED); #endif - lv_obj_t *buttonFanstate = lv_img_create(scr, nullptr); - lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin"); - lv_obj_set_pos(buttonFanstate, 350, 186); + buttonFanstate = lv_imgbtn_create(scr, "F:/bmp_fan_state.bin", 350, 186, event_handler, ID_FAN); lv_obj_t *buttonTime = lv_img_create(scr, nullptr); lv_img_set_src(buttonTime, "F:/bmp_time_state.bin"); - lv_obj_set_pos(buttonTime, 205, 86); + lv_obj_set_pos(buttonTime, 206, 86); - lv_obj_t *buttonZpos = lv_img_create(scr, nullptr); - lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin"); - lv_obj_set_pos(buttonZpos, 350, 86); + buttonZpos = lv_imgbtn_create(scr, "F:/bmp_zpos_state.bin", 350, 86, event_handler, ID_BABYSTEP); buttonPause = lv_imgbtn_create(scr, uiCfg.print_state == WORKING ? "F:/bmp_pause.bin" : "F:/bmp_resume.bin", 5, 240, event_handler, ID_PAUSE); buttonStop = lv_imgbtn_create(scr, "F:/bmp_stop.bin", 165, 240, event_handler, ID_STOP); @@ -155,6 +166,9 @@ void lv_draw_printing() { lv_group_add_obj(g, buttonPause); lv_group_add_obj(g, buttonStop); lv_group_add_obj(g, buttonOperat); + lv_group_add_obj(g, buttonPause); + lv_group_add_obj(g, buttonPause); + lv_group_add_obj(g, buttonPause); } #endif @@ -205,18 +219,18 @@ void lv_draw_printing() { } void disp_ext_temp() { - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, public_buf_l); #endif } void disp_bed_temp() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); + sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); #endif } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index acdfa24f1b..5787cfb009 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -63,7 +63,7 @@ static lv_obj_t *labelExt1, *labelExt1Target, *labelFan; uint8_t curent_disp_ui = 0; #endif -enum { ID_TOOL = 1, ID_SET, ID_PRINT }; +enum { ID_TOOL = 1, ID_SET, ID_PRINT, ID_INFO_EXT, ID_INFO_BED, ID_INFO_FAN }; static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; @@ -71,6 +71,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_TOOL: lv_draw_tool(); break; case ID_SET: lv_draw_set(); break; + case ID_INFO_EXT: uiCfg.curTempType = 0; lv_draw_preHeat(); break; + case ID_INFO_BED: uiCfg.curTempType = 1; lv_draw_preHeat(); break; + case ID_INFO_FAN: lv_draw_fan(); break; case ID_PRINT: lv_draw_print_file(); break; } } @@ -181,32 +184,14 @@ void lv_draw_ready_print() { lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 180, event_handler, ID_PRINT); // Monitoring - lv_obj_t *buttonExt1 = lv_img_create(scr, NULL); + lv_obj_t *buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT); #if HAS_MULTI_EXTRUDER - lv_obj_t *buttonExt2 = lv_img_create(scr, NULL); + lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 55, ICON_POS_Y + SECOND_EXT_MOD_Y, event_handler, ID_INFO_EXT); #endif #if HAS_HEATED_BED - lv_obj_t *buttonBedstate = lv_img_create(scr, NULL); + lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 210, ICON_POS_Y, event_handler, ID_INFO_BED); #endif - lv_obj_t *buttonFanstate = lv_img_create(scr, NULL); - - lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin"); - #if HAS_MULTI_EXTRUDER - lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin"); - #endif - #if HAS_HEATED_BED - lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin"); - #endif - lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin"); - - lv_obj_set_pos(buttonExt1, 55, ICON_POS_Y); - #if HAS_MULTI_EXTRUDER - lv_obj_set_pos(buttonExt2, 55, ICON_POS_Y + SECOND_EXT_MOD_Y); - #endif - #if HAS_HEATED_BED - lv_obj_set_pos(buttonBedstate, 210, ICON_POS_Y); - #endif - lv_obj_set_pos(buttonFanstate, 380, ICON_POS_Y); + lv_obj_t *buttonFanstate = lv_big_button_create(scr, "F:/bmp_fan_state.bin", " ", 380, ICON_POS_Y, event_handler, ID_INFO_FAN); labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); @@ -262,6 +247,21 @@ void lv_draw_ready_print() { #endif } +void lv_temp_refr() { + #if HAS_HEATED_BED + sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed()); + lv_label_set_text(labelBed, public_buf_l); + #endif + + sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); + lv_label_set_text(labelExt1, public_buf_l); + + #if HAS_MULTI_EXTRUDER + sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1)); + lv_label_set_text(labelExt2, public_buf_l); + #endif +} + void lv_clear_ready_print() { #if HAS_ROTARY_ENCODER if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h index a3cfd67665..56077e5dec 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h @@ -32,6 +32,7 @@ extern void disp_Limit_error(); extern void disp_det_error(); extern void disp_det_ok(); extern void lv_clear_ready_print(); +extern void lv_temp_refr(); #ifdef __cplusplus } /* C-declarations for C++ */ 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 0c574b1e15..8d560a19a4 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -805,6 +805,10 @@ void GUI_RefreshPage() { } break; case PRINT_READY_UI: + if (temps_update_flag) { + temps_update_flag = false; + lv_temp_refr(); + } break; case PRINT_FILE_UI: break; @@ -843,8 +847,8 @@ void GUI_RefreshPage() { #if ENABLED(MKS_WIFI_MODULE) case WIFI_UI: if (temps_update_flag) { - disp_wifi_state(); temps_update_flag = false; + disp_wifi_state(); } break; 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 ddf7173297..44aa2300e2 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -897,9 +897,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcpy_P(outBuf, PSTR(" B:")); outBuf += 3; #if HAS_HEATED_BED - strcpy(outBuf, dtostrf(thermalManager.temp_bed.celsius, 1, 1, str_1)); + strcpy(outBuf, dtostrf(thermalManager.degBed(), 1, 1, str_1)); strcat_P(outBuf, PSTR(" /")); - strcat(outBuf, dtostrf(thermalManager.temp_bed.target, 1, 1, str_1)); + strcat(outBuf, dtostrf(thermalManager.degTargetBed(), 1, 1, str_1)); #else strcpy_P(outBuf, PSTR("0 /0")); #endif @@ -924,15 +924,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { } 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.degHotend(0), (int)thermalManager.degTargetHotend(0), + thermalManager.degHotend(0), thermalManager.degTargetHotend(0), #if HAS_HEATED_BED - (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target, + thermalManager.degBed(), thermalManager.degTargetBed(), #else 0, 0, #endif - (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0), + thermalManager.degHotend(0), thermalManager.degTargetHotend(0), #if HAS_MULTI_HOTEND - (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1) + thermalManager.degHotend(1), thermalManager.degTargetHotend(1) #else 0, 0 #endif From 86ba0cde35537dd9a7c0978beb7dcc059b3e72f7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Mar 2021 03:32:34 -0500 Subject: [PATCH 125/311] reduced verbiage --- Marlin/Makefile | 2 +- Marlin/src/core/boards.h | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index 19c2d0b329..a3ca81abdd 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -219,7 +219,7 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1111) else ifeq ($(HARDWARE_MOTHERBOARD),1112) # MKS GEN L else ifeq ($(HARDWARE_MOTHERBOARD),1113) -# zrib V2.0 control board (Chinese knock off RAMPS replica) +# zrib V2.0 control board (Chinese RAMPS replica) else ifeq ($(HARDWARE_MOTHERBOARD),1114) # BigTreeTech or BIQU KFB2.0 else ifeq ($(HARDWARE_MOTHERBOARD),1115) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index f0d967c763..46c198a0ed 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -68,8 +68,8 @@ #define BOARD_MKS_GEN_13 1112 // MKS GEN v1.3 or 1.4 #define BOARD_MKS_GEN_L 1113 // MKS GEN L #define BOARD_KFB_2 1114 // BigTreeTech or BIQU KFB2.0 -#define BOARD_ZRIB_V20 1115 // zrib V2.0 control board (Chinese knock off RAMPS replica) -#define BOARD_ZRIB_V52 1116 // zrib V5.2 control board (Chinese knock off RAMPS replica) +#define BOARD_ZRIB_V20 1115 // zrib V2.0 (Chinese RAMPS replica) +#define BOARD_ZRIB_V52 1116 // zrib V5.2 (Chinese RAMPS replica) #define BOARD_FELIX2 1117 // Felix 2.0+ Electronics Board (RAMPS like) #define BOARD_RIGIDBOARD 1118 // Invent-A-Part RigidBoard #define BOARD_RIGIDBOARD_V2 1119 // Invent-A-Part RigidBoard V2 @@ -87,7 +87,7 @@ #define BOARD_FORMBOT_RAPTOR 1131 // Formbot Raptor #define BOARD_FORMBOT_RAPTOR2 1132 // Formbot Raptor 2 #define BOARD_BQ_ZUM_MEGA_3D 1133 // bq ZUM Mega 3D -#define BOARD_MAKEBOARD_MINI 1134 // MakeBoard Mini v2.1.2 is a control board sold by MicroMake +#define BOARD_MAKEBOARD_MINI 1134 // MakeBoard Mini v2.1.2 by MicroMake #define BOARD_TRIGORILLA_13 1135 // TriGorilla Anycubic version 1.3-based on RAMPS EFB #define BOARD_TRIGORILLA_14 1136 // ... Ver 1.4 #define BOARD_TRIGORILLA_14_11 1137 // ... Rev 1.1 (new servo pin order) @@ -174,8 +174,8 @@ #define BOARD_MELZI 1502 // Melzi #define BOARD_MELZI_V2 1503 // Melzi V2 #define BOARD_MELZI_MAKR3D 1504 // Melzi with ATmega1284 (MaKr3d version) -#define BOARD_MELZI_CREALITY 1505 // Melzi Creality3D board (for CR-10 etc) -#define BOARD_MELZI_MALYAN 1506 // Melzi Malyan M150 board +#define BOARD_MELZI_CREALITY 1505 // Melzi Creality3D (for CR-10 etc) +#define BOARD_MELZI_MALYAN 1506 // Melzi Malyan M150 #define BOARD_MELZI_TRONXY 1507 // Tronxy X5S #define BOARD_STB_11 1508 // STB V1.1 #define BOARD_AZTEEG_X1 1509 // Azteeg X1 @@ -194,8 +194,8 @@ #define BOARD_GEN7_12 1605 // Gen7 v1.1, v1.2 #define BOARD_GEN7_13 1606 // Gen7 v1.3 #define BOARD_GEN7_14 1607 // Gen7 v1.4 -#define BOARD_OMCA_A 1608 // Alpha OMCA board -#define BOARD_OMCA 1609 // Final OMCA board +#define BOARD_OMCA_A 1608 // Alpha OMCA +#define BOARD_OMCA 1609 // Final OMCA #define BOARD_SETHI 1610 // Sethi 3D_1 // @@ -226,7 +226,7 @@ #define BOARD_SELENA_COMPACT 2008 // Selena Compact (Power outputs: Hotend0, Hotend1, Bed0, Bed1, Fan0, Fan1) #define BOARD_BIQU_B300_V1_0 2009 // BIQU B300_V1.0 (Power outputs: Hotend0, Fan, Bed, SPI Driver) #define BOARD_MKS_SGEN_L 2010 // MKS-SGen-L (Power outputs: Hotend0, Hotend1, Bed, Fan) -#define BOARD_GMARSH_X6_REV1 2011 // GMARSH X6 board, revision 1 prototype +#define BOARD_GMARSH_X6_REV1 2011 // GMARSH X6, revision 1 prototype #define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed) #define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed) #define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed) @@ -392,8 +392,8 @@ // #define BOARD_ESPRESSIF_ESP32 6000 // Generic ESP32 -#define BOARD_MRR_ESPA 6001 // MRR ESPA board based on ESP32 (native pins only) -#define BOARD_MRR_ESPE 6002 // MRR ESPE board based on ESP32 (with I2S stepper stream) +#define BOARD_MRR_ESPA 6001 // MRR ESPA based on ESP32 (native pins only) +#define BOARD_MRR_ESPE 6002 // MRR ESPE based on ESP32 (with I2S stepper stream) #define BOARD_E4D_BOX 6003 // E4d@BOX #define BOARD_FYSETC_E4 6004 // FYSETC E4 From 1d3f28da2e9e7ecbecc4a25fffb120645a5b6ae1 Mon Sep 17 00:00:00 2001 From: George Fu Date: Mon, 29 Mar 2021 17:38:28 +0800 Subject: [PATCH 126/311] FYSETC Spider board (#21458) --- Marlin/src/core/boards.h | 19 ++-- Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f4/pins_FYSETC_S6.h | 18 ++- Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h | 110 +++++++++++++++++++ 4 files changed, 135 insertions(+), 14 deletions(-) create mode 100644 Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 46c198a0ed..a7ee18d6eb 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -368,15 +368,16 @@ #define BOARD_LERDGE_S 4212 // Lerdge S (STM32F407VE) #define BOARD_LERDGE_X 4213 // Lerdge X (STM32F407VE) #define BOARD_VAKE403D 4214 // VAkE 403D (STM32F446VET6) -#define BOARD_FYSETC_S6 4215 // FYSETC S6 board -#define BOARD_FYSETC_S6_V2_0 4216 // FYSETC S6 v2.0 board -#define BOARD_FLYF407ZG 4217 // FLYF407ZG board (STM32F407ZG) -#define BOARD_MKS_ROBIN2 4218 // MKS_ROBIN2 (STM32F407ZE) -#define BOARD_MKS_ROBIN_PRO_V2 4219 // MKS Robin Pro V2 (STM32F407VE) -#define BOARD_MKS_ROBIN_NANO_V3 4220 // MKS Robin Nano V3 (STM32F407VG) -#define BOARD_ANET_ET4 4221 // ANET ET4 V1.x (STM32F407VGT6) -#define BOARD_ANET_ET4P 4222 // ANET ET4P V1.x (STM32F407VGT6) -#define BOARD_FYSETC_CHEETAH_V20 4223 // FYSETC Cheetah V2.0 +#define BOARD_FYSETC_S6 4215 // FYSETC S6 (STM32F446VET6) +#define BOARD_FYSETC_S6_V2_0 4216 // FYSETC S6 v2.0 (STM32F446VET6) +#define BOARD_FYSETC_SPIDER 4217 // FYSETC Spider (STM32F446VET6) +#define BOARD_FLYF407ZG 4218 // FLYF407ZG (STM32F407ZG) +#define BOARD_MKS_ROBIN2 4219 // MKS_ROBIN2 (STM32F407ZE) +#define BOARD_MKS_ROBIN_PRO_V2 4220 // MKS Robin Pro V2 (STM32F407VE) +#define BOARD_MKS_ROBIN_NANO_V3 4221 // MKS Robin Nano V3 (STM32F407VG) +#define BOARD_ANET_ET4 4222 // ANET ET4 V1.x (STM32F407VGT6) +#define BOARD_ANET_ET4P 4223 // ANET ET4P V1.x (STM32F407VGT6) +#define BOARD_FYSETC_CHEETAH_V20 4224 // FYSETC Cheetah V2.0 // // ARM Cortex M7 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 58a87f2313..8eecce2c17 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -600,6 +600,8 @@ #include "stm32f4/pins_FYSETC_S6.h" // STM32F4 env:FYSETC_S6 #elif MB(FYSETC_S6_V2_0) #include "stm32f4/pins_FYSETC_S6_V2_0.h" // STM32F4 env:FYSETC_S6 +#elif MB(FYSETC_SPIDER) + #include "stm32f4/pins_FYSETC_SPIDER.h" // STM32F4 env:FYSETC_S6 #elif MB(FLYF407ZG) #include "stm32f4/pins_FLYF407ZG.h" // STM32F4 env:FLYF407ZG #elif MB(MKS_ROBIN2) diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index d617087e9d..e6420dc238 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -24,7 +24,7 @@ #include "env_validate.h" #if HOTENDS > 3 || E_STEPPERS > 3 - #error "RUMBA32 supports up to 3 hotends / E-steppers." + #error "FYSETC S6 supports up to 3 hotends / E-steppers." #endif #ifndef BOARD_INFO_NAME @@ -168,10 +168,18 @@ // // Heaters / Fans // -#define HEATER_0_PIN PB3 -#define HEATER_1_PIN PB4 -#define HEATER_2_PIN PB15 -#define HEATER_BED_PIN PC8 +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PB3 +#endif +#ifndef HEATER_0_PIN + #define HEATER_1_PIN PB4 +#endif +#ifndef HEATER_0_PIN + #define HEATER_2_PIN PB15 +#endif +#ifndef HEATER_0_PIN + #define HEATER_BED_PIN PC8 +#endif #define FAN_PIN PB0 #define FAN1_PIN PB1 diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h new file mode 100644 index 0000000000..a33f35bd55 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h @@ -0,0 +1,110 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "FYSETC SPIDER" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +#endif + +// +// EEPROM Emulation +// +#if NO_EEPROM_SELECTED + #undef NO_EEPROM_SELECTED + //#define FLASH_EEPROM_EMULATION + //#define SRAM_EEPROM_EMULATION + #define I2C_EEPROM +#endif + +#if ENABLED(I2C_EEPROM) + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// +// Steppers +// +#define X2_STEP_PIN PD12 +#define X2_DIR_PIN PC4 +#define X2_ENABLE_PIN PE8 +#define X2_CS_PIN PA15 + +#define Z2_STEP_PIN PE1 +#define Z2_DIR_PIN PE0 +#define Z2_ENABLE_PIN PC5 +#define Z2_CS_PIN PD11 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB15 +#define HEATER_1_PIN PC8 +#define HEATER_2_PIN PB3 +#define HEATER_BED_PIN PB4 + +// +// Steppers +// +#define X_ENABLE_PIN PE9 + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PE7 + #define X_SERIAL_RX_PIN PE7 + #define Y_SERIAL_TX_PIN PE15 + #define Y_SERIAL_RX_PIN PE15 + #define Z_SERIAL_TX_PIN PD10 + #define Z_SERIAL_RX_PIN PD10 + #define E0_SERIAL_TX_PIN PD7 + #define E0_SERIAL_RX_PIN PD7 + #define E1_SERIAL_TX_PIN PC14 + #define E1_SERIAL_RX_PIN PC14 + #define E2_SERIAL_TX_PIN PC15 + #define E2_SERIAL_RX_PIN PC15 + #define X2_SERIAL_TX_PIN PA15 + #define X2_SERIAL_RX_PIN PA15 + #define Z2_SERIAL_TX_PIN PD11 + #define Z2_SERIAL_RX_PIN PD11 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#define TMC_USE_SW_SPI +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PE13 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE12 + #endif +#endif + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "FYSETC SPIDER supports up to 3 hotends / E-steppers." +#else + #include "pins_FYSETC_S6.h" +#endif From 1caf8a1f5b1aaaca01e10af2a918a264ed549a1b Mon Sep 17 00:00:00 2001 From: ellensp Date: Mon, 29 Mar 2021 22:43:07 +1300 Subject: [PATCH 127/311] GT2560 Rev.A Plus Z Max Pin with BLTouch (#21375) --- Marlin/src/pins/mega/pins_GT2560_REV_A.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_A.h b/Marlin/src/pins/mega/pins_GT2560_REV_A.h index 2fb43a299f..1adf8d3079 100644 --- a/Marlin/src/pins/mega/pins_GT2560_REV_A.h +++ b/Marlin/src/pins/mega/pins_GT2560_REV_A.h @@ -47,10 +47,11 @@ #if ENABLED(BLTOUCH) #if MB(GT2560_REV_A_PLUS) #define SERVO0_PIN 11 + #define Z_MAX_PIN 32 #else #define SERVO0_PIN 32 + #define Z_MAX_PIN -1 #endif - #define Z_MAX_PIN -1 #else #define Z_MAX_PIN 32 #endif From 71e789943ea28ff7fddb1eb07295e75460703cb7 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 30 Mar 2021 00:32:47 +0000 Subject: [PATCH 128/311] [cron] Bump distribution date (2021-03-30) --- 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 86f557bd52..2e71c2231b 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-03-29" + #define STRING_DISTRIBUTION_DATE "2021-03-30" #endif /** From 3b73b115ca9366f0155986b717d4c85c31ed2f80 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Mar 2021 20:36:37 -0500 Subject: [PATCH 129/311] Apply pointer formatting --- Marlin/src/HAL/AVR/HAL_SPI.cpp | 8 +- Marlin/src/HAL/DUE/HAL_SPI.cpp | 30 ++++---- Marlin/src/HAL/DUE/eeprom_flash.cpp | 14 ++-- Marlin/src/HAL/DUE/usb/udi_cdc.h | 4 +- Marlin/src/HAL/DUE/usb/usb_task.c | 2 +- Marlin/src/HAL/ESP32/HAL_SPI.cpp | 4 +- Marlin/src/HAL/ESP32/WebSocketSerial.cpp | 2 +- Marlin/src/HAL/ESP32/WebSocketSerial.h | 4 +- Marlin/src/HAL/LPC1768/HAL_SPI.cpp | 10 +-- .../u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp | 2 +- Marlin/src/HAL/SAMD51/HAL_SPI.cpp | 4 +- Marlin/src/HAL/STM32/HAL_SPI.cpp | 4 +- Marlin/src/HAL/STM32/MarlinSerial.h | 2 +- Marlin/src/HAL/STM32F1/HAL_SPI.cpp | 6 +- Marlin/src/HAL/STM32F1/eeprom_flash.cpp | 4 +- Marlin/src/HAL/TEENSY31_32/HAL_SPI.cpp | 4 +- Marlin/src/HAL/TEENSY35_36/HAL_SPI.cpp | 4 +- Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp | 4 +- Marlin/src/HAL/shared/HAL_MinSerial.h | 2 +- Marlin/src/HAL/shared/HAL_SPI.h | 6 +- Marlin/src/HAL/shared/backtrace/backtrace.cpp | 2 +- Marlin/src/HAL/shared/eeprom_api.h | 6 +- Marlin/src/HAL/shared/eeprom_if_spi.cpp | 2 +- Marlin/src/core/macros.h | 4 +- Marlin/src/core/serial_base.h | 6 +- Marlin/src/feature/binary_stream.h | 10 +-- Marlin/src/feature/meatpack.cpp | 2 +- Marlin/src/feature/meatpack.h | 2 +- Marlin/src/feature/mmu/mmu2.cpp | 14 ++-- Marlin/src/feature/mmu/mmu2.h | 10 +-- Marlin/src/feature/runout.h | 10 +-- Marlin/src/gcode/queue.cpp | 6 +- Marlin/src/gcode/queue.h | 6 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 4 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 4 +- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 4 +- .../dogm/u8g_dev_tft_upscale_from_128x64.cpp | 6 +- .../dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp | 4 +- .../lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 4 +- .../extui/lib/dgus/fysetc/DGUSScreenHandler.h | 6 +- .../lib/dgus/hiprecy/DGUSScreenHandler.h | 6 +- .../extui/lib/dgus/mks/DGUSScreenHandler.cpp | 4 +- .../extui/lib/dgus/mks/DGUSScreenHandler.h | 10 +-- .../extui/lib/dgus/origin/DGUSScreenHandler.h | 6 +- .../archim2-flash/media_file_reader.cpp | 2 +- .../archim2-flash/media_file_reader.h | 2 +- .../ftdi_eve_lib/basic/spi.cpp | 4 +- .../ftdi_eve_lib/basic/spi.h | 4 +- .../ftdi_eve_lib/extended/sound_list.h | 2 +- .../ftdi_eve_lib/extended/sound_player.cpp | 2 +- .../ftdi_eve_lib/extended/sound_player.h | 2 +- .../ftdi_eve_lib/extended/text_ellipsis.cpp | 2 +- .../lib/ftdi_eve_touch_ui/marlin_events.cpp | 2 +- .../screens/bio_printing_dialog_box.cpp | 4 +- .../confirm_user_request_alert_box.cpp | 2 +- .../screens/files_screen.cpp | 2 +- .../ftdi_eve_touch_ui/screens/files_screen.h | 2 +- .../screens/status_screen.cpp | 4 +- .../lcd/extui/lib/mks_ui/SPIFlashStorage.cpp | 12 +-- .../lcd/extui/lib/mks_ui/SPIFlashStorage.h | 12 +-- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 20 ++--- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 2 +- .../src/lcd/extui/lib/mks_ui/pic_manager.cpp | 4 +- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 4 +- .../src/lcd/extui/lib/nextion/nextion_tft.cpp | 4 +- Marlin/src/lcd/extui/malyan_lcd.cpp | 14 ++-- Marlin/src/lcd/lcdprint.h | 2 +- Marlin/src/lcd/marlinui.h | 4 +- Marlin/src/lcd/menu/menu.h | 6 +- Marlin/src/lcd/tft/ui_320x240.cpp | 2 +- Marlin/src/lcd/tft/ui_480x320.cpp | 4 +- Marlin/src/lcd/tft/ui_common.cpp | 2 +- Marlin/src/libs/W25Qxx.cpp | 10 +-- Marlin/src/libs/W25Qxx.h | 10 +-- Marlin/src/libs/softspi.h | 4 +- Marlin/src/module/planner.cpp | 10 +-- Marlin/src/module/planner.h | 6 +- Marlin/src/module/stepper.cpp | 4 +- Marlin/src/module/stepper.h | 4 +- Marlin/src/module/stepper/trinamic.cpp | 6 +- Marlin/src/sd/Sd2Card.cpp | 22 +++--- Marlin/src/sd/Sd2Card.h | 16 ++-- Marlin/src/sd/SdBaseFile.cpp | 74 +++++++++---------- Marlin/src/sd/SdBaseFile.h | 38 +++++----- Marlin/src/sd/SdFatStructs.h | 8 +- Marlin/src/sd/SdFile.cpp | 4 +- Marlin/src/sd/SdFile.h | 4 +- Marlin/src/sd/SdVolume.cpp | 10 +-- Marlin/src/sd/SdVolume.h | 12 +-- Marlin/src/sd/cardreader.h | 2 +- .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 4 +- .../sd/usb_flashdrive/Sd2Card_FlashDrive.h | 8 +- Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp | 14 ++-- .../src/sd/usb_flashdrive/lib-uhs2/UsbCore.h | 20 ++--- .../sd/usb_flashdrive/lib-uhs2/usbhost.cpp | 4 +- .../src/sd/usb_flashdrive/lib-uhs2/usbhost.h | 4 +- .../lib-uhs3/UHS_host/UHS_host_INLINE.h | 12 +-- .../lib-uhs3/UHS_host/UHS_usbhost.h | 14 ++-- .../USB_HOST_SHIELD/USB_HOST_SHIELD.h | 6 +- .../USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h | 6 +- .../variants/MARLIN_F4x7Vx/hal_conf_extra.h | 2 +- buildroot/share/fonts/genpages.c | 4 +- 102 files changed, 364 insertions(+), 364 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL_SPI.cpp b/Marlin/src/HAL/AVR/HAL_SPI.cpp index 3e5572e559..1a1b98b3dd 100644 --- a/Marlin/src/HAL/AVR/HAL_SPI.cpp +++ b/Marlin/src/HAL/AVR/HAL_SPI.cpp @@ -88,7 +88,7 @@ void spiBegin() { } /** SPI read data */ - void spiRead(uint8_t* buf, uint16_t nbyte) { + void spiRead(uint8_t *buf, uint16_t nbyte) { if (nbyte-- == 0) return; SPDR = 0xFF; for (uint16_t i = 0; i < nbyte; i++) { @@ -107,7 +107,7 @@ void spiBegin() { } /** SPI send block */ - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { SPDR = token; for (uint16_t i = 0; i < 512; i += 2) { while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } @@ -215,7 +215,7 @@ void spiBegin() { } // Soft SPI read data - void spiRead(uint8_t* buf, uint16_t nbyte) { + void spiRead(uint8_t *buf, uint16_t nbyte) { for (uint16_t i = 0; i < nbyte; i++) buf[i] = spiRec(); } @@ -242,7 +242,7 @@ void spiBegin() { } // Soft SPI send block - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { spiSend(token); for (uint16_t i = 0; i < 512; i++) spiSend(buf[i]); diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp index 6cb2912c12..f42e8a9802 100644 --- a/Marlin/src/HAL/DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp @@ -56,8 +56,8 @@ #pragma GCC optimize (3) typedef uint8_t (*pfnSpiTransfer)(uint8_t b); - typedef void (*pfnSpiRxBlock)(uint8_t* buf, uint32_t nbyte); - typedef void (*pfnSpiTxBlock)(const uint8_t* buf, uint32_t nbyte); + typedef void (*pfnSpiRxBlock)(uint8_t *buf, uint32_t nbyte); + typedef void (*pfnSpiTxBlock)(const uint8_t *buf, uint32_t nbyte); /* ---------------- Macros to be able to access definitions from asm */ #define _PORT(IO) DIO ## IO ## _WPORT @@ -270,7 +270,7 @@ static pfnSpiTransfer spiTransferTx = (pfnSpiTransfer)spiTransferX; // Block transfers run at ~8 .. ~10Mhz - Tx version (Rx data discarded) - static void spiTxBlock0(const uint8_t* ptr, uint32_t todo) { + static void spiTxBlock0(const uint8_t *ptr, uint32_t todo) { uint32_t MOSI_PORT_PLUS30 = ((uint32_t) PORT(SD_MOSI_PIN)) + 0x30; /* SODR of port */ uint32_t MOSI_MASK = PIN_MASK(SD_MOSI_PIN); uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SD_SCK_PIN)) + 0x30; /* SODR of port */ @@ -349,7 +349,7 @@ ); } - static void spiRxBlock0(uint8_t* ptr, uint32_t todo) { + static void spiRxBlock0(uint8_t *ptr, uint32_t todo) { uint32_t bin = 0; uint32_t work = 0; uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(SD_MISO_PIN))+0x3C, PIN_SHIFT(SD_MISO_PIN)); /* PDSR of port in bitband area */ @@ -425,13 +425,13 @@ ); } - static void spiTxBlockX(const uint8_t* buf, uint32_t todo) { + static void spiTxBlockX(const uint8_t *buf, uint32_t todo) { do { (void)spiTransferTx(*buf++); } while (--todo); } - static void spiRxBlockX(uint8_t* buf, uint32_t todo) { + static void spiRxBlockX(uint8_t *buf, uint32_t todo) { do { *buf++ = spiTransferRx(0xFF); } while (--todo); @@ -463,7 +463,7 @@ return b; } - void spiRead(uint8_t* buf, uint16_t nbyte) { + void spiRead(uint8_t *buf, uint16_t nbyte) { if (nbyte) { _SS_WRITE(LOW); WRITE(SD_MOSI_PIN, HIGH); // Output 1s 1 @@ -478,7 +478,7 @@ _SS_WRITE(HIGH); } - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { _SS_WRITE(LOW); (void)spiTransferTx(token); spiTxBlock(buf, 512); @@ -645,7 +645,7 @@ } // Read from SPI into buffer - void spiRead(uint8_t* buf, uint16_t nbyte) { + void spiRead(uint8_t *buf, uint16_t nbyte) { if (!nbyte) return; --nbyte; for (int i = 0; i < nbyte; i++) { @@ -668,7 +668,7 @@ //DELAY_US(1U); } - void spiSend(const uint8_t* buf, size_t nbyte) { + void spiSend(const uint8_t *buf, size_t nbyte) { if (!nbyte) return; --nbyte; for (size_t i = 0; i < nbyte; i++) { @@ -689,7 +689,7 @@ FLUSH_RX(); } - void spiSend(uint32_t chan, const uint8_t* buf, size_t nbyte) { + void spiSend(uint32_t chan, const uint8_t *buf, size_t nbyte) { if (!nbyte) return; --nbyte; for (size_t i = 0; i < nbyte; i++) { @@ -702,7 +702,7 @@ } // Write from buffer to SPI - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { SPI0->SPI_TDR = (uint32_t)token | SPI_PCS(SPI_CHAN); WHILE_TX(0); //WHILE_RX(0); @@ -801,19 +801,19 @@ uint8_t spiRec() { return (uint8_t)spiTransfer(0xFF); } - void spiRead(uint8_t* buf, uint16_t nbyte) { + void spiRead(uint8_t *buf, uint16_t nbyte) { for (int i = 0; i < nbyte; i++) buf[i] = spiTransfer(0xFF); } void spiSend(uint8_t data) { spiTransfer(data); } - void spiSend(const uint8_t* buf, size_t nbyte) { + void spiSend(const uint8_t *buf, size_t nbyte) { for (uint16_t i = 0; i < nbyte; i++) spiTransfer(buf[i]); } - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { spiTransfer(token); for (uint16_t i = 0; i < 512; i++) spiTransfer(buf[i]); diff --git a/Marlin/src/HAL/DUE/eeprom_flash.cpp b/Marlin/src/HAL/DUE/eeprom_flash.cpp index 738f44acc9..14c843576c 100644 --- a/Marlin/src/HAL/DUE/eeprom_flash.cpp +++ b/Marlin/src/HAL/DUE/eeprom_flash.cpp @@ -139,7 +139,7 @@ static void ee_Dump(const int page, const void* data) { #ifdef EE_EMU_DEBUG - const uint8_t* c = (const uint8_t*) data; + const uint8_t *c = (const uint8_t*) data; char buffer[80]; sprintf_P(buffer, PSTR("Page: %d (0x%04x)\n"), page, page); @@ -293,8 +293,8 @@ static bool ee_PageWrite(uint16_t page, const void* data) { ee_Dump(-page, data); // Calculate count of changed bits - uint32_t* p1 = (uint32_t*)addrflash; - uint32_t* p2 = (uint32_t*)data; + uint32_t *p1 = (uint32_t*)addrflash; + uint32_t *p2 = (uint32_t*)data; int count = 0; for (i =0; i> 2; i++) { if (p1[i] != p2[i]) { @@ -470,7 +470,7 @@ static uint8_t ee_Read(uint32_t address, bool excludeRAMBuffer=false) { for (int page = curPage - 1; page >= 0; --page) { // Get a pointer to the flash page - uint8_t* pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup); + uint8_t *pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup); uint16_t i = 0; while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */ @@ -550,7 +550,7 @@ static uint32_t ee_GetAddrRange(uint32_t address, bool excludeRAMBuffer=false) { for (int page = curPage - 1; page >= 0; --page) { // Get a pointer to the flash page - uint8_t* pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup); + uint8_t *pflash = (uint8_t*)getFlashStorage(page + curGroup * PagesPerGroup); uint16_t i = 0; while (i <= (PageSize - 4)) { /* (PageSize - 4) because otherwise, there is not enough room for data and headers */ @@ -589,7 +589,7 @@ static uint32_t ee_GetAddrRange(uint32_t address, bool excludeRAMBuffer=false) { } static bool ee_IsPageClean(int page) { - uint32_t* pflash = (uint32_t*) getFlashStorage(page); + uint32_t *pflash = (uint32_t*) getFlashStorage(page); for (uint16_t i = 0; i < (PageSize >> 2); ++i) if (*pflash++ != 0xFFFFFFFF) return false; return true; @@ -599,7 +599,7 @@ static bool ee_Flush(uint32_t overrideAddress = 0xFFFFFFFF, uint8_t overrideData // Check if RAM buffer has something to be written bool isEmpty = true; - uint32_t* p = (uint32_t*) &buffer[0]; + uint32_t *p = (uint32_t*) &buffer[0]; for (uint16_t j = 0; j < (PageSize >> 2); j++) { if (*p++ != 0xFFFFFFFF) { isEmpty = false; diff --git a/Marlin/src/HAL/DUE/usb/udi_cdc.h b/Marlin/src/HAL/DUE/usb/udi_cdc.h index 0ecf7bb00e..b61845011a 100644 --- a/Marlin/src/HAL/DUE/usb/udi_cdc.h +++ b/Marlin/src/HAL/DUE/usb/udi_cdc.h @@ -675,11 +675,11 @@ iram_size_t udi_cdc_multi_write_buf(uint8_t port, const void* buf, iram_size_t s * - \code // Waits and gets a value on CDC line int udi_cdc_getc(void); // Reads a RAM buffer on CDC line - iram_size_t udi_cdc_read_buf(int* buf, iram_size_t size); + iram_size_t udi_cdc_read_buf(int *buf, iram_size_t size); // Puts a byte on CDC line int udi_cdc_putc(int value); // Writes a RAM buffer on CDC line - iram_size_t udi_cdc_write_buf(const int* buf, iram_size_t size); \endcode + iram_size_t udi_cdc_write_buf(const int *buf, iram_size_t size); \endcode * * \section udi_cdc_use_cases Advanced use cases * For more advanced use of the UDI CDC module, see the following use cases: diff --git a/Marlin/src/HAL/DUE/usb/usb_task.c b/Marlin/src/HAL/DUE/usb/usb_task.c index 66bdb265d8..acb1d5b933 100644 --- a/Marlin/src/HAL/DUE/usb/usb_task.c +++ b/Marlin/src/HAL/DUE/usb/usb_task.c @@ -264,7 +264,7 @@ bool usb_task_extra_string(void) { ** Handle device requests that the ASF stack doesn't */ bool usb_task_other_requests(void) { - uint8_t* ptr = 0; + uint8_t *ptr = 0; uint16_t size = 0; if (Udd_setup_type() == USB_REQ_TYPE_VENDOR) { diff --git a/Marlin/src/HAL/ESP32/HAL_SPI.cpp b/Marlin/src/HAL/ESP32/HAL_SPI.cpp index 8ee837ba15..8743ac5be2 100644 --- a/Marlin/src/HAL/ESP32/HAL_SPI.cpp +++ b/Marlin/src/HAL/ESP32/HAL_SPI.cpp @@ -85,7 +85,7 @@ uint8_t spiRec() { return returnByte; } -void spiRead(uint8_t* buf, uint16_t nbyte) { +void spiRead(uint8_t *buf, uint16_t nbyte) { SPI.beginTransaction(spiConfig); SPI.transferBytes(0, buf, nbyte); SPI.endTransaction(); @@ -97,7 +97,7 @@ void spiSend(uint8_t b) { SPI.endTransaction(); } -void spiSendBlock(uint8_t token, const uint8_t* buf) { +void spiSendBlock(uint8_t token, const uint8_t *buf) { SPI.beginTransaction(spiConfig); SPI.transfer(token); SPI.writeBytes(const_cast(buf), 512); diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp index 8825742d38..96769f261f 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp +++ b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp @@ -137,7 +137,7 @@ size_t WebSocketSerial::write(const uint8_t c) { return ret; } -size_t WebSocketSerial::write(const uint8_t* buffer, size_t size) { +size_t WebSocketSerial::write(const uint8_t *buffer, size_t size) { size_t written = 0; for (size_t i = 0; i < size; i++) written += write(buffer[i]); diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.h b/Marlin/src/HAL/ESP32/WebSocketSerial.h index 924d36f15c..574f7b10f0 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.h +++ b/Marlin/src/HAL/ESP32/WebSocketSerial.h @@ -54,7 +54,7 @@ public: ring_buffer_pos_t read(uint8_t *buffer); void flush(); ring_buffer_pos_t write(const uint8_t c); - ring_buffer_pos_t write(const uint8_t* buffer, ring_buffer_pos_t size); + ring_buffer_pos_t write(const uint8_t *buffer, ring_buffer_pos_t size); }; class WebSocketSerial: public Stream { @@ -70,7 +70,7 @@ public: int read(); void flush(); size_t write(const uint8_t c); - size_t write(const uint8_t* buffer, size_t size); + size_t write(const uint8_t *buffer, size_t size); #if ENABLED(SERIAL_STATS_DROPPED_RX) FORCE_INLINE uint32_t dropped() { return 0; } diff --git a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp index dbc89a33f5..99db15f6e9 100644 --- a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp +++ b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp @@ -93,12 +93,12 @@ void spiSend(uint8_t b) { (void)spiTransfer(b); } - void spiSend(const uint8_t* buf, size_t nbyte) { + void spiSend(const uint8_t *buf, size_t nbyte) { for (uint16_t i = 0; i < nbyte; i++) (void)spiTransfer(buf[i]); } - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { (void)spiTransfer(token); for (uint16_t i = 0; i < 512; i++) (void)spiTransfer(buf[i]); @@ -135,13 +135,13 @@ void spiSend(uint8_t b) { doio(b); } - void spiSend(const uint8_t* buf, size_t nbyte) { + void spiSend(const uint8_t *buf, size_t nbyte) { for (uint16_t i = 0; i < nbyte; i++) doio(buf[i]); } void spiSend(uint32_t chan, byte b) {} - void spiSend(uint32_t chan, const uint8_t* buf, size_t nbyte) {} + void spiSend(uint32_t chan, const uint8_t *buf, size_t nbyte) {} // Read single byte from SPI uint8_t spiRec() { return doio(0xFF); } @@ -156,7 +156,7 @@ uint8_t spiTransfer(uint8_t b) { return doio(b); } // Write from buffer to SPI - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { (void)spiTransfer(token); for (uint16_t i = 0; i < 512; i++) (void)spiTransfer(buf[i]); diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp index 592e27f6c0..0b0626de79 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp @@ -66,7 +66,7 @@ void spiBegin(); void spiInit(uint8_t spiRate); void spiSend(uint8_t b); -void spiSend(const uint8_t* buf, size_t n); +void spiSend(const uint8_t *buf, size_t n); static uint8_t rs_last_state = 255; diff --git a/Marlin/src/HAL/SAMD51/HAL_SPI.cpp b/Marlin/src/HAL/SAMD51/HAL_SPI.cpp index c3acd38237..77f4d5ecd5 100644 --- a/Marlin/src/HAL/SAMD51/HAL_SPI.cpp +++ b/Marlin/src/HAL/SAMD51/HAL_SPI.cpp @@ -103,7 +103,7 @@ * @param nbyte Number of bytes to receive. * @return Nothing */ - void spiRead(uint8_t* buf, uint16_t nbyte) { + void spiRead(uint8_t *buf, uint16_t nbyte) { if (nbyte == 0) return; memset(buf, 0xFF, nbyte); sdSPI.beginTransaction(spiConfig); @@ -132,7 +132,7 @@ * * @details Uses DMA */ - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { sdSPI.beginTransaction(spiConfig); sdSPI.transfer(token); sdSPI.transfer((uint8_t*)buf, nullptr, 512); diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index c9f23e6fa3..80347e115d 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -193,7 +193,7 @@ static SPISettings spiConfig; * * @details Uses DMA */ - void spiRead(uint8_t* buf, uint16_t nbyte) { + void spiRead(uint8_t *buf, uint16_t nbyte) { if (nbyte == 0) return; memset(buf, 0xFF, nbyte); SPI.transfer(buf, nbyte); @@ -218,7 +218,7 @@ static SPISettings spiConfig; * * @details Use DMA */ - void spiSendBlock(uint8_t token, const uint8_t* buf) { + void spiSendBlock(uint8_t token, const uint8_t *buf) { uint8_t rxBuf[512]; SPI.transfer(token); SPI.transfer((uint8_t*)buf, &rxBuf, 512); diff --git a/Marlin/src/HAL/STM32/MarlinSerial.h b/Marlin/src/HAL/STM32/MarlinSerial.h index 7b0529cfd2..d9e8457017 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.h +++ b/Marlin/src/HAL/STM32/MarlinSerial.h @@ -36,7 +36,7 @@ struct MarlinSerial : public HardwareSerial { void begin(unsigned long baud, uint8_t config); inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); } - void _rx_complete_irq(serial_t* obj); + void _rx_complete_irq(serial_t *obj); protected: usart_rx_callback_t _rx_callback; diff --git a/Marlin/src/HAL/STM32F1/HAL_SPI.cpp b/Marlin/src/HAL/STM32F1/HAL_SPI.cpp index 7e876f765f..abb348d743 100644 --- a/Marlin/src/HAL/STM32F1/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32F1/HAL_SPI.cpp @@ -123,7 +123,7 @@ uint8_t spiRec() { * * @details Uses DMA */ -void spiRead(uint8_t* buf, uint16_t nbyte) { +void spiRead(uint8_t *buf, uint16_t nbyte) { SPI.dmaTransfer(0, const_cast(buf), nbyte); } @@ -146,7 +146,7 @@ void spiSend(uint8_t b) { * * @details Use DMA */ -void spiSendBlock(uint8_t token, const uint8_t* buf) { +void spiSendBlock(uint8_t token, const uint8_t *buf) { SPI.send(token); SPI.dmaSend(const_cast(buf), 512); } @@ -160,7 +160,7 @@ uint8_t spiRec(uint32_t chan) { return SPI.transfer(0xFF); } void spiSend(uint32_t chan, byte b) { SPI.send(b); } // Write buffer to specified SPI channel -void spiSend(uint32_t chan, const uint8_t* buf, size_t n) { +void spiSend(uint32_t chan, const uint8_t *buf, size_t n) { for (size_t p = 0; p < n; p++) spiSend(chan, buf[p]); } diff --git a/Marlin/src/HAL/STM32F1/eeprom_flash.cpp b/Marlin/src/HAL/STM32F1/eeprom_flash.cpp index dfcaaaf29f..e7d9dd29e2 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_flash.cpp @@ -48,8 +48,8 @@ static uint8_t ram_eeprom[MARLIN_EEPROM_SIZE] __attribute__((aligned(4))) = {0}; static bool eeprom_dirty = false; bool PersistentStore::access_start() { - const uint32_t* source = reinterpret_cast(EEPROM_PAGE0_BASE); - uint32_t* destination = reinterpret_cast(ram_eeprom); + const uint32_t *source = reinterpret_cast(EEPROM_PAGE0_BASE); + uint32_t *destination = reinterpret_cast(ram_eeprom); static_assert(0 == (MARLIN_EEPROM_SIZE) % 4, "MARLIN_EEPROM_SIZE is corrupted. (Must be a multiple of 4.)"); // Ensure copying as uint32_t is safe constexpr size_t eeprom_size_u32 = (MARLIN_EEPROM_SIZE) / 4; diff --git a/Marlin/src/HAL/TEENSY31_32/HAL_SPI.cpp b/Marlin/src/HAL/TEENSY31_32/HAL_SPI.cpp index dce236ef6b..21330eaac1 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL_SPI.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL_SPI.cpp @@ -82,7 +82,7 @@ uint8_t spiRec() { } // SPI read data -void spiRead(uint8_t* buf, uint16_t nbyte) { +void spiRead(uint8_t *buf, uint16_t nbyte) { SPI.beginTransaction(spiConfig); SPI.transfer(buf, nbyte); SPI.endTransaction(); @@ -107,7 +107,7 @@ void spiSend(uint8_t b) { } // SPI send block -void spiSendBlock(uint8_t token, const uint8_t* buf) { +void spiSendBlock(uint8_t token, const uint8_t *buf) { SPI.beginTransaction(spiConfig); SPDR = token; for (uint16_t i = 0; i < 512; i += 2) { diff --git a/Marlin/src/HAL/TEENSY35_36/HAL_SPI.cpp b/Marlin/src/HAL/TEENSY35_36/HAL_SPI.cpp index 84852cd358..5b22668fce 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL_SPI.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL_SPI.cpp @@ -80,7 +80,7 @@ uint8_t spiRec() { //return SPDR; } -void spiRead(uint8_t* buf, uint16_t nbyte) { +void spiRead(uint8_t *buf, uint16_t nbyte) { SPI.beginTransaction(spiConfig); SPI.transfer(buf, nbyte); SPI.endTransaction(); @@ -103,7 +103,7 @@ void spiSend(uint8_t b) { //while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } } -void spiSendBlock(uint8_t token, const uint8_t* buf) { +void spiSendBlock(uint8_t token, const uint8_t *buf) { SPI.beginTransaction(spiConfig); SPDR = token; for (uint16_t i = 0; i < 512; i += 2) { diff --git a/Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp b/Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp index 8c93049027..e4335ff74f 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp @@ -97,7 +97,7 @@ uint8_t spiRec() { //return SPDR; } -void spiRead(uint8_t* buf, uint16_t nbyte) { +void spiRead(uint8_t *buf, uint16_t nbyte) { SPI.beginTransaction(spiConfig); SPI.transfer(buf, nbyte); SPI.endTransaction(); @@ -120,7 +120,7 @@ void spiSend(uint8_t b) { //while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } } -void spiSendBlock(uint8_t token, const uint8_t* buf) { +void spiSendBlock(uint8_t token, const uint8_t *buf) { SPI.beginTransaction(spiConfig); SPDR = token; for (uint16_t i = 0; i < 512; i += 2) { diff --git a/Marlin/src/HAL/shared/HAL_MinSerial.h b/Marlin/src/HAL/shared/HAL_MinSerial.h index 04643c1ab3..3089b8aa06 100644 --- a/Marlin/src/HAL/shared/HAL_MinSerial.h +++ b/Marlin/src/HAL/shared/HAL_MinSerial.h @@ -42,7 +42,7 @@ struct MinSerial { HAL_min_serial_out(ch); } // Send String through UART - static void TX(const char* s) { while (*s) TX(*s++); } + static void TX(const char *s) { while (*s) TX(*s++); } // Send a digit through UART static void TXDigit(uint32_t d) { if (d < 10) TX((char)(d+'0')); diff --git a/Marlin/src/HAL/shared/HAL_SPI.h b/Marlin/src/HAL/shared/HAL_SPI.h index 59af554806..6611f9ec4e 100644 --- a/Marlin/src/HAL/shared/HAL_SPI.h +++ b/Marlin/src/HAL/shared/HAL_SPI.h @@ -71,10 +71,10 @@ void spiSend(uint8_t b); uint8_t spiRec(); // Read from SPI into buffer -void spiRead(uint8_t* buf, uint16_t nbyte); +void spiRead(uint8_t *buf, uint16_t nbyte); // Write token and then write from 512 byte buffer to SPI (for SD card) -void spiSendBlock(uint8_t token, const uint8_t* buf); +void spiSendBlock(uint8_t token, const uint8_t *buf); // Begin SPI transaction, set clock, bit order, data mode void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode); @@ -87,7 +87,7 @@ void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode); void spiSend(uint32_t chan, byte b); // Write buffer to specified SPI channel -void spiSend(uint32_t chan, const uint8_t* buf, size_t n); +void spiSend(uint32_t chan, const uint8_t *buf, size_t n); // Read single byte from specified SPI channel uint8_t spiRec(uint32_t chan); diff --git a/Marlin/src/HAL/shared/backtrace/backtrace.cpp b/Marlin/src/HAL/shared/backtrace/backtrace.cpp index 8320f47509..e4ae502a88 100644 --- a/Marlin/src/HAL/shared/backtrace/backtrace.cpp +++ b/Marlin/src/HAL/shared/backtrace/backtrace.cpp @@ -44,7 +44,7 @@ static bool UnwReportOut(void* ctx, const UnwReport* bte) { } #ifdef UNW_DEBUG - void UnwPrintf(const char* format, ...) { + void UnwPrintf(const char *format, ...) { char dest[256]; va_list argptr; va_start(argptr, format); diff --git a/Marlin/src/HAL/shared/eeprom_api.h b/Marlin/src/HAL/shared/eeprom_api.h index 6445f7a4aa..1f38639930 100644 --- a/Marlin/src/HAL/shared/eeprom_api.h +++ b/Marlin/src/HAL/shared/eeprom_api.h @@ -45,11 +45,11 @@ public: // Read one or more bytes of data and update the CRC // Return 'true' on read error - static bool read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing=true); + static bool read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing=true); // Write one or more bytes of data // Return 'true' on write error - static inline bool write_data(const int pos, const uint8_t* value, const size_t size=sizeof(uint8_t)) { + static inline bool write_data(const int pos, const uint8_t *value, const size_t size=sizeof(uint8_t)) { int data_pos = pos; uint16_t crc = 0; return write_data(data_pos, value, size, &crc); @@ -61,7 +61,7 @@ public: // Read one or more bytes of data // Return 'true' on read error - static inline bool read_data(const int pos, uint8_t* value, const size_t size=1) { + static inline bool read_data(const int pos, uint8_t *value, const size_t size=1) { int data_pos = pos; uint16_t crc = 0; return read_data(data_pos, value, size, &crc); diff --git a/Marlin/src/HAL/shared/eeprom_if_spi.cpp b/Marlin/src/HAL/shared/eeprom_if_spi.cpp index e162f6fedc..6aa6e09096 100644 --- a/Marlin/src/HAL/shared/eeprom_if_spi.cpp +++ b/Marlin/src/HAL/shared/eeprom_if_spi.cpp @@ -55,7 +55,7 @@ static void _eeprom_begin(uint8_t * const pos, const uint8_t cmd) { // Leave the Bus in-use } -uint8_t eeprom_read_byte(uint8_t* pos) { +uint8_t eeprom_read_byte(uint8_t *pos) { _eeprom_begin(pos, CMD_READ); // Set read location and begin transmission const uint8_t v = spiRec(SPI_CHAN_EEPROM1); // After READ a value sits on the Bus diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index d7043ba523..f900993784 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -362,13 +362,13 @@ return *str == '/' ? true : (*str ? containsSlash(str + 1) : false); } // Find the last position of the slash - constexpr const char* findLastSlashPos(const char* str) { + constexpr const char* findLastSlashPos(const char *str) { return *str == '/' ? (str + 1) : findLastSlashPos(str - 1); } // Compile-time evaluation of the last part of a file path // Typically used to shorten the path to file in compiled strings // CompileTimeString::baseName(__FILE__) returns "macros.h" and not /path/to/Marlin/src/core/macros.h - constexpr const char* baseName(const char* str) { + constexpr const char* baseName(const char *str) { return containsSlash(str) ? findLastSlashPos(findStringEnd(str)) : str; } } diff --git a/Marlin/src/core/serial_base.h b/Marlin/src/core/serial_base.h index f8fe3a181d..78721c6f14 100644 --- a/Marlin/src/core/serial_base.h +++ b/Marlin/src/core/serial_base.h @@ -108,9 +108,9 @@ struct SerialBase { void flushTX() { CALL_IF_EXISTS(void, static_cast(this), flushTX); } // Glue code here - 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); } + 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 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); } diff --git a/Marlin/src/feature/binary_stream.h b/Marlin/src/feature/binary_stream.h index b5d68196ae..9eb151b27f 100644 --- a/Marlin/src/feature/binary_stream.h +++ b/Marlin/src/feature/binary_stream.h @@ -51,10 +51,10 @@ class SDFileTransferProtocol { private: struct Packet { struct [[gnu::packed]] Open { - static bool validate(char* buffer, size_t length) { + static bool validate(char *buffer, size_t length) { return (length > sizeof(Open) && buffer[length - 1] == '\0'); } - static Open& decode(char* buffer) { + static Open& decode(char *buffer) { data = &buffer[2]; return *reinterpret_cast(buffer); } @@ -67,7 +67,7 @@ private: }; }; - static bool file_open(char* filename) { + static bool file_open(char *filename) { if (!dummy_transfer) { card.mount(); card.openFileWrite(filename); @@ -79,7 +79,7 @@ private: return true; } - static bool file_write(char* buffer, const size_t length) { + static bool file_write(char *buffer, const size_t length) { #if ENABLED(BINARY_STREAM_COMPRESSION) if (compression) { size_t total_processed = 0, processed_count = 0; @@ -150,7 +150,7 @@ public: } } - static void process(uint8_t packet_type, char* buffer, const uint16_t length) { + static void process(uint8_t packet_type, char *buffer, const uint16_t length) { transfer_timeout = millis() + TIMEOUT; switch (static_cast(packet_type)) { case FileTransfer::QUERY: diff --git a/Marlin/src/feature/meatpack.cpp b/Marlin/src/feature/meatpack.cpp index 0742f82350..6803a0de7d 100644 --- a/Marlin/src/feature/meatpack.cpp +++ b/Marlin/src/feature/meatpack.cpp @@ -205,7 +205,7 @@ void MeatPack::handle_rx_char(const uint8_t c, const serial_index_t serial_ind) handle_rx_char_inner(c); // Other characters are passed on for MeatPack decoding } -uint8_t MeatPack::get_result_char(char* const __restrict out) { +uint8_t MeatPack::get_result_char(char * const __restrict out) { uint8_t res = 0; if (char_out_count) { res = char_out_count; diff --git a/Marlin/src/feature/meatpack.h b/Marlin/src/feature/meatpack.h index 80f4570e03..2c4c4686d8 100644 --- a/Marlin/src/feature/meatpack.h +++ b/Marlin/src/feature/meatpack.h @@ -109,7 +109,7 @@ public: * @param out [in] Output pointer for unpacked/processed data. * @return Number of characters returned. Range from 0 to 2. */ - uint8_t get_result_char(char* const __restrict out); + uint8_t get_result_char(char * const __restrict out); void reset_state(); void report_state(); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index d4238400c7..c1c34f8eee 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -362,7 +362,7 @@ bool MMU2::rx_start() { /** * Check if the data received ends with the given string. */ -bool MMU2::rx_str_P(const char* str) { +bool MMU2::rx_str_P(const char *str) { uint8_t i = strlen(rx_buffer); while (MMU2_SERIAL.available()) { @@ -394,7 +394,7 @@ bool MMU2::rx_str_P(const char* str) { /** * Transfer data to MMU, no argument */ -void MMU2::tx_str_P(const char* str) { +void MMU2::tx_str_P(const char *str) { clear_rx_buffer(); uint8_t len = strlen_P(str); LOOP_L_N(i, len) MMU2_SERIAL.write(pgm_read_byte(str++)); @@ -404,7 +404,7 @@ void MMU2::tx_str_P(const char* str) { /** * Transfer data to MMU, single argument */ -void MMU2::tx_printf_P(const char* format, int argument = -1) { +void MMU2::tx_printf_P(const char *format, int argument = -1) { clear_rx_buffer(); uint8_t len = sprintf_P(tx_buffer, format, argument); LOOP_L_N(i, len) MMU2_SERIAL.write(tx_buffer[i]); @@ -414,7 +414,7 @@ void MMU2::tx_printf_P(const char* format, int argument = -1) { /** * Transfer data to MMU, two arguments */ -void MMU2::tx_printf_P(const char* format, int argument1, int argument2) { +void MMU2::tx_printf_P(const char *format, int argument1, int argument2) { clear_rx_buffer(); uint8_t len = sprintf_P(tx_buffer, format, argument1, argument2); LOOP_L_N(i, len) MMU2_SERIAL.write(tx_buffer[i]); @@ -511,7 +511,7 @@ static void mmu2_not_responding() { * Tx Same as T?, except nozzle doesn't have to be preheated. Tc must be placed after extruder nozzle is preheated to finish filament load. * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ - void MMU2::tool_change(const char* special) { + void MMU2::tool_change(const char *special) { if (!enabled) return; set_runout_valid(false); @@ -598,7 +598,7 @@ static void mmu2_not_responding() { * Tx Same as T?, except nozzle doesn't have to be preheated. Tc must be placed after extruder nozzle is preheated to finish filament load. * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ - void MMU2::tool_change(const char* special) { + void MMU2::tool_change(const char *special) { if (!enabled) return; set_runout_valid(false); @@ -692,7 +692,7 @@ static void mmu2_not_responding() { * Tx Same as T?, except nozzle doesn't have to be preheated. Tc must be placed after extruder nozzle is preheated to finish filament load. * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. */ - void MMU2::tool_change(const char* special) { + void MMU2::tool_change(const char *special) { if (!enabled) return; set_runout_valid(false); diff --git a/Marlin/src/feature/mmu/mmu2.h b/Marlin/src/feature/mmu/mmu2.h index 4326989a74..079a6ef79a 100644 --- a/Marlin/src/feature/mmu/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -45,7 +45,7 @@ public: static void reset(); static void mmu_loop(); static void tool_change(const uint8_t index); - static void tool_change(const char* special); + static void tool_change(const char *special); static uint8_t get_current_tool(); static void set_filament_type(const uint8_t index, const uint8_t type); @@ -56,10 +56,10 @@ public: static bool eject_filament(const uint8_t index, const bool recover); private: - static bool rx_str_P(const char* str); - static void tx_str_P(const char* str); - static void tx_printf_P(const char* format, const int argument); - static void tx_printf_P(const char* format, const int argument1, const int argument2); + static bool rx_str_P(const char *str); + static void tx_str_P(const char *str); + static void tx_printf_P(const char *format, const int argument); + static void tx_printf_P(const char *format, const int argument1, const int argument2); static void clear_rx_buffer(); static bool rx_ok(); diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 34ae67899b..0c35ef6659 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -106,7 +106,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. - static inline void block_completed(const block_t* const b) { + static inline void block_completed(const block_t * const b) { if (enabled) { response.block_completed(b); sensor.block_completed(b); @@ -273,7 +273,7 @@ class FilamentSensorBase { } public: - static inline void block_completed(const block_t* const b) { + static inline void block_completed(const block_t * const b) { // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. if (TEST(motion_detected, b->extruder)) @@ -307,7 +307,7 @@ class FilamentSensorBase { } public: - static inline void block_completed(const block_t* const) {} + static inline void block_completed(const block_t * const) {} static inline void run() { LOOP_L_N(s, NUM_RUNOUT_SENSORS) { @@ -368,7 +368,7 @@ class FilamentSensorBase { runout_mm_countdown[extruder] = runout_distance_mm; } - static inline void block_completed(const block_t* const b) { + static inline void block_completed(const block_t * const b) { if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. const uint8_t e = b->extruder; @@ -403,7 +403,7 @@ class FilamentSensorBase { return runout_flags; } - static inline void block_completed(const block_t* const) { } + static inline void block_completed(const block_t * const) { } static inline void filament_present(const uint8_t extruder) { runout_count[extruder] = runout_threshold; diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 7845b01ad6..a79909917e 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -99,7 +99,7 @@ void GCodeQueue::RingBuffer::commit_command(bool skip_ok * Return true if the command was successfully added. * Return false for a full buffer, or if the 'command' is a comment. */ -bool GCodeQueue::RingBuffer::enqueue(const char* cmd, bool skip_ok/*=true*/ +bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/ #if HAS_MULTI_SERIAL , serial_index_t serial_ind/*=-1*/ #endif @@ -118,7 +118,7 @@ bool GCodeQueue::RingBuffer::enqueue(const char* cmd, bool skip_ok/*=true*/ * Enqueue with Serial Echo * Return true if the command was consumed */ -bool GCodeQueue::enqueue_one(const char* cmd) { +bool GCodeQueue::enqueue_one(const char *cmd) { //SERIAL_ECHOLNPAIR("enqueue_one(\"", cmd, "\")"); if (*cmd == 0 || ISEOL(*cmd)) return true; @@ -187,7 +187,7 @@ bool GCodeQueue::process_injected_command() { * Enqueue and return only when commands are actually enqueued. * Never call this from a G-code handler! */ -void GCodeQueue::enqueue_one_now(const char* cmd) { while (!enqueue_one(cmd)) idle(); } +void GCodeQueue::enqueue_one_now(const char *cmd) { while (!enqueue_one(cmd)) idle(); } /** * Attempt to enqueue a single G-code command diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 4d3ccb364e..5df4a0104c 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -85,7 +85,7 @@ public: #endif ); - bool enqueue(const char* cmd, bool skip_ok = true + bool enqueue(const char *cmd, bool skip_ok = true #if HAS_MULTI_SERIAL , serial_index_t serial_ind = serial_index_t() #endif @@ -143,7 +143,7 @@ public: /** * Enqueue and return only when commands are actually enqueued */ - static void enqueue_one_now(const char* cmd); + static void enqueue_one_now(const char *cmd); /** * Attempt to enqueue a single G-code command @@ -219,7 +219,7 @@ private: * Enqueue with Serial Echo * Return true on success */ - static bool enqueue_one(const char* cmd); + static bool enqueue_one(const char *cmd); static void gcode_line_error(PGM_P const err, const serial_index_t serial_ind); diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 683c1c0884..e18ed7273c 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -1076,7 +1076,7 @@ void MarlinUI::draw_status_screen() { } // Draw a menu item with a (potentially) editable value - void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const inStr, const bool pgm) { + void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm) { const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)) : 0; lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vlen); @@ -1088,7 +1088,7 @@ void MarlinUI::draw_status_screen() { } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace - void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) { + void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); uint8_t n = lcd_put_u8str_ind_P(0, 1, pstr, itemIndex, itemString, LCD_WIDTH - 1); if (value) { diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index e645a76611..6976bfed22 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -835,7 +835,7 @@ void MarlinUI::draw_status_screen() { } // Draw a menu item with a (potentially) editable value - void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) { + void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const data, const bool pgm) { if (!PanelDetected) return; const uint8_t vlen = data ? (pgm ? utf8_strlen_P(data) : utf8_strlen(data)) : 0; lcd.setCursor(0, row); @@ -851,7 +851,7 @@ void MarlinUI::draw_status_screen() { // Low-level draw_edit_screen can be used to draw an edit screen from anyplace // This line moves to the last line of the screen for UBL plot screen on the panel side - void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) { + void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { if (!PanelDetected) return; ui.encoder_direction_normal(); const uint8_t y = TERN0(AUTO_BED_LEVELING_UBL, ui.external_control) ? LCD_HEIGHT - 1 : MIDDLE_Y; diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index a3b14d8609..c2d2cf43af 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -385,7 +385,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop } // Draw a menu item with an editable value - void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const inStr, const bool pgm) { + void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm) { if (mark_as_selected(row, sel)) { const uint8_t vallen = (pgm ? utf8_strlen_P(inStr) : utf8_strlen((char*)inStr)), pixelwidth = (pgm ? uxg_GetUtf8StrPixelWidthP(u8g.getU8g(), inStr) : uxg_GetUtf8StrPixelWidth(u8g.getU8g(), (char*)inStr)); @@ -400,7 +400,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop } } - void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) { + void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); const u8g_uint_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value); diff --git a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp index 7f88df7bc4..3842611fdf 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp @@ -311,7 +311,7 @@ static void setWindow(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, // Used to fill RGB565 (16bits) background inline void memset2(const void *ptr, uint16_t fill, size_t cnt) { - uint16_t* wptr = (uint16_t*)ptr; + uint16_t *wptr = (uint16_t*)ptr; for (size_t i = 0; i < cnt; i += 2) { *wptr = fill; wptr++; } } @@ -346,7 +346,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u #if HAS_LCD_IO static uint16_t bufferA[WIDTH * sq(GRAPHICAL_TFT_UPSCALE)], bufferB[WIDTH * sq(GRAPHICAL_TFT_UPSCALE)]; - uint16_t* buffer = &bufferA[0]; + uint16_t *buffer = &bufferA[0]; #else uint16_t buffer[WIDTH * GRAPHICAL_TFT_UPSCALE]; // 16-bit RGB 565 pixel line buffer #endif @@ -404,7 +404,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u tftio.WriteSequence(buffer, COUNT(bufferA)); #else - uint8_t* bufptr = (uint8_t*) buffer; + uint8_t *bufptr = (uint8_t*) buffer; for (uint8_t i = GRAPHICAL_TFT_UPSCALE; i--;) { LOOP_S_L_N(n, 0, GRAPHICAL_TFT_UPSCALE * 2) { u8g_WriteSequence(u8g, dev, WIDTH, &bufptr[WIDTH * n]); diff --git a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp index 8542424d7e..1e19bf85e5 100644 --- a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp @@ -148,8 +148,8 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo case U8G_DEV_MSG_STOP: break; case U8G_DEV_MSG_PAGE_NEXT: { - uint8_t* ptr; - u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem); + uint8_t *ptr; + u8g_pb_t *pb = (u8g_pb_t*)(dev->dev_mem); y = pb->p.page_y0; ptr = (uint8_t*)pb->buf; diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index a585ef670a..b4e876ce4c 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -62,7 +62,7 @@ void (*DGUSScreenHandler::confirm_action_cb)() = nullptr; filament_data_t filament_data; #endif -void DGUSScreenHandler::sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { +void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { DGUS_VP_Variable ramcopy; if (populate_VPVar(VP_MSGSTR1, &ramcopy)) { ramcopy.memadr = (void*) line1; @@ -82,7 +82,7 @@ void DGUSScreenHandler::sendinfoscreen(const char* line1, const char* line2, con } } -void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1, bool l2, bool l3, bool l4) { +void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1, bool l2, bool l3, bool l4) { if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first. PopToOldScreen(); diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.h index 28ab952e53..24965597a5 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.h @@ -37,12 +37,12 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifing whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char* msg); + static void setstatusmessage(const char *msg); // The same for messages from Flash static void setstatusmessagePGM(PGM_P const msg); // Callback for VP "Display wants to change screen on idle printer" diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.h index 28ab952e53..24965597a5 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.h @@ -37,12 +37,12 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifing whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char* msg); + static void setstatusmessage(const char *msg); // The same for messages from Flash static void setstatusmessagePGM(PGM_P const msg); // Callback for VP "Display wants to change screen on idle printer" diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index 0efb70b686..d956ec4c52 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -61,14 +61,14 @@ uint8_t DGUSLanguageSwitch = 0; // Switch language for MKS DGUS uint32_t swap32(const uint32_t value) { return (value & 0x000000FFU) << 24U | (value & 0x0000FF00U) << 8U | (value & 0x00FF0000U) >> 8U | (value & 0xFF000000U) >> 24U; } #if 0 -void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t* line1, const uint16_t* line2, const uint16_t* line3, const uint16_t* line4) { +void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4) { dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true); } -void DGUSScreenHandler::sendinfoscreen_en_mks(const char* line1, const char* line2, const char* line3, const char* line4) { +void DGUSScreenHandler::sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) { dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true); diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h index bfec3c4572..dc656326ac 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h @@ -37,18 +37,18 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifing whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); #if 0 - static void sendinfoscreen_ch_mks(const uint16_t* line1, const uint16_t* line2, const uint16_t* line3, const uint16_t* line4); - static void sendinfoscreen_en_mks(const char* line1, const char* line2, const char* line3, const char* line4) ; + static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4); + static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ; static void sendinfoscreen_mks(const void* line1, const void* line2, const void* line3, const void* line4,uint16_t language); #endif // "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char* msg); + static void setstatusmessage(const char *msg); // The same for messages from Flash static void setstatusmessagePGM(PGM_P const msg); // Callback for VP "Display wants to change screen on idle printer" diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.h index 28ab952e53..24965597a5 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.h @@ -37,12 +37,12 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifing whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char* line1, const char* line2, const char* line3, const char* line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char* msg); + static void setstatusmessage(const char *msg); // The same for messages from Flash static void setstatusmessagePGM(PGM_P const msg); // Callback for VP "Display wants to change screen on idle printer" diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp index 9868492d81..ab60579700 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.cpp @@ -26,7 +26,7 @@ #include "media_file_reader.h" #if ENABLED(SDSUPPORT) - bool MediaFileReader::open(const char* filename) { + bool MediaFileReader::open(const char *filename) { card.init(SD_SPI_SPEED, SDSS); volume.init(&card); root.openRoot(&volume); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h index be393a952c..d9edea8388 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h @@ -38,7 +38,7 @@ class MediaFileReader { #endif public: - bool open(const char* filename); + bool open(const char *filename); int16_t read(void *buff, size_t bytes); uint32_t size(); void rewind(); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/spi.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/spi.cpp index 006cbe872c..30f778e9f5 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/spi.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/spi.cpp @@ -103,12 +103,12 @@ namespace FTDI { #endif void SPI::spi_read_bulk(void *data, uint16_t len) { - uint8_t* p = (uint8_t *)data; + uint8_t *p = (uint8_t *)data; while (len--) *p++ = spi_recv(); } bool SPI::spi_verify_bulk(const void *data, uint16_t len) { - const uint8_t* p = (const uint8_t *)data; + const uint8_t *p = (const uint8_t *)data; while (len--) if (*p++ != spi_recv()) return false; return true; } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/spi.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/spi.h index e3a23d768f..7adf7e9c53 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/spi.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/spi.h @@ -116,14 +116,14 @@ namespace FTDI { template void spi_write_bulk(const void *data, uint16_t len, uint8_t padding) { - const uint8_t* p = (const uint8_t *)data; + const uint8_t *p = (const uint8_t *)data; while (len--) spi_send(byte_op(p++)); while (padding--) spi_send(0); } template void spi_write_bulk(const void *data, uint16_t len) { - const uint8_t* p = (const uint8_t *)data; + const uint8_t *p = (const uint8_t *)data; while (len--) spi_send(byte_op(p++)); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h index 20df15a91e..2ddab1b818 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h @@ -24,7 +24,7 @@ class SoundList { private: static PROGMEM const struct list_t { - const char *const PROGMEM name; + const char * const PROGMEM name; const FTDI::SoundPlayer::sound_t* data; } list[]; public: 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 f48448eb84..47bf79e467 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 @@ -62,7 +62,7 @@ namespace FTDI { timer.start(); } - void SoundPlayer::play(const sound_t* seq, play_mode_t mode) { + void SoundPlayer::play(const sound_t *seq, play_mode_t mode) { sequence = seq; wait = 250; // Adding this delay causes the note to not be clipped, not sure why. timer.start(); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.h index fcfe70bd76..3ba39b8c57 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.h @@ -55,7 +55,7 @@ namespace FTDI { static void play(effect_t effect, note_t note = NOTE_C4); static bool is_sound_playing(); - void play(const sound_t* seq, play_mode_t mode = PLAY_SYNCHRONOUS); + void play(const sound_t *seq, play_mode_t mode = PLAY_SYNCHRONOUS); void play_tone(const uint16_t frequency_hz, const uint16_t duration_ms); bool has_more_notes() {return sequence != 0;}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp index 5fc89f1fa9..6a58dd2e49 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp @@ -47,7 +47,7 @@ namespace FTDI { break; } #else - for (char* c = str; *c; c++) { + for (char *c = str; *c; c++) { lineWidth += fm.get_char_width(*c); if (lineWidth + ellipsisWidth < w) breakPoint = c; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp index 902ede025c..d8abfcd29a 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp @@ -71,7 +71,7 @@ namespace ExtUI { AlertDialogBox::showError(F("Unable to read media.")); } - void onStatusChanged(const char* lcd_msg) { + void onStatusChanged(const char *lcd_msg) { StatusScreen::setStatusMessage(lcd_msg); } 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 7f81d49a27..a812f0f3d0 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 @@ -34,7 +34,7 @@ using namespace Theme; #define GRID_COLS 2 #define GRID_ROWS 9 -void BioPrintingDialogBox::draw_status_message(draw_mode_t what, const char* message) { +void BioPrintingDialogBox::draw_status_message(draw_mode_t what, const char *message) { if (what & BACKGROUND) { CommandProcessor cmd; cmd.cmd(COLOR_RGB(bg_text_enabled)) @@ -113,7 +113,7 @@ void BioPrintingDialogBox::setStatusMessage(progmem_str message) { setStatusMessage(buff); } -void BioPrintingDialogBox::setStatusMessage(const char* message) { +void BioPrintingDialogBox::setStatusMessage(const char *message) { CommandProcessor cmd; cmd.cmd(CMD_DLSTART) .cmd(CLEAR_COLOR_RGB(bg_color)) 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 e3892217a5..d514015058 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 @@ -56,7 +56,7 @@ void ConfirmUserRequestAlertBox::onIdle() { } } -void ConfirmUserRequestAlertBox::show(const char* msg) { +void ConfirmUserRequestAlertBox::show(const char *msg) { drawMessage(msg); storeBackground(); screen_data.AlertDialogBox.isError = false; 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 c8febfd7d8..f9057ae88e 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 @@ -76,7 +76,7 @@ uint16_t FilesScreen::getFileForTag(uint8_t tag) { #define GRID_ROWS (files_per_page + header_h + footer_h) #endif -void FilesScreen::drawFileButton(const char* filename, uint8_t tag, bool is_dir, bool is_highlighted) { +void FilesScreen::drawFileButton(const char *filename, uint8_t tag, bool is_dir, bool is_highlighted) { const uint8_t line = getLineForTag(tag)+1; CommandProcessor cmd; cmd.tag(tag); 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 index a4fb37cc14..06ae88a45a 100644 --- 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 @@ -60,7 +60,7 @@ class FilesScreen : public BaseScreen, public CachedScreen -void j_move_axis(const char* command, const T axis) { +void j_move_axis(const char *command, const T axis) { const float dist = atof(command + 1) / 10.0; ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(axis) + dist, axis); }; -void process_lcd_j_command(const char* command) { +void process_lcd_j_command(const char *command) { switch (command[0]) { case 'E': break; case 'A': j_move_axis(command, ExtUI::extruder_t::E0); break; @@ -241,7 +241,7 @@ void process_lcd_j_command(const char* command) { * T:-2537.4 E:0 * Note only the curly brace stuff matters. */ -void process_lcd_p_command(const char* command) { +void process_lcd_p_command(const char *command) { switch (command[0]) { case 'P': @@ -301,7 +301,7 @@ void process_lcd_p_command(const char* command) { * {FILE:fcupdate.flg} * {SYS:OK} */ -void process_lcd_s_command(const char* command) { +void process_lcd_s_command(const char *command) { switch (command[0]) { case 'I': { // temperature information @@ -348,7 +348,7 @@ void process_lcd_s_command(const char* command) { * Currently {E:0} is not handled. Its function is unknown, * but it occurs during the temp window after a sys build. */ -void process_lcd_command(const char* command) { +void process_lcd_command(const char *command) { const char *current = command; byte command_code = *current++; diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index 90ffa14ad1..fe856535b0 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -161,7 +161,7 @@ inline lcd_uint_t lcd_put_u8str_ind_P(const lcd_uint_t col, const lcd_uint_t row return lcd_put_u8str_ind_P(pstr, ind, inStr, maxlen); } -inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); } +inline int lcd_put_u8str(const char *str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); } inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, PGM_P const str) { lcd_moveto(col, row); return lcd_put_u8str(str); diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index f85771f562..57e6fc26e6 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -292,7 +292,7 @@ public: static bool has_status(); static void reset_status(const bool no_welcome=false); - static void set_status(const char* const message, const bool persist=false); + static void set_status(const char * const message, const bool persist=false); static void set_status_P(PGM_P const message, const int8_t level=0); static void status_printf_P(const uint8_t level, PGM_P const fmt, ...); static void set_alert_status_P(PGM_P const message); @@ -300,7 +300,7 @@ public: #else static constexpr bool has_status() { return false; } static inline void reset_status(const bool=false) {} - static void set_status(const char* message, const bool=false); + static void set_status(const char *message, const bool=false); static void set_status_P(PGM_P message, const int8_t=0); static void status_printf_P(const uint8_t, PGM_P message, ...); static inline void set_alert_status_P(PGM_P const) {} diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index de11ee3a5a..cbef9b50c9 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -172,14 +172,14 @@ class MenuEditItemBase : public MenuItemBase { public: // Implemented for HD44780 and DOGM // Draw the current item at specified row with edit data - static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const inStr, const bool pgm=false); + static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm=false); // Implemented for HD44780 and DOGM // This low-level method is good to draw from anywhere - static void draw_edit_screen(PGM_P const pstr, const char* const value); + static void draw_edit_screen(PGM_P const pstr, const char * const value); // This method is for the current menu item - static inline void draw_edit_screen(const char* const value) { draw_edit_screen(editLabel, value); } + static inline void draw_edit_screen(const char * const value) { draw_edit_screen(editLabel, value); } }; #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 37a44f51b4..793ee60847 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -326,7 +326,7 @@ void MarlinUI::draw_status_screen() { } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace -void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) { +void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); TERN_(TOUCH_SCREEN, touch.clear()); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 81e4603ea4..a8979d0ca6 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -326,7 +326,7 @@ void MarlinUI::draw_status_screen() { } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace -void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) { +void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); TERN_(TOUCH_SCREEN, touch.clear()); @@ -779,7 +779,7 @@ static void disable_steppers() { queue.inject_P(PSTR("M84")); } -static void drawBtn(int x, int y, const char* label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { +static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { uint16_t width = Images[imgBtn52Rounded].width; uint16_t height = Images[imgBtn52Rounded].height; diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index 842fc3909c..7c053e7be7 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -131,7 +131,7 @@ void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, co } // Draw a menu item with a (potentially) editable value -void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) { +void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const data, const bool pgm) { menu_item(row, sel); tft_string.set(pstr, itemIndex, itemString); diff --git a/Marlin/src/libs/W25Qxx.cpp b/Marlin/src/libs/W25Qxx.cpp index 0eb40a1441..fd7804cb27 100644 --- a/Marlin/src/libs/W25Qxx.cpp +++ b/Marlin/src/libs/W25Qxx.cpp @@ -106,7 +106,7 @@ uint8_t W25QXXFlash::spi_flash_read_write_byte(uint8_t data) { * * @details Uses DMA */ -void W25QXXFlash::spi_flash_Read(uint8_t* buf, uint16_t nbyte) { +void W25QXXFlash::spi_flash_Read(uint8_t *buf, uint16_t nbyte) { mySPI.dmaTransfer(0, const_cast(buf), nbyte); } @@ -127,7 +127,7 @@ void W25QXXFlash::spi_flash_Send(uint8_t b) { mySPI.transfer(b); } * * @details Use DMA */ -void W25QXXFlash::spi_flash_SendBlock(uint8_t token, const uint8_t* buf) { +void W25QXXFlash::spi_flash_SendBlock(uint8_t token, const uint8_t *buf) { mySPI.transfer(token); mySPI.dmaSend(const_cast(buf), 512); } @@ -257,7 +257,7 @@ void W25QXXFlash::SPI_FLASH_BulkErase(void) { * Output : None * Return : None *******************************************************************************/ -void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { +void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { // Enable the write access to the FLASH SPI_FLASH_WriteEnable(); @@ -300,7 +300,7 @@ void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint * Output : None * Return : None *******************************************************************************/ -void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { +void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { uint8_t NumOfPage = 0, NumOfSingle = 0, Addr = 0, count = 0, temp = 0; Addr = WriteAddr % SPI_FLASH_PageSize; @@ -364,7 +364,7 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui * Output : None * Return : None *******************************************************************************/ -void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) { +void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) { // Select the FLASH: Chip Select low W25QXX_CS_L; diff --git a/Marlin/src/libs/W25Qxx.h b/Marlin/src/libs/W25Qxx.h index eddae6b1f2..1133af2e74 100644 --- a/Marlin/src/libs/W25Qxx.h +++ b/Marlin/src/libs/W25Qxx.h @@ -57,18 +57,18 @@ public: void init(uint8_t spiRate); static uint8_t spi_flash_Rec(); static uint8_t spi_flash_read_write_byte(uint8_t data); - static void spi_flash_Read(uint8_t* buf, uint16_t nbyte); + static void spi_flash_Read(uint8_t *buf, uint16_t nbyte); static void spi_flash_Send(uint8_t b); - static void spi_flash_SendBlock(uint8_t token, const uint8_t* buf); + static void spi_flash_SendBlock(uint8_t token, const uint8_t *buf); static uint16_t W25QXX_ReadID(void); static void SPI_FLASH_WriteEnable(void); static void SPI_FLASH_WaitForWriteEnd(void); static void SPI_FLASH_SectorErase(uint32_t SectorAddr); static void SPI_FLASH_BlockErase(uint32_t BlockAddr); static void SPI_FLASH_BulkErase(void); - static void SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); - static void SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); - static void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); + static void SPI_FLASH_PageWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); + static void SPI_FLASH_BufferWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); + static void SPI_FLASH_BufferRead(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); }; extern W25QXXFlash W25QXX; diff --git a/Marlin/src/libs/softspi.h b/Marlin/src/libs/softspi.h index 5d48f9fd8c..fb02de8653 100644 --- a/Marlin/src/libs/softspi.h +++ b/Marlin/src/libs/softspi.h @@ -715,7 +715,7 @@ class SoftSPI { FORCE_INLINE bool MODE_CPHA(uint8_t mode) { return bool(mode & 1); } FORCE_INLINE bool MODE_CPOL(uint8_t mode) { return bool(mode & 2); } - FORCE_INLINE void receiveBit(uint8_t bit, uint8_t* data) { + FORCE_INLINE void receiveBit(uint8_t bit, uint8_t *data) { if (MODE_CPHA(Mode)) fastDigitalWrite(SckPin, !MODE_CPOL(Mode)); nop; nop; @@ -734,7 +734,7 @@ class SoftSPI { if (!MODE_CPHA(Mode)) fastDigitalWrite(SckPin, MODE_CPOL(Mode)); } - FORCE_INLINE void transferBit(uint8_t bit, uint8_t* rxData, uint8_t txData) { + FORCE_INLINE void transferBit(uint8_t bit, uint8_t *rxData, uint8_t txData) { if (MODE_CPHA(Mode)) fastDigitalWrite(SckPin, !MODE_CPOL(Mode)); fastDigitalWrite(MosiPin, txData & _BV(bit)); fastDigitalWrite(SckPin, diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index b20d1e273b..832d6e316a 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -381,7 +381,7 @@ void Planner::init() { r9 = (d >> 8) & 0xFF, r10 = (d >> 16) & 0xFF, r2,r3,r4,r5,r6,r7,r11,r12,r13,r14,r15,r16,r17,r18; - const uint8_t* ptab = inv_tab; + const uint8_t *ptab = inv_tab; __asm__ __volatile__( // %8:%7:%6 = interval @@ -775,7 +775,7 @@ block_t* Planner::get_current_block() { * is not and will not use the block while we modify it, so it is safe to * alter its values. */ -void Planner::calculate_trapezoid_for_block(block_t* const block, const float &entry_factor, const float &exit_factor) { +void Planner::calculate_trapezoid_for_block(block_t * const block, const float &entry_factor, const float &exit_factor) { uint32_t initial_rate = CEIL(block->nominal_rate * entry_factor), final_rate = CEIL(block->nominal_rate * exit_factor); // (steps per second) @@ -942,7 +942,7 @@ void Planner::calculate_trapezoid_for_block(block_t* const block, const float &e */ // The kernel called by recalculate() when scanning the plan from last to first entry. -void Planner::reverse_pass_kernel(block_t* const current, const block_t * const next) { +void Planner::reverse_pass_kernel(block_t * const current, const block_t * const next) { if (current) { // If entry speed is already at the maximum entry speed, and there was no change of speed // in the next block, there is no need to recheck. Block is cruising and there is no need to @@ -1039,7 +1039,7 @@ void Planner::reverse_pass() { } // The kernel called by recalculate() when scanning the plan from first to last entry. -void Planner::forward_pass_kernel(const block_t* const previous, block_t* const current, const uint8_t block_index) { +void Planner::forward_pass_kernel(const block_t * const previous, block_t * const current, const uint8_t block_index) { if (previous) { // If the previous block is an acceleration block, too short to complete the full speed // change, adjust the entry speed accordingly. Entry speeds have already been reset, @@ -1440,7 +1440,7 @@ void Planner::check_axes_activity() { float high = 0.0; for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { - block_t* block = &block_buffer[b]; + block_t *block = &block_buffer[b]; if (block->steps.x || block->steps.y || block->steps.z) { const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; NOLESS(high, se); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index da9e202cdf..768bf29e2f 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -993,10 +993,10 @@ class Planner { } #endif - static void calculate_trapezoid_for_block(block_t* const block, const float &entry_factor, const float &exit_factor); + static void calculate_trapezoid_for_block(block_t * const block, const float &entry_factor, const float &exit_factor); - static void reverse_pass_kernel(block_t* const current, const block_t * const next); - static void forward_pass_kernel(const block_t * const previous, block_t* const current, uint8_t block_index); + static void reverse_pass_kernel(block_t * const current, const block_t * const next); + static void forward_pass_kernel(const block_t * const previous, block_t * const current, uint8_t block_index); static void reverse_pass(); static void forward_pass(); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 49eca7047c..8c377bf7bf 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2362,7 +2362,7 @@ uint32_t Stepper::block_phase_isr() { // Check if the given block is busy or not - Must not be called from ISR contexts // The current_block could change in the middle of the read by an Stepper ISR, so // we must explicitly prevent that! -bool Stepper::is_block_busy(const block_t* const block) { +bool Stepper::is_block_busy(const block_t * const block) { #ifdef __AVR__ // A SW memory barrier, to ensure GCC does not overoptimize loops #define sw_barrier() asm volatile("": : :"memory"); @@ -2372,7 +2372,7 @@ bool Stepper::is_block_busy(const block_t* const block) { // This works because stepper ISRs happen at a slower rate than // successive reads of a variable, so 2 consecutive reads with // the same value means no interrupt updated it. - block_t* vold, *vnew = current_block; + block_t *vold, *vnew = current_block; sw_barrier(); do { vold = vnew; diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 639a1b2650..ca1781fb9c 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -423,7 +423,7 @@ class Stepper { #endif // Check if the given block is busy or not - Must not be called from ISR contexts - static bool is_block_busy(const block_t* const block); + static bool is_block_busy(const block_t * const block); // Get the position of a stepper, in steps static int32_t position(const AxisEnum axis); @@ -529,7 +529,7 @@ class Stepper { static void _set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e); FORCE_INLINE static void _set_position(const abce_long_t &spos) { _set_position(spos.a, spos.b, spos.c, spos.e); } - FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t* loops) { + FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t *loops) { uint32_t timer; // Scale the frequency, as requested by the caller diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index c33581d132..de3d45e4b6 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -830,11 +830,11 @@ void reset_trinamic_drivers() { } constexpr bool sc_hw_done(size_t start, size_t end) { return start == end; } - constexpr bool sc_hw_skip(const char* port_name) { return !(*port_name); } - constexpr bool sc_hw_match(const char* port_name, uint32_t address, size_t start, size_t end) { + constexpr bool sc_hw_skip(const char *port_name) { return !(*port_name); } + constexpr bool sc_hw_match(const char *port_name, uint32_t address, size_t start, size_t end) { return !sc_hw_done(start, end) && !sc_hw_skip(port_name) && (address == sanity_tmc_hw_details[start].address && str_eq_ce(port_name, sanity_tmc_hw_details[start].port)); } - constexpr int count_tmc_hw_serial_matches(const char* port_name, uint32_t address, size_t start, size_t end) { + constexpr int count_tmc_hw_serial_matches(const char *port_name, uint32_t address, size_t start, size_t end) { return sc_hw_done(start, end) ? 0 : ((sc_hw_skip(port_name) ? 0 : (sc_hw_match(port_name, address, start, end) ? 1 : 0)) + count_tmc_hw_serial_matches(port_name, address, start + 1, end)); } diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index 491c0692c7..b914b29635 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -63,7 +63,7 @@ 0x0E,0x07,0x1C,0x15,0x2A,0x23,0x38,0x31,0x46,0x4F,0x54,0x5D,0x62,0x6B,0x70,0x79 }; - static uint8_t CRC7(const uint8_t* data, uint8_t n) { + static uint8_t CRC7(const uint8_t *data, uint8_t n) { uint8_t crc = 0; while (n > 0) { crc = pgm_read_byte(&crctab7[ (crc << 1) ^ *data++ ]); @@ -72,7 +72,7 @@ return (crc << 1) | 1; } #else - static uint8_t CRC7(const uint8_t* data, uint8_t n) { + static uint8_t CRC7(const uint8_t *data, uint8_t n) { uint8_t crc = 0; LOOP_L_N(i, n) { uint8_t d = data[i]; @@ -338,7 +338,7 @@ bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) { * \param[out] dst Pointer to the location that will receive the data. * \return true for success, false for failure. */ -bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) { +bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t *dst) { #if IS_TEENSY_35_36 || IS_TEENSY_40_41 return 0 == SDHC_CardReadBlock(dst, blockNumber); #endif @@ -378,7 +378,7 @@ bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) { * * \return true for success, false for failure. */ -bool Sd2Card::readData(uint8_t* dst) { +bool Sd2Card::readData(uint8_t *dst) { chipSelect(); return readData(dst, 512); } @@ -421,7 +421,7 @@ bool Sd2Card::readData(uint8_t* dst) { }; // faster CRC-CCITT // uses the x^16,x^12,x^5,x^1 polynomial. - static uint16_t CRC_CCITT(const uint8_t* data, size_t n) { + static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { uint16_t crc = 0; for (size_t i = 0; i < n; i++) { crc = pgm_read_word(&crctab16[(crc >> 8 ^ data[i]) & 0xFF]) ^ (crc << 8); @@ -431,7 +431,7 @@ bool Sd2Card::readData(uint8_t* dst) { #else // slower CRC-CCITT // uses the x^16,x^12,x^5,x^1 polynomial. - static uint16_t CRC_CCITT(const uint8_t* data, size_t n) { + static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { uint16_t crc = 0; for (size_t i = 0; i < n; i++) { crc = (uint8_t)(crc >> 8) | (crc << 8); @@ -445,7 +445,7 @@ bool Sd2Card::readData(uint8_t* dst) { #endif #endif // SD_CHECK_AND_RETRY -bool Sd2Card::readData(uint8_t* dst, const uint16_t count) { +bool Sd2Card::readData(uint8_t *dst, const uint16_t count) { bool success = false; const millis_t read_timeout = millis() + SD_READ_TIMEOUT; @@ -478,7 +478,7 @@ bool Sd2Card::readData(uint8_t* dst, const uint16_t count) { /** read CID or CSR register */ bool Sd2Card::readRegister(const uint8_t cmd, void* buf) { - uint8_t* dst = reinterpret_cast(buf); + uint8_t *dst = reinterpret_cast(buf); if (cardCommand(cmd, 0)) { error(SD_CARD_ERROR_READ_REG); chipDeselect(); @@ -555,7 +555,7 @@ bool Sd2Card::waitNotBusy(const millis_t timeout_ms) { * \param[in] src Pointer to the location of the data to be written. * \return true for success, false for failure. */ -bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t* src) { +bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t *src) { if (ENABLED(SDCARD_READONLY)) return false; #if IS_TEENSY_35_36 || IS_TEENSY_40_41 @@ -586,7 +586,7 @@ bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t* src) { * \param[in] src Pointer to the location of the data to be written. * \return true for success, false for failure. */ -bool Sd2Card::writeData(const uint8_t* src) { +bool Sd2Card::writeData(const uint8_t *src) { if (ENABLED(SDCARD_READONLY)) return false; bool success = true; @@ -601,7 +601,7 @@ bool Sd2Card::writeData(const uint8_t* src) { } // Send one block of data for write block or write multiple blocks -bool Sd2Card::writeData(const uint8_t token, const uint8_t* src) { +bool Sd2Card::writeData(const uint8_t token, const uint8_t *src) { if (ENABLED(SDCARD_READONLY)) return false; const uint16_t crc = TERN(SD_CHECK_AND_RETRY, CRC_CCITT(src, 512), 0xFFFF); diff --git a/Marlin/src/sd/Sd2Card.h b/Marlin/src/sd/Sd2Card.h index 6900502e03..d82cb10a1e 100644 --- a/Marlin/src/sd/Sd2Card.h +++ b/Marlin/src/sd/Sd2Card.h @@ -124,7 +124,7 @@ public: */ bool init(const uint8_t sckRateID, const pin_t chipSelectPin); - bool readBlock(uint32_t block, uint8_t* dst); + bool readBlock(uint32_t block, uint8_t *dst); /** * Read a card's CID register. The CID contains card identification @@ -135,7 +135,7 @@ public: * * \return true for success or false for failure. */ - bool readCID(cid_t* cid) { return readRegister(CMD10, cid); } + bool readCID(cid_t *cid) { return readRegister(CMD10, cid); } /** * Read a card's CSD register. The CSD contains Card-Specific Data that @@ -145,9 +145,9 @@ public: * * \return true for success or false for failure. */ - inline bool readCSD(csd_t* csd) { return readRegister(CMD9, csd); } + inline bool readCSD(csd_t *csd) { return readRegister(CMD9, csd); } - bool readData(uint8_t* dst); + bool readData(uint8_t *dst); bool readStart(uint32_t blockNumber); bool readStop(); bool setSckRate(const uint8_t sckRateID); @@ -157,8 +157,8 @@ public: * \return 0 - SD V1, 1 - SD V2, or 3 - SDHC. */ int type() const {return type_;} - bool writeBlock(uint32_t blockNumber, const uint8_t* src); - bool writeData(const uint8_t* src); + bool writeBlock(uint32_t blockNumber, const uint8_t *src); + bool writeData(const uint8_t *src); bool writeStart(uint32_t blockNumber, const uint32_t eraseCount); bool writeStop(); @@ -176,11 +176,11 @@ private: } uint8_t cardCommand(const uint8_t cmd, const uint32_t arg); - bool readData(uint8_t* dst, const uint16_t count); + bool readData(uint8_t *dst, const uint16_t count); bool readRegister(const uint8_t cmd, void* buf); void chipDeselect(); void chipSelect(); inline void type(const uint8_t value) { type_ = value; } bool waitNotBusy(const millis_t timeout_ms); - bool writeData(const uint8_t token, const uint8_t* src); + bool writeData(const uint8_t token, const uint8_t *src); }; diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 3cd88318ff..120668baa8 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -43,7 +43,7 @@ SdBaseFile* SdBaseFile::cwd_ = 0; // Pointer to Current Working Directory // callback function for date/time -void (*SdBaseFile::dateTime_)(uint16_t* date, uint16_t* time) = 0; +void (*SdBaseFile::dateTime_)(uint16_t *date, uint16_t *time) = 0; // add a cluster to a file bool SdBaseFile::addCluster() { @@ -118,7 +118,7 @@ bool SdBaseFile::close() { * Reasons for failure include file is not contiguous, file has zero length * or an I/O error occurred. */ -bool SdBaseFile::contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock) { +bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) { // error if no blocks if (firstCluster_ == 0) return false; @@ -155,7 +155,7 @@ bool SdBaseFile::contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock) { * a file is already open, the file already exists, the root * directory is full or an I/O error. */ -bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char* path, uint32_t size) { +bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char *path, uint32_t size) { if (ENABLED(SDCARD_READONLY)) return false; uint32_t count; @@ -186,8 +186,8 @@ bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char* path, uint32_ * * \return true for success, false for failure. */ -bool SdBaseFile::dirEntry(dir_t* dir) { - dir_t* p; +bool SdBaseFile::dirEntry(dir_t *dir) { + dir_t *p; // make sure fields on SD are correct if (!sync()) return false; @@ -207,7 +207,7 @@ bool SdBaseFile::dirEntry(dir_t* dir) { * \param[in] dir The directory structure containing the name. * \param[out] name A 13 byte char array for the formatted name. */ -void SdBaseFile::dirName(const dir_t& dir, char* name) { +void SdBaseFile::dirName(const dir_t& dir, char *name) { uint8_t j = 0; LOOP_L_N(i, 11) { if (dir.name[i] == ' ')continue; @@ -229,7 +229,7 @@ void SdBaseFile::dirName(const dir_t& dir, char* name) { * * \return true if the file exists else false. */ -bool SdBaseFile::exists(const char* name) { +bool SdBaseFile::exists(const char *name) { SdBaseFile file; return file.open(this, name, O_READ); } @@ -254,7 +254,7 @@ bool SdBaseFile::exists(const char* name) { * \return For success fgets() returns the length of the string in \a str. * If no data is read, fgets() returns zero for EOF or -1 if an error occurred. **/ -int16_t SdBaseFile::fgets(char* str, int16_t num, char* delim) { +int16_t SdBaseFile::fgets(char *str, int16_t num, char *delim) { char ch; int16_t n = 0; int16_t r = -1; @@ -293,7 +293,7 @@ bool SdBaseFile::getDosName(char * const name) { return true; } // cache entry - dir_t* p = cacheDirEntry(SdVolume::CACHE_FOR_READ); + dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_READ); if (!p) return false; // format name @@ -301,7 +301,7 @@ bool SdBaseFile::getDosName(char * const name) { return true; } -void SdBaseFile::getpos(filepos_t* pos) { +void SdBaseFile::getpos(filepos_t *pos) { pos->position = curPosition_; pos->cluster = curCluster_; } @@ -386,7 +386,7 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) { } // Format directory name field from a 8.3 name string -bool SdBaseFile::make83Name(const char* str, uint8_t* name, const char** ptr) { +bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char** ptr) { uint8_t n = 7, // Max index until a dot is found i = 11; while (i) name[--i] = ' '; // Set whole FILENAME.EXT to spaces @@ -423,7 +423,7 @@ bool SdBaseFile::make83Name(const char* str, uint8_t* name, const char** ptr) { * Reasons for failure include this file is already open, \a parent is not a * directory, \a path is invalid or already exists in \a parent. */ -bool SdBaseFile::mkdir(SdBaseFile* parent, const char* path, bool pFlag) { +bool SdBaseFile::mkdir(SdBaseFile* parent, const char *path, bool pFlag) { if (ENABLED(SDCARD_READONLY)) return false; uint8_t dname[11]; @@ -460,7 +460,7 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) { uint32_t block; dir_t d; - dir_t* p; + dir_t *p; if (!parent->isDir()) return false; @@ -523,7 +523,7 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) { * * \return true for success, false for failure. */ -bool SdBaseFile::open(const char* path, uint8_t oflag) { +bool SdBaseFile::open(const char *path, uint8_t oflag) { return open(cwd_, path, oflag); } @@ -577,7 +577,7 @@ bool SdBaseFile::open(const char* path, uint8_t oflag) { * a directory, \a path is invalid, the file does not exist * or can't be opened in the access mode specified by oflag. */ -bool SdBaseFile::open(SdBaseFile* dirFile, const char* path, uint8_t oflag) { +bool SdBaseFile::open(SdBaseFile* dirFile, const char *path, uint8_t oflag) { uint8_t dname[11]; SdBaseFile dir1, dir2; SdBaseFile *parent = dirFile, *sub = &dir1; @@ -608,7 +608,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const char* path, uint8_t oflag) { bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag) { bool emptyFound = false, fileFound = false; uint8_t index; - dir_t* p; + dir_t *p; vol_ = dirFile->vol_; @@ -697,7 +697,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla * \return true for success or false for failure. */ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) { - dir_t* p; + dir_t *p; vol_ = dirFile->vol_; @@ -725,7 +725,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) { // open a cached directory entry. Assumes vol_ is initialized bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { - dir_t* p; + dir_t *p; #if ENABLED(SDCARD_READONLY) if (oflag & (O_WRITE | O_CREAT | O_TRUNC)) goto FAIL; @@ -785,7 +785,7 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { * \return true for success or false for failure. */ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) { - dir_t* p; + dir_t *p; uint8_t index; if (!dirFile) return false; @@ -827,7 +827,7 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) { */ bool SdBaseFile::openParent(SdBaseFile* dir) { dir_t entry; - dir_t* p; + dir_t *p; SdBaseFile file; uint32_t c; uint32_t cluster; @@ -1009,7 +1009,7 @@ int16_t SdBaseFile::read() { * or an I/O error occurred. */ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) { - uint8_t* dst = reinterpret_cast(buf); + uint8_t *dst = reinterpret_cast(buf); uint16_t offset, toRead; uint32_t block; // raw device block number @@ -1049,7 +1049,7 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) { else { // read block to cache and copy data to caller if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_READ)) return -1; - uint8_t* src = vol_->cache()->data + offset; + uint8_t *src = vol_->cache()->data + offset; memcpy(dst, src, n); } dst += n; @@ -1070,7 +1070,7 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) { * readDir() called before a directory has been opened, this is not * a directory file or an I/O error occurred. */ -int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { +int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0x1F & curPosition_)) return -1; @@ -1096,7 +1096,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { // Fill the long filename if we have a long filename entry. // Long filename entries are stored before the short filename. if (longFilename && DIR_IS_LONG_NAME(dir)) { - vfat_t* VFAT = (vfat_t*)dir; + vfat_t *VFAT = (vfat_t*)dir; // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 if (VFAT->firstClusterLow == 0) { const uint8_t seq = VFAT->sequenceNumber & 0x1F; @@ -1199,7 +1199,7 @@ dir_t* SdBaseFile::readDirCache() { bool SdBaseFile::remove() { if (ENABLED(SDCARD_READONLY)) return false; - dir_t* d; + dir_t *d; // free any clusters - will fail if read-only or directory if (!truncate(0)) return false; @@ -1235,7 +1235,7 @@ bool SdBaseFile::remove() { * \a dirFile is not a directory, \a path is not found * or an I/O error occurred. */ -bool SdBaseFile::remove(SdBaseFile* dirFile, const char* path) { +bool SdBaseFile::remove(SdBaseFile* dirFile, const char *path) { if (ENABLED(SDCARD_READONLY)) return false; SdBaseFile file; @@ -1252,13 +1252,13 @@ bool SdBaseFile::remove(SdBaseFile* dirFile, const char* path) { * Reasons for failure include \a dirFile is not open or is not a directory * file, newPath is invalid or already exists, or an I/O error occurs. */ -bool SdBaseFile::rename(SdBaseFile* dirFile, const char* newPath) { +bool SdBaseFile::rename(SdBaseFile* dirFile, const char *newPath) { if (ENABLED(SDCARD_READONLY)) return false; dir_t entry; uint32_t dirCluster = 0; SdBaseFile file; - dir_t* d; + dir_t *d; // must be an open file or subdirectory if (!(isFile() || isSubDir())) return false; @@ -1356,7 +1356,7 @@ bool SdBaseFile::rmdir() { // make sure directory is empty while (curPosition_ < fileSize_) { - dir_t* p = readDirCache(); + dir_t *p = readDirCache(); if (!p) return false; // done if past last used entry if (p->name[0] == DIR_NAME_FREE) break; @@ -1396,7 +1396,7 @@ bool SdBaseFile::rmRfStar() { // remember position index = curPosition_ / 32; - dir_t* p = readDirCache(); + dir_t *p = readDirCache(); if (!p) return false; // done if past last entry @@ -1438,7 +1438,7 @@ bool SdBaseFile::rmRfStar() { * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). */ -SdBaseFile::SdBaseFile(const char* path, uint8_t oflag) { +SdBaseFile::SdBaseFile(const char *path, uint8_t oflag) { type_ = FAT_FILE_TYPE_CLOSED; writeError = false; open(path, oflag); @@ -1481,7 +1481,7 @@ bool SdBaseFile::seekSet(const uint32_t pos) { return true; } -void SdBaseFile::setpos(filepos_t* pos) { +void SdBaseFile::setpos(filepos_t *pos) { curPosition_ = pos->position; curCluster_ = pos->cluster; } @@ -1499,7 +1499,7 @@ bool SdBaseFile::sync() { if (ENABLED(SDCARD_READONLY) || !isOpen()) goto FAIL; if (flags_ & F_FILE_DIR_DIRTY) { - dir_t* d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); // check for deleted by another open file object if (!d || d->name[0] == DIR_NAME_DELETED) goto FAIL; @@ -1537,7 +1537,7 @@ bool SdBaseFile::sync() { * \return true for success, false for failure. */ bool SdBaseFile::timestamp(SdBaseFile* file) { - dir_t* d; + dir_t *d; dir_t dir; // get timestamps @@ -1599,7 +1599,7 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month, if (ENABLED(SDCARD_READONLY)) return false; uint16_t dirDate, dirTime; - dir_t* d; + dir_t *d; if (!isOpen() || year < 1980 @@ -1716,7 +1716,7 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) { #endif // convert void* to uint8_t* - must be before goto statements - const uint8_t* src = reinterpret_cast(buf); + const uint8_t *src = reinterpret_cast(buf); // number of bytes left to write - must be before goto statements uint16_t nToWrite = nbyte; @@ -1782,7 +1782,7 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) { // rewrite part of block if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) goto FAIL; } - uint8_t* dst = vol_->cache()->data + blockOffset; + uint8_t *dst = vol_->cache()->data + blockOffset; memcpy(dst, src, n); } curPosition_ += n; diff --git a/Marlin/src/sd/SdBaseFile.h b/Marlin/src/sd/SdBaseFile.h index 2f7dfb9f3b..1e2bc5d09e 100644 --- a/Marlin/src/sd/SdBaseFile.h +++ b/Marlin/src/sd/SdBaseFile.h @@ -163,7 +163,7 @@ uint16_t const FAT_DEFAULT_TIME = (1 << 11); class SdBaseFile { public: SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {} - SdBaseFile(const char* path, uint8_t oflag); + SdBaseFile(const char *path, uint8_t oflag); ~SdBaseFile() { if (isOpen()) close(); } /** @@ -179,18 +179,18 @@ class SdBaseFile { * get position for streams * \param[out] pos struct to receive position */ - void getpos(filepos_t* pos); + void getpos(filepos_t *pos); /** * set position for streams * \param[out] pos struct with value for new position */ - void setpos(filepos_t* pos); + void setpos(filepos_t *pos); bool close(); - bool contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock); + bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock); bool createContiguous(SdBaseFile* dirFile, - const char* path, uint32_t size); + const char *path, uint32_t size); /** * \return The current cluster number for a file or directory. */ @@ -213,7 +213,7 @@ class SdBaseFile { * function is of the form: * * \code - * void dateTime(uint16_t* date, uint16_t* time) { + * void dateTime(uint16_t *date, uint16_t *time) { * uint16_t year; * uint8_t month, day, hour, minute, second; * @@ -235,7 +235,7 @@ class SdBaseFile { * See the timestamp() function. */ static void dateTimeCallback( - void (*dateTime)(uint16_t* date, uint16_t* time)) { + void (*dateTime)(uint16_t *date, uint16_t *time)) { dateTime_ = dateTime; } @@ -243,10 +243,10 @@ class SdBaseFile { * Cancel the date/time callback function. */ static void dateTimeCallbackCancel() { dateTime_ = 0; } - bool dirEntry(dir_t* dir); - static void dirName(const dir_t& dir, char* name); - bool exists(const char* name); - int16_t fgets(char* str, int16_t num, char* delim = 0); + bool dirEntry(dir_t *dir); + static void dirName(const dir_t& dir, char *name); + bool exists(const char *name); + int16_t fgets(char *str, int16_t num, char *delim = 0); /** * \return The total number of bytes in a file or directory. @@ -286,10 +286,10 @@ class SdBaseFile { bool getDosName(char * const name); void ls(uint8_t flags = 0, uint8_t indent = 0); - bool mkdir(SdBaseFile* dir, const char* path, bool pFlag = true); + bool mkdir(SdBaseFile* dir, const char *path, bool pFlag = true); bool open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag); - bool open(SdBaseFile* dirFile, const char* path, uint8_t oflag); - bool open(const char* path, uint8_t oflag = O_READ); + bool open(SdBaseFile* dirFile, const char *path, uint8_t oflag); + bool open(const char *path, uint8_t oflag = O_READ); bool openNext(SdBaseFile* dirFile, uint8_t oflag); bool openRoot(SdVolume* vol); int peek(); @@ -298,15 +298,15 @@ class SdBaseFile { bool printName(); int16_t read(); int16_t read(void* buf, uint16_t nbyte); - int8_t readDir(dir_t* dir, char* longFilename); - static bool remove(SdBaseFile* dirFile, const char* path); + int8_t readDir(dir_t *dir, char *longFilename); + static bool remove(SdBaseFile* dirFile, const char *path); bool remove(); /** * Set the file's current position to zero. */ void rewind() { seekSet(0); } - bool rename(SdBaseFile* dirFile, const char* newPath); + bool rename(SdBaseFile* dirFile, const char *newPath); bool rmdir(); bool rmRfStar(); @@ -348,7 +348,7 @@ class SdBaseFile { static SdBaseFile* cwd_; // global pointer to cwd dir // data time callback function - static void (*dateTime_)(uint16_t* date, uint16_t* time); + static void (*dateTime_)(uint16_t *date, uint16_t *time); // bits defined in flags_ static uint8_t const F_OFLAG = (O_ACCMODE | O_APPEND | O_SYNC), // should be 0x0F @@ -376,7 +376,7 @@ class SdBaseFile { bool addDirCluster(); dir_t* cacheDirEntry(uint8_t action); int8_t lsPrintNext(uint8_t flags, uint8_t indent); - static bool make83Name(const char* str, uint8_t* name, const char** ptr); + static bool make83Name(const char *str, uint8_t *name, const char** ptr); bool mkdir(SdBaseFile* parent, const uint8_t dname[11]); bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag); bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags); diff --git a/Marlin/src/sd/SdFatStructs.h b/Marlin/src/sd/SdFatStructs.h index ac81f1d64e..03bbc1c194 100644 --- a/Marlin/src/sd/SdFatStructs.h +++ b/Marlin/src/sd/SdFatStructs.h @@ -571,7 +571,7 @@ uint8_t const DIR_NAME_0xE5 = 0x05, // escape for name[0] = 0xE5 * * \return true if the entry is for part of a long name else false. */ -static inline uint8_t DIR_IS_LONG_NAME(const dir_t* dir) { +static inline uint8_t DIR_IS_LONG_NAME(const dir_t *dir) { return (dir->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME; } @@ -584,7 +584,7 @@ uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY); * * \return true if the entry is for a normal file else false. */ -static inline uint8_t DIR_IS_FILE(const dir_t* dir) { +static inline uint8_t DIR_IS_FILE(const dir_t *dir) { return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == 0; } @@ -594,7 +594,7 @@ static inline uint8_t DIR_IS_FILE(const dir_t* dir) { * * \return true if the entry is for a subdirectory else false. */ -static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) { +static inline uint8_t DIR_IS_SUBDIR(const dir_t *dir) { return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == DIR_ATT_DIRECTORY; } @@ -604,6 +604,6 @@ static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) { * * \return true if the entry is for a normal file or subdirectory else false. */ -static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) { +static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t *dir) { return (dir->attributes & DIR_ATT_VOLUME_ID) == 0; } diff --git a/Marlin/src/sd/SdFile.cpp b/Marlin/src/sd/SdFile.cpp index cba67e2bba..cc86ce819f 100644 --- a/Marlin/src/sd/SdFile.cpp +++ b/Marlin/src/sd/SdFile.cpp @@ -43,7 +43,7 @@ * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). */ -SdFile::SdFile(const char* path, uint8_t oflag) : SdBaseFile(path, oflag) { } +SdFile::SdFile(const char *path, uint8_t oflag) : SdBaseFile(path, oflag) { } /** * Write data to an open file. @@ -78,7 +78,7 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) { return SdBaseFile::writ * \param[in] str Pointer to the string. * Use writeError to check for errors. */ -void SdFile::write(const char* str) { SdBaseFile::write(str, strlen(str)); } +void SdFile::write(const char *str) { SdBaseFile::write(str, strlen(str)); } /** * Write a PROGMEM string to a file. diff --git a/Marlin/src/sd/SdFile.h b/Marlin/src/sd/SdFile.h index 17256b47c8..69fe05b499 100644 --- a/Marlin/src/sd/SdFile.h +++ b/Marlin/src/sd/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile { public: SdFile() {} - SdFile(const char* name, uint8_t oflag); + SdFile(const char *name, uint8_t oflag); #if ARDUINO >= 100 size_t write(uint8_t b); #else @@ -50,7 +50,7 @@ class SdFile : public SdBaseFile { #endif int16_t write(const void* buf, uint16_t nbyte); - void write(const char* str); + void write(const char *str); void write_P(PGM_P str); void writeln_P(PGM_P str); }; diff --git a/Marlin/src/sd/SdVolume.cpp b/Marlin/src/sd/SdVolume.cpp index e262c8867a..7fcebd640d 100644 --- a/Marlin/src/sd/SdVolume.cpp +++ b/Marlin/src/sd/SdVolume.cpp @@ -47,7 +47,7 @@ #endif // USE_MULTIPLE_CARDS // find a contiguous group of clusters -bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) { +bool SdVolume::allocContiguous(uint32_t count, uint32_t *curCluster) { if (ENABLED(SDCARD_READONLY)) return false; // start of group @@ -149,7 +149,7 @@ bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) { } // return the size in bytes of a cluster chain -bool SdVolume::chainSize(uint32_t cluster, uint32_t* size) { +bool SdVolume::chainSize(uint32_t cluster, uint32_t *size) { uint32_t s = 0; do { if (!fatGet(cluster, &cluster)) return false; @@ -160,7 +160,7 @@ bool SdVolume::chainSize(uint32_t cluster, uint32_t* size) { } // Fetch a FAT entry -bool SdVolume::fatGet(uint32_t cluster, uint32_t* value) { +bool SdVolume::fatGet(uint32_t cluster, uint32_t *value) { uint32_t lba; if (cluster > (clusterCount_ + 1)) return false; if (FAT12_SUPPORT && fatType_ == 12) { @@ -328,7 +328,7 @@ int32_t SdVolume::freeClusterCount() { */ bool SdVolume::init(Sd2Card* dev, uint8_t part) { uint32_t totalBlocks, volumeStartBlock = 0; - fat32_boot_t* fbs; + fat32_boot_t *fbs; sdCard_ = dev; fatType_ = 0; @@ -342,7 +342,7 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) { if (part) { if (part > 4) return false; if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) return false; - part_t* p = &cacheBuffer_.mbr.part[part - 1]; + part_t *p = &cacheBuffer_.mbr.part[part - 1]; if ((p->boot & 0x7F) != 0 || p->totalSectors < 100 || p->firstSector == 0) return false; // not a valid partition volumeStartBlock = p->firstSector; diff --git a/Marlin/src/sd/SdVolume.h b/Marlin/src/sd/SdVolume.h index 2d57c681c4..8122087451 100644 --- a/Marlin/src/sd/SdVolume.h +++ b/Marlin/src/sd/SdVolume.h @@ -124,7 +124,7 @@ class SdVolume { * \param[out] v value of entry * \return true for success or false for failure */ - bool dbgFat(uint32_t n, uint32_t* v) { return fatGet(n, v); } + bool dbgFat(uint32_t n, uint32_t *v) { return fatGet(n, v); } private: // Allow SdBaseFile access to SdVolume private data. @@ -161,7 +161,7 @@ class SdVolume { uint16_t rootDirEntryCount_; // number of entries in FAT16 root dir uint32_t rootDirStart_; // root start block for FAT16, cluster for FAT32 - bool allocContiguous(uint32_t count, uint32_t* curCluster); + bool allocContiguous(uint32_t count, uint32_t *curCluster); uint8_t blockOfCluster(uint32_t position) const { return (position >> 9) & (blocksPerCluster_ - 1); } uint32_t clusterStartBlock(uint32_t cluster) const { return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_); } uint32_t blockNumber(uint32_t cluster, uint32_t position) const { return clusterStartBlock(cluster) + blockOfCluster(position); } @@ -183,8 +183,8 @@ class SdVolume { cacheBlockNumber_ = blockNumber; } void cacheSetDirty() { cacheDirty_ |= CACHE_FOR_WRITE; } - bool chainSize(uint32_t beginCluster, uint32_t* size); - bool fatGet(uint32_t cluster, uint32_t* value); + bool chainSize(uint32_t beginCluster, uint32_t *size); + bool fatGet(uint32_t cluster, uint32_t *value); bool fatPut(uint32_t cluster, uint32_t value); bool fatPutEOC(uint32_t cluster) { return fatPut(cluster, 0x0FFFFFFF); } bool freeChain(uint32_t cluster); @@ -193,6 +193,6 @@ class SdVolume { if (fatType_ == 16) return cluster >= FAT16EOC_MIN; return cluster >= FAT32EOC_MIN; } - bool readBlock(uint32_t block, uint8_t* dst) { return sdCard_->readBlock(block, dst); } - bool writeBlock(uint32_t block, const uint8_t* dst) { return sdCard_->writeBlock(block, dst); } + bool readBlock(uint32_t block, uint8_t *dst) { return sdCard_->readBlock(block, dst); } + bool writeBlock(uint32_t block, const uint8_t *dst) { return sdCard_->writeBlock(block, dst); } }; diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 4399d9a4b6..1f917f8576 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -122,7 +122,7 @@ public: // Select a file static void selectFileByIndex(const uint16_t nr); - static void selectFileByName(const char* const match); + static void selectFileByName(const char * const match); // Print job static void openAndPrintFile(const char *name); // (working directory) diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 6dc7063122..dc9efcb672 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -295,7 +295,7 @@ uint32_t Sd2Card::cardSize() { return lun0_capacity; } -bool Sd2Card::readBlock(uint32_t block, uint8_t* dst) { +bool Sd2Card::readBlock(uint32_t block, uint8_t *dst) { if (!isInserted()) return false; #if USB_DEBUG >= 3 if (block >= lun0_capacity) { @@ -309,7 +309,7 @@ bool Sd2Card::readBlock(uint32_t block, uint8_t* dst) { return bulk.Read(0, block, 512, 1, dst) == 0; } -bool Sd2Card::writeBlock(uint32_t block, const uint8_t* src) { +bool Sd2Card::writeBlock(uint32_t block, const uint8_t *src) { if (!isInserted()) return false; #if USB_DEBUG >= 3 if (block >= lun0_capacity) { diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h index 5789121367..320678d091 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h @@ -60,15 +60,15 @@ class Sd2Card { static void idle(); inline bool readStart(const uint32_t block) { pos = block; return isReady(); } - inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); } + inline bool readData(uint8_t *dst) { return readBlock(pos++, dst); } inline bool readStop() const { return true; } inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return isReady(); } - inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); } + inline bool writeData(uint8_t *src) { return writeBlock(pos++, src); } inline bool writeStop() const { return true; } - bool readBlock(uint32_t block, uint8_t* dst); - bool writeBlock(uint32_t blockNumber, const uint8_t* src); + bool readBlock(uint32_t block, uint8_t *dst); + bool writeBlock(uint32_t blockNumber, const uint8_t *src); bool readCSD(csd_t*) { return true; } diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp index f26e82b9c7..75421f4482 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp @@ -133,7 +133,7 @@ uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_l /* 00 = success */ /* 01-0f = non-zero HRSLT */ uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, - uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) { + uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p) { bool direction = false; // Request direction, IN or OUT uint8_t rcode; SETUP_PKT setup_pkt; @@ -201,7 +201,7 @@ uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bReque * Keep sending INs and writes data to memory area pointed by 'data' * rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, fe = USB xfer timeout */ -uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) { +uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval /*= 0*/) { EpInfo *pep = nullptr; uint16_t nak_limit = 0; @@ -215,7 +215,7 @@ uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* return InTransfer(pep, nak_limit, nbytesptr, data, bInterval); } -uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) { +uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval /*= 0*/) { uint8_t rcode = 0; uint8_t pktsize; @@ -286,7 +286,7 @@ uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, ui * Handles NAK bug per Maxim Application Note 4000 for single buffer transfer * rcode 0 if no errors. rcode 01-0f is relayed from HRSL */ -uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) { +uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data) { EpInfo *pep = nullptr; uint16_t nak_limit = 0; @@ -743,12 +743,12 @@ uint8_t USB::ReleaseDevice(uint8_t addr) { } // Get device descriptor -uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { +uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr) { return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, nullptr); } // Get configuration descriptor -uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { +uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) { return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, nullptr); } @@ -774,7 +774,7 @@ uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser } // Get string descriptor -uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) { +uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t *dataptr) { return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, nullptr); } diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h b/Marlin/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h index d94958dd54..5c76ffb758 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h @@ -250,19 +250,19 @@ public: uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr); /* Control requests */ - uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr); - uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr); + uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr); + uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr); uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p); - uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t* dataptr); + uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr); uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr); uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value); /**/ - uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, bool direction); + uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr, bool direction); uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit); - uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval = 0); - uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data); + uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval = 0); + uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data); uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit); void Task(); @@ -272,7 +272,7 @@ public: uint8_t ReleaseDevice(uint8_t addr); uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, - uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p); + uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p); private: void init(); @@ -285,17 +285,17 @@ private: #if 0 //defined(USB_METHODS_INLINE) //get device descriptor -inline uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { +inline uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr)); } //get configuration descriptor -inline uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { +inline uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr)); } //get string descriptor -inline uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t* dataptr) { +inline uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t *dataptr) { return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr)); } //set address diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp index 190a0f1a9e..4ee206bc32 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp @@ -51,7 +51,7 @@ void MAX3421e::regWr(uint8_t reg, uint8_t data) { // multiple-byte write // return a pointer to memory position after last written -uint8_t* MAX3421e::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) { +uint8_t* MAX3421e::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { cs(); spiSend(reg | 0x02); while (nbytes--) spiSend(*data_p++); @@ -79,7 +79,7 @@ uint8_t MAX3421e::regRd(uint8_t reg) { // multiple-byte register read // return a pointer to a memory position after last read -uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) { +uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { cs(); spiSend(reg); while (nbytes--) *data_p++ = spiRec(); diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.h b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.h index 5c3b852d55..cbdd281858 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.h @@ -37,10 +37,10 @@ class MAX3421e { bool start(); void regWr(uint8_t reg, uint8_t data); - uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p); + uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p); void gpioWr(uint8_t data); uint8_t regRd(uint8_t reg); - uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p); + uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p); uint8_t gpioRd(); bool reset(); diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h index 4ab1a6b8f9..3f758e7712 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h @@ -594,7 +594,7 @@ void UHS_USB_HOST_BASE::ReleaseDevice(uint8_t addr) { * @param dataptr pointer to the data to return * @return status of the request, zero is success. */ -uint8_t UHS_USB_HOST_BASE::getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t* dataptr) { +uint8_t UHS_USB_HOST_BASE::getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t *dataptr) { return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes), nbytes, dataptr)); } @@ -607,7 +607,7 @@ uint8_t UHS_USB_HOST_BASE::getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t* d * @param dataptr ointer to the data to return * @return status of the request, zero is success. */ -uint8_t UHS_USB_HOST_BASE::getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { +uint8_t UHS_USB_HOST_BASE::getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) { return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes), nbytes, dataptr)); } @@ -621,7 +621,7 @@ uint8_t UHS_USB_HOST_BASE::getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t c * @param dataptr pointer to the data to return * @return status of the request, zero is success. */ -uint8_t UHS_USB_HOST_BASE::getStrDescr(uint8_t addr, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) { +uint8_t UHS_USB_HOST_BASE::getStrDescr(uint8_t addr, uint16_t ns, uint8_t index, uint16_t langid, uint8_t *dataptr) { return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns), ns, dataptr)); } @@ -668,7 +668,7 @@ uint8_t UHS_USB_HOST_BASE::setConf(uint8_t addr, uint8_t conf_value) { * @param data pointer to buffer to hold transfer * @return zero for success or error code */ -uint8_t UHS_USB_HOST_BASE::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) { +uint8_t UHS_USB_HOST_BASE::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data) { UHS_EpInfo *pep = NULL; uint16_t nak_limit = 0; HOST_DEBUG("outTransfer: addr: 0x%2.2x ep: 0x%2.2x nbytes: 0x%4.4x data: 0x%p\r\n", addr, ep, nbytes, data); @@ -689,7 +689,7 @@ uint8_t UHS_USB_HOST_BASE::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes * @param data pointer to buffer to hold transfer * @return zero for success or error code */ -uint8_t UHS_USB_HOST_BASE::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data) { +uint8_t UHS_USB_HOST_BASE::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data) { UHS_EpInfo *pep = NULL; uint16_t nak_limit = 0; @@ -980,7 +980,7 @@ uint8_t UHS_USB_HOST_BASE::eat(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, return rcode; } -uint8_t UHS_USB_HOST_BASE::ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t* dataptr) { +uint8_t UHS_USB_HOST_BASE::ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t *dataptr) { //bool direction = bmReqType & 0x80; //request direction, IN or OUT uint8_t rcode = 0; diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h index b289a896ef..b81dbf2a28 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h @@ -103,7 +103,7 @@ public: return (current_state == usb_task_state); }; - virtual UHS_EpInfo * UHS_NI ctrlReqOpen(NOTUSED(uint8_t addr), NOTUSED(uint64_t Request), NOTUSED(uint8_t* dataptr)) { + virtual UHS_EpInfo * UHS_NI ctrlReqOpen(NOTUSED(uint8_t addr), NOTUSED(uint64_t Request), NOTUSED(uint8_t *dataptr)) { return NULL; }; @@ -213,17 +213,17 @@ public: uint8_t UHS_NI EPClearHalt(uint8_t addr, uint8_t ep); - uint8_t UHS_NI ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t* dataptr); + uint8_t UHS_NI ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t *dataptr); - uint8_t UHS_NI getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t* dataptr); + uint8_t UHS_NI getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t *dataptr); - uint8_t UHS_NI getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t* dataptr); + uint8_t UHS_NI getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t *dataptr); uint8_t UHS_NI setAddr(uint8_t oldaddr, uint8_t newaddr); uint8_t UHS_NI setConf(uint8_t addr, uint8_t conf_value); - uint8_t UHS_NI getStrDescr(uint8_t addr, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t* dataptr); + uint8_t UHS_NI getStrDescr(uint8_t addr, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr); void UHS_NI ReleaseDevice(uint8_t addr); @@ -262,8 +262,8 @@ public: uint8_t enumerateInterface(ENUMERATION_INFO *ei); uint8_t getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pep, uint8_t data[], uint16_t *left, uint16_t *read, uint8_t *offset); uint8_t initDescrStream(ENUMERATION_INFO *ei, USB_FD_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset); - uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data); - uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data); + uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data); + uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data); uint8_t doSoftReset(uint8_t parent, uint8_t port, uint8_t address); uint8_t getone(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset); uint8_t eat(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset, uint16_t *yum); diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h index 56d6400979..7d17d626c1 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h @@ -388,7 +388,7 @@ public: return (!condet); }; - virtual UHS_EpInfo *ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t* dataptr); + virtual UHS_EpInfo *ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t *dataptr); virtual void UHS_NI vbusPower(VBUS_t state) { regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE) | (uint8_t)(state)); @@ -483,8 +483,8 @@ public: void gpioWr(uint8_t data); uint8_t regRd(uint8_t reg); uint8_t gpioRd(); - uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p); - uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p); + uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p); + uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p); // ARM/NVIC specific, used to emulate reentrant ISR. #ifdef SWI_IRQ_NUM 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 7fe48652fd..6cfc0152d0 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 @@ -76,7 +76,7 @@ void UHS_NI MAX3421E_HOST::regWr(uint8_t reg, uint8_t data) { /* multiple-byte write */ /* returns a pointer to memory position after last written */ -uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) { +uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { SPIclass.beginTransaction(MAX3421E_SPI_Settings); MARLIN_UHS_WRITE_SS(LOW); SPIclass.transfer(reg | 0x02); @@ -117,7 +117,7 @@ uint8_t UHS_NI MAX3421E_HOST::regRd(uint8_t reg) { /* multiple-byte register read */ /* returns a pointer to a memory position after last read */ -uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) { +uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { SPIclass.beginTransaction(MAX3421E_SPI_Settings); MARLIN_UHS_WRITE_SS(LOW); SPIclass.transfer(reg); @@ -472,7 +472,7 @@ uint8_t UHS_NI MAX3421E_HOST::SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo ** * @param data pointer to data buffer * @return 0 on success */ -uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data) { +uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data) { uint8_t rcode = 0; uint8_t pktsize; diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h index abac2b08b3..a8500c595f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h @@ -479,7 +479,7 @@ */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); + void assert_failed(uint8_t *file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ diff --git a/buildroot/share/fonts/genpages.c b/buildroot/share/fonts/genpages.c index c855ceac50..dea5b05c5c 100644 --- a/buildroot/share/fonts/genpages.c +++ b/buildroot/share/fonts/genpages.c @@ -142,12 +142,12 @@ uint8_t* get_utf8_value(uint8_t *pstart, wchar_t *pval) { return p; } -void usage(char* progname) { +void usage(char *progname) { fprintf(stderr, "usage: %s\n", progname); fprintf(stderr, " read data from stdin\n"); } -void utf8_parse(const char* msg, unsigned int len) { +void utf8_parse(const char *msg, unsigned int len) { uint8_t *pend = NULL; uint8_t *p; uint8_t *pre; From f587a4e3f30324789a50acc107047e430be1a172 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Mar 2021 20:00:57 -0500 Subject: [PATCH 130/311] Improve uncrust script --- buildroot/bin/uncrust | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/buildroot/bin/uncrust b/buildroot/bin/uncrust index 9893b5c380..7898f73c8c 100755 --- a/buildroot/bin/uncrust +++ b/buildroot/bin/uncrust @@ -6,11 +6,12 @@ TMPDIR=`mktemp -d` # Reformat a single file to tmp/ -uncrustify -l CPP -c ./buildroot/share/extras/uncrustify.cfg -f "$1" >$TMPDIR/uncrustify.out - -# Replace the original file -cp "$TMPDIR/uncrustify.out" "$1" +if uncrustify -l CPP -c ./buildroot/share/extras/uncrustify.cfg -f "$1" >$TMPDIR/uncrustify.out ; then + cp "$TMPDIR/uncrustify.out" "$1" ; # Replace the original file +else + echo "Something went wrong with uncrustify." +fi # Clean up, deliberately -rm "$TMPDIR/uncrustify.out" +[[ -f "$TMPDIR/uncrustify.out" ]] && rm "$TMPDIR/uncrustify.out" rmdir "$TMPDIR" From d30b5481f5373559bc152d48a48ebabc5304acff Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Tue, 30 Mar 2021 03:56:44 +0200 Subject: [PATCH 131/311] Optimize BLTouch code for size (#21477) --- Marlin/src/feature/bltouch.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index 8bd41f03e4..9ecccb4256 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -74,33 +74,33 @@ public: static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing - FORCE_INLINE static bool deploy() { return deploy_proc(); } - FORCE_INLINE static bool stow() { return stow_proc(); } - FORCE_INLINE static bool status() { return status_proc(); } + static bool deploy() { return deploy_proc(); } + static bool stow() { return stow_proc(); } + static bool status() { return status_proc(); } // Native BLTouch commands ("Underscore"...), used in lcd menus and internally - FORCE_INLINE static void _reset() { command(BLTOUCH_RESET, BLTOUCH_RESET_DELAY); } + static void _reset() { command(BLTOUCH_RESET, BLTOUCH_RESET_DELAY); } - FORCE_INLINE static void _selftest() { command(BLTOUCH_SELFTEST, BLTOUCH_DELAY); } + static void _selftest() { command(BLTOUCH_SELFTEST, BLTOUCH_DELAY); } - FORCE_INLINE static void _set_SW_mode() { command(BLTOUCH_SW_MODE, BLTOUCH_DELAY); } - FORCE_INLINE static void _reset_SW_mode() { if (triggered()) _stow(); else _deploy(); } + static void _set_SW_mode() { command(BLTOUCH_SW_MODE, BLTOUCH_DELAY); } + static void _reset_SW_mode() { if (triggered()) _stow(); else _deploy(); } - FORCE_INLINE static void _set_5V_mode() { command(BLTOUCH_5V_MODE, BLTOUCH_SET5V_DELAY); } - FORCE_INLINE static void _set_OD_mode() { command(BLTOUCH_OD_MODE, BLTOUCH_SETOD_DELAY); } - FORCE_INLINE static void _mode_store() { command(BLTOUCH_MODE_STORE, BLTOUCH_MODE_STORE_DELAY); } + static void _set_5V_mode() { command(BLTOUCH_5V_MODE, BLTOUCH_SET5V_DELAY); } + static void _set_OD_mode() { command(BLTOUCH_OD_MODE, BLTOUCH_SETOD_DELAY); } + static void _mode_store() { command(BLTOUCH_MODE_STORE, BLTOUCH_MODE_STORE_DELAY); } - FORCE_INLINE static void _deploy() { command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); } - FORCE_INLINE static void _stow() { command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY); } + static void _deploy() { command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); } + static void _stow() { command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY); } - FORCE_INLINE static void mode_conv_5V() { mode_conv_proc(true); } - FORCE_INLINE static void mode_conv_OD() { mode_conv_proc(false); } + static void mode_conv_5V() { mode_conv_proc(true); } + static void mode_conv_OD() { mode_conv_proc(false); } static bool triggered(); private: - FORCE_INLINE static bool _deploy_query_alarm() { return command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); } - FORCE_INLINE static bool _stow_query_alarm() { return command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY) == STOW_ALARM; } + static bool _deploy_query_alarm() { return command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); } + static bool _stow_query_alarm() { return command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY) == STOW_ALARM; } static void clear(); static bool command(const BLTCommand cmd, const millis_t &ms); From c298095000ac0ff5213dea2348b432779ad894ef Mon Sep 17 00:00:00 2001 From: Ste Date: Tue, 30 Mar 2021 04:07:21 +0200 Subject: [PATCH 132/311] Align temp settings (#21329) --- Marlin/Configuration.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index c9c83f9bb6..f333c3369b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -437,17 +437,17 @@ //#define TEMP_SENSOR_1_AS_REDUNDANT #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 -#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 -#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 +#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer +#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target -#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 -#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 +#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer +#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target #define TEMP_CHAMBER_RESIDENCY_TIME 10 // (seconds) Time to wait for chamber to "settle" in M191 -#define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer +#define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target // Below this temperature the heater will be switched off // because it probably indicates a broken thermistor wire. From 3f7cd45df4b7159e92b37eb561fe4d7980d031af Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Tue, 30 Mar 2021 04:14:11 +0200 Subject: [PATCH 133/311] Generalize MMU (#21469) --- Marlin/Configuration.h | 10 +++++----- Marlin/src/gcode/control/T.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 20 ++++++++++---------- Marlin/src/inc/SanityCheck.h | 14 +++++++++----- Marlin/src/pins/pins.h | 4 ++-- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index f333c3369b..93a60394c2 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -160,11 +160,11 @@ * Multi-Material Unit * Set to one of these predefined models: * - * PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version) - * PRUSA_MMU2 : Průša MMU2 - * PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5) - * SMUFF_EMU_MMU2 : Technik Gegg SMuFF (Průša MMU2 emulation mode) - * SMUFF_EMU_MMU2S : Technik Gegg SMuFF (Průša MMU2S emulation mode) + * PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version) + * PRUSA_MMU2 : Průša MMU2 + * PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5) + * EXTENDABLE_EMU_MMU2 : MMU with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) + * EXTENDABLE_EMU_MMU2S : MMUS with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) * * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. * See additional options in Configuration_adv.h. diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index 3ce284f82e..6a084d83ad 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -40,7 +40,7 @@ * F[units/min] Set the movement feedrate * S1 Don't move the tool in XY after change * - * For PRUSA_MMU2(S) and SMUFF_EMU_MMU2(S) + * For PRUSA_MMU2(S) and EXTENDABLE_EMU_MMU2(S) * T[n] Gcode to extrude at least 38.10 mm at feedrate 19.02 mm/s must follow immediately to load to extruder wheels. * T? Gcode to extrude shouldn't have to follow. Load to extruder wheels is done automatically. * Tx Same as T?, but nozzle doesn't have to be preheated. Tc requires a preheated nozzle to finish filament load. diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index af902481f3..a0fced150f 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -501,11 +501,11 @@ /** * Multi-Material-Unit supported models */ -#define PRUSA_MMU1 1 -#define PRUSA_MMU2 2 -#define PRUSA_MMU2S 3 -#define SMUFF_EMU_MMU2 12 -#define SMUFF_EMU_MMU2S 13 +#define PRUSA_MMU1 1 +#define PRUSA_MMU2 2 +#define PRUSA_MMU2S 3 +#define EXTENDABLE_EMU_MMU2 12 +#define EXTENDABLE_EMU_MMU2S 13 #ifdef MMU_MODEL #define HAS_MMU 1 @@ -517,16 +517,16 @@ #define HAS_PRUSA_MMU2 1 #define HAS_PRUSA_MMU2S 1 #endif - #if MMU_MODEL == SMUFF_EMU_MMU2 || MMU_MODEL == SMUFF_EMU_MMU2S - #define HAS_SMUFF 1 + #if MMU_MODEL == EXTENDABLE_EMU_MMU2 || MMU_MODEL == EXTENDABLE_EMU_MMU2S + #define HAS_EXTENDABLE_MMU 1 #endif #endif #undef PRUSA_MMU1 #undef PRUSA_MMU2 #undef PRUSA_MMU2S -#undef SMUFF_EMU_MMU2 -#undef SMUFF_EMU_MMU2S +#undef EXTENDABLE_EMU_MMU2 +#undef EXTENDABLE_EMU_MMU2S /** * Extruders have some combination of stepper motors and hotends @@ -579,7 +579,7 @@ #undef DISABLE_INACTIVE_EXTRUDER #endif -// Průša MMU1, MMU 2.0, MMUS 2.0 and SMuFF force SINGLENOZZLE +// Průša MMU1, MMU(S) 2.0 and EXTENDABLE_EMU_MMU2(S) force SINGLENOZZLE #if HAS_MMU #define SINGLENOZZLE #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 6ed0f53245..287f0c5600 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -920,10 +920,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "PRUSA_MMU2 is obsolete. Define MMU_MODEL as PRUSA_MMU2 instead." #elif ENABLED(PRUSA_MMU2_S_MODE) #error "PRUSA_MMU2_S_MODE is obsolete. Define MMU_MODEL as PRUSA_MMU2S instead." +#elif ENABLED(SMUFF_EMU_MMU2) + #error "SMUFF_EMU_MMU2 is obsolete. Define MMU_MODEL as EXTENDABLE_EMU_MMU2 instead." +#elif ENABLED(SMUFF_EMU_MMU2S) + #error "SMUFF_EMU_MMU2S is obsolete. Define MMU_MODEL as EXTENDABLE_EMU_MMU2S instead." #endif /** - * Multi-Material-Unit 2 / SMuFF requirements + * Multi-Material-Unit 2 / EXTENDABLE_EMU_MMU2 requirements */ #if HAS_PRUSA_MMU2 #if EXTRUDERS != 5 @@ -938,11 +942,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(MMU_EXTRUDER_SENSOR) && !HAS_LCD_MENU #error "MMU_EXTRUDER_SENSOR requires an LCD supporting MarlinUI to be enabled." #elif DISABLED(ADVANCED_PAUSE_FEATURE) - static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / SMUFF_EMU_MMU2(S)."); + static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / HAS_EXTENDABLE_MMU(S)."); #endif #endif -#if HAS_SMUFF && EXTRUDERS > 12 - #error "Too many extruders for SMUFF_EMU_MMU2(S). (12 maximum)." +#if HAS_EXTENDABLE_MMU && EXTRUDERS > 15 + #error "Too many extruders for MMU(S) emulation mode. (15 maximum)." #endif /** @@ -980,7 +984,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TOOLCHANGE_ZRAISE required for EXTRUDERS > 1." #endif -#elif HAS_PRUSA_MMU1 || HAS_SMUFF +#elif HAS_PRUSA_MMU1 || HAS_EXTENDABLE_MMU #error "Multi-Material-Unit requires 2 or more EXTRUDERS." diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 8eecce2c17..35bfb266eb 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -35,8 +35,8 @@ * These numbers are the same in any pin mapping. */ -#if HAS_SMUFF - #define MAX_EXTRUDERS 12 +#if HAS_EXTENDABLE_MMU + #define MAX_EXTRUDERS 15 #else #define MAX_EXTRUDERS 8 #endif From 139c14948621adcaa227bcef67765a5228039cd3 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Tue, 30 Mar 2021 04:36:01 +0200 Subject: [PATCH 134/311] Flags for MarlinSerial instance features (#21318) --- Marlin/src/core/bug_on.h | 7 ++-- Marlin/src/core/macros.h | 44 ++++++++++++++++++---- Marlin/src/core/serial.h | 2 +- Marlin/src/core/serial_base.h | 68 ++++++++++++++++++++++++---------- Marlin/src/core/serial_hook.h | 27 ++++++++++++-- Marlin/src/feature/meatpack.h | 2 + Marlin/src/gcode/gcode_d.cpp | 5 +++ Marlin/src/gcode/host/M115.cpp | 9 ++++- 8 files changed, 127 insertions(+), 37 deletions(-) diff --git a/Marlin/src/core/bug_on.h b/Marlin/src/core/bug_on.h index dc32f0385a..3c9dec0f96 100644 --- a/Marlin/src/core/bug_on.h +++ b/Marlin/src/core/bug_on.h @@ -27,11 +27,12 @@ // Useful macro for stopping the CPU on an unexpected condition // This is used like SERIAL_ECHOPAIR, that is: a key-value call of the local variables you want // to dump to the serial port before stopping the CPU. - #define BUG_ON(V...) do { SERIAL_ECHOPAIR(ONLY_FILENAME, __LINE__, ": "); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0) + // \/ Don't replace by SERIAL_ECHOPAIR since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building + #define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLN(": "); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0) #elif ENABLED(MARLIN_DEV_MODE) // Don't stop the CPU here, but at least dump the bug on the serial port - //#define BUG_ON(V...) do { SERIAL_ECHOPAIR(ONLY_FILENAME, __LINE__, ": BUG!\n"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0) - #define BUG_ON(V...) NOOP + // \/ Don't replace by SERIAL_ECHOPAIR since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building + #define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLN(": BUG!"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0) #else // Release mode, let's ignore the bug #define BUG_ON(V...) NOOP diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index f900993784..fb129cd939 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -318,6 +318,16 @@ #endif + // Allow manipulating enumeration value like flags without ugly cast everywhere + #define ENUM_FLAGS(T) \ + FORCE_INLINE constexpr T operator&(T x, T y) { return static_cast(static_cast(x) & static_cast(y)); } \ + FORCE_INLINE constexpr T operator|(T x, T y) { return static_cast(static_cast(x) | static_cast(y)); } \ + FORCE_INLINE constexpr T operator^(T x, T y) { return static_cast(static_cast(x) ^ static_cast(y)); } \ + FORCE_INLINE constexpr T operator~(T x) { return static_cast(~static_cast(x)); } \ + FORCE_INLINE T & operator&=(T &x, T y) { return x &= y; } \ + FORCE_INLINE T & operator|=(T &x, T y) { return x |= y; } \ + FORCE_INLINE T & operator^=(T &x, T y) { return x ^= y; } + // C++11 solution that is standard compliant. is not available on all platform namespace Private { template struct enable_if { }; @@ -357,23 +367,43 @@ return *str ? findStringEnd(str + 1) : str; } - // Check whether a string contains a slash - constexpr bool containsSlash(const char *str) { - return *str == '/' ? true : (*str ? containsSlash(str + 1) : false); + // Check whether a string contains a specific character + constexpr bool contains(const char *str, const char ch) { + return *str == ch ? true : (*str ? contains(str + 1, ch) : false); } - // Find the last position of the slash - constexpr const char* findLastSlashPos(const char *str) { - return *str == '/' ? (str + 1) : findLastSlashPos(str - 1); + // Find the last position of the specific character (should be called with findStringEnd) + constexpr const char* findLastPos(const char *str, const char ch) { + return *str == ch ? (str + 1) : findLastPos(str - 1, ch); } // Compile-time evaluation of the last part of a file path // Typically used to shorten the path to file in compiled strings // CompileTimeString::baseName(__FILE__) returns "macros.h" and not /path/to/Marlin/src/core/macros.h constexpr const char* baseName(const char *str) { - return containsSlash(str) ? findLastSlashPos(findStringEnd(str)) : str; + return contains(str, '/') ? findLastPos(findStringEnd(str), '/') : str; + } + + // Find the first occurence of a character in a string (or return the last position in the string) + constexpr const char* findFirst(const char *str, const char ch) { + return *str == ch || *str == 0 ? (str + 1) : findFirst(str + 1, ch); + } + // Compute the string length at compile time + constexpr unsigned stringLen(const char *str) { + return *str == 0 ? 0 : 1 + stringLen(str + 1); } } #define ONLY_FILENAME CompileTimeString::baseName(__FILE__) + /** Get the templated type name. This does not depends on RTTI, but on the preprocessor, so it should be quite safe to use even on old compilers. + WARNING: DO NOT RENAME THIS FUNCTION (or change the text inside the function to match what the preprocessor will generate) + The name is chosen very short since the binary will store "const char* gtn(T*) [with T = YourTypeHere]" so avoid long function name here */ + template + inline const char* gtn(T*) { + // It works on GCC by instantiating __PRETTY_FUNCTION__ and parsing the result. So the syntax here is very limited to GCC output + constexpr unsigned verboseChatLen = sizeof("const char* gtn(T*) [with T = ") - 1; + static char templateType[sizeof(__PRETTY_FUNCTION__) - verboseChatLen] = {}; + __builtin_memcpy(templateType, __PRETTY_FUNCTION__ + verboseChatLen, sizeof(__PRETTY_FUNCTION__) - verboseChatLen - 2); + return templateType; + } #else diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 2f23e4e3c2..43137f71d7 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -146,7 +146,7 @@ inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); } #define AS_CHAR(C) serial_char_t(C) // 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); } +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); } diff --git a/Marlin/src/core/serial_base.h b/Marlin/src/core/serial_base.h index 78721c6f14..cdea70e2c5 100644 --- a/Marlin/src/core/serial_base.h +++ b/Marlin/src/core/serial_base.h @@ -45,10 +45,6 @@ struct serial_index_t { constexpr serial_index_t() : index(-1) {} }; -// 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 @@ -59,19 +55,34 @@ enum class PrintBase { 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 +// A simple feature list enumeration +enum class SerialFeature { + None = 0x00, + MeatPack = 0x01, //!< Enabled when Meatpack is present + BinaryFileTransfer = 0x02, //!< Enabled for BinaryFile transfer support (in the future) + Virtual = 0x04, //!< Enabled for virtual serial port (like Telnet / Websocket / ...) + Hookable = 0x08, //!< Enabled if the serial class supports a setHook method +}; +ENUM_FLAGS(SerialFeature); + +// 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); +CALL_IF_EXISTS_IMPL(SerialFeature, features, SerialFeature::None); + +// A simple forward struct to prevent the compiler from selecting print(double, int) as a default overload +// for any type other than double/float. For double/float, a conversion exists so the call will be invisible. 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: + // If the compiler breaks on ambiguity here, it's likely because print(X, base) is called with X not a double/float, and + // a base that's not a PrintBase value. This code is made to detect the error. You MUST set a base explicitly 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. +// 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 the compiler writing // a completely efficient code. template @@ -85,27 +96,44 @@ struct SerialBase { SerialBase(const bool) {} #endif + #define SerialChild static_cast(this) + // Static dispatch methods below: // The most important method here is where it all ends to: - size_t write(uint8_t c) { return static_cast(this)->write(c); } + size_t write(uint8_t c) { return SerialChild->write(c); } + // Called when the parser finished processing an instruction, usually build to nothing - void msgDone() { static_cast(this)->msgDone(); } - // Called upon initialization - void begin(const long baudRate) { static_cast(this)->begin(baudRate); } - // Called upon destruction - void end() { static_cast(this)->end(); } + void msgDone() const { SerialChild->msgDone(); } + + // Called on initialization + void begin(const long baudRate) { SerialChild->begin(baudRate); } + + // Called on destruction + void end() { SerialChild->end(); } + /** Check for available data from the port @param index The port index, usually 0 */ - int available(serial_index_t index = 0) { return static_cast(this)->available(index); } + int available(serial_index_t index=0) const { return SerialChild->available(index); } + /** Read a value from the port @param index The port index, usually 0 */ - int read(serial_index_t index = 0) { return static_cast(this)->read(index); } + int read(serial_index_t index=0) { return SerialChild->read(index); } + + /** Combine the features of this serial instance and return it + @param index The port index, usually 0 */ + SerialFeature features(serial_index_t index=0) const { return static_cast(this)->features(index); } + + // Check if the serial port has a feature + bool has_feature(serial_index_t index, SerialFeature flag) const { (features(index) & flag) != SerialFeature::None; } + // Check if the serial port is connected (usually bypassed) - bool connected() { return static_cast(this)->connected(); } + bool connected() const { return SerialChild->connected(); } + // Redirect flush - void flush() { static_cast(this)->flush(); } + void flush() { SerialChild->flush(); } + // Not all implementation have a flushTX, so let's call them only if the child has the implementation - void flushTX() { CALL_IF_EXISTS(void, static_cast(this), flushTX); } + void flushTX() { CALL_IF_EXISTS(void, SerialChild, flushTX); } // Glue code here FORCE_INLINE void write(const char *str) { while (*str) write(*str++); } diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index c687891fb4..7bc04a5e88 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -65,6 +65,8 @@ struct BaseSerial : public SerialBase< BaseSerial >, public SerialT { bool connected() { return CALL_IF_EXISTS(bool, static_cast(this), connected);; } void flushTX() { CALL_IF_EXISTS(void, static_cast(this), flushTX); } + SerialFeature features(serial_index_t index) const { return CALL_IF_EXISTS(SerialFeature, static_cast(this), features, index); } + // 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; @@ -98,10 +100,11 @@ struct ConditionalSerial : public SerialBase< ConditionalSerial > { bool connected() { return CALL_IF_EXISTS(bool, &out, connected); } void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); } - int available(serial_index_t ) { return (int)out.available(); } - int read(serial_index_t ) { return (int)out.read(); } + int available(serial_index_t) { return (int)out.available(); } + int read(serial_index_t) { return (int)out.read(); } int available() { return (int)out.available(); } int read() { return (int)out.read(); } + SerialFeature features(serial_index_t index) const { return CALL_IF_EXISTS(SerialFeature, &out, features, index); } ConditionalSerial(bool & conditionVariable, SerialT & out, const bool e) : BaseClassT(e), condition(conditionVariable), out(out) {} }; @@ -126,6 +129,7 @@ struct ForwardSerial : public SerialBase< ForwardSerial > { int read(serial_index_t) { return (int)out.read(); } int available() { return (int)out.available(); } int read() { return (int)out.read(); } + SerialFeature features(serial_index_t index) const { return CALL_IF_EXISTS(SerialFeature, &out, features, index); } ForwardSerial(const bool e, SerialT & out) : BaseClassT(e), out(out) {} }; @@ -163,9 +167,15 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial >, public Seria // 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(); + 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 flushTX() { CALL_IF_EXISTS(void, static_cast(this), flushTX); } + + // Append Hookable for this class + SerialFeature features(serial_index_t index) const { return SerialFeature::Hookable | CALL_IF_EXISTS(SerialFeature, static_cast(this), features, index); } void setHook(WriteHook writeHook = 0, EndOfMessageHook eofHook = 0, void * userPointer = 0) { // Order is important here as serial code can be called inside interrupts @@ -251,6 +261,15 @@ struct MultiSerial : public SerialBase< MultiSerial> { // 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); } + SerialFeature features(serial_index_t index) const { return SerialFeature::MeatPack | CALL_IF_EXISTS(SerialFeature, &out, features, index); } + int available(serial_index_t index) { if (charCount) return charCount; // The buffer still has data diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index a683a330f1..8941523a16 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -167,6 +167,11 @@ dump_delay_accuracy_check(); break; + case 7: // D7 dump the current serial port type (hence configuration) + SERIAL_ECHOLNPAIR("Current serial configuration RX_BS:", RX_BUFFER_SIZE, ", TX_BS:", TX_BUFFER_SIZE); + SERIAL_ECHOLN(gtn(&SERIAL_IMPL)); + 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") ")"); diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index a518e68cf5..4f18e5504d 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -22,6 +22,8 @@ #include "../gcode.h" #include "../../inc/MarlinConfig.h" +#include "../queue.h" // for getting the command port + #if ENABLED(M115_GEOMETRY_REPORT) #include "../../module/motion.h" @@ -59,6 +61,9 @@ void GcodeSuite::M115() { #if ENABLED(EXTENDED_CAPABILITIES_REPORT) + // The port that sent M115 + serial_index_t port = queue.ring_buffer.command_port(); + // PAREN_COMMENTS TERN_(PAREN_COMMENTS, cap_line(PSTR("PAREN_COMMENTS"), true)); @@ -69,7 +74,7 @@ void GcodeSuite::M115() { cap_line(PSTR("SERIAL_XON_XOFF"), ENABLED(SERIAL_XON_XOFF)); // BINARY_FILE_TRANSFER (M28 B1) - cap_line(PSTR("BINARY_FILE_TRANSFER"), ENABLED(BINARY_FILE_TRANSFER)); + cap_line(PSTR("BINARY_FILE_TRANSFER"), ENABLED(BINARY_FILE_TRANSFER)); // TODO: Use SERIAL_IMPL.has_feature(port, SerialFeature::BinaryFileTransfer) once implemented // EEPROM (M500, M501) cap_line(PSTR("EEPROM"), ENABLED(EEPROM_SETTINGS)); @@ -148,7 +153,7 @@ void GcodeSuite::M115() { cap_line(PSTR("COOLER_TEMPERATURE"), ENABLED(HAS_COOLER)); // MEATPACK Compression - cap_line(PSTR("MEATPACK"), ENABLED(HAS_MEATPACK)); + cap_line(PSTR("MEATPACK"), SERIAL_IMPL.has_feature(port, SerialFeature::MeatPack)); // Machine Geometry #if ENABLED(M115_GEOMETRY_REPORT) From 6e0b79a33b7e6d5405be6d0ae5b16e5f3fd62fac Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Mon, 29 Mar 2021 23:52:30 -0300 Subject: [PATCH 135/311] Fix and add STM32 SDIO DMA (#21476) --- .../src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp | 219 ++++++++++-------- Marlin/src/gcode/gcode_d.cpp | 105 +++++++-- 2 files changed, 199 insertions(+), 125 deletions(-) diff --git a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp index fc9b960c1c..824142b889 100644 --- a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp +++ b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp @@ -36,9 +36,10 @@ // use USB drivers - extern "C" { int8_t SD_MSC_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); - int8_t SD_MSC_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); - extern SD_HandleTypeDef hsd; + extern "C" { + int8_t SD_MSC_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); + int8_t SD_MSC_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); + extern SD_HandleTypeDef hsd; } bool SDIO_Init() { @@ -75,7 +76,18 @@ #error "ERROR - Only STM32F103xE, STM32F103xG, STM32F4xx or STM32F7xx CPUs supported" #endif + // Fixed + #define SDIO_D0_PIN PC8 + #define SDIO_D1_PIN PC9 + #define SDIO_D2_PIN PC10 + #define SDIO_D3_PIN PC11 + #define SDIO_CK_PIN PC12 + #define SDIO_CMD_PIN PD2 + SD_HandleTypeDef hsd; // create SDIO structure + // F4 support one dma for RX and another for TX. + // But Marlin will never do read and write at same time, so we use always one dma for both. + DMA_HandleTypeDef hdma_sdio; /* SDIO_INIT_CLK_DIV is 118 @@ -96,12 +108,12 @@ // Target Clock, configurable. Default is 18MHz, from STM32F1 #ifndef SDIO_CLOCK - #define SDIO_CLOCK 18000000 /* 18 MHz */ + #define SDIO_CLOCK 18000000 // 18 MHz #endif // SDIO retries, configurable. Default is 3, from STM32F1 #ifndef SDIO_READ_RETRIES - #define SDIO_READ_RETRIES 3 + #define SDIO_READ_RETRIES 3 #endif // SDIO Max Clock (naming from STM Manual, don't change) @@ -120,24 +132,21 @@ } void go_to_transfer_speed() { - SD_InitTypeDef Init; - /* Default SDIO peripheral configuration for SD card initialization */ - Init.ClockEdge = hsd.Init.ClockEdge; - Init.ClockBypass = hsd.Init.ClockBypass; - Init.ClockPowerSave = hsd.Init.ClockPowerSave; - Init.BusWide = hsd.Init.BusWide; - Init.HardwareFlowControl = hsd.Init.HardwareFlowControl; - Init.ClockDiv = clock_to_divider(SDIO_CLOCK); + hsd.Init.ClockEdge = hsd.Init.ClockEdge; + hsd.Init.ClockBypass = hsd.Init.ClockBypass; + hsd.Init.ClockPowerSave = hsd.Init.ClockPowerSave; + hsd.Init.BusWide = hsd.Init.BusWide; + hsd.Init.HardwareFlowControl = hsd.Init.HardwareFlowControl; + hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); /* Initialize SDIO peripheral interface with default configuration */ - SDIO_Init(hsd.Instance, Init); + SDIO_Init(hsd.Instance, hsd.Init); } void SD_LowLevel_Init(void) { uint32_t tempreg; - __HAL_RCC_SDIO_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); //enable GPIO clocks __HAL_RCC_GPIOD_CLK_ENABLE(); //enable GPIO clocks @@ -163,11 +172,45 @@ 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 - RCC->APB2ENR |= RCC_APB2RSTR_SDIORST_Msk; // enable SDIO clock - // Enable the DMA2 Clock + // Setup DMA + #if defined(STM32F1xx) + hdma_sdio.Init.Mode = DMA_NORMAL; + hdma_sdio.Instance = DMA2_Channel4; + HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn); + #elif defined(STM32F4xx) + hdma_sdio.Init.Mode = DMA_PFCTRL; + hdma_sdio.Instance = DMA2_Stream3; + hdma_sdio.Init.Channel = DMA_CHANNEL_4; + hdma_sdio.Init.FIFOMode = DMA_FIFOMODE_ENABLE; + hdma_sdio.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; + hdma_sdio.Init.MemBurst = DMA_MBURST_INC4; + hdma_sdio.Init.PeriphBurst = DMA_PBURST_INC4; + HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); + #endif + HAL_NVIC_EnableIRQ(SDIO_IRQn); + hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sdio.Init.MemInc = DMA_MINC_ENABLE; + hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sdio.Init.Priority = DMA_PRIORITY_LOW; + __HAL_LINKDMA(&hsd, hdmarx, hdma_sdio); + __HAL_LINKDMA(&hsd, hdmatx, hdma_sdio); + + #if defined(STM32F1xx) + __HAL_RCC_SDIO_CLK_ENABLE(); + __HAL_RCC_DMA2_CLK_ENABLE(); + #else + __HAL_RCC_SDIO_FORCE_RESET(); + delay(2); + __HAL_RCC_SDIO_RELEASE_RESET(); + delay(2); + __HAL_RCC_SDIO_CLK_ENABLE(); + + __HAL_RCC_DMA2_FORCE_RESET(); + delay(2); + __HAL_RCC_DMA2_RELEASE_RESET(); + delay(2); + __HAL_RCC_DMA2_CLK_ENABLE(); #endif //Initialize the SDIO (with initial <400Khz Clock) @@ -179,6 +222,7 @@ // Power up the SDIO SDIO_PowerState_ON(SDIO); + hsd.Instance = SDIO; } void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { // application specific init @@ -222,107 +266,82 @@ if (!status) break; if (!--retry_Cnt) return false; // return failing status if retries are exhausted } + go_to_transfer_speed(); } #endif return true; } - /* - void init_SDIO_pins(void) { - GPIO_InitTypeDef GPIO_InitStruct = {0}; - // SDIO GPIO Configuration - // PC8 ------> SDIO_D0 - // PC12 ------> SDIO_CK - // PD2 ------> SDIO_CMD + static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) { + if(HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false; - GPIO_InitStruct.Pin = GPIO_PIN_8; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); - GPIO_InitStruct.Pin = GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_2; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - } - */ - //bool SDIO_init() { return (bool) (SD_SDIO_Init() ? 1 : 0);} - //bool SDIO_Init_C() { return (bool) (SD_SDIO_Init() ? 1 : 0);} - - bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { - hsd.Instance = SDIO; - uint8_t retryCnt = SDIO_READ_RETRIES; - - bool status; - for (;;) { - TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); - status = (bool) HAL_SD_ReadBlocks(&hsd, (uint8_t*)dst, block, 1, 1000); // read one 512 byte block with 500mS timeout - status |= (bool) HAL_SD_GetCardState(&hsd); // make sure all is OK - if (!status) break; // return passing status - if (!--retryCnt) break; // return failing status if retries are exhausted + HAL_StatusTypeDef ret; + if (src) { + hdma_sdio.Init.Direction = DMA_MEMORY_TO_PERIPH; + HAL_DMA_Init(&hdma_sdio); + ret = HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)src, block, 1); + } + else { + hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY; + HAL_DMA_Init(&hdma_sdio); + ret = HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)dst, block, 1); } - return status; - /* - return (bool) ((status_read | status_card) ? 1 : 0); - - if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false; - if (blockAddress >= SdCard.LogBlockNbr) return false; - if ((0x03 & (uint32_t)data)) return false; // misaligned data - - if (SdCard.CardType != CARD_SDHC_SDXC) { blockAddress *= 512U; } - - if (!SDIO_CmdReadSingleBlock(blockAddress)) { - SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS); - dma_disable(SDIO_DMA_DEV, SDIO_DMA_CHANNEL); + if (ret != HAL_OK) { + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); return false; } - while (!SDIO_GET_FLAG(SDIO_STA_DATAEND | SDIO_STA_TRX_ERROR_FLAGS)) {} - - dma_disable(SDIO_DMA_DEV, SDIO_DMA_CHANNEL); - - if (SDIO->STA & SDIO_STA_RXDAVL) { - while (SDIO->STA & SDIO_STA_RXDAVL) (void)SDIO->FIFO; - SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS); - return false; + uint32_t timeout = millis() + 500; + // Wait the transfer + while (hsd.State != HAL_SD_STATE_READY) { + if (millis() > timeout) { + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + return false; + } } - if (SDIO_GET_FLAG(SDIO_STA_TRX_ERROR_FLAGS)) { - SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS); - return false; - } - SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS); - */ + while (__HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TC_FLAG_INDEX(&hdma_sdio)) != 0 + || __HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TE_FLAG_INDEX(&hdma_sdio)) != 0) { /* nada */ } + + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + + timeout = millis() + 500; + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) + if (millis() > timeout) return false; return true; } - bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { - hsd.Instance = SDIO; - uint8_t retryCnt = SDIO_READ_RETRIES; - bool status; - for (;;) { - status = (bool) HAL_SD_WriteBlocks(&hsd, (uint8_t*)src, block, 1, 500); // write one 512 byte block with 500mS timeout - status |= (bool) HAL_SD_GetCardState(&hsd); // make sure all is OK - if (!status) break; // return passing status - if (!--retryCnt) break; // return failing status if retries are exhausted - } - return status; + bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { + uint8_t retries = SDIO_READ_RETRIES; + while (retries--) if (SDIO_ReadWriteBlock_DMA(block, NULL, dst)) return true; + return false; } + bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { + uint8_t retries = SDIO_READ_RETRIES; + while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, NULL)) return true; + return false; + } + + #if defined(STM32F1xx) + #define DMA_IRQ_HANDLER DMA2_Channel4_5_IRQHandler + #elif defined(STM32F4xx) + #define DMA_IRQ_HANDLER DMA2_Stream3_IRQHandler + #else + #error "Unknown STM32 architecture." + #endif + + extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } + extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); } + #endif // !USBD_USE_CDC_COMPOSITE #endif // SDIO_SUPPORT #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 8941523a16..f87cebc886 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -29,6 +29,7 @@ #include "../libs/hex_print.h" #include "../HAL/shared/eeprom_if.h" #include "../HAL/shared/Delay.h" + #include "../sd/cardreader.h" extern void dump_delay_accuracy_check(); @@ -126,19 +127,19 @@ #endif case 4: { // D4 Read / Write PIN - // const uint8_t pin = parser.byteval('P'); - // const bool is_out = parser.boolval('F'), - // val = parser.byteval('V', LOW); + //const bool is_out = parser.boolval('F'); + //const uint8_t pin = parser.byteval('P'), + // val = parser.byteval('V', LOW); if (parser.seenval('X')) { // TODO: Write the hex bytes after the X //while (len--) { //} } else { - // while (len--) { - // TODO: Read bytes from EEPROM - // print_hex_byte(eeprom_read_byte(*(adr++)); - // } + //while (len--) { + //// TODO: Read bytes from EEPROM + // print_hex_byte(eeprom_read_byte(adr++)); + //} SERIAL_EOL(); } } break; @@ -155,10 +156,10 @@ //while (len--) {} } else { - // while (len--) { - // TODO: Read bytes from EEPROM - // print_hex_byte(eeprom_read_byte(adr++)); - // } + //while (len--) { + //// TODO: Read bytes from EEPROM + // print_hex_byte(eeprom_read_byte(adr++)); + //} SERIAL_EOL(); } } break; @@ -186,22 +187,76 @@ SERIAL_ECHOLNPGM("FAILURE: Watchdog did not trigger board reset."); } break; - #if ENABLED(POSTMORTEM_DEBUGGING) - case 451: { // Trigger all kind of faults to test exception catcher - SERIAL_ECHOLNPGM("Disabling heaters"); - thermalManager.disable_all_heaters(); - delay(1000); // Allow time to print - volatile uint8_t type[5] = { parser.byteval('T', 1) }; + #if ENABLED(SDSUPPORT) - // The code below is obviously wrong and it's full of quirks to fool the compiler from optimizing away the code - switch (type[0]) { - case 1: default: *(int*)0 = 451; break; // Write at bad address - case 2: { volatile int a = 0; volatile int b = 452 / a; *(int*)&a = b; } break; // Divide by zero (some CPUs accept this, like ARM) - case 3: { *(uint32_t*)&type[1] = 453; volatile int a = *(int*)&type[1]; type[0] = a / 255; } break; // Unaligned access (some CPUs accept this) - case 4: { volatile void (*func)() = (volatile void (*)()) 0xE0000000; func(); } break; // Invalid instruction + case 101: { // D101 Test SD Write + card.openFileWrite("test.gco"); + if (!card.isFileOpen()) { + SERIAL_ECHOLNPAIR("Failed to open test.gco to write."); + return; + } + __attribute__((aligned(sizeof(size_t)))) uint8_t buf[512]; + + uint16_t c; + for (c = 0; c < COUNT(buf); c++) + buf[c] = 'A' + (c % ('Z' - 'A')); + + c = 1024 * 4; + while (c--) { + TERN_(USE_WATCHDOG, watchdog_refresh()); + card.write(buf, COUNT(buf)); + } + SERIAL_ECHOLNPGM(" done"); + card.closefile(); + } break; + + case 102: { // D102 Test SD Read + card.openFileRead("test.gco"); + if (!card.isFileOpen()) { + SERIAL_ECHOLNPAIR("Failed to open test.gco to read."); + return; + } + __attribute__((aligned(sizeof(size_t)))) uint8_t buf[512]; + uint16_t c = 1024 * 4; + while (c--) { + TERN_(USE_WATCHDOG, watchdog_refresh()); + card.read(buf, COUNT(buf)); + bool error = false; + for (uint16_t i = 0; i < COUNT(buf); i++) { + if (buf[i] != ('A' + (i % ('Z' - 'A')))) { + error = true; + break; + } + } + if (error) { + SERIAL_ECHOLNPGM(" Read error!"); + break; + } + } + SERIAL_ECHOLNPGM(" done"); + card.closefile(); + } break; + + #endif // SDSUPPORT + + #if ENABLED(POSTMORTEM_DEBUGGING) + + case 451: { // Trigger all kind of faults to test exception catcher + SERIAL_ECHOLNPGM("Disabling heaters"); + thermalManager.disable_all_heaters(); + delay(1000); // Allow time to print + volatile uint8_t type[5] = { parser.byteval('T', 1) }; + + // The code below is obviously wrong and it's full of quirks to fool the compiler from optimizing away the code + switch (type[0]) { + case 1: default: *(int*)0 = 451; break; // Write at bad address + case 2: { volatile int a = 0; volatile int b = 452 / a; *(int*)&a = b; } break; // Divide by zero (some CPUs accept this, like ARM) + case 3: { *(uint32_t*)&type[1] = 453; volatile int a = *(int*)&type[1]; type[0] = a / 255; } break; // Unaligned access (some CPUs accept this) + case 4: { volatile void (*func)() = (volatile void (*)()) 0xE0000000; func(); } break; // Invalid instruction + } + break; } - break; - } + #endif } } From f43b250ed2f32bf2423e234b1c40d655bf4c484c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Mar 2021 21:10:55 -0500 Subject: [PATCH 136/311] Adjust microsteps alignment --- Marlin/Configuration_adv.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d3ad971e6d..a2f357501b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2507,7 +2507,7 @@ #if AXIS_IS_TMC(E1) #define E1_CURRENT 800 - #define E1_MICROSTEPS E0_MICROSTEPS + #define E1_MICROSTEPS E0_MICROSTEPS #define E1_RSENSE 0.11 #define E1_CHAIN_POS -1 //#define E1_INTERPOLATE true @@ -2515,7 +2515,7 @@ #if AXIS_IS_TMC(E2) #define E2_CURRENT 800 - #define E2_MICROSTEPS E0_MICROSTEPS + #define E2_MICROSTEPS E0_MICROSTEPS #define E2_RSENSE 0.11 #define E2_CHAIN_POS -1 //#define E2_INTERPOLATE true @@ -2523,7 +2523,7 @@ #if AXIS_IS_TMC(E3) #define E3_CURRENT 800 - #define E3_MICROSTEPS E0_MICROSTEPS + #define E3_MICROSTEPS E0_MICROSTEPS #define E3_RSENSE 0.11 #define E3_CHAIN_POS -1 //#define E3_INTERPOLATE true @@ -2531,7 +2531,7 @@ #if AXIS_IS_TMC(E4) #define E4_CURRENT 800 - #define E4_MICROSTEPS E0_MICROSTEPS + #define E4_MICROSTEPS E0_MICROSTEPS #define E4_RSENSE 0.11 #define E4_CHAIN_POS -1 //#define E4_INTERPOLATE true @@ -2539,7 +2539,7 @@ #if AXIS_IS_TMC(E5) #define E5_CURRENT 800 - #define E5_MICROSTEPS E0_MICROSTEPS + #define E5_MICROSTEPS E0_MICROSTEPS #define E5_RSENSE 0.11 #define E5_CHAIN_POS -1 //#define E5_INTERPOLATE true @@ -2547,7 +2547,7 @@ #if AXIS_IS_TMC(E6) #define E6_CURRENT 800 - #define E6_MICROSTEPS E0_MICROSTEPS + #define E6_MICROSTEPS E0_MICROSTEPS #define E6_RSENSE 0.11 #define E6_CHAIN_POS -1 //#define E6_INTERPOLATE true @@ -2555,7 +2555,7 @@ #if AXIS_IS_TMC(E7) #define E7_CURRENT 800 - #define E7_MICROSTEPS E0_MICROSTEPS + #define E7_MICROSTEPS E0_MICROSTEPS #define E7_RSENSE 0.11 #define E7_CHAIN_POS -1 //#define E7_INTERPOLATE true From 0f2309054520f4186502a6ebd84042713359ac8a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Mar 2021 22:38:33 -0500 Subject: [PATCH 137/311] Serial flags followup Followup to #21318 --- Marlin/src/core/serial_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/core/serial_base.h b/Marlin/src/core/serial_base.h index cdea70e2c5..8b23816b17 100644 --- a/Marlin/src/core/serial_base.h +++ b/Marlin/src/core/serial_base.h @@ -124,7 +124,7 @@ struct SerialBase { SerialFeature features(serial_index_t index=0) const { return static_cast(this)->features(index); } // Check if the serial port has a feature - bool has_feature(serial_index_t index, SerialFeature flag) const { (features(index) & flag) != SerialFeature::None; } + bool has_feature(serial_index_t index, SerialFeature flag) const { return (features(index) & flag) != SerialFeature::None; } // Check if the serial port is connected (usually bypassed) bool connected() const { return SerialChild->connected(); } From 6175802693390509e812c31ba134949a4b6eaf6a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 31 Mar 2021 00:29:24 +0000 Subject: [PATCH 138/311] [cron] Bump distribution date (2021-03-31) --- 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 2e71c2231b..2930228b14 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-03-30" + #define STRING_DISTRIBUTION_DATE "2021-03-31" #endif /** From df297b6ca3bac1b65a36cf6af685cd7b11c34639 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Wed, 31 Mar 2021 03:11:33 +0200 Subject: [PATCH 139/311] Fix FYSETC_S6 heaters pins (#21483) When adding support FYSETC Spider board the S6 pins file was broken. --- Marlin/src/pins/stm32f4/pins_FYSETC_S6.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index e6420dc238..7aeab0196a 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -171,13 +171,13 @@ #ifndef HEATER_0_PIN #define HEATER_0_PIN PB3 #endif -#ifndef HEATER_0_PIN +#ifndef HEATER_1_PIN #define HEATER_1_PIN PB4 #endif -#ifndef HEATER_0_PIN +#ifndef HEATER_2_PIN #define HEATER_2_PIN PB15 #endif -#ifndef HEATER_0_PIN +#ifndef HEATER_BED_PIN #define HEATER_BED_PIN PC8 #endif From 20d2061f22790bb30cf3b934bef2be54d931293e Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Wed, 31 Mar 2021 04:20:33 +0200 Subject: [PATCH 140/311] Optimized string-to-number functions (#21484) --- Marlin/src/gcode/parser.cpp | 140 ++++++++++++++++++ Marlin/src/gcode/parser.h | 29 +--- Marlin/src/gcode/queue.cpp | 8 +- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 2 +- 4 files changed, 153 insertions(+), 26 deletions(-) diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index ebe9d3b2cd..6eb56126e1 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -28,6 +28,146 @@ #include "../MarlinCore.h" +#ifdef __AVR__ + + static FORCE_INLINE uint32_t mult10(uint32_t val) { + uint32_t tmp = val; + __asm__ __volatile__ ( + "add %A[tmp], %A[tmp]\n" + "adc %B[tmp], %B[tmp]\n" + "adc %C[tmp], %C[tmp]\n" + "adc %D[tmp], %D[tmp]\n" + "add %A[tmp], %A[tmp]\n" + "adc %B[tmp], %B[tmp]\n" + "adc %C[tmp], %C[tmp]\n" + "adc %D[tmp], %D[tmp]\n" + "add %A[val], %A[tmp]\n" + "adc %B[val], %B[tmp]\n" + "adc %C[val], %C[tmp]\n" + "adc %D[val], %D[tmp]\n" + "add %A[val], %A[val]\n" + "adc %B[val], %B[val]\n" + "adc %C[val], %C[val]\n" + "adc %D[val], %D[val]\n" + : [val] "+&r" (val), + [tmp] "+&r" (tmp) + ); + return val; + } + +#else + + static FORCE_INLINE uint32_t mult10(uint32_t val) { return val * 10; } + +#endif + +// cheap base-10 strto(u)l. +// does not check for errors. +int32_t parse_int32(const char *buf) { + char c; + + // Get a char, skipping leading spaces + do { c = *buf++; } while (c == ' '); + + // check for sign + bool is_negative = (c == '-'); + if (is_negative || c == '+') + c = *buf++; + + // optimization for first digit (no multiplication) + uint8_t uc = c - '0'; + if (uc > 9) return 0; + + // read unsigned value + uint32_t uval = uc; + while (true) { + c = *buf++; + uc = c - '0'; + if (uc > 9) break; + uval = mult10(uval) + uc; + } + + return is_negative ? -uval : uval; +} + +// cheap strtof. +// does not support nan/infinity or exponent notation. +// does not check for errors. +float parse_float(const char *buf) { + char c; + + // Get a char, skipping leading spaces + do { c = *buf++; } while (c == ' '); + + // check for sign + bool is_negative = (c == '-'); + if (is_negative || c == '+') + c = *buf++; + + // read unsigned value and decimal point + uint32_t uval; + uint8_t exp_dec; + uint8_t uc = c - '0'; + if (uc <= 9) { + uval = uc; + exp_dec = 0; + } + else { + if (c != '.') return 0; + uval = 0; + exp_dec = 1; + } + + int8_t exp = 0; + while (true) { + c = *buf++; + uc = c - '0'; + if (uc <= 9) { + exp -= exp_dec; + uval = mult10(uval) + uc; + if (uval >= (UINT32_MAX - 9) / 10) { + // overflow. keep reading digits until decimal point. + while (exp_dec == 0) { + c = *buf++; + uc = c - '0'; + if (uc > 9) break; + exp++; + } + goto overflow; + } + } + else { + if (c != '.' || exp_dec != 0) break; + exp_dec = 1; + } + } + + // early return for 0 + if (uval == 0) return 0; + + overflow: + + // convert to float and apply sign + float fval = uval; + if (is_negative) fval *= -1; + + // apply exponent (up to 1e-15 / 1e+15) + if (exp < 0) { + if (exp <= -8) { fval *= 1e-8; exp += 8; } + if (exp <= -4) { fval *= 1e-4; exp += 4; } + if (exp <= -2) { fval *= 1e-2; exp += 2; } + if (exp <= -1) { fval *= 1e-1; exp += 1; } + } + else if (exp > 0) { + if (exp >= 8) { fval *= 1e+8; exp -= 8; } + if (exp >= 4) { fval *= 1e+4; exp -= 4; } + if (exp >= 2) { fval *= 1e+2; exp -= 2; } + if (exp >= 1) { fval *= 1e+1; exp -= 1; } + } + + return fval; +} + // Must be declared for allocation and to satisfy the linker // Zero values need no initialization. diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index b21c930cfa..ed503f8a90 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -42,6 +42,10 @@ typedef enum : uint8_t { LINEARUNIT_MM, LINEARUNIT_INCH } LinearUnit; #endif + +int32_t parse_int32(const char *buf); +float parse_float(const char *buf); + /** * GCode parser * @@ -256,29 +260,12 @@ public: // The value as a string static inline char* value_string() { return value_ptr; } - // Float removes 'E' to prevent scientific notation interpretation - static inline float value_float() { - if (value_ptr) { - char *e = value_ptr; - for (;;) { - const char c = *e; - if (c == '\0' || c == ' ') break; - if (c == 'E' || c == 'e') { - *e = '\0'; - const float ret = strtof(value_ptr, nullptr); - *e = c; - return ret; - } - ++e; - } - return strtof(value_ptr, nullptr); - } - return 0; - } + // Code value as float + static inline float value_float() { return value_ptr ? parse_float(value_ptr) : 0.0; } // Code value as a long or ulong - static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; } - static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; } + static inline int32_t value_long() { return value_ptr ? parse_int32(value_ptr) : 0L; } + static inline uint32_t value_ulong() { return value_ptr ? parse_int32(value_ptr) : 0UL; } // Code value for use as time static inline millis_t value_millis() { return value_ulong(); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index a79909917e..eb7ad79102 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -445,7 +445,7 @@ void GCodeQueue::get_serial_commands() { if (process_line_done(serial.input_state, serial.line_buffer, serial.count)) continue; - char* command = serial.line_buffer; + char *command = serial.line_buffer; while (*command == ' ') command++; // Skip leading spaces char *npos = (*command == 'N') ? command : nullptr; // Require the N parameter to start the line @@ -459,7 +459,7 @@ void GCodeQueue::get_serial_commands() { if (n2pos) npos = n2pos; } - const long gcode_N = strtol(npos + 1, nullptr, 10); + const long gcode_N = parse_int32(npos + 1); if (gcode_N != serial.last_N + 1 && !M110) { // In case of error on a serial port, don't prevent other serial port from making progress @@ -471,7 +471,7 @@ void GCodeQueue::get_serial_commands() { if (apos) { uint8_t checksum = 0, count = uint8_t(apos - command); while (count) checksum ^= command[--count]; - if (strtol(apos + 1, nullptr, 10) != checksum) { + if (parse_int32(apos + 1) != checksum) { // In case of error on a serial port, don't prevent other serial port from making progress gcode_line_error(PSTR(STR_ERR_CHECKSUM_MISMATCH), p); break; @@ -500,7 +500,7 @@ void GCodeQueue::get_serial_commands() { if (IsStopped()) { char* gpos = strchr(command, 'G'); if (gpos) { - switch (strtol(gpos + 1, nullptr, 10)) { + switch (parse_int32(gpos + 1)) { case 0: case 1: #if ENABLED(ARC_SUPPORT) case 2: case 3: 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 a74ecd2f1e..ac07dc0102 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -1799,7 +1799,7 @@ void get_wifi_commands() { if (IsStopped()) { char* gpos = strchr(command, 'G'); if (gpos) { - switch (strtol(gpos + 1, nullptr, 10)) { + switch (parse_int32(gpos + 1)) { case 0 ... 1: #if ENABLED(ARC_SUPPORT) case 2 ... 3: From 7573524a1437faa7cecdd9e5611f61db667923ef Mon Sep 17 00:00:00 2001 From: Marcio T Date: Tue, 30 Mar 2021 20:23:43 -0600 Subject: [PATCH 141/311] FTDI Touch UI fix and reorganize (#21487) --- .../{extras => extended}/adjuster_widget.cpp | 49 ++++---- .../{extras => extended}/adjuster_widget.h | 31 ++--- .../extended/circular_progress.cpp | 108 ++++++++++++++++++ .../ftdi_eve_lib/extended/circular_progress.h | 27 +++++ .../ftdi_eve_lib/extended/ftdi_extended.h | 3 + .../{extras => extended}/poly_ui.h | 0 .../ftdi_eve_lib/extras/circular_progress.h | 105 ----------------- .../{extras => scripts}/bitmap2cpp.py | 0 .../{extras => scripts}/svg2cpp.py | 0 .../screens/bed_mesh_screen.cpp | 2 - .../screens/bio_printing_dialog_box.cpp | 2 - .../screens/bio_status_screen.cpp | 2 - .../ftdi_eve_touch_ui/screens/boot_screen.cpp | 1 - .../screens/cocoa_press_load_chocolate.cpp | 2 - .../screens/cocoa_press_preheat_screen.cpp | 2 - .../screens/cocoa_press_status_screen.cpp | 2 - .../lib/ftdi_eve_touch_ui/screens/screens.h | 4 + 17 files changed, 184 insertions(+), 156 deletions(-) rename Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/{extras => extended}/adjuster_widget.cpp (59%) rename Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/{extras => extended}/adjuster_widget.h (74%) create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.cpp create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.h rename Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/{extras => extended}/poly_ui.h (100%) delete mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/circular_progress.h rename Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/{extras => scripts}/bitmap2cpp.py (100%) rename Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/{extras => scripts}/svg2cpp.py (100%) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp similarity index 59% rename from Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp rename to Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp index ef3cb565d2..26be9f4e59 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp @@ -19,10 +19,9 @@ * location: . * ****************************************************************************/ -#include "../ftdi_eve_lib.h" -#include "../extended/grid_layout.h" +#include "ftdi_extended.h" -#include "adjuster_widget.h" +#if ENABLED(FTDI_EXTENDED) #define SUB_COLS 9 #define SUB_ROWS 1 @@ -30,28 +29,32 @@ #define INC_POS SUB_POS(6,1), SUB_SIZE(2,1) #define DEC_POS SUB_POS(8,1), SUB_SIZE(2,1) -void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) { - char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)]; - if (isnan(value)) - strcpy_P(str, PSTR("-")); - else - dtostrf(value, width, precision, str); +namespace FTDI { + void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) { + char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)]; + if (isnan(value)) + strcpy_P(str, PSTR("-")); + else + dtostrf(value, width, precision, str); - if (units) { - strcat_P(str, PSTR(" ")); - strcat_P(str, (const char*) units); + if (units) { + strcat_P(str, PSTR(" ")); + strcat_P(str, (const char*) units); + } + + cmd.text(VAL_POS, str); } - cmd.text(VAL_POS, str); -} + void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) { + if (what & BACKGROUND) + cmd.tag(0).button(VAL_POS, F(""), FTDI::OPT_FLAT); -void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) { - if (what & BACKGROUND) - cmd.tag(0).button(VAL_POS, F(""), FTDI::OPT_FLAT); - - if (what & FOREGROUND) { - draw_adjuster_value(cmd, x, y, w, h, value, units, width, precision); - cmd.tag(tag ).button(INC_POS, F("-")) - .tag(tag+1).button(DEC_POS, F("+")); + if (what & FOREGROUND) { + draw_adjuster_value(cmd, x, y, w, h, value, units, width, precision); + cmd.tag(tag ).button(INC_POS, F("-")) + .tag(tag+1).button(DEC_POS, F("+")); + } } -} +} // namespace FTDI + +#endif // FTDI_EXTENDED diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.h similarity index 74% rename from Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h rename to Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.h index 9b5cab0dfb..71f7398694 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.h @@ -20,20 +20,21 @@ ****************************************************************************/ #pragma once -#include "../extended/screen_types.h" -void draw_adjuster_value( - CommandProcessor& cmd, - int16_t x, int16_t y, int16_t w, int16_t h, - float value, progmem_str units = nullptr, - int8_t width = 5, uint8_t precision = 1 -); +namespace FTDI { + void draw_adjuster_value( + CommandProcessor& cmd, + int16_t x, int16_t y, int16_t w, int16_t h, + float value, progmem_str units = nullptr, + int8_t width = 5, uint8_t precision = 1 + ); -void draw_adjuster( - CommandProcessor& cmd, - int16_t x, int16_t y, int16_t w, int16_t h, - uint8_t tag, - float value, progmem_str units = nullptr, - int8_t width = 5, uint8_t precision = 1, - draw_mode_t what = BOTH -); + void draw_adjuster( + CommandProcessor& cmd, + int16_t x, int16_t y, int16_t w, int16_t h, + uint8_t tag, + float value, progmem_str units = nullptr, + int8_t width = 5, uint8_t precision = 1, + draw_mode_t what = BOTH + ); +} diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.cpp new file mode 100644 index 0000000000..32cc37d2e2 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.cpp @@ -0,0 +1,108 @@ +/************************* + * circular_progress.cpp * + *************************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2019 - 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: . * + ****************************************************************************/ + +#include "ftdi_extended.h" + +#if ENABLED(FTDI_EXTENDED) + +/* This function draws a circular progress "ring" */ +namespace FTDI { + void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, char *text, uint32_t bgcolor, uint32_t fgcolor) { + const float rim = 0.3; + const float a = percent/100.0*2.0*PI; + const float a1 = min(PI/2, a); + const float a2 = min(PI/2, a-a1); + const float a3 = min(PI/2, a-a1-a2); + const float a4 = min(PI/2, a-a1-a2-a3); + + const int ro = min(w,h) * 8; + const int rr = ro * rim; + const int cx = x * 16 + w * 8; + const int cy = y * 16 + h * 8; + + // Load a rim shape into stencil buffer + cmd.cmd(SAVE_CONTEXT()); + cmd.cmd(TAG_MASK(0)); + cmd.cmd(CLEAR(0,1,0)); + cmd.cmd(COLOR_MASK(0,0,0,0)); + cmd.cmd(STENCIL_OP(STENCIL_OP_KEEP, STENCIL_OP_INVERT)); + cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_ALWAYS, 255, 255)); + cmd.cmd(BEGIN(POINTS)); + cmd.cmd(POINT_SIZE(ro)); + cmd.cmd(VERTEX2F(cx, cy)); + cmd.cmd(POINT_SIZE(ro - rr)); + cmd.cmd(VERTEX2F(cx, cy)); + cmd.cmd(RESTORE_CONTEXT()); + + // Mask further drawing by stencil buffer + cmd.cmd(SAVE_CONTEXT()); + cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_NOTEQUAL, 0, 255)); + + // Fill the background + cmd.cmd(COLOR_RGB(bgcolor)); + cmd.cmd(BEGIN(POINTS)); + cmd.cmd(POINT_SIZE(ro)); + cmd.cmd(VERTEX2F(cx, cy)); + cmd.cmd(COLOR_RGB(fgcolor)); + + // Paint upper-right quadrant + cmd.cmd(BEGIN(EDGE_STRIP_A)); + cmd.cmd(VERTEX2F(cx, cy)); + cmd.cmd(VERTEX2F(cx + ro*sin(a1) + 16,cy - ro*cos(a1) + 8)); + + // Paint lower-right quadrant + if (a > PI/2) { + cmd.cmd(BEGIN(EDGE_STRIP_R)); + cmd.cmd(VERTEX2F(cx, cy)); + cmd.cmd(VERTEX2F(cx + ro*cos(a2),cy + ro*sin(a2) + 16)); + } + + // Paint lower-left quadrant + if (a > PI) { + cmd.cmd(BEGIN(EDGE_STRIP_B)); + cmd.cmd(VERTEX2F(cx, cy)); + cmd.cmd(VERTEX2F(cx - ro*sin(a3) - 8,cy + ro*cos(a3))); + } + + // Paint upper-left quadrant + if (a > 1.5*PI) { + cmd.cmd(BEGIN(EDGE_STRIP_L)); + cmd.cmd(VERTEX2F(cx, cy)); + cmd.cmd(VERTEX2F(cx - ro*cos(a4),cy - ro*sin(a4))); + } + cmd.cmd(RESTORE_CONTEXT()); + + // Draw the text + + cmd.cmd(SAVE_CONTEXT()); + cmd.cmd(COLOR_RGB(fgcolor)); + cmd.text(x,y,w,h,text, OPT_CENTERX | OPT_CENTERY); + cmd.cmd(RESTORE_CONTEXT()); + } + + void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, uint32_t bgcolor, uint32_t fgcolor) { + char str[5]; + sprintf(str,"%d\%%",int(percent)); + draw_circular_progress(cmd, x, y, w, h, percent, str, bgcolor, fgcolor); + } +} // namespace FTDI + +#endif // FTDI_EXTENDED diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.h new file mode 100644 index 0000000000..68fc06b4d9 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.h @@ -0,0 +1,27 @@ +/*********************** + * circular_progress.h * + ***********************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2019 - 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 + +namespace FTDI { + void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, char *text, uint32_t bgcolor, uint32_t fgcolor); + void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, uint32_t bgcolor, uint32_t fgcolor); +} diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h index fd84c795f1..bf9858f6eb 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h @@ -47,6 +47,9 @@ #include "sound_player.h" #include "sound_list.h" #include "polygon.h" + #include "poly_ui.h" #include "text_box.h" #include "text_ellipsis.h" + #include "adjuster_widget.h" + #include "circular_progress.h" #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/poly_ui.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h similarity index 100% rename from Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/poly_ui.h rename to Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/circular_progress.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/circular_progress.h deleted file mode 100644 index 6695134046..0000000000 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/circular_progress.h +++ /dev/null @@ -1,105 +0,0 @@ -/*********************** - * circular_progress.h * - ***********************/ - -/**************************************************************************** - * Written By Marcio Teixeira 2019 - 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 - -/* This function draws a circular progress "ring" */ - -void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, char *text, uint32_t bgcolor, uint32_t fgcolor) { - using namespace FTDI; - - const float rim = 0.3; - const float a = percent/100.0*2.0*PI; - const float a1 = min(PI/2, a); - const float a2 = min(PI/2, a-a1); - const float a3 = min(PI/2, a-a1-a2); - const float a4 = min(PI/2, a-a1-a2-a3); - - const int ro = min(w,h) * 8; - const int rr = ro * rim; - const int cx = x * 16 + w * 8; - const int cy = y * 16 + h * 8; - - // Load a rim shape into stencil buffer - cmd.cmd(SAVE_CONTEXT()); - cmd.cmd(TAG_MASK(0)); - cmd.cmd(CLEAR(0,1,0)); - cmd.cmd(COLOR_MASK(0,0,0,0)); - cmd.cmd(STENCIL_OP(STENCIL_OP_KEEP, STENCIL_OP_INVERT)); - cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_ALWAYS, 255, 255)); - cmd.cmd(BEGIN(POINTS)); - cmd.cmd(POINT_SIZE(ro)); - cmd.cmd(VERTEX2F(cx, cy)); - cmd.cmd(POINT_SIZE(ro - rr)); - cmd.cmd(VERTEX2F(cx, cy)); - cmd.cmd(RESTORE_CONTEXT()); - - // Mask further drawing by stencil buffer - cmd.cmd(SAVE_CONTEXT()); - cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_NOTEQUAL, 0, 255)); - - // Fill the background - cmd.cmd(COLOR_RGB(bgcolor)); - cmd.cmd(BEGIN(POINTS)); - cmd.cmd(POINT_SIZE(ro)); - cmd.cmd(VERTEX2F(cx, cy)); - cmd.cmd(COLOR_RGB(fgcolor)); - - // Paint upper-right quadrant - cmd.cmd(BEGIN(EDGE_STRIP_A)); - cmd.cmd(VERTEX2F(cx, cy)); - cmd.cmd(VERTEX2F(cx + ro*sin(a1) + 16,cy - ro*cos(a1) + 8)); - - // Paint lower-right quadrant - if (a > PI/2) { - cmd.cmd(BEGIN(EDGE_STRIP_R)); - cmd.cmd(VERTEX2F(cx, cy)); - cmd.cmd(VERTEX2F(cx + ro*cos(a2),cy + ro*sin(a2) + 16)); - } - - // Paint lower-left quadrant - if (a > PI) { - cmd.cmd(BEGIN(EDGE_STRIP_B)); - cmd.cmd(VERTEX2F(cx, cy)); - cmd.cmd(VERTEX2F(cx - ro*sin(a3) - 8,cy + ro*cos(a3))); - } - - // Paint upper-left quadrant - if (a > 1.5*PI) { - cmd.cmd(BEGIN(EDGE_STRIP_L)); - cmd.cmd(VERTEX2F(cx, cy)); - cmd.cmd(VERTEX2F(cx - ro*cos(a4),cy - ro*sin(a4))); - } - cmd.cmd(RESTORE_CONTEXT()); - - // Draw the text - - cmd.cmd(SAVE_CONTEXT()); - cmd.cmd(COLOR_RGB(fgcolor)); - cmd.text(x,y,w,h,text, OPT_CENTERX | OPT_CENTERY); - cmd.cmd(RESTORE_CONTEXT()); -} - -void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, uint32_t bgcolor, uint32_t fgcolor) { - char str[5]; - sprintf(str,"%d\%%",int(percent)); - draw_circular_progress(cmd, x, y, w, h, percent, str, bgcolor, fgcolor); -} diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/bitmap2cpp.py b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/bitmap2cpp.py similarity index 100% rename from Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/bitmap2cpp.py rename to Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/bitmap2cpp.py diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/svg2cpp.py b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py similarity index 100% rename from Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/svg2cpp.py rename to Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py 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 053f4ebd72..f8b4b5b5d1 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 @@ -25,8 +25,6 @@ #ifdef FTDI_BED_MESH_SCREEN -#include "../ftdi_eve_lib/extras/adjuster_widget.h" - using namespace FTDI; using namespace Theme; using namespace ExtUI; 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 a812f0f3d0..10ed6eb14a 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 @@ -25,8 +25,6 @@ #ifdef FTDI_BIO_PRINTING_DIALOG_BOX -#include "../ftdi_eve_lib/extras/circular_progress.h" - using namespace FTDI; using namespace ExtUI; using namespace Theme; 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 f2bb5f3d3c..c66e4d94d8 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 @@ -26,8 +26,6 @@ #ifdef FTDI_BIO_STATUS_SCREEN -#include "../ftdi_eve_lib/extras/poly_ui.h" - #if ENABLED(TOUCH_UI_PORTRAIT) #include "bio_printer_ui_portrait.h" #else 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 236830dbc4..c8c7cdb5a5 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 @@ -26,7 +26,6 @@ #ifdef FTDI_BOOT_SCREEN -#include "../ftdi_eve_lib/extras/poly_ui.h" #include "../archim2-flash/flash_storage.h" #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) 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 d9c01366b9..ac49df0916 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 @@ -27,8 +27,6 @@ #ifdef FTDI_COCOA_LOAD_CHOCOLATE_SCREEN -#include "../ftdi_eve_lib/extras/poly_ui.h" - #include "cocoa_press_ui.h" #define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0])) 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 66256ab46f..a8a172b3da 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 @@ -25,8 +25,6 @@ #ifdef FTDI_COCOA_PREHEAT_SCREEN -#include "../ftdi_eve_lib/extras/circular_progress.h" - using namespace FTDI; using namespace ExtUI; using namespace Theme; 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 5a0fe485f8..a0c8914589 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 @@ -26,8 +26,6 @@ #ifdef FTDI_COCOA_STATUS_SCREEN -#include "../ftdi_eve_lib/extras/poly_ui.h" - #include "cocoa_press_ui.h" #define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0])) 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 3e69a3ad2f..7aca5800e1 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" @@ -260,3 +262,5 @@ enum { #if NUM_LANGUAGES > 1 #include "language_menu.h" #endif + +#endif // TOUCH_UI_FTDI_EVE From 8d083eb2488c6e4bd19bec8090b1673d60d2da2a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 30 Mar 2021 21:54:34 -0500 Subject: [PATCH 142/311] Put ABL state into a class --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 424 +++++++++++++------------- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/SanityCheck.h | 2 +- buildroot/tests/rambo | 2 +- 4 files changed, 216 insertions(+), 214 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a746b86108..f3cfe02e40 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -68,22 +68,77 @@ #include "../../../module/tool_change.h" #endif -#if ABL_GRID +#if ABL_USES_GRID #if ENABLED(PROBE_Y_FIRST) - #define PR_OUTER_VAR meshCount.x - #define PR_OUTER_END abl_grid_points.x - #define PR_INNER_VAR meshCount.y - #define PR_INNER_END abl_grid_points.y + #define PR_OUTER_VAR abl.meshCount.x + #define PR_OUTER_SIZE abl.grid_points.x + #define PR_INNER_VAR abl.meshCount.y + #define PR_INNER_SIZE abl.grid_points.y #else - #define PR_OUTER_VAR meshCount.y - #define PR_OUTER_END abl_grid_points.y - #define PR_INNER_VAR meshCount.x - #define PR_INNER_END abl_grid_points.x + #define PR_OUTER_VAR abl.meshCount.y + #define PR_OUTER_SIZE abl.grid_points.y + #define PR_INNER_VAR abl.meshCount.x + #define PR_INNER_SIZE abl.grid_points.x #endif #endif #define G29_RETURN(b) return TERN_(G29_RETRY_AND_RECOVER, b) +// For manual probing values persist over multiple G29 +class G29_State { +public: + int verbose_level; + xy_pos_t probePos; + float measured_z; + bool dryrun, + reenable; + + #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) + int abl_probe_index; + #endif + + #if ABL_USES_GRID + + xy_int8_t meshCount; + + xy_pos_t probe_position_lf, + probe_position_rb; + + xy_float_t gridSpacing; // = { 0.0f, 0.0f } + + #if ENABLED(AUTO_BED_LEVELING_LINEAR) + bool topography_map; + xy_uint8_t grid_points; + #else // Bilinear + static constexpr xy_uint8_t grid_points = { GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y }; + #endif + + #if ENABLED(AUTO_BED_LEVELING_LINEAR) + int abl_points; + #elif ENABLED(AUTO_BED_LEVELING_3POINT) + static constexpr int abl_points = 3; + #else + static constexpr int abl_points = GRID_MAX_POINTS; + #endif + + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + float Z_offset; + #endif + + #if ENABLED(AUTO_BED_LEVELING_LINEAR) + int indexIntoAB[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; + float eqnAMatrix[(GRID_MAX_POINTS) * 3], // "A" matrix of the linear system of equations + eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points + mean; + #endif + #endif +}; + +#if ABL_USES_GRID && EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR) + constexpr xy_uint8_t G29_State::grid_points; + constexpr int G29_State::abl_points; +#endif + /** * G29: Detailed Z probe, probes the bed at 3 or more points. * Will fail if the printer has not been homed with G28. @@ -163,6 +218,8 @@ */ G29_TYPE GcodeSuite::G29() { + TERN_(PROBE_MANUALLY, static) G29_State abl; + reset_stepper_timeout(); const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q'); @@ -193,63 +250,10 @@ G29_TYPE GcodeSuite::G29() { // Don't allow auto-leveling without homing first if (homing_needed_error()) G29_RETURN(false); - // Define local vars 'static' for manual probing, 'auto' otherwise - #define ABL_VAR TERN_(PROBE_MANUALLY, static) - - ABL_VAR int verbose_level; - ABL_VAR xy_pos_t probePos; - ABL_VAR float measured_z; - ABL_VAR bool dryrun, abl_should_enable; - - #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) - ABL_VAR int abl_probe_index; - #endif - - #if ABL_GRID - - #if ENABLED(PROBE_MANUALLY) - ABL_VAR xy_int8_t meshCount; - #endif - - ABL_VAR xy_pos_t probe_position_lf, probe_position_rb; - ABL_VAR xy_float_t gridSpacing = { 0, 0 }; - - #if ENABLED(AUTO_BED_LEVELING_LINEAR) - ABL_VAR bool do_topography_map; - ABL_VAR xy_uint8_t abl_grid_points; - #else // Bilinear - constexpr xy_uint8_t abl_grid_points = { GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y }; - #endif - - #if ENABLED(AUTO_BED_LEVELING_LINEAR) - ABL_VAR int abl_points; - #else - int constexpr abl_points = GRID_MAX_POINTS; - #endif - - #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - - ABL_VAR float zoffset; - - #elif ENABLED(AUTO_BED_LEVELING_LINEAR) - - ABL_VAR int indexIntoAB[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - - ABL_VAR float eqnAMatrix[(GRID_MAX_POINTS) * 3], // "A" matrix of the linear system of equations - eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points - mean; - #endif - - #elif ENABLED(AUTO_BED_LEVELING_3POINT) - - #if ENABLED(PROBE_MANUALLY) - int constexpr abl_points = 3; // used to show total points - #endif - + #if ENABLED(AUTO_BED_LEVELING_3POINT) vector_3 points[3]; probe.get_three_points(points); - - #endif // AUTO_BED_LEVELING_3POINT + #endif #if ENABLED(AUTO_BED_LEVELING_LINEAR) struct linear_fit_data lsf_results; @@ -263,10 +267,10 @@ G29_TYPE GcodeSuite::G29() { TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) - abl_probe_index = -1; + abl.abl_probe_index = -1; #endif - abl_should_enable = planner.leveling_active; + abl.reenable = planner.leveling_active; #if ENABLED(AUTO_BED_LEVELING_BILINEAR) @@ -289,8 +293,8 @@ G29_TYPE GcodeSuite::G29() { if (!isnan(rx) && !isnan(ry)) { // Get nearest i / j from rx / ry - i = (rx - bilinear_start.x + 0.5 * gridSpacing.x) / gridSpacing.x; - j = (ry - bilinear_start.y + 0.5 * gridSpacing.y) / gridSpacing.y; + i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x; + j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y; LIMIT(i, 0, GRID_MAX_POINTS_X - 1); LIMIT(j, 0, GRID_MAX_POINTS_Y - 1); } @@ -299,8 +303,8 @@ G29_TYPE GcodeSuite::G29() { z_values[i][j] = rz; TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, rz)); - set_bed_leveling_enabled(abl_should_enable); - if (abl_should_enable) report_current_position(); + set_bed_leveling_enabled(abl.reenable); + if (abl.reenable) report_current_position(); } G29_RETURN(false); } // parser.seen('W') @@ -317,47 +321,47 @@ G29_TYPE GcodeSuite::G29() { G29_RETURN(false); } - verbose_level = parser.intval('V'); - if (!WITHIN(verbose_level, 0, 4)) { + abl.verbose_level = parser.intval('V'); + if (!WITHIN(abl.verbose_level, 0, 4)) { SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4)."); G29_RETURN(false); } - dryrun = parser.boolval('D') || TERN0(PROBE_MANUALLY, no_action); + abl.dryrun = parser.boolval('D') || TERN0(PROBE_MANUALLY, no_action); #if ENABLED(AUTO_BED_LEVELING_LINEAR) incremental_LSF_reset(&lsf_results); - do_topography_map = verbose_level > 2 || parser.boolval('T'); + abl.topography_map = abl.verbose_level > 2 || parser.boolval('T'); // X and Y specify points in each direction, overriding the default // These values may be saved with the completed mesh - abl_grid_points.set( + abl.grid_points.set( parser.byteval('X', GRID_MAX_POINTS_X), parser.byteval('Y', GRID_MAX_POINTS_Y) ); - if (parser.seenval('P')) abl_grid_points.x = abl_grid_points.y = parser.value_int(); + if (parser.seenval('P')) abl.grid_points.x = abl.grid_points.y = parser.value_int(); - if (!WITHIN(abl_grid_points.x, 2, GRID_MAX_POINTS_X)) { + if (!WITHIN(abl.grid_points.x, 2, GRID_MAX_POINTS_X)) { SERIAL_ECHOLNPGM("?Probe points (X) implausible (2-" STRINGIFY(GRID_MAX_POINTS_X) ")."); G29_RETURN(false); } - if (!WITHIN(abl_grid_points.y, 2, GRID_MAX_POINTS_Y)) { + if (!WITHIN(abl.grid_points.y, 2, GRID_MAX_POINTS_Y)) { SERIAL_ECHOLNPGM("?Probe points (Y) implausible (2-" STRINGIFY(GRID_MAX_POINTS_Y) ")."); G29_RETURN(false); } - abl_points = abl_grid_points.x * abl_grid_points.y; - mean = 0; + abl.abl_points = abl.grid_points.x * abl.grid_points.y; + abl.mean = 0; #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - zoffset = parser.linearval('Z'); + abl.Z_offset = parser.linearval('Z'); #endif - #if ABL_GRID + #if ABL_USES_GRID xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_FEEDRATE)); @@ -366,32 +370,32 @@ G29_TYPE GcodeSuite::G29() { if (parser.seen('H')) { const int16_t size = (int16_t)parser.value_linear_units(); - probe_position_lf.set(_MAX((X_CENTER) - size / 2, x_min), _MAX((Y_CENTER) - size / 2, y_min)); - probe_position_rb.set(_MIN(probe_position_lf.x + size, x_max), _MIN(probe_position_lf.y + size, y_max)); + abl.probe_position_lf.set(_MAX((X_CENTER) - size / 2, x_min), _MAX((Y_CENTER) - size / 2, y_min)); + abl.probe_position_rb.set(_MIN(abl.probe_position_lf.x + size, x_max), _MIN(abl.probe_position_lf.y + size, y_max)); } else { - probe_position_lf.set(parser.linearval('L', x_min), parser.linearval('F', y_min)); - probe_position_rb.set(parser.linearval('R', x_max), parser.linearval('B', y_max)); + abl.probe_position_lf.set(parser.linearval('L', x_min), parser.linearval('F', y_min)); + abl.probe_position_rb.set(parser.linearval('R', x_max), parser.linearval('B', y_max)); } - if (!probe.good_bounds(probe_position_lf, probe_position_rb)) { + if (!probe.good_bounds(abl.probe_position_lf, abl.probe_position_rb)) { if (DEBUGGING(LEVELING)) { - DEBUG_ECHOLNPAIR("G29 L", probe_position_lf.x, " R", probe_position_rb.x, - " F", probe_position_lf.y, " B", probe_position_rb.y); + DEBUG_ECHOLNPAIR("G29 L", abl.probe_position_lf.x, " R", abl.probe_position_rb.x, + " F", abl.probe_position_lf.y, " B", abl.probe_position_rb.y); } SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds."); G29_RETURN(false); } // Probe at the points of a lattice grid - gridSpacing.set((probe_position_rb.x - probe_position_lf.x) / (abl_grid_points.x - 1), - (probe_position_rb.y - probe_position_lf.y) / (abl_grid_points.y - 1)); + abl.gridSpacing.set((abl.probe_position_rb.x - abl.probe_position_lf.x) / (abl.grid_points.x - 1), + (abl.probe_position_rb.y - abl.probe_position_lf.y) / (abl.grid_points.y - 1)); - #endif // ABL_GRID + #endif // ABL_USES_GRID - if (verbose_level > 0) { + if (abl.verbose_level > 0) { SERIAL_ECHOPGM("G29 Auto Bed Leveling"); - if (dryrun) SERIAL_ECHOPGM(" (DRYRUN)"); + if (abl.dryrun) SERIAL_ECHOPGM(" (DRYRUN)"); SERIAL_EOL(); } @@ -410,7 +414,7 @@ G29_TYPE GcodeSuite::G29() { remember_feedrate_scaling_off(); #if ENABLED(PREHEAT_BEFORE_LEVELING) - if (!dryrun) probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, LEVELING_BED_TEMP); + if (!abl.dryrun) probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, LEVELING_BED_TEMP); #endif } @@ -423,24 +427,24 @@ G29_TYPE GcodeSuite::G29() { if (ENABLED(BLTOUCH)) do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); else if (probe.deploy()) { - set_bed_leveling_enabled(abl_should_enable); + set_bed_leveling_enabled(abl.reenable); G29_RETURN(false); } #endif #if ENABLED(AUTO_BED_LEVELING_BILINEAR) if (TERN1(PROBE_MANUALLY, !no_action) - && (gridSpacing != bilinear_grid_spacing || probe_position_lf != bilinear_start) + && (abl.gridSpacing != bilinear_grid_spacing || abl.probe_position_lf != bilinear_start) ) { // Reset grid to 0.0 or "not probed". (Also disables ABL) reset_bed_level(); // Initialize a grid with the given dimensions - bilinear_grid_spacing = gridSpacing; - bilinear_start = probe_position_lf; + bilinear_grid_spacing = abl.gridSpacing; + bilinear_start = abl.probe_position_lf; // Can't re-enable (on error) until the new grid is written - abl_should_enable = false; + abl.reenable = false; } #endif // AUTO_BED_LEVELING_BILINEAR @@ -451,7 +455,7 @@ G29_TYPE GcodeSuite::G29() { // For manual probing, get the next index to probe now. // On the first probe this will be incremented to 0. if (!no_action) { - ++abl_probe_index; + ++abl.abl_probe_index; g29_in_progress = true; } @@ -459,17 +463,17 @@ G29_TYPE GcodeSuite::G29() { if (seenA && g29_in_progress) { SERIAL_ECHOLNPGM("Manual G29 aborted"); SET_SOFT_ENDSTOP_LOOSE(false); - set_bed_leveling_enabled(abl_should_enable); + set_bed_leveling_enabled(abl.reenable); g29_in_progress = false; TERN_(LCD_BED_LEVELING, ui.wait_for_move = false); } // Query G29 status - if (verbose_level || seenQ) { + if (abl.verbose_level || seenQ) { SERIAL_ECHOPGM("Manual G29 "); if (g29_in_progress) { - SERIAL_ECHOPAIR("point ", _MIN(abl_probe_index + 1, abl_points)); - SERIAL_ECHOLNPAIR(" of ", abl_points); + SERIAL_ECHOPAIR("point ", _MIN(abl.abl_probe_index + 1, abl.abl_points)); + SERIAL_ECHOLNPAIR(" of ", abl.abl_points); } else SERIAL_ECHOLNPGM("idle"); @@ -477,7 +481,7 @@ G29_TYPE GcodeSuite::G29() { if (no_action) G29_RETURN(false); - if (abl_probe_index == 0) { + if (abl.abl_probe_index == 0) { // For the initial G29 S2 save software endstop state SET_SOFT_ENDSTOP_LOOSE(true); // Move close to the bed before the first point @@ -486,34 +490,34 @@ G29_TYPE GcodeSuite::G29() { else { #if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) - const uint16_t index = abl_probe_index - 1; + const uint16_t index = abl.abl_probe_index - 1; #endif // For G29 after adjusting Z. // Save the previous Z before going to the next point - measured_z = current_position.z; + abl.measured_z = current_position.z; #if ENABLED(AUTO_BED_LEVELING_LINEAR) - mean += measured_z; - eqnBVector[index] = measured_z; - eqnAMatrix[index + 0 * abl_points] = probePos.x; - eqnAMatrix[index + 1 * abl_points] = probePos.y; - eqnAMatrix[index + 2 * abl_points] = 1; + abl.mean += abl.measured_z; + abl.eqnBVector[index] = abl.measured_z; + abl.eqnAMatrix[index + 0 * abl.abl_points] = abl.probePos.x; + abl.eqnAMatrix[index + 1 * abl.abl_points] = abl.probePos.y; + abl.eqnAMatrix[index + 2 * abl.abl_points] = 1; - incremental_LSF(&lsf_results, probePos, measured_z); + incremental_LSF(&lsf_results, abl.probePos, abl.measured_z); #elif ENABLED(AUTO_BED_LEVELING_3POINT) - points[index].z = measured_z; + points[index].z = abl.measured_z; #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - const float newz = measured_z + zoffset; - z_values[meshCount.x][meshCount.y] = newz; - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, newz)); + const float newz = abl.measured_z + abl.Z_offset; + z_values[abl.meshCount.x][abl.meshCount.y] = newz; + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, newz)); - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_P(PSTR("Save X"), meshCount.x, SP_Y_STR, meshCount.y, SP_Z_STR, measured_z + zoffset); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_P(PSTR("Save X"), abl.meshCount.x, SP_Y_STR, abl.meshCount.y, SP_Z_STR, abl.measured_z + abl.Z_offset); #endif } @@ -522,31 +526,31 @@ G29_TYPE GcodeSuite::G29() { // If there's another point to sample, move there with optional lift. // - #if ABL_GRID + #if ABL_USES_GRID // Skip any unreachable points - while (abl_probe_index < abl_points) { + while (abl.abl_probe_index < abl.abl_points) { - // Set meshCount.x, meshCount.y based on abl_probe_index, with zig-zag - PR_OUTER_VAR = abl_probe_index / PR_INNER_END; - PR_INNER_VAR = abl_probe_index - (PR_OUTER_VAR * PR_INNER_END); + // Set abl.meshCount.x, abl.meshCount.y based on abl.abl_probe_index, with zig-zag + PR_OUTER_VAR = abl.abl_probe_index / PR_INNER_SIZE; + PR_INNER_VAR = abl.abl_probe_index - (PR_OUTER_VAR * PR_INNER_SIZE); // Probe in reverse order for every other row/column - const bool zig = (PR_OUTER_VAR & 1); // != ((PR_OUTER_END) & 1); - if (zig) PR_INNER_VAR = (PR_INNER_END - 1) - PR_INNER_VAR; + const bool zig = (PR_OUTER_VAR & 1); // != ((PR_OUTER_SIZE) & 1); + if (zig) PR_INNER_VAR = (PR_INNER_SIZE - 1) - PR_INNER_VAR; - probePos = probe_position_lf + gridSpacing * meshCount.asFloat(); + abl.probePos = abl.probe_position_lf + abl.gridSpacing * abl.meshCount.asFloat(); - TERN_(AUTO_BED_LEVELING_LINEAR, indexIntoAB[meshCount.x][meshCount.y] = abl_probe_index); + TERN_(AUTO_BED_LEVELING_LINEAR, abl.indexIntoAB[abl.meshCount.x][abl.meshCount.y] = abl.abl_probe_index); // Keep looping till a reachable point is found - if (position_is_reachable(probePos)) break; - ++abl_probe_index; + if (position_is_reachable(abl.probePos)) break; + ++abl.abl_probe_index; } // Is there a next point to move to? - if (abl_probe_index < abl_points) { - _manual_goto_xy(probePos); // Can be used here too! + if (abl.abl_probe_index < abl.abl_points) { + _manual_goto_xy(abl.probePos); // Can be used here too! // Disable software endstops to allow manual adjustment // If G29 is not completed, they will not be re-enabled SET_SOFT_ENDSTOP_LOOSE(true); @@ -562,9 +566,9 @@ G29_TYPE GcodeSuite::G29() { #elif ENABLED(AUTO_BED_LEVELING_3POINT) // Probe at 3 arbitrary points - if (abl_probe_index < abl_points) { - probePos = points[abl_probe_index]; - _manual_goto_xy(probePos); + if (abl.abl_probe_index < abl.abl_points) { + abl.probePos = points[abl.abl_probe_index]; + _manual_goto_xy(abl.probePos); // Disable software endstops to allow manual adjustment // If G29 is not completed, they will not be re-enabled SET_SOFT_ENDSTOP_LOOSE(true); @@ -577,13 +581,13 @@ G29_TYPE GcodeSuite::G29() { // Re-enable software endstops, if needed SET_SOFT_ENDSTOP_LOOSE(false); - if (!dryrun) { + if (!abl.dryrun) { vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal(); if (planeNormal.z < 0) planeNormal *= -1; planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal); // Can't re-enable (on error) until the new grid is written - abl_should_enable = false; + abl.reenable = false; } } @@ -594,84 +598,82 @@ G29_TYPE GcodeSuite::G29() { { const ProbePtRaise raise_after = parser.boolval('E') ? PROBE_PT_STOW : PROBE_PT_RAISE; - measured_z = 0; + abl.measured_z = 0; - #if ABL_GRID + #if ABL_USES_GRID - bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION + bool zig = PR_OUTER_SIZE & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION - measured_z = 0; - - xy_int8_t meshCount; + abl.measured_z = 0; // Outer loop is X with PROBE_Y_FIRST enabled // Outer loop is Y with PROBE_Y_FIRST disabled - for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_END && !isnan(measured_z); PR_OUTER_VAR++) { + for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !isnan(abl.measured_z); PR_OUTER_VAR++) { int8_t inStart, inStop, inInc; - if (zig) { // Zig away from origin - inStart = 0; // Left or front - inStop = PR_INNER_END; // Right or back - inInc = 1; // Zig right + if (zig) { // Zig away from origin + inStart = 0; // Left or front + inStop = PR_INNER_SIZE; // Right or back + inInc = 1; // Zig right } - else { // Zag towards origin - inStart = PR_INNER_END - 1; // Right or back - inStop = -1; // Left or front - inInc = -1; // Zag left + else { // Zag towards origin + inStart = PR_INNER_SIZE - 1; // Right or back + inStop = -1; // Left or front + inInc = -1; // Zag left } zig ^= true; // zag // An index to print current state - uint8_t pt_index = (PR_OUTER_VAR) * (PR_INNER_END) + 1; + uint8_t pt_index = (PR_OUTER_VAR) * (PR_INNER_SIZE) + 1; // Inner loop is Y with PROBE_Y_FIRST enabled // Inner loop is X with PROBE_Y_FIRST disabled for (PR_INNER_VAR = inStart; PR_INNER_VAR != inStop; pt_index++, PR_INNER_VAR += inInc) { - probePos = probe_position_lf + gridSpacing * meshCount.asFloat(); + abl.probePos = abl.probe_position_lf + abl.gridSpacing * abl.meshCount.asFloat(); - TERN_(AUTO_BED_LEVELING_LINEAR, indexIntoAB[meshCount.x][meshCount.y] = ++abl_probe_index); // 0... + TERN_(AUTO_BED_LEVELING_LINEAR, abl.indexIntoAB[abl.meshCount.x][abl.meshCount.y] = ++abl.abl_probe_index); // 0... // Avoid probing outside the round or hexagonal area - if (TERN0(IS_KINEMATIC, !probe.can_reach(probePos))) continue; + if (TERN0(IS_KINEMATIC, !probe.can_reach(abl.probePos))) continue; - if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", pt_index, "/", abl_points, "."); - TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(abl_points))); + if (abl.verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", pt_index, "/", abl.abl_points, "."); + TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(abl.abl_points))); - measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level); + abl.measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level); - if (isnan(measured_z)) { - set_bed_leveling_enabled(abl_should_enable); + if (isnan(abl.measured_z)) { + set_bed_leveling_enabled(abl.reenable); break; // Breaks out of both loops } #if ENABLED(PROBE_TEMP_COMPENSATION) - temp_comp.compensate_measurement(TSI_BED, thermalManager.degBed(), measured_z); - temp_comp.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), measured_z); - TERN_(USE_TEMP_EXT_COMPENSATION, temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(), measured_z)); + temp_comp.compensate_measurement(TSI_BED, thermalManager.degBed(), abl.measured_z); + temp_comp.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), abl.measured_z); + TERN_(USE_TEMP_EXT_COMPENSATION, temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(), abl.measured_z)); #endif #if ENABLED(AUTO_BED_LEVELING_LINEAR) - mean += measured_z; - eqnBVector[abl_probe_index] = measured_z; - eqnAMatrix[abl_probe_index + 0 * abl_points] = probePos.x; - eqnAMatrix[abl_probe_index + 1 * abl_points] = probePos.y; - eqnAMatrix[abl_probe_index + 2 * abl_points] = 1; + abl.mean += abl.measured_z; + abl.eqnBVector[abl.abl_probe_index] = abl.measured_z; + abl.eqnAMatrix[abl.abl_probe_index + 0 * abl.abl_points] = abl.probePos.x; + abl.eqnAMatrix[abl.abl_probe_index + 1 * abl.abl_points] = abl.probePos.y; + abl.eqnAMatrix[abl.abl_probe_index + 2 * abl.abl_points] = 1; - incremental_LSF(&lsf_results, probePos, measured_z); + incremental_LSF(&lsf_results, abl.probePos, abl.measured_z); #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - const float z = measured_z + zoffset; - z_values[meshCount.x][meshCount.y] = z; - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, z)); + const float z = abl.measured_z + abl.Z_offset; + z_values[abl.meshCount.x][abl.meshCount.y] = z; + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, z)); #endif - abl_should_enable = false; + abl.reenable = false; idle_no_sleep(); } // inner @@ -682,26 +684,26 @@ G29_TYPE GcodeSuite::G29() { // Probe at 3 arbitrary points LOOP_L_N(i, 3) { - if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", i + 1, "/3."); + if (abl.verbose_level) SERIAL_ECHOLNPAIR("Probing point ", i + 1, "/3."); TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i + 1))); // Retain the last probe position - probePos = points[i]; - measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level); - if (isnan(measured_z)) { - set_bed_leveling_enabled(abl_should_enable); + abl.probePos = points[i]; + abl.measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level); + if (isnan(abl.measured_z)) { + set_bed_leveling_enabled(abl.reenable); break; } - points[i].z = measured_z; + points[i].z = abl.measured_z; } - if (!dryrun && !isnan(measured_z)) { + if (!abl.dryrun && !isnan(abl.measured_z)) { vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal(); if (planeNormal.z < 0) planeNormal *= -1; planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal); // Can't re-enable (on error) until the new grid is written - abl_should_enable = false; + abl.reenable = false; } #endif // AUTO_BED_LEVELING_3POINT @@ -710,8 +712,8 @@ G29_TYPE GcodeSuite::G29() { // Stow the probe. No raise for FIX_MOUNTED_PROBE. if (probe.stow()) { - set_bed_leveling_enabled(abl_should_enable); - measured_z = NAN; + set_bed_leveling_enabled(abl.reenable); + abl.measured_z = NAN; } } #endif // !PROBE_MANUALLY @@ -734,10 +736,10 @@ G29_TYPE GcodeSuite::G29() { #endif // Calculate leveling, print reports, correct the position - if (!isnan(measured_z)) { + if (!isnan(abl.measured_z)) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (!dryrun) extrapolate_unprobed_bed_level(); + if (!abl.dryrun) extrapolate_unprobed_bed_level(); print_bilinear_leveling_grid(); refresh_bed_level(); @@ -763,39 +765,39 @@ G29_TYPE GcodeSuite::G29() { plane_equation_coefficients.b = -lsf_results.B; // but that is not yet tested. plane_equation_coefficients.d = -lsf_results.D; - mean /= abl_points; + abl.mean /= abl.abl_points; - if (verbose_level) { + if (abl.verbose_level) { SERIAL_ECHOPAIR_F("Eqn coefficients: a: ", plane_equation_coefficients.a, 8); SERIAL_ECHOPAIR_F(" b: ", plane_equation_coefficients.b, 8); SERIAL_ECHOPAIR_F(" d: ", plane_equation_coefficients.d, 8); - if (verbose_level > 2) - SERIAL_ECHOPAIR_F("\nMean of sampled points: ", mean, 8); + if (abl.verbose_level > 2) + SERIAL_ECHOPAIR_F("\nMean of sampled points: ", abl.mean, 8); SERIAL_EOL(); } // Create the matrix but don't correct the position yet - if (!dryrun) + if (!abl.dryrun) planner.bed_level_matrix = matrix_3x3::create_look_at( vector_3(-plane_equation_coefficients.a, -plane_equation_coefficients.b, 1) // We can eliminate the '-' here and up above ); // Show the Topography map if enabled - if (do_topography_map) { + if (abl.topography_map) { float min_diff = 999; auto print_topo_map = [&](PGM_P const title, const bool get_min) { SERIAL_ECHOPGM_P(title); - for (int8_t yy = abl_grid_points.y - 1; yy >= 0; yy--) { - LOOP_L_N(xx, abl_grid_points.x) { - const int ind = indexIntoAB[xx][yy]; - xyz_float_t tmp = { eqnAMatrix[ind + 0 * abl_points], - eqnAMatrix[ind + 1 * abl_points], 0 }; + for (int8_t yy = abl.grid_points.y - 1; yy >= 0; yy--) { + LOOP_L_N(xx, abl.grid_points.x) { + const int ind = abl.indexIntoAB[xx][yy]; + xyz_float_t tmp = { abl.eqnAMatrix[ind + 0 * abl.abl_points], + abl.eqnAMatrix[ind + 1 * abl.abl_points], 0 }; apply_rotation_xyz(planner.bed_level_matrix, tmp); - if (get_min) NOMORE(min_diff, eqnBVector[ind] - tmp.z); - const float subval = get_min ? mean : tmp.z + min_diff, - diff = eqnBVector[ind] - subval; + if (get_min) NOMORE(min_diff, abl.eqnBVector[ind] - tmp.z); + const float subval = get_min ? abl.mean : tmp.z + min_diff, + diff = abl.eqnBVector[ind] - subval; SERIAL_CHAR(' '); if (diff >= 0.0) SERIAL_CHAR('+'); // Include + for column alignment SERIAL_ECHO_F(diff, 5); } // xx @@ -815,10 +817,10 @@ G29_TYPE GcodeSuite::G29() { " | |\n" " O-- FRONT --+\n" " (0,0)\n"), true); - if (verbose_level > 3) + if (abl.verbose_level > 3) print_topo_map(PSTR("\nCorrected Bed Height vs. Bed Topology:\n"), false); - } //do_topography_map + } // abl.topography_map #endif // AUTO_BED_LEVELING_LINEAR @@ -826,10 +828,10 @@ G29_TYPE GcodeSuite::G29() { // For LINEAR and 3POINT leveling correct the current position - if (verbose_level > 0) + if (abl.verbose_level > 0) planner.bed_level_matrix.debug(PSTR("\n\nBed Level Correction Matrix:")); - if (!dryrun) { + if (!abl.dryrun) { // // Correct the current XYZ position based on the tilted plane. // @@ -840,10 +842,10 @@ G29_TYPE GcodeSuite::G29() { planner.force_unapply_leveling(converted); // use conversion machinery // Use the last measured distance to the bed, if possible - if ( NEAR(current_position.x, probePos.x - probe.offset_xy.x) - && NEAR(current_position.y, probePos.y - probe.offset_xy.y) + if ( NEAR(current_position.x, abl.probePos.x - probe.offset_xy.x) + && NEAR(current_position.y, abl.probePos.y - probe.offset_xy.y) ) { - const float simple_z = current_position.z - measured_z; + const float simple_z = current_position.z - abl.measured_z; if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, " Matrix Z", converted.z, " Discrepancy ", simple_z - converted.z); converted.z = simple_z; } @@ -856,7 +858,7 @@ G29_TYPE GcodeSuite::G29() { #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (!dryrun) { + if (!abl.dryrun) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("G29 uncorrected Z:", current_position.z); // Unapply the offset because it is going to be immediately applied @@ -870,8 +872,8 @@ G29_TYPE GcodeSuite::G29() { #endif // ABL_PLANAR // Auto Bed Leveling is complete! Enable if possible. - planner.leveling_active = dryrun ? abl_should_enable : true; - } // !isnan(measured_z) + planner.leveling_active = !abl.dryrun || abl.reenable; + } // !isnan(abl.measured_z) // Restore state after probing if (!faux) restore_feedrate_and_scaling(); @@ -895,7 +897,7 @@ G29_TYPE GcodeSuite::G29() { report_current_position(); - G29_RETURN(isnan(measured_z)); + G29_RETURN(isnan(abl.measured_z)); } #endif // HAS_ABL_NOT_UBL diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index a0fced150f..88bd382020 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -842,7 +842,7 @@ #define ABL_PLANAR 1 #endif #if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR) - #define ABL_GRID 1 + #define ABL_USES_GRID 1 #endif #if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT) #define HAS_ABL_NOT_UBL 1 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 287f0c5600..647e0d55dd 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1262,7 +1262,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "DELTA_AUTO_CALIBRATION requires a probe or LCD Controller." #elif ENABLED(DELTA_CALIBRATION_MENU) && !HAS_LCD_MENU #error "DELTA_CALIBRATION_MENU requires an LCD Controller." - #elif ABL_GRID + #elif ABL_USES_GRID #if (GRID_MAX_POINTS_X & 1) == 0 || (GRID_MAX_POINTS_Y & 1) == 0 #error "DELTA requires GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y to be odd numbers." #elif GRID_MAX_POINTS_X < 3 diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index 5da4eed9b4..95260e58b4 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -88,7 +88,7 @@ opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CO PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 M114_DETAIL opt_add M100_FREE_MEMORY_DUMPER opt_add M100_FREE_MEMORY_CORRUPTOR -exec_test $1 $2 "MINIRAMBO | RRDGFSC | M100 | PWM_MOTOR_CURRENT | PRINTCOUNTER | Advanced Pause ..." "$3" +exec_test $1 $2 "MINIRAMBO | RRDGFSC | ABL Bilinear Manual | M100 | PWM_MOTOR_CURRENT | M600..." "$3" # # Test many less common options From be775ed72db983ea150669ad6e0e094285b2fec2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 30 Mar 2021 23:16:29 -0500 Subject: [PATCH 143/311] Move apply_rotation_xyz into matrix_3x3 --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- Marlin/src/libs/vector_3.cpp | 4 ++-- Marlin/src/libs/vector_3.h | 10 ++++------ Marlin/src/module/planner.cpp | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 2003e9b6f5..c11962bf9d 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -1592,7 +1592,7 @@ void unified_bed_leveling::smart_fill_mesh() { DEBUG_DELAY(20); } - apply_rotation_xyz(rotation, mx, my, mz); + rotation.apply_rotation_xyz(mx, my, mz); if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR_F("after rotation = [", mx, 7); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index f3cfe02e40..42d3a75da1 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -794,7 +794,7 @@ G29_TYPE GcodeSuite::G29() { const int ind = abl.indexIntoAB[xx][yy]; xyz_float_t tmp = { abl.eqnAMatrix[ind + 0 * abl.abl_points], abl.eqnAMatrix[ind + 1 * abl.abl_points], 0 }; - apply_rotation_xyz(planner.bed_level_matrix, tmp); + planner.bed_level_matrix.apply_rotation_xyz(tmp); if (get_min) NOMORE(min_diff, abl.eqnBVector[ind] - tmp.z); const float subval = get_min ? abl.mean : tmp.z + min_diff, diff = abl.eqnBVector[ind] - subval; diff --git a/Marlin/src/libs/vector_3.cpp b/Marlin/src/libs/vector_3.cpp index 0ef29f33bd..f1bff7d4c6 100644 --- a/Marlin/src/libs/vector_3.cpp +++ b/Marlin/src/libs/vector_3.cpp @@ -87,8 +87,8 @@ void vector_3::debug(PGM_P const title) { * matrix_3x3 */ -void apply_rotation_xyz(const matrix_3x3 &matrix, float &_x, float &_y, float &_z) { - vector_3 vec = vector_3(_x, _y, _z); vec.apply_rotation(matrix); +void matrix_3x3::apply_rotation_xyz(float &_x, float &_y, float &_z) { + vector_3 vec = vector_3(_x, _y, _z); vec.apply_rotation(*this); _x = vec.x; _y = vec.y; _z = vec.z; } diff --git a/Marlin/src/libs/vector_3.h b/Marlin/src/libs/vector_3.h index 58428314d9..764e10accb 100644 --- a/Marlin/src/libs/vector_3.h +++ b/Marlin/src/libs/vector_3.h @@ -45,7 +45,6 @@ class matrix_3x3; struct vector_3 : xyz_float_t { - vector_3(const float &_x, const float &_y, const float &_z) { set(_x, _y, _z); } vector_3(const xy_float_t &in) { set(in.x, in.y); } vector_3(const xyz_float_t &in) { set(in.x, in.y, in.z); } @@ -82,9 +81,8 @@ struct matrix_3x3 { void set_to_identity(); void debug(PGM_P const title); -}; -void apply_rotation_xyz(const matrix_3x3 &rotationMatrix, float &x, float &y, float &z); -FORCE_INLINE void apply_rotation_xyz(const matrix_3x3 &rotationMatrix, xyz_pos_t &pos) { - apply_rotation_xyz(rotationMatrix, pos.x, pos.y, pos.z); -} + void apply_rotation_xyz(float &x, float &y, float &z); + + FORCE_INLINE void apply_rotation_xyz(xyz_pos_t &pos) { apply_rotation_xyz(pos.x, pos.y, pos.z); } +}; diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 832d6e316a..eee1a9f269 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1534,7 +1534,7 @@ void Planner::check_axes_activity() { #if ABL_PLANAR xy_pos_t d = raw - level_fulcrum; - apply_rotation_xyz(bed_level_matrix, d.x, d.y, raw.z); + bed_level_matrix.apply_rotation_xyz(d.x, d.y, raw.z); raw = d + level_fulcrum; #elif HAS_MESH @@ -1571,7 +1571,7 @@ void Planner::check_axes_activity() { matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix); xy_pos_t d = raw - level_fulcrum; - apply_rotation_xyz(inverse, d.x, d.y, raw.z); + inverse.apply_rotation_xyz(d.x, d.y, raw.z); raw = d + level_fulcrum; #elif HAS_MESH From bfdd1f4662f74c9db1cb62cc4f134d4e66a2da4f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 30 Mar 2021 23:57:57 -0500 Subject: [PATCH 144/311] Update UBL param --- Marlin/src/feature/bedlevel/ubl/ubl.h | 2 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 56de4e45ba..acc191908c 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -57,7 +57,7 @@ typedef struct { xy_pos_t XY_pos; xy_bool_t XY_seen; #if HAS_BED_PROBE - int grid_size; + uint8_t J_grid_size; #endif } G29_parameters_t; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index c11962bf9d..3282ebe620 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -391,7 +391,7 @@ void unified_bed_leveling::G29() { if (parser.seen('J')) { save_ubl_active_state_and_disable(); - tilt_mesh_based_on_probed_grid(param.grid_size == 0); // Zero size does 3-Point + tilt_mesh_based_on_probed_grid(param.J_grid_size == 0); // Zero size does 3-Point restore_ubl_active_state_and_leave(); #if ENABLED(UBL_G29_J_RECENTER) do_blocking_move_to_xy(0.5f * ((MESH_MIN_X) + (MESH_MAX_X)), 0.5f * ((MESH_MIN_Y) + (MESH_MAX_Y))); @@ -1118,8 +1118,8 @@ bool unified_bed_leveling::G29_parse_parameters() { if (parser.seen('J')) { #if HAS_BED_PROBE - param.grid_size = parser.has_value() ? parser.value_int() : 0; - if (param.grid_size && !WITHIN(param.grid_size, 2, 9)) { + param.J_grid_size = parser.value_byte(); + if (param.J_grid_size && !WITHIN(param.J_grid_size, 2, 9)) { SERIAL_ECHOLNPGM("?Invalid grid size (J) specified (2-9).\n"); err_flag = true; } @@ -1420,8 +1420,8 @@ void unified_bed_leveling::smart_fill_mesh() { void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) { const float x_min = probe.min_x(), x_max = probe.max_x(), y_min = probe.min_y(), y_max = probe.max_y(), - dx = (x_max - x_min) / (param.grid_size - 1), - dy = (y_max - y_min) / (param.grid_size - 1); + dx = (x_max - x_min) / (param.J_grid_size - 1), + dy = (y_max - y_min) / (param.J_grid_size - 1); xy_float_t points[3]; probe.get_three_points(points); @@ -1507,14 +1507,14 @@ void unified_bed_leveling::smart_fill_mesh() { bool zig_zag = false; - const uint16_t total_points = sq(param.grid_size); + const uint16_t total_points = sq(param.J_grid_size); uint16_t point_num = 1; xy_pos_t rpos; - LOOP_L_N(ix, param.grid_size) { + LOOP_L_N(ix, param.J_grid_size) { rpos.x = x_min + ix * dx; - LOOP_L_N(iy, param.grid_size) { - rpos.y = y_min + dy * (zig_zag ? param.grid_size - 1 - iy : iy); + LOOP_L_N(iy, param.J_grid_size) { + rpos.y = y_min + dy * (zig_zag ? param.J_grid_size - 1 - iy : iy); if (!abort_flag) { SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n"); From 4d17613050e7d77bb1bf229f9682743f3924caf4 Mon Sep 17 00:00:00 2001 From: Sola <42537573+solawc@users.noreply.github.com> Date: Wed, 31 Mar 2021 15:34:17 +0800 Subject: [PATCH 145/311] MKS H43 fix, cleanup (#21485) Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 6 +- Marlin/src/HAL/LPC1768/HAL.h | 3 + Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 8 +- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 93 ++++---- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.h | 31 +-- .../extui/lib/dgus/mks/DGUSScreenHandler.cpp | 219 ++++++++---------- .../extui/lib/dgus/mks/DGUSScreenHandler.h | 6 +- Marlin/src/module/settings.cpp | 41 ++++ 8 files changed, 202 insertions(+), 205 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 93a60394c2..5f9b1782fc 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2373,7 +2373,11 @@ //#define DGUS_LCD_UI_ORIGIN //#define DGUS_LCD_UI_FYSETC //#define DGUS_LCD_UI_HIPRECY -//#define DGUS_LCD_UI_MKS + +// #define DGUS_LCD_UI_MKS +#if ENABLED(DGUS_LCD_UI_MKS) + #define USE_MKS_GREEN_UI +#endif // // Touch-screen LCD for Malyan M200/M300 printers diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 58f9cb71fb..828e126d70 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -102,6 +102,9 @@ extern DefaultSerial1 USBSerial; #else #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif + #if HAS_DGUS_LCD + #define SERIAL_GET_TX_BUFFER_FREE() MSerial0.available() + #endif #endif // diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index 702c5cc47e..2c283b1a92 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -62,9 +62,11 @@ void DGUSDisplay::InitDisplay() { #define LCD_BAUDRATE 115200 #endif LCD_SERIAL.begin(LCD_BAUDRATE); - #if BOTH(DGUS_LCD_UI_MKS, POWER_LOSS_RECOVERY) - if (!recovery.valid()) delay(LOGO_TIME_DELAY); - #endif + + if (TERN1(POWER_LOSS_RECOVERY, !recovery.valid())) { // If no Power-Loss Recovery is needed... + TERN_(DGUS_LCD_UI_MKS, delay(LOGO_TIME_DELAY)); // Show the logo for a little while + } + RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN)); } diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index 25e1670740..a2ccdada36 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -43,58 +43,45 @@ uint16_t distanceToMove = 10; #endif -uint16_t distanceMove = 1; +uint16_t manualMoveStep = 1; float distanceFilament = 10; uint16_t FilamentSpeed = 25; float ZOffset_distance = 0.1; -float mesh_adj_distance = 0.1; +float mesh_adj_distance = 0.01; float Z_distance = 0.1; -int16_t level_1_x_point = 20; -int16_t level_1_y_point = 20; +//struct { uint16_t h, m, s; } dgus_time; -int16_t level_2_x_point = 20; -int16_t level_2_y_point = 20; +// +// Persistent settings +// +xy_int_t mks_corner_offsets[5]; // Initialized by settings.load() +xyz_int_t mks_park_pos; // Initialized by settings.load() +celsius_t mks_min_extrusion_temp; // Initialized by settings.load() -int16_t level_3_x_point = 20; -int16_t level_3_y_point = 20; - -int16_t level_4_x_point = 20; -int16_t level_4_y_point = 20; -int16_t level_5_x_point = X_MAX_POS / 2; -int16_t level_5_y_point = Y_MAX_POS / 2; - -uint16_t tim_h; -uint16_t tim_m; -uint16_t tim_s; - -uint16_t x_park_pos = 20; -uint16_t y_park_pos = 20; -uint16_t z_park_pos = 10; +void MKS_reset_settings() { + constexpr xy_int_t init_dgus_level_offsets[5] = { + { 20, 20 }, { 20, 20 }, + { 20, 20 }, { 20, 20 }, + { X_CENTER, Y_CENTER } + }; + mks_language_index = 0; + COPY(mks_corner_offsets, init_dgus_level_offsets); + mks_park_pos.set(20, 20, 10); + mks_min_extrusion_temp = 0; +} xyz_pos_t position_before_pause; - void MKS_pause_print_move() { queue.exhaust(); position_before_pause = current_position; - do_blocking_move_to(X_MIN_POS + x_park_pos, Y_MIN_POS + y_park_pos, current_position.z + z_park_pos); + do_blocking_move_to(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y, current_position.z + mks_park_pos.z); } - void MKS_resume_print_move() { do_blocking_move_to(position_before_pause); } -uint16_t min_ex_temp = 0; - float z_offset_add = 0; -#if ENABLED(SENSORLESS_HOMING) - uint16_t tmc_x_step = 0; - uint16_t tmc_y_step = 0; - uint16_t tmc_z_step = 0; -#else - uint16_t tmc_x_step = 0; - uint16_t tmc_y_step = 0; - uint16_t tmc_z_step = 0; -#endif +xyz_int_t tmc_step; // = { 0, 0, 0 } uint16_t lcd_default_light = 50; @@ -525,7 +512,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_Y_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr), VPHELPER(VP_Z_HOME, nullptr, &ScreenHandler.HandleManualMove, nullptr), - VPHELPER(VP_MOVE_DISTANCE, &distanceMove, &ScreenHandler.GetManualMovestep, nullptr), + VPHELPER(VP_MOVE_DISTANCE, &manualMoveStep, &ScreenHandler.GetManualMovestep, nullptr), VPHELPER(VP_MOTOR_LOCK_UNLOK, nullptr, &ScreenHandler.HandleManualMove, nullptr), VPHELPER(VP_LEVEL_POINT, nullptr, &ScreenHandler.ManualAssistLeveling, nullptr), @@ -567,7 +554,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr), VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr), - VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #endif @@ -623,16 +610,16 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_ZPos, ¤t_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), // Level Point Set - VPHELPER(VP_Level_Point_One_X, &level_1_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_One_Y, &level_1_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Two_X, &level_2_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Two_Y, &level_2_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Three_X, &level_3_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Three_Y, &level_3_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Four_X, &level_4_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Four_Y, &level_4_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Five_X, &level_5_x_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Five_Y, &level_5_y_point, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_One_X, &mks_corner_offsets[0].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_One_Y, &mks_corner_offsets[0].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Two_X, &mks_corner_offsets[1].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Two_Y, &mks_corner_offsets[1].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Three_X, &mks_corner_offsets[2].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Three_Y, &mks_corner_offsets[2].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Four_X, &mks_corner_offsets[3].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Four_Y, &mks_corner_offsets[3].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Five_X, &mks_corner_offsets[4].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Five_Y, &mks_corner_offsets[4].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // Print Progress VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay), @@ -679,20 +666,20 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_X_PARK_POS, &x_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Y_PARK_POS, &y_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Z_PARK_POS, &z_park_pos, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #if ENABLED(SENSORLESS_HOMING) // TMC SENSORLESS Setting #if AXIS_HAS_STEALTHCHOP(X) - VPHELPER(VP_TMC_X_STEP, &tmc_x_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue), + VPHELPER(VP_TMC_X_STEP, &tmc_step.x, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue), #endif #if AXIS_HAS_STEALTHCHOP(Y) - VPHELPER(VP_TMC_Y_STEP, &tmc_y_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue), + VPHELPER(VP_TMC_Y_STEP, &tmc_step.y, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue), #endif #if AXIS_HAS_STEALTHCHOP(Z) - VPHELPER(VP_TMC_Z_STEP, &tmc_z_step, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue), + VPHELPER(VP_TMC_Z_STEP, &tmc_step.z, ScreenHandler.TMC_ChangeConfig, ScreenHandler.DGUSLCD_SendTMCStepValue), #endif #endif diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h index c8915a3d25..9a3690f356 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h @@ -23,7 +23,6 @@ #include "../DGUSDisplayDef.h" -#define USE_MKS_GREEN_UI //#define DGUS_MKS_RUNOUT_SENSOR #define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 8000, 1500) @@ -36,43 +35,27 @@ #define MKS_FINSH -extern uint16_t distanceMove; +extern uint16_t manualMoveStep; extern float distanceFilament; extern uint16_t FilamentSpeed; extern float ZOffset_distance; extern float mesh_adj_distance; extern float Z_distance; -extern int16_t level_1_x_point; -extern int16_t level_1_y_point; -extern int16_t level_2_x_point; -extern int16_t level_2_y_point; -extern int16_t level_3_x_point; -extern int16_t level_3_y_point; -extern int16_t level_4_x_point; -extern int16_t level_4_y_point; -extern int16_t level_5_x_point; -extern int16_t level_5_y_point; +//extern struct { uint16_t h, m, s; } dgus_time; -extern uint16_t tim_h; -extern uint16_t tim_m; -extern uint16_t tim_s; +extern xy_int_t mks_corner_offsets[5]; +extern xyz_int_t mks_park_pos; +extern celsius_t mks_min_extrusion_temp; -extern uint16_t x_park_pos; -extern uint16_t y_park_pos; -extern uint16_t z_park_pos; +void MKS_reset_settings(); // Restore persistent settings to defaults -extern xyz_pos_t position_before_pause; void MKS_pause_print_move(); void MKS_resume_print_move(); -extern uint16_t min_ex_temp; - extern float z_offset_add; -extern uint16_t tmc_x_step; -extern uint16_t tmc_y_step; -extern uint16_t tmc_z_step; +xyz_int_t tmc_step; extern uint16_t lcd_default_light; diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index d956ec4c52..b6633d3a1f 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -55,7 +55,7 @@ #endif bool DGUSAutoTurnOff = false; -uint8_t DGUSLanguageSwitch = 0; // Switch language for MKS DGUS +uint8_t mks_language_index; // Initialized by settings.load() // endianness swap uint32_t swap32(const uint32_t value) { return (value & 0x000000FFU) << 24U | (value & 0x0000FF00U) << 8U | (value & 0x00FF0000U) >> 8U | (value & 0xFF000000U) >> 24U; } @@ -125,11 +125,11 @@ void DGUSScreenHandler::DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var) { } void DGUSScreenHandler::DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variable &var) { - if (DGUSLanguageSwitch == MKS_English) { + if (mks_language_index == MKS_English) { char *tmp = (char*) var.memadr; dgusdisplay.WriteVariable(var.VP, tmp, var.size, true); } - else if (DGUSLanguageSwitch == MKS_SimpleChinese) { + else if (mks_language_index == MKS_SimpleChinese) { uint16_t *tmp = (uint16_t *)var.memadr; dgusdisplay.WriteVariable(var.VP, tmp, var.size, true); } @@ -138,15 +138,15 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variabl void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { #if ENABLED(SENSORLESS_HOMING) #if AXIS_HAS_STEALTHCHOP(X) - tmc_x_step = stepperX.homing_threshold(); + tmc_step.x = stepperX.homing_threshold(); dgusdisplay.WriteVariable(var.VP, *(int16_t*)var.memadr); #endif #if AXIS_HAS_STEALTHCHOP(Y) - tmc_y_step = stepperY.homing_threshold(); + tmc_step.y = stepperY.homing_threshold(); dgusdisplay.WriteVariable(var.VP, *(int16_t*)var.memadr); #endif #if AXIS_HAS_STEALTHCHOP(Z) - tmc_z_step = stepperZ.homing_threshold(); + tmc_step.z = stepperZ.homing_threshold(); dgusdisplay.WriteVariable(var.VP, *(int16_t*)var.memadr); #endif #endif @@ -329,7 +329,7 @@ void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("ctrl turn off\n"); + DEBUG_ECHOLNPGM("GetTurnOffCtrl\n"); const uint16_t value = swap16(*(uint16_t *)val_ptr); switch (value) { case 0 ... 1: DGUSAutoTurnOff = (bool)value; break; @@ -338,15 +338,15 @@ void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("MinExtrudeTempChange DistanceChange"); + DEBUG_ECHOLNPGM("GetMinExtrudeTemp"); const uint16_t value = swap16(*(uint16_t *)val_ptr); thermalManager.extrude_min_temp = value; - min_ex_temp = value; + mks_min_extrusion_temp = value; settings.save(); } void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("Zoffset DistanceChange"); + DEBUG_ECHOLNPGM("GetZoffsetDistance"); const uint16_t value = swap16(*(uint16_t *)val_ptr); float val_distance = 0; switch (value) { @@ -360,7 +360,7 @@ void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) } void DGUSScreenHandler::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("\nMove DistanceChange"); + DEBUG_ECHOLNPGM("\nGetManualMovestep"); *(uint16_t *)var.memadr = swap16(*(uint16_t *)val_ptr); } @@ -414,14 +414,14 @@ void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) switch (lag_flag) { case MKS_SimpleChinese: DGUS_LanguageDisplay(MKS_SimpleChinese); - DGUSLanguageSwitch = MKS_SimpleChinese; + mks_language_index = MKS_SimpleChinese; dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose); dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose); settings.save(); break; case MKS_English: DGUS_LanguageDisplay(MKS_English); - DGUSLanguageSwitch = MKS_English; + mks_language_index = MKS_English; dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose); dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose); settings.save(); @@ -454,11 +454,11 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) { mesh_point_count = GRID_MAX_POINTS; - if (DGUSLanguageSwitch == MKS_English) { + if (mks_language_index == MKS_English) { const char level_buf_en[] = "Start Level"; dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_en, 32, true); } - else if (DGUSLanguageSwitch == MKS_SimpleChinese) { + else if (mks_language_index == MKS_SimpleChinese) { const uint16_t level_buf_ch[] = {0xAABF, 0xBCCA, 0xF7B5, 0xBDC6, 0x2000}; dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_ch, 32, true); } @@ -532,15 +532,17 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { break; case 2: - if (mesh_point_count == GRID_MAX_POINTS) { // 第1个点 + if (mesh_point_count == GRID_MAX_POINTS) { // The first point + + queue.enqueue_now_P(PSTR("G28")); queue.enqueue_now_P(PSTR("G29S1")); mesh_point_count--; - if (DGUSLanguageSwitch == MKS_English) { + if (mks_language_index == MKS_English) { const char level_buf_en1[] = "Next Point"; dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_en1, 32, true); } - else if (DGUSLanguageSwitch == MKS_SimpleChinese) { + else if (mks_language_index == MKS_SimpleChinese) { const uint16_t level_buf_ch1[] = {0xC2CF, 0xBBD2, 0xE3B5, 0x2000}; dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_ch1, 32, true); } @@ -548,11 +550,11 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { else if (mesh_point_count > 1) { // 倒数第二个点 queue.enqueue_now_P(PSTR("G29S2")); mesh_point_count--; - if (DGUSLanguageSwitch == MKS_English) { + if (mks_language_index == MKS_English) { const char level_buf_en2[] = "Next Point"; dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_en2, 32, true); } - else if (DGUSLanguageSwitch == MKS_SimpleChinese) { + else if (mks_language_index == MKS_SimpleChinese) { const uint16_t level_buf_ch2[] = {0xC2CF, 0xBBD2, 0xE3B5, 0x2000}; dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_ch2, 32, true); } @@ -560,11 +562,11 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { else if (mesh_point_count == 1) { queue.enqueue_now_P(PSTR("G29S2")); mesh_point_count--; - if (DGUSLanguageSwitch == MKS_English) { + if (mks_language_index == MKS_English) { const char level_buf_en2[] = "Level Finsh"; dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_en2, 32, true); } - else if (DGUSLanguageSwitch == MKS_SimpleChinese) { + else if (mks_language_index == MKS_SimpleChinese) { const uint16_t level_buf_ch2[] = {0xF7B5, 0xBDC6, 0xEACD, 0xC9B3, 0x2000}; dgusdisplay.WriteVariable(VP_AutoLevel_1_Dis, level_buf_ch2, 32, true); } @@ -597,85 +599,52 @@ void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) { const int16_t point_value = swap16(*(uint16_t *)val_ptr); - int16_t level_x_pos, level_y_pos; - char buf_level[32] = {0}; - unsigned int level_speed = 1500; + // Insist on leveling first time at this screen static bool first_level_flag = false; - - if (!first_level_flag) + if (!first_level_flag || point_value == 0x0001) { queue.enqueue_now_P(G28_STR); + first_level_flag = true; + } + + constexpr uint16_t level_speed = 1500; + + auto enqueue_corner_move = [](int16_t lx, int16_t ly, uint16_t fr) { + char buf_level[32]; + sprintf_P(buf_level, "G0X%dY%dF%d", lx, ly, fr); + queue.enqueue_one_now(buf_level); + }; + + if (WITHIN(point_value, 0x0001, 0x0005)) + queue.enqueue_now_P(PSTR("G1Z10")); switch (point_value) { case 0x0001: - if (first_level_flag) - queue.enqueue_now_P(G28_STR); - queue.enqueue_now_P(PSTR("G1 Z10")); - //level_x_pos = X_MIN_POS + 20; - //level_y_pos = Y_MIN_POS + 20; - level_x_pos = X_MIN_POS + abs(level_1_x_point); - level_y_pos = Y_MIN_POS + abs(level_1_y_point); - - memset(buf_level, 0, sizeof(buf_level)); - sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed); - queue.enqueue_one_now(buf_level); - queue.enqueue_now_P(PSTR("G28 Z")); + enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[0].x), + Y_MIN_POS + abs(mks_corner_offsets[0].y), level_speed); + queue.enqueue_now_P(PSTR("G28Z")); break; case 0x0002: - queue.enqueue_now_P(PSTR("G1 Z10")); - - //level_x_pos = X_MAX_POS - 20; - //level_y_pos = Y_MIN_POS + 20; - - level_x_pos = X_MAX_POS - abs(level_2_x_point); - level_y_pos = Y_MIN_POS + abs(level_2_y_point); - - sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed); - queue.enqueue_one_now(buf_level); - //queue.enqueue_now_P(PSTR("G28Z")); - queue.enqueue_now_P(PSTR("G1 Z-10")); + enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[1].x), + Y_MIN_POS + abs(mks_corner_offsets[1].y), level_speed); break; case 0x0003: - queue.enqueue_now_P(PSTR("G1 Z10")); - - //level_x_pos = X_MAX_POS - 20; - //level_y_pos = Y_MAX_POS - 20; - - level_x_pos = X_MAX_POS - abs(level_3_x_point); - level_y_pos = Y_MAX_POS - abs(level_3_y_point); - - sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed); - queue.enqueue_one_now(buf_level); - //sprintf_P(buf_level, PSTR("G28 Z")); - queue.enqueue_now_P(PSTR("G1 Z-10")); + enqueue_corner_move(X_MAX_POS - abs(mks_corner_offsets[2].x), + Y_MAX_POS - abs(mks_corner_offsets[2].y), level_speed); break; case 0x0004: - queue.enqueue_now_P(PSTR("G1 Z10")); - - //level_x_pos = X_MIN_POS + 20; - //level_y_pos = Y_MAX_POS - 20; - level_x_pos = X_MIN_POS + abs(level_4_x_point); - level_y_pos = Y_MAX_POS - abs(level_4_y_point); - - sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed); - queue.enqueue_one_now(buf_level); - //sprintf_P(buf_level, PSTR("G28 Z")); - queue.enqueue_now_P(PSTR("G1 Z-10")); + enqueue_corner_move(X_MIN_POS + abs(mks_corner_offsets[3].x), + Y_MAX_POS - abs(mks_corner_offsets[3].y), level_speed); break; case 0x0005: - queue.enqueue_now_P(PSTR("G1 Z10")); - //level_x_pos = (uint16_t)(X_MAX_POS / 2); - //level_y_pos = (uint16_t)(Y_MAX_POS / 2); - level_x_pos = abs(level_5_x_point); - level_y_pos = abs(level_5_y_point); - - sprintf_P(buf_level, "G0 X%d Y%d F%d", level_x_pos, level_y_pos, level_speed); - queue.enqueue_one_now(buf_level); - queue.enqueue_now_P(PSTR("G1 Z-10")); + enqueue_corner_move(abs(mks_corner_offsets[4].x), + abs(mks_corner_offsets[4].y), level_speed); break; } - // Only once - first_level_flag = true; + if (WITHIN(point_value, 0x0002, 0x0005)) { + //queue.enqueue_now_P(PSTR("G28Z")); + queue.enqueue_now_P(PSTR("G1Z-10")); + } } #define mks_min(a, b) ((a) < (b)) ? (a) : (b) @@ -691,7 +660,7 @@ void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) { #if AXIS_HAS_STEALTHCHOP(X) stepperX.homing_threshold(mks_min(tmc_value, 255)); settings.save(); - //tmc_x_step = stepperX.homing_threshold(); + //tmc_step.x = stepperX.homing_threshold(); #endif #endif break; @@ -700,7 +669,7 @@ void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) { #if AXIS_HAS_STEALTHCHOP(Y) stepperY.homing_threshold(mks_min(tmc_value, 255)); settings.save(); - //tmc_y_step = stepperY.homing_threshold(); + //tmc_step.y = stepperY.homing_threshold(); #endif #endif break; @@ -709,7 +678,7 @@ void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) { #if AXIS_HAS_STEALTHCHOP(Z) stepperZ.homing_threshold(mks_min(tmc_value, 255)); settings.save(); - //tmc_z_step = stepperZ.homing_threshold(); + //tmc_step.z = stepperZ.homing_threshold(); #endif #endif break; @@ -767,13 +736,13 @@ void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) { } #if USE_SENSORLESS #if AXIS_HAS_STEALTHCHOP(X) - tmc_x_step = stepperX.homing_threshold(); + tmc_step.x = stepperX.homing_threshold(); #endif #if AXIS_HAS_STEALTHCHOP(Y) - tmc_y_step = stepperY.homing_threshold(); + tmc_step.y = stepperY.homing_threshold(); #endif #if AXIS_HAS_STEALTHCHOP(Z) - tmc_z_step = stepperZ.homing_threshold(); + tmc_step.z = stepperZ.homing_threshold(); #endif #endif } @@ -784,9 +753,9 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { int16_t movevalue = swap16(*(uint16_t*)val_ptr); // Choose Move distance - if (distanceMove == 0x01) distanceMove = 10; - else if (distanceMove == 0x02) distanceMove = 100; - else if (distanceMove == 0x03) distanceMove = 1000; + if (manualMoveStep == 0x01) manualMoveStep = 10; + else if (manualMoveStep == 0x02) manualMoveStep = 100; + else if (manualMoveStep == 0x03) manualMoveStep = 1000; DEBUG_ECHOLNPAIR("QUEUE LEN:", queue.length); @@ -853,8 +822,8 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOPAIR("movevalue = ", movevalue); if (movevalue != 0 && movevalue != 5) { // get move distance switch (movevalue) { - case 0x0001: movevalue = distanceMove; break; - case 0x0002: movevalue = -distanceMove; break; + case 0x0001: movevalue = manualMoveStep; break; + case 0x0002: movevalue = -manualMoveStep; break; default: movevalue = 0; break; } } @@ -929,16 +898,16 @@ void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) { const int16_t value_pos = swap16(*(int16_t*)val_ptr); switch (var.VP) { - case VP_X_PARK_POS: x_park_pos = value_pos; break; - case VP_Y_PARK_POS: y_park_pos = value_pos; break; - case VP_Z_PARK_POS: z_park_pos = value_pos; break; + case VP_X_PARK_POS: mks_park_pos.x = value_pos; break; + case VP_Y_PARK_POS: mks_park_pos.y = value_pos; break; + case VP_Z_PARK_POS: mks_park_pos.z = value_pos; break; default: break; } skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); + DEBUG_ECHOLNPGM("HandleChangeLevelPoint_MKS"); const int16_t value_raw = swap16(*(int16_t*)val_ptr); DEBUG_ECHOLNPAIR_F("value_raw:", value_raw); @@ -950,7 +919,7 @@ void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void * } void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); + DEBUG_ECHOLNPGM("HandleStepPerMMChanged_MKS"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; @@ -972,7 +941,7 @@ void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void * } void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); + DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged_MKS"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; @@ -1019,7 +988,7 @@ void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *va } void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS"); + DEBUG_ECHOLNPGM("HandleExtruderMaxSpeedChange_MKS"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; @@ -1044,7 +1013,7 @@ void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, } void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS"); + DEBUG_ECHOLNPGM("HandleMaxAccChange_MKS"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; @@ -1066,7 +1035,7 @@ void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ } void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS"); + DEBUG_ECHOLNPGM("HandleExtruderAccChange_MKS"); uint16_t value_raw = swap16(*(uint16_t*)val_ptr); DEBUG_ECHOLNPAIR("value_raw:", value_raw); @@ -1199,7 +1168,7 @@ void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ #endif // BABYSTEPPING void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleGetFilament"); + DEBUG_ECHOLNPGM("GetManualFilament"); uint16_t value_len = swap16(*(uint16_t*)val_ptr); @@ -1212,7 +1181,7 @@ void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) } void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleGetFilamentSpeed"); + DEBUG_ECHOLNPGM("GetManualFilamentSpeed"); uint16_t value_len = swap16(*(uint16_t*)val_ptr); @@ -1225,8 +1194,10 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) { #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) + char buf[40]; uint8_t swap_tool = 0; #endif + #if HAS_HOTEND uint8_t hotend_too_cold = 0; #endif @@ -1234,13 +1205,19 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ if (!print_job_timer.isPaused() && !queue.ring_buffer.empty()) return; - char buf[40]; const uint16_t val_t = swap16(*(uint16_t*)val_ptr); switch (val_t) { default: break; case 0: #if HAS_HOTEND - if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; else swap_tool = 1; + if (thermalManager.tooColdToExtrude(0)) { + hotend_too_cold = 1; + } + else { + #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) + swap_tool = 2; + #endif + } #endif break; case 1: @@ -1273,12 +1250,12 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ } void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("Load Filament"); + DEBUG_ECHOLNPGM("MKS_FilamentLoad"); MKS_FilamentLoadUnload(var, val_ptr, 1); } void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("UnLoad Filament"); + DEBUG_ECHOLNPGM("MKS_FilamentUnLoad"); MKS_FilamentLoadUnload(var, val_ptr, -1); } @@ -1403,7 +1380,7 @@ bool DGUSScreenHandler::loop() { if (language_times != 0) { LanguagePInit(); - DGUS_LanguageDisplay(DGUSLanguageSwitch); + DGUS_LanguageDisplay(mks_language_index); language_times--; } @@ -1413,18 +1390,18 @@ bool DGUSScreenHandler::loop() { booted = true; #if USE_SENSORLESS #if AXIS_HAS_STEALTHCHOP(X) - tmc_x_step = stepperX.homing_threshold(); + tmc_step.x = stepperX.homing_threshold(); #endif #if AXIS_HAS_STEALTHCHOP(Y) - tmc_y_step = stepperY.homing_threshold(); + tmc_step.y = stepperY.homing_threshold(); #endif #if AXIS_HAS_STEALTHCHOP(Z) - tmc_z_step = stepperZ.homing_threshold(); + tmc_step.z = stepperZ.homing_threshold(); #endif #endif - if (min_ex_temp != 0) - thermalManager.extrude_min_temp = min_ex_temp; + if (mks_min_extrusion_temp != 0) + thermalManager.extrude_min_temp = mks_min_extrusion_temp; DGUS_ExtrudeLoadInit(); @@ -1446,7 +1423,7 @@ bool DGUSScreenHandler::loop() { } void DGUSScreenHandler::LanguagePInit() { - switch (DGUSLanguageSwitch) { + switch (mks_language_index) { case MKS_SimpleChinese: dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose); dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose); @@ -1705,10 +1682,10 @@ void DGUSScreenHandler::DGUS_LanguageDisplay(uint8_t var) { const char Printing_buf_en[] = "Printing"; dgusdisplay.WriteVariable(VP_Printing_Dis, Printing_buf_en, 32, true); - const char Info_EEPROM_1_buf_en[] = "Store setting?"; + const char Info_EEPROM_1_buf_en[] = "Store setting?"; dgusdisplay.WriteVariable(VP_Info_EEPROM_1_Dis, Info_EEPROM_1_buf_en, 32, true); - const char Info_EEPROM_2_buf_en[] = "Revert setting?"; + const char Info_EEPROM_2_buf_en[] = "Revert setting?"; dgusdisplay.WriteVariable(VP_Info_EEPROM_2_Dis, Info_EEPROM_2_buf_en, 32, true); const char Info_PrinfFinsh_1_buf_en[] = "Print Done"; @@ -1963,7 +1940,7 @@ void DGUSScreenHandler::DGUS_LanguageDisplay(uint8_t var) { const uint16_t Info_EEPROM_1_buf_ch[] = { 0xC7CA, 0xF1B7, 0xA3B1, 0xE6B4, 0xE8C9, 0xC3D6, 0xBFA3, 0x2000 }; dgusdisplay.WriteVariable(VP_Info_EEPROM_1_Dis, Info_EEPROM_1_buf_ch, 32, true); - const uint16_t Info_EEPROM_2_buf_ch[] = { 0xC7CA, 0xF1B7, 0xD6BB, 0xB4B8, 0xF6B3, 0xA7B3, 0xE8C9, 0xC3D6, 0x2000 }; + const uint16_t Info_EEPROM_2_buf_ch[] = { 0xC7CA, 0xF1B7, 0xD6BB, 0xB4B8, 0xF6B3, 0xA7B3, 0xE8C9, 0xC3D6, 0xBFA3, 0x2000 }; dgusdisplay.WriteVariable(VP_Info_EEPROM_2_Dis, Info_EEPROM_2_buf_ch, 32, true); const uint16_t TMC_X_Step_buf_ch[] = { 0x2058, 0xE9C1, 0xF4C3, 0xC8B6, 0x2000 }; diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h index dc656326ac..2d0678ca5b 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h @@ -158,13 +158,13 @@ public: static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr); #endif + // File touched. + static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); #if ENABLED(SDSUPPORT) // Callback for VP "Display wants to change screen when there is a SD card" static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); // Scroll buttons on the file listing screen. static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); - // File touched. - static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); // start print after confirmation received. static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); // User hit the pause, resume or abort button. @@ -301,7 +301,7 @@ private: #define MKS_SimpleChinese 0 #define MKS_English 1 -extern uint8_t DGUSLanguageSwitch; +extern uint8_t mks_language_index; extern bool DGUSAutoTurnOff; #if ENABLED(POWER_LOSS_RECOVERY) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index d98ee3c218..ced33a1986 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -153,6 +153,11 @@ #include "../libs/buzzer.h" #endif +#if ENABLED(DGUS_LCD_UI_MKS) + #include "../lcd/extui/lib/dgus/DGUSScreenHandler.h" + #include "../lcd/extui/lib/dgus/DGUSDisplayDef.h" +#endif + #pragma pack(push, 1) // No padding between variables #if HAS_ETHERNET @@ -461,6 +466,16 @@ typedef struct SettingsDataStruct { bool buzzer_enabled; #endif + // + // MKS UI controller + // + #if ENABLED(DGUS_LCD_UI_MKS) + uint8_t mks_language_index; // Display Language + xy_int_t mks_corner_offsets[5]; // Bed Tramming + xyz_int_t mks_park_pos; // Custom Parking (without NOZZLE_PARK) + celsius_t mks_min_extrusion_temp; // Min E Temp (shadow M302 value) + #endif + #if HAS_MULTI_LANGUAGE uint8_t ui_language; // M414 S #endif @@ -1402,6 +1417,16 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(ui.buzzer_enabled); #endif + // + // MKS UI controller + // + #if ENABLED(DGUS_LCD_UI_MKS) + EEPROM_WRITE(mks_language_index); + EEPROM_WRITE(mks_corner_offsets); + EEPROM_WRITE(mks_park_pos); + EEPROM_WRITE(mks_min_extrusion_temp); + #endif + // // Selected LCD language // @@ -2302,6 +2327,17 @@ void MarlinSettings::postprocess() { EEPROM_READ(ui.buzzer_enabled); #endif + // + // MKS UI controller + // + #if ENABLED(DGUS_LCD_UI_MKS) + _FIELD_TEST(mks_language_index); + EEPROM_READ(mks_language_index); + EEPROM_READ(mks_corner_offsets); + EEPROM_READ(mks_park_pos); + EEPROM_READ(mks_min_extrusion_temp); + #endif + // // Selected LCD language // @@ -2967,6 +3003,11 @@ void MarlinSettings::reset() { #endif #endif + // + // MKS UI controller + // + TERN_(DGUS_LCD_UI_MKS, MKS_reset_settings()); + postprocess(); DEBUG_ECHO_START(); From 600ef1e47cf905bec1e76b35f3912863ade4fff0 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 1 Apr 2021 00:34:23 +0000 Subject: [PATCH 146/311] [cron] Bump distribution date (2021-04-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 2930228b14..361b647dd5 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-03-31" + #define STRING_DISTRIBUTION_DATE "2021-04-01" #endif /** From 62f37669dc506a6e579389ca549ce5993548944d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 1 Apr 2021 17:59:57 -0500 Subject: [PATCH 147/311] Replace 'const float &' with 'const_float_t' (#21505) --- Marlin/src/HAL/AVR/fastio.cpp | 2 +- Marlin/src/core/serial.cpp | 2 +- Marlin/src/core/serial.h | 2 +- Marlin/src/core/types.h | 10 +++ Marlin/src/feature/babystep.cpp | 2 +- Marlin/src/feature/babystep.h | 2 +- Marlin/src/feature/backlash.h | 2 +- Marlin/src/feature/bedlevel/abl/abl.cpp | 4 +- Marlin/src/feature/bedlevel/abl/abl.h | 2 +- Marlin/src/feature/bedlevel/bedlevel.cpp | 2 +- Marlin/src/feature/bedlevel/bedlevel.h | 2 +- .../bedlevel/mbl/mesh_bed_leveling.cpp | 2 +- .../feature/bedlevel/mbl/mesh_bed_leveling.h | 22 +++--- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 4 +- Marlin/src/feature/bedlevel/ubl/ubl.h | 44 +++++------ Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 12 +-- .../src/feature/bedlevel/ubl/ubl_motion.cpp | 4 +- Marlin/src/feature/encoder_i2c.h | 2 +- Marlin/src/feature/filwidth.h | 2 +- .../src/feature/leds/printer_event_leds.cpp | 8 +- Marlin/src/feature/leds/printer_event_leds.h | 6 +- Marlin/src/feature/max7219.cpp | 2 +- Marlin/src/feature/max7219.h | 7 ++ Marlin/src/feature/mixing.cpp | 2 +- Marlin/src/feature/mixing.h | 4 +- Marlin/src/feature/pause.cpp | 10 +-- Marlin/src/feature/pause.h | 10 +-- Marlin/src/feature/powerloss.cpp | 2 +- Marlin/src/feature/powerloss.h | 2 +- Marlin/src/feature/probe_temp_comp.cpp | 8 +- Marlin/src/feature/probe_temp_comp.h | 8 +- Marlin/src/feature/runout.h | 2 +- Marlin/src/feature/spindle_laser.h | 2 +- Marlin/src/gcode/bedlevel/G26.cpp | 4 +- Marlin/src/gcode/calibrate/G33.cpp | 2 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/calibrate/M48.cpp | 2 +- Marlin/src/gcode/feature/camera/M240.cpp | 2 +- Marlin/src/gcode/feature/mixing/M166.cpp | 2 +- Marlin/src/gcode/motion/M290.cpp | 2 +- Marlin/src/gcode/parser.h | 12 +-- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 2 +- Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp | 2 +- Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp | 2 +- Marlin/src/lcd/extui/dgus_lcd.cpp | 2 +- Marlin/src/lcd/extui/example.cpp | 2 +- .../lib/ftdi_eve_touch_ui/marlin_events.cpp | 2 +- Marlin/src/lcd/extui/malyan_lcd.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 70 +++++++++--------- Marlin/src/lcd/extui/ui_api.h | 74 +++++++++---------- Marlin/src/lcd/marlinui.h | 2 +- Marlin/src/lcd/menu/menu.cpp | 2 +- Marlin/src/lcd/menu/menu.h | 8 +- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 2 +- Marlin/src/lcd/menu/menu_item.h | 10 +-- Marlin/src/lcd/menu/menu_motion.cpp | 2 +- Marlin/src/lcd/menu/menu_probe_offset.cpp | 4 +- Marlin/src/lcd/menu/menu_ubl.cpp | 2 +- Marlin/src/libs/L64XX/L64XX_Marlin.cpp | 4 +- Marlin/src/libs/least_squares_fit.h | 8 +- Marlin/src/libs/nozzle.cpp | 4 +- Marlin/src/libs/nozzle.h | 4 +- Marlin/src/libs/numtostr.cpp | 38 +++++----- Marlin/src/libs/numtostr.h | 49 ++++++------ Marlin/src/libs/vector_3.h | 2 +- Marlin/src/module/delta.cpp | 2 +- Marlin/src/module/delta.h | 2 +- Marlin/src/module/motion.cpp | 32 ++++---- Marlin/src/module/motion.h | 46 ++++++------ Marlin/src/module/planner.cpp | 22 +++--- Marlin/src/module/planner.h | 56 +++++++------- Marlin/src/module/planner_bezier.cpp | 8 +- Marlin/src/module/planner_bezier.h | 2 +- Marlin/src/module/probe.cpp | 6 +- Marlin/src/module/probe.h | 12 +-- Marlin/src/module/scara.cpp | 4 +- Marlin/src/module/scara.h | 4 +- Marlin/src/module/temperature.cpp | 8 +- Marlin/src/module/temperature.h | 14 ++-- 79 files changed, 376 insertions(+), 366 deletions(-) diff --git a/Marlin/src/HAL/AVR/fastio.cpp b/Marlin/src/HAL/AVR/fastio.cpp index b51d7f9768..70132e71ee 100644 --- a/Marlin/src/HAL/AVR/fastio.cpp +++ b/Marlin/src/HAL/AVR/fastio.cpp @@ -241,7 +241,7 @@ uint8_t extDigitalRead(const int8_t pin) { * * DC values -1.0 to 1.0. Negative duty cycle inverts the pulse. */ -uint16_t set_pwm_frequency_hz(const float &hz, const float dca, const float dcb, const float dcc) { +uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb, const float dcc) { float count = 0; if (hz > 0 && (dca || dcb || dcc)) { count = float(F_CPU) / hz; // 1x prescaler, TOP for 16MHz base freq. diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index dcbfd608bf..8af367c801 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -91,7 +91,7 @@ void print_bin(uint16_t val) { } } -void print_xyz(const float &x, const float &y, const float &z, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) { +void print_xyz(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) { if (prefix) serialprintPGM(prefix); SERIAL_ECHOPAIR_P(SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z); if (suffix) serialprintPGM(suffix); else SERIAL_EOL(); diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 43137f71d7..45a1ab012e 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -387,7 +387,7 @@ void serialprint_truefalse(const bool tf); void serial_spaces(uint8_t count); void print_bin(const uint16_t val); -void print_xyz(const float &x, const float &y, const float &z, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr); +void print_xyz(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr); inline void print_xyz(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) { print_xyz(xyz.x, xyz.y, xyz.z, prefix, suffix); diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index d77dba38d9..687ec867d1 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -78,6 +78,16 @@ typedef float feedRate_t; // typedef int16_t celsius_t; +// +// On AVR pointers are only 2 bytes so use 'const float &' for 'const float' +// +#ifdef __AVR__ + typedef const float & const_float_t; +#else + typedef const float const_float_t; +#endif +typedef const_float_t const_feedRate_t; + // Conversion macros #define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f) #define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f) diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index b076881461..54ad9588f4 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -50,7 +50,7 @@ void Babystep::step_axis(const AxisEnum axis) { } } -void Babystep::add_mm(const AxisEnum axis, const float &mm) { +void Babystep::add_mm(const AxisEnum axis, const_float_t mm) { add_steps(axis, mm * planner.settings.axis_steps_per_mm[axis]); } diff --git a/Marlin/src/feature/babystep.h b/Marlin/src/feature/babystep.h index f85e5909ca..f8037678ca 100644 --- a/Marlin/src/feature/babystep.h +++ b/Marlin/src/feature/babystep.h @@ -61,7 +61,7 @@ public: #endif static void add_steps(const AxisEnum axis, const int16_t distance); - static void add_mm(const AxisEnum axis, const float &mm); + static void add_mm(const AxisEnum axis, const_float_t mm); static inline bool has_steps() { return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)]; diff --git a/Marlin/src/feature/backlash.h b/Marlin/src/feature/backlash.h index 49857f1f99..500168b380 100644 --- a/Marlin/src/feature/backlash.h +++ b/Marlin/src/feature/backlash.h @@ -35,7 +35,7 @@ public: static float smoothing_mm; #endif - static inline void set_correction(const float &v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; } + static inline void set_correction(const_float_t v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; } static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; } #else static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF; diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index a663ee571d..bc3aedb2f4 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -213,7 +213,7 @@ void print_bilinear_leveling_grid() { ) * 0.5f; } - static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const float &tx, const float &ty) { + static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) { float row[4], column[4]; LOOP_L_N(i, 4) { LOOP_L_N(j, 4) { @@ -356,7 +356,7 @@ float bilinear_z_offset(const xy_pos_t &raw) { * Prepare a bilinear-leveled linear move on Cartesian, * splitting the move where it crosses grid borders. */ - void bilinear_line_to_destination(const feedRate_t &scaled_fr_mm_s, uint16_t x_splits, uint16_t y_splits) { + void bilinear_line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits, uint16_t y_splits) { // Get current and destination cells for this line xy_int_t c1 { CELL_INDEX(x, current_position.x), CELL_INDEX(y, current_position.y) }, c2 { CELL_INDEX(x, destination.x), CELL_INDEX(y, destination.y) }; diff --git a/Marlin/src/feature/bedlevel/abl/abl.h b/Marlin/src/feature/bedlevel/abl/abl.h index bbe2411dc3..3d54c55695 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.h +++ b/Marlin/src/feature/bedlevel/abl/abl.h @@ -37,7 +37,7 @@ void refresh_bed_level(); #endif #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) - void bilinear_line_to_destination(const feedRate_t &scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF); + void bilinear_line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF); #endif #define _GET_MESH_X(I) float(bilinear_start.x + (I) * bilinear_grid_spacing.x) diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 3680fbac05..30fafbf57b 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -98,7 +98,7 @@ TemporaryBedLevelingState::TemporaryBedLevelingState(const bool enable) : saved( #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - void set_z_fade_height(const float &zfh, const bool do_report/*=true*/) { + void set_z_fade_height(const_float_t zfh, const bool do_report/*=true*/) { if (planner.z_fade_height == zfh) return; diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index 3e89a08802..9bab2fbd2f 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -38,7 +38,7 @@ void set_bed_leveling_enabled(const bool enable=true); void reset_bed_level(); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - void set_z_fade_height(const float &zfh, const bool do_report=true); + void set_z_fade_height(const_float_t zfh, const bool do_report=true); #endif #if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY) diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp index ec5b95c108..f51d83f996 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp @@ -61,7 +61,7 @@ * Prepare a mesh-leveled linear move in a Cartesian setup, * splitting the move where it crosses mesh borders. */ - void mesh_bed_leveling::line_to_destination(const feedRate_t &scaled_fr_mm_s, uint8_t x_splits, uint8_t y_splits) { + void mesh_bed_leveling::line_to_destination(const_feedRate_t scaled_fr_mm_s, uint8_t x_splits, uint8_t y_splits) { // Get current and destination cells for this line xy_int8_t scel = cell_indexes(current_position), ecel = cell_indexes(destination); NOMORE(scel.x, GRID_MAX_POINTS_X - 2); diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index ade7a93140..9932ce9e5c 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -56,7 +56,7 @@ public: return false; } - static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; } + static void set_z(const int8_t px, const int8_t py, const_float_t z) { z_values[px][py] = z; } static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) { px = index % (GRID_MAX_POINTS_X); @@ -64,39 +64,39 @@ public: if (py & 1) px = (GRID_MAX_POINTS_X - 1) - px; // Zig zag } - static void set_zigzag_z(const int8_t index, const float &z) { + static void set_zigzag_z(const int8_t index, const_float_t z) { int8_t px, py; zigzag(index, px, py); set_z(px, py, z); } - static int8_t cell_index_x(const float &x) { + static int8_t cell_index_x(const_float_t x) { int8_t cx = (x - (MESH_MIN_X)) * RECIPROCAL(MESH_X_DIST); return constrain(cx, 0, (GRID_MAX_POINTS_X) - 2); } - static int8_t cell_index_y(const float &y) { + static int8_t cell_index_y(const_float_t y) { int8_t cy = (y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST); return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 2); } - static inline xy_int8_t cell_indexes(const float &x, const float &y) { + static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { return { cell_index_x(x), cell_index_y(y) }; } static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } - static int8_t probe_index_x(const float &x) { + static int8_t probe_index_x(const_float_t x) { int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * RECIPROCAL(MESH_X_DIST); return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1; } - static int8_t probe_index_y(const float &y) { + static int8_t probe_index_y(const_float_t y) { int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * RECIPROCAL(MESH_Y_DIST); return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1; } - static inline xy_int8_t probe_indexes(const float &x, const float &y) { + static inline xy_int8_t probe_indexes(const_float_t x, const_float_t y) { return { probe_index_x(x), probe_index_y(y) }; } static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); } - static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) { + static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) { const float delta_z = (z2 - z1) / (a2 - a1), delta_a = a0 - a1; return z1 + delta_a * delta_z; @@ -104,7 +104,7 @@ public: static float get_z(const xy_pos_t &pos #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - , const float &factor=1.0f + , const_float_t factor=1.0f #endif ) { #if DISABLED(ENABLE_LEVELING_FADE_HEIGHT) @@ -120,7 +120,7 @@ public: } #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) - static void line_to_destination(const feedRate_t &scaled_fr_mm_s, uint8_t x_splits=0xFF, uint8_t y_splits=0xFF); + static void line_to_destination(const_feedRate_t scaled_fr_mm_s, uint8_t x_splits=0xFF, uint8_t y_splits=0xFF); #endif }; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 05b96daefa..14491bdd81 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -102,7 +102,7 @@ void unified_bed_leveling::invalidate() { set_all_mesh_points_to_value(NAN); } -void unified_bed_leveling::set_all_mesh_points_to_value(const float value) { +void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) { GRID_LOOP(x, y) { z_values[x][y] = value; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, value)); @@ -115,7 +115,7 @@ void unified_bed_leveling::set_all_mesh_points_to_value(const float value) { constexpr int16_t Z_STEPS_NAN = INT16_MAX; void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) { - auto z_to_store = [](const float &z) { + auto z_to_store = [](const_float_t z) { if (isnan(z)) return Z_STEPS_NAN; const int32_t z_scaled = TRUNC(z * mesh_store_scaling); if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX)) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index acc191908c..222e7b0f20 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -67,17 +67,17 @@ private: static G29_parameters_t param; #if IS_NEWPANEL - static void move_z_with_encoder(const float &multiplier); + static void move_z_with_encoder(const_float_t multiplier); static float measure_point_with_encoder(); static float measure_business_card_thickness(); - static void manually_probe_remaining_mesh(const xy_pos_t&, const float&, const float&, const bool) _O0; + static void manually_probe_remaining_mesh(const xy_pos_t&, const_float_t , const_float_t , const bool) _O0; static void fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) _O0; #endif static bool G29_parse_parameters() _O0; static void shift_mesh_height(); static void probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) _O0; - static void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3); + static void tilt_mesh_based_on_3pts(const_float_t z1, const_float_t z2, const_float_t z3); static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map); static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir); static inline bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) { @@ -103,12 +103,12 @@ public: static mesh_index_pair find_furthest_invalid_mesh_point() _O0; static void reset(); static void invalidate(); - static void set_all_mesh_points_to_value(const float value); - static void adjust_mesh_to_mean(const bool cflag, const float value); + static void set_all_mesh_points_to_value(const_float_t value); + static void adjust_mesh_to_mean(const bool cflag, const_float_t value); static bool sanity_check(); static void G29() _O0; // O0 for no optimization - static void smart_fill_wlsf(const float &) _O2; // O2 gives smaller code than Os on A2560 + static void smart_fill_wlsf(const_float_t ) _O2; // O2 gives smaller code than Os on A2560 static int8_t storage_slot; @@ -131,42 +131,42 @@ public: unified_bed_leveling(); - FORCE_INLINE static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; } + FORCE_INLINE static void set_z(const int8_t px, const int8_t py, const_float_t z) { z_values[px][py] = z; } - static int8_t cell_index_x_raw(const float &x) { + static int8_t cell_index_x_raw(const_float_t x) { return FLOOR((x - (MESH_MIN_X)) * RECIPROCAL(MESH_X_DIST)); } - static int8_t cell_index_y_raw(const float &y) { + static int8_t cell_index_y_raw(const_float_t y) { return FLOOR((y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST)); } - static int8_t cell_index_x_valid(const float &x) { + static int8_t cell_index_x_valid(const_float_t x) { return WITHIN(cell_index_x_raw(x), 0, (GRID_MAX_POINTS_X - 2)); } - static int8_t cell_index_y_valid(const float &y) { + static int8_t cell_index_y_valid(const_float_t y) { return WITHIN(cell_index_y_raw(y), 0, (GRID_MAX_POINTS_Y - 2)); } - static int8_t cell_index_x(const float &x) { + static int8_t cell_index_x(const_float_t x) { return constrain(cell_index_x_raw(x), 0, (GRID_MAX_POINTS_X) - 2); } - static int8_t cell_index_y(const float &y) { + static int8_t cell_index_y(const_float_t y) { return constrain(cell_index_y_raw(y), 0, (GRID_MAX_POINTS_Y) - 2); } - static inline xy_int8_t cell_indexes(const float &x, const float &y) { + static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { return { cell_index_x(x), cell_index_y(y) }; } static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } - static int8_t closest_x_index(const float &x) { + static int8_t closest_x_index(const_float_t x) { const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * RECIPROCAL(MESH_X_DIST); return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1; } - static int8_t closest_y_index(const float &y) { + static int8_t closest_y_index(const_float_t y) { const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * RECIPROCAL(MESH_Y_DIST); return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1; } @@ -189,7 +189,7 @@ public: * It is fairly expensive with its 4 floating point additions and 2 floating point * multiplications. */ - FORCE_INLINE static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) { + FORCE_INLINE static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) { return z1 + (z2 - z1) * (a0 - a1) / (a2 - a1); } @@ -203,7 +203,7 @@ public: * z_correction_for_x_on_horizontal_mesh_line is an optimization for * the case where the printer is making a vertical line that only crosses horizontal mesh lines. */ - static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) { + static inline float z_correction_for_x_on_horizontal_mesh_line(const_float_t rx0, const int x1_i, const int yi) { if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) { if (DEBUGGING(LEVELING)) { @@ -226,7 +226,7 @@ public: // // See comments above for z_correction_for_x_on_horizontal_mesh_line // - static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) { + static inline float z_correction_for_y_on_vertical_mesh_line(const_float_t ry0, const int xi, const int y1_i) { if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) { if (DEBUGGING(LEVELING)) { @@ -252,7 +252,7 @@ public: * Z-Height at both ends. Then it does a linear interpolation of these heights based * on the Y position within the cell. */ - static float get_z_correction(const float &rx0, const float &ry0) { + static float get_z_correction(const_float_t rx0, const_float_t ry0) { const int8_t cx = cell_index_x(rx0), cy = cell_index_y(ry0); // return values are clamped /** @@ -309,9 +309,9 @@ public: } #if UBL_SEGMENTED - static bool line_to_destination_segmented(const feedRate_t &scaled_fr_mm_s); + static bool line_to_destination_segmented(const_feedRate_t scaled_fr_mm_s); #else - static void line_to_destination_cartesian(const feedRate_t &scaled_fr_mm_s, const uint8_t e); + static void line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t e); #endif static inline bool mesh_is_valid() { diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 3282ebe620..545d95676e 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -672,7 +672,7 @@ void unified_bed_leveling::G29() { * G29 P5 C : Adjust Mesh To Mean (and subtract the given offset). * Find the mean average and shift the mesh to center on that value. */ -void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float offset) { +void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t offset) { float sum = 0; int n = 0; GRID_LOOP(x, y) @@ -821,7 +821,7 @@ void set_message_with_feedback(PGM_P const msg_P) { return false; } - void unified_bed_leveling::move_z_with_encoder(const float &multiplier) { + void unified_bed_leveling::move_z_with_encoder(const_float_t multiplier) { ui.wait_for_release(); while (!ui.button_pressed()) { idle(); @@ -883,7 +883,7 @@ void set_message_with_feedback(PGM_P const msg_P) { * Move to INVALID points and * NOTE: Blocks the G-code queue and captures Marlin UI during use. */ - void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) { + void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const_float_t z_clearance, const_float_t thick, const bool do_ubl_mesh_map) { ui.capture(); save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained @@ -1633,10 +1633,10 @@ void unified_bed_leveling::smart_fill_mesh() { */ #ifdef VALIDATE_MESH_TILT auto d_from = []{ DEBUG_ECHOPGM("D from "); }; - auto normed = [&](const xy_pos_t &pos, const float &zadd) { + auto normed = [&](const xy_pos_t &pos, const_float_t zadd) { return normal.x * pos.x + normal.y * pos.y + zadd; }; - auto debug_pt = [](PGM_P const pre, const xy_pos_t &pos, const float &zadd) { + auto debug_pt = [](PGM_P const pre, const xy_pos_t &pos, const_float_t zadd) { d_from(); SERIAL_ECHOPGM_P(pre); DEBUG_ECHO_F(normed(pos, zadd), 6); DEBUG_ECHOLNPAIR_F(" Z error = ", zadd - get_z_correction(pos), 6); @@ -1658,7 +1658,7 @@ void unified_bed_leveling::smart_fill_mesh() { #endif // HAS_BED_PROBE #if ENABLED(UBL_G29_P31) - void unified_bed_leveling::smart_fill_wlsf(const float &weight_factor) { + void unified_bed_leveling::smart_fill_wlsf(const_float_t weight_factor) { // For each undefined mesh point, compute a distance-weighted least squares fit // from all the originally populated mesh points, weighted toward the point diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 33b4f03ac2..4e522210d0 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -37,7 +37,7 @@ #if !UBL_SEGMENTED - void unified_bed_leveling::line_to_destination_cartesian(const feedRate_t &scaled_fr_mm_s, const uint8_t extruder) { + void unified_bed_leveling::line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t extruder) { /** * Much of the nozzle movement will be within the same cell. So we will do as little computation * as possible to determine if this is the case. If this move is within the same cell, we will @@ -323,7 +323,7 @@ * Returns true if did NOT move, false if moved (requires current_position update). */ - bool _O2 unified_bed_leveling::line_to_destination_segmented(const feedRate_t &scaled_fr_mm_s) { + bool _O2 unified_bed_leveling::line_to_destination_segmented(const_feedRate_t scaled_fr_mm_s) { if (!position_is_reachable(destination)) // fail if moving outside reachable boundary return true; // did not move, so current_position still accurate diff --git a/Marlin/src/feature/encoder_i2c.h b/Marlin/src/feature/encoder_i2c.h index e771130391..20871af98c 100644 --- a/Marlin/src/feature/encoder_i2c.h +++ b/Marlin/src/feature/encoder_i2c.h @@ -188,7 +188,7 @@ class I2CPositionEncoder { FORCE_INLINE void set_ec_method(const byte method) { ecMethod = method; } FORCE_INLINE float get_ec_threshold() { return ecThreshold; } - FORCE_INLINE void set_ec_threshold(const float newThreshold) { ecThreshold = newThreshold; } + FORCE_INLINE void set_ec_threshold(const_float_t newThreshold) { ecThreshold = newThreshold; } FORCE_INLINE int get_encoder_ticks_mm() { switch (type) { diff --git a/Marlin/src/feature/filwidth.h b/Marlin/src/feature/filwidth.h index ef3859df71..e63d3d719f 100644 --- a/Marlin/src/feature/filwidth.h +++ b/Marlin/src/feature/filwidth.h @@ -78,7 +78,7 @@ public: static inline void update_measured_mm() { measured_mm = raw_to_mm(); } // Update ring buffer used to delay filament measurements - static inline void advance_e(const float &e_move) { + static inline void advance_e(const_float_t e_move) { // Increment counters with the E distance e_count += e_move; diff --git a/Marlin/src/feature/leds/printer_event_leds.cpp b/Marlin/src/feature/leds/printer_event_leds.cpp index 32c6862704..fe7db9a8e4 100644 --- a/Marlin/src/feature/leds/printer_event_leds.cpp +++ b/Marlin/src/feature/leds/printer_event_leds.cpp @@ -40,7 +40,7 @@ PrinterEventLEDs printerEventLEDs; uint8_t PrinterEventLEDs::old_intensity = 0; - inline uint8_t pel_intensity(const float &start, const float ¤t, const float &target) { + inline uint8_t pel_intensity(const_float_t start, const_float_t current, const_float_t target) { if (uint16_t(start) == uint16_t(target)) return 255; return (uint8_t)map(constrain(current, start, target), start, target, 0.f, 255.f); } @@ -58,7 +58,7 @@ PrinterEventLEDs printerEventLEDs; #if HAS_TEMP_HOTEND - void PrinterEventLEDs::onHotendHeating(const float &start, const float ¤t, const float &target) { + void PrinterEventLEDs::onHotendHeating(const_float_t start, const_float_t current, const_float_t target) { const uint8_t blue = pel_intensity(start, current, target); if (blue != old_intensity) { old_intensity = blue; @@ -70,7 +70,7 @@ PrinterEventLEDs printerEventLEDs; #if HAS_HEATED_BED - void PrinterEventLEDs::onBedHeating(const float &start, const float ¤t, const float &target) { + void PrinterEventLEDs::onBedHeating(const_float_t start, const_float_t current, const_float_t target) { const uint8_t red = pel_intensity(start, current, target); if (red != old_intensity) { old_intensity = red; @@ -82,7 +82,7 @@ PrinterEventLEDs printerEventLEDs; #if HAS_HEATED_CHAMBER - void PrinterEventLEDs::onChamberHeating(const float &start, const float ¤t, const float &target) { + void PrinterEventLEDs::onChamberHeating(const_float_t start, const_float_t current, const_float_t target) { const uint8_t green = pel_intensity(start, current, target); if (green != old_intensity) { old_intensity = green; diff --git a/Marlin/src/feature/leds/printer_event_leds.h b/Marlin/src/feature/leds/printer_event_leds.h index 668c9c969b..a262ddf85e 100644 --- a/Marlin/src/feature/leds/printer_event_leds.h +++ b/Marlin/src/feature/leds/printer_event_leds.h @@ -47,17 +47,17 @@ private: public: #if HAS_TEMP_HOTEND static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); } - static void onHotendHeating(const float &start, const float ¤t, const float &target); + static void onHotendHeating(const_float_t start, const_float_t current, const_float_t target); #endif #if HAS_HEATED_BED static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); } - static void onBedHeating(const float &start, const float ¤t, const float &target); + static void onBedHeating(const_float_t start, const_float_t current, const_float_t target); #endif #if HAS_HEATED_CHAMBER static inline LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); } - static void onChamberHeating(const float &start, const float ¤t, const float &target); + static void onChamberHeating(const_float_t start, const_float_t current, const_float_t target); #endif #if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER diff --git a/Marlin/src/feature/max7219.cpp b/Marlin/src/feature/max7219.cpp index d7433cb7d9..200e6b580d 100644 --- a/Marlin/src/feature/max7219.cpp +++ b/Marlin/src/feature/max7219.cpp @@ -256,7 +256,7 @@ void Max7219::set(const uint8_t line, const uint8_t bits) { } // Draw a float with a decimal point and optional digits - void Max7219::print(const uint8_t start, const float value, const uint8_t pre_size, const uint8_t post_size, const bool leadzero=false) { + void Max7219::print(const uint8_t start, const_float_t value, const uint8_t pre_size, const uint8_t post_size, const bool leadzero=false) { if (pre_size) print(start, value, pre_size, leadzero, !!post_size); if (post_size) { const int16_t after = ABS(value) * (10 ^ post_size); diff --git a/Marlin/src/feature/max7219.h b/Marlin/src/feature/max7219.h index 8e98c9456c..3e5b62db2f 100644 --- a/Marlin/src/feature/max7219.h +++ b/Marlin/src/feature/max7219.h @@ -100,6 +100,13 @@ public: // Update a single native line on just one unit static void refresh_unit_line(const uint8_t line); + #if ENABLED(MAX7219_NUMERIC) + // Draw an integer with optional leading zeros and optional decimal point + void print(const uint8_t start, int16_t value, uint8_t size, const bool leadzero=false, bool dec=false); + // Draw a float with a decimal point and optional digits + void print(const uint8_t start, const_float_t value, const uint8_t pre_size, const uint8_t post_size, const bool leadzero=false); + #endif + // Set a single LED by XY coordinate static void led_set(const uint8_t x, const uint8_t y, const bool on); static void led_on(const uint8_t x, const uint8_t y); diff --git a/Marlin/src/feature/mixing.cpp b/Marlin/src/feature/mixing.cpp index 722020ba8a..4823ac2c60 100644 --- a/Marlin/src/feature/mixing.cpp +++ b/Marlin/src/feature/mixing.cpp @@ -162,7 +162,7 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*= float Mixer::prev_z; // = 0 - void Mixer::update_gradient_for_z(const float z) { + void Mixer::update_gradient_for_z(const_float_t z) { if (z == prev_z) return; prev_z = z; diff --git a/Marlin/src/feature/mixing.h b/Marlin/src/feature/mixing.h index 5de039985d..573b61cb68 100644 --- a/Marlin/src/feature/mixing.h +++ b/Marlin/src/feature/mixing.h @@ -180,9 +180,9 @@ class Mixer { static float prev_z; // Update the current mix from the gradient for a given Z - static void update_gradient_for_z(const float z); + static void update_gradient_for_z(const_float_t z); static void update_gradient_for_planner_z(); - static inline void gradient_control(const float z) { + static inline void gradient_control(const_float_t z) { if (gradient.enabled) { if (z >= gradient.end_z) T(gradient.end_vtool); diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index a934b0ead0..5990c09a90 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -170,7 +170,7 @@ static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=P * * Returns 'true' if load was completed, 'false' for abort */ -bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=0*/, const int8_t max_beep_count/*=0*/, +bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load_length/*=0*/, const_float_t purge_length/*=0*/, const int8_t max_beep_count/*=0*/, const bool show_lcd/*=false*/, const bool pause_for_user/*=false*/, const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/ DXC_ARGS @@ -298,10 +298,10 @@ inline void disable_active_extruder() { * * Returns 'true' if unload was completed, 'false' for abort */ -bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/, +bool unload_filament(const_float_t unload_length, const bool show_lcd/*=false*/, const PauseMode mode/*=PAUSE_MODE_PAUSE_PRINT*/ #if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER) - , const float &mix_multiplier/*=1.0*/ + , const_float_t mix_multiplier/*=1.0*/ #endif ) { DEBUG_SECTION(uf, "unload_filament", true); @@ -367,7 +367,7 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/, */ 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) { +bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const_float_t 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:", show_lcd DXC_SAY); @@ -555,7 +555,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep * - Send host action for resume, if configured * - Resume the current SD print job, if any */ -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*/, const celsius_t targetTemp/*=0*/ DXC_ARGS) { +void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_length/*=0*/, const_float_t purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/, const celsius_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:", max_beep_count, " targetTemp:", targetTemp DXC_SAY); diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index 4ab33ac519..2a7ea40b83 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -85,19 +85,19 @@ extern uint8_t did_pause_print; #define DXC_SAY #endif -bool pause_print(const float &retract, const xyz_pos_t &park_point, const float &unload_length=0, const bool show_lcd=false DXC_PARAMS); +bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const_float_t unload_length=0, const bool show_lcd=false DXC_PARAMS); void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS); -void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, +void resume_print(const_float_t slow_load_length=0, const_float_t fast_load_length=0, const_float_t extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, const int8_t max_beep_count=0, const celsius_t targetTemp=0 DXC_PARAMS); -bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, +bool load_filament(const_float_t slow_load_length=0, const_float_t fast_load_length=0, const_float_t extrude_length=0, const int8_t max_beep_count=0, const bool show_lcd=false, const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS); -bool unload_filament(const float &unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT +bool unload_filament(const_float_t unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT #if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER) - , const float &mix_multiplier=1.0 + , const_float_t mix_multiplier=1.0 #endif ); diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index cc45d6ecf0..e45864b484 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -240,7 +240,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/ #if ENABLED(BACKUP_POWER_SUPPLY) - void PrintJobRecovery::retract_and_lift(const float &zraise) { + void PrintJobRecovery::retract_and_lift(const_float_t zraise) { #if POWER_LOSS_RETRACT_LEN || POWER_LOSS_ZRAISE gcode.set_relative_mode(true); // Use relative coordinates diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 7c09c0f3cf..ad34de6e53 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -199,7 +199,7 @@ class PrintJobRecovery { static void write(); #if ENABLED(BACKUP_POWER_SUPPLY) - static void retract_and_lift(const float &zraise); + static void retract_and_lift(const_float_t zraise); #endif #if PIN_EXISTS(POWER_LOSS) diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index 8fdf160d0f..b0867817b6 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -88,12 +88,12 @@ void ProbeTempComp::print_offsets() { } } -void ProbeTempComp::prepare_new_calibration(const float &init_meas_z) { +void ProbeTempComp::prepare_new_calibration(const_float_t init_meas_z) { calib_idx = 0; init_measurement = init_meas_z; } -void ProbeTempComp::push_back_new_measurement(const TempSensorID tsi, const float &meas_z) { +void ProbeTempComp::push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z) { switch (tsi) { case TSI_PROBE: case TSI_BED: @@ -159,12 +159,12 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { return true; } -void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const float &temp, float &meas_z) { +void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const_float_t temp, float &meas_z) { if (WITHIN(temp, cali_info[tsi].start_temp, cali_info[tsi].end_temp)) meas_z -= get_offset_for_temperature(tsi, temp); } -float ProbeTempComp::get_offset_for_temperature(const TempSensorID tsi, const float &temp) { +float ProbeTempComp::get_offset_for_temperature(const TempSensorID tsi, const_float_t temp) { const uint8_t measurements = cali_info[tsi].measurements; const float start_temp = cali_info[tsi].start_temp, res_temp = cali_info[tsi].temp_res; diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 626dd87f94..e29da7ece1 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -121,10 +121,10 @@ class ProbeTempComp { } static bool set_offset(const TempSensorID tsi, const uint8_t idx, const int16_t offset); static void print_offsets(); - static void prepare_new_calibration(const float &init_meas_z); - static void push_back_new_measurement(const TempSensorID tsi, const float &meas_z); + static void prepare_new_calibration(const_float_t init_meas_z); + static void push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z); static bool finish_calibration(const TempSensorID tsi); - static void compensate_measurement(const TempSensorID tsi, const float &temp, float &meas_z); + static void compensate_measurement(const TempSensorID tsi, const_float_t temp, float &meas_z); private: static uint8_t calib_idx; @@ -135,7 +135,7 @@ class ProbeTempComp { */ static float init_measurement; - static float get_offset_for_temperature(const TempSensorID tsi, const float &temp); + static float get_offset_for_temperature(const TempSensorID tsi, const_float_t temp); /** * Fit a linear function in measured temperature offsets diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 0c35ef6659..15bf607550 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -101,7 +101,7 @@ class TFilamentMonitor : public FilamentMonitorBase { #if HAS_FILAMENT_RUNOUT_DISTANCE static inline float& runout_distance() { return response.runout_distance_mm; } - static inline void set_runout_distance(const float &mm) { response.runout_distance_mm = mm; } + static inline void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; } #endif // Handle a block completion. RunoutResponseDelayed uses this to diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index b3d008851c..bf7106fab7 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -53,7 +53,7 @@ public: min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); - static const inline uint8_t pct_to_ocr(const float pct) { return uint8_t(PCT_TO_PWM(pct)); } + static const inline uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); } // cpower = configured values (e.g., SPEED_POWER_MAX) diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 0468b79363..e05336d6c5 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -212,7 +212,7 @@ mesh_index_pair find_closest_circle_to_print(const xy_pos_t &pos) { return out_point; } -void move_to(const float &rx, const float &ry, const float &z, const float &e_delta) { +void move_to(const_float_t rx, const_float_t ry, const_float_t z, const_float_t e_delta) { static float last_z = -999.99; const xy_pos_t dest = { rx, ry }; @@ -239,7 +239,7 @@ void move_to(const float &rx, const float &ry, const float &z, const float &e_de prepare_internal_move_to_destination(fr_mm_s); } -FORCE_INLINE void move_to(const xyz_pos_t &where, const float &de) { move_to(where.x, where.y, where.z, de); } +FORCE_INLINE void move_to(const xyz_pos_t &where, const_float_t de) { move_to(where.x, where.y, where.z, de); } void retract_filament(const xyz_pos_t &where) { if (!g26_retracted) { // Only retract if we are not already retracted! diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 902711397d..1b8eb889c6 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -93,7 +93,7 @@ void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) { TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, true)); } -void print_signed_float(PGM_P const prefix, const float &f) { +void print_signed_float(PGM_P const prefix, const_float_t f) { SERIAL_ECHOPGM(" "); SERIAL_ECHOPGM_P(prefix); SERIAL_CHAR(':'); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index a97283b3e7..1614dd6fbd 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -312,7 +312,7 @@ void GcodeSuite::G34() { ui.set_status(msg); #endif - auto decreasing_accuracy = [](const float &v1, const float &v2){ + auto decreasing_accuracy = [](const_float_t v1, const_float_t v2){ if (v1 < v2 * 0.7f) { SERIAL_ECHOLNPGM("Decreasing Accuracy Detected."); LCD_MESSAGEPGM(MSG_DECREASING_ACCURACY); diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 0c3da13bf9..19b11f602a 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -117,7 +117,7 @@ void GcodeSuite::M48() { max = -99999.9, // Largest value sampled so far sample_set[n_samples]; // Storage for sampled values - auto dev_report = [](const bool verbose, const float &mean, const float &sigma, const float &min, const float &max, const bool final=false) { + auto dev_report = [](const bool verbose, const_float_t mean, const_float_t sigma, const_float_t min, const_float_t max, const bool final=false) { if (verbose) { SERIAL_ECHOPAIR_F("Mean: ", mean, 6); if (!final) SERIAL_ECHOPAIR_F(" Sigma: ", sigma, 6); diff --git a/Marlin/src/gcode/feature/camera/M240.cpp b/Marlin/src/gcode/feature/camera/M240.cpp index fc350d8a55..f5c910a9e9 100644 --- a/Marlin/src/gcode/feature/camera/M240.cpp +++ b/Marlin/src/gcode/feature/camera/M240.cpp @@ -47,7 +47,7 @@ #endif #ifdef PHOTO_RETRACT_MM - inline void e_move_m240(const float length, const feedRate_t &fr_mm_s) { + inline void e_move_m240(const float length, const_feedRate_t fr_mm_s) { if (length && thermalManager.hotEnoughToExtrude(active_extruder)) unscaled_e_move(length, fr_mm_s); } diff --git a/Marlin/src/gcode/feature/mixing/M166.cpp b/Marlin/src/gcode/feature/mixing/M166.cpp index 3f2b8b79e8..5f788344eb 100644 --- a/Marlin/src/gcode/feature/mixing/M166.cpp +++ b/Marlin/src/gcode/feature/mixing/M166.cpp @@ -33,7 +33,7 @@ inline void echo_mix() { SERIAL_ECHOPAIR(" (", mixer.mix[0], "%|", mixer.mix[1], "%)"); } -inline void echo_zt(const int t, const float &z) { +inline void echo_zt(const int t, const_float_t z) { mixer.update_mix_from_vtool(t); SERIAL_ECHOPAIR_P(SP_Z_STR, z, SP_T_STR, t); echo_mix(); diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index 1cae8d11a2..7dd89a6fac 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -39,7 +39,7 @@ #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - FORCE_INLINE void mod_probe_offset(const float &offs) { + FORCE_INLINE void mod_probe_offset(const_float_t offs) { if (TERN1(BABYSTEP_HOTEND_Z_OFFSET, active_extruder == 0)) { probe.offset.z += offs; SERIAL_ECHO_MSG(STR_PROBE_OFFSET " " STR_Z, probe.offset.z); diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index ed503f8a90..a0fc67b9e5 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -282,8 +282,8 @@ public: // Units modes: Inches, Fahrenheit, Kelvin #if ENABLED(INCH_MODE_SUPPORT) - static inline float mm_to_linear_unit(const float mm) { return mm / linear_unit_factor; } - static inline float mm_to_volumetric_unit(const float mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } + static inline float mm_to_linear_unit(const_float_t mm) { return mm / linear_unit_factor; } + static inline float mm_to_volumetric_unit(const_float_t mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } // Init linear units by constructor GCodeParser() { set_input_linear_units(LINEARUNIT_MM); } @@ -301,16 +301,16 @@ public: return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } - static inline float linear_value_to_mm(const float v) { return v * linear_unit_factor; } + static inline float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; } static inline float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); } static inline float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); } #else - static inline float mm_to_linear_unit(const float mm) { return mm; } - static inline float mm_to_volumetric_unit(const float mm) { return mm; } + static inline float mm_to_linear_unit(const_float_t mm) { return mm; } + static inline float mm_to_volumetric_unit(const_float_t mm) { return mm; } - static inline float linear_value_to_mm(const float v) { return v; } + static inline float linear_value_to_mm(const_float_t v) { return v; } static inline float axis_value_to_mm(const AxisEnum, const float v) { return v; } static inline float per_axis_value(const AxisEnum, const float v) { return v; } diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index c2d2cf43af..e41ed62573 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -669,7 +669,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop B00001100,B00000000 }; - void _lcd_zoffset_overlay_gfx(const float zvalue) { + void _lcd_zoffset_overlay_gfx(const_float_t zvalue) { // Determine whether the user is raising or lowering the nozzle. static int8_t dir; static float old_zvalue; diff --git a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp index a424327b08..10c791cbc5 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp @@ -101,7 +101,7 @@ namespace ExtUI { #if HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated //SERIAL_ECHOLNPAIR("onMeshUpdate() x:", xpos, " y:", ypos, " z:", zval); } diff --git a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp index 939199db93..a98da07959 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp @@ -93,7 +93,7 @@ namespace ExtUI { void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated } #endif diff --git a/Marlin/src/lcd/extui/dgus_lcd.cpp b/Marlin/src/lcd/extui/dgus_lcd.cpp index 273a8d2d2a..73542090c5 100644 --- a/Marlin/src/lcd/extui/dgus_lcd.cpp +++ b/Marlin/src/lcd/extui/dgus_lcd.cpp @@ -111,7 +111,7 @@ namespace ExtUI { #if HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated } diff --git a/Marlin/src/lcd/extui/example.cpp b/Marlin/src/lcd/extui/example.cpp index 415d381dd6..38986fba73 100644 --- a/Marlin/src/lcd/extui/example.cpp +++ b/Marlin/src/lcd/extui/example.cpp @@ -97,7 +97,7 @@ namespace ExtUI { #if HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp index d8abfcd29a..10c873d19c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp @@ -140,7 +140,7 @@ namespace ExtUI { #if HAS_LEVELING && HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t x, const int8_t y, const float &val) { + void onMeshUpdate(const int8_t x, const int8_t y, const_float_t val) { BedMeshScreen::onMeshUpdate(x, y, val); } diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index d684ebd017..780401964b 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -528,7 +528,7 @@ namespace ExtUI { #if HAS_MESH void onMeshLevelingStart() {} - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval) {} + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {} #endif diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 23930c04f3..2eecda9df0 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -325,7 +325,7 @@ namespace ExtUI { return epos; } - void setAxisPosition_mm(const float &position, const axis_t axis, const feedRate_t feedrate/*=0*/) { + void setAxisPosition_mm(const_float_t position, const axis_t axis, const feedRate_t feedrate/*=0*/) { // Get motion limit from software endstops, if any float min, max; soft_endstop.get_manual_axis_limits((AxisEnum)axis, min, max); @@ -343,7 +343,7 @@ namespace ExtUI { line_to_current_position(feedrate ?: manual_feedrate_mm_s[axis]); } - void setAxisPosition_mm(const float &position, const extruder_t extruder, const feedRate_t feedrate/*=0*/) { + void setAxisPosition_mm(const_float_t position, const extruder_t extruder, const feedRate_t feedrate/*=0*/) { setActiveTool(extruder, true); current_position.e = position; @@ -455,7 +455,7 @@ namespace ExtUI { }; } - void setAxisCurrent_mA(const float &mA, const axis_t axis) { + void setAxisCurrent_mA(const_float_t mA, const axis_t axis) { switch (axis) { #if AXIS_IS_TMC(X) case X: stepperX.rms_current(constrain(mA, 400, 1500)); break; @@ -479,7 +479,7 @@ namespace ExtUI { }; } - void setAxisCurrent_mA(const float &mA, const extruder_t extruder) { + void setAxisCurrent_mA(const_float_t mA, const extruder_t extruder) { switch (extruder) { #if AXIS_IS_TMC(E0) case E0: stepperE0.rms_current(constrain(mA, 400, 1500)); break; @@ -539,7 +539,7 @@ namespace ExtUI { } } - void setTMCBumpSensitivity(const float &value, const axis_t axis) { + void setTMCBumpSensitivity(const_float_t value, const axis_t axis) { switch (axis) { #if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS #if X_SENSORLESS @@ -583,12 +583,12 @@ namespace ExtUI { return planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)]; } - void setAxisSteps_per_mm(const float &value, const axis_t axis) { + void setAxisSteps_per_mm(const_float_t value, const axis_t axis) { planner.settings.axis_steps_per_mm[axis] = value; planner.refresh_positioning(); } - void setAxisSteps_per_mm(const float &value, const extruder_t extruder) { + void setAxisSteps_per_mm(const_float_t value, const extruder_t extruder) { UNUSED_E(extruder); planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)] = value; planner.refresh_positioning(); @@ -621,11 +621,11 @@ namespace ExtUI { return planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)]; } - void setAxisMaxAcceleration_mm_s2(const float &value, const axis_t axis) { + void setAxisMaxAcceleration_mm_s2(const_float_t value, const axis_t axis) { planner.set_max_acceleration(axis, value); } - void setAxisMaxAcceleration_mm_s2(const float &value, const extruder_t extruder) { + void setAxisMaxAcceleration_mm_s2(const_float_t value, const extruder_t extruder) { UNUSED_E(extruder); planner.set_max_acceleration(E_AXIS_N(extruder - E0), value); } @@ -638,7 +638,7 @@ namespace ExtUI { #if HAS_FILAMENT_RUNOUT_DISTANCE float getFilamentRunoutDistance_mm() { return runout.runout_distance(); } - void setFilamentRunoutDistance_mm(const float &value) { runout.set_runout_distance(constrain(value, 0, 999)); } + void setFilamentRunoutDistance_mm(const_float_t value) { runout.set_runout_distance(constrain(value, 0, 999)); } #endif #endif @@ -651,7 +651,7 @@ namespace ExtUI { #if CASELIGHT_USES_BRIGHTNESS float getCaseLightBrightness_percent() { return ui8_to_percent(caselight.brightness); } - void setCaseLightBrightness_percent(const float &value) { + void setCaseLightBrightness_percent(const_float_t value) { caselight.brightness = map(constrain(value, 0, 100), 0, 100, 0, 255); caselight.update_brightness(); } @@ -663,7 +663,7 @@ namespace ExtUI { return (extruder < EXTRUDERS) ? planner.extruder_advance_K[extruder - E0] : 0; } - void setLinearAdvance_mm_mm_s(const float &value, const extruder_t extruder) { + void setLinearAdvance_mm_mm_s(const_float_t value, const extruder_t extruder) { if (extruder < EXTRUDERS) planner.extruder_advance_K[extruder - E0] = constrain(value, 0, 10); } @@ -675,7 +675,7 @@ namespace ExtUI { return planner.junction_deviation_mm; } - void setJunctionDeviation_mm(const float &value) { + void setJunctionDeviation_mm(const_float_t value) { planner.junction_deviation_mm = constrain(value, 0.001, 0.3); TERN_(LIN_ADVANCE, planner.recalculate_max_e_jerk()); } @@ -683,8 +683,8 @@ namespace ExtUI { #else float getAxisMaxJerk_mm_s(const axis_t axis) { return planner.max_jerk[axis]; } float getAxisMaxJerk_mm_s(const extruder_t) { return planner.max_jerk.e; } - void setAxisMaxJerk_mm_s(const float &value, const axis_t axis) { planner.set_max_jerk((AxisEnum)axis, value); } - void setAxisMaxJerk_mm_s(const float &value, const extruder_t) { planner.set_max_jerk(E_AXIS, value); } + void setAxisMaxJerk_mm_s(const_float_t value, const axis_t axis) { planner.set_max_jerk((AxisEnum)axis, value); } + void setAxisMaxJerk_mm_s(const_float_t value, const extruder_t) { planner.set_max_jerk(E_AXIS, value); } #endif #if ENABLED(DUAL_X_CARRIAGE) @@ -709,9 +709,9 @@ namespace ExtUI { void setFlow_percent(const int16_t flow, const extruder_t extr) { planner.set_flow(extr, flow); } void setMinFeedrate_mm_s(const feedRate_t fr) { planner.settings.min_feedrate_mm_s = fr; } void setMinTravelFeedrate_mm_s(const feedRate_t fr) { planner.settings.min_travel_feedrate_mm_s = fr; } - void setPrintingAcceleration_mm_s2(const float &acc) { planner.settings.acceleration = acc; } - void setRetractAcceleration_mm_s2(const float &acc) { planner.settings.retract_acceleration = acc; } - void setTravelAcceleration_mm_s2(const float &acc) { planner.settings.travel_acceleration = acc; } + void setPrintingAcceleration_mm_s2(const_float_t acc) { planner.settings.acceleration = acc; } + void setRetractAcceleration_mm_s2(const_float_t acc) { planner.settings.retract_acceleration = acc; } + void setTravelAcceleration_mm_s2(const_float_t acc) { planner.settings.travel_acceleration = acc; } #if ENABLED(BABYSTEPPING) @@ -772,7 +772,7 @@ namespace ExtUI { * Converts a mm displacement to a number of whole number of * steps that is at least mm long. */ - int16_t mmToWholeSteps(const float &mm, const axis_t axis) { + int16_t mmToWholeSteps(const_float_t mm, const axis_t axis) { const float steps = mm / planner.steps_to_mm[axis]; return steps > 0 ? CEIL(steps) : FLOOR(steps); } @@ -789,7 +789,7 @@ namespace ExtUI { ); } - void setZOffset_mm(const float &value) { + void setZOffset_mm(const_float_t value) { #if HAS_BED_PROBE if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) probe.offset.z = value; @@ -807,7 +807,7 @@ namespace ExtUI { return hotend_offset[extruder - E0][axis]; } - void setNozzleOffset_mm(const float &value, const axis_t axis, const extruder_t extruder) { + void setNozzleOffset_mm(const_float_t value, const axis_t axis, const extruder_t extruder) { if (extruder - E0 >= HOTENDS) return; hotend_offset[extruder - E0][axis] = value; } @@ -826,20 +826,20 @@ namespace ExtUI { #if HAS_BED_PROBE float getProbeOffset_mm(const axis_t axis) { return probe.offset.pos[axis]; } - void setProbeOffset_mm(const float &val, const axis_t axis) { probe.offset.pos[axis] = val; } + void setProbeOffset_mm(const_float_t val, const axis_t axis) { probe.offset.pos[axis] = val; } #endif #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t axis) { return backlash.distance_mm[axis]; } - void setAxisBacklash_mm(const float &value, const axis_t axis) + void setAxisBacklash_mm(const_float_t value, const axis_t axis) { backlash.distance_mm[axis] = constrain(value,0,5); } float getBacklashCorrection_percent() { return ui8_to_percent(backlash.correction); } - void setBacklashCorrection_percent(const float &value) { backlash.correction = map(constrain(value, 0, 100), 0, 100, 0, 255); } + void setBacklashCorrection_percent(const_float_t value) { backlash.correction = map(constrain(value, 0, 100), 0, 100, 0, 255); } #ifdef BACKLASH_SMOOTHING_MM float getBacklashSmoothing_mm() { return backlash.smoothing_mm; } - void setBacklashSmoothing_mm(const float &value) { backlash.smoothing_mm = constrain(value, 0, 999); } + void setBacklashSmoothing_mm(const_float_t value) { backlash.smoothing_mm = constrain(value, 0, 999); } #endif #endif @@ -858,14 +858,14 @@ namespace ExtUI { bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; } float getMeshPoint(const xy_uint8_t &pos) { return Z_VALUES(pos.x, pos.y); } - void setMeshPoint(const xy_uint8_t &pos, const float &zoff) { + void setMeshPoint(const xy_uint8_t &pos, const_float_t zoff) { if (WITHIN(pos.x, 0, GRID_MAX_POINTS_X) && WITHIN(pos.y, 0, GRID_MAX_POINTS_Y)) { Z_VALUES(pos.x, pos.y) = zoff; TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); } } - void moveToMeshPoint(const xy_uint8_t &pos, const float &z) { + void moveToMeshPoint(const xy_uint8_t &pos, const_float_t z) { #if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL) const feedRate_t old_feedrate = feedrate_mm_s; const float x_target = MESH_MIN_X + pos.x * (MESH_X_DIST), @@ -919,14 +919,14 @@ namespace ExtUI { float getPIDValues_Ki(const extruder_t tool) { return unscalePID_i(PID_PARAM(Ki, tool)); } float getPIDValues_Kd(const extruder_t tool) { return unscalePID_d(PID_PARAM(Kd, tool)); } - void setPIDValues(const float &p, const float &i, const float &d, extruder_t tool) { + void setPIDValues(const_float_t p, const_float_t i, const_float_t d, extruder_t tool) { thermalManager.temp_hotend[tool].pid.Kp = p; thermalManager.temp_hotend[tool].pid.Ki = scalePID_i(i); thermalManager.temp_hotend[tool].pid.Kd = scalePID_d(d); thermalManager.updatePID(); } - void startPIDTune(const float &temp, extruder_t tool) { + void startPIDTune(const_float_t temp, extruder_t tool) { thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true); } #endif @@ -936,14 +936,14 @@ namespace ExtUI { float getBedPIDValues_Ki() { return unscalePID_i(thermalManager.temp_bed.pid.Ki); } float getBedPIDValues_Kd() { return unscalePID_d(thermalManager.temp_bed.pid.Kd); } - void setBedPIDValues(const float &p, const float &i, const float &d) { + void setBedPIDValues(const_float_t p, const_float_t i, const_float_t d) { thermalManager.temp_bed.pid.Kp = p; thermalManager.temp_bed.pid.Ki = scalePID_i(i); thermalManager.temp_bed.pid.Kd = scalePID_d(d); thermalManager.updatePID(); } - void startBedPIDTune(const float &temp) { + void startBedPIDTune(const_float_t temp) { thermalManager.PID_autotune(temp, H_BED, 4, true); } #endif @@ -963,7 +963,7 @@ namespace ExtUI { return firmware_name; } - void setTargetTemp_celsius(const float &inval, const heater_t heater) { + void setTargetTemp_celsius(const_float_t inval, const heater_t heater) { float value = inval; #ifdef TOUCH_UI_LCD_TEMP_SCALING value *= TOUCH_UI_LCD_TEMP_SCALING; @@ -988,7 +988,7 @@ namespace ExtUI { } } - void setTargetTemp_celsius(const float &inval, const extruder_t extruder) { + void setTargetTemp_celsius(const_float_t inval, const extruder_t extruder) { float value = inval; #ifdef TOUCH_UI_LCD_TEMP_SCALING value *= TOUCH_UI_LCD_TEMP_SCALING; @@ -1000,7 +1000,7 @@ namespace ExtUI { #endif } - void setTargetFan_percent(const float &value, const fan_t fan) { + void setTargetFan_percent(const_float_t value, const fan_t fan) { #if HAS_FAN if (fan < FAN_COUNT) thermalManager.set_fan_speed(fan - FAN0, map(constrain(value, 0, 100), 0, 100, 0, 255)); @@ -1010,7 +1010,7 @@ namespace ExtUI { #endif } - void setFeedrate_percent(const float &value) { feedrate_percentage = constrain(value, 10, 500); } + void setFeedrate_percent(const_float_t value) { feedrate_percentage = constrain(value, 10, 500); } void coolDown() { #if HAS_HOTEND diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index ea49a3b63d..24bf284648 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -102,11 +102,11 @@ namespace ExtUI { #if HAS_TRINAMIC_CONFIG float getAxisCurrent_mA(const axis_t); float getAxisCurrent_mA(const extruder_t); - void setAxisCurrent_mA(const float&, const axis_t); - void setAxisCurrent_mA(const float&, const extruder_t); + void setAxisCurrent_mA(const_float_t , const axis_t); + void setAxisCurrent_mA(const_float_t , const extruder_t); int getTMCBumpSensitivity(const axis_t); - void setTMCBumpSensitivity(const float&, const axis_t); + void setTMCBumpSensitivity(const_float_t , const axis_t); #endif float getActualTemp_celsius(const heater_t); @@ -161,11 +161,11 @@ namespace ExtUI { #if HAS_MESH bed_mesh_t& getMeshArray(); float getMeshPoint(const xy_uint8_t &pos); - void setMeshPoint(const xy_uint8_t &pos, const float &zval); - void moveToMeshPoint(const xy_uint8_t &pos, const float &z); + void setMeshPoint(const xy_uint8_t &pos, const_float_t zval); + void moveToMeshPoint(const xy_uint8_t &pos, const_float_t z); void onMeshLevelingStart(); - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float &zval); - inline void onMeshUpdate(const xy_int8_t &pos, const float &zval) { onMeshUpdate(pos.x, pos.y, zval); } + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); + inline void onMeshUpdate(const xy_int8_t &pos, const_float_t zval) { onMeshUpdate(pos.x, pos.y, zval); } typedef enum : uint8_t { MESH_START, // Prior to start of probe @@ -191,42 +191,42 @@ namespace ExtUI { char* getFilamentUsed_str(char buffer[21]); #endif - void setTargetTemp_celsius(const float&, const heater_t); - void setTargetTemp_celsius(const float&, const extruder_t); - void setTargetFan_percent(const float&, const fan_t); + void setTargetTemp_celsius(const_float_t , const heater_t); + void setTargetTemp_celsius(const_float_t , const extruder_t); + void setTargetFan_percent(const_float_t , const fan_t); void coolDown(); - void setAxisPosition_mm(const float&, const axis_t, const feedRate_t=0); - void setAxisPosition_mm(const float&, const extruder_t, const feedRate_t=0); - void setAxisSteps_per_mm(const float&, const axis_t); - void setAxisSteps_per_mm(const float&, const extruder_t); + void setAxisPosition_mm(const_float_t , const axis_t, const feedRate_t=0); + void setAxisPosition_mm(const_float_t , const extruder_t, const feedRate_t=0); + void setAxisSteps_per_mm(const_float_t , const axis_t); + void setAxisSteps_per_mm(const_float_t , const extruder_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const axis_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const extruder_t); - void setAxisMaxAcceleration_mm_s2(const float&, const axis_t); - void setAxisMaxAcceleration_mm_s2(const float&, const extruder_t); + void setAxisMaxAcceleration_mm_s2(const_float_t , const axis_t); + void setAxisMaxAcceleration_mm_s2(const_float_t , const extruder_t); void setFeedrate_mm_s(const feedRate_t); void setMinFeedrate_mm_s(const feedRate_t); void setMinTravelFeedrate_mm_s(const feedRate_t); - void setPrintingAcceleration_mm_s2(const float&); - void setRetractAcceleration_mm_s2(const float&); - void setTravelAcceleration_mm_s2(const float&); - void setFeedrate_percent(const float&); + void setPrintingAcceleration_mm_s2(const_float_t ); + void setRetractAcceleration_mm_s2(const_float_t ); + void setTravelAcceleration_mm_s2(const_float_t ); + void setFeedrate_percent(const_float_t ); void setFlow_percent(const int16_t, const extruder_t); bool awaitingUserConfirm(); void setUserConfirmed(); #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t); - void setLinearAdvance_mm_mm_s(const float&, const extruder_t); + void setLinearAdvance_mm_mm_s(const_float_t , const extruder_t); #endif #if HAS_JUNCTION_DEVIATION float getJunctionDeviation_mm(); - void setJunctionDeviation_mm(const float&); + void setJunctionDeviation_mm(const_float_t ); #else float getAxisMaxJerk_mm_s(const axis_t); float getAxisMaxJerk_mm_s(const extruder_t); - void setAxisMaxJerk_mm_s(const float&, const axis_t); - void setAxisMaxJerk_mm_s(const float&, const extruder_t); + void setAxisMaxJerk_mm_s(const_float_t , const axis_t); + void setAxisMaxJerk_mm_s(const_float_t , const extruder_t); #endif extruder_t getTool(const uint8_t extruder); @@ -234,7 +234,7 @@ namespace ExtUI { void setActiveTool(const extruder_t, bool no_move); #if ENABLED(BABYSTEPPING) - int16_t mmToWholeSteps(const float& mm, const axis_t axis); + int16_t mmToWholeSteps(const_float_t mm, const axis_t axis); bool babystepAxis_steps(const int16_t steps, const axis_t axis); void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles); @@ -242,28 +242,28 @@ namespace ExtUI { #if HAS_HOTEND_OFFSET float getNozzleOffset_mm(const axis_t, const extruder_t); - void setNozzleOffset_mm(const float&, const axis_t, const extruder_t); + void setNozzleOffset_mm(const_float_t , const axis_t, const extruder_t); void normalizeNozzleOffset(const axis_t axis); #endif float getZOffset_mm(); - void setZOffset_mm(const float&); + void setZOffset_mm(const_float_t ); #if HAS_BED_PROBE float getProbeOffset_mm(const axis_t); - void setProbeOffset_mm(const float&, const axis_t); + void setProbeOffset_mm(const_float_t , const axis_t); #endif #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t); - void setAxisBacklash_mm(const float&, const axis_t); + void setAxisBacklash_mm(const_float_t , const axis_t); float getBacklashCorrection_percent(); - void setBacklashCorrection_percent(const float&); + void setBacklashCorrection_percent(const_float_t ); #ifdef BACKLASH_SMOOTHING_MM float getBacklashSmoothing_mm(); - void setBacklashSmoothing_mm(const float&); + void setBacklashSmoothing_mm(const_float_t ); #endif #endif @@ -275,7 +275,7 @@ namespace ExtUI { #if HAS_FILAMENT_RUNOUT_DISTANCE float getFilamentRunoutDistance_mm(); - void setFilamentRunoutDistance_mm(const float&); + void setFilamentRunoutDistance_mm(const_float_t ); #endif #endif @@ -285,7 +285,7 @@ namespace ExtUI { #if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) float getCaseLightBrightness_percent(); - void setCaseLightBrightness_percent(const float&); + void setCaseLightBrightness_percent(const_float_t ); #endif #endif @@ -293,16 +293,16 @@ namespace ExtUI { float getPIDValues_Kp(const extruder_t); float getPIDValues_Ki(const extruder_t); float getPIDValues_Kd(const extruder_t); - void setPIDValues(const float&, const float&, const float&, extruder_t); - void startPIDTune(const float&, extruder_t); + void setPIDValues(const_float_t , const_float_t , const_float_t , extruder_t); + void startPIDTune(const_float_t , extruder_t); #endif #if ENABLED(PIDTEMPBED) float getBedPIDValues_Kp(); float getBedPIDValues_Ki(); float getBedPIDValues_Kd(); - void setBedPIDValues(const float&, const float&, const float&); - void startBedPIDTune(const float&); + void setBedPIDValues(const_float_t , const_float_t , const_float_t ); + void startBedPIDTune(const_float_t ); #endif /** diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 57e6fc26e6..24fedb039e 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -501,7 +501,7 @@ public: #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - static void ubl_mesh_edit_start(const float &initial); + static void ubl_mesh_edit_start(const_float_t initial); static float ubl_mesh_value(); #endif diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index add306b6e3..6143e8da1e 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -289,7 +289,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { #if HAS_LINE_TO_Z - void line_to_z(const float &z) { + void line_to_z(const_float_t z) { current_position.z = z; line_to_current_position(manual_feedrate_mm_s.z); } diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index cbef9b50c9..290832c49c 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -40,7 +40,7 @@ typedef void (*selectFunc_t)(); #define SS_DEFAULT SS_CENTER #if HAS_MARLINUI_U8GLIB && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) - void _lcd_zoffset_overlay_gfx(const float zvalue); + void _lcd_zoffset_overlay_gfx(const_float_t zvalue); #endif #if ENABLED(BABYSTEP_ZPROBE_OFFSET) && Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9 @@ -212,11 +212,7 @@ void _lcd_draw_homing(); #define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LEVEL_BED_CORNERS) #if HAS_LINE_TO_Z - void line_to_z(const float &z); -#endif - -#if HAS_MARLINUI_U8GLIB && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) - void _lcd_zoffset_overlay_gfx(const float zvalue); + void line_to_z(const_float_t z); #endif #if ENABLED(PROBE_OFFSET_WIZARD) diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index ef9f2246c2..b857b62de5 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -86,7 +86,7 @@ void _man_probe_pt(const xy_pos_t &xy) { ui.goto_screen(_lcd_calibrate_homing); } - void _goto_tower_a(const float &a) { + void _goto_tower_a(const_float_t a) { xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) }; _man_probe_pt(tower_vec * delta_calibration_radius()); } diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 945a892799..d3ec359fb1 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -77,8 +77,8 @@ template class TMenuEditItem : MenuEditItemBase { private: typedef typename NAME::type_t type_t; - static inline float scale(const float value) { return NAME::scale(value); } - static inline float unscale(const float value) { return NAME::unscale(value); } + static inline float scale(const_float_t value) { return NAME::scale(value); } + static inline float unscale(const_float_t value) { return NAME::unscale(value); } static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); } static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); } public: @@ -114,9 +114,9 @@ class TMenuEditItem : MenuEditItemBase { #define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \ struct MenuEditItemInfo_##NAME { \ typedef TYPE type_t; \ - static inline float scale(const float value) { return value * (SCALE) + (V+0); } \ - static inline float unscale(const float value) { return value / (SCALE) + (V+0); } \ - static inline const char* strfunc(const float value) { return STRFUNC(_DOFIX(TYPE,value)); } \ + static inline float scale(const_float_t value) { return value * (SCALE) + (V+0); } \ + static inline float unscale(const_float_t value) { return value / (SCALE) + (V+0); } \ + static inline const char* strfunc(const_float_t value) { return STRFUNC(_DOFIX(TYPE,value)); } \ }; \ typedef TMenuEditItem MenuItem_##NAME diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 71fc4246c7..dfa7b92a99 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -149,7 +149,7 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); } screenFunc_t _manual_move_func_ptr; -void _goto_manual_move(const float scale) { +void _goto_manual_move(const_float_t scale) { ui.defer_status_screen(); ui.manual_move.menu_scale = scale; ui.goto_screen(_manual_move_func_ptr); diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index 1d62ada327..008db6a8b8 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -58,14 +58,14 @@ inline void z_clearance_move() { ); } -void set_offset_and_go_back(const float &z) { +void set_offset_and_go_back(const_float_t z) { probe.offset.z = z; SET_SOFT_ENDSTOP_LOOSE(false); TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); ui.goto_previous_screen_no_defer(); } -void _goto_manual_move_z(const float scale) { +void _goto_manual_move_z(const_float_t scale) { ui.manual_move.menu_scale = scale; ui.goto_screen(lcd_move_z); } diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 565e6725a7..876c9ae621 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -92,7 +92,7 @@ void _lcd_mesh_fine_tune(PGM_P const msg) { // Init mesh editing and go to the fine tuning screen (ubl.fine_tune_mesh) // To capture encoder events UBL will also call ui.capture and ui.release. // -void MarlinUI::ubl_mesh_edit_start(const float &initial) { +void MarlinUI::ubl_mesh_edit_start(const_float_t initial) { TERN_(HAS_GRAPHICAL_TFT, clear_lcd()); mesh_edit_accumulator = initial; goto_screen([]{ _lcd_mesh_fine_tune(GET_TEXT(MSG_MESH_EDIT_Z)); }); diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index d079e0b4b3..8f71d52ec8 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -368,12 +368,12 @@ void L64XX_Marlin::set_param(const L64XX_axis_t axis, const uint8_t param, const } } -inline void echo_min_max(const char a, const float &min, const float &max) { +inline void echo_min_max(const char a, const_float_t min, const_float_t max) { DEBUG_CHAR(' '); DEBUG_CHAR(a); DEBUG_ECHOPAIR(" min = ", min); DEBUG_ECHOLNPAIR(" max = ", max); } -inline void echo_oct_used(const float &oct, const uint8_t stall) { +inline void echo_oct_used(const_float_t oct, const uint8_t stall) { DEBUG_ECHOPAIR("over_current_threshold used : ", oct); DEBUG_ECHOPGM_P(stall ? PSTR(" (Stall") : PSTR(" (OCD")); DEBUG_ECHOLNPGM(" threshold)"); diff --git a/Marlin/src/libs/least_squares_fit.h b/Marlin/src/libs/least_squares_fit.h index dbbab0a55e..374a1f5ada 100644 --- a/Marlin/src/libs/least_squares_fit.h +++ b/Marlin/src/libs/least_squares_fit.h @@ -47,7 +47,7 @@ inline void incremental_LSF_reset(struct linear_fit_data *lsf) { memset(lsf, 0, sizeof(linear_fit_data)); } -inline void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) { +inline void incremental_WLSF(struct linear_fit_data *lsf, const_float_t x, const_float_t y, const_float_t z, const_float_t w) { // weight each accumulator by factor w, including the "number" of samples // (analogous to calling inc_LSF twice with same values to weight it by 2X) const float wx = w * x, wy = w * y, wz = w * z; @@ -63,11 +63,11 @@ inline void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const lsf->max_absx = _MAX(ABS(wx), lsf->max_absx); lsf->max_absy = _MAX(ABS(wy), lsf->max_absy); } -inline void incremental_WLSF(struct linear_fit_data *lsf, const xy_pos_t &pos, const float &z, const float &w) { +inline void incremental_WLSF(struct linear_fit_data *lsf, const xy_pos_t &pos, const_float_t z, const_float_t w) { incremental_WLSF(lsf, pos.x, pos.y, z, w); } -inline void incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) { +inline void incremental_LSF(struct linear_fit_data *lsf, const_float_t x, const_float_t y, const_float_t z) { lsf->xbar += x; lsf->ybar += y; lsf->zbar += z; @@ -80,7 +80,7 @@ inline void incremental_LSF(struct linear_fit_data *lsf, const float &x, const f lsf->max_absy = _MAX(ABS(y), lsf->max_absy); lsf->N += 1.0; } -inline void incremental_LSF(struct linear_fit_data *lsf, const xy_pos_t &pos, const float &z) { +inline void incremental_LSF(struct linear_fit_data *lsf, const xy_pos_t &pos, const_float_t z) { incremental_LSF(lsf, pos.x, pos.y, z); } diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index c56f45c70b..6918d2fd80 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -130,7 +130,7 @@ Nozzle nozzle; * @param strokes number of strokes to execute * @param radius radius of circle */ - void Nozzle::circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const float &radius) { + void Nozzle::circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const_float_t radius) { if (strokes == 0) return; #if ENABLED(NOZZLE_CLEAN_GOBACK) @@ -158,7 +158,7 @@ Nozzle nozzle; * @param pattern one of the available patterns * @param argument depends on the cleaning pattern */ - void Nozzle::clean(const uint8_t &pattern, const uint8_t &strokes, const float &radius, const uint8_t &objects, const uint8_t cleans) { + void Nozzle::clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) { xyz_pos_t start[HOTENDS] = NOZZLE_CLEAN_START_POINT, end[HOTENDS] = NOZZLE_CLEAN_END_POINT, middle[HOTENDS] = NOZZLE_CLEAN_CIRCLE_MIDDLE; const uint8_t arrPos = ANY(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder; diff --git a/Marlin/src/libs/nozzle.h b/Marlin/src/libs/nozzle.h index 81594b1381..d1706f0b31 100644 --- a/Marlin/src/libs/nozzle.h +++ b/Marlin/src/libs/nozzle.h @@ -62,7 +62,7 @@ class Nozzle { * @param strokes number of strokes to execute * @param radius radius of circle */ - static void circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const float &radius) _Os; + static void circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const_float_t radius) _Os; #endif // NOZZLE_CLEAN_FEATURE @@ -77,7 +77,7 @@ class Nozzle { * @param pattern one of the available patterns * @param argument depends on the cleaning pattern */ - static void clean(const uint8_t &pattern, const uint8_t &strokes, const float &radius, const uint8_t &objects, const uint8_t cleans) _Os; + static void clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) _Os; #endif // NOZZLE_CLEAN_FEATURE diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index 283734faab..1e1ac05710 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -178,7 +178,7 @@ const char* i16tostr4signrj(const int16_t i) { } // Convert unsigned float to string with 1.1 format -const char* ftostr11ns(const float &f) { +const char* ftostr11ns(const_float_t f) { const long i = UINTFLOAT(f, 1); conv[4] = DIGIMOD(i, 10); conv[5] = '.'; @@ -187,7 +187,7 @@ const char* ftostr11ns(const float &f) { } // Convert unsigned float to string with 1.23 format -const char* ftostr12ns(const float &f) { +const char* ftostr12ns(const_float_t f) { const long i = UINTFLOAT(f, 2); conv[3] = DIGIMOD(i, 100); conv[4] = '.'; @@ -197,7 +197,7 @@ const char* ftostr12ns(const float &f) { } // Convert unsigned float to string with 12.3 format -const char* ftostr31ns(const float &f) { +const char* ftostr31ns(const_float_t f) { const long i = UINTFLOAT(f, 1); conv[3] = DIGIMOD(i, 100); conv[4] = DIGIMOD(i, 10); @@ -207,7 +207,7 @@ const char* ftostr31ns(const float &f) { } // Convert unsigned float to string with 123.4 format -const char* ftostr41ns(const float &f) { +const char* ftostr41ns(const_float_t f) { const long i = UINTFLOAT(f, 1); conv[2] = DIGIMOD(i, 1000); conv[3] = DIGIMOD(i, 100); @@ -218,7 +218,7 @@ const char* ftostr41ns(const float &f) { } // Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format -const char* ftostr42_52(const float &f) { +const char* ftostr42_52(const_float_t f) { if (f <= -10 || f >= 100) return ftostr52(f); // -23.45 / 123.45 long i = INTFLOAT(f, 2); conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000)); @@ -230,7 +230,7 @@ const char* ftostr42_52(const float &f) { } // Convert signed float to fixed-length string with 023.45 / -23.45 format -const char* ftostr52(const float &f) { +const char* ftostr52(const_float_t f) { long i = INTFLOAT(f, 2); conv[1] = MINUSOR(i, DIGIMOD(i, 10000)); conv[2] = DIGIMOD(i, 1000); @@ -242,7 +242,7 @@ const char* ftostr52(const float &f) { } // Convert signed float to fixed-length string with 12.345 / _2.345 / -2.345 or -23.45 / 123.45 format -const char* ftostr53_63(const float &f) { +const char* ftostr53_63(const_float_t f) { if (f <= -10 || f >= 100) return ftostr63(f); // -23.456 / 123.456 long i = INTFLOAT(f, 3); conv[1] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 10000)); @@ -255,7 +255,7 @@ const char* ftostr53_63(const float &f) { } // Convert signed float to fixed-length string with 023.456 / -23.456 format -const char* ftostr63(const float &f) { +const char* ftostr63(const_float_t f) { long i = INTFLOAT(f, 3); conv[0] = MINUSOR(i, DIGIMOD(i, 100000)); conv[1] = DIGIMOD(i, 10000); @@ -270,7 +270,7 @@ const char* ftostr63(const float &f) { #if ENABLED(LCD_DECIMAL_SMALL_XY) // Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format - const char* ftostr4sign(const float &f) { + const char* ftostr4sign(const_float_t f) { const int i = INTFLOAT(f, 1); if (!WITHIN(i, -99, 999)) return i16tostr4signrj((int)f); const bool neg = i < 0; @@ -285,7 +285,7 @@ const char* ftostr63(const float &f) { #endif // Convert float to fixed-length string with +12.3 / -12.3 format -const char* ftostr31sign(const float &f) { +const char* ftostr31sign(const_float_t f) { int i = INTFLOAT(f, 1); conv[2] = MINUSOR(i, '+'); conv[3] = DIGIMOD(i, 100); @@ -296,7 +296,7 @@ const char* ftostr31sign(const float &f) { } // Convert float to fixed-length string with +123.4 / -123.4 format -const char* ftostr41sign(const float &f) { +const char* ftostr41sign(const_float_t f) { int i = INTFLOAT(f, 1); conv[1] = MINUSOR(i, '+'); conv[2] = DIGIMOD(i, 1000); @@ -308,7 +308,7 @@ const char* ftostr41sign(const float &f) { } // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format -const char* ftostr43sign(const float &f, char plus/*=' '*/) { +const char* ftostr43sign(const_float_t f, char plus/*=' '*/) { long i = INTFLOAT(f, 3); conv[1] = i ? MINUSOR(i, plus) : ' '; conv[2] = DIGIMOD(i, 1000); @@ -320,7 +320,7 @@ const char* ftostr43sign(const float &f, char plus/*=' '*/) { } // Convert signed float to string (5 digit) with -1.2345 / _0.0000 / +1.2345 format -const char* ftostr54sign(const float &f, char plus/*=' '*/) { +const char* ftostr54sign(const_float_t f, char plus/*=' '*/) { long i = INTFLOAT(f, 4); conv[0] = i ? MINUSOR(i, plus) : ' '; conv[1] = DIGIMOD(i, 10000); @@ -333,13 +333,13 @@ const char* ftostr54sign(const float &f, char plus/*=' '*/) { } // Convert unsigned float to rj string with 12345 format -const char* ftostr5rj(const float &f) { +const char* ftostr5rj(const_float_t f) { const long i = UINTFLOAT(f, 0); return ui16tostr5rj(i); } // Convert signed float to string with +1234.5 format -const char* ftostr51sign(const float &f) { +const char* ftostr51sign(const_float_t f) { long i = INTFLOAT(f, 1); conv[0] = MINUSOR(i, '+'); conv[1] = DIGIMOD(i, 10000); @@ -352,7 +352,7 @@ const char* ftostr51sign(const float &f) { } // Convert signed float to string with +123.45 format -const char* ftostr52sign(const float &f) { +const char* ftostr52sign(const_float_t f) { long i = INTFLOAT(f, 2); conv[0] = MINUSOR(i, '+'); conv[1] = DIGIMOD(i, 10000); @@ -365,7 +365,7 @@ const char* ftostr52sign(const float &f) { } // Convert signed float to string with +12.345 format -const char* ftostr53sign(const float &f) { +const char* ftostr53sign(const_float_t f) { long i = INTFLOAT(f, 3); conv[0] = MINUSOR(i, '+'); conv[1] = DIGIMOD(i, 10000); @@ -378,7 +378,7 @@ const char* ftostr53sign(const float &f) { } // Convert unsigned float to string with ____4.5, __34.5, _234.5, 1234.5 format -const char* ftostr51rj(const float &f) { +const char* ftostr51rj(const_float_t f) { const long i = UINTFLOAT(f, 1); conv[0] = ' '; conv[1] = RJDIGIT(i, 10000); @@ -391,7 +391,7 @@ const char* ftostr51rj(const float &f) { } // Convert signed float to space-padded string with -_23.4_ format -const char* ftostr52sp(const float &f) { +const char* ftostr52sp(const_float_t f) { long i = INTFLOAT(f, 2); uint8_t dig; conv[0] = MINUSOR(i, ' '); diff --git a/Marlin/src/libs/numtostr.h b/Marlin/src/libs/numtostr.h index 54cebab252..b058f3cdf6 100644 --- a/Marlin/src/libs/numtostr.h +++ b/Marlin/src/libs/numtostr.h @@ -21,7 +21,8 @@ */ #pragma once -#include +#include "../inc/MarlinConfigPre.h" +#include "../core/types.h" // Format uint8_t (0-100) as rj string with 123% / _12% / __1% format const char* pcttostrpctrj(const uint8_t i); @@ -62,70 +63,66 @@ const char* i16tostr3left(const int16_t xx); const char* i16tostr4signrj(const int16_t x); // Convert unsigned float to string with 1.2 format -const char* ftostr11ns(const float &x); +const char* ftostr11ns(const_float_t x); // Convert unsigned float to string with 1.23 format -const char* ftostr12ns(const float &x); +const char* ftostr12ns(const_float_t x); // Convert unsigned float to string with 12.3 format -const char* ftostr31ns(const float &x); +const char* ftostr31ns(const_float_t x); // Convert unsigned float to string with 123.4 format -const char* ftostr41ns(const float &x); +const char* ftostr41ns(const_float_t x); // Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format -const char* ftostr42_52(const float &x); +const char* ftostr42_52(const_float_t x); // Convert signed float to fixed-length string with 023.45 / -23.45 format -const char* ftostr52(const float &x); +const char* ftostr52(const_float_t x); // Convert signed float to fixed-length string with 12.345 / -2.345 or 023.456 / -23.456 format -const char* ftostr53_63(const float &x); +const char* ftostr53_63(const_float_t x); // Convert signed float to fixed-length string with 023.456 / -23.456 format -const char* ftostr63(const float &x); +const char* ftostr63(const_float_t x); // Convert float to fixed-length string with +12.3 / -12.3 format -const char* ftostr31sign(const float &x); +const char* ftostr31sign(const_float_t x); // Convert float to fixed-length string with +123.4 / -123.4 format -const char* ftostr41sign(const float &x); +const char* ftostr41sign(const_float_t x); // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format -const char* ftostr43sign(const float &x, char plus=' '); +const char* ftostr43sign(const_float_t x, char plus=' '); // Convert signed float to string (5 digit) with -1.2345 / _0.0000 / +1.2345 format -const char* ftostr54sign(const float &x, char plus=' '); +const char* ftostr54sign(const_float_t x, char plus=' '); // Convert unsigned float to rj string with 12345 format -const char* ftostr5rj(const float &x); +const char* ftostr5rj(const_float_t x); // Convert signed float to string with +1234.5 format -const char* ftostr51sign(const float &x); +const char* ftostr51sign(const_float_t x); // Convert signed float to space-padded string with -_23.4_ format -const char* ftostr52sp(const float &x); +const char* ftostr52sp(const_float_t x); // Convert signed float to string with +123.45 format -const char* ftostr52sign(const float &x); +const char* ftostr52sign(const_float_t x); // Convert signed float to string with +12.345 format -const char* ftostr53sign(const float &f); +const char* ftostr53sign(const_float_t f); // Convert unsigned float to string with 1234.5 format omitting trailing zeros -const char* ftostr51rj(const float &x); - -#include "../core/macros.h" +const char* ftostr51rj(const_float_t x); // Convert float to rj string with 123 or -12 format -FORCE_INLINE const char* ftostr3(const float &x) { return i16tostr3rj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } - -#include "../inc/MarlinConfigPre.h" +FORCE_INLINE const char* ftostr3(const_float_t x) { return i16tostr3rj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } #if ENABLED(LCD_DECIMAL_SMALL_XY) // Convert float to rj string with 1234, _123, 12.3, _1.2, -123, _-12, or -1.2 format - const char* ftostr4sign(const float &fx); + const char* ftostr4sign(const_float_t fx); #else // Convert float to rj string with 1234, _123, -123, __12, _-12, ___1, or __-1 format - FORCE_INLINE const char* ftostr4sign(const float &x) { return i16tostr4signrj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } + FORCE_INLINE const char* ftostr4sign(const_float_t x) { return i16tostr4signrj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } #endif diff --git a/Marlin/src/libs/vector_3.h b/Marlin/src/libs/vector_3.h index 764e10accb..5ce5914961 100644 --- a/Marlin/src/libs/vector_3.h +++ b/Marlin/src/libs/vector_3.h @@ -45,7 +45,7 @@ class matrix_3x3; struct vector_3 : xyz_float_t { - vector_3(const float &_x, const float &_y, const float &_z) { set(_x, _y, _z); } + vector_3(const_float_t _x, const_float_t _y, const_float_t _z) { set(_x, _y, _z); } vector_3(const xy_float_t &in) { set(in.x, in.y); } vector_3(const xyz_float_t &in) { set(in.x, in.y, in.z); } vector_3(const xyze_float_t &in) { set(in.x, in.y, in.z); } diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 2312e1a012..6ba9f4e9f2 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -177,7 +177,7 @@ float delta_safe_distance_from_top() { * * The result is stored in the cartes[] array. */ -void forward_kinematics(const float &z1, const float &z2, const float &z3) { +void forward_kinematics(const_float_t z1, const_float_t z2, const_float_t z3) { // Create a vector in old coordinates along x axis of new coordinate const float p12[3] = { delta_tower[B_AXIS].x - delta_tower[A_AXIS].x, delta_tower[B_AXIS].y - delta_tower[A_AXIS].y, z2 - z1 }, diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index 9caec53028..308e206700 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -120,7 +120,7 @@ float delta_safe_distance_from_top(); * * The result is stored in the cartes[] array. */ -void forward_kinematics(const float &z1, const float &z2, const float &z3); +void forward_kinematics(const_float_t z1, const_float_t z2, const_float_t z3); FORCE_INLINE void forward_kinematics(const abc_float_t &point) { forward_kinematics(point.a, point.b, point.c); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 28ad9cf761..81c3a81fbe 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -311,12 +311,12 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { * Move the planner to the current position from wherever it last moved * (or from wherever it has been told it is located). */ -void line_to_current_position(const feedRate_t &fr_mm_s/*=feedrate_mm_s*/) { +void line_to_current_position(const_feedRate_t fr_mm_s/*=feedrate_mm_s*/) { planner.buffer_line(current_position, fr_mm_s, active_extruder); } #if EXTRUDERS - void unscaled_e_move(const float &length, const feedRate_t &fr_mm_s) { + void unscaled_e_move(const_float_t length, const_feedRate_t fr_mm_s) { TERN_(HAS_FILAMENT_SENSOR, runout.reset()); current_position.e += length / planner.e_factor[active_extruder]; line_to_current_position(fr_mm_s); @@ -329,7 +329,7 @@ void line_to_current_position(const feedRate_t &fr_mm_s/*=feedrate_mm_s*/) { /** * Buffer a fast move without interpolation. Set current_position to destination */ - void prepare_fast_move_to_destination(const feedRate_t &scaled_fr_mm_s/*=MMS_SCALED(feedrate_mm_s)*/) { + void prepare_fast_move_to_destination(const_feedRate_t scaled_fr_mm_s/*=MMS_SCALED(feedrate_mm_s)*/) { if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_fast_move_to_destination", destination); #if UBL_SEGMENTED @@ -351,7 +351,7 @@ void line_to_current_position(const feedRate_t &fr_mm_s/*=feedrate_mm_s*/) { * - Move at normal speed regardless of feedrate percentage. * - Extrude the specified length regardless of flow percentage. */ -void _internal_move_to_destination(const feedRate_t &fr_mm_s/*=0.0f*/ +void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ #if IS_KINEMATIC , const bool is_fast/*=false*/ #endif @@ -384,7 +384,7 @@ void _internal_move_to_destination(const feedRate_t &fr_mm_s/*=0.0f*/ /** * Plan a move to (X, Y, Z) and set the current_position */ -void do_blocking_move_to(const float rx, const float ry, const float rz, const feedRate_t &fr_mm_s/*=0.0*/) { +void do_blocking_move_to(const float rx, const float ry, const float rz, const_feedRate_t fr_mm_s/*=0.0*/) { DEBUG_SECTION(log_move, "do_blocking_move_to", DEBUGGING(LEVELING)); if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", rx, ry, rz); @@ -473,38 +473,38 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f planner.synchronize(); } -void do_blocking_move_to(const xy_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { +void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to(raw.x, raw.y, current_position.z, fr_mm_s); } -void do_blocking_move_to(const xyz_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { +void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s); } -void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { +void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to(raw.x, raw.y, raw.z, fr_mm_s); } -void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s/*=0.0*/) { +void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to(rx, current_position.y, current_position.z, fr_mm_s); } -void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s/*=0.0*/) { +void do_blocking_move_to_y(const_float_t ry, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to(current_position.x, ry, current_position.z, fr_mm_s); } -void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s/*=0.0*/) { +void do_blocking_move_to_z(const_float_t rz, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xy_z(current_position, rz, fr_mm_s); } -void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s/*=0.0*/) { +void do_blocking_move_to_xy(const_float_t rx, const_float_t ry, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to(rx, ry, current_position.z, fr_mm_s); } -void do_blocking_move_to_xy(const xy_pos_t &raw, const feedRate_t &fr_mm_s/*=0.0f*/) { +void do_blocking_move_to_xy(const xy_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to_xy(raw.x, raw.y, fr_mm_s); } -void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRate_t &fr_mm_s/*=0.0f*/) { +void do_blocking_move_to_xy_z(const xy_pos_t &raw, const_float_t z, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to(raw.x, raw.y, z, fr_mm_s); } -void do_z_clearance(const float &zclear, const bool lower_allowed/*=false*/) { +void do_z_clearance(const_float_t zclear, const bool lower_allowed/*=false*/) { float zdest = zclear; if (!lower_allowed) NOLESS(zdest, current_position.z); do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), TERN(HAS_BED_PROBE, z_probe_fast_mm_s, homing_feedrate(Z_AXIS))); @@ -826,7 +826,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { * small incremental moves. This allows the planner to * apply more detailed bed leveling to the full move. */ - inline void segmented_line_to_destination(const feedRate_t &fr_mm_s, const float segment_size=LEVELED_SEGMENT_LENGTH) { + inline void segmented_line_to_destination(const_feedRate_t fr_mm_s, const float segment_size=LEVELED_SEGMENT_LENGTH) { const xyze_float_t diff = destination - current_position; diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 7b8d2f2018..2cfc8406a5 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -229,28 +229,28 @@ void sync_plan_position_e(); * Move the planner to the current position from wherever it last moved * (or from wherever it has been told it is located). */ -void line_to_current_position(const feedRate_t &fr_mm_s=feedrate_mm_s); +void line_to_current_position(const_feedRate_t fr_mm_s=feedrate_mm_s); #if EXTRUDERS - void unscaled_e_move(const float &length, const feedRate_t &fr_mm_s); + void unscaled_e_move(const_float_t length, const_feedRate_t fr_mm_s); #endif void prepare_line_to_destination(); -void _internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f +void _internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f #if IS_KINEMATIC , const bool is_fast=false #endif ); -inline void prepare_internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f) { +inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) { _internal_move_to_destination(fr_mm_s); } #if IS_KINEMATIC - void prepare_fast_move_to_destination(const feedRate_t &scaled_fr_mm_s=MMS_SCALED(feedrate_mm_s)); + void prepare_fast_move_to_destination(const_feedRate_t scaled_fr_mm_s=MMS_SCALED(feedrate_mm_s)); - inline void prepare_internal_fast_move_to_destination(const feedRate_t &fr_mm_s=0.0f) { + inline void prepare_internal_fast_move_to_destination(const_feedRate_t fr_mm_s=0.0f) { _internal_move_to_destination(fr_mm_s, true); } #endif @@ -258,29 +258,29 @@ inline void prepare_internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f) /** * Blocking movement and shorthand functions */ -void do_blocking_move_to(const float rx, const float ry, const float rz, const feedRate_t &fr_mm_s=0.0f); -void do_blocking_move_to(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); -void do_blocking_move_to(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); -void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); +void do_blocking_move_to(const float rx, const float ry, const float rz, const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); -void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s=0.0f); -void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s=0.0f); -void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s=0.0f); +void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to_y(const_float_t ry, const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to_z(const_float_t rz, const_feedRate_t fr_mm_s=0.0f); -void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s=0.0f); -void do_blocking_move_to_xy(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f); -FORCE_INLINE void do_blocking_move_to_xy(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy(xy_pos_t(raw), fr_mm_s); } -FORCE_INLINE void do_blocking_move_to_xy(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy(xy_pos_t(raw), fr_mm_s); } +void do_blocking_move_to_xy(const_float_t rx, const_float_t ry, const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to_xy(const xy_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); +FORCE_INLINE void do_blocking_move_to_xy(const xyz_pos_t &raw, const_feedRate_t fr_mm_s=0.0f) { do_blocking_move_to_xy(xy_pos_t(raw), fr_mm_s); } +FORCE_INLINE void do_blocking_move_to_xy(const xyze_pos_t &raw, const_feedRate_t fr_mm_s=0.0f) { do_blocking_move_to_xy(xy_pos_t(raw), fr_mm_s); } -void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f); -FORCE_INLINE void do_blocking_move_to_xy_z(const xyz_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy_z(xy_pos_t(raw), z, fr_mm_s); } -FORCE_INLINE void do_blocking_move_to_xy_z(const xyze_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy_z(xy_pos_t(raw), z, fr_mm_s); } +void do_blocking_move_to_xy_z(const xy_pos_t &raw, const_float_t z, const_feedRate_t fr_mm_s=0.0f); +FORCE_INLINE void do_blocking_move_to_xy_z(const xyz_pos_t &raw, const_float_t z, const_feedRate_t fr_mm_s=0.0f) { do_blocking_move_to_xy_z(xy_pos_t(raw), z, fr_mm_s); } +FORCE_INLINE void do_blocking_move_to_xy_z(const xyze_pos_t &raw, const_float_t z, const_feedRate_t fr_mm_s=0.0f) { do_blocking_move_to_xy_z(xy_pos_t(raw), z, fr_mm_s); } void remember_feedrate_and_scaling(); void remember_feedrate_scaling_off(); void restore_feedrate_and_scaling(); -void do_z_clearance(const float &zclear, const bool lower_allowed=false); +void do_z_clearance(const_float_t zclear, const bool lower_allowed=false); /** * Homing and Trusted Axes @@ -393,7 +393,7 @@ FORCE_INLINE bool all_axes_trusted() { return xyz_bits == #endif // Return true if the given point is within the printable area - inline bool position_is_reachable(const float &rx, const float &ry, const float inset=0) { + inline bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset=0) { #if ENABLED(DELTA) return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + fslop); @@ -428,7 +428,7 @@ FORCE_INLINE bool all_axes_trusted() { return xyz_bits == #else // CARTESIAN // Return true if the given position is within the machine bounds. - inline bool position_is_reachable(const float &rx, const float &ry) { + inline bool position_is_reachable(const_float_t rx, const_float_t ry) { if (!COORDINATE_OKAY(ry, Y_MIN_POS - fslop, Y_MAX_POS + fslop)) return false; #if ENABLED(DUAL_X_CARRIAGE) if (active_extruder) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index eee1a9f269..891f6a7ab0 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -775,7 +775,7 @@ block_t* Planner::get_current_block() { * is not and will not use the block while we modify it, so it is safe to * alter its values. */ -void Planner::calculate_trapezoid_for_block(block_t * const block, const float &entry_factor, const float &exit_factor) { +void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t entry_factor, const_float_t exit_factor) { uint32_t initial_rate = CEIL(block->nominal_rate * entry_factor), final_rate = CEIL(block->nominal_rate * exit_factor); // (steps per second) @@ -1463,7 +1463,7 @@ void Planner::check_axes_activity() { * This is the reciprocal of the circular cross-section area. * Return 1.0 with volumetric off or a diameter of 0.0. */ - inline float calculate_volumetric_multiplier(const float &diameter) { + inline float calculate_volumetric_multiplier(const_float_t diameter) { return (parser.volumetric_enabled && diameter) ? 1.0f / CIRCLE_AREA(diameter * 0.5f) : 1; } @@ -1745,7 +1745,7 @@ bool Planner::_buffer_steps(const xyze_long_t &target #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif - , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters + , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters ) { // Wait for the next available block @@ -1811,7 +1811,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif - , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/ + , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ ) { const int32_t da = target.a - position.a, @@ -2745,11 +2745,11 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ * * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc. */ -bool Planner::buffer_segment(const float &a, const float &b, const float &c, const float &e +bool Planner::buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif - , const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/ + , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ ) { // If we are cleaning, do not accept queuing of movements @@ -2839,9 +2839,9 @@ bool Planner::buffer_segment(const float &a, const float &b, const float &c, con * millimeters - the length of the movement, if known * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) */ -bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters +bool Planner::buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters #if ENABLED(SCARA_FEEDRATE_SCALING) - , const float &inv_duration + , const_float_t inv_duration #endif ) { xyze_pos_t machine = { rx, ry, rz, e }; @@ -2960,7 +2960,7 @@ bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, con * The provided ABC position is in machine units. */ -void Planner::set_machine_position_mm(const float &a, const float &b, const float &c, const float &e) { +void Planner::set_machine_position_mm(const_float_t a, const_float_t b, const_float_t c, const_float_t e) { TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder); TERN_(HAS_POSITION_FLOAT, position_float.set(a, b, c, e)); position.set(LROUND(a * settings.axis_steps_per_mm[A_AXIS]), @@ -2976,7 +2976,7 @@ void Planner::set_machine_position_mm(const float &a, const float &b, const floa stepper.set_position(position); } -void Planner::set_position_mm(const float &rx, const float &ry, const float &rz, const float &e) { +void Planner::set_position_mm(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e) { xyze_pos_t machine = { rx, ry, rz, e }; #if HAS_POSITION_MODIFIERS apply_modifiers(machine, true); @@ -2993,7 +2993,7 @@ void Planner::set_position_mm(const float &rx, const float &ry, const float &rz, /** * Setters for planner position (also setting stepper position). */ -void Planner::set_e_position_mm(const float &e) { +void Planner::set_e_position_mm(const_float_t e) { const uint8_t axis_index = E_AXIS_N(active_extruder); TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 768bf29e2f..6b99c8bcc1 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -491,7 +491,7 @@ class Planner { #if HAS_CLASSIC_JERK static void set_max_jerk(const AxisEnum axis, float inMaxJerkMMS); #else - static inline void set_max_jerk(const AxisEnum, const float&) {} + static inline void set_max_jerk(const AxisEnum, const_float_t ) {} #endif #if EXTRUDERS @@ -541,7 +541,7 @@ class Planner { static void calculate_volumetric_extruder_limits(); #endif - FORCE_INLINE static void set_filament_size(const uint8_t e, const float &v) { + FORCE_INLINE static void set_filament_size(const uint8_t e, const_float_t v) { filament_size[e] = v; if (v > 0) volumetric_area_nominal = CIRCLE_AREA(v * 0.5); //TODO: should it be per extruder // make sure all extruders have some sane value for the filament size @@ -552,7 +552,7 @@ class Planner { #endif #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - FORCE_INLINE static void set_volumetric_extruder_limit(const uint8_t e, const float &v) { + FORCE_INLINE static void set_volumetric_extruder_limit(const uint8_t e, const_float_t v) { volumetric_extruder_limit[e] = v; calculate_volumetric_extruder_limit(e); } @@ -567,7 +567,7 @@ class Planner { * Returns 1.0 if planner.z_fade_height is 0.0. * Returns 0.0 if Z is past the specified 'Fade Height'. */ - static inline float fade_scaling_factor_for_z(const float &rz) { + static inline float fade_scaling_factor_for_z(const_float_t rz) { static float z_fade_factor = 1; if (!z_fade_height) return 1; if (rz >= z_fade_height) return 0; @@ -580,27 +580,27 @@ class Planner { FORCE_INLINE static void force_fade_recalc() { last_fade_z = -999.999f; } - FORCE_INLINE static void set_z_fade_height(const float &zfh) { + FORCE_INLINE static void set_z_fade_height(const_float_t zfh) { z_fade_height = zfh > 0 ? zfh : 0; inverse_z_fade_height = RECIPROCAL(z_fade_height); force_fade_recalc(); } - FORCE_INLINE static bool leveling_active_at_z(const float &rz) { + FORCE_INLINE static bool leveling_active_at_z(const_float_t rz) { return !z_fade_height || rz < z_fade_height; } #else - FORCE_INLINE static float fade_scaling_factor_for_z(const float&) { return 1; } + FORCE_INLINE static float fade_scaling_factor_for_z(const_float_t ) { return 1; } - FORCE_INLINE static bool leveling_active_at_z(const float&) { return true; } + FORCE_INLINE static bool leveling_active_at_z(const_float_t ) { return true; } #endif #if ENABLED(SKEW_CORRECTION) - FORCE_INLINE static void skew(float &cx, float &cy, const float &cz) { + FORCE_INLINE static void skew(float &cx, float &cy, const_float_t cz) { if (COORDINATE_OKAY(cx, X_MIN_POS + 1, X_MAX_POS) && COORDINATE_OKAY(cy, Y_MIN_POS + 1, Y_MAX_POS)) { const float sx = cx - cy * skew_factor.xy - cz * (skew_factor.xz - (skew_factor.xy * skew_factor.yz)), sy = cy - cz * skew_factor.yz; @@ -611,7 +611,7 @@ class Planner { } FORCE_INLINE static void skew(xyz_pos_t &raw) { skew(raw.x, raw.y, raw.z); } - FORCE_INLINE static void unskew(float &cx, float &cy, const float &cz) { + FORCE_INLINE static void unskew(float &cx, float &cy, const_float_t cz) { if (COORDINATE_OKAY(cx, X_MIN_POS, X_MAX_POS) && COORDINATE_OKAY(cy, Y_MIN_POS, Y_MAX_POS)) { const float sx = cx + cy * skew_factor.xy + cz * skew_factor.xz, sy = cy + cz * skew_factor.yz; @@ -713,7 +713,7 @@ class Planner { #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif - , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters=0.0 + , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ); /** @@ -736,7 +736,7 @@ class Planner { #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif - , feedRate_t fr_mm_s, const uint8_t extruder, const float &millimeters=0.0 + , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ); /** @@ -767,18 +767,18 @@ class Planner { * extruder - target extruder * millimeters - the length of the movement, if known */ - static bool buffer_segment(const float &a, const float &b, const float &c, const float &e + static bool buffer_segment(const_float_t a, const_float_t b, const_float_t c, const_float_t e #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif - , const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0 + , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ); FORCE_INLINE static bool buffer_segment(abce_pos_t &abce #if HAS_DIST_MM_ARG , const xyze_float_t &cart_dist_mm #endif - , const feedRate_t &fr_mm_s, const uint8_t extruder, const float &millimeters=0.0 + , const_feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 ) { return buffer_segment(abce.a, abce.b, abce.c, abce.e #if HAS_DIST_MM_ARG @@ -800,15 +800,15 @@ class Planner { * millimeters - the length of the movement, if known * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) */ - static bool buffer_line(const float &rx, const float &ry, const float &rz, const float &e, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0 + static bool buffer_line(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0 #if ENABLED(SCARA_FEEDRATE_SCALING) - , const float &inv_duration=0.0 + , const_float_t inv_duration=0.0 #endif ); - FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const feedRate_t &fr_mm_s, const uint8_t extruder, const float millimeters=0.0 + FORCE_INLINE static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder, const float millimeters=0.0 #if ENABLED(SCARA_FEEDRATE_SCALING) - , const float &inv_duration=0.0 + , const_float_t inv_duration=0.0 #endif ) { return buffer_line(cart.x, cart.y, cart.z, cart.e, fr_mm_s, extruder, millimeters @@ -835,9 +835,9 @@ class Planner { * * Clears previous speed values. */ - static void set_position_mm(const float &rx, const float &ry, const float &rz, const float &e); + static void set_position_mm(const_float_t rx, const_float_t ry, const_float_t rz, const_float_t e); FORCE_INLINE static void set_position_mm(const xyze_pos_t &cart) { set_position_mm(cart.x, cart.y, cart.z, cart.e); } - static void set_e_position_mm(const float &e); + static void set_e_position_mm(const_float_t e); /** * Set the planner.position and individual stepper positions. @@ -845,7 +845,7 @@ class Planner { * The supplied position is in machine space, and no additional * conversions are applied. */ - static void set_machine_position_mm(const float &a, const float &b, const float &c, const float &e); + static void set_machine_position_mm(const_float_t a, const_float_t b, const_float_t c, const_float_t e); FORCE_INLINE static void set_machine_position_mm(const abce_pos_t &abce) { set_machine_position_mm(abce.a, abce.b, abce.c, abce.e); } /** @@ -957,7 +957,7 @@ class Planner { * Calculate the distance (not time) it takes to accelerate * from initial_rate to target_rate using the given acceleration: */ - static float estimate_acceleration_distance(const float &initial_rate, const float &target_rate, const float &accel) { + static float estimate_acceleration_distance(const_float_t initial_rate, const_float_t target_rate, const_float_t accel) { if (accel == 0) return 0; // accel was 0, set acceleration distance to 0 return (sq(target_rate) - sq(initial_rate)) / (accel * 2); } @@ -970,7 +970,7 @@ class Planner { * This is used to compute the intersection point between acceleration and deceleration * in cases where the "trapezoid" has no plateau (i.e., never reaches maximum speed) */ - static float intersection_distance(const float &initial_rate, const float &final_rate, const float &accel, const float &distance) { + static float intersection_distance(const_float_t initial_rate, const_float_t final_rate, const_float_t accel, const_float_t distance) { if (accel == 0) return 0; // accel was 0, set intersection distance to 0 return (accel * 2 * distance - sq(initial_rate) + sq(final_rate)) / (accel * 4); } @@ -980,7 +980,7 @@ class Planner { * to reach 'target_velocity_sqr' using 'acceleration' within a given * 'distance'. */ - static float max_allowable_speed_sqr(const float &accel, const float &target_velocity_sqr, const float &distance) { + static float max_allowable_speed_sqr(const_float_t accel, const_float_t target_velocity_sqr, const_float_t distance) { return target_velocity_sqr - 2 * accel * distance; } @@ -988,12 +988,12 @@ class Planner { /** * Calculate the speed reached given initial speed, acceleration and distance */ - static float final_speed(const float &initial_velocity, const float &accel, const float &distance) { + static float final_speed(const_float_t initial_velocity, const_float_t accel, const_float_t distance) { return SQRT(sq(initial_velocity) + 2 * accel * distance); } #endif - static void calculate_trapezoid_for_block(block_t * const block, const float &entry_factor, const float &exit_factor); + static void calculate_trapezoid_for_block(block_t * const block, const_float_t entry_factor, const_float_t exit_factor); static void reverse_pass_kernel(block_t * const current, const block_t * const next); static void forward_pass_kernel(const block_t * const previous, block_t * const current, uint8_t block_index); @@ -1013,7 +1013,7 @@ class Planner { vector *= RSQRT(magnitude_sq); } - FORCE_INLINE static float limit_value_by_axis_maximum(const float &max_value, xyze_float_t &unit_vec) { + FORCE_INLINE static float limit_value_by_axis_maximum(const_float_t max_value, xyze_float_t &unit_vec) { float limit_value = max_value; LOOP_XYZE(idx) { if (unit_vec[idx]) { diff --git a/Marlin/src/module/planner_bezier.cpp b/Marlin/src/module/planner_bezier.cpp index 02d878d5f5..be5ce4bbb4 100644 --- a/Marlin/src/module/planner_bezier.cpp +++ b/Marlin/src/module/planner_bezier.cpp @@ -43,7 +43,7 @@ #define SIGMA 0.1f // Compute the linear interpolation between two real numbers. -static inline float interp(const float &a, const float &b, const float &t) { return (1 - t) * a + t * b; } +static inline float interp(const_float_t a, const_float_t b, const_float_t t) { return (1 - t) * a + t * b; } /** * Compute a Bézier curve using the De Casteljau's algorithm (see @@ -51,7 +51,7 @@ static inline float interp(const float &a, const float &b, const float &t) { ret * easy to code and has good numerical stability (very important, * since Arudino works with limited precision real numbers). */ -static inline float eval_bezier(const float &a, const float &b, const float &c, const float &d, const float &t) { +static inline float eval_bezier(const_float_t a, const_float_t b, const_float_t c, const_float_t d, const_float_t t) { const float iab = interp(a, b, t), ibc = interp(b, c, t), icd = interp(c, d, t), @@ -64,7 +64,7 @@ static inline float eval_bezier(const float &a, const float &b, const float &c, * We approximate Euclidean distance with the sum of the coordinates * offset (so-called "norm 1"), which is quicker to compute. */ -static inline float dist1(const float &x1, const float &y1, const float &x2, const float &y2) { return ABS(x1 - x2) + ABS(y1 - y2); } +static inline float dist1(const_float_t x1, const_float_t y1, const_float_t x2, const_float_t y2) { return ABS(x1 - x2) + ABS(y1 - y2); } /** * The algorithm for computing the step is loosely based on the one in Kig @@ -109,7 +109,7 @@ void cubic_b_spline( const xyze_pos_t &position, // current position const xyze_pos_t &target, // target position const xy_pos_t (&offsets)[2], // a pair of offsets - const feedRate_t &scaled_fr_mm_s, // mm/s scaled by feedrate % + const_feedRate_t scaled_fr_mm_s, // mm/s scaled by feedrate % const uint8_t extruder ) { // Absolute first and second control points are recovered. diff --git a/Marlin/src/module/planner_bezier.h b/Marlin/src/module/planner_bezier.h index 72048c4273..eb48cf5e1a 100644 --- a/Marlin/src/module/planner_bezier.h +++ b/Marlin/src/module/planner_bezier.h @@ -33,6 +33,6 @@ void cubic_b_spline( const xyze_pos_t &position, // current position const xyze_pos_t &target, // target position const xy_pos_t (&offsets)[2], // a pair of offsets - const feedRate_t &scaled_fr_mm_s, // mm/s scaled by feedrate % + const_feedRate_t scaled_fr_mm_s, // mm/s scaled by feedrate % const uint8_t extruder ); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 28c89e7a00..d4b8409efa 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -475,7 +475,7 @@ bool Probe::set_deployed(const bool deploy) { * * @return TRUE if the probe failed to trigger. */ -bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { +bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { DEBUG_SECTION(log_probe, "Probe::probe_down_to_z", DEBUGGING(LEVELING)); #if BOTH(HAS_HEATED_BED, WAIT_FOR_BED_HEATER) @@ -588,7 +588,7 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) { float Probe::run_z_probe(const bool sanity_check/*=true*/) { DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING)); - auto try_to_probe = [&](PGM_P const plbl, const float &z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck, const float clearance) -> bool { + auto try_to_probe = [&](PGM_P const plbl, const_float_t z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck, const float clearance) -> bool { // Tare the probe, if supported if (TERN0(PROBE_TARE, tare())) return true; @@ -743,7 +743,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { * - Raise to the BETWEEN height * - Return the probed Z position */ -float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/, const bool sanity_check/*=true*/) { +float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/, const bool sanity_check/*=true*/) { DEBUG_SECTION(log_probe, "Probe::probe_at_point", DEBUGGING(LEVELING)); if (DEBUGGING(LEVELING)) { diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index b54bf00f00..d8272c31b6 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -71,12 +71,12 @@ public: #if HAS_PROBE_XY_OFFSET // Return true if the both nozzle and the probe can reach the given point. // Note: This won't work on SCARA since the probe offset rotates with the arm. - static bool can_reach(const float &rx, const float &ry) { + static bool can_reach(const_float_t rx, const_float_t ry) { return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) // The nozzle can go where it needs to go? && position_is_reachable(rx, ry, ABS(PROBING_MARGIN)); // Can the nozzle also go near there? } #else - static bool can_reach(const float &rx, const float &ry) { + static bool can_reach(const_float_t rx, const_float_t ry) { return position_is_reachable(rx, ry, PROBING_MARGIN); } #endif @@ -90,7 +90,7 @@ public: * Example: For a probe offset of -10,+10, then for the probe to reach 0,0 the * nozzle must be be able to reach +10,-10. */ - static bool can_reach(const float &rx, const float &ry) { + static bool can_reach(const_float_t rx, const_float_t ry) { return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) && COORDINATE_OKAY(rx, min_x() - fslop, max_x() + fslop) && COORDINATE_OKAY(ry, min_y() - fslop, max_y() + fslop); @@ -103,7 +103,7 @@ public: do_z_clearance(Z_AFTER_PROBING, true); // Move down still permitted #endif } - static float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true); + static float probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true); static float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true) { return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative, sanity_check); } @@ -114,7 +114,7 @@ public: static bool set_deployed(const bool) { return false; } - static bool can_reach(const float &rx, const float &ry) { return position_is_reachable(rx, ry); } + static bool can_reach(const_float_t rx, const_float_t ry) { return position_is_reachable(rx, ry); } #endif @@ -257,7 +257,7 @@ public: #endif private: - static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s); + static bool probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s); static void do_z_raise(const float z_raise); static float run_z_probe(const bool sanity_check=true); }; diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index 1767e230c1..d02136039a 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -48,7 +48,7 @@ float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SE * Maths and first version by QHARLEY. * Integrated into Marlin and slightly restructured by Joachim Cerny. */ - void forward_kinematics(const float &a, const float &b) { + void forward_kinematics(const_float_t a, const_float_t b) { const float a_sin = sin(RADIANS(a)) * L1, a_cos = cos(RADIANS(a)) * L1, b_sin = sin(RADIANS(b + TERN0(MP_SCARA, a))) * L2, @@ -197,7 +197,7 @@ float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SE } // Convert ABC inputs in degrees to XYZ outputs in mm - void forward_kinematics(const float &a, const float &b, const float &c) { + void forward_kinematics(const_float_t a, const_float_t b, const_float_t c) { const float w = c - b, r = L1 * cos(RADIANS(b)) + L2 * sin(RADIANS(w - (90 - b))), x = r * cos(RADIANS(a)), diff --git a/Marlin/src/module/scara.h b/Marlin/src/module/scara.h index d24a4110fd..8ce50e55e1 100644 --- a/Marlin/src/module/scara.h +++ b/Marlin/src/module/scara.h @@ -35,7 +35,7 @@ extern float segments_per_second; L1_2 = sq(float(L1)), L1_2_2 = 2.0 * L1_2, L2_2 = sq(float(L2)); - void forward_kinematics(const float &a, const float &b, const float &c); + void forward_kinematics(const_float_t a, const_float_t b, const_float_t c); void home_TPARA(); #else @@ -44,7 +44,7 @@ extern float segments_per_second; L1_2 = sq(float(L1)), L1_2_2 = 2.0 * L1_2, L2_2 = sq(float(L2)); - void forward_kinematics(const float &a, const float &b); + void forward_kinematics(const_float_t a, const_float_t b); #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 5a8704d3ba..02fe7588d9 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -499,7 +499,7 @@ volatile bool Temperature::raw_temps_ready = false; * Needs sufficient heater power to make some overshoot at target * temperature to succeed. */ - void Temperature::PID_autotune(const float &target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) { + void Temperature::PID_autotune(const_float_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) { float current_temp = 0.0; int cycles = 0; bool heating = true; @@ -2336,7 +2336,7 @@ void Temperature::init() { * * TODO: Embed the last 3 parameters during init, if not less optimal */ - void Temperature::tr_state_machine_t::run(const float ¤t, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) { + void Temperature::tr_state_machine_t::run(const_float_t current, const_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) { #if HEATER_IDLE_HANDLER // Convert the given heater_id_t to an idle array index @@ -3371,7 +3371,7 @@ void Temperature::tick() { #include "../gcode/gcode.h" - static void print_heater_state(const float &c, const float &t + static void print_heater_state(const_float_t c, const_float_t t #if ENABLED(SHOW_TEMP_ADC_VALUES) , const float r #endif @@ -3804,7 +3804,7 @@ void Temperature::tick() { #define MIN_DELTA_SLOPE_TIME_PROBE 600 #endif - bool Temperature::wait_for_probe(const float target_temp, bool no_wait_for_cooling/*=true*/) { + bool Temperature::wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling/*=true*/) { const bool wants_to_cool = isProbeAboveTemp(target_temp); const bool will_wait = !(wants_to_cool && no_wait_for_cooling); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index ec603b5217..92e436c73f 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -688,7 +688,7 @@ class Temperature { return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS; } - FORCE_INLINE static bool degHotendNear(const uint8_t e, const float &temp) { + FORCE_INLINE static bool degHotendNear(const uint8_t e, const_float_t temp) { return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS); } @@ -724,7 +724,7 @@ class Temperature { static void wait_for_bed_heating(); - FORCE_INLINE static bool degBedNear(const float &temp) { + FORCE_INLINE static bool degBedNear(const_float_t temp) { return ABS(degBed() - temp) < (TEMP_BED_HYSTERESIS); } @@ -735,9 +735,9 @@ class Temperature { FORCE_INLINE static int16_t rawProbeTemp() { return temp_probe.raw; } #endif FORCE_INLINE static float degProbe() { return temp_probe.celsius; } - FORCE_INLINE static bool isProbeBelowTemp(const float target_temp) { return temp_probe.celsius < target_temp; } - FORCE_INLINE static bool isProbeAboveTemp(const float target_temp) { return temp_probe.celsius > target_temp; } - static bool wait_for_probe(const float target_temp, bool no_wait_for_cooling=true); + FORCE_INLINE static bool isProbeBelowTemp(const_float_t target_temp) { return temp_probe.celsius < target_temp; } + FORCE_INLINE static bool isProbeAboveTemp(const_float_t target_temp) { return temp_probe.celsius > target_temp; } + static bool wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling=true); #endif #if WATCH_PROBE @@ -825,7 +825,7 @@ class Temperature { static bool pid_debug_flag; #endif - static void PID_autotune(const float &target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false); + static void PID_autotune(const_float_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false); #if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING) static bool adaptive_fan_slowing; @@ -959,7 +959,7 @@ class Temperature { millis_t timer = 0; TRState state = TRInactive; float running_temp; - void run(const float ¤t, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc); + void run(const_float_t current, const_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc); } tr_state_machine_t; static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY]; From 05b39623b0490f0c49593b10bcc04d4b0f10851d Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Thu, 1 Apr 2021 19:05:02 -0400 Subject: [PATCH 148/311] Board IDs for G2560 Rev B, G2560 v4, GTM32 VD (#21499) --- Marlin/src/core/boards.h | 25 +++++++++-------- Marlin/src/pins/mega/pins_GT2560_REV_B.h | 30 +++++++++++++++++++++ Marlin/src/pins/mega/pins_GT2560_V3.h | 6 +++-- Marlin/src/pins/mega/pins_GT2560_V4.h | 30 +++++++++++++++++++++ Marlin/src/pins/pins.h | 6 +++++ Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h | 8 ++++-- Marlin/src/pins/stm32f1/pins_GTM32_PRO_VD.h | 30 +++++++++++++++++++++ 7 files changed, 120 insertions(+), 15 deletions(-) create mode 100644 Marlin/src/pins/mega/pins_GT2560_REV_B.h create mode 100644 Marlin/src/pins/mega/pins_GT2560_V4.h create mode 100644 Marlin/src/pins/stm32f1/pins_GTM32_PRO_VD.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index a7ee18d6eb..d2e2236a14 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -146,17 +146,19 @@ #define BOARD_ELEFU_3 1311 // Elefu Ra Board (v3) #define BOARD_LEAPFROG 1312 // Leapfrog #define BOARD_MEGACONTROLLER 1313 // Mega controller -#define BOARD_GT2560_REV_A 1314 // Geeetech GT2560 Rev. A -#define BOARD_GT2560_REV_A_PLUS 1315 // Geeetech GT2560 Rev. A+ (with auto level probe) -#define BOARD_GT2560_V3 1316 // Geeetech GT2560 Rev B for A10(M/D) -#define BOARD_GT2560_V3_MC2 1317 // Geeetech GT2560 Rev B for Mecreator2 -#define BOARD_GT2560_V3_A20 1318 // Geeetech GT2560 Rev B for A20(M/D) -#define BOARD_EINSTART_S 1319 // Einstart retrofit -#define BOARD_WANHAO_ONEPLUS 1320 // Wanhao 0ne+ i3 Mini -#define BOARD_LEAPFROG_XEED2015 1321 // Leapfrog Xeed 2015 -#define BOARD_PICA_REVB 1322 // PICA Shield (original version) -#define BOARD_PICA 1323 // PICA Shield (rev C or later) -#define BOARD_INTAMSYS40 1324 // Intamsys 4.0 (Funmat HT) +#define BOARD_GT2560_REV_A 1314 // Geeetech GT2560 Rev A +#define BOARD_GT2560_REV_A_PLUS 1315 // Geeetech GT2560 Rev A+ (with auto level probe) +#define BOARD_GT2560_REV_B 1316 // Geeetech GT2560 Rev B +#define BOARD_GT2560_V3 1317 // Geeetech GT2560 Rev B for A10(M/D) +#define BOARD_GT2560_V4 1318 // Geeetech GT2560 Rev B for A10(M/D) +#define BOARD_GT2560_V3_MC2 1319 // Geeetech GT2560 Rev B for Mecreator2 +#define BOARD_GT2560_V3_A20 1320 // Geeetech GT2560 Rev B for A20(M/D) +#define BOARD_EINSTART_S 1321 // Einstart retrofit +#define BOARD_WANHAO_ONEPLUS 1322 // Wanhao 0ne+ i3 Mini +#define BOARD_LEAPFROG_XEED2015 1323 // Leapfrog Xeed 2015 +#define BOARD_PICA_REVB 1324 // PICA Shield (original version) +#define BOARD_PICA 1325 // PICA Shield (rev C or later) +#define BOARD_INTAMSYS40 1326 // Intamsys 4.0 (Funmat HT) // // ATmega1281, ATmega2561 @@ -341,6 +343,7 @@ #define BOARD_FLSUN_HISPEED 4046 // FLSUN HiSpeedV1 (STM32F103VET6) #define BOARD_BEAST 4047 // STM32F103RET6 Libmaple-based controller #define BOARD_MINGDA_MPX_ARM_MINI 4048 // STM32F103ZET6 Mingda MD-16 +#define BOARD_GTM32_PRO_VD 4049 // STM32F103VET6 controller // // ARM Cortex-M4F diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_B.h b/Marlin/src/pins/mega/pins_GT2560_REV_B.h new file mode 100644 index 0000000000..be71ec4902 --- /dev/null +++ b/Marlin/src/pins/mega/pins_GT2560_REV_B.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Geeetech GT2560 Rev B Pins + */ + +#define BOARD_INFO_NAME "GT2560 Rev B" + +#include "pins_GT2560_V3.h" diff --git a/Marlin/src/pins/mega/pins_GT2560_V3.h b/Marlin/src/pins/mega/pins_GT2560_V3.h index dd2d1d0f65..8490d5571d 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3.h @@ -22,14 +22,16 @@ #pragma once /** - * Geeetech GT2560 RevB + GT2560 3.0/3.1 + GT2560 4.0/4.1 pin assignments + * Geeetech GT2560 3.0/3.1 pin assignments + * + * Also GT2560 RevB and GT2560 4.0/4.1 */ #define ALLOW_MEGA1280 #include "env_validate.h" #ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "GT2560 RevB/3.x/4.x" + #define BOARD_INFO_NAME "GT2560 3.x" #endif // diff --git a/Marlin/src/pins/mega/pins_GT2560_V4.h b/Marlin/src/pins/mega/pins_GT2560_V4.h new file mode 100644 index 0000000000..6ac07b70bf --- /dev/null +++ b/Marlin/src/pins/mega/pins_GT2560_V4.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Geeetech GT2560 V4.X Pins + */ + +#define BOARD_INFO_NAME "GT2560 4.x" + +#include "pins_GT2560_V3.h" diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 35bfb266eb..e4c692a3b9 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -244,6 +244,10 @@ #include "mega/pins_GT2560_REV_A_PLUS.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(GT2560_V3) #include "mega/pins_GT2560_V3.h" // ATmega2560 env:mega2560 +#elif MB(GT2560_REV_B) + #include "mega/pins_GT2560_REV_B.h" // ATmega2560 env:mega2560 +#elif MB(GT2560_V4) + #include "mega/pins_GT2560_V4.h" // ATmega2560 env:mega2560 #elif MB(GT2560_V3_MC2) #include "mega/pins_GT2560_V3_MC2.h" // ATmega2560 env:mega2560 #elif MB(GT2560_V3_A20) @@ -470,6 +474,8 @@ #include "stm32f1/pins_STM3R_MINI.h" // STM32F1 env:STM32F103RE #elif MB(GTM32_PRO_VB) #include "stm32f1/pins_GTM32_PRO_VB.h" // STM32F1 env:STM32F103RE +#elif MB(GTM32_PRO_VD) + #include "stm32f1/pins_GTM32_PRO_VD.h" // STM32F1 env:STM32F103RE #elif MB(GTM32_MINI) #include "stm32f1/pins_GTM32_MINI.h" // STM32F1 env:STM32F103RE #elif MB(GTM32_MINI_A30) diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index 18156fc0ff..2545642bae 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -22,13 +22,17 @@ #pragma once /** - * Geeetech GTM32 Pro VB/VD board pin assignments + * Geeetech GTM32 Pro VB board pin assignments * http://www.geeetech.com/wiki/index.php/File:Hardware_GTM32_PRO_VB.pdf + * + * Also applies to GTM32 Pro VD */ #include "env_validate.h" -#define BOARD_INFO_NAME "GTM32 Pro VB/VD" +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "GTM32 Pro VB" +#endif #define DEFAULT_MACHINE_NAME "STM32F103VET6" #define BOARD_NO_NATIVE_USB diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VD.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VD.h new file mode 100644 index 0000000000..fb8c73c45f --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VD.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Geeetech GTM32 Pro VD board pin assignments + */ + +#define BOARD_INFO_NAME "GTM32 Pro VD" + +#include "pins_GTM32_PRO_VB.h" From 45c1432946547cef4cbe9ac832394ff68526687d Mon Sep 17 00:00:00 2001 From: Marcio T Date: Thu, 1 Apr 2021 18:12:00 -0600 Subject: [PATCH 149/311] G26 Hilbert Curve followup (#21480) --- Marlin/src/core/utility.h | 2 +- Marlin/src/feature/bedlevel/abl/abl.cpp | 38 +- Marlin/src/feature/bedlevel/hilbert_curve.cpp | 8 +- .../bedlevel/mbl/mesh_bed_leveling.cpp | 8 +- .../feature/bedlevel/mbl/mesh_bed_leveling.h | 14 +- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 4 +- Marlin/src/feature/bedlevel/ubl/ubl.h | 46 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 8 +- .../src/feature/bedlevel/ubl/ubl_motion.cpp | 4 +- Marlin/src/gcode/bedlevel/G26.cpp | 667 +++++++++--------- Marlin/src/gcode/bedlevel/M420.cpp | 4 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 6 +- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 10 +- Marlin/src/inc/Conditionals_post.h | 5 + Marlin/src/inc/SanityCheck.h | 6 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 2 +- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 2 +- .../screens/bed_mesh_screen.cpp | 10 +- Marlin/src/lcd/extui/ui_api.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_leveling.cpp | 4 +- Marlin/src/lcd/menu/menu_ubl.cpp | 4 +- Marlin/src/lcd/tft/ui_320x240.cpp | 14 +- Marlin/src/lcd/tft/ui_480x320.cpp | 14 +- Marlin/src/module/settings.cpp | 4 +- 24 files changed, 442 insertions(+), 444 deletions(-) diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index 645a4be807..aaa241d460 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -34,7 +34,7 @@ void safe_delay(millis_t ms); inline void serial_delay(const millis_t) {} #endif -#if GRID_MAX_POINTS_X && GRID_MAX_POINTS_Y +#if (GRID_MAX_POINTS_X) && (GRID_MAX_POINTS_Y) // 16x16 bit arrays template diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index bc3aedb2f4..7390656563 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -85,9 +85,9 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t //#define EXTRAPOLATE_FROM_EDGE #if ENABLED(EXTRAPOLATE_FROM_EDGE) - #if GRID_MAX_POINTS_X < GRID_MAX_POINTS_Y + #if (GRID_MAX_POINTS_X) < (GRID_MAX_POINTS_Y) #define HALF_IN_X - #elif GRID_MAX_POINTS_Y < GRID_MAX_POINTS_X + #elif (GRID_MAX_POINTS_Y) < (GRID_MAX_POINTS_X) #define HALF_IN_Y #endif #endif @@ -98,23 +98,23 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t */ void extrapolate_unprobed_bed_level() { #ifdef HALF_IN_X - constexpr uint8_t ctrx2 = 0, xlen = GRID_MAX_POINTS_X - 1; + constexpr uint8_t ctrx2 = 0, xend = GRID_MAX_POINTS_X - 1; #else - constexpr uint8_t ctrx1 = (GRID_MAX_POINTS_X - 1) / 2, // left-of-center - ctrx2 = (GRID_MAX_POINTS_X) / 2, // right-of-center - xlen = ctrx1; + constexpr uint8_t ctrx1 = (GRID_MAX_CELLS_X) / 2, // left-of-center + ctrx2 = (GRID_MAX_POINTS_X) / 2, // right-of-center + xend = ctrx1; #endif #ifdef HALF_IN_Y - constexpr uint8_t ctry2 = 0, ylen = GRID_MAX_POINTS_Y - 1; + constexpr uint8_t ctry2 = 0, yend = GRID_MAX_POINTS_Y - 1; #else - constexpr uint8_t ctry1 = (GRID_MAX_POINTS_Y - 1) / 2, // top-of-center - ctry2 = (GRID_MAX_POINTS_Y) / 2, // bottom-of-center - ylen = ctry1; + constexpr uint8_t ctry1 = (GRID_MAX_CELLS_Y) / 2, // top-of-center + ctry2 = (GRID_MAX_POINTS_Y) / 2, // bottom-of-center + yend = ctry1; #endif - LOOP_LE_N(xo, xlen) - LOOP_LE_N(yo, ylen) { + LOOP_LE_N(xo, xend) + LOOP_LE_N(yo, yend) { uint8_t x2 = ctrx2 + xo, y2 = ctry2 + yo; #ifndef HALF_IN_X const uint8_t x1 = ctrx1 - xo; @@ -143,8 +143,8 @@ void print_bilinear_leveling_grid() { #if ENABLED(ABL_BILINEAR_SUBDIVISION) - #define ABL_GRID_POINTS_VIRT_X (GRID_MAX_POINTS_X - 1) * (BILINEAR_SUBDIVISIONS) + 1 - #define ABL_GRID_POINTS_VIRT_Y (GRID_MAX_POINTS_Y - 1) * (BILINEAR_SUBDIVISIONS) + 1 + #define ABL_GRID_POINTS_VIRT_X GRID_MAX_CELLS_X * (BILINEAR_SUBDIVISIONS) + 1 + #define ABL_GRID_POINTS_VIRT_Y GRID_MAX_CELLS_Y * (BILINEAR_SUBDIVISIONS) + 1 #define ABL_TEMP_POINTS_X (GRID_MAX_POINTS_X + 2) #define ABL_TEMP_POINTS_Y (GRID_MAX_POINTS_Y + 2) float z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y]; @@ -161,7 +161,7 @@ void print_bilinear_leveling_grid() { #define LINEAR_EXTRAPOLATION(E, I) ((E) * 2 - (I)) float bed_level_virt_coord(const uint8_t x, const uint8_t y) { uint8_t ep = 0, ip = 1; - if (x > GRID_MAX_POINTS_X + 1 || y > GRID_MAX_POINTS_Y + 1) { + if (x > (GRID_MAX_POINTS_X) + 1 || y > (GRID_MAX_POINTS_Y) + 1) { // The requested point requires extrapolating two points beyond the mesh. // These values are only requested for the edges of the mesh, which are always an actual mesh point, // and do not require interpolation. When interpolation is not needed, this "Mesh + 2" point is @@ -171,8 +171,8 @@ void print_bilinear_leveling_grid() { } if (!x || x == ABL_TEMP_POINTS_X - 1) { if (x) { - ep = GRID_MAX_POINTS_X - 1; - ip = GRID_MAX_POINTS_X - 2; + ep = (GRID_MAX_POINTS_X) - 1; + ip = GRID_MAX_CELLS_X - 1; } if (WITHIN(y, 1, ABL_TEMP_POINTS_Y - 2)) return LINEAR_EXTRAPOLATION( @@ -187,8 +187,8 @@ void print_bilinear_leveling_grid() { } if (!y || y == ABL_TEMP_POINTS_Y - 1) { if (y) { - ep = GRID_MAX_POINTS_Y - 1; - ip = GRID_MAX_POINTS_Y - 2; + ep = (GRID_MAX_POINTS_Y) - 1; + ip = GRID_MAX_CELLS_Y - 1; } if (WITHIN(x, 1, ABL_TEMP_POINTS_X - 2)) return LINEAR_EXTRAPOLATION( diff --git a/Marlin/src/feature/bedlevel/hilbert_curve.cpp b/Marlin/src/feature/bedlevel/hilbert_curve.cpp index 6150226e0b..e4bc3aa618 100644 --- a/Marlin/src/feature/bedlevel/hilbert_curve.cpp +++ b/Marlin/src/feature/bedlevel/hilbert_curve.cpp @@ -36,7 +36,7 @@ constexpr uint8_t dim = _BV(ord); static inline bool eval_candidate(int8_t x, int8_t y, hilbert_curve::callback_ptr func, void *data) { // The print bed likely has fewer points than the full Hilbert // curve, so cull unecessary points - return x < GRID_MAX_POINTS_X && y < GRID_MAX_POINTS_Y ? func(x, y, data) : false; + return x < (GRID_MAX_POINTS_X) && y < (GRID_MAX_POINTS_Y) ? func(x, y, data) : false; } bool hilbert_curve::hilbert(int8_t x, int8_t y, int8_t xi, int8_t xj, int8_t yi, int8_t yj, uint8_t n, hilbert_curve::callback_ptr func, void *data) { @@ -102,10 +102,8 @@ bool hilbert_curve::search_from(uint8_t x, uint8_t y, hilbert_curve::callback_pt */ bool hilbert_curve::search_from_closest(const xy_pos_t &pos, hilbert_curve::callback_ptr func, void *data) { // Find closest grid intersection - uint8_t grid_x = LROUND(float(pos.x - MESH_MIN_X) / MESH_X_DIST); - uint8_t grid_y = LROUND(float(pos.y - MESH_MIN_Y) / MESH_Y_DIST); - LIMIT(grid_x, 0, GRID_MAX_POINTS_X); - LIMIT(grid_y, 0, GRID_MAX_POINTS_Y); + const uint8_t grid_x = LROUND(constrain(float(pos.x - (MESH_MIN_X)) / (MESH_X_DIST), 0, (GRID_MAX_POINTS_X) - 1)); + const uint8_t grid_y = LROUND(constrain(float(pos.y - (MESH_MIN_Y)) / (MESH_Y_DIST), 0, (GRID_MAX_POINTS_Y) - 1)); return search_from(grid_x, grid_y, func, data); } diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp index f51d83f996..51cf28f890 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp @@ -64,10 +64,10 @@ void mesh_bed_leveling::line_to_destination(const_feedRate_t scaled_fr_mm_s, uint8_t x_splits, uint8_t y_splits) { // Get current and destination cells for this line xy_int8_t scel = cell_indexes(current_position), ecel = cell_indexes(destination); - NOMORE(scel.x, GRID_MAX_POINTS_X - 2); - NOMORE(scel.y, GRID_MAX_POINTS_Y - 2); - NOMORE(ecel.x, GRID_MAX_POINTS_X - 2); - NOMORE(ecel.y, GRID_MAX_POINTS_Y - 2); + NOMORE(scel.x, GRID_MAX_CELLS_X - 1); + NOMORE(scel.y, GRID_MAX_CELLS_Y - 1); + NOMORE(ecel.x, GRID_MAX_CELLS_X - 1); + NOMORE(ecel.y, GRID_MAX_CELLS_Y - 1); // Start and end in the same cell? No split needed. if (scel == ecel) { diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index 9932ce9e5c..eadcc28aa4 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -32,8 +32,8 @@ enum MeshLevelingState : char { MeshReset // G29 S5 }; -#define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1)) -#define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1)) +#define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_CELLS_X)) +#define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_CELLS_Y)) #define _GET_MESH_X(I) mbl.index_to_xpos[I] #define _GET_MESH_Y(J) mbl.index_to_ypos[J] #define Z_VALUES_ARR mbl.z_values @@ -61,7 +61,7 @@ public: static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) { px = index % (GRID_MAX_POINTS_X); py = index / (GRID_MAX_POINTS_X); - if (py & 1) px = (GRID_MAX_POINTS_X - 1) - px; // Zig zag + if (py & 1) px = (GRID_MAX_POINTS_X) - 1 - px; // Zig zag } static void set_zigzag_z(const int8_t index, const_float_t z) { @@ -72,11 +72,11 @@ public: static int8_t cell_index_x(const_float_t x) { int8_t cx = (x - (MESH_MIN_X)) * RECIPROCAL(MESH_X_DIST); - return constrain(cx, 0, (GRID_MAX_POINTS_X) - 2); + return constrain(cx, 0, GRID_MAX_CELLS_X - 1); } static int8_t cell_index_y(const_float_t y) { int8_t cy = (y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST); - return constrain(cy, 0, (GRID_MAX_POINTS_Y) - 2); + return constrain(cy, 0, GRID_MAX_CELLS_Y - 1); } static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { return { cell_index_x(x), cell_index_y(y) }; @@ -85,11 +85,11 @@ public: static int8_t probe_index_x(const_float_t x) { int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * RECIPROCAL(MESH_X_DIST); - return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1; + return WITHIN(px, 0, (GRID_MAX_POINTS_X) - 1) ? px : -1; } static int8_t probe_index_y(const_float_t y) { int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * RECIPROCAL(MESH_Y_DIST); - return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1; + return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1; } static inline xy_int8_t probe_indexes(const_float_t x, const_float_t y) { return { probe_index_x(x), probe_index_y(y) }; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 14491bdd81..164d267ceb 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -190,7 +190,7 @@ void unified_bed_leveling::display_map(const int map_type) { const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe.offset_xy); if (!lcd) SERIAL_EOL(); - for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) { + for (int8_t j = (GRID_MAX_POINTS_Y) - 1; j >= 0; j--) { // Row Label (J index) if (human) { @@ -217,7 +217,7 @@ void unified_bed_leveling::display_map(const int map_type) { 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'); + if (csv && i < (GRID_MAX_POINTS_X) - 1) SERIAL_CHAR('\t'); // Closing Brace or Space if (human) SERIAL_CHAR(is_current ? ']' : ' '); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 222e7b0f20..dd6c261341 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -38,8 +38,8 @@ enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP }; struct mesh_index_pair; -#define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1)) -#define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1)) +#define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_CELLS_X)) +#define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_CELLS_Y)) #if ENABLED(OPTIMIZED_MESH_STORAGE) typedef int16_t mesh_store_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; @@ -142,19 +142,19 @@ public: } static int8_t cell_index_x_valid(const_float_t x) { - return WITHIN(cell_index_x_raw(x), 0, (GRID_MAX_POINTS_X - 2)); + return WITHIN(cell_index_x_raw(x), 0, GRID_MAX_CELLS_X - 1); } static int8_t cell_index_y_valid(const_float_t y) { - return WITHIN(cell_index_y_raw(y), 0, (GRID_MAX_POINTS_Y - 2)); + return WITHIN(cell_index_y_raw(y), 0, GRID_MAX_CELLS_Y - 1); } static int8_t cell_index_x(const_float_t x) { - return constrain(cell_index_x_raw(x), 0, (GRID_MAX_POINTS_X) - 2); + return constrain(cell_index_x_raw(x), 0, GRID_MAX_CELLS_X - 1); } static int8_t cell_index_y(const_float_t y) { - return constrain(cell_index_y_raw(y), 0, (GRID_MAX_POINTS_Y) - 2); + return constrain(cell_index_y_raw(y), 0, GRID_MAX_CELLS_Y - 1); } static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { @@ -164,11 +164,11 @@ public: static int8_t closest_x_index(const_float_t x) { const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * RECIPROCAL(MESH_X_DIST); - return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1; + return WITHIN(px, 0, (GRID_MAX_POINTS_X) - 1) ? px : -1; } static int8_t closest_y_index(const_float_t y) { const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * RECIPROCAL(MESH_Y_DIST); - return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1; + return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1; } static inline xy_int8_t closest_indexes(const xy_pos_t &xy) { return { closest_x_index(xy.x), closest_y_index(xy.y) }; @@ -204,10 +204,10 @@ public: * the case where the printer is making a vertical line that only crosses horizontal mesh lines. */ static inline float z_correction_for_x_on_horizontal_mesh_line(const_float_t rx0, const int x1_i, const int yi) { - if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) { + if (!WITHIN(x1_i, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(yi, 0, (GRID_MAX_POINTS_Y) - 1)) { if (DEBUGGING(LEVELING)) { - if (WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("yi"); else DEBUG_ECHOPGM("x1_i"); + if (WITHIN(x1_i, 0, (GRID_MAX_POINTS_X) - 1)) DEBUG_ECHOPGM("yi"); else DEBUG_ECHOPGM("x1_i"); DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0, ",x1_i=", x1_i, ",yi=", yi, ")"); } @@ -218,19 +218,19 @@ public: const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * RECIPROCAL(MESH_X_DIST), z1 = z_values[x1_i][yi]; - return z1 + xratio * (z_values[_MIN(x1_i, GRID_MAX_POINTS_X - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array - // If it is, it is clamped to the last element of the - // z_values[][] array and no correction is applied. + return z1 + xratio * (z_values[_MIN(x1_i, (GRID_MAX_POINTS_X) - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array + // If it is, it is clamped to the last element of the + // z_values[][] array and no correction is applied. } // // See comments above for z_correction_for_x_on_horizontal_mesh_line // static inline float z_correction_for_y_on_vertical_mesh_line(const_float_t ry0, const int xi, const int y1_i) { - if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) { + if (!WITHIN(xi, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(y1_i, 0, (GRID_MAX_POINTS_Y) - 1)) { if (DEBUGGING(LEVELING)) { - if (WITHIN(xi, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("y1_i"); else DEBUG_ECHOPGM("xi"); + if (WITHIN(xi, 0, (GRID_MAX_POINTS_X) - 1)) DEBUG_ECHOPGM("y1_i"); else DEBUG_ECHOPGM("xi"); DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0, ", xi=", xi, ", y1_i=", y1_i, ")"); } @@ -241,9 +241,9 @@ public: const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * RECIPROCAL(MESH_Y_DIST), z1 = z_values[xi][y1_i]; - return z1 + yratio * (z_values[xi][_MIN(y1_i, GRID_MAX_POINTS_Y - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array - // If it is, it is clamped to the last element of the - // z_values[][] array and no correction is applied. + return z1 + yratio * (z_values[xi][_MIN(y1_i, (GRID_MAX_POINTS_Y) - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array + // If it is, it is clamped to the last element of the + // z_values[][] array and no correction is applied. } /** @@ -266,11 +266,11 @@ public: const float z1 = calc_z0(rx0, mesh_index_to_xpos(cx), z_values[cx][cy], - mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, GRID_MAX_POINTS_X - 2) + 1][cy]); + mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1][cy]); const float z2 = calc_z0(rx0, - mesh_index_to_xpos(cx), z_values[cx][_MIN(cy, GRID_MAX_POINTS_Y - 2) + 1], - mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, GRID_MAX_POINTS_X - 2) + 1][_MIN(cy, GRID_MAX_POINTS_Y - 2) + 1]); + mesh_index_to_xpos(cx), z_values[cx][_MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1], + mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1][_MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1]); float z0 = calc_z0(ry0, mesh_index_to_ypos(cy), z1, @@ -302,10 +302,10 @@ public: static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); } static inline float mesh_index_to_xpos(const uint8_t i) { - return i < GRID_MAX_POINTS_X ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST); + return i < (GRID_MAX_POINTS_X) ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST); } static inline float mesh_index_to_ypos(const uint8_t i) { - return i < GRID_MAX_POINTS_Y ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST); + return i < (GRID_MAX_POINTS_Y) ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST); } #if UBL_SEGMENTED diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 545d95676e..9153f369bd 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -433,8 +433,7 @@ void unified_bed_leveling::G29() { SERIAL_DECIMAL(param.XY_pos.y); SERIAL_ECHOLNPGM(").\n"); } - const xy_pos_t near_probe_xy = param.XY_pos + probe.offset_xy; - probe_entire_mesh(near_probe_xy, parser.seen('T'), parser.seen('E'), parser.seen('U')); + probe_entire_mesh(param.XY_pos, parser.seen('T'), parser.seen('E'), parser.seen('U')); report_current_position(); probe_deployed = true; @@ -1140,8 +1139,9 @@ bool unified_bed_leveling::G29_parse_parameters() { } // If X or Y are not valid, use center of the bed values - if (!COORDINATE_OKAY(sx, X_MIN_BED, X_MAX_BED)) sx = X_CENTER; - if (!COORDINATE_OKAY(sy, Y_MIN_BED, Y_MAX_BED)) sy = Y_CENTER; + // (for UBL_HILBERT_CURVE default to lower-left corner instead) + if (!COORDINATE_OKAY(sx, X_MIN_BED, X_MAX_BED)) sx = TERN(UBL_HILBERT_CURVE, 0, X_CENTER); + if (!COORDINATE_OKAY(sy, Y_MIN_BED, Y_MAX_BED)) sy = TERN(UBL_HILBERT_CURVE, 0, Y_CENTER); if (err_flag) return UBL_ERR; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 4e522210d0..3ebc5fc2bd 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -397,8 +397,8 @@ int8_t((raw.x - (MESH_MIN_X)) * RECIPROCAL(MESH_X_DIST)), int8_t((raw.y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST)) }; - LIMIT(icell.x, 0, (GRID_MAX_POINTS_X) - 1); - LIMIT(icell.y, 0, (GRID_MAX_POINTS_Y) - 1); + LIMIT(icell.x, 0, GRID_MAX_CELLS_X); + LIMIT(icell.y, 0, GRID_MAX_CELLS_Y); float z_x0y0 = z_values[icell.x ][icell.y ], // z at lower left corner z_x1y0 = z_values[icell.x+1][icell.y ], // z at upper left corner diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index e05336d6c5..f3e9a78178 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -113,6 +113,10 @@ #include "../../module/temperature.h" #include "../../lcd/marlinui.h" +#if ENABLED(UBL_HILBERT_CURVE) + #include "../../feature/bedlevel/hilbert_curve.h" +#endif + #define EXTRUSION_MULTIPLIER 1.0 #define PRIME_LENGTH 10.0 #define OOZE_AMOUNT 0.3 @@ -145,24 +149,9 @@ constexpr float g26_e_axis_feedrate = 0.025; -static MeshFlags circle_flags, horizontal_mesh_line_flags, vertical_mesh_line_flags; +static MeshFlags circle_flags; float g26_random_deviation = 0.0; -static bool g26_retracted = false; // Track the retracted state of the nozzle so mismatched - // retracts/recovers won't result in a bad state. - -float g26_extrusion_multiplier, - g26_retraction_multiplier, - g26_layer_height, - g26_prime_length; - -xy_pos_t g26_xy_pos; // = { 0, 0 } - -int16_t g26_bed_temp, - g26_hotend_temp; - -int8_t g26_prime_flag; - #if HAS_LCD_MENU /** @@ -178,52 +167,17 @@ int8_t g26_prime_flag; #endif -mesh_index_pair find_closest_circle_to_print(const xy_pos_t &pos) { - float closest = 99999.99; - mesh_index_pair out_point; - - out_point.pos = -1; - - GRID_LOOP(i, j) { - if (!circle_flags.marked(i, j)) { - // We found a circle that needs to be printed - const xy_pos_t m = { _GET_MESH_X(i), _GET_MESH_Y(j) }; - - // Get the distance to this intersection - float f = (pos - m).magnitude(); - - // It is possible that we are being called with the values - // to let us find the closest circle to the start position. - // But if this is not the case, add a small weighting to the - // distance calculation to help it choose a better place to continue. - f += (g26_xy_pos - m).magnitude() / 15.0f; - - // Add the specified amount of Random Noise to our search - if (g26_random_deviation > 1.0) f += random(0.0, g26_random_deviation); - - if (f < closest) { - closest = f; // Found a closer un-printed location - out_point.pos.set(i, j); // Save its data - out_point.distance = closest; - } - } - } - circle_flags.mark(out_point); // Mark this location as done. - return out_point; -} - void move_to(const_float_t rx, const_float_t ry, const_float_t z, const_float_t e_delta) { static float last_z = -999.99; const xy_pos_t dest = { rx, ry }; - const bool has_xy_component = dest != current_position; // Check if X or Y is involved in the movement. - const bool has_e_component = e_delta != 0.0; - - destination = current_position; + const bool has_xy_component = dest != current_position, // Check if X or Y is involved in the movement. + has_e_component = e_delta != 0.0; if (z != last_z) { - last_z = destination.z = z; + last_z = z; + destination.set(current_position.x, current_position.y, z, current_position.e); const feedRate_t fr_mm_s = planner.settings.max_feedrate_mm_s[Z_AXIS] * 0.5f; // Use half of the Z_AXIS max feed rate prepare_internal_move_to_destination(fr_mm_s); } @@ -239,241 +193,293 @@ void move_to(const_float_t rx, const_float_t ry, const_float_t z, const_float_t prepare_internal_move_to_destination(fr_mm_s); } -FORCE_INLINE void move_to(const xyz_pos_t &where, const_float_t de) { move_to(where.x, where.y, where.z, de); } +void move_to(const xyz_pos_t &where, const_float_t de) { move_to(where.x, where.y, where.z, de); } -void retract_filament(const xyz_pos_t &where) { - if (!g26_retracted) { // Only retract if we are not already retracted! - g26_retracted = true; - move_to(where, -1.0f * g26_retraction_multiplier); - } -} +typedef struct { + float extrusion_multiplier = EXTRUSION_MULTIPLIER, + retraction_multiplier = G26_RETRACT_MULTIPLIER, + layer_height = MESH_TEST_LAYER_HEIGHT, + prime_length = PRIME_LENGTH; -// TODO: Parameterize the Z lift with a define -void retract_lift_move(const xyz_pos_t &s) { - retract_filament(destination); - move_to(current_position.x, current_position.y, current_position.z + 0.5f, 0.0); // Z lift to minimize scraping - move_to(s.x, s.y, s.z + 0.5f, 0.0); // Get to the starting point with no extrusion while lifted -} + int16_t bed_temp = MESH_TEST_BED_TEMP, + hotend_temp = MESH_TEST_HOTEND_TEMP; -void recover_filament(const xyz_pos_t &where) { - if (g26_retracted) { // Only un-retract if we are retracted. - move_to(where, 1.2f * g26_retraction_multiplier); - g26_retracted = false; - } -} + float nozzle = MESH_TEST_NOZZLE_SIZE, + filament_diameter = DEFAULT_NOMINAL_FILAMENT_DIA, + ooze_amount; // 'O' ... OOZE_AMOUNT -/** - * print_line_from_here_to_there() takes two cartesian coordinates and draws a line from one - * to the other. But there are really three sets of coordinates involved. The first coordinate - * is the present location of the nozzle. We don't necessarily want to print from this location. - * We first need to move the nozzle to the start of line segment where we want to print. Once - * there, we can use the two coordinates supplied to draw the line. - * - * Note: Although we assume the first set of coordinates is the start of the line and the second - * set of coordinates is the end of the line, it does not always work out that way. This function - * optimizes the movement to minimize the travel distance before it can start printing. This saves - * a lot of time and eliminates a lot of nonsensical movement of the nozzle. However, it does - * cause a lot of very little short retracement of th nozzle when it draws the very first line - * segment of a 'circle'. The time this requires is very short and is easily saved by the other - * cases where the optimization comes into play. - */ -void print_line_from_here_to_there(const xyz_pos_t &s, const xyz_pos_t &e) { + bool continue_with_closest, // 'C' + keep_heaters_on; // 'K' - // Distances to the start / end of the line - xy_float_t svec = current_position - s, evec = current_position - e; + xy_pos_t xy_pos; // = { 0, 0 } - const float dist_start = HYPOT2(svec.x, svec.y), - dist_end = HYPOT2(evec.x, evec.y), - line_length = HYPOT(e.x - s.x, e.y - s.y); + int8_t prime_flag = 0; - // If the end point of the line is closer to the nozzle, flip the direction, - // moving from the end to the start. On very small lines the optimization isn't worth it. - if (dist_end < dist_start && (INTERSECTION_CIRCLE_RADIUS) < ABS(line_length)) - return print_line_from_here_to_there(e, s); + bool g26_retracted = false; // Track the retracted state during G26 so mismatched + // retracts/recovers don't result in a bad state. - // Decide whether to retract & lift - if (dist_start > 2.0) retract_lift_move(s); - - move_to(s, 0.0); // Get to the starting point with no extrusion / un-Z lift - - const float e_pos_delta = line_length * g26_e_axis_feedrate * g26_extrusion_multiplier; - - recover_filament(destination); - move_to(e, e_pos_delta); // Get to the ending point with an appropriate amount of extrusion -} - -inline bool look_for_lines_to_connect() { - xyz_pos_t s, e; - s.z = e.z = g26_layer_height; - - GRID_LOOP(i, j) { - - if (TERN0(HAS_LCD_MENU, user_canceled())) return true; - - if (i < (GRID_MAX_POINTS_X)) { // Can't connect to anything farther to the right than GRID_MAX_POINTS_X. - // Already a half circle at the edge of the bed. - - if (circle_flags.marked(i, j) && circle_flags.marked(i + 1, j)) { // Test whether a leftward line can be done - if (!horizontal_mesh_line_flags.marked(i, j)) { - // Two circles need a horizontal line to connect them - s.x = _GET_MESH_X( i ) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // right edge - e.x = _GET_MESH_X(i + 1) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // left edge - - #if HAS_ENDSTOPS - LIMIT(s.x, X_MIN_POS + 1, X_MAX_POS - 1); - s.y = e.y = constrain(_GET_MESH_Y(j), Y_MIN_POS + 1, Y_MAX_POS - 1); - LIMIT(e.x, X_MIN_POS + 1, X_MAX_POS - 1); - #else - s.y = e.y = _GET_MESH_Y(j); - #endif - - if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y)) - print_line_from_here_to_there(s, e); - - horizontal_mesh_line_flags.mark(i, j); // Mark done, even if skipped - } - } - - if (j < (GRID_MAX_POINTS_Y)) { // Can't connect to anything further back than GRID_MAX_POINTS_Y. - // Already a half circle at the edge of the bed. - - if (circle_flags.marked(i, j) && circle_flags.marked(i, j + 1)) { // Test whether a downward line can be done - if (!vertical_mesh_line_flags.marked(i, j)) { - // Two circles that need a vertical line to connect them - s.y = _GET_MESH_Y( j ) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // top edge - e.y = _GET_MESH_Y(j + 1) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // bottom edge - - #if HAS_ENDSTOPS - s.x = e.x = constrain(_GET_MESH_X(i), X_MIN_POS + 1, X_MAX_POS - 1); - LIMIT(s.y, Y_MIN_POS + 1, Y_MAX_POS - 1); - LIMIT(e.y, Y_MIN_POS + 1, Y_MAX_POS - 1); - #else - s.x = e.x = _GET_MESH_X(i); - #endif - - if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y)) - print_line_from_here_to_there(s, e); - - vertical_mesh_line_flags.mark(i, j); // Mark done, even if skipped - } - } - } + void retract_filament(const xyz_pos_t &where) { + if (!g26_retracted) { // Only retract if we are not already retracted! + g26_retracted = true; + move_to(where, -1.0f * retraction_multiplier); } } - return false; -} -/** - * Turn on the bed and nozzle heat and - * wait for them to get up to temperature. - */ -inline bool turn_on_heaters() { - - SERIAL_ECHOLNPGM("Waiting for heatup."); - - #if HAS_HEATED_BED - - if (g26_bed_temp > 25) { - #if HAS_WIRED_LCD - ui.set_status_P(GET_TEXT(MSG_G26_HEATING_BED), 99); - ui.quick_feedback(); - TERN_(HAS_LCD_MENU, ui.capture()); - #endif - thermalManager.setTargetBed(g26_bed_temp); - - // Wait for the temperature to stabilize - if (!thermalManager.wait_for_bed(true - #if G26_CLICK_CAN_CANCEL - , true - #endif - ) - ) return G26_ERR; - } - - #endif // HAS_HEATED_BED - - // Start heating the active nozzle - #if HAS_WIRED_LCD - ui.set_status_P(GET_TEXT(MSG_G26_HEATING_NOZZLE), 99); - ui.quick_feedback(); - #endif - thermalManager.setTargetHotend(g26_hotend_temp, active_extruder); - - // Wait for the temperature to stabilize - if (!thermalManager.wait_for_hotend(active_extruder, true - #if G26_CLICK_CAN_CANCEL - , true - #endif - )) return G26_ERR; - - #if HAS_WIRED_LCD - ui.reset_status(); - ui.quick_feedback(); - #endif - - return G26_OK; -} - -/** - * Prime the nozzle if needed. Return true on error. - */ -inline bool prime_nozzle() { - - const feedRate_t fr_slow_e = planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0f; - #if HAS_LCD_MENU && !HAS_TOUCH_BUTTONS // ui.button_pressed issue with touchscreen - #if ENABLED(PREVENT_LENGTHY_EXTRUDE) - float Total_Prime = 0.0; - #endif - - if (g26_prime_flag == -1) { // The user wants to control how much filament gets purged - ui.capture(); - ui.set_status_P(GET_TEXT(MSG_G26_MANUAL_PRIME), 99); - ui.chirp(); - - destination = current_position; - - recover_filament(destination); // Make sure G26 doesn't think the filament is retracted(). - - while (!ui.button_pressed()) { - ui.chirp(); - destination.e += 0.25; - #if ENABLED(PREVENT_LENGTHY_EXTRUDE) - Total_Prime += 0.25; - if (Total_Prime >= EXTRUDE_MAXLENGTH) { - ui.release(); - return G26_ERR; - } - #endif - prepare_internal_move_to_destination(fr_slow_e); - destination = current_position; - planner.synchronize(); // Without this synchronize, the purge is more consistent, - // but because the planner has a buffer, we won't be able - // to stop as quickly. So we put up with the less smooth - // action to give the user a more responsive 'Stop'. - } - - ui.wait_for_release(); - - ui.set_status_P(GET_TEXT(MSG_G26_PRIME_DONE), 99); - ui.quick_feedback(); - ui.release(); - } - else - #endif - { - #if HAS_WIRED_LCD - ui.set_status_P(GET_TEXT(MSG_G26_FIXED_LENGTH), 99); - ui.quick_feedback(); - #endif - destination = current_position; - destination.e += g26_prime_length; - prepare_internal_move_to_destination(fr_slow_e); - destination.e -= g26_prime_length; + // TODO: Parameterize the Z lift with a define + void retract_lift_move(const xyz_pos_t &s) { retract_filament(destination); + move_to(current_position.x, current_position.y, current_position.z + 0.5f, 0.0f); // Z lift to minimize scraping + move_to(s.x, s.y, s.z + 0.5f, 0.0f); // Get to the starting point with no extrusion while lifted } - return G26_OK; -} + void recover_filament(const xyz_pos_t &where) { + if (g26_retracted) { // Only un-retract if we are retracted. + move_to(where, 1.2f * retraction_multiplier); + g26_retracted = false; + } + } + + /** + * print_line_from_here_to_there() takes two cartesian coordinates and draws a line from one + * to the other. But there are really three sets of coordinates involved. The first coordinate + * is the present location of the nozzle. We don't necessarily want to print from this location. + * We first need to move the nozzle to the start of line segment where we want to print. Once + * there, we can use the two coordinates supplied to draw the line. + * + * Note: Although we assume the first set of coordinates is the start of the line and the second + * set of coordinates is the end of the line, it does not always work out that way. This function + * optimizes the movement to minimize the travel distance before it can start printing. This saves + * a lot of time and eliminates a lot of nonsensical movement of the nozzle. However, it does + * cause a lot of very little short retracement of th nozzle when it draws the very first line + * segment of a 'circle'. The time this requires is very short and is easily saved by the other + * cases where the optimization comes into play. + */ + void print_line_from_here_to_there(const xyz_pos_t &s, const xyz_pos_t &e) { + + // Distances to the start / end of the line + xy_float_t svec = current_position - s, evec = current_position - e; + + const float dist_start = HYPOT2(svec.x, svec.y), + dist_end = HYPOT2(evec.x, evec.y), + line_length = HYPOT(e.x - s.x, e.y - s.y); + + // If the end point of the line is closer to the nozzle, flip the direction, + // moving from the end to the start. On very small lines the optimization isn't worth it. + if (dist_end < dist_start && (INTERSECTION_CIRCLE_RADIUS) < ABS(line_length)) + return print_line_from_here_to_there(e, s); + + // Decide whether to retract & lift + if (dist_start > 2.0) retract_lift_move(s); + + move_to(s, 0.0); // Get to the starting point with no extrusion / un-Z lift + + const float e_pos_delta = line_length * g26_e_axis_feedrate * extrusion_multiplier; + + recover_filament(destination); + move_to(e, e_pos_delta); // Get to the ending point with an appropriate amount of extrusion + } + + void connect_neighbor_with_line(const xy_int8_t &p1, int8_t dx, int8_t dy) { + xy_int8_t p2; + p2.x = p1.x + dx; + p2.y = p1.y + dy; + + if (p2.x < 0 || p2.x >= (GRID_MAX_POINTS_X)) return; + if (p2.y < 0 || p2.y >= (GRID_MAX_POINTS_Y)) return; + + if(circle_flags.marked(p1.x, p1.y) && circle_flags.marked(p2.x, p2.y)) { + xyz_pos_t s, e; + s.x = _GET_MESH_X(p1.x) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dx; + e.x = _GET_MESH_X(p2.x) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dx; + s.y = _GET_MESH_Y(p1.y) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dy; + e.y = _GET_MESH_Y(p2.y) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dy; + s.z = e.z = layer_height; + + #if HAS_ENDSTOPS + LIMIT(s.y, Y_MIN_POS + 1, Y_MAX_POS - 1); + LIMIT(e.y, Y_MIN_POS + 1, Y_MAX_POS - 1); + LIMIT(s.x, X_MIN_POS + 1, X_MAX_POS - 1); + LIMIT(e.x, X_MIN_POS + 1, X_MAX_POS - 1); + #endif + + if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y)) + print_line_from_here_to_there(s, e); + } + } + + /** + * Turn on the bed and nozzle heat and + * wait for them to get up to temperature. + */ + bool turn_on_heaters() { + + SERIAL_ECHOLNPGM("Waiting for heatup."); + + #if HAS_HEATED_BED + + if (bed_temp > 25) { + #if HAS_WIRED_LCD + ui.set_status_P(GET_TEXT(MSG_G26_HEATING_BED), 99); + ui.quick_feedback(); + TERN_(HAS_LCD_MENU, ui.capture()); + #endif + thermalManager.setTargetBed(bed_temp); + + // Wait for the temperature to stabilize + if (!thermalManager.wait_for_bed(true + #if G26_CLICK_CAN_CANCEL + , true + #endif + ) + ) return G26_ERR; + } + + #else + + UNUSED(bed_temp); + + #endif // HAS_HEATED_BED + + // Start heating the active nozzle + #if HAS_WIRED_LCD + ui.set_status_P(GET_TEXT(MSG_G26_HEATING_NOZZLE), 99); + ui.quick_feedback(); + #endif + thermalManager.setTargetHotend(hotend_temp, active_extruder); + + // Wait for the temperature to stabilize + if (!thermalManager.wait_for_hotend(active_extruder, true + #if G26_CLICK_CAN_CANCEL + , true + #endif + )) return G26_ERR; + + #if HAS_WIRED_LCD + ui.reset_status(); + ui.quick_feedback(); + #endif + + return G26_OK; + } + + /** + * Prime the nozzle if needed. Return true on error. + */ + bool prime_nozzle() { + + const feedRate_t fr_slow_e = planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0f; + #if HAS_LCD_MENU && !HAS_TOUCH_BUTTONS // ui.button_pressed issue with touchscreen + #if ENABLED(PREVENT_LENGTHY_EXTRUDE) + float Total_Prime = 0.0; + #endif + + if (prime_flag == -1) { // The user wants to control how much filament gets purged + ui.capture(); + ui.set_status_P(GET_TEXT(MSG_G26_MANUAL_PRIME), 99); + ui.chirp(); + + destination = current_position; + + recover_filament(destination); // Make sure G26 doesn't think the filament is retracted(). + + while (!ui.button_pressed()) { + ui.chirp(); + destination.e += 0.25; + #if ENABLED(PREVENT_LENGTHY_EXTRUDE) + Total_Prime += 0.25; + if (Total_Prime >= EXTRUDE_MAXLENGTH) { + ui.release(); + return G26_ERR; + } + #endif + prepare_internal_move_to_destination(fr_slow_e); + destination = current_position; + planner.synchronize(); // Without this synchronize, the purge is more consistent, + // but because the planner has a buffer, we won't be able + // to stop as quickly. So we put up with the less smooth + // action to give the user a more responsive 'Stop'. + } + + ui.wait_for_release(); + + ui.set_status_P(GET_TEXT(MSG_G26_PRIME_DONE), 99); + ui.quick_feedback(); + ui.release(); + } + else + #endif + { + #if HAS_WIRED_LCD + ui.set_status_P(GET_TEXT(MSG_G26_FIXED_LENGTH), 99); + ui.quick_feedback(); + #endif + destination = current_position; + destination.e += prime_length; + prepare_internal_move_to_destination(fr_slow_e); + destination.e -= prime_length; + retract_filament(destination); + } + + return G26_OK; + } + + /** + * Find the nearest point at which to print a circle + */ + mesh_index_pair find_closest_circle_to_print(const xy_pos_t &pos) { + + mesh_index_pair out_point; + out_point.pos = -1; + + #if ENABLED(UBL_HILBERT_CURVE) + + auto test_func = [](uint8_t i, uint8_t j, void *data) -> bool { + if (!circle_flags.marked(i, j)) { + mesh_index_pair *out_point = (mesh_index_pair*)data; + out_point->pos.set(i, j); // Save its data + return true; + } + return false; + }; + + hilbert_curve::search_from_closest(pos, test_func, &out_point); + + #else + + float closest = 99999.99; + + GRID_LOOP(i, j) { + if (!circle_flags.marked(i, j)) { + // We found a circle that needs to be printed + const xy_pos_t m = { _GET_MESH_X(i), _GET_MESH_Y(j) }; + + // Get the distance to this intersection + float f = (pos - m).magnitude(); + + // It is possible that we are being called with the values + // to let us find the closest circle to the start position. + // But if this is not the case, add a small weighting to the + // distance calculation to help it choose a better place to continue. + f += (xy_pos - m).magnitude() / 15.0f; + + // Add the specified amount of Random Noise to our search + if (g26_random_deviation > 1.0) f += random(0.0, g26_random_deviation); + + if (f < closest) { + closest = f; // Found a closer un-printed location + out_point.pos.set(i, j); // Save its data + out_point.distance = closest; + } + } + } + + #endif + + circle_flags.mark(out_point); // Mark this location as done. + return out_point; + } + +} g26_helper_t; /** * G26: Mesh Validation Pattern generation. @@ -510,20 +516,11 @@ void GcodeSuite::G26() { // Change the tool first, if specified if (parser.seenval('T')) tool_change(parser.value_int()); - g26_extrusion_multiplier = EXTRUSION_MULTIPLIER; - g26_retraction_multiplier = G26_RETRACT_MULTIPLIER; - g26_layer_height = MESH_TEST_LAYER_HEIGHT; - g26_prime_length = PRIME_LENGTH; - g26_bed_temp = MESH_TEST_BED_TEMP; - g26_hotend_temp = MESH_TEST_HOTEND_TEMP; - g26_prime_flag = 0; + g26_helper_t g26; - float g26_nozzle = MESH_TEST_NOZZLE_SIZE, - g26_filament_diameter = DEFAULT_NOMINAL_FILAMENT_DIA, - g26_ooze_amount = parser.linearval('O', OOZE_AMOUNT); - - bool g26_continue_with_closest = parser.boolval('C'), - g26_keep_heaters_on = parser.boolval('K'); + g26.ooze_amount = parser.linearval('O', OOZE_AMOUNT); + g26.continue_with_closest = parser.boolval('C'); + g26.keep_heaters_on = parser.boolval('K'); // Accept 'I' if temperature presets are defined #if PREHEAT_COUNT @@ -548,14 +545,14 @@ void GcodeSuite::G26() { SERIAL_ECHOLNPAIR("?Specified bed temperature not plausible (40-", BED_MAX_TARGET, "C)."); return; } - g26_bed_temp = bedtemp; + g26.bed_temp = bedtemp; } #endif // HAS_HEATED_BED if (parser.seenval('L')) { - g26_layer_height = parser.value_linear_units(); - if (!WITHIN(g26_layer_height, 0.0, 2.0)) { + g26.layer_height = parser.value_linear_units(); + if (!WITHIN(g26.layer_height, 0.0, 2.0)) { SERIAL_ECHOLNPGM("?Specified layer height not plausible."); return; } @@ -563,8 +560,8 @@ void GcodeSuite::G26() { if (parser.seen('Q')) { if (parser.has_value()) { - g26_retraction_multiplier = parser.value_float(); - if (!WITHIN(g26_retraction_multiplier, 0.05, 15.0)) { + g26.retraction_multiplier = parser.value_float(); + if (!WITHIN(g26.retraction_multiplier, 0.05, 15.0)) { SERIAL_ECHOLNPGM("?Specified Retraction Multiplier not plausible."); return; } @@ -576,8 +573,8 @@ void GcodeSuite::G26() { } if (parser.seenval('S')) { - g26_nozzle = parser.value_float(); - if (!WITHIN(g26_nozzle, 0.1, 2.0)) { + g26.nozzle = parser.value_float(); + if (!WITHIN(g26.nozzle, 0.1, 2.0)) { SERIAL_ECHOLNPGM("?Specified nozzle size not plausible."); return; } @@ -586,16 +583,16 @@ void GcodeSuite::G26() { if (parser.seen('P')) { if (!parser.has_value()) { #if HAS_LCD_MENU - g26_prime_flag = -1; + g26.prime_flag = -1; #else SERIAL_ECHOLNPGM("?Prime length must be specified when not using an LCD."); return; #endif } else { - g26_prime_flag++; - g26_prime_length = parser.value_linear_units(); - if (!WITHIN(g26_prime_length, 0.0, 25.0)) { + g26.prime_flag++; + g26.prime_length = parser.value_linear_units(); + if (!WITHIN(g26.prime_length, 0.0, 25.0)) { SERIAL_ECHOLNPGM("?Specified prime length not plausible."); return; } @@ -603,17 +600,17 @@ void GcodeSuite::G26() { } if (parser.seenval('F')) { - g26_filament_diameter = parser.value_linear_units(); - if (!WITHIN(g26_filament_diameter, 1.0, 4.0)) { + g26.filament_diameter = parser.value_linear_units(); + if (!WITHIN(g26.filament_diameter, 1.0, 4.0)) { SERIAL_ECHOLNPGM("?Specified filament size not plausible."); return; } } - g26_extrusion_multiplier *= sq(1.75) / sq(g26_filament_diameter); // If we aren't using 1.75mm filament, we need to + g26.extrusion_multiplier *= sq(1.75) / sq(g26.filament_diameter); // If we aren't using 1.75mm filament, we need to // scale up or down the length needed to get the // same volume of filament - g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3); // Scale up by nozzle size + g26.extrusion_multiplier *= g26.filament_diameter * sq(g26.nozzle) / sq(0.3); // Scale up by nozzle size // Get a temperature from 'I' or 'H' celsius_t noztemp = 0; @@ -632,7 +629,7 @@ void GcodeSuite::G26() { SERIAL_ECHOLNPGM("?Specified nozzle temperature not plausible."); return; } - g26_hotend_temp = noztemp; + g26.hotend_temp = noztemp; } // 'U' to Randomize and optionally set circle deviation @@ -660,9 +657,9 @@ void GcodeSuite::G26() { } // Set a position with 'X' and/or 'Y'. Default: current_position - g26_xy_pos.set(parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x, + g26.xy_pos.set(parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x, parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y); - if (!position_is_reachable(g26_xy_pos)) { + if (!position_is_reachable(g26.xy_pos)) { SERIAL_ECHOLNPGM("?Specified X,Y coordinate out of bounds."); return; } @@ -680,12 +677,12 @@ void GcodeSuite::G26() { planner.calculate_volumetric_multipliers(); #endif - if (turn_on_heaters() != G26_OK) goto LEAVE; + if (g26.turn_on_heaters() != G26_OK) goto LEAVE; current_position.e = 0.0; sync_plan_position_e(); - if (g26_prime_flag && prime_nozzle() != G26_OK) goto LEAVE; + if (g26.prime_flag && g26.prime_nozzle() != G26_OK) goto LEAVE; /** * Bed is preheated @@ -698,14 +695,12 @@ void GcodeSuite::G26() { */ circle_flags.reset(); - horizontal_mesh_line_flags.reset(); - vertical_mesh_line_flags.reset(); // Move nozzle to the specified height for the first layer destination = current_position; - destination.z = g26_layer_height; + destination.z = g26.layer_height; move_to(destination, 0.0); - move_to(destination, g26_ooze_amount); + move_to(destination, g26.ooze_amount); TERN_(HAS_LCD_MENU, ui.capture()); @@ -732,7 +727,7 @@ void GcodeSuite::G26() { mesh_index_pair location; do { // Find the nearest confluence - location = find_closest_circle_to_print(g26_continue_with_closest ? xy_pos_t(current_position) : g26_xy_pos); + location = g26.find_closest_circle_to_print(g26.continue_with_closest ? xy_pos_t(current_position) : g26.xy_pos); if (location.valid()) { const xy_pos_t circle = _GET_MESH_POS(location.pos); @@ -762,7 +757,7 @@ void GcodeSuite::G26() { if (!b) { e.x = circle.x; e.y += INTERSECTION_CIRCLE_RADIUS; } arc_length = (f || b) ? ARC_LENGTH(1) : ARC_LENGTH(2); } - else if (r) { // right edge + else if (r) { // right edge if (b) s.set(circle.x - (INTERSECTION_CIRCLE_RADIUS), circle.y); else s.set(circle.x, circle.y + INTERSECTION_CIRCLE_RADIUS); if (f) e.set(circle.x - (INTERSECTION_CIRCLE_RADIUS), circle.y); @@ -782,25 +777,24 @@ void GcodeSuite::G26() { const xy_float_t dist = current_position - s; // Distance from the start of the actual circle const float dist_start = HYPOT2(dist.x, dist.y); const xyze_pos_t endpoint = { - e.x, e.y, g26_layer_height, - current_position.e + (arc_length * g26_e_axis_feedrate * g26_extrusion_multiplier) + e.x, e.y, g26.layer_height, + current_position.e + (arc_length * g26_e_axis_feedrate * g26.extrusion_multiplier) }; if (dist_start > 2.0) { - s.z = g26_layer_height + 0.5f; - retract_lift_move(s); + s.z = g26.layer_height + 0.5f; + g26.retract_lift_move(s); } - s.z = g26_layer_height; + s.z = g26.layer_height; move_to(s, 0.0); // Get to the starting point with no extrusion / un-Z lift - recover_filament(destination); + g26.recover_filament(destination); - const feedRate_t old_feedrate = feedrate_mm_s; - feedrate_mm_s = PLANNER_XY_FEEDRATE() * 0.1f; - plan_arc(endpoint, arc_offset, false, 0); // Draw a counter-clockwise arc - feedrate_mm_s = old_feedrate; - destination = current_position; + { REMEMBER(fr, feedrate_mm_s, PLANNER_XY_FEEDRATE() * 0.1f); + plan_arc(endpoint, arc_offset, false, 0); // Draw a counter-clockwise arc + destination = current_position; + } if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation @@ -828,8 +822,8 @@ void GcodeSuite::G26() { if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation - xyz_float_t p = { circle.x + _COS(ind ), circle.y + _SIN(ind ), g26_layer_height }, - q = { circle.x + _COS(ind + 1), circle.y + _SIN(ind + 1), g26_layer_height }; + xyz_float_t p = { circle.x + _COS(ind ), circle.y + _SIN(ind ), g26.layer_height }, + q = { circle.x + _COS(ind + 1), circle.y + _SIN(ind + 1), g26.layer_height }; #if IS_KINEMATIC // Check to make sure this segment is entirely on the bed, skip if not. @@ -841,13 +835,17 @@ void GcodeSuite::G26() { LIMIT(q.y, Y_MIN_POS + 1, Y_MAX_POS - 1); #endif - print_line_from_here_to_there(p, q); + g26.print_line_from_here_to_there(p, q); SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } #endif // !ARC_SUPPORT - if (look_for_lines_to_connect()) goto LEAVE; + g26.connect_neighbor_with_line(location.pos, -1, 0); + g26.connect_neighbor_with_line(location.pos, 1, 0); + g26.connect_neighbor_with_line(location.pos, 0, -1); + g26.connect_neighbor_with_line(location.pos, 0, 1); + if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; } SERIAL_FLUSH(); // Prevent host M105 buffer overrun. @@ -857,12 +855,9 @@ void GcodeSuite::G26() { LEAVE: ui.set_status_P(GET_TEXT(MSG_G26_LEAVING), -1); - retract_filament(destination); + g26.retract_filament(destination); destination.z = Z_CLEARANCE_BETWEEN_PROBES; - move_to(destination, 0); // Raise the nozzle - - destination = g26_xy_pos; // Move back to the starting XY position - move_to(destination, 0); // Move back to the starting position + move_to(destination, 0); // Raise the nozzle #if DISABLED(NO_VOLUMETRICS) parser.volumetric_enabled = volumetric_was_enabled; @@ -871,7 +866,7 @@ void GcodeSuite::G26() { TERN_(HAS_LCD_MENU, ui.release()); // Give back control of the LCD - if (!g26_keep_heaters_on) { + if (!g26.keep_heaters_on) { TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0)); thermalManager.setTargetHotend(active_extruder, 0); } diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 55b14c19dc..e42a590265 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -68,8 +68,8 @@ void GcodeSuite::M420() { y_min = probe.min_y(), y_max = probe.max_y(); #if ENABLED(AUTO_BED_LEVELING_BILINEAR) bilinear_start.set(x_min, y_min); - bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1), - (y_max - y_min) / (GRID_MAX_POINTS_Y - 1)); + bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X), + (y_max - y_min) / (GRID_MAX_CELLS_Y)); #endif GRID_LOOP(x, y) { Z_VALUES(x, y) = 0.001 * random(-200, 200); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 42d3a75da1..654a381383 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -295,10 +295,10 @@ G29_TYPE GcodeSuite::G29() { // Get nearest i / j from rx / ry i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x; j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y; - LIMIT(i, 0, GRID_MAX_POINTS_X - 1); - LIMIT(j, 0, GRID_MAX_POINTS_Y - 1); + LIMIT(i, 0, (GRID_MAX_POINTS_X) - 1); + LIMIT(j, 0, (GRID_MAX_POINTS_Y) - 1); } - if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) { + if (WITHIN(i, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(j, 0, (GRID_MAX_POINTS_Y) - 1)) { set_bed_leveling_enabled(false); z_values[i][j] = rz; TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 278a39b4f8..1ec514c3ec 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -106,7 +106,7 @@ void GcodeSuite::G29() { SET_SOFT_ENDSTOP_LOOSE(false); } // If there's another point to sample, move there with optional lift. - if (mbl_probe_index < GRID_MAX_POINTS) { + if (mbl_probe_index < (GRID_MAX_POINTS)) { // Disable software endstops to allow manual adjustment // If G29 is left hanging without completion they won't be re-enabled! SET_SOFT_ENDSTOP_LOOSE(true); @@ -142,8 +142,8 @@ void GcodeSuite::G29() { case MeshSet: if (parser.seenval('I')) { ix = parser.value_int(); - if (!WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) { - SERIAL_ECHOLNPAIR("I out of range (0-", GRID_MAX_POINTS_X - 1, ")"); + if (!WITHIN(ix, 0, (GRID_MAX_POINTS_X) - 1)) { + SERIAL_ECHOLNPAIR("I out of range (0-", (GRID_MAX_POINTS_X) - 1, ")"); return; } } @@ -152,8 +152,8 @@ 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-", GRID_MAX_POINTS_Y - 1, ")"); + if (!WITHIN(iy, 0, (GRID_MAX_POINTS_Y) - 1)) { + SERIAL_ECHOLNPAIR("J out of range (0-", (GRID_MAX_POINTS_Y) - 1, ")"); return; } } diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 2433050528..337cf2a950 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -224,6 +224,11 @@ #endif #endif +#ifdef GRID_MAX_POINTS_X + #define GRID_MAX_CELLS_X (GRID_MAX_POINTS_X - 1) + #define GRID_MAX_CELLS_Y (GRID_MAX_POINTS_Y - 1) +#endif + /** * Host keep alive */ diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 647e0d55dd..48a536b531 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1263,9 +1263,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(DELTA_CALIBRATION_MENU) && !HAS_LCD_MENU #error "DELTA_CALIBRATION_MENU requires an LCD Controller." #elif ABL_USES_GRID - #if (GRID_MAX_POINTS_X & 1) == 0 || (GRID_MAX_POINTS_Y & 1) == 0 + #if ((GRID_MAX_POINTS_X) & 1) == 0 || ((GRID_MAX_POINTS_Y) & 1) == 0 #error "DELTA requires GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y to be odd numbers." - #elif GRID_MAX_POINTS_X < 3 + #elif (GRID_MAX_POINTS_X) < 3 #error "DELTA requires GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y to be 3 or higher." #endif #endif @@ -1518,7 +1518,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS // Mesh Bed Leveling #if ENABLED(DELTA) #error "MESH_BED_LEVELING is not compatible with DELTA printers." - #elif GRID_MAX_POINTS_X > 9 || GRID_MAX_POINTS_Y > 9 + #elif (GRID_MAX_POINTS_X) > 9 || (GRID_MAX_POINTS_Y) > 9 #error "GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y must be less than 10 for MBL." #endif diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index e18ed7273c..61c7ce18d6 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -1279,7 +1279,7 @@ void MarlinUI::draw_status_screen() { pixels_per_x_mesh_pnt, pixels_per_y_mesh_pnt, suppress_x_offset = 0, suppress_y_offset = 0; - const uint8_t y_plot_inv = (GRID_MAX_POINTS_Y - 1) - y_plot; + const uint8_t y_plot_inv = (GRID_MAX_POINTS_Y) - 1 - y_plot; upper_left.column = 0; upper_left.row = 0; diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index e41ed62573..44ada03c7e 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -529,7 +529,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Fill in the Specified Mesh Point - const uint8_t y_plot_inv = (GRID_MAX_POINTS_Y - 1) - y_plot; // The origin is typically in the lower right corner. We need to + const uint8_t y_plot_inv = (GRID_MAX_POINTS_Y) - 1 - y_plot; // The origin is typically in the lower right corner. We need to // invert the Y to get it to plot in the right location. const u8g_uint_t by = y_offset + y_plot_inv * pixels_per_y_mesh_pnt; 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 f8b4b5b5d1..cba27931f2 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 @@ -53,12 +53,12 @@ constexpr static float gaugeThickness = 0.25; #endif void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::bed_mesh_t data, uint8_t opts, float autoscale_max) { - constexpr uint8_t rows = GRID_MAX_POINTS_Y; - constexpr uint8_t cols = GRID_MAX_POINTS_X; + constexpr uint8_t rows = GRID_MAX_POINTS_Y; + constexpr uint8_t cols = GRID_MAX_POINTS_X; - #define VALUE(X,Y) (data ? data[X][Y] : 0) - #define ISVAL(X,Y) (data ? !isnan(VALUE(X,Y)) : true) - #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0) + #define VALUE(X,Y) (data ? data[X][Y] : 0) + #define ISVAL(X,Y) (data ? !isnan(VALUE(X,Y)) : true) + #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0) // Compute the mean, min and max for the points diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 2eecda9df0..2cac0f8e77 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -859,7 +859,7 @@ namespace ExtUI { bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; } float getMeshPoint(const xy_uint8_t &pos) { return Z_VALUES(pos.x, pos.y); } void setMeshPoint(const xy_uint8_t &pos, const_float_t zoff) { - if (WITHIN(pos.x, 0, GRID_MAX_POINTS_X) && WITHIN(pos.y, 0, GRID_MAX_POINTS_Y)) { + if (WITHIN(pos.x, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(pos.y, 0, (GRID_MAX_POINTS_Y) - 1)) { Z_VALUES(pos.x, pos.y) = zoff; TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); } diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 6a9f89f118..5fc9fbccbd 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -214,8 +214,8 @@ static uint8_t xind, yind; // =0 START_MENU(); BACK_ITEM(MSG_BED_LEVELING); - EDIT_ITEM(uint8, MSG_MESH_X, &xind, 0, GRID_MAX_POINTS_X - 1); - EDIT_ITEM(uint8, MSG_MESH_Y, &yind, 0, GRID_MAX_POINTS_Y - 1); + EDIT_ITEM(uint8, MSG_MESH_X, &xind, 0, (GRID_MAX_POINTS_X) - 1); + EDIT_ITEM(uint8, MSG_MESH_Y, &yind, 0, (GRID_MAX_POINTS_Y) - 1); EDIT_ITEM_FAST(float43, MSG_MESH_EDIT_Z, &Z_VALUES(xind, yind), -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner); END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 876c9ae621..1ab44856dc 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -484,8 +484,8 @@ void ubl_map_screen() { #if IS_KINEMATIC n_edit_pts = 9; // TODO: Delta accessible edit points #else - const bool xc = WITHIN(x, 1, GRID_MAX_POINTS_X - 2), - yc = WITHIN(y, 1, GRID_MAX_POINTS_Y - 2); + const bool xc = WITHIN(x, 1, (GRID_MAX_POINTS_X) - 2), + yc = WITHIN(y, 1, (GRID_MAX_POINTS_Y) - 2); n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners #endif diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 793ee60847..5563d3069b 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -462,12 +462,12 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE); - for (uint16_t x = 0; x < GRID_MAX_POINTS_X ; x++) - for (uint16_t y = 0; y < GRID_MAX_POINTS_Y ; y++) + for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++) + for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++) if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) })) - tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 2, 2, COLOR_UBL); + tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 2, 2, COLOR_UBL); - tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 6, 6, COLOR_UBL); + tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 6, 6, COLOR_UBL); const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, lpos = pos.asLogical(); @@ -512,9 +512,9 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const #if ENABLED(TOUCH_SCREEN) touch.clear(); draw_menu_navigation = false; - add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgUp); - add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT - CONTROL_OFFSET - 32, UBL, - ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgDown); - add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft); + add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + CONTROL_OFFSET, UBL, (ENCODER_STEPS_PER_MENU_ITEM) * (GRID_MAX_POINTS_X), imgUp); + add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT - CONTROL_OFFSET - 32, UBL, -(ENCODER_STEPS_PER_MENU_ITEM) * (GRID_MAX_POINTS_X), imgDown); + add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, -(ENCODER_STEPS_PER_MENU_ITEM), imgLeft); add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM, imgRight); add_control(224, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling); add_control(144, 206, BACK, imgBack); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index a8979d0ca6..21b280ac75 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -462,12 +462,12 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE); - for (uint16_t x = 0; x < GRID_MAX_POINTS_X ; x++) - for (uint16_t y = 0; y < GRID_MAX_POINTS_Y ; y++) + for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++) + for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++) if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) })) - tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 2, 2, COLOR_UBL); + tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 2, 2, COLOR_UBL); - tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 6, 6, COLOR_UBL); + tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 6, 6, COLOR_UBL); const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, lpos = pos.asLogical(); @@ -512,9 +512,9 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const #if ENABLED(TOUCH_SCREEN) touch.clear(); draw_menu_navigation = false; - add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgUp); - add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT - CONTROL_OFFSET - 32, UBL, - ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgDown); - add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft); + add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + CONTROL_OFFSET, UBL, (ENCODER_STEPS_PER_MENU_ITEM) * (GRID_MAX_POINTS_X), imgUp); + add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT - CONTROL_OFFSET - 32, UBL, -(ENCODER_STEPS_PER_MENU_ITEM) * (GRID_MAX_POINTS_X), imgDown); + add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, -(ENCODER_STEPS_PER_MENU_ITEM), imgLeft); add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM, imgRight); add_control(320, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling); add_control(224, TFT_HEIGHT - 34, BACK, imgBack); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index ced33a1986..915886fe4a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1605,7 +1605,7 @@ void MarlinSettings::postprocess() { #if ENABLED(MESH_BED_LEVELING) if (!validating) mbl.z_offset = dummyf; - if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) { + if (mesh_num_x == (GRID_MAX_POINTS_X) && mesh_num_y == (GRID_MAX_POINTS_Y)) { // EEPROM data fits the current mesh EEPROM_READ(mbl.z_values); } @@ -1652,7 +1652,7 @@ void MarlinSettings::postprocess() { EEPROM_READ_ALWAYS(grid_max_x); // 1 byte EEPROM_READ_ALWAYS(grid_max_y); // 1 byte #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (grid_max_x == GRID_MAX_POINTS_X && grid_max_y == GRID_MAX_POINTS_Y) { + if (grid_max_x == (GRID_MAX_POINTS_X) && grid_max_y == (GRID_MAX_POINTS_Y)) { if (!validating) set_bed_leveling_enabled(false); EEPROM_READ(bilinear_grid_spacing); // 2 ints EEPROM_READ(bilinear_start); // 2 ints From 6747d350a53ff78be2e7679cb3e9afec0d9aca52 Mon Sep 17 00:00:00 2001 From: Sola <42537573+solawc@users.noreply.github.com> Date: Fri, 2 Apr 2021 08:19:22 +0800 Subject: [PATCH 150/311] MKS H43 fix, cleanup (#21500) Followup to #21485 --- Marlin/Configuration.h | 2 +- Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 2 +- Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 9 ++++++--- Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h | 4 ++-- Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp | 7 ++++++- Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h | 7 +++++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 5f9b1782fc..0847892934 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2374,7 +2374,7 @@ //#define DGUS_LCD_UI_FYSETC //#define DGUS_LCD_UI_HIPRECY -// #define DGUS_LCD_UI_MKS +//#define DGUS_LCD_UI_MKS #if ENABLED(DGUS_LCD_UI_MKS) #define USE_MKS_GREEN_UI #endif diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index b4e876ce4c..067ea482c7 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -176,6 +176,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var) { #if HAS_PID_HEATING void DGUSScreenHandler::DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var) { float value = *(float *)var.memadr; + value /= 10; float valuesend = 0; switch (var.VP) { default: return; @@ -343,7 +344,6 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); } - #endif // SDSUPPORT void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index a2ccdada36..786d1821a6 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -44,7 +44,7 @@ #endif uint16_t manualMoveStep = 1; -float distanceFilament = 10; +uint16_t distanceFilament = 10; uint16_t FilamentSpeed = 25; float ZOffset_distance = 0.1; float mesh_adj_distance = 0.01; @@ -554,7 +554,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr), VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr), - VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), + VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #endif @@ -733,8 +733,9 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // SDCard File listing - VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), + #if ENABLED(SDSUPPORT) + VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr), VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr), VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename), @@ -759,6 +760,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_OFFSET_Y, &probe.offset.y, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), VPHELPER(VP_OFFSET_Z, &probe.offset.z, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), #endif + #else + VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.PrintReturn, nullptr), #endif #if ENABLED(DGUS_UI_WAITING) diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h index 9a3690f356..ac0a482ede 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h @@ -36,7 +36,7 @@ #define MKS_FINSH extern uint16_t manualMoveStep; -extern float distanceFilament; +extern uint16_t distanceFilament; extern uint16_t FilamentSpeed; extern float ZOffset_distance; extern float mesh_adj_distance; @@ -55,7 +55,7 @@ void MKS_resume_print_move(); extern float z_offset_add; -xyz_int_t tmc_step; +extern xyz_int_t tmc_step; extern uint16_t lcd_default_light; diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index b6633d3a1f..54500011f8 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -270,6 +270,11 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { GotoScreen(MKSLCD_SCREEN_PrintDone); } +#else + void DGUSScreenHandler::PrintReturn(DGUS_VP_Variable& var, void *val_ptr) { + uint16_t value = swap16(*(uint16_t*)val_ptr); + if (value == 0x0F) GotoScreen(DGUSLCD_SCREEN_MAIN); + } #endif // SDSUPPORT void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { @@ -1215,7 +1220,7 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ } else { #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) - swap_tool = 2; + swap_tool = 1; #endif } #endif diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h index 2d0678ca5b..07c123d928 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h @@ -158,13 +158,14 @@ public: static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr); #endif - // File touched. - static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(SDSUPPORT) // Callback for VP "Display wants to change screen when there is a SD card" static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); // Scroll buttons on the file listing screen. static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); + // File touched. + static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); // start print after confirmation received. static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); // User hit the pause, resume or abort button. @@ -183,6 +184,8 @@ public: static void SDCardError(); // Marlin informed us about SD print completion. static void SDPrintingFinished(); + #else + static void PrintReturn(DGUS_VP_Variable &var, void *val_ptr); #endif // OK Button the Confirm screen. From 235ba926021709e293f33b7229690406761298e4 Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Thu, 1 Apr 2021 19:29:49 -0500 Subject: [PATCH 151/311] Followup to Laser Flow Meter (#21498) --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 6 +++--- Marlin/src/lcd/dogm/dogm_Statusscreen.h | 6 +++--- Marlin/src/lcd/dogm/status/cooler.h | 2 +- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 2 +- Marlin/src/lcd/menu/menu_temperature.cpp | 2 +- Marlin/src/module/temperature.cpp | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 61c7ce18d6..98ca1c0930 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -46,7 +46,7 @@ #include "../../gcode/parser.h" #endif -#if HAS_COOLER || HAS_FLOWMETER +#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER) #include "../../feature/cooler.h" #endif @@ -584,7 +584,7 @@ FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { } #endif -#if HAS_FLOWMETER +#if ENABLED(LASER_COOLANT_FLOW_METER) FORCE_INLINE void _draw_flowmeter_status() { lcd_put_u8str("~ "); lcd_put_u8str(ftostr11ns(cooler.flowrate)); @@ -827,7 +827,7 @@ void MarlinUI::draw_status_screen() { #if HAS_COOLER _draw_cooler_status('*', blink); #endif - #if HAS_FLOWMETER + #if ENABLED(LASER_COOLANT_FLOW_METER) _draw_flowmeter_status(); #endif diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index 396b05b084..f0e37aa249 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -97,7 +97,7 @@ // // Laser Flowmeter // -#if !STATUS_FLOWMETER_WIDTH && HAS_FLOWMETER +#if !STATUS_FLOWMETER_WIDTH && ENABLED(LASER_COOLANT_FLOW_METER) #include "status/cooler.h" #endif #ifndef STATUS_FLOWMETER_WIDTH @@ -567,7 +567,7 @@ // // Flowmeter Bitmap Properties // -#if HAS_FLOWMETER +#if ENABLED(LASER_COOLANT_FLOW_METER) #if STATUS_FLOWMETER_WIDTH #ifndef STATUS_FLOWMETER_X @@ -689,7 +689,7 @@ #if HAS_COOLER #define DO_DRAW_COOLER 1 #endif -#if HAS_FLOWMETER +#if ENABLED(LASER_COOLANT_FLOW_METER) #define DO_DRAW_FLOWMETER 1 #endif diff --git a/Marlin/src/lcd/dogm/status/cooler.h b/Marlin/src/lcd/dogm/status/cooler.h index 0d72efea72..df596b5c5a 100644 --- a/Marlin/src/lcd/dogm/status/cooler.h +++ b/Marlin/src/lcd/dogm/status/cooler.h @@ -64,7 +64,7 @@ }; #endif -#if HAS_FLOWMETER +#if ENABLED(LASER_COOLANT_FLOW_METER) #define STATUS_FLOWMETER_WIDTH 24 const unsigned char status_flowmeter_bmp2[] PROGMEM = { B00000001,B11111000,B00000000, diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 2ec462c34a..921dee0e34 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -53,7 +53,7 @@ #include "../../feature/spindle_laser.h" #endif -#if HAS_COOLER || HAS_FLOWMETER +#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER) #include "../../feature/cooler.h" #endif diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index fb47c22ce9..85578ea351 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -35,7 +35,7 @@ #include "../../module/motion.h" #endif -#if HAS_COOLER || HAS_FLOWMETER +#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER) #include "../../feature/cooler.h" #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 02fe7588d9..992681632d 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -35,7 +35,7 @@ #include "endstops.h" #include "planner.h" -#if HAS_COOLER || HAS_FLOWMETER +#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER) #include "../feature/cooler.h" #include "../feature/spindle_laser.h" #endif @@ -1549,7 +1549,7 @@ void Temperature::manage_heater() { #endif // HAS_COOLER - #if HAS_FLOWMETER + #if ENABLED(LASER_COOLANT_FLOW_METER) cooler.flowmeter_task(ms); #if ENABLED(FLOWMETER_SAFETY) if (cutter.enabled() && cooler.check_flow_too_low()) { From 0dde8f89682245eba48e553fd62bf0deb1f10e88 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 2 Apr 2021 01:13:58 +0000 Subject: [PATCH 152/311] [cron] Bump distribution date (2021-04-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 361b647dd5..994348eb76 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-04-01" + #define STRING_DISTRIBUTION_DATE "2021-04-02" #endif /** From 3229100025dc428d5038eca753c70f3c831d6336 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 1 Apr 2021 21:53:19 -0500 Subject: [PATCH 153/311] Split up platformio.ini (#21507) --- .../PlatformIO/scripts/common-dependencies.py | 37 +- ini/avr.ini | 174 ++ ini/due.ini | 43 + ini/esp32.ini | 29 + ini/features.ini | 218 +++ ini/lpc176x.ini | 44 + ini/native.ini | 23 + ini/samd51.ini | 27 + ini/stm32f0.ini | 42 + ini/stm32f1.ini | 439 +++++ ini/stm32f4.ini | 371 +++++ ini/stm32f7.ini | 30 + ini/teensy.ini | 42 + platformio.ini | 1426 +---------------- 14 files changed, 1504 insertions(+), 1441 deletions(-) create mode 100644 ini/avr.ini create mode 100644 ini/due.ini create mode 100644 ini/esp32.ini create mode 100644 ini/features.ini create mode 100644 ini/lpc176x.ini create mode 100644 ini/native.ini create mode 100644 ini/samd51.ini create mode 100644 ini/stm32f0.ini create mode 100644 ini/stm32f1.ini create mode 100644 ini/stm32f4.ini create mode 100644 ini/stm32f7.ini create mode 100644 ini/teensy.ini diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index 3844d8298a..fe6ae7dba5 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -3,16 +3,6 @@ # Convenience script to check dependencies and add libs and sources for Marlin Enabled Features # import subprocess,os,re -try: - import configparser -except ImportError: - import ConfigParser as configparser -try: - # PIO < 4.4 - from platformio.managers.package import PackageManager -except ImportError: - # PIO >= 4.4 - from platformio.package.meta import PackageSpec as PackageManager PIO_VERSION_MIN = (5, 0, 3) try: @@ -38,6 +28,9 @@ except SystemExit: except: print("Can't detect PlatformIO Version") +from platformio.package.meta import PackageSpec +from platformio.project.config import ProjectConfig + Import("env") #print(env.Dump()) @@ -51,13 +44,6 @@ def blab(str): if verbose: print(str) -def parse_pkg_uri(spec): - if PackageManager.__name__ == 'PackageSpec': - return PackageManager(spec).name - else: - name, _, _ = PackageManager.parse_pkg_uri(spec) - return name - FEATURE_CONFIG = {} def add_to_feat_cnf(feature, flines): @@ -86,9 +72,7 @@ def add_to_feat_cnf(feature, flines): feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] def load_config(): - config = configparser.ConfigParser() - config.read("platformio.ini") - items = config.items('features') + items = ProjectConfig().items('features') for key in items: feature = key[0].upper() if not feature in FEATURE_CONFIG: @@ -114,16 +98,14 @@ def get_all_known_libs(): if not 'lib_deps' in feat: continue for dep in feat['lib_deps']: - name = parse_pkg_uri(dep) - known_libs.append(name) + known_libs.append(PackageSpec(dep).name) return known_libs def get_all_env_libs(): env_libs = [] lib_deps = env.GetProjectOption('lib_deps') for dep in lib_deps: - name = parse_pkg_uri(dep) - env_libs.append(name) + env_libs.append(PackageSpec(dep).name) return env_libs def set_env_field(field, value): @@ -154,20 +136,19 @@ def apply_features_config(): # feat to add deps_to_add = {} for dep in feat['lib_deps']: - name = parse_pkg_uri(dep) - deps_to_add[name] = dep + deps_to_add[PackageSpec(dep).name] = dep # Does the env already have the dependency? deps = env.GetProjectOption('lib_deps') for dep in deps: - name = parse_pkg_uri(dep) + name = PackageSpec(dep).name if name in deps_to_add: del deps_to_add[name] # Are there any libraries that should be ignored? lib_ignore = env.GetProjectOption('lib_ignore') for dep in deps: - name = parse_pkg_uri(dep) + name = PackageSpec(dep).name if name in deps_to_add: del deps_to_add[name] diff --git a/ini/avr.ini b/ini/avr.ini new file mode 100644 index 0000000000..944646190a --- /dev/null +++ b/ini/avr.ini @@ -0,0 +1,174 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# AVR Architecture # +# # +################################# + +# +# AVR (8-bit) Common Environment values +# +[common_avr8] +board_build.f_cpu = 16000000L +src_filter = ${common.default_src_filter} + + +# +# ATmega2560 +# +[env:mega2560] +platform = atmelavr +extends = common_avr8 +board = megaatmega2560 + +# +# ATmega2560 with extended pins 70-85 defined +# BOARD_BQ_ZUM_MEGA_3D +# BOARD_ULTIMAIN_2 +# BOARD_MIGHTYBOARD_REVE +# BOARD_EINSTART_S +# +[env:mega2560ext] +platform = atmelavr +extends = env:mega2560 +board_build.variant = megaextendedpins +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py + +# +# ATmega1280 +# +[env:mega1280] +platform = atmelavr +extends = common_avr8 +board = megaatmega1280 + +# +# MightyBoard AVR with extended pins +# +[mega_extended_optimized] +extends = common_avr8 +board_build.variant = megaextendedpins +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py +upload_speed = 57600 +build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues + +# +# MightyBoard ATmega1280 +# +[env:MightyBoard1280] +platform = atmelavr +extends = mega_extended_optimized +board = megaatmega1280 + +# +# MightyBoard ATmega2560 +# +[env:MightyBoard2560] +platform = atmelavr +extends = mega_extended_optimized +board = megaatmega2560 + +# +# RAMBo +# +[env:rambo] +platform = atmelavr +extends = common_avr8 +board = reprap_rambo + +# +# FYSETC F6 V1.3 / V1.4 +# +[env:FYSETC_F6] +platform = atmelavr +extends = common_avr8 +board = fysetc_f6 + +# +# Sanguinololu (ATmega644p) +# +[env:sanguino644p] +platform = atmelavr +extends = common_avr8 +board = sanguino_atmega644p + +# +# Sanguinololu (ATmega1284p) +# +[env:sanguino1284p] +platform = atmelavr +extends = common_avr8 +board = sanguino_atmega1284p +board_upload.maximum_size = 126976 + +# +# Melzi and clones (ATmega1284p) +# +[env:melzi] +platform = atmelavr +extends = env:sanguino1284p +upload_speed = 57600 + +# +# Sanguinololu (ATmega1284p stock bootloader with tuned flags) +# + +[tuned_1284p] +build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues + +[env:sanguino1284p_optimized] +platform = atmelavr +extends = env:melzi +build_flags = ${tuned_1284p.build_flags} + +# +# Melzi and clones (alias for sanguino1284p_optimized) +# +[env:melzi_optimized] +platform = atmelavr +extends = env:sanguino1284p_optimized + +# +# Melzi and clones (Optiboot bootloader) +# +[env:melzi_optiboot] +platform = atmelavr +extends = common_avr8 +board = sanguino_atmega1284p +upload_speed = 115200 + +# +# Melzi and clones (Zonestar Melzi2 with tuned flags) +# +[env:melzi_optiboot_optimized] +platform = atmelavr +extends = env:melzi_optiboot +build_flags = ${tuned_1284p.build_flags} + +# +# AT90USB1286 boards using CDC bootloader +# - BRAINWAVE +# - BRAINWAVE_PRO +# - SAV_MKI +# - TEENSYLU +# +[env:at90usb1286_cdc] +platform = teensy +extends = common_avr8 +board = at90usb1286 +lib_ignore = ${env:common_avr8.lib_ignore}, Teensy_ADC, NativeEthernet + +# +# AT90USB1286 boards using DFU bootloader +# - Printrboard +# - Printrboard Rev.F +# - ? 5DPRINT ? +# +[env:at90usb1286_dfu] +platform = teensy +extends = env:at90usb1286_cdc diff --git a/ini/due.ini b/ini/due.ini new file mode 100644 index 0000000000..7abc262eb4 --- /dev/null +++ b/ini/due.ini @@ -0,0 +1,43 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# DUE Architecture # +# # +################################# + +# +# Due (Atmel SAM3X8E ARM Cortex-M3) +# +# - RAMPS4DUE +# - RADDS +# +[env:DUE] +platform = atmelsam +board = due +src_filter = ${common.default_src_filter} + + + +[env:DUE_USB] +platform = atmelsam +extends = env:DUE +board = dueUSB + +# +# Archim SAM +# +[common_DUE_archim] +platform = atmelsam +extends = env:DUE +board = archim +build_flags = ${common.build_flags} + -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSBCON +board_build.variants_dir = buildroot/share/PlatformIO/variants/ +extra_scripts = ${common.extra_scripts} + Marlin/src/HAL/DUE/upload_extra_script.py + +[env:DUE_archim] +platform = ${common_DUE_archim.platform} +extends = common_DUE_archim diff --git a/ini/esp32.ini b/ini/esp32.ini new file mode 100644 index 0000000000..1aee88f692 --- /dev/null +++ b/ini/esp32.ini @@ -0,0 +1,29 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# ESP32 Architecture # +# # +################################# + +# +# Espressif ESP32 +# +[env:esp32] +platform = espressif32@2.1.0 +board = esp32dev +build_flags = ${common.build_flags} -DCORE_DEBUG_LEVEL=0 +src_filter = ${common.default_src_filter} + +lib_ignore = NativeEthernet +upload_speed = 500000 +monitor_speed = 250000 +#upload_port = marlinesp.local +#board_build.flash_mode = qio + +[env:FYSETC_E4] +platform = espressif32@1.11.2 +extends = env:esp32 +board_build.partitions = default_16MB.csv diff --git a/ini/features.ini b/ini/features.ini new file mode 100644 index 0000000000..7399a22446 --- /dev/null +++ b/ini/features.ini @@ -0,0 +1,218 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# Features Dependencies # +# # +################################# + +[features] +YHCB2004 = red-scorp/LiquidCrystal_AIP31068@^1.0.4, red-scorp/SoftSPIB@^1.1.1 +HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip + src_filter=+ + extra_scripts=download_mks_assets.py +POSTMORTEM_DEBUGGING = src_filter=+ + + build_flags=-funwind-tables +MKS_WIFI_MODULE = QRCode=https://github.com/makerbase-mks/QRCode/archive/master.zip +HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.1 + src_filter=+ + + + + +HAS_STEALTHCHOP = src_filter=+ +SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip +HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster + src_filter=+ +HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip + src_filter=+ +HAS_L64XX = Arduino-L6470@0.8.0 + src_filter=+ + + + +NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 + src_filter=+ +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 +HAS_WIRED_LCD = src_filter=+ +HAS_MARLINUI_HD44780 = src_filter=+ +HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.1 + src_filter=+ +HAS_(FSMC|SPI)_TFT = src_filter=+ + + +HAS_FSMC_TFT = src_filter=+ + +HAS_SPI_TFT = src_filter=+ + +I2C_EEPROM = src_filter=+ +SPI_EEPROM = src_filter=+ +HAS_GRAPHICAL_TFT = src_filter=+ +DWIN_CREALITY_LCD = src_filter=+ +IS_TFTGLCD_PANEL = src_filter=+ +HAS_TOUCH_BUTTONS = src_filter=+ +HAS_LCD_MENU = src_filter=+ +HAS_GAMES = src_filter=+ +MARLIN_BRICKOUT = src_filter=+ +MARLIN_INVADERS = src_filter=+ +MARLIN_MAZE = src_filter=+ +MARLIN_SNAKE = src_filter=+ +HAS_MENU_BACKLASH = src_filter=+ +HAS_MENU_BED_CORNERS = src_filter=+ +LCD_BED_LEVELING = src_filter=+ +HAS_MENU_CANCELOBJECT = src_filter=+ +HAS_MENU_DELTA_CALIBRATE = src_filter=+ +HAS_MENU_FILAMENT = src_filter=+ +LCD_INFO_MENU = src_filter=+ +HAS_MENU_JOB_RECOVERY = src_filter=+ +HAS_MULTI_LANGUAGE = src_filter=+ +HAS_MENU_LED = src_filter=+ +HAS_MENU_MEDIA = src_filter=+ +HAS_MENU_MIXER = src_filter=+ +HAS_MENU_MMU2 = src_filter=+ +HAS_MENU_PASSWORD = src_filter=+ +HAS_MENU_POWER_MONITOR = src_filter=+ +HAS_MENU_CUTTER = src_filter=+ +HAS_MENU_TEMPERATURE = src_filter=+ +HAS_MENU_TMC = src_filter=+ +HAS_MENU_TOUCH_SCREEN = src_filter=+ +HAS_MENU_TRAMMING = src_filter=+ +HAS_MENU_UBL = src_filter=+ +ANYCUBIC_LCD_CHIRON = src_filter=+ + +ANYCUBIC_LCD_I3MEGA = src_filter=+ + +NEXTION_TFT = src_filter=+ + +HAS_DGUS_LCD = src_filter=+ + +DGUS_LCD_UI_FYSETC = src_filter=+ +DGUS_LCD_UI_HIPRECY = src_filter=+ +DGUS_LCD_UI_MKS = src_filter=+ +DGUS_LCD_UI_ORIGIN = src_filter=+ +TOUCH_UI_FTDI_EVE = src_filter=+ +EXTUI_EXAMPLE = src_filter=+ +MALYAN_LCD = src_filter=+ +USE_UHS2_USB = src_filter=+ +USE_UHS3_USB = src_filter=+ +USB_FLASH_DRIVE_SUPPORT = src_filter=+ +AUTO_BED_LEVELING_BILINEAR = src_filter=+ +AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ +MESH_BED_LEVELING = src_filter=+ + +AUTO_BED_LEVELING_UBL = src_filter=+ + +UBL_HILBERT_CURVE = src_filter=+ +BACKLASH_COMPENSATION = src_filter=+ +BARICUDA = src_filter=+ + +BINARY_FILE_TRANSFER = src_filter=+ + +BLTOUCH = src_filter=+ +CANCEL_OBJECTS = src_filter=+ + +CASE_LIGHT_ENABLE = src_filter=+ + +EXTERNAL_CLOSED_LOOP_CONTROLLER = src_filter=+ + +USE_CONTROLLER_FAN = src_filter=+ +HAS_MOTOR_CURRENT_DAC = src_filter=+ +DIRECT_STEPPING = src_filter=+ + +EMERGENCY_PARSER = src_filter=+ - +I2C_POSITION_ENCODERS = src_filter=+ +IIC_BL24CXX_EEPROM = src_filter=+ +HAS_SPI_FLASH = src_filter=+ +HAS_ETHERNET = src_filter=+ + +HAS_FANMUX = src_filter=+ +FILAMENT_WIDTH_SENSOR = src_filter=+ + +FWRETRACT = src_filter=+ + +HOST_ACTION_COMMANDS = src_filter=+ +HOTEND_IDLE_TIMEOUT = src_filter=+ +JOYSTICK = src_filter=+ +BLINKM = src_filter=+ +HAS_COLOR_LEDS = src_filter=+ + +PCA9533 = src_filter=+ +PCA9632 = src_filter=+ +PRINTER_EVENT_LEDS = src_filter=+ +TEMP_STAT_LEDS = src_filter=+ +MAX7219_DEBUG = src_filter=+ + +HAS_MEATPACK = src_filter=+ +MIXING_EXTRUDER = src_filter=+ + +HAS_PRUSA_MMU1 = src_filter=+ +HAS_PRUSA_MMU2 = src_filter=+ + +PASSWORD_FEATURE = src_filter=+ + +ADVANCED_PAUSE_FEATURE = src_filter=+ + + +AUTO_POWER_CONTROL = src_filter=+ +HAS_POWER_MONITOR = src_filter=+ + +POWER_LOSS_RECOVERY = src_filter=+ + +PROBE_TEMP_COMPENSATION = src_filter=+ + +HAS_FILAMENT_SENSOR = src_filter=+ + +(EXT|MANUAL)_SOLENOID.* = src_filter=+ + +MK2_MULTIPLEXER = src_filter=+ +HAS_CUTTER = src_filter=+ + +EXPERIMENTAL_I2CBUS = src_filter=+ + +MECHANICAL_GANTRY_CAL.+ = src_filter=+ +Z_MULTI_ENDSTOPS = src_filter=+ +Z_STEPPER_AUTO_ALIGN = src_filter=+ + +G26_MESH_VALIDATION = src_filter=+ +ASSISTED_TRAMMING = src_filter=+ + +HAS_MESH = src_filter=+ +HAS_LEVELING = src_filter=+ + +DELTA_AUTO_CALIBRATION = src_filter=+ +CALIBRATION_GCODE = src_filter=+ +Z_MIN_PROBE_REPEATABILITY_TEST = src_filter=+ +M100_FREE_MEMORY_WATCHER = src_filter=+ +BACKLASH_GCODE = src_filter=+ +IS_KINEMATIC = src_filter=+ +HAS_EXTRA_ENDSTOPS = src_filter=+ +SKEW_CORRECTION_GCODE = src_filter=+ +DIRECT_PIN_CONTROL = src_filter=+ + +PINS_DEBUGGING = src_filter=+ +NO_VOLUMETRICS = src_filter=- +HAS_MULTI_EXTRUDER = src_filter=+ +HAS_HOTEND_OFFSET = src_filter=+ +EDITABLE_SERVO_ANGLES = src_filter=+ +PIDTEMP = src_filter=+ +PREVENT_COLD_EXTRUSION = src_filter=+ +PIDTEMPBED = src_filter=+ +HAS_USER_THERMISTORS = src_filter=+ +SD_ABORT_ON_ENDSTOP_HIT = src_filter=+ +BAUD_RATE_GCODE = src_filter=+ +HAS_SMART_EFF_MOD = src_filter=+ +COOLANT_CONTROL = src_filter=+ +HAS_SOFTWARE_ENDSTOPS = src_filter=+ +HAS_DUPLICATION_MODE = src_filter=+ +LIN_ADVANCE = src_filter=+ +PHOTO_GCODE = src_filter=+ +CONTROLLER_FAN_EDITABLE = src_filter=+ +GCODE_MACROS = src_filter=+ +GRADIENT_MIX = src_filter=+ +HAS_SAVED_POSITIONS = src_filter=+ + +PARK_HEAD_ON_PAUSE = src_filter=+ +FILAMENT_LOAD_UNLOAD_GCODES = src_filter=+ +CNC_WORKSPACE_PLANES = src_filter=+ +CNC_COORDINATE_SYSTEMS = src_filter=+ +HAS_M206_COMMAND = src_filter=+ +EXPECTED_PRINTER_CHECK = src_filter=+ +HOST_KEEPALIVE_FEATURE = src_filter=+ +REPETIER_GCODE_M360 = src_filter=+ +HAS_GCODE_M876 = src_filter=+ +HAS_RESUME_CONTINUE = src_filter=+ +HAS_LCD_CONTRAST = src_filter=+ +LCD_SET_PROGRESS_MANUALLY = src_filter=+ +TOUCH_SCREEN_CALIBRATION = src_filter=+ +ARC_SUPPORT = src_filter=+ +GCODE_MOTION_MODES = src_filter=+ +BABYSTEPPING = src_filter=+ + +Z_PROBE_SLED = src_filter=+ +G38_PROBE_TARGET = src_filter=+ +MAGNETIC_PARKING_EXTRUDER = src_filter=+ +SDSUPPORT = src_filter=+ + + + + + + +HAS_MEDIA_SUBCALLS = src_filter=+ +GCODE_REPEAT_MARKERS = src_filter=+ + +HAS_EXTRUDERS = src_filter=+ + +HAS_COOLER = src_filter=+ + +AUTO_REPORT_TEMPERATURES = src_filter=+ +INCH_MODE_SUPPORT = src_filter=+ +TEMPERATURE_UNITS_SUPPORT = src_filter=+ +NEED_HEX_PRINT = src_filter=+ +NEED_LSF = src_filter=+ +NOZZLE_PARK_FEATURE = src_filter=+ + +NOZZLE_CLEAN_FEATURE = src_filter=+ + +DELTA = src_filter=+ + +BEZIER_CURVE_SUPPORT = src_filter=+ + +PRINTCOUNTER = src_filter=+ +HAS_BED_PROBE = src_filter=+ + + + +IS_SCARA = src_filter=+ +HAS_SERVOS = src_filter=+ + +MORGAN_SCARA = src_filter=+ +HAS_MICROSTEPS = src_filter=+ +(ESP3D_)?WIFISUPPORT = AsyncTCP, ESP Async WebServer + ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master.zip + arduinoWebSockets=links2004/WebSockets@2.3.4 + luc-github/ESP32SSDP@^1.1.1 + lib_ignore=ESPAsyncTCP diff --git a/ini/lpc176x.ini b/ini/lpc176x.ini new file mode 100644 index 0000000000..2a59ba7f50 --- /dev/null +++ b/ini/lpc176x.ini @@ -0,0 +1,44 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# LPC176x Architecture # +# # +################################# + +# +# NXP LPC176x ARM Cortex-M3 +# +[common_LPC] +platform = https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.3.zip +platform_packages = framework-arduino-lpc176x@^0.2.6 +board = nxp_lpc1768 +lib_ldf_mode = off +lib_compat_mode = strict +extra_scripts = ${common.extra_scripts} + Marlin/src/HAL/LPC1768/upload_extra_script.py +src_filter = ${common.default_src_filter} + + +lib_deps = ${common.lib_deps} + Servo +custom_marlin.USES_LIQUIDCRYSTAL = arduino-libraries/LiquidCrystal@~1.0.7 +custom_marlin.NEOPIXEL_LED = Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/1.5.0.zip +build_flags = ${common.build_flags} -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC1768/include -IMarlin/src/HAL/LPC1768/u8g + # debug options for backtrace + #-funwind-tables + #-mpoke-function-name + +# +# NXP LPC176x ARM Cortex-M3 +# +[env:LPC1768] +platform = ${common_LPC.platform} +extends = common_LPC +board = nxp_lpc1768 + +[env:LPC1769] +platform = ${common_LPC.platform} +extends = common_LPC +board = nxp_lpc1769 diff --git a/ini/native.ini b/ini/native.ini new file mode 100644 index 0000000000..dbdfd26f8b --- /dev/null +++ b/ini/native.ini @@ -0,0 +1,23 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# Native / Simulation # +# # +################################# + +# +# No supported Arduino libraries, base Marlin only +# +[env:linux_native] +platform = native +framework = +build_flags = -D__PLAT_LINUX__ -std=gnu++17 -ggdb -g -lrt -lpthread -D__MARLIN_FIRMWARE__ -Wno-expansion-to-defined +src_build_flags = -Wall -IMarlin/src/HAL/LINUX/include +build_unflags = -Wall +lib_ldf_mode = off +lib_deps = +src_filter = ${common.default_src_filter} + diff --git a/ini/samd51.ini b/ini/samd51.ini new file mode 100644 index 0000000000..8e8682da94 --- /dev/null +++ b/ini/samd51.ini @@ -0,0 +1,27 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# SAMD51 Architecture # +# # +################################# + +# +# Adafruit Grand Central M4 (Atmel SAMD51P20A ARM Cortex-M4) +# +[env:SAMD51_grandcentral_m4] +platform = atmelsam +board = adafruit_grandcentral_m4 +build_flags = ${common.build_flags} -std=gnu++17 +build_unflags = -std=gnu++11 +src_filter = ${common.default_src_filter} + +lib_deps = ${common.lib_deps} + SoftwareSerialM + Adafruit SPIFlash +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py +custom_marlin.SDSUPPORT = SdFat - Adafruit Fork +debug_tool = jlink diff --git a/ini/stm32f0.ini b/ini/stm32f0.ini new file mode 100644 index 0000000000..fb6ce00dd0 --- /dev/null +++ b/ini/stm32f0.ini @@ -0,0 +1,42 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# STM32F0 Architecture # +# # +################################# + +# +# Malyan M200 v2 (STM32F070RB) +# +[env:STM32F070RB_malyan] +platform = ${common_stm32.platform} +extends = common_stm32 +board = malyanM200v2 +build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED + -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing + -DCUSTOM_STARTUP_FILE + +# +# Malyan M200 v2 (STM32F070CB) +# +[env:STM32F070CB_malyan] +platform = ${common_stm32.platform} +extends = common_stm32 +board = malyanm200_f070cb +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED -DCUSTOM_STARTUP_FILE + +# +# Malyan M300 (STM32F070CB) +# +[env:malyan_M300] +platform = ${common_stm32.platform} +extends = common_stm32 +board = malyanm300_f070cb +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED +src_filter = ${common.default_src_filter} + diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini new file mode 100644 index 0000000000..2ba3d84862 --- /dev/null +++ b/ini/stm32f1.ini @@ -0,0 +1,439 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# STM32F1 Architecture # +# # +################################# + +# +# HAL/STM32 Base Environment values +# +[common_stm32] +platform = ststm32@~12.0 +build_flags = ${common.build_flags} + -std=gnu++14 + -DUSBCON -DUSBD_USE_CDC + -DTIM_IRQ_PRIO=13 + -DADC_RESOLUTION=12 +build_unflags = -std=gnu++11 +src_filter = ${common.default_src_filter} + + + +# +# HAL/STM32F1 Common Environment values +# +[common_stm32f1] +platform = ststm32@~12.0 +board_build.core = maple +build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py + ${common.build_flags} + -DARDUINO_ARCH_STM32 +build_unflags = -std=gnu11 -std=gnu++11 +src_filter = ${common.default_src_filter} + +lib_ignore = SPI, FreeRTOS701, FreeRTOS821 +lib_deps = ${common.lib_deps} + SoftwareSerialM +platform_packages = tool-stm32duino +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py + +# +# STM32F103RC +# +[env:STM32F103RC] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103RC +monitor_speed = 115200 + +# +# MEEB_3DP (STM32F103RCT6 with 512K) +# +[env:STM32F103RC_meeb] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = MEEB_3DP +build_flags = ${common_stm32f1.build_flags} + -DDEBUG_LEVEL=0 + -DSS_TIMER=4 + -DSTM32_FLASH_SIZE=512 + -DHSE_VALUE=12000000U + -DUSE_USB_COMPOSITE + -DVECT_TAB_OFFSET=0x2000 + -DGENERIC_BOOTLOADER +extra_scripts = ${common_stm32f1.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py + buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +lib_deps = ${common.lib_deps} + SoftwareSerialM + USBComposite for STM32F1@0.91 +custom_marlin.NEOPIXEL_LED = Adafruit NeoPixel=https://github.com/ccccmagicboy/Adafruit_NeoPixel#meeb_3dp_use +debug_tool = stlink +upload_protocol = dfu + +# +# STM32F103RC_fysetc +# +[env:STM32F103RC_fysetc] +platform = ${common_stm32f1.platform} +extends = env:STM32F103RC +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 +lib_ldf_mode = chain +debug_tool = stlink +upload_protocol = serial + +# +# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3) +# +# STM32F103RC_btt ............. RCT6 with 256K +# STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) +# STM32F103RC_btt_512K ........ RCT6 with 512K +# STM32F103RC_btt_512K_USB .... RCT6 with 512K (USB mass storage) +# +# WARNING! If you have an SKR Mini v1.1 or an SKR Mini E3 1.0 / 1.2 / 2.0 / DIP +# and experience a printer freeze, re-flash Marlin using the regular (non-512K) +# build option. 256K chips may be re-branded 512K chips, but this means the +# upper 256K is sketchy, and failure is very likely. +# + +[env:STM32F103RC_btt] +platform = ${common_stm32f1.platform} +extends = env:STM32F103RC +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py +build_flags = ${common_stm32f1.build_flags} + -DDEBUG_LEVEL=0 -DSS_TIMER=4 +monitor_speed = 115200 + +[env:STM32F103RC_btt_USB] +platform = ${common_stm32f1.platform} +extends = env:STM32F103RC_btt +build_flags = ${env:STM32F103RC_btt.build_flags} -DUSE_USB_COMPOSITE +lib_deps = ${env:STM32F103RC_btt.lib_deps} + USBComposite for STM32F1@0.91 + +[env:STM32F103RC_btt_512K] +platform = ${common_stm32f1.platform} +extends = env:STM32F103RC_btt +board_upload.maximum_size=524288 +build_flags = ${env:STM32F103RC_btt.build_flags} -DSTM32_FLASH_SIZE=512 + +[env:STM32F103RC_btt_512K_USB] +platform = ${common_stm32f1.platform} +extends = env:STM32F103RC_btt_512K +build_flags = ${env:STM32F103RC_btt_512K.build_flags} -DUSE_USB_COMPOSITE +lib_deps = ${env:STM32F103RC_btt_512K.lib_deps} + USBComposite for STM32F1@0.91 + +# +# STM32F103RE +# +[env:STM32F103RE] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103RE +monitor_speed = 115200 + +# +# STM32F103RE_btt ............. RET6 +# STM32F103RE_btt_USB ......... RET6 (USB mass storage) +# +[env:STM32F103RE_btt] +platform = ${common_stm32f1.platform} +extends = env:STM32F103RE +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py +build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 +debug_tool = stlink +upload_protocol = stlink + +[env:STM32F103RE_btt_USB] +platform = ${common_stm32f1.platform} +extends = env:STM32F103RE_btt +build_flags = ${env:STM32F103RE_btt.build_flags} -DUSE_USB_COMPOSITE +lib_deps = ${common_stm32f1.lib_deps} + USBComposite for STM32F1@0.91 + +# +# Geeetech GTM32 (STM32F103VET6) +# +[env:STM32F103VE_GTM32] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103VE +build_flags = ${common_stm32f1.build_flags} + -ffunction-sections -fdata-sections -nostdlib -MMD + -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 -DBOARD_generic_stm32f103v + -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DVECT_TAB_ADDR=0x8000000 + -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 +upload_protocol = serial + +# +# Longer 3D board in Alfawise U20 (STM32F103VET6) +# +[env:STM32F103VE_longer] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103VE +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py +build_flags = ${common_stm32f1.build_flags} + -DMCU_STM32F103VE -DSTM32F1xx -USERIAL_USB -DU20 -DTS_V12 +build_unflags = ${common_stm32f1.build_unflags} + -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 + +# +# MKS Robin Mini (STM32F103VET6) +# +[env:mks_robin_mini] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103VE +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin_mini.py +build_flags = ${common_stm32f1.build_flags} + -DMCU_STM32F103VE + +# +# MKS Robin Nano (STM32F103VET6) +# +[env:mks_robin_nano35] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103VE +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +build_flags = ${common_stm32f1.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 +debug_tool = jlink +upload_protocol = jlink + +# +# MKS Robin (STM32F103ZET6) +# +[env:mks_robin] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103ZE +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin.py +build_flags = ${common_stm32f1.build_flags} + -DSS_TIMER=4 -DSTM32_XL_DENSITY + +# MKS Robin (STM32F103ZET6) +# Uses HAL STM32 to support Marlin UI for TFT screen with optional touch panel +# +[env:mks_robin_stm32] +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F103ZE +board_build.core = stm32 +board_build.variant = MARLIN_F103Zx +board_build.ldscript = ldscript.ld +board_build.offset = 0x7000 +board_build.encrypt = Yes +board_build.firmware = Robin.bin +build_flags = ${common_stm32.build_flags} + -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 +build_unflags = ${common_stm32.build_unflags} + -DUSBCON -DUSBD_USE_CDC +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + buildroot/share/PlatformIO/scripts/mks_encrypt.py +lib_deps = + +# +# MKS Robin Pro (STM32F103ZET6) +# +[env:mks_robin_pro] +platform = ${common_stm32f1.platform} +extends = env:mks_robin +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin_pro.py + +# +# TRIGORILLA PRO (STM32F103ZET6) +# +[env:trigorilla_pro] +platform = ${common_stm32f1.platform} +extends = env:mks_robin +extra_scripts = ${common_stm32f1.extra_scripts} + +# +# MKS Robin E3D (STM32F103RCT6) and +# MKS Robin E3 with TMC2209 +# +[env:mks_robin_e3] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103RC +platform_packages = tool-stm32duino +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin_e3.py +build_flags = ${common_stm32f1.build_flags} + -DDEBUG_LEVEL=0 -DSS_TIMER=4 + +# +# MKS Robin E3p (STM32F103VET6) +# - LVGL UI +# +[env:mks_robin_e3p] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103VE +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +build_flags = ${common_stm32f1.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 +debug_tool = jlink +upload_protocol = jlink + +# +# MKS Robin Lite/Lite2 (STM32F103RCT6) +# +[env:mks_robin_lite] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103RC +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin_lite.py + +# +# MKS ROBIN LITE3 (STM32F103RCT6) +# +[env:mks_robin_lite3] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103RC +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/mks_robin_lite3.py + +# +# JGAurora A5S A1 (STM32F103ZET6) +# +[env:jgaurora_a5s_a1] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103ZE +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +build_flags = ${common_stm32f1.build_flags} + -DSTM32F1xx -DSTM32_XL_DENSITY + +# +# Malyan M200 (STM32F103CB) +# +[env:STM32F103CB_malyan] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = malyanM200 +build_flags = ${common_stm32f1.build_flags} + -DMCU_STM32F103CB -D__STM32F1__=1 -std=c++1y -DSERIAL_USB -ffunction-sections -fdata-sections + -Wl,--gc-sections -DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__ +lib_ignore = ${common_stm32f1.lib_ignore} + SoftwareSerialM + +# +# Chitu boards like Tronxy X5s (STM32F103ZET6) +# +[env:chitu_f103] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = CHITU_F103 +extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py + pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py + buildroot/share/PlatformIO/scripts/chitu_crypt.py +build_flags = ${common_stm32f1.build_flags} + -DSTM32F1xx -DSTM32_XL_DENSITY +build_unflags = ${common_stm32f1.build_unflags} + -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG= -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 + +# +# Some Chitu V5 boards have a problem with GPIO init. +# Use this target if G28 or G29 are always failing. +# +[env:chitu_v5_gpio_init] +platform = ${common_stm32f1.platform} +extends = env:chitu_f103 +build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX + +# +# Creality (STM32F103RET6) +# +[env:STM32F103RET6_creality] +platform = ${env:STM32F103RE.platform} +extends = env:STM32F103RE +build_flags = ${env:STM32F103RE.build_flags} -DTEMP_TIMER_CHAN=4 +extra_scripts = ${env:STM32F103RE.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/random-bin.py + buildroot/share/PlatformIO/scripts/STM32F103RET6_creality.py +debug_tool = jlink +upload_protocol = jlink + +# +# FLSUN QQS Pro (STM32F103VET6) using hal STM32 +# board Hispeedv1 +# +[env:flsun_hispeedv1] +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 +board = genericSTM32F103VE +board_build.core = stm32 +board_build.variant = MARLIN_F103Vx +board_build.ldscript = ldscript.ld +board_build.offset = 0x7000 +board_build.firmware = Robin_mini.bin +board_build.encrypt = Yes +board_upload.offset_address = 0x08007000 +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + buildroot/share/PlatformIO/scripts/mks_encrypt.py + +# +# MKS Robin Nano V1.2 and V2 using hal STM32 +# +[env:mks_robin_nano35_stm32] +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 +board = genericSTM32F103VE +board_build.core = stm32 +board_build.variant = MARLIN_F103Vx +board_build.ldscript = ldscript.ld +board_build.offset = 0x7000 +board_build.encrypt = Yes +board_build.firmware = Robin_nano35.bin +board_upload.offset_address = 0x08007000 +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC +debug_tool = jlink +upload_protocol = jlink +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + buildroot/share/PlatformIO/scripts/mks_encrypt.py + +# +# Mingda MPX_ARM_MINI +# +[env:mingda_mpx_arm_mini] +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F103ZE +board_build.core = stm32 +board_build.variant = MARLIN_F103Zx +board_build.ldscript = ldscript.ld +board_build.offset = 0x10000 +build_flags = ${common_stm32.build_flags} -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini new file mode 100644 index 0000000000..a15dc8b056 --- /dev/null +++ b/ini/stm32f4.ini @@ -0,0 +1,371 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# STM32F4 Architecture # +# # +################################# + +# +# ARMED (STM32) +# +[env:ARMED] +platform = ${common_stm32.platform} +extends = common_stm32 +board = armed_v1 +build_flags = ${common_stm32.build_flags} + -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing + +# +# STM32F401VE +# 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html +# +[env:STM32F401VE_STEVAL] +platform = ${common_stm32.platform} +extends = common_stm32 +board = STEVAL_STM32F401VE +build_flags = ${common_stm32.build_flags} + -DARDUINO_STEVAL -DSTM32F401xE + -DDISABLE_GENERIC_SERIALUSB -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/STM32F401VE_STEVAL.py + +# +# STM32F401RC +# +[env:FYSETC_CHEETAH_V20] +platform = ${common_stm32.platform} +extends = common_stm32 +board = FYSETC_CHEETAH_V20 +build_flags = ${common_stm32.build_flags} -DSTM32F401xC -DVECT_TAB_OFFSET=0xC000 +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/FYSETC_CHEETAH_V20.py + +# +# FLYF407ZG +# +[env:FLYF407ZG] +platform = ${common_stm32.platform} +extends = common_stm32 +board = FLYF407ZG +build_flags = ${common_stm32.build_flags} + -DVECT_TAB_OFFSET=0x8000 +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + +# +# FLY MINI(stm32f103rct6) +# +[env:FLY_MINI] +platform = ${common_stm32f1.platform} +extends = common_stm32f1 +board = genericSTM32F103RC +extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/fly_mini.py +build_flags = ${common_stm32f1.build_flags} + -DDEBUG_LEVEL=0 -DSS_TIMER=4 + +# +# FYSETC S6 (STM32F446VET6 ARM Cortex-M4) +# +[env:FYSETC_S6] +platform = ${common_stm32.platform} +extends = common_stm32 +platform_packages = tool-stm32duino +board = marlin_fysetc_s6 +build_flags = ${common_stm32.build_flags} + -DVECT_TAB_OFFSET=0x10000 + -DHAL_PCD_MODULE_ENABLED +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +debug_tool = stlink +upload_protocol = dfu +upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" + +# +# STM32F407VET6 with RAMPS-like shield +# 'Black' STM32F407VET6 board - https://wiki.stm32duino.com/index.php?title=STM32F407 +# Shield - https://github.com/jmz52/Hardware +# +[env:STM32F407VE_black] +platform = ${common_stm32.platform} +extends = common_stm32 +board = blackSTM32F407VET6 +build_flags = ${common_stm32.build_flags} + -DARDUINO_BLACK_F407VE + -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + +# +# Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4) +# For use with with davidtgbe's OpenBLT bootloader https://github.com/davidtgbe/openblt/releases +# Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000. +# +[env:Anet_ET4_OpenBLT] +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED +board = genericSTM32F407VGT6 +board_build.core = stm32 +board_build.variant = MARLIN_F4x7Vx +board_build.ldscript = ldscript.ld +board_build.firmware = firmware.srec +# Just openblt.py (not stm32_bootloader.py) generates the file +board_build.encrypt = Yes +board_build.offset = 0x10000 +board_upload.offset_address = 0x08010000 +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 +debug_tool = jlink +upload_protocol = jlink +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + buildroot/share/PlatformIO/scripts/openblt.py + +# +# BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) +# +[env:BIGTREE_SKR_PRO] +platform = ${common_stm32.platform} +extends = common_stm32 +board = BigTree_SKR_Pro +build_flags = ${common_stm32.build_flags} + -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000 +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +#upload_protocol = stlink +#upload_command = "$PROJECT_PACKAGES_DIR/tool-stm32duino/stlink/ST-LINK_CLI.exe" -c SWD -P "$BUILD_DIR/firmware.bin" 0x8008000 -Rst -Run +debug_tool = stlink +debug_init_break = + +# +# USB Flash Drive mix-ins for STM32 +# +[stm_flash_drive] +platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DHAL_HCD_MODULE_ENABLED + -DUSBHOST -DUSBH_IRQ_PRIO=3 -DUSBH_IRQ_SUBPRIO=4 + +# +# BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support +# +[env:BIGTREE_SKR_PRO_usb_flash_drive] +extends = env:BIGTREE_SKR_PRO +platform_packages = ${stm_flash_drive.platform_packages} +build_unflags = -DUSBCON -DUSBD_USE_CDC +build_flags = ${stm_flash_drive.build_flags} + -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000 + +# +# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) +# +[env:BIGTREE_GTR_V1_0] +platform = ${common_stm32.platform} +extends = common_stm32 +board = BigTree_GTR_v1 +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +build_flags = ${common_stm32.build_flags} + -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000 + +# +# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support +# +[env:BIGTREE_GTR_V1_0_usb_flash_drive] +extends = env:BIGTREE_GTR_V1_0 +platform_packages = ${stm_flash_drive.platform_packages} +build_unflags = -DUSBCON -DUSBD_USE_CDC +build_flags = ${stm_flash_drive.build_flags} + -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000 + +# +# BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4) +# +[env:BIGTREE_BTT002] +platform = ${common_stm32.platform} +extends = common_stm32 +board = BigTree_Btt002 +build_flags = ${common_stm32.build_flags} + -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000 + -DHAVE_HWSERIAL2 + -DHAVE_HWSERIAL3 + -DPIN_SERIAL2_RX=PD_6 + -DPIN_SERIAL2_TX=PD_5 +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + +# +# Lerdge base +# +[lerdge_common] +platform = ${common_stm32.platform} +extends = common_stm32 +board = LERDGE +board_build.offset = 0x10000 +board_build.encrypt = Yes +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + buildroot/share/PlatformIO/scripts/lerdge.py +build_flags = ${common_stm32.build_flags} + -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4 + -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DARDUINO_LERDGE + -DHAL_SRAM_MODULE_ENABLED +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 + +# +# Lerdge X +# +[env:LERDGEX] +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.firmware = Lerdge_X_firmware_force.bin + +# +# Lerdge X with USB Flash Drive Support +# +[env:LERDGEX_usb_flash_drive] +platform = ${env:LERDGEX.platform} +extends = env:LERDGEX +platform_packages = ${stm_flash_drive.platform_packages} +build_flags = ${stm_flash_drive.build_flags} + +# +# Lerdge S +# +[env:LERDGES] +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.firmware = Lerdge_firmware_force.bin + +# +# Lerdge S with USB Flash Drive Support +# +[env:LERDGES_usb_flash_drive] +platform = ${env:LERDGES.platform} +extends = env:LERDGES +platform_packages = ${stm_flash_drive.platform_packages} +build_flags = ${stm_flash_drive.build_flags} + +# +# Lerdge K +# +[env:LERDGEK] +platform = ${lerdge_common.platform} +extends = lerdge_common +board_build.firmware = Lerdge_K_firmware_force.bin +build_flags = ${lerdge_common.build_flags} + -DLERDGEK + +# +# Lerdge K with USB Flash Drive Support +# +[env:LERDGEK_usb_flash_drive] +platform = ${env:LERDGEK.platform} +extends = env:LERDGEK +platform_packages = ${stm_flash_drive.platform_packages} +build_flags = ${stm_flash_drive.build_flags} + +# +# RUMBA32 +# +[env:rumba32] +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} + -Os + -DHAL_PCD_MODULE_ENABLED + -DDISABLE_GENERIC_SERIALUSB + -DHAL_UART_MODULE_ENABLED + -DTIMER_SERIAL=TIM9 +board = rumba32_f446ve +upload_protocol = dfu +monitor_speed = 500000 + +# +# MKS Robin Pro V2 +# +[env:mks_robin_pro2] +platform = ${common_stm32.platform} +platform_packages = ${stm_flash_drive.platform_packages} +extends = common_stm32 +build_flags = ${stm_flash_drive.build_flags} +board = genericSTM32F407VET6 +board_build.core = stm32 +board_build.variant = MARLIN_F4x7Vx +board_build.ldscript = ldscript.ld +board_build.firmware = firmware.bin +board_build.offset = 0x0000 +board_upload.offset_address = 0x08000000 +build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC +debug_tool = jlink +upload_protocol = jlink +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + +# +# This SPI is used by Robin Nano V3 +# +[stm32f4_I2C1] +build_flags = -DPIN_WIRE_SCL=PB6 -DPIN_WIRE_SDA=PB7 + +# +# MKS Robin Nano V3 +# +[env:mks_robin_nano_v3] +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} ${stm32f4_I2C1.build_flags} -DHAL_PCD_MODULE_ENABLED -DUSBCON -DUSBD_USE_CDC +board = genericSTM32F407VGT6 +board_build.core = stm32 +board_build.variant = MARLIN_F4x7Vx +board_build.ldscript = ldscript.ld +board_build.firmware = Robin_nano_v3.bin +board_build.offset = 0xC000 +board_upload.offset_address = 0x0800C000 +build_unflags = ${common_stm32.build_unflags} +debug_tool = jlink +upload_protocol = jlink +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py + +# +# MKS Robin Nano V3 with USB Flash Drive Support +# Currently, using a STM32duino fork, until USB Host get merged +# +[env:mks_robin_nano_v3_usb_flash_drive] +extends = env:mks_robin_nano_v3 +platform_packages = ${stm_flash_drive.platform_packages} +build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} + -DUSBCON + -DUSE_USBHOST_HS + -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -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] +platform = ${common_stm32.platform} +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 = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} + -DUSBCON + -DUSE_USBHOST_HS + -DUSBD_IRQ_PRIO=5 + -DUSBD_IRQ_SUBPRIO=6 + -DUSE_USB_HS_IN_FS + -DUSBD_USE_CDC_MSC diff --git a/ini/stm32f7.ini b/ini/stm32f7.ini new file mode 100644 index 0000000000..442ef5f9b0 --- /dev/null +++ b/ini/stm32f7.ini @@ -0,0 +1,30 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# STM32F7 Architecture # +# # +################################# + +# +# ST NUCLEO-F767ZI Development Board +# This environment is for testing purposes prior to control boards +# being readily available based on STM32F7 MCUs +# +[env:NUCLEO_F767ZI] +platform = ${common_stm32.platform} +extends = common_stm32 +board = nucleo_f767zi +build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 + +# +# REMRAM_V1 +# +[env:REMRAM_V1] +platform = ${common_stm32.platform} +extends = common_stm32 +board = remram_v1 +build_flags = ${common_stm32.build_flags} diff --git a/ini/teensy.ini b/ini/teensy.ini new file mode 100644 index 0000000000..ae33cc7a02 --- /dev/null +++ b/ini/teensy.ini @@ -0,0 +1,42 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# Teensy Architectures # +# # +################################# + +# +# Teensy 3.1 / 3.2 (ARM Cortex-M4) +# +[env:teensy31] +platform = teensy +board = teensy31 +src_filter = ${common.default_src_filter} + +lib_ignore = NativeEthernet + +# +# Teensy 3.5 / 3.6 (ARM Cortex-M4) +# +[env:teensy35] +platform = teensy +board = teensy35 +src_filter = ${common.default_src_filter} + +lib_ignore = NativeEthernet + +[env:teensy36] +platform = teensy +board = teensy36 +src_filter = ${common.default_src_filter} + +lib_ignore = NativeEthernet + +# +# Teensy 4.0 / 4.1 (ARM Cortex-M7) +# +[env:teensy41] +platform = teensy +board = teensy41 +src_filter = ${common.default_src_filter} + diff --git a/platformio.ini b/platformio.ini index 26b27bbf99..913bb44ae0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,6 +20,19 @@ src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards default_envs = mega2560 include_dir = Marlin +extra_configs = + ini/avr.ini + ini/due.ini + ini/esp32.ini + ini/features.ini + ini/lpc176x.ini + ini/native.ini + ini/samd51.ini + ini/stm32f0.ini + ini/stm32f1.ini + ini/stm32f4.ini + ini/stm32f7.ini + ini/teensy.ini # # The 'common' values are used for most Marlin builds @@ -222,217 +235,6 @@ extra_scripts = build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants lib_deps = -# -# Feature Dependencies -# -[features] -YHCB2004 = red-scorp/LiquidCrystal_AIP31068@^1.0.4, red-scorp/SoftSPIB@^1.1.1 -HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip - src_filter=+ - extra_scripts=download_mks_assets.py -POSTMORTEM_DEBUGGING = src_filter=+ + - build_flags=-funwind-tables -MKS_WIFI_MODULE = QRCode=https://github.com/makerbase-mks/QRCode/archive/master.zip -HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.1 - src_filter=+ + + + + -HAS_STEALTHCHOP = src_filter=+ -SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip -HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster - src_filter=+ -HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip - src_filter=+ -HAS_L64XX = Arduino-L6470@0.8.0 - src_filter=+ + + + -NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 - src_filter=+ -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 -HAS_WIRED_LCD = src_filter=+ -HAS_MARLINUI_HD44780 = src_filter=+ -HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.1 - src_filter=+ -HAS_(FSMC|SPI)_TFT = src_filter=+ + + -HAS_FSMC_TFT = src_filter=+ + -HAS_SPI_TFT = src_filter=+ + -I2C_EEPROM = src_filter=+ -SPI_EEPROM = src_filter=+ -HAS_GRAPHICAL_TFT = src_filter=+ -DWIN_CREALITY_LCD = src_filter=+ -IS_TFTGLCD_PANEL = src_filter=+ -HAS_TOUCH_BUTTONS = src_filter=+ -HAS_LCD_MENU = src_filter=+ -HAS_GAMES = src_filter=+ -MARLIN_BRICKOUT = src_filter=+ -MARLIN_INVADERS = src_filter=+ -MARLIN_MAZE = src_filter=+ -MARLIN_SNAKE = src_filter=+ -HAS_MENU_BACKLASH = src_filter=+ -HAS_MENU_BED_CORNERS = src_filter=+ -LCD_BED_LEVELING = src_filter=+ -HAS_MENU_CANCELOBJECT = src_filter=+ -HAS_MENU_DELTA_CALIBRATE = src_filter=+ -HAS_MENU_FILAMENT = src_filter=+ -LCD_INFO_MENU = src_filter=+ -HAS_MENU_JOB_RECOVERY = src_filter=+ -HAS_MULTI_LANGUAGE = src_filter=+ -HAS_MENU_LED = src_filter=+ -HAS_MENU_MEDIA = src_filter=+ -HAS_MENU_MIXER = src_filter=+ -HAS_MENU_MMU2 = src_filter=+ -HAS_MENU_PASSWORD = src_filter=+ -HAS_MENU_POWER_MONITOR = src_filter=+ -HAS_MENU_CUTTER = src_filter=+ -HAS_MENU_TEMPERATURE = src_filter=+ -HAS_MENU_TMC = src_filter=+ -HAS_MENU_TOUCH_SCREEN = src_filter=+ -HAS_MENU_TRAMMING = src_filter=+ -HAS_MENU_UBL = src_filter=+ -ANYCUBIC_LCD_CHIRON = src_filter=+ + -ANYCUBIC_LCD_I3MEGA = src_filter=+ + -NEXTION_TFT = src_filter=+ + -HAS_DGUS_LCD = src_filter=+ + -DGUS_LCD_UI_FYSETC = src_filter=+ -DGUS_LCD_UI_HIPRECY = src_filter=+ -DGUS_LCD_UI_MKS = src_filter=+ -DGUS_LCD_UI_ORIGIN = src_filter=+ -TOUCH_UI_FTDI_EVE = src_filter=+ -EXTUI_EXAMPLE = src_filter=+ -MALYAN_LCD = src_filter=+ -USE_UHS2_USB = src_filter=+ -USE_UHS3_USB = src_filter=+ -USB_FLASH_DRIVE_SUPPORT = src_filter=+ -AUTO_BED_LEVELING_BILINEAR = src_filter=+ -AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ -MESH_BED_LEVELING = src_filter=+ + -AUTO_BED_LEVELING_UBL = src_filter=+ + -UBL_HILBERT_CURVE = src_filter=+ -BACKLASH_COMPENSATION = src_filter=+ -BARICUDA = src_filter=+ + -BINARY_FILE_TRANSFER = src_filter=+ + -BLTOUCH = src_filter=+ -CANCEL_OBJECTS = src_filter=+ + -CASE_LIGHT_ENABLE = src_filter=+ + -EXTERNAL_CLOSED_LOOP_CONTROLLER = src_filter=+ + -USE_CONTROLLER_FAN = src_filter=+ -HAS_MOTOR_CURRENT_DAC = src_filter=+ -DIRECT_STEPPING = src_filter=+ + -EMERGENCY_PARSER = src_filter=+ - -I2C_POSITION_ENCODERS = src_filter=+ -IIC_BL24CXX_EEPROM = src_filter=+ -HAS_SPI_FLASH = src_filter=+ -HAS_ETHERNET = src_filter=+ + -HAS_FANMUX = src_filter=+ -FILAMENT_WIDTH_SENSOR = src_filter=+ + -FWRETRACT = src_filter=+ + -HOST_ACTION_COMMANDS = src_filter=+ -HOTEND_IDLE_TIMEOUT = src_filter=+ -JOYSTICK = src_filter=+ -BLINKM = src_filter=+ -HAS_COLOR_LEDS = src_filter=+ + -PCA9533 = src_filter=+ -PCA9632 = src_filter=+ -PRINTER_EVENT_LEDS = src_filter=+ -TEMP_STAT_LEDS = src_filter=+ -MAX7219_DEBUG = src_filter=+ + -HAS_MEATPACK = src_filter=+ -MIXING_EXTRUDER = src_filter=+ + -HAS_PRUSA_MMU1 = src_filter=+ -HAS_PRUSA_MMU2 = src_filter=+ + -PASSWORD_FEATURE = src_filter=+ + -ADVANCED_PAUSE_FEATURE = src_filter=+ + + -AUTO_POWER_CONTROL = src_filter=+ -HAS_POWER_MONITOR = src_filter=+ + -POWER_LOSS_RECOVERY = src_filter=+ + -PROBE_TEMP_COMPENSATION = src_filter=+ + -HAS_FILAMENT_SENSOR = src_filter=+ + -(EXT|MANUAL)_SOLENOID.* = src_filter=+ + -MK2_MULTIPLEXER = src_filter=+ -HAS_CUTTER = src_filter=+ + -EXPERIMENTAL_I2CBUS = src_filter=+ + -MECHANICAL_GANTRY_CAL.+ = src_filter=+ -Z_MULTI_ENDSTOPS = src_filter=+ -Z_STEPPER_AUTO_ALIGN = src_filter=+ + -G26_MESH_VALIDATION = src_filter=+ -ASSISTED_TRAMMING = src_filter=+ + -HAS_MESH = src_filter=+ -HAS_LEVELING = src_filter=+ + -DELTA_AUTO_CALIBRATION = src_filter=+ -CALIBRATION_GCODE = src_filter=+ -Z_MIN_PROBE_REPEATABILITY_TEST = src_filter=+ -M100_FREE_MEMORY_WATCHER = src_filter=+ -BACKLASH_GCODE = src_filter=+ -IS_KINEMATIC = src_filter=+ -HAS_EXTRA_ENDSTOPS = src_filter=+ -SKEW_CORRECTION_GCODE = src_filter=+ -DIRECT_PIN_CONTROL = src_filter=+ + -PINS_DEBUGGING = src_filter=+ -NO_VOLUMETRICS = src_filter=- -HAS_MULTI_EXTRUDER = src_filter=+ -HAS_HOTEND_OFFSET = src_filter=+ -EDITABLE_SERVO_ANGLES = src_filter=+ -PIDTEMP = src_filter=+ -PREVENT_COLD_EXTRUSION = src_filter=+ -PIDTEMPBED = src_filter=+ -HAS_USER_THERMISTORS = src_filter=+ -SD_ABORT_ON_ENDSTOP_HIT = src_filter=+ -BAUD_RATE_GCODE = src_filter=+ -HAS_SMART_EFF_MOD = src_filter=+ -COOLANT_CONTROL = src_filter=+ -HAS_SOFTWARE_ENDSTOPS = src_filter=+ -HAS_DUPLICATION_MODE = src_filter=+ -LIN_ADVANCE = src_filter=+ -PHOTO_GCODE = src_filter=+ -CONTROLLER_FAN_EDITABLE = src_filter=+ -GCODE_MACROS = src_filter=+ -GRADIENT_MIX = src_filter=+ -HAS_SAVED_POSITIONS = src_filter=+ + -PARK_HEAD_ON_PAUSE = src_filter=+ -FILAMENT_LOAD_UNLOAD_GCODES = src_filter=+ -CNC_WORKSPACE_PLANES = src_filter=+ -CNC_COORDINATE_SYSTEMS = src_filter=+ -HAS_M206_COMMAND = src_filter=+ -EXPECTED_PRINTER_CHECK = src_filter=+ -HOST_KEEPALIVE_FEATURE = src_filter=+ -REPETIER_GCODE_M360 = src_filter=+ -HAS_GCODE_M876 = src_filter=+ -HAS_RESUME_CONTINUE = src_filter=+ -HAS_LCD_CONTRAST = src_filter=+ -LCD_SET_PROGRESS_MANUALLY = src_filter=+ -TOUCH_SCREEN_CALIBRATION = src_filter=+ -ARC_SUPPORT = src_filter=+ -GCODE_MOTION_MODES = src_filter=+ -BABYSTEPPING = src_filter=+ + -Z_PROBE_SLED = src_filter=+ -G38_PROBE_TARGET = src_filter=+ -MAGNETIC_PARKING_EXTRUDER = src_filter=+ -SDSUPPORT = src_filter=+ + + + + + + -HAS_MEDIA_SUBCALLS = src_filter=+ -GCODE_REPEAT_MARKERS = src_filter=+ + -HAS_EXTRUDERS = src_filter=+ + -HAS_COOLER = src_filter=+ + -AUTO_REPORT_TEMPERATURES = src_filter=+ -INCH_MODE_SUPPORT = src_filter=+ -TEMPERATURE_UNITS_SUPPORT = src_filter=+ -NEED_HEX_PRINT = src_filter=+ -NEED_LSF = src_filter=+ -NOZZLE_PARK_FEATURE = src_filter=+ + -NOZZLE_CLEAN_FEATURE = src_filter=+ + -DELTA = src_filter=+ + -BEZIER_CURVE_SUPPORT = src_filter=+ + -PRINTCOUNTER = src_filter=+ -HAS_BED_PROBE = src_filter=+ + + + -IS_SCARA = src_filter=+ -HAS_SERVOS = src_filter=+ + -MORGAN_SCARA = src_filter=+ -HAS_MICROSTEPS = src_filter=+ -(ESP3D_)?WIFISUPPORT = AsyncTCP, ESP Async WebServer - ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master.zip - arduinoWebSockets=links2004/WebSockets@2.3.4 - luc-github/ESP32SSDP@^1.1.1 - lib_ignore=ESPAsyncTCP - # # Default values apply to all 'env:' prefixed environments # @@ -452,1208 +254,6 @@ monitor_flags = --filter time -################################# -# # -# Unique Core Architectures # -# # -# Add a new "env" below if no # -# entry has values suitable to # -# build for a given board. # -# # -################################# - -################################# -# # -# AVR Architecture # -# # -################################# - -# -# AVR (8-bit) Common Environment values -# -[common_avr8] -board_build.f_cpu = 16000000L -src_filter = ${common.default_src_filter} + - -# -# ATmega2560 -# -[env:mega2560] -platform = atmelavr -extends = common_avr8 -board = megaatmega2560 - -# -# ATmega2560 with extended pins 70-85 defined -# BOARD_BQ_ZUM_MEGA_3D -# BOARD_ULTIMAIN_2 -# BOARD_MIGHTYBOARD_REVE -# BOARD_EINSTART_S -# -[env:mega2560ext] -platform = atmelavr -extends = env:mega2560 -board_build.variant = megaextendedpins -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py - -# -# ATmega1280 -# -[env:mega1280] -platform = atmelavr -extends = common_avr8 -board = megaatmega1280 - -# -# MightyBoard AVR with extended pins -# -[mega_extended_optimized] -extends = common_avr8 -board_build.variant = megaextendedpins -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py -upload_speed = 57600 -build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues - -# -# MightyBoard ATmega1280 -# -[env:MightyBoard1280] -platform = atmelavr -extends = mega_extended_optimized -board = megaatmega1280 - -# -# MightyBoard ATmega2560 -# -[env:MightyBoard2560] -platform = atmelavr -extends = mega_extended_optimized -board = megaatmega2560 - -# -# RAMBo -# -[env:rambo] -platform = atmelavr -extends = common_avr8 -board = reprap_rambo - -# -# FYSETC F6 V1.3 / V1.4 -# -[env:FYSETC_F6] -platform = atmelavr -extends = common_avr8 -board = fysetc_f6 - -# -# Sanguinololu (ATmega644p) -# -[env:sanguino644p] -platform = atmelavr -extends = common_avr8 -board = sanguino_atmega644p - -# -# Sanguinololu (ATmega1284p) -# -[env:sanguino1284p] -platform = atmelavr -extends = common_avr8 -board = sanguino_atmega1284p -board_upload.maximum_size = 126976 - -# -# Melzi and clones (ATmega1284p) -# -[env:melzi] -platform = atmelavr -extends = env:sanguino1284p -upload_speed = 57600 - -# -# Sanguinololu (ATmega1284p stock bootloader with tuned flags) -# - -[tuned_1284p] -build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues - -[env:sanguino1284p_optimized] -platform = atmelavr -extends = env:melzi -build_flags = ${tuned_1284p.build_flags} - -# -# Melzi and clones (alias for sanguino1284p_optimized) -# -[env:melzi_optimized] -platform = atmelavr -extends = env:sanguino1284p_optimized - -# -# Melzi and clones (Optiboot bootloader) -# -[env:melzi_optiboot] -platform = atmelavr -extends = common_avr8 -board = sanguino_atmega1284p -upload_speed = 115200 - -# -# Melzi and clones (Zonestar Melzi2 with tuned flags) -# -[env:melzi_optiboot_optimized] -platform = atmelavr -extends = env:melzi_optiboot -build_flags = ${tuned_1284p.build_flags} - -# -# AT90USB1286 boards using CDC bootloader -# - BRAINWAVE -# - BRAINWAVE_PRO -# - SAV_MKI -# - TEENSYLU -# -[env:at90usb1286_cdc] -platform = teensy -extends = common_avr8 -board = at90usb1286 -lib_ignore = ${env:common_avr8.lib_ignore}, Teensy_ADC, NativeEthernet - -# -# AT90USB1286 boards using DFU bootloader -# - Printrboard -# - Printrboard Rev.F -# - ? 5DPRINT ? -# -[env:at90usb1286_dfu] -platform = teensy -extends = env:at90usb1286_cdc - -################################# -# # -# DUE Architecture # -# # -################################# - -# -# Due (Atmel SAM3X8E ARM Cortex-M3) -# -# - RAMPS4DUE -# - RADDS -# -[env:DUE] -platform = atmelsam -board = due -src_filter = ${common.default_src_filter} + + - -[env:DUE_USB] -platform = atmelsam -extends = env:DUE -board = dueUSB - -# -# Archim SAM -# -[common_DUE_archim] -platform = atmelsam -extends = env:DUE -board = archim -build_flags = ${common.build_flags} - -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSBCON -board_build.variants_dir = buildroot/share/PlatformIO/variants/ -extra_scripts = ${common.extra_scripts} - Marlin/src/HAL/DUE/upload_extra_script.py - -[env:DUE_archim] -platform = ${common_DUE_archim.platform} -extends = common_DUE_archim - -################################# -# # -# SAMD51 Architecture # -# # -################################# - -# -# Adafruit Grand Central M4 (Atmel SAMD51P20A ARM Cortex-M4) -# -[env:SAMD51_grandcentral_m4] -platform = atmelsam -board = adafruit_grandcentral_m4 -build_flags = ${common.build_flags} -std=gnu++17 -build_unflags = -std=gnu++11 -src_filter = ${common.default_src_filter} + -lib_deps = ${common.lib_deps} - SoftwareSerialM - Adafruit SPIFlash -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py -custom_marlin.SDSUPPORT = SdFat - Adafruit Fork -debug_tool = jlink - -################################# -# # -# LPC176x Architecture # -# # -################################# - -# -# NXP LPC176x ARM Cortex-M3 -# -[common_LPC] -platform = https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.3.zip -platform_packages = framework-arduino-lpc176x@^0.2.6 -board = nxp_lpc1768 -lib_ldf_mode = off -lib_compat_mode = strict -extra_scripts = ${common.extra_scripts} - Marlin/src/HAL/LPC1768/upload_extra_script.py -src_filter = ${common.default_src_filter} + + -lib_deps = ${common.lib_deps} - Servo -custom_marlin.USES_LIQUIDCRYSTAL = arduino-libraries/LiquidCrystal@~1.0.7 -custom_marlin.NEOPIXEL_LED = Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/1.5.0.zip -build_flags = ${common.build_flags} -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC1768/include -IMarlin/src/HAL/LPC1768/u8g - # debug options for backtrace - #-funwind-tables - #-mpoke-function-name - -# -# NXP LPC176x ARM Cortex-M3 -# -[env:LPC1768] -platform = ${common_LPC.platform} -extends = common_LPC -board = nxp_lpc1768 - -[env:LPC1769] -platform = ${common_LPC.platform} -extends = common_LPC -board = nxp_lpc1769 - -################################# -# # -# STM32 Architecture # -# # -################################# - -# -# HAL/STM32 Base Environment values -# -[common_stm32] -platform = ststm32@~12.0 -build_flags = ${common.build_flags} - -std=gnu++14 - -DUSBCON -DUSBD_USE_CDC - -DTIM_IRQ_PRIO=13 - -DADC_RESOLUTION=12 -build_unflags = -std=gnu++11 -src_filter = ${common.default_src_filter} + + - -# -# HAL/STM32F1 Common Environment values -# -[common_stm32f1] -platform = ststm32@~12.0 -board_build.core = maple -build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py - ${common.build_flags} - -DARDUINO_ARCH_STM32 -build_unflags = -std=gnu11 -std=gnu++11 -src_filter = ${common.default_src_filter} + -lib_ignore = SPI, FreeRTOS701, FreeRTOS821 -lib_deps = ${common.lib_deps} - SoftwareSerialM -platform_packages = tool-stm32duino -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py - -# -# STM32F103RC -# -[env:STM32F103RC] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -monitor_speed = 115200 - -# -# MEEB_3DP (STM32F103RCT6 with 512K) -# -[env:STM32F103RC_meeb] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = MEEB_3DP -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 - -DSS_TIMER=4 - -DSTM32_FLASH_SIZE=512 - -DHSE_VALUE=12000000U - -DUSE_USB_COMPOSITE - -DVECT_TAB_OFFSET=0x2000 - -DGENERIC_BOOTLOADER -extra_scripts = ${common_stm32f1.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py - buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py -lib_deps = ${common.lib_deps} - SoftwareSerialM - USBComposite for STM32F1@0.91 -custom_marlin.NEOPIXEL_LED = Adafruit NeoPixel=https://github.com/ccccmagicboy/Adafruit_NeoPixel#meeb_3dp_use -debug_tool = stlink -upload_protocol = dfu - -# -# STM32F103RC_fysetc -# -[env:STM32F103RC_fysetc] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RC -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py -build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -lib_ldf_mode = chain -debug_tool = stlink -upload_protocol = serial - -# -# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3) -# -# STM32F103RC_btt ............. RCT6 with 256K -# STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) -# STM32F103RC_btt_512K ........ RCT6 with 512K -# STM32F103RC_btt_512K_USB .... RCT6 with 512K (USB mass storage) -# -# WARNING! If you have an SKR Mini v1.1 or an SKR Mini E3 1.0 / 1.2 / 2.0 / DIP -# and experience a printer freeze, re-flash Marlin using the regular (non-512K) -# build option. 256K chips may be re-branded 512K chips, but this means the -# upper 256K is sketchy, and failure is very likely. -# - -[env:STM32F103RC_btt] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RC -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 -DSS_TIMER=4 -monitor_speed = 115200 - -[env:STM32F103RC_btt_USB] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RC_btt -build_flags = ${env:STM32F103RC_btt.build_flags} -DUSE_USB_COMPOSITE -lib_deps = ${env:STM32F103RC_btt.lib_deps} - USBComposite for STM32F1@0.91 - -[env:STM32F103RC_btt_512K] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RC_btt -board_upload.maximum_size=524288 -build_flags = ${env:STM32F103RC_btt.build_flags} -DSTM32_FLASH_SIZE=512 - -[env:STM32F103RC_btt_512K_USB] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RC_btt_512K -build_flags = ${env:STM32F103RC_btt_512K.build_flags} -DUSE_USB_COMPOSITE -lib_deps = ${env:STM32F103RC_btt_512K.lib_deps} - USBComposite for STM32F1@0.91 - -# -# STM32F103RE -# -[env:STM32F103RE] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RE -monitor_speed = 115200 - -# -# STM32F103RE_btt ............. RET6 -# STM32F103RE_btt_USB ......... RET6 (USB mass storage) -# -[env:STM32F103RE_btt] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py -build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 -debug_tool = stlink -upload_protocol = stlink - -[env:STM32F103RE_btt_USB] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RE_btt -build_flags = ${env:STM32F103RE_btt.build_flags} -DUSE_USB_COMPOSITE -lib_deps = ${common_stm32f1.lib_deps} - USBComposite for STM32F1@0.91 - -# -# REMRAM_V1 -# -[env:REMRAM_V1] -platform = ${common_stm32.platform} -extends = common_stm32 -board = remram_v1 -build_flags = ${common_stm32.build_flags} - -# -# ST NUCLEO-F767ZI Development Board -# This environment is for testing purposes prior to control boards -# being readily available based on STM32F7 MCUs -# -[env:NUCLEO_F767ZI] -platform = ${common_stm32.platform} -extends = common_stm32 -board = nucleo_f767zi -build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 - -# -# ARMED (STM32) -# -[env:ARMED] -platform = ${common_stm32.platform} -extends = common_stm32 -board = armed_v1 -build_flags = ${common_stm32.build_flags} - -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing - -# -# Geeetech GTM32 (STM32F103VET6) -# -[env:STM32F103VE_GTM32] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -build_flags = ${common_stm32f1.build_flags} - -ffunction-sections -fdata-sections -nostdlib -MMD - -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 -DBOARD_generic_stm32f103v - -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DVECT_TAB_ADDR=0x8000000 - -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 -upload_protocol = serial - -# -# Longer 3D board in Alfawise U20 (STM32F103VET6) -# -[env:STM32F103VE_longer] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE -DSTM32F1xx -USERIAL_USB -DU20 -DTS_V12 -build_unflags = ${common_stm32f1.build_unflags} - -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 - -# -# MKS Robin Mini (STM32F103VET6) -# -[env:mks_robin_mini] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_mini.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE - -# -# MKS Robin Nano (STM32F103VET6) -# -[env:mks_robin_nano35] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_nano35.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE -DSS_TIMER=4 -debug_tool = jlink -upload_protocol = jlink - -# -# MKS Robin (STM32F103ZET6) -# -[env:mks_robin] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103ZE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin.py -build_flags = ${common_stm32f1.build_flags} - -DSS_TIMER=4 -DSTM32_XL_DENSITY - -# MKS Robin (STM32F103ZET6) -# Uses HAL STM32 to support Marlin UI for TFT screen with optional touch panel -# -[env:mks_robin_stm32] -platform = ${common_stm32.platform} -extends = common_stm32 -board = genericSTM32F103ZE -board_build.core = stm32 -board_build.variant = MARLIN_F103Zx -board_build.ldscript = ldscript.ld -board_build.offset = 0x7000 -board_build.encrypt = Yes -board_build.firmware = Robin.bin -build_flags = ${common_stm32.build_flags} - -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 -build_unflags = ${common_stm32.build_unflags} - -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/mks_encrypt.py -lib_deps = - -# -# MKS Robin Pro (STM32F103ZET6) -# -[env:mks_robin_pro] -platform = ${common_stm32f1.platform} -extends = env:mks_robin -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_pro.py - -# -# TRIGORILLA PRO (STM32F103ZET6) -# -[env:trigorilla_pro] -platform = ${common_stm32f1.platform} -extends = env:mks_robin -extra_scripts = ${common_stm32f1.extra_scripts} - -# -# MKS Robin E3D (STM32F103RCT6) and -# MKS Robin E3 with TMC2209 -# -[env:mks_robin_e3] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -platform_packages = tool-stm32duino -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_e3.py -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 -DSS_TIMER=4 - -# -# MKS Robin E3p (STM32F103VET6) -# - LVGL UI -# -[env:mks_robin_e3p] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_e3p.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE -DSS_TIMER=4 -debug_tool = jlink -upload_protocol = jlink - -# -# MKS Robin Lite/Lite2 (STM32F103RCT6) -# -[env:mks_robin_lite] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_lite.py - -# -# MKS ROBIN LITE3 (STM32F103RCT6) -# -[env:mks_robin_lite3] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_lite3.py - -# -# JGAurora A5S A1 (STM32F103ZET6) -# -[env:jgaurora_a5s_a1] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103ZE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py -build_flags = ${common_stm32f1.build_flags} - -DSTM32F1xx -DSTM32_XL_DENSITY - -# -# Malyan M200 (STM32F103CB) -# -[env:STM32F103CB_malyan] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = malyanM200 -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103CB -D__STM32F1__=1 -std=c++1y -DSERIAL_USB -ffunction-sections -fdata-sections - -Wl,--gc-sections -DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__ -lib_ignore = ${common_stm32f1.lib_ignore} - SoftwareSerialM - -# -# Malyan M200 v2 (STM32F070RB) -# -[env:STM32F070RB_malyan] -platform = ${common_stm32.platform} -extends = common_stm32 -board = malyanM200v2 -build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED - -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing - -DCUSTOM_STARTUP_FILE - -# -# Malyan M200 v2 (STM32F070CB) -# -[env:STM32F070CB_malyan] -platform = ${common_stm32.platform} -extends = common_stm32 -board = malyanm200_f070cb -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED -DCUSTOM_STARTUP_FILE - -# -# Malyan M300 (STM32F070CB) -# -[env:malyan_M300] -platform = ${common_stm32.platform} -extends = common_stm32 -board = malyanm300_f070cb -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED -src_filter = ${common.default_src_filter} + - -# -# Chitu boards like Tronxy X5s (STM32F103ZET6) -# -[env:chitu_f103] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = CHITU_F103 -extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py - pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py - buildroot/share/PlatformIO/scripts/chitu_crypt.py -build_flags = ${common_stm32f1.build_flags} - -DSTM32F1xx -DSTM32_XL_DENSITY -build_unflags = ${common_stm32f1.build_unflags} - -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG= -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 - -# -# Some Chitu V5 boards have a problem with GPIO init. -# Use this target if G28 or G29 are always failing. -# -[env:chitu_v5_gpio_init] -platform = ${common_stm32f1.platform} -extends = env:chitu_f103 -build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX - -# -# Creality (STM32F103RET6) -# -[env:STM32F103RET6_creality] -platform = ${env:STM32F103RE.platform} -extends = env:STM32F103RE -build_flags = ${env:STM32F103RE.build_flags} -DTEMP_TIMER_CHAN=4 -extra_scripts = ${env:STM32F103RE.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/random-bin.py - buildroot/share/PlatformIO/scripts/STM32F103RET6_creality.py -debug_tool = jlink -upload_protocol = jlink - -# -# FLSUN QQS Pro (STM32F103VET6) using hal STM32 -# board Hispeedv1 -# -[env:flsun_hispeedv1] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 -board = genericSTM32F103VE -board_build.core = stm32 -board_build.variant = MARLIN_F103Vx -board_build.ldscript = ldscript.ld -board_build.offset = 0x7000 -board_build.firmware = Robin_mini.bin -board_build.encrypt = Yes -board_upload.offset_address = 0x08007000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/mks_encrypt.py - -# -# STM32F401VE -# 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html -# -[env:STM32F401VE_STEVAL] -platform = ${common_stm32.platform} -extends = common_stm32 -board = STEVAL_STM32F401VE -build_flags = ${common_stm32.build_flags} - -DARDUINO_STEVAL -DSTM32F401xE - -DDISABLE_GENERIC_SERIALUSB -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/STM32F401VE_STEVAL.py - -# -# STM32F401RC -# -[env:FYSETC_CHEETAH_V20] -platform = ${common_stm32.platform} -extends = common_stm32 -board = FYSETC_CHEETAH_V20 -build_flags = ${common_stm32.build_flags} -DSTM32F401xC -DVECT_TAB_OFFSET=0xC000 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/FYSETC_CHEETAH_V20.py - -# -# FLYF407ZG -# -[env:FLYF407ZG] -platform = ${common_stm32.platform} -extends = common_stm32 -board = FLYF407ZG -build_flags = ${common_stm32.build_flags} - -DVECT_TAB_OFFSET=0x8000 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - -# -# FLY MINI(stm32f103rct6) -# -[env:FLY_MINI] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/fly_mini.py -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 -DSS_TIMER=4 - -# -# FYSETC S6 (STM32F446VET6 ARM Cortex-M4) -# -[env:FYSETC_S6] -platform = ${common_stm32.platform} -extends = common_stm32 -platform_packages = tool-stm32duino -board = marlin_fysetc_s6 -build_flags = ${common_stm32.build_flags} - -DVECT_TAB_OFFSET=0x10000 - -DHAL_PCD_MODULE_ENABLED -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py -debug_tool = stlink -upload_protocol = dfu -upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" - -# -# STM32F407VET6 with RAMPS-like shield -# 'Black' STM32F407VET6 board - https://wiki.stm32duino.com/index.php?title=STM32F407 -# Shield - https://github.com/jmz52/Hardware -# -[env:STM32F407VE_black] -platform = ${common_stm32.platform} -extends = common_stm32 -board = blackSTM32F407VET6 -build_flags = ${common_stm32.build_flags} - -DARDUINO_BLACK_F407VE - -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - -# -# Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4) -# For use with with davidtgbe's OpenBLT bootloader https://github.com/davidtgbe/openblt/releases -# Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000. -# -[env:Anet_ET4_OpenBLT] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED -board = genericSTM32F407VGT6 -board_build.core = stm32 -board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = firmware.srec -# Just openblt.py (not stm32_bootloader.py) generates the file -board_build.encrypt = Yes -board_build.offset = 0x10000 -board_upload.offset_address = 0x08010000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 -debug_tool = jlink -upload_protocol = jlink -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/openblt.py - -# -# BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) -# -[env:BIGTREE_SKR_PRO] -platform = ${common_stm32.platform} -extends = common_stm32 -board = BigTree_SKR_Pro -build_flags = ${common_stm32.build_flags} - -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py -#upload_protocol = stlink -#upload_command = "$PROJECT_PACKAGES_DIR/tool-stm32duino/stlink/ST-LINK_CLI.exe" -c SWD -P "$BUILD_DIR/firmware.bin" 0x8008000 -Rst -Run -debug_tool = stlink -debug_init_break = - -# -# USB Flash Drive mix-ins for STM32 -# -[stm32_flash_drive] -platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED -DHAL_HCD_MODULE_ENABLED - -DUSBHOST -DUSBH_IRQ_PRIO=3 -DUSBH_IRQ_SUBPRIO=4 - -# -# BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support -# -[env:BIGTREE_SKR_PRO_usb_flash_drive] -extends = env:BIGTREE_SKR_PRO -platform_packages = ${stm32_flash_drive.platform_packages} -build_unflags = -DUSBCON -DUSBD_USE_CDC -build_flags = ${stm32_flash_drive.build_flags} - -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000 - -# -# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) -# -[env:BIGTREE_GTR_V1_0] -platform = ${common_stm32.platform} -extends = common_stm32 -board = BigTree_GTR_v1 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py -build_flags = ${common_stm32.build_flags} - -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000 - -# -# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support -# -[env:BIGTREE_GTR_V1_0_usb_flash_drive] -extends = env:BIGTREE_GTR_V1_0 -platform_packages = ${stm32_flash_drive.platform_packages} -build_unflags = -DUSBCON -DUSBD_USE_CDC -build_flags = ${stm32_flash_drive.build_flags} - -DSTM32F407IX -DVECT_TAB_OFFSET=0x8000 - -# -# BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4) -# -[env:BIGTREE_BTT002] -platform = ${common_stm32.platform} -extends = common_stm32 -board = BigTree_Btt002 -build_flags = ${common_stm32.build_flags} - -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000 - -DHAVE_HWSERIAL2 - -DHAVE_HWSERIAL3 - -DPIN_SERIAL2_RX=PD_6 - -DPIN_SERIAL2_TX=PD_5 -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - -# -# Lerdge base -# -[lerdge_common] -platform = ${common_stm32.platform} -extends = common_stm32 -board = LERDGE -board_build.offset = 0x10000 -board_build.encrypt = Yes -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/lerdge.py -build_flags = ${common_stm32.build_flags} - -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4 - -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DARDUINO_LERDGE - -DHAL_SRAM_MODULE_ENABLED -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 - -# -# Lerdge X -# -[env:LERDGEX] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_X_firmware_force.bin - -# -# Lerdge X with USB Flash Drive Support -# -[env:LERDGEX_usb_flash_drive] -platform = ${env:LERDGEX.platform} -extends = env:LERDGEX -platform_packages = ${stm32_flash_drive.platform_packages} -build_flags = ${stm32_flash_drive.build_flags} - -# -# Lerdge S -# -[env:LERDGES] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_firmware_force.bin - -# -# Lerdge S with USB Flash Drive Support -# -[env:LERDGES_usb_flash_drive] -platform = ${env:LERDGES.platform} -extends = env:LERDGES -platform_packages = ${stm32_flash_drive.platform_packages} -build_flags = ${stm32_flash_drive.build_flags} - -# -# Lerdge K -# -[env:LERDGEK] -platform = ${lerdge_common.platform} -extends = lerdge_common -board_build.firmware = Lerdge_K_firmware_force.bin -build_flags = ${lerdge_common.build_flags} - -DLERDGEK - -# -# Lerdge K with USB Flash Drive Support -# -[env:LERDGEK_usb_flash_drive] -platform = ${env:LERDGEK.platform} -extends = env:LERDGEK -platform_packages = ${stm32_flash_drive.platform_packages} -build_flags = ${stm32_flash_drive.build_flags} - -# -# RUMBA32 -# -[env:rumba32] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} - -Os - -DHAL_PCD_MODULE_ENABLED - -DDISABLE_GENERIC_SERIALUSB - -DHAL_UART_MODULE_ENABLED - -DTIMER_SERIAL=TIM9 -board = rumba32_f446ve -upload_protocol = dfu -monitor_speed = 500000 - -# -# MKS Robin Nano V1.2 and V2 using hal STM32 -# -[env:mks_robin_nano35_stm32] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 -board = genericSTM32F103VE -board_build.core = stm32 -board_build.variant = MARLIN_F103Vx -board_build.ldscript = ldscript.ld -board_build.offset = 0x7000 -board_build.encrypt = Yes -board_build.firmware = Robin_nano35.bin -board_upload.offset_address = 0x08007000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -debug_tool = jlink -upload_protocol = jlink -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - buildroot/share/PlatformIO/scripts/mks_encrypt.py - -# -# MKS Robin Pro V2 -# -[env:mks_robin_pro2] -platform = ${common_stm32.platform} -platform_packages = ${stm32_flash_drive.platform_packages} -extends = common_stm32 -build_flags = ${stm32_flash_drive.build_flags} -board = genericSTM32F407VET6 -board_build.core = stm32 -board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = firmware.bin -board_build.offset = 0x0000 -board_upload.offset_address = 0x08000000 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -debug_tool = jlink -upload_protocol = jlink -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - -# -# This SPI is used by Robin Nano V3 -# -[stm32f4_I2C1] -build_flags = -DPIN_WIRE_SCL=PB6 -DPIN_WIRE_SDA=PB7 - -# -# MKS Robin Nano V3 -# -[env:mks_robin_nano_v3] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} ${stm32f4_I2C1.build_flags} -DHAL_PCD_MODULE_ENABLED -DUSBCON -DUSBD_USE_CDC -board = genericSTM32F407VGT6 -board_build.core = stm32 -board_build.variant = MARLIN_F4x7Vx -board_build.ldscript = ldscript.ld -board_build.firmware = Robin_nano_v3.bin -board_build.offset = 0xC000 -board_upload.offset_address = 0x0800C000 -build_unflags = ${common_stm32.build_unflags} -debug_tool = jlink -upload_protocol = jlink -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - -# -# MKS Robin Nano V3 with USB Flash Drive Support -# Currently, using a STM32duino fork, until USB Host get merged -# -[env:mks_robin_nano_v3_usb_flash_drive] -extends = env:mks_robin_nano_v3 -platform_packages = ${stm32_flash_drive.platform_packages} -build_flags = ${stm32_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} - -DUSBCON - -DUSE_USBHOST_HS - -DUSBD_IRQ_PRIO=5 - -DUSBD_IRQ_SUBPRIO=6 - -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] -platform = ${common_stm32.platform} -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} ${stm32f4_I2C1.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 -# - -[env:mingda_mpx_arm_mini] -platform = ${common_stm32.platform} -extends = common_stm32 -board = genericSTM32F103ZE -board_build.core = stm32 -board_build.variant = MARLIN_F103Zx -board_build.ldscript = ldscript.ld -board_build.offset = 0x10000 -build_flags = ${common_stm32.build_flags} -DENABLE_HWSERIAL3 -DTIMER_SERIAL=TIM5 -build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/stm32_bootloader.py - -################################# -# # -# Other Architectures # -# # -################################# - -# -# Espressif ESP32 -# -[env:esp32] -platform = espressif32@2.1.0 -board = esp32dev -build_flags = ${common.build_flags} -DCORE_DEBUG_LEVEL=0 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet -upload_speed = 500000 -monitor_speed = 250000 -#upload_port = marlinesp.local -#board_build.flash_mode = qio - -[env:FYSETC_E4] -platform = espressif32@1.11.2 -extends = env:esp32 -board_build.partitions = default_16MB.csv - -# -# Teensy 3.1 / 3.2 (ARM Cortex-M4) -# -[env:teensy31] -platform = teensy -board = teensy31 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet - -# -# Teensy 3.5 / 3.6 (ARM Cortex-M4) -# -[env:teensy35] -platform = teensy -board = teensy35 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet - -[env:teensy36] -platform = teensy -board = teensy36 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet - -# -# Teensy 4.0 / 4.1 (ARM Cortex-M7) -# -[env:teensy41] -platform = teensy -board = teensy41 -src_filter = ${common.default_src_filter} + - -# -# Native -# No supported Arduino libraries, base Marlin only -# -[env:linux_native] -platform = native -framework = -build_flags = -D__PLAT_LINUX__ -std=gnu++17 -ggdb -g -lrt -lpthread -D__MARLIN_FIRMWARE__ -Wno-expansion-to-defined -src_build_flags = -Wall -IMarlin/src/HAL/LINUX/include -build_unflags = -Wall -lib_ldf_mode = off -lib_deps = -src_filter = ${common.default_src_filter} + - # # Just print the dependency tree # From 9d0b6c5730e55298b6a94fb07542502a147e84f3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 1 Apr 2021 21:54:34 -0500 Subject: [PATCH 154/311] Requiring PIO >= 5.0.3 --- .../PlatformIO/scripts/STM32F1_create_variant.py | 6 ++++-- .../scripts/copy_marlin_variant_to_framework.py | 16 ++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py index 0ba5d71f26..91522a9d06 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py @@ -20,12 +20,14 @@ board = env.BoardConfig() FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple") assert os.path.isdir(FRAMEWORK_DIR) -assert os.path.isdir("buildroot/share/PlatformIO/variants") + +source_root = os.path.join("buildroot", "share", "PlatformIO", "variants") +assert os.path.isdir(source_root) variant = board.get("build.variant") variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant) -source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) +source_dir = os.path.join(source_root, variant) assert os.path.isdir(source_dir) if os.path.isdir(variant_dir): diff --git a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py index 7ea7ac57f3..15c953156c 100644 --- a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py +++ b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py @@ -4,19 +4,7 @@ import os,shutil from SCons.Script import DefaultEnvironment from platformio import util -try: - # PIO < 4.4 - from platformio.managers.package import PackageManager -except ImportError: - # PIO >= 4.4 - from platformio.package.meta import PackageSpec as PackageManager - -def parse_pkg_uri(spec): - if PackageManager.__name__ == 'PackageSpec': - return PackageManager(spec).name - else: - name, _, _ = PackageManager.parse_pkg_uri(spec) - return name +from platformio.package.meta import PackageSpec def copytree(src, dst, symlinks=False, ignore=None): for item in os.listdir(src): @@ -41,7 +29,7 @@ framewords = { if len(platform_packages) == 0: platform_name = framewords[platform.__class__.__name__] else: - platform_name = parse_pkg_uri(platform_packages[0]) + platform_name = PackageSpec(platform_packages[0]).name FRAMEWORK_DIR = platform.get_package_dir(platform_name) assert os.path.isdir(FRAMEWORK_DIR) From c2b72c0e73a59c7b0915253c775eb6253032f0b0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 2 Apr 2021 14:22:43 -0500 Subject: [PATCH 155/311] Remove extraneous 'extern' hints (#21516) --- Marlin/src/feature/fanmux.h | 4 +- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_about.h | 4 +- .../lib/mks_ui/draw_acceleration_settings.h | 4 +- .../extui/lib/mks_ui/draw_advance_settings.h | 4 +- .../mks_ui/draw_auto_level_offset_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_baby_stepping.h | 8 ++-- .../lcd/extui/lib/mks_ui/draw_change_speed.h | 10 ++--- .../lcd/extui/lib/mks_ui/draw_cloud_bind.h | 12 ++--- Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h | 10 ++--- .../extui/lib/mks_ui/draw_eeprom_settings.h | 4 +- .../extui/lib/mks_ui/draw_encoder_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_error_message.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_extrusion.h | 14 +++--- Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h | 6 +-- .../extui/lib/mks_ui/draw_filament_change.h | 8 ++-- .../extui/lib/mks_ui/draw_filament_settings.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_home.h | 4 +- .../mks_ui/draw_homing_sensitivity_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_jerk_settings.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_keyboard.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_language.h | 4 +- .../extui/lib/mks_ui/draw_level_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_machine_para.h | 4 +- .../extui/lib/mks_ui/draw_machine_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_manuaLevel.h | 4 +- .../lib/mks_ui/draw_max_feedrate_settings.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_more.h | 4 +- .../extui/lib/mks_ui/draw_motor_settings.h | 4 +- .../lcd/extui/lib/mks_ui/draw_move_motor.h | 6 +-- .../lcd/extui/lib/mks_ui/draw_number_key.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_operation.h | 4 +- .../lcd/extui/lib/mks_ui/draw_pause_message.h | 2 +- .../extui/lib/mks_ui/draw_pause_position.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.h | 10 ++--- .../lcd/extui/lib/mks_ui/draw_print_file.h | 18 ++++---- .../src/lcd/extui/lib/mks_ui/draw_printing.h | 22 +++++----- .../lcd/extui/lib/mks_ui/draw_ready_print.h | 16 +++---- Marlin/src/lcd/extui/lib/mks_ui/draw_set.h | 4 +- .../lcd/extui/lib/mks_ui/draw_step_settings.h | 4 +- .../lib/mks_ui/draw_tmc_current_settings.h | 4 +- .../lib/mks_ui/draw_tmc_step_mode_settings.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h | 4 +- .../extui/lib/mks_ui/draw_touch_calibration.h | 6 +-- .../lib/mks_ui/draw_tramming_pos_settings.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 36 +++++++-------- Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h | 6 +-- .../src/lcd/extui/lib/mks_ui/draw_wifi_list.h | 10 ++--- .../lcd/extui/lib/mks_ui/draw_wifi_settings.h | 4 +- .../src/lcd/extui/lib/mks_ui/draw_wifi_tips.h | 4 +- Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h | 16 +++---- .../lcd/extui/lib/mks_ui/printer_operation.h | 6 +-- .../lib/mks_ui/tft_lvgl_configuration.cpp | 8 ++-- .../extui/lib/mks_ui/tft_lvgl_configuration.h | 44 +++++++++---------- .../lcd/extui/lib/mks_ui/tft_multi_language.h | 2 +- Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h | 10 ++--- .../src/lcd/extui/lib/mks_ui/wifi_upload.cpp | 4 +- Marlin/src/module/servo.h | 2 +- Marlin/src/module/tool_change.h | 2 +- 61 files changed, 215 insertions(+), 217 deletions(-) diff --git a/Marlin/src/feature/fanmux.h b/Marlin/src/feature/fanmux.h index b1b0c67a55..efb92cf198 100644 --- a/Marlin/src/feature/fanmux.h +++ b/Marlin/src/feature/fanmux.h @@ -25,5 +25,5 @@ * feature/fanmux.h - Cooling Fan Multiplexer support functions */ -extern void fanmux_switch(const uint8_t e); -extern void fanmux_init(); +void fanmux_switch(const uint8_t e); +void fanmux_init(); diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h index 6e0ee3053f..c017d69dae 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h @@ -117,7 +117,7 @@ extern DGUSDisplay dgusdisplay; constexpr float cpow(const float x, const int y) { return y == 0 ? 1.0 : x * cpow(x, y - 1); } /// Find the flash address of a DGUS_VP_Variable for the VP. -extern const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp); +const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp); /// Helper to populate a DGUS_VP_Variable for a given VP. Return false if not found. -extern bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy); +bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h index 77d66aef11..4e7b318eda 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_about.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_about(); -extern void lv_clear_about(); +void lv_draw_about(); +void lv_clear_about(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.h index dc72739106..e333e0ae51 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_acceleration_settings(); -extern void lv_clear_acceleration_settings(); +void lv_draw_acceleration_settings(); +void lv_clear_acceleration_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.h index 8885fc6a4e..8848c34451 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_advance_settings(); -extern void lv_clear_advance_settings(); +void lv_draw_advance_settings(); +void lv_clear_advance_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h index ec61862a24..38314f6bc2 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_auto_level_offset_settings(); -extern void lv_clear_auto_level_offset_settings(); +void lv_draw_auto_level_offset_settings(); +void lv_clear_auto_level_offset_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h index 8793ad772f..f8efeabc40 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h @@ -25,10 +25,10 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_baby_stepping(); -extern void lv_clear_baby_stepping(); -extern void disp_baby_step_dist(); -extern void disp_z_offset_value(); +void lv_draw_baby_stepping(); +void lv_clear_baby_stepping(); +void disp_baby_step_dist(); +void disp_z_offset_value(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h index 75e4fe3099..66662d8811 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h @@ -28,11 +28,11 @@ #define MIN_EXT_SPEED_PERCENT 10 #define MAX_EXT_SPEED_PERCENT 999 -extern void lv_draw_change_speed(); -extern void lv_clear_change_speed(); -extern void disp_speed_step(); -extern void disp_print_speed(); -extern void disp_speed_type(); +void lv_draw_change_speed(); +void lv_clear_change_speed(); +void disp_speed_step(); +void disp_print_speed(); +void disp_speed_type(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.h index 1626680051..917b52ab0a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.h @@ -25,12 +25,12 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_cloud_bind(); -extern void lv_clear_cloud_bind(); -extern void disp_bind_state(); -extern void refresh_bind_ui(); -extern void display_qrcode(uint8_t *qrcode_data); -extern void cloud_unbind(); +void lv_draw_cloud_bind(); +void lv_clear_cloud_bind(); +void disp_bind_state(); +void refresh_bind_ui(); +void display_qrcode(uint8_t *qrcode_data); +void cloud_unbind(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h index 38f5fa0635..e53d48a2b8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h @@ -74,11 +74,11 @@ enum { DIALOG_TRANSFER_NO_DEVICE }; -extern void lv_draw_dialog(uint8_t type); -extern void lv_clear_dialog(); -extern void filament_sprayer_temp(); -extern void filament_dialog_handle(); -extern void lv_filament_setbar(); +void lv_draw_dialog(uint8_t type); +void lv_clear_dialog(); +void filament_sprayer_temp(); +void filament_dialog_handle(); +void lv_filament_setbar(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.h index 3d9f7cae00..575ebbc6a2 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_eeprom_settings(); -extern void lv_clear_eeprom_settings(); +void lv_draw_eeprom_settings(); +void lv_clear_eeprom_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h index 392dc67db7..bbf0c34858 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_encoder_settings(); -extern void lv_clear_encoder_settings(); +void lv_draw_encoder_settings(); +void lv_clear_encoder_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h index 35e3bd6cf5..6999ecf5e4 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h @@ -29,8 +29,8 @@ #define PGM_P const char * #endif -extern void lv_draw_error_message(PGM_P const msg); -extern void lv_clear_error_message(); +void lv_draw_error_message(PGM_P const msg); +void lv_clear_error_message(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h index 75db2fbab5..0252767767 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h @@ -25,13 +25,13 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_extrusion(); -extern void lv_clear_extrusion(); -extern void disp_ext_type(); -extern void disp_ext_step(); -extern void disp_ext_speed(); -extern void disp_hotend_temp(); -extern void disp_extru_amount(); +void lv_draw_extrusion(); +void lv_clear_extrusion(); +void disp_ext_type(); +void disp_ext_step(); +void disp_ext_speed(); +void disp_hotend_temp(); +void disp_extru_amount(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h index d9b23fbbe4..0db87eb4f6 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h @@ -25,9 +25,9 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_fan(); -extern void lv_clear_fan(); -extern void disp_fan_value(); +void lv_draw_fan(); +void lv_clear_fan(); +void disp_fan_value(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h index 9c1c9a8767..d3536a380a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h @@ -25,10 +25,10 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_filament_change(); -extern void lv_clear_filament_change(); -extern void disp_filament_type(); -extern void disp_filament_temp(); +void lv_draw_filament_change(); +void lv_clear_filament_change(); +void disp_filament_type(); +void disp_filament_temp(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h index f9967df31f..3d190e99c7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_filament_settings(); -extern void lv_clear_filament_settings(); +void lv_draw_filament_settings(); +void lv_clear_filament_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h index 30a378a15a..4e1610431e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_gcode.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_gcode(bool clear = false); -extern void lv_clear_gcode(); +void lv_draw_gcode(bool clear = false); +void lv_clear_gcode(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h index 779cbb0130..7375dc7aa8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_home.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_home(); -extern void lv_clear_home(); +void lv_draw_home(); +void lv_clear_home(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h index c6f0e11457..e086391373 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_homing_sensitivity_settings(); -extern void lv_clear_homing_sensitivity_settings(); +void lv_draw_homing_sensitivity_settings(); +void lv_clear_homing_sensitivity_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.h index 69fd344609..7f5ffc3ac5 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_jerk_settings(); -extern void lv_clear_jerk_settings(); +void lv_draw_jerk_settings(); +void lv_clear_jerk_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h index 0013dc4030..d89806c272 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_keyboard(); -extern void lv_clear_keyboard(); +void lv_draw_keyboard(); +void lv_clear_keyboard(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h index 9e769e3692..4f51856f4f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_language.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_language(); -extern void lv_clear_language(); +void lv_draw_language(); +void lv_clear_language(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h index 95a4e2e2e5..06283d2095 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_level_settings(); -extern void lv_clear_level_settings(); +void lv_draw_level_settings(); +void lv_clear_level_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.h index 652a7e1eb7..f495e8b35e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_machine_para(); -extern void lv_clear_machine_para(); +void lv_draw_machine_para(); +void lv_clear_machine_para(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.h index dd988ede72..f113f65fc1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_machine_settings(); -extern void lv_clear_machine_settings(); +void lv_draw_machine_settings(); +void lv_clear_machine_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h index 4e9b8275ba..29c8fa144e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_manualLevel(); -extern void lv_clear_manualLevel(); +void lv_draw_manualLevel(); +void lv_clear_manualLevel(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.h index f82ffd0eaa..45c3fd29db 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_max_feedrate_settings(); -extern void lv_clear_max_feedrate_settings(); +void lv_draw_max_feedrate_settings(); +void lv_clear_max_feedrate_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_more.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_more.h index 2a68d3da99..74ac7e994d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_more.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_more.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_more(); -extern void lv_clear_more(); +void lv_draw_more(); +void lv_clear_more(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.h index 632f7bd24d..5d26a402d0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_motor_settings(); -extern void lv_clear_motor_settings(); +void lv_draw_motor_settings(); +void lv_clear_motor_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h index a9b75c1d13..133a0444c1 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.h @@ -25,9 +25,9 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_move_motor(); -extern void lv_clear_move_motor(); -extern void disp_move_dist(); +void lv_draw_move_motor(); +void lv_clear_move_motor(); +void disp_move_dist(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.h index dbf9015452..fcff280d3b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_number_key(); -extern void lv_clear_number_key(); +void lv_draw_number_key(); +void lv_clear_number_key(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.h index e034f7070b..d58b3307b8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_operation.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_operation(); -extern void lv_clear_operation(); +void lv_draw_operation(); +void lv_clear_operation(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h index 88222f0e1a..c3df8118a4 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.h @@ -25,7 +25,7 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_pause_message(const PauseMessage msg); +void lv_draw_pause_message(const PauseMessage msg); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.h index e7c92a7396..fd5459c647 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_pause_position(); -extern void lv_clear_pause_position(); +void lv_draw_pause_position(); +void lv_clear_pause_position(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h index da3ce88384..2993a95f00 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h @@ -25,11 +25,11 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_preHeat(); -extern void lv_clear_preHeat(); -extern void disp_temp_type(); -extern void disp_step_heat(); -extern void disp_desire_temp(); +void lv_draw_preHeat(); +void lv_clear_preHeat(); +void disp_temp_type(); +void disp_step_heat(); +void disp_desire_temp(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h index 759ccdc1c0..85eadc0a6b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h @@ -49,15 +49,15 @@ typedef struct { } LIST_FILE; extern LIST_FILE list_file; -extern void disp_gcode_icon(uint8_t file_num); -extern void lv_draw_print_file(); -extern uint32_t lv_open_gcode_file(char *path); -extern void lv_gcode_file_read(uint8_t *data_buf); -extern void lv_close_gcode_file(); -extern void cutFileName(char *path, int len, int bytePerLine, char *outStr); -extern int ascii2dec_test(char *ascii); -extern void lv_clear_print_file(); -extern void lv_gcode_file_seek(uint32_t pos); +void disp_gcode_icon(uint8_t file_num); +void lv_draw_print_file(); +uint32_t lv_open_gcode_file(char *path); +void lv_gcode_file_read(uint8_t *data_buf); +void lv_close_gcode_file(); +void cutFileName(char *path, int len, int bytePerLine, char *outStr); +int ascii2dec_test(char *ascii); +void lv_clear_print_file(); +void lv_gcode_file_seek(uint32_t pos); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h index 7c98fd767b..b2a02a62da 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h @@ -36,17 +36,17 @@ enum { STOP }; -extern void lv_draw_printing(); -extern void lv_clear_printing(); -extern void disp_ext_temp(); -extern void disp_bed_temp(); -extern void disp_fan_speed(); -extern void disp_print_time(); -extern void disp_fan_Zpos(); -extern void reset_print_time(); -extern void start_print_time(); -extern void stop_print_time(); -extern void setProBarRate(); +void lv_draw_printing(); +void lv_clear_printing(); +void disp_ext_temp(); +void disp_bed_temp(); +void disp_fan_speed(); +void disp_print_time(); +void disp_fan_Zpos(); +void reset_print_time(); +void start_print_time(); +void stop_print_time(); +void setProBarRate(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h index 56077e5dec..873be528ed 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h @@ -25,14 +25,14 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_ready_print(); -extern void mks_disp_test(); -extern void disp_Limit_ok(); -extern void disp_Limit_error(); -extern void disp_det_error(); -extern void disp_det_ok(); -extern void lv_clear_ready_print(); -extern void lv_temp_refr(); +void lv_draw_ready_print(); +void mks_disp_test(); +void disp_Limit_ok(); +void disp_Limit_error(); +void disp_det_error(); +void disp_det_ok(); +void lv_clear_ready_print(); +void lv_temp_refr(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h index 8ad8b9f2ea..a270308e07 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_set.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_set(); -extern void lv_clear_set(); +void lv_draw_set(); +void lv_clear_set(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.h index 249e5a7942..4f32f0a6c2 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_step_settings(); -extern void lv_clear_step_settings(); +void lv_draw_step_settings(); +void lv_clear_step_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ 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 92a2fb12b5..99589a3a17 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 @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_tmc_current_settings(); -extern void lv_clear_tmc_current_settings(); +void lv_draw_tmc_current_settings(); +void lv_clear_tmc_current_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.h index a15baf21e8..aa42d9b87d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_tmc_step_mode_settings(); -extern void lv_clear_tmc_step_mode_settings(); +void lv_draw_tmc_step_mode_settings(); +void lv_clear_tmc_step_mode_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h index 1cfd297aba..0dc86b7030 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tool.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_tool(); -extern void lv_clear_tool(); +void lv_draw_tool(); +void lv_clear_tool(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_touch_calibration.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_touch_calibration.h index 63749a2b3c..567256a792 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_touch_calibration.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_touch_calibration.h @@ -25,9 +25,9 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_touch_calibration_screen(); -extern void lv_clear_touch_calibration_screen(); -extern void lv_update_touch_calibration_screen(); +void lv_draw_touch_calibration_screen(); +void lv_clear_touch_calibration_screen(); +void lv_update_touch_calibration_screen(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.h index 3ebb8ae731..863ff6fc7e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.h @@ -25,8 +25,8 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_tramming_pos_settings(); -extern void lv_clear_tramming_pos_settings(); +void lv_draw_tramming_pos_settings(); +void lv_clear_tramming_pos_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ 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 e65ba788f5..68baea30c7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -72,7 +72,7 @@ extern bool once_flag; extern uint8_t sel_id; extern lv_group_t *g; -extern void LCD_IO_WriteData(uint16_t RegValue); +void LCD_IO_WriteData(uint16_t RegValue); static const char custom_gcode_command[][100] = { "G29N\nM500", 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 f4a6d71ea0..2be4f7d70b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -442,28 +442,28 @@ extern lv_style_t style_btn_rel; extern lv_point_t line_points[4][2]; -extern void gCfgItems_init(); -extern void ui_cfg_init(); -extern void tft_style_init(); +void gCfgItems_init(); +void ui_cfg_init(); +void tft_style_init(); extern char *creat_title_text(); -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 *); +void preview_gcode_prehandle(char *path); +void update_spi_flash(); +void update_gcode_command(int addr,uint8_t *s); +void get_gcode_command(int addr,uint8_t *d); +void lv_serial_capt_hook(void *, uint8_t); +void lv_eom_hook(void *); #if HAS_GCODE_PREVIEW - extern void disp_pre_gcode(int xpos_pixel, int ypos_pixel); + void disp_pre_gcode(int xpos_pixel, int ypos_pixel); #endif -extern void GUI_RefreshPage(); -extern void clear_cur_ui(); -extern void draw_return_ui(); -extern void sd_detection(); -extern void gCfg_to_spiFlah(); -extern void print_time_count(); +void GUI_RefreshPage(); +void clear_cur_ui(); +void draw_return_ui(); +void sd_detection(); +void gCfg_to_spiFlah(); +void print_time_count(); -extern void LV_TASK_HANDLER(); -extern void lv_ex_line(lv_obj_t *line, lv_point_t *points); +void LV_TASK_HANDLER(); +void lv_ex_line(lv_obj_t *line, lv_point_t *points); #ifdef __cplusplus } /* C-declarations for C++ */ 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 77ba5925a3..4fa642b39c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h @@ -26,9 +26,9 @@ #endif -extern void lv_draw_wifi(); -extern void lv_clear_wifi(); -extern void disp_wifi_state(); +void lv_draw_wifi(); +void lv_clear_wifi(); +void disp_wifi_state(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h index e42b738f14..e2005d5cbc 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h @@ -25,11 +25,11 @@ extern "C" { /* C-declarations for C++ */ #endif -extern void lv_draw_wifi_list(); -extern void lv_clear_wifi_list(); -extern void disp_wifi_list(); -extern void cutWifiName(char *name, int len,char *outStr); -extern void wifi_scan_handle(); +void lv_draw_wifi_list(); +void lv_clear_wifi_list(); +void disp_wifi_list(); +void cutWifiName(char *name, int len,char *outStr); +void wifi_scan_handle(); #define NUMBER_OF_PAGE 5 diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h index 605423b131..ff27397049 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h @@ -28,8 +28,8 @@ #define WIFI_AP_TEXT "AP" #define WIFI_STA_TEXT "STA" -extern void lv_draw_wifi_settings(); -extern void lv_clear_wifi_settings(); +void lv_draw_wifi_settings(); +void lv_clear_wifi_settings(); #ifdef __cplusplus } /* C-declarations for C++ */ 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 2f9c9f5745..4ffe6c1312 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 @@ -26,8 +26,8 @@ #endif -extern void lv_draw_wifi_tips(); -extern void lv_clear_wifi_tips(); +void lv_draw_wifi_tips(); +void lv_clear_wifi_tips(); typedef enum { TIPS_TYPE_JOINING, diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h index 19c93468e4..e9960fc73a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h @@ -154,14 +154,14 @@ typedef struct pic_msg PIC_MSG; #define PIC_SIZE_xM 6 #define FONT_SIZE_xM 2 -extern void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff); -extern void Pic_Logo_Read(uint8_t *LogoName,uint8_t *Logo_Rbuff,uint32_t LogoReadsize); -extern void lv_pic_test(uint8_t *P_Rbuff, uint32_t addr, uint32_t size); -extern uint32_t lv_get_pic_addr(uint8_t *Pname); -extern void get_spi_flash_data(const char *rec_buf, int offset, int size); -extern void spi_flash_read_test(); -extern void default_view_Read(uint8_t *default_view_Rbuff, uint32_t default_view_Readsize); -extern void flash_view_Read(uint8_t *flash_view_Rbuff, uint32_t flash_view_Readsize); +void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff); +void Pic_Logo_Read(uint8_t *LogoName,uint8_t *Logo_Rbuff,uint32_t LogoReadsize); +void lv_pic_test(uint8_t *P_Rbuff, uint32_t addr, uint32_t size); +uint32_t lv_get_pic_addr(uint8_t *Pname); +void get_spi_flash_data(const char *rec_buf, int offset, int size); +void spi_flash_read_test(); +void default_view_Read(uint8_t *default_view_Rbuff, uint32_t default_view_Readsize); +void flash_view_Read(uint8_t *flash_view_Rbuff, uint32_t flash_view_Readsize); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.h b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.h index f304158824..499799c6c7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/printer_operation.h @@ -27,9 +27,9 @@ #define MIN_FILE_PRINTED 100 //5000 -extern void printer_state_polling(); -extern void filament_pin_setup(); -extern void filament_check(); +void printer_state_polling(); +void filament_pin_setup(); +void filament_check(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp index b7441f71f4..f54b290c13 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp @@ -64,13 +64,13 @@ XPT2046 touch; #endif #if HAS_SPI_FLASH_FONT - extern void init_gb2312_font(); + void init_gb2312_font(); #endif static lv_disp_buf_t disp_buf; lv_group_t* g; #if ENABLED(SDSUPPORT) - extern void UpdateAssets(); + void UpdateAssets(); #endif uint16_t DeviceCode = 0x9488; extern uint8_t sel_id; @@ -190,9 +190,7 @@ void tft_lvgl_init() { #endif tft_style_init(); - filament_pin_setup(); - lv_encoder_pin_init(); TERN_(MKS_WIFI_MODULE, mks_wifi_firmware_update()); @@ -211,7 +209,7 @@ void tft_lvgl_init() { strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m)); card.printLongPath(public_buf_m); - strncpy(list_file.long_name[sel_id], card.longFilename, sizeof(list_file.long_name[sel_id])); + strncpy(list_file.long_name[sel_id], card.longFilename, sizeof(list_file.long_name[0])); lv_draw_printing(); } #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h index d0ea4e376f..308162b799 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h @@ -37,32 +37,32 @@ extern uint8_t bmp_public_buf[14 * 1024]; extern uint8_t public_buf[513]; -extern void tft_lvgl_init(); -extern void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p); -extern bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data); -extern bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); +void tft_lvgl_init(); +void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p); +bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data); +bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -extern void LCD_Clear(uint16_t Color); -extern void tft_set_point(uint16_t x, uint16_t y, uint16_t point); -extern void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh); -extern void LCD_WriteRAM_Prepare(); -extern void lcd_draw_logo(); -extern void lv_encoder_pin_init(); -extern void lv_update_encoder(); +void LCD_Clear(uint16_t Color); +void tft_set_point(uint16_t x, uint16_t y, uint16_t point); +void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh); +void LCD_WriteRAM_Prepare(); +void lcd_draw_logo(); +void lv_encoder_pin_init(); +void lv_update_encoder(); -extern lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode); -extern lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p); -extern lv_fs_res_t spi_flash_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br); -extern lv_fs_res_t spi_flash_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos); -extern lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); +lv_fs_res_t spi_flash_open_cb(lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode); +lv_fs_res_t spi_flash_close_cb(lv_fs_drv_t * drv, void * file_p); +lv_fs_res_t spi_flash_read_cb(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br); +lv_fs_res_t spi_flash_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos); +lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); -extern lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode); -extern lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p); -extern lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br); -extern lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos); -extern lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); +lv_fs_res_t sd_open_cb(lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode); +lv_fs_res_t sd_close_cb(lv_fs_drv_t * drv, void * file_p); +lv_fs_res_t sd_read_cb(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br); +lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos); +lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); -extern void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color); +void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color); #ifdef __cplusplus } /* C-declarations for C++ */ 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 61c46a648f..61e3524c58 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 @@ -29,7 +29,7 @@ #include "tft_Language_sp.h" #include "tft_Language_it.h" -extern void disp_language_init(); +void disp_language_init(); #define LANG_SIMPLE_CHINESE 1 #define LANG_COMPLEX_CHINESE 2 diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h index 07ae6f72db..048996e919 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h @@ -181,16 +181,16 @@ extern WIFI_GCODE_BUFFER espGcodeFifo; extern uint32_t getWifiTick(); extern uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick); -extern void mks_esp_wifi_init(); +void mks_esp_wifi_init(); extern int cfg_cloud_flag; extern int send_to_wifi(uint8_t *buf, int len); -extern void wifi_looping(); +void wifi_looping(); extern int raw_send_to_wifi(uint8_t *buf, int len); extern int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len); -extern void get_wifi_list_command_send(); -extern void get_wifi_commands(); +void get_wifi_list_command_send(); +void get_wifi_commands(); extern int readWifiBuf(int8_t *buf, int32_t len); -extern void mks_wifi_firmware_update(); +void mks_wifi_firmware_update(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp index 378de6d584..e41d473c11 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp @@ -39,9 +39,9 @@ extern SZ_USART_FIFO WifiRxFifo; extern int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len); extern int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len); -extern void esp_port_begin(uint8_t interrupt); +void esp_port_begin(uint8_t interrupt); extern int usartFifoAvailable(SZ_USART_FIFO *fifo); -extern void wifi_delay(int n); +void wifi_delay(int n); #define ARRAY_SIZE(a) sizeof(a) / sizeof((a)[0]) diff --git a/Marlin/src/module/servo.h b/Marlin/src/module/servo.h index 29bd3b8798..3b5a5e7e2c 100644 --- a/Marlin/src/module/servo.h +++ b/Marlin/src/module/servo.h @@ -112,4 +112,4 @@ #define MOVE_SERVO(I, P) servo[I].move(P) extern HAL_SERVO_LIB servo[NUM_SERVOS]; -extern void servo_init(); +void servo_init(); diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index a97b09fd89..b79ec676a0 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -42,7 +42,7 @@ extern toolchange_settings_t toolchange_settings; #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - extern void tool_change_prime(); + void tool_change_prime(); #endif #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) From d0d5003f45eacfba6101ad57fd86d6c25f9691d8 Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Fri, 2 Apr 2021 20:06:43 -0400 Subject: [PATCH 156/311] GT2560 V3 followup (#21512) --- Marlin/src/pins/mega/pins_GT2560_V3.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/src/pins/mega/pins_GT2560_V3.h b/Marlin/src/pins/mega/pins_GT2560_V3.h index 8490d5571d..46b4ebf428 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3.h @@ -83,6 +83,9 @@ #ifndef FIL_RUNOUT2_PIN #define FIL_RUNOUT2_PIN 67 #endif +#ifndef FIL_RUNOUT3_PIN + #define FIL_RUNOUT3_PIN 54 +#endif // // Power Recovery From 9d0e82788a754367cd16d6e1faf21a9bede2e957 Mon Sep 17 00:00:00 2001 From: XDA-Bam <1209896+XDA-Bam@users.noreply.github.com> Date: Sat, 3 Apr 2021 02:11:22 +0200 Subject: [PATCH 157/311] Update u8g / AVR display timing defaults (#21518) --- Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp index 1e19bf85e5..24baae221e 100644 --- a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp @@ -34,9 +34,9 @@ #include "ultralcd_st7920_u8glib_rrd_AVR.h" #if F_CPU >= 20000000 - #define CPU_ST7920_DELAY_1 DELAY_NS(0) + #define CPU_ST7920_DELAY_1 DELAY_NS(150) #define CPU_ST7920_DELAY_2 DELAY_NS(0) - #define CPU_ST7920_DELAY_3 DELAY_NS(50) + #define CPU_ST7920_DELAY_3 DELAY_NS(150) #elif MB(3DRAG, K8200, K8400) #define CPU_ST7920_DELAY_1 DELAY_NS(0) #define CPU_ST7920_DELAY_2 DELAY_NS(188) @@ -58,9 +58,9 @@ #define CPU_ST7920_DELAY_2 DELAY_NS(40) #define CPU_ST7920_DELAY_3 DELAY_NS(340) #elif F_CPU == 16000000 - #define CPU_ST7920_DELAY_1 DELAY_NS(0) + #define CPU_ST7920_DELAY_1 DELAY_NS(125) #define CPU_ST7920_DELAY_2 DELAY_NS(0) - #define CPU_ST7920_DELAY_3 DELAY_NS(63) + #define CPU_ST7920_DELAY_3 DELAY_NS(125) #else #error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'" #endif From dd76a50683358732ec3c1a9dadeef479d42d3c94 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 3 Apr 2021 00:33:51 +0000 Subject: [PATCH 158/311] [cron] Bump distribution date (2021-04-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 994348eb76..928e18dae2 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-04-02" + #define STRING_DISTRIBUTION_DATE "2021-04-03" #endif /** From c442485137cac378f7ed8fc56a18f4466e3a461b Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 4 Apr 2021 00:35:49 +0000 Subject: [PATCH 159/311] [cron] Bump distribution date (2021-04-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 928e18dae2..dc143277d2 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-04-03" + #define STRING_DISTRIBUTION_DATE "2021-04-04" #endif /** From 895e40190b8710d62bd4a87bb68cdeda43bdac1d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 18 Mar 2021 22:49:04 -0500 Subject: [PATCH 160/311] Suppress redundant serial errors --- Marlin/src/HAL/STM32F1/HAL.h | 36 ++++++++++++------- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 4 +-- .../extui/lib/dgus/mks/DGUSScreenHandler.h | 3 +- buildroot/tests/BIGTREE_SKR_PRO | 2 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 4656583590..4f430ab4d9 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -84,10 +84,13 @@ #define MYSERIAL1 UsbSerial #elif WITHIN(SERIAL_PORT, 1, NUM_UARTS) #define MYSERIAL1 MSERIAL(SERIAL_PORT) -#elif NUM_UARTS == 5 - #error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." #else - #error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #define MYSERIAL1 MSERIAL(1) // dummy port + #if NUM_UARTS == 5 + #error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." + #else + #error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #endif #endif #ifdef SERIAL_PORT_2 @@ -95,10 +98,13 @@ #define MYSERIAL2 UsbSerial #elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) - #elif NUM_UARTS == 5 - #error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration." #else - #error "SERIAL_PORT_2 must be -1 or from 1 to 3. Please update your configuration." + #define MYSERIAL2 MSERIAL(1) // dummy port + #if NUM_UARTS == 5 + #error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration." + #else + #error "SERIAL_PORT_2 must be -1 or from 1 to 3. Please update your configuration." + #endif #endif #endif @@ -107,10 +113,13 @@ #define MMU2_SERIAL UsbSerial #elif WITHIN(MMU2_SERIAL_PORT, 1, NUM_UARTS) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) - #elif NUM_UARTS == 5 - #error "MMU2_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." #else - #error "MMU2_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #define MMU2_SERIAL MSERIAL(1) // dummy port + #if NUM_UARTS == 5 + #error "MMU2_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." + #else + #error "MMU2_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #endif #endif #endif @@ -119,10 +128,13 @@ #define LCD_SERIAL UsbSerial #elif WITHIN(LCD_SERIAL_PORT, 1, NUM_UARTS) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) - #elif NUM_UARTS == 5 - #error "LCD_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." #else - #error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #define LCD_SERIAL MSERIAL(1) // dummy port + #if NUM_UARTS == 5 + #error "LCD_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." + #else + #error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #endif #endif #if HAS_DGUS_LCD #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index 786d1821a6..355565ae5a 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -733,7 +733,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { // SDCard File listing - + #if ENABLED(SDSUPPORT) VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr), VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr), @@ -760,7 +760,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_OFFSET_Y, &probe.offset.y, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), VPHELPER(VP_OFFSET_Z, &probe.offset.z, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), #endif - #else + #else VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.PrintReturn, nullptr), #endif diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h index 07c123d928..382197c7d6 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h @@ -158,7 +158,6 @@ public: static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr); #endif - #if ENABLED(SDSUPPORT) // Callback for VP "Display wants to change screen when there is a SD card" static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); @@ -184,7 +183,7 @@ public: static void SDCardError(); // Marlin informed us about SD print completion. static void SDPrintingFinished(); - #else + #else static void PrintReturn(DGUS_VP_Variable &var, void *val_ptr); #endif diff --git a/buildroot/tests/BIGTREE_SKR_PRO b/buildroot/tests/BIGTREE_SKR_PRO index 025d8cbce8..2503b28544 100755 --- a/buildroot/tests/BIGTREE_SKR_PRO +++ b/buildroot/tests/BIGTREE_SKR_PRO @@ -26,7 +26,7 @@ opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ CUTTER_POWER_UNIT PERCENT \ SPINDLE_LASER_PWM_PIN HEATER_1_PIN SPINDLE_LASER_ENA_PIN HEATER_2_PIN \ TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 -opt_enable LASER_FEATURE REPRAP_DISCOUNT_SMART_CONTROLLER +opt_enable LASER_FEATURE REPRAP_DISCOUNT_SMART_CONTROLLER exec_test $1 $2 "BigTreeTech SKR Pro | Laser (Percent) | Cooling | LCD" "$3" # clean up From a628559258524164f8fd51e3fcb12e3ff4d81e6d Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Sun, 4 Apr 2021 23:45:56 +0200 Subject: [PATCH 161/311] Update Italian language (#21537) --- Marlin/src/lcd/language/language_it.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index be54d5035d..d359354932 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -114,10 +114,10 @@ namespace Language_it { PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Alterna Laser"); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("ms impulso di test"); PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Spara impulso"); + PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Err.flusso refrig."); PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Alterna mandrino"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Mandrino in avanti"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Inverti mandrino"); - PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Accendi aliment."); PROGMEM Language_Str MSG_SWITCH_PS_OFF = _UxGT("Spegni aliment."); PROGMEM Language_Str MSG_EXTRUDE = _UxGT("Estrudi"); @@ -276,6 +276,10 @@ namespace Language_it { PROGMEM Language_Str MSG_NOZZLE_STANDBY = _UxGT("Ugello in pausa"); PROGMEM Language_Str MSG_BED = _UxGT("Piatto"); PROGMEM Language_Str MSG_CHAMBER = _UxGT("Camera"); + PROGMEM Language_Str MSG_COOLER = _UxGT("Raffreddam. laser"); + PROGMEM Language_Str MSG_COOLER_TOGGLE = _UxGT("Alterna raffreddam."); + PROGMEM Language_Str MSG_FLOWMETER_SAFETY = _UxGT("Sicurezza flusso"); + PROGMEM Language_Str MSG_LASER = _UxGT("Laser"); PROGMEM Language_Str MSG_FAN_SPEED = _UxGT("Vel. ventola"); // Max 15 characters PROGMEM Language_Str MSG_FAN_SPEED_N = _UxGT("Vel. ventola ~"); // Max 15 characters PROGMEM Language_Str MSG_STORED_FAN_N = _UxGT("Ventola mem. ~"); // Max 15 characters @@ -472,6 +476,8 @@ namespace Language_it { PROGMEM Language_Str MSG_THERMAL_RUNAWAY = _UxGT("TEMP FUORI CONTROLLO"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_BED = _UxGT("TEMP PIAT.FUORI CTRL"); PROGMEM Language_Str MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("T.CAMERA FUORI CTRL"); + PROGMEM Language_Str MSG_THERMAL_RUNAWAY_COOLER = _UxGT("RAFFREDAM.FUORI CTRL"); + PROGMEM Language_Str MSG_COOLING_FAILED = _UxGT("Raffreddam. fallito"); PROGMEM Language_Str MSG_ERR_MAXTEMP = _UxGT("Err: TEMP MASSIMA"); PROGMEM Language_Str MSG_ERR_MINTEMP = _UxGT("Err: TEMP MINIMA"); PROGMEM Language_Str MSG_HALTED = _UxGT("STAMPANTE FERMATA"); @@ -487,6 +493,7 @@ namespace Language_it { PROGMEM Language_Str MSG_PROBE_COOLING = _UxGT("Raffr. sonda..."); PROGMEM Language_Str MSG_CHAMBER_HEATING = _UxGT("Risc. camera..."); PROGMEM Language_Str MSG_CHAMBER_COOLING = _UxGT("Raffr. camera..."); + PROGMEM Language_Str MSG_LASER_COOLING = _UxGT("Raffr. laser..."); PROGMEM Language_Str MSG_DELTA_CALIBRATE = _UxGT("Calibraz. Delta"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_X = _UxGT("Calibra X"); PROGMEM Language_Str MSG_DELTA_CALIBRATE_Y = _UxGT("Calibra Y"); @@ -506,6 +513,7 @@ namespace Language_it { PROGMEM Language_Str MSG_BILINEAR_LEVELING = _UxGT("Livel. Bilineare"); PROGMEM Language_Str MSG_UBL_LEVELING = _UxGT("Livel.piatto unific."); PROGMEM Language_Str MSG_MESH_LEVELING = _UxGT("Livel. Mesh"); + PROGMEM Language_Str MSG_MESH_DONE = _UxGT("Sond.mesh eseguito"); PROGMEM Language_Str MSG_INFO_STATS_MENU = _UxGT("Statistiche"); PROGMEM Language_Str MSG_INFO_BOARD_MENU = _UxGT("Info. scheda"); PROGMEM Language_Str MSG_INFO_THERMISTOR_MENU = _UxGT("Termistori"); From c4b69fcdddfe7a626d8277b175851379b699b92b Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sun, 4 Apr 2021 17:55:34 -0400 Subject: [PATCH 162/311] Fix Hotend-abort-on-idle Check (#21535) --- Marlin/src/feature/hotend_idle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index 7f8f20a047..911cd20e6c 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -34,6 +34,7 @@ #include "../module/temperature.h" #include "../module/motion.h" +#include "../module/planner.h" #include "../lcd/marlinui.h" extern HotendIdleProtection hotend_idle; @@ -43,7 +44,8 @@ millis_t HotendIdleProtection::next_protect_ms = 0; void HotendIdleProtection::check_hotends(const millis_t &ms) { bool do_prot = false; HOTEND_LOOP() { - if (thermalManager.degHotend(e) >= HOTEND_IDLE_MIN_TRIGGER) { + const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued()); + if (thermalManager.degHotend(e) >= HOTEND_IDLE_MIN_TRIGGER && !busy) { do_prot = true; break; } } From 98b2b45264c142053b6ddb015472d4fe2a08c78d Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:35:58 -0400 Subject: [PATCH 163/311] Revert "Optimized string-to-number functions" (#21532) This reverts #21484 --- Marlin/src/gcode/parser.cpp | 140 ------------------ Marlin/src/gcode/parser.h | 29 +++- Marlin/src/gcode/queue.cpp | 8 +- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 2 +- 4 files changed, 26 insertions(+), 153 deletions(-) diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 6eb56126e1..ebe9d3b2cd 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -28,146 +28,6 @@ #include "../MarlinCore.h" -#ifdef __AVR__ - - static FORCE_INLINE uint32_t mult10(uint32_t val) { - uint32_t tmp = val; - __asm__ __volatile__ ( - "add %A[tmp], %A[tmp]\n" - "adc %B[tmp], %B[tmp]\n" - "adc %C[tmp], %C[tmp]\n" - "adc %D[tmp], %D[tmp]\n" - "add %A[tmp], %A[tmp]\n" - "adc %B[tmp], %B[tmp]\n" - "adc %C[tmp], %C[tmp]\n" - "adc %D[tmp], %D[tmp]\n" - "add %A[val], %A[tmp]\n" - "adc %B[val], %B[tmp]\n" - "adc %C[val], %C[tmp]\n" - "adc %D[val], %D[tmp]\n" - "add %A[val], %A[val]\n" - "adc %B[val], %B[val]\n" - "adc %C[val], %C[val]\n" - "adc %D[val], %D[val]\n" - : [val] "+&r" (val), - [tmp] "+&r" (tmp) - ); - return val; - } - -#else - - static FORCE_INLINE uint32_t mult10(uint32_t val) { return val * 10; } - -#endif - -// cheap base-10 strto(u)l. -// does not check for errors. -int32_t parse_int32(const char *buf) { - char c; - - // Get a char, skipping leading spaces - do { c = *buf++; } while (c == ' '); - - // check for sign - bool is_negative = (c == '-'); - if (is_negative || c == '+') - c = *buf++; - - // optimization for first digit (no multiplication) - uint8_t uc = c - '0'; - if (uc > 9) return 0; - - // read unsigned value - uint32_t uval = uc; - while (true) { - c = *buf++; - uc = c - '0'; - if (uc > 9) break; - uval = mult10(uval) + uc; - } - - return is_negative ? -uval : uval; -} - -// cheap strtof. -// does not support nan/infinity or exponent notation. -// does not check for errors. -float parse_float(const char *buf) { - char c; - - // Get a char, skipping leading spaces - do { c = *buf++; } while (c == ' '); - - // check for sign - bool is_negative = (c == '-'); - if (is_negative || c == '+') - c = *buf++; - - // read unsigned value and decimal point - uint32_t uval; - uint8_t exp_dec; - uint8_t uc = c - '0'; - if (uc <= 9) { - uval = uc; - exp_dec = 0; - } - else { - if (c != '.') return 0; - uval = 0; - exp_dec = 1; - } - - int8_t exp = 0; - while (true) { - c = *buf++; - uc = c - '0'; - if (uc <= 9) { - exp -= exp_dec; - uval = mult10(uval) + uc; - if (uval >= (UINT32_MAX - 9) / 10) { - // overflow. keep reading digits until decimal point. - while (exp_dec == 0) { - c = *buf++; - uc = c - '0'; - if (uc > 9) break; - exp++; - } - goto overflow; - } - } - else { - if (c != '.' || exp_dec != 0) break; - exp_dec = 1; - } - } - - // early return for 0 - if (uval == 0) return 0; - - overflow: - - // convert to float and apply sign - float fval = uval; - if (is_negative) fval *= -1; - - // apply exponent (up to 1e-15 / 1e+15) - if (exp < 0) { - if (exp <= -8) { fval *= 1e-8; exp += 8; } - if (exp <= -4) { fval *= 1e-4; exp += 4; } - if (exp <= -2) { fval *= 1e-2; exp += 2; } - if (exp <= -1) { fval *= 1e-1; exp += 1; } - } - else if (exp > 0) { - if (exp >= 8) { fval *= 1e+8; exp -= 8; } - if (exp >= 4) { fval *= 1e+4; exp -= 4; } - if (exp >= 2) { fval *= 1e+2; exp -= 2; } - if (exp >= 1) { fval *= 1e+1; exp -= 1; } - } - - return fval; -} - // Must be declared for allocation and to satisfy the linker // Zero values need no initialization. diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index a0fc67b9e5..8523630098 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -42,10 +42,6 @@ typedef enum : uint8_t { LINEARUNIT_MM, LINEARUNIT_INCH } LinearUnit; #endif - -int32_t parse_int32(const char *buf); -float parse_float(const char *buf); - /** * GCode parser * @@ -260,12 +256,29 @@ public: // The value as a string static inline char* value_string() { return value_ptr; } - // Code value as float - static inline float value_float() { return value_ptr ? parse_float(value_ptr) : 0.0; } + // Float removes 'E' to prevent scientific notation interpretation + static inline float value_float() { + if (value_ptr) { + char *e = value_ptr; + for (;;) { + const char c = *e; + if (c == '\0' || c == ' ') break; + if (c == 'E' || c == 'e') { + *e = '\0'; + const float ret = strtof(value_ptr, nullptr); + *e = c; + return ret; + } + ++e; + } + return strtof(value_ptr, nullptr); + } + return 0; + } // Code value as a long or ulong - static inline int32_t value_long() { return value_ptr ? parse_int32(value_ptr) : 0L; } - static inline uint32_t value_ulong() { return value_ptr ? parse_int32(value_ptr) : 0UL; } + static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; } + static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; } // Code value for use as time static inline millis_t value_millis() { return value_ulong(); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index eb7ad79102..a79909917e 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -445,7 +445,7 @@ void GCodeQueue::get_serial_commands() { if (process_line_done(serial.input_state, serial.line_buffer, serial.count)) continue; - char *command = serial.line_buffer; + char* command = serial.line_buffer; while (*command == ' ') command++; // Skip leading spaces char *npos = (*command == 'N') ? command : nullptr; // Require the N parameter to start the line @@ -459,7 +459,7 @@ void GCodeQueue::get_serial_commands() { if (n2pos) npos = n2pos; } - const long gcode_N = parse_int32(npos + 1); + const long gcode_N = strtol(npos + 1, nullptr, 10); if (gcode_N != serial.last_N + 1 && !M110) { // In case of error on a serial port, don't prevent other serial port from making progress @@ -471,7 +471,7 @@ void GCodeQueue::get_serial_commands() { if (apos) { uint8_t checksum = 0, count = uint8_t(apos - command); while (count) checksum ^= command[--count]; - if (parse_int32(apos + 1) != checksum) { + if (strtol(apos + 1, nullptr, 10) != checksum) { // In case of error on a serial port, don't prevent other serial port from making progress gcode_line_error(PSTR(STR_ERR_CHECKSUM_MISMATCH), p); break; @@ -500,7 +500,7 @@ void GCodeQueue::get_serial_commands() { if (IsStopped()) { char* gpos = strchr(command, 'G'); if (gpos) { - switch (parse_int32(gpos + 1)) { + switch (strtol(gpos + 1, nullptr, 10)) { case 0: case 1: #if ENABLED(ARC_SUPPORT) case 2: case 3: 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 ac07dc0102..a74ecd2f1e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -1799,7 +1799,7 @@ void get_wifi_commands() { if (IsStopped()) { char* gpos = strchr(command, 'G'); if (gpos) { - switch (parse_int32(gpos + 1)) { + switch (strtol(gpos + 1, nullptr, 10)) { case 0 ... 1: #if ENABLED(ARC_SUPPORT) case 2 ... 3: From 8b6718c6320c32abe0fa1de56a033aca54ff0b76 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 4 Apr 2021 18:07:16 -0500 Subject: [PATCH 164/311] misc. pointer formatting --- Marlin/src/HAL/DUE/eeprom_flash.cpp | 4 +- Marlin/src/HAL/ESP32/i2s.cpp | 2 +- Marlin/src/HAL/STM32/MarlinSerial.h | 2 +- Marlin/src/HAL/STM32F1/onboard_sd.h | 2 +- Marlin/src/HAL/shared/backtrace/backtrace.cpp | 2 +- Marlin/src/HAL/shared/backtrace/unwinder.h | 2 +- Marlin/src/feature/spindle_laser.h | 2 +- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 4 +- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h | 4 +- .../extui/lib/dgus/mks/DGUSScreenHandler.cpp | 2 +- .../extui/lib/dgus/mks/DGUSScreenHandler.h | 2 +- .../ftdi_eve_lib/basic/commands.cpp | 2 +- .../ftdi_eve_lib/basic/commands.h | 2 +- .../ftdi_eve_lib/extended/command_processor.h | 2 +- Marlin/src/sd/Sd2Card.cpp | 2 +- Marlin/src/sd/Sd2Card.h | 2 +- Marlin/src/sd/SdBaseFile.cpp | 82 ++++++++----------- Marlin/src/sd/SdBaseFile.h | 36 ++++---- Marlin/src/sd/SdFile.cpp | 2 +- Marlin/src/sd/SdFile.h | 4 +- Marlin/src/sd/SdVolume.h | 8 +- Marlin/src/sd/cardreader.cpp | 8 +- Marlin/src/sd/cardreader.h | 6 +- 23 files changed, 85 insertions(+), 99 deletions(-) diff --git a/Marlin/src/HAL/DUE/eeprom_flash.cpp b/Marlin/src/HAL/DUE/eeprom_flash.cpp index 14c843576c..b4cb9912b2 100644 --- a/Marlin/src/HAL/DUE/eeprom_flash.cpp +++ b/Marlin/src/HAL/DUE/eeprom_flash.cpp @@ -135,7 +135,7 @@ static uint8_t buffer[256] = {0}, // The RAM buffer to accumulate writes #define DEBUG_OUT ENABLED(EE_EMU_DEBUG) #include "../../core/debug_out.h" -static void ee_Dump(const int page, const void* data) { +static void ee_Dump(const int page, const void *data) { #ifdef EE_EMU_DEBUG @@ -181,7 +181,7 @@ static void ee_Dump(const int page, const void* data) { * @param data (pointer to the data buffer) */ __attribute__ ((long_call, section (".ramfunc"))) -static bool ee_PageWrite(uint16_t page, const void* data) { +static bool ee_PageWrite(uint16_t page, const void *data) { uint16_t i; uint32_t addrflash = uint32_t(getFlashStorage(page)); diff --git a/Marlin/src/HAL/ESP32/i2s.cpp b/Marlin/src/HAL/ESP32/i2s.cpp index e8f3806543..c28c008793 100644 --- a/Marlin/src/HAL/ESP32/i2s.cpp +++ b/Marlin/src/HAL/ESP32/i2s.cpp @@ -139,7 +139,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) { I2S0.int_clr.val = I2S0.int_st.val; //clear pending interrupt } -void stepperTask(void* parameter) { +void stepperTask(void *parameter) { uint32_t remaining = 0; while (1) { diff --git a/Marlin/src/HAL/STM32/MarlinSerial.h b/Marlin/src/HAL/STM32/MarlinSerial.h index d9e8457017..ab5c4260af 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.h +++ b/Marlin/src/HAL/STM32/MarlinSerial.h @@ -29,7 +29,7 @@ typedef void (*usart_rx_callback_t)(serial_t * obj); struct MarlinSerial : public HardwareSerial { - MarlinSerial(void* peripheral, usart_rx_callback_t rx_callback) : + MarlinSerial(void *peripheral, usart_rx_callback_t rx_callback) : HardwareSerial(peripheral), _rx_callback(rx_callback) { } diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.h b/Marlin/src/HAL/STM32F1/onboard_sd.h index 1dc7ec5b3b..1c0a1c5b84 100644 --- a/Marlin/src/HAL/STM32F1/onboard_sd.h +++ b/Marlin/src/HAL/STM32F1/onboard_sd.h @@ -48,7 +48,7 @@ DRESULT disk_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count); DRESULT disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); #endif #if _DISKIO_IOCTL - DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff); + DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff); #endif /* Disk Status Bits (DSTATUS) */ diff --git a/Marlin/src/HAL/shared/backtrace/backtrace.cpp b/Marlin/src/HAL/shared/backtrace/backtrace.cpp index e4ae502a88..ad88de8385 100644 --- a/Marlin/src/HAL/shared/backtrace/backtrace.cpp +++ b/Marlin/src/HAL/shared/backtrace/backtrace.cpp @@ -29,7 +29,7 @@ #include // Dump a backtrace entry -static bool UnwReportOut(void* ctx, const UnwReport* bte) { +static bool UnwReportOut(void *ctx, const UnwReport *bte) { int *p = (int*)ctx; (*p)++; diff --git a/Marlin/src/HAL/shared/backtrace/unwinder.h b/Marlin/src/HAL/shared/backtrace/unwinder.h index 157808d540..8692c7a1aa 100644 --- a/Marlin/src/HAL/shared/backtrace/unwinder.h +++ b/Marlin/src/HAL/shared/backtrace/unwinder.h @@ -114,7 +114,7 @@ typedef struct { * report function maybe called again in future. If false is returned, * unwinding will stop with UnwindStart() returning UNWIND_TRUNCATED. */ -typedef bool (*UnwindReportFunc)(void* data, const UnwReport* bte); +typedef bool (*UnwindReportFunc)(void *data, const UnwReport *bte); /** Structure that holds memory callback function pointers. */ diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index bf7106fab7..88cf372a02 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -215,7 +215,7 @@ public: static inline void disable() { isReady = false; set_enabled(false); } #if HAS_LCD_MENU - static inline void enable_with_dir(const bool reverse) { + static inline void enable_with_dir(const bool reverse) { isReady = true; const uint8_t ocr = TERN(SPINDLE_LASER_PWM, upower_to_ocr(menuPower), 255); if (menuPower) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index 2c283b1a92..2f33768655 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -70,7 +70,7 @@ void DGUSDisplay::InitDisplay() { RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN)); } -void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) { +void DGUSDisplay::WriteVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) { const char* myvalues = static_cast(values); bool strend = !myvalues; WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen); @@ -120,7 +120,7 @@ void DGUSDisplay::WriteVariable(uint16_t adr, long value) { WriteVariable(adr, static_cast(&tmp), sizeof(long)); } -void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) { +void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) { const char* myvalues = static_cast(values); bool strend = !myvalues; WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen); diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h index c017d69dae..f33935a269 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h @@ -56,8 +56,8 @@ public: static void InitDisplay(); // Variable access. - static void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false); - static void WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false); + static void WriteVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr=false); + static void WriteVariablePGM(uint16_t adr, const void *values, uint8_t valueslen, bool isstr=false); static void WriteVariable(uint16_t adr, int16_t value); static void WriteVariable(uint16_t adr, uint16_t value); static void WriteVariable(uint16_t adr, uint8_t value); diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index 54500011f8..109e9a8ac6 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -75,7 +75,7 @@ void DGUSScreenHandler::sendinfoscreen_en_mks(const char *line1, const char *lin dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true); } -void DGUSScreenHandler::sendinfoscreen_mks(const void* line1, const void* line2, const void* line3, const void* line4, uint16_t language) { +void DGUSScreenHandler::sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language) { if (language == MKS_English) DGUSScreenHandler::sendinfoscreen_en_mks((char *)line1, (char *)line2, (char *)line3, (char *)line4); else if (language == MKS_SimpleChinese) diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h index 382197c7d6..ef67635f8d 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h @@ -44,7 +44,7 @@ public: #if 0 static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4); static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ; - static void sendinfoscreen_mks(const void* line1, const void* line2, const void* line3, const void* line4,uint16_t language); + static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language); #endif // "M117" Message -- msg is a RAM ptr. 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 736809323b..47ce1c700d 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 @@ -229,7 +229,7 @@ void CLCD::CommandFifo::cmd(uint32_t cmd32) { write((void*)&cmd32, sizeof(uint32_t)); } -void CLCD::CommandFifo::cmd(void* data, uint16_t len) { +void CLCD::CommandFifo::cmd(void *data, uint16_t len) { write(data, len); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h index 376beaec44..eea24b06bd 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.h @@ -196,7 +196,7 @@ class CLCD::CommandFifo { void execute(); void cmd(uint32_t cmd32); - void cmd(void* data, uint16_t len); + void cmd(void *data, uint16_t len); void dlstart() {cmd(FTDI::CMD_DLSTART);} void swap() {cmd(FTDI::CMD_SWAP);} diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h index da51ee6385..2258529221 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h @@ -149,7 +149,7 @@ class CommandProcessor : public CLCD::CommandFifo { // Wrap all the CommandFifo routines to allow method chaining inline CommandProcessor& cmd (uint32_t cmd32) {CLCD::CommandFifo::cmd(cmd32); return *this;} - inline CommandProcessor& cmd (void* data, uint16_t len) {CLCD::CommandFifo::cmd(data, len); return *this;} + inline CommandProcessor& cmd (void *data, uint16_t len) {CLCD::CommandFifo::cmd(data, len); return *this;} inline CommandProcessor& execute() {CLCD::CommandFifo::execute(); return *this;} inline CommandProcessor& fgcolor (uint32_t rgb) {CLCD::CommandFifo::fgcolor(rgb); return *this;} diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index b914b29635..28049c7e7e 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -477,7 +477,7 @@ bool Sd2Card::readData(uint8_t *dst, const uint16_t count) { } /** read CID or CSR register */ -bool Sd2Card::readRegister(const uint8_t cmd, void* buf) { +bool Sd2Card::readRegister(const uint8_t cmd, void *buf) { uint8_t *dst = reinterpret_cast(buf); if (cardCommand(cmd, 0)) { error(SD_CARD_ERROR_READ_REG); diff --git a/Marlin/src/sd/Sd2Card.h b/Marlin/src/sd/Sd2Card.h index d82cb10a1e..eb7f9bb2ca 100644 --- a/Marlin/src/sd/Sd2Card.h +++ b/Marlin/src/sd/Sd2Card.h @@ -177,7 +177,7 @@ private: uint8_t cardCommand(const uint8_t cmd, const uint32_t arg); bool readData(uint8_t *dst, const uint16_t count); - bool readRegister(const uint8_t cmd, void* buf); + bool readRegister(const uint8_t cmd, void *buf); void chipDeselect(); void chipSelect(); inline void type(const uint8_t value) { type_ = value; } diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 120668baa8..ac73a5a806 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -40,7 +40,7 @@ #include "SdBaseFile.h" #include "../MarlinCore.h" -SdBaseFile* SdBaseFile::cwd_ = 0; // Pointer to Current Working Directory +SdBaseFile *SdBaseFile::cwd_ = 0; // Pointer to Current Working Directory // callback function for date/time void (*SdBaseFile::dateTime_)(uint16_t *date, uint16_t *time) = 0; @@ -155,7 +155,7 @@ bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) { * a file is already open, the file already exists, the root * directory is full or an I/O error. */ -bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char *path, uint32_t size) { +bool SdBaseFile::createContiguous(SdBaseFile *dirFile, const char *path, uint32_t size) { if (ENABLED(SDCARD_READONLY)) return false; uint32_t count; @@ -187,12 +187,11 @@ bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char *path, uint32_ * \return true for success, false for failure. */ bool SdBaseFile::dirEntry(dir_t *dir) { - dir_t *p; // make sure fields on SD are correct if (!sync()) return false; // read entry - p = cacheDirEntry(SdVolume::CACHE_FOR_READ); + dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_READ); if (!p) return false; // copy to caller's struct @@ -207,7 +206,7 @@ bool SdBaseFile::dirEntry(dir_t *dir) { * \param[in] dir The directory structure containing the name. * \param[out] name A 13 byte char array for the formatted name. */ -void SdBaseFile::dirName(const dir_t& dir, char *name) { +void SdBaseFile::dirName(const dir_t &dir, char *name) { uint8_t j = 0; LOOP_L_N(i, 11) { if (dir.name[i] == ' ')continue; @@ -386,7 +385,7 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) { } // Format directory name field from a 8.3 name string -bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char** ptr) { +bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char **ptr) { uint8_t n = 7, // Max index until a dot is found i = 11; while (i) name[--i] = ' '; // Set whole FILENAME.EXT to spaces @@ -423,13 +422,13 @@ bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char** ptr) { * Reasons for failure include this file is already open, \a parent is not a * directory, \a path is invalid or already exists in \a parent. */ -bool SdBaseFile::mkdir(SdBaseFile* parent, const char *path, bool pFlag) { +bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { if (ENABLED(SDCARD_READONLY)) return false; uint8_t dname[11]; SdBaseFile dir1, dir2; - SdBaseFile* sub = &dir1; - SdBaseFile* start = parent; + SdBaseFile *sub = &dir1; + SdBaseFile *start = parent; if (!parent || isOpen()) return false; @@ -455,13 +454,9 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const char *path, bool pFlag) { return mkdir(parent, dname); } -bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) { +bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11]) { if (ENABLED(SDCARD_READONLY)) return false; - uint32_t block; - dir_t d; - dir_t *p; - if (!parent->isDir()) return false; // create a normal file @@ -478,19 +473,20 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) { if (!sync()) return false; // cache entry - should already be in cache due to sync() call - p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); if (!p) return false; // change directory entry attribute p->attributes = DIR_ATT_DIRECTORY; // make entry for '.' + dir_t d; memcpy(&d, p, sizeof(d)); d.name[0] = '.'; LOOP_S_L_N(i, 1, 11) d.name[i] = ' '; // cache block for '.' and '..' - block = vol_->clusterStartBlock(firstCluster_); + uint32_t block = vol_->clusterStartBlock(firstCluster_); if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) return false; // copy '.' to block @@ -577,7 +573,7 @@ bool SdBaseFile::open(const char *path, uint8_t oflag) { * a directory, \a path is invalid, the file does not exist * or can't be opened in the access mode specified by oflag. */ -bool SdBaseFile::open(SdBaseFile* dirFile, const char *path, uint8_t oflag) { +bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { uint8_t dname[11]; SdBaseFile dir1, dir2; SdBaseFile *parent = dirFile, *sub = &dir1; @@ -605,7 +601,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const char *path, uint8_t oflag) { } // open with filename in dname -bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag) { +bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag) { bool emptyFound = false, fileFound = false; uint8_t index; dir_t *p; @@ -696,9 +692,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla * See open() by path for definition of flags. * \return true for success or false for failure. */ -bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) { - dir_t *p; - +bool SdBaseFile::open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag) { vol_ = dirFile->vol_; // error if already open @@ -711,7 +705,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) { if (!dirFile->seekSet(32 * index)) return false; // read entry into cache - p = dirFile->readDirCache(); + dir_t *p = dirFile->readDirCache(); if (!p) return false; // error if empty slot or '.' or '..' @@ -784,10 +778,7 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { * See open() by path for definition of flags. * \return true for success or false for failure. */ -bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) { - dir_t *p; - uint8_t index; - +bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { if (!dirFile) return false; // error if already open @@ -796,10 +787,10 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) { vol_ = dirFile->vol_; while (1) { - index = 0xF & (dirFile->curPosition_ >> 5); + uint8_t index = 0xF & (dirFile->curPosition_ >> 5); // read entry into cache - p = dirFile->readDirCache(); + dir_t *p = dirFile->readDirCache(); if (!p) return false; // done if last entry @@ -825,9 +816,8 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) { * * \return true for success, false for failure. */ -bool SdBaseFile::openParent(SdBaseFile* dir) { +bool SdBaseFile::openParent(SdBaseFile *dir) { dir_t entry; - dir_t *p; SdBaseFile file; uint32_t c; uint32_t cluster; @@ -850,7 +840,7 @@ bool SdBaseFile::openParent(SdBaseFile* dir) { // first block of parent dir if (!vol_->cacheRawBlock(lbn, SdVolume::CACHE_FOR_READ)) return false; - p = &vol_->cacheBuffer_.dir[1]; + dir_t *p = &vol_->cacheBuffer_.dir[1]; // verify name for '../..' if (p->name[0] != '.' || p->name[1] != '.') return false; // '..' is pointer to first cluster of parent. open '../..' to find parent @@ -881,7 +871,7 @@ bool SdBaseFile::openParent(SdBaseFile* dir) { * Reasons for failure include the file is already open, the FAT volume has * not been initialized or it a FAT12 volume. */ -bool SdBaseFile::openRoot(SdVolume* vol) { +bool SdBaseFile::openRoot(SdVolume *vol) { // error if file is already open if (isOpen()) return false; @@ -1008,7 +998,7 @@ int16_t SdBaseFile::read() { * read() called before a file has been opened, corrupt file system * or an I/O error occurred. */ -int16_t SdBaseFile::read(void* buf, uint16_t nbyte) { +int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { uint8_t *dst = reinterpret_cast(buf); uint16_t offset, toRead; uint32_t block; // raw device block number @@ -1136,7 +1126,7 @@ int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) { // Reset n to the start of the long name n = 0; for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH) / 2; idx += 2) { // idx is fixed since FAT LFN always contains UTF-16LE encoding - uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8); + const uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8); if (0xD800 == (utf16_ch & 0xF800)) // Surrogate pair - encode as '_' longFilename[n++] = '_'; else if (0 == (utf16_ch & 0xFF80)) // Encode as 1-byte UTF-8 char @@ -1199,12 +1189,11 @@ dir_t* SdBaseFile::readDirCache() { bool SdBaseFile::remove() { if (ENABLED(SDCARD_READONLY)) return false; - dir_t *d; // free any clusters - will fail if read-only or directory if (!truncate(0)) return false; // cache directory entry - d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); if (!d) return false; // mark entry deleted @@ -1235,7 +1224,7 @@ bool SdBaseFile::remove() { * \a dirFile is not a directory, \a path is not found * or an I/O error occurred. */ -bool SdBaseFile::remove(SdBaseFile* dirFile, const char *path) { +bool SdBaseFile::remove(SdBaseFile *dirFile, const char *path) { if (ENABLED(SDCARD_READONLY)) return false; SdBaseFile file; @@ -1252,13 +1241,10 @@ bool SdBaseFile::remove(SdBaseFile* dirFile, const char *path) { * Reasons for failure include \a dirFile is not open or is not a directory * file, newPath is invalid or already exists, or an I/O error occurs. */ -bool SdBaseFile::rename(SdBaseFile* dirFile, const char *newPath) { +bool SdBaseFile::rename(SdBaseFile *dirFile, const char *newPath) { if (ENABLED(SDCARD_READONLY)) return false; - dir_t entry; uint32_t dirCluster = 0; - SdBaseFile file; - dir_t *d; // must be an open file or subdirectory if (!(isFile() || isSubDir())) return false; @@ -1268,16 +1254,18 @@ bool SdBaseFile::rename(SdBaseFile* dirFile, const char *newPath) { // sync() and cache directory entry sync(); - d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); if (!d) return false; // save directory entry + dir_t entry; memcpy(&entry, d, sizeof(entry)); // mark entry deleted d->name[0] = DIR_NAME_DELETED; // make directory entry for new path + SdBaseFile file; if (isFile()) { if (!file.open(dirFile, newPath, O_CREAT | O_EXCL | O_WRITE)) { goto restore; @@ -1536,8 +1524,7 @@ bool SdBaseFile::sync() { * * \return true for success, false for failure. */ -bool SdBaseFile::timestamp(SdBaseFile* file) { - dir_t *d; +bool SdBaseFile::timestamp(SdBaseFile *file) { dir_t dir; // get timestamps @@ -1546,7 +1533,7 @@ bool SdBaseFile::timestamp(SdBaseFile* file) { // update directory fields if (!sync()) return false; - d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); if (!d) return false; // copy timestamps @@ -1599,7 +1586,6 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month, if (ENABLED(SDCARD_READONLY)) return false; uint16_t dirDate, dirTime; - dir_t *d; if (!isOpen() || year < 1980 @@ -1616,7 +1602,7 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month, // update directory entry if (!sync()) return false; - d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); if (!d) return false; dirDate = FAT_DATE(year, month, day); @@ -1710,7 +1696,7 @@ bool SdBaseFile::truncate(uint32_t length) { * include write() is called before a file has been opened, write is called * for a read-only file, device is full, a corrupt file system or an I/O error. */ -int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) { +int16_t SdBaseFile::write(const void *buf, uint16_t nbyte) { #if ENABLED(SDCARD_READONLY) writeError = true; return -1; #endif diff --git a/Marlin/src/sd/SdBaseFile.h b/Marlin/src/sd/SdBaseFile.h index 1e2bc5d09e..342edefb70 100644 --- a/Marlin/src/sd/SdBaseFile.h +++ b/Marlin/src/sd/SdBaseFile.h @@ -189,7 +189,7 @@ class SdBaseFile { bool close(); bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock); - bool createContiguous(SdBaseFile* dirFile, + bool createContiguous(SdBaseFile *dirFile, const char *path, uint32_t size); /** * \return The current cluster number for a file or directory. @@ -204,7 +204,7 @@ class SdBaseFile { /** * \return Current working directory */ - static SdBaseFile* cwd() { return cwd_; } + static SdBaseFile *cwd() { return cwd_; } /** * Set the date/time callback function @@ -286,27 +286,27 @@ class SdBaseFile { bool getDosName(char * const name); void ls(uint8_t flags = 0, uint8_t indent = 0); - bool mkdir(SdBaseFile* dir, const char *path, bool pFlag = true); - bool open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag); - bool open(SdBaseFile* dirFile, const char *path, uint8_t oflag); + bool mkdir(SdBaseFile *dir, const char *path, bool pFlag = true); + bool open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag); + bool open(SdBaseFile *dirFile, const char *path, uint8_t oflag); bool open(const char *path, uint8_t oflag = O_READ); - bool openNext(SdBaseFile* dirFile, uint8_t oflag); - bool openRoot(SdVolume* vol); + bool openNext(SdBaseFile *dirFile, uint8_t oflag); + bool openRoot(SdVolume *vol); int peek(); static void printFatDate(uint16_t fatDate); static void printFatTime(uint16_t fatTime); bool printName(); int16_t read(); - int16_t read(void* buf, uint16_t nbyte); + int16_t read(void *buf, uint16_t nbyte); int8_t readDir(dir_t *dir, char *longFilename); - static bool remove(SdBaseFile* dirFile, const char *path); + static bool remove(SdBaseFile *dirFile, const char *path); bool remove(); /** * Set the file's current position to zero. */ void rewind() { seekSet(0); } - bool rename(SdBaseFile* dirFile, const char *newPath); + bool rename(SdBaseFile *dirFile, const char *newPath); bool rmdir(); bool rmRfStar(); @@ -325,7 +325,7 @@ class SdBaseFile { bool seekEnd(const int32_t offset = 0) { return seekSet(fileSize_ + offset); } bool seekSet(const uint32_t pos); bool sync(); - bool timestamp(SdBaseFile* file); + bool timestamp(SdBaseFile *file); bool timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second); @@ -341,11 +341,11 @@ class SdBaseFile { * \return SdVolume that contains this file. */ SdVolume* volume() const { return vol_; } - int16_t write(const void* buf, uint16_t nbyte); + int16_t write(const void *buf, uint16_t nbyte); private: friend class SdFat; // allow SdFat to set cwd_ - static SdBaseFile* cwd_; // global pointer to cwd dir + static SdBaseFile *cwd_; // global pointer to cwd dir // data time callback function static void (*dateTime_)(uint16_t *date, uint16_t *time); @@ -364,21 +364,21 @@ class SdBaseFile { uint8_t dirIndex_; // index of directory entry in dirBlock uint32_t fileSize_; // file size in bytes uint32_t firstCluster_; // first cluster of file - SdVolume* vol_; // volume where file is located + SdVolume *vol_; // volume where file is located /** * EXPERIMENTAL - Don't use! */ - //bool openParent(SdBaseFile* dir); + //bool openParent(SdBaseFile *dir); // private functions bool addCluster(); bool addDirCluster(); dir_t* cacheDirEntry(uint8_t action); int8_t lsPrintNext(uint8_t flags, uint8_t indent); - static bool make83Name(const char *str, uint8_t *name, const char** ptr); - bool mkdir(SdBaseFile* parent, const uint8_t dname[11]); - bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag); + static bool make83Name(const char *str, uint8_t *name, const char **ptr); + bool mkdir(SdBaseFile *parent, const uint8_t dname[11]); + bool open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag); bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags); dir_t* readDirCache(); }; diff --git a/Marlin/src/sd/SdFile.cpp b/Marlin/src/sd/SdFile.cpp index cc86ce819f..bce96ef02d 100644 --- a/Marlin/src/sd/SdFile.cpp +++ b/Marlin/src/sd/SdFile.cpp @@ -60,7 +60,7 @@ SdFile::SdFile(const char *path, uint8_t oflag) : SdBaseFile(path, oflag) { } * include write() is called before a file has been opened, write is called * for a read-only file, device is full, a corrupt file system or an I/O error. */ -int16_t SdFile::write(const void* buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); } +int16_t SdFile::write(const void *buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); } /** * Write a byte to a file. Required by the Arduino Print class. diff --git a/Marlin/src/sd/SdFile.h b/Marlin/src/sd/SdFile.h index 69fe05b499..1691898899 100644 --- a/Marlin/src/sd/SdFile.h +++ b/Marlin/src/sd/SdFile.h @@ -46,10 +46,10 @@ class SdFile : public SdBaseFile { #if ARDUINO >= 100 size_t write(uint8_t b); #else - void write(uint8_t b); + void write(uint8_t b); #endif - int16_t write(const void* buf, uint16_t nbyte); + int16_t write(const void *buf, uint16_t nbyte); void write(const char *str); void write_P(PGM_P str); void writeln_P(PGM_P str); diff --git a/Marlin/src/sd/SdVolume.h b/Marlin/src/sd/SdVolume.h index 8122087451..c2eaf0bd13 100644 --- a/Marlin/src/sd/SdVolume.h +++ b/Marlin/src/sd/SdVolume.h @@ -90,8 +90,8 @@ class SdVolume { * Reasons for failure include not finding a valid partition, not finding * a valid FAT file system or an I/O error. */ - bool init(Sd2Card* dev) { return init(dev, 1) ? true : init(dev, 0); } - bool init(Sd2Card* dev, uint8_t part); + bool init(Sd2Card *dev) { return init(dev, 1) ? true : init(dev, 0); } + bool init(Sd2Card *dev, uint8_t part); // inline functions that return volume info uint8_t blocksPerCluster() const { return blocksPerCluster_; } //> \return The volume's cluster size in blocks. @@ -138,13 +138,13 @@ class SdVolume { #if USE_MULTIPLE_CARDS cache_t cacheBuffer_; // 512 byte cache for device blocks uint32_t cacheBlockNumber_; // Logical number of block in the cache - Sd2Card* sdCard_; // Sd2Card object for cache + Sd2Card *sdCard_; // Sd2Card object for cache bool cacheDirty_; // cacheFlush() will write block if true uint32_t cacheMirrorBlock_; // block number for mirror FAT #else static cache_t cacheBuffer_; // 512 byte cache for device blocks static uint32_t cacheBlockNumber_; // Logical number of block in the cache - static Sd2Card* sdCard_; // Sd2Card object for cache + static Sd2Card *sdCard_; // Sd2Card object for cache static bool cacheDirty_; // cacheFlush() will write block if true static uint32_t cacheMirrorBlock_; // block number for mirror FAT #endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 53053e88dc..225f7d9a95 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -723,9 +723,9 @@ void CardReader::report_status() { } void CardReader::write_command(char * const buf) { - char* begin = buf; - char* npos = nullptr; - char* end = buf + strlen(buf) - 1; + char *begin = buf; + char *npos = nullptr; + char *end = buf + strlen(buf) - 1; file.writeError = false; if ((npos = strchr(buf, 'N'))) { @@ -845,7 +845,7 @@ uint16_t CardReader::countFilesInWorkDir() { * * A nullptr result indicates an unrecoverable error. */ -const char* CardReader::diveToFile(const bool update_cwd, SdFile*& diveDir, const char * const path, const bool echo/*=false*/) { +const char* CardReader::diveToFile(const bool update_cwd, SdFile* &diveDir, const char * const path, const bool echo/*=false*/) { // Track both parent and subfolder static SdFile newDir1, newDir2; SdFile *sub = &newDir1, *startDir; diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 1f917f8576..9528c4ac28 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -141,7 +141,7 @@ public: static inline uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; } // Helper for open and remove - static const char* diveToFile(const bool update_cwd, SdFile*& curDir, const char * const path, const bool echo=false); + static const char* diveToFile(const bool update_cwd, SdFile* &curDir, const char * const path, const bool echo=false); #if ENABLED(SDCARD_SORT_ALPHA) static void presort(); @@ -168,8 +168,8 @@ public: static inline void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); } static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; } static inline int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; } - static inline int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } - static inline int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } + static inline int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } + static inline int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } static Sd2Card& getSd2Card() { return sd2card; } From 8da8bf7e879835a14c045fdfe947c81008027a17 Mon Sep 17 00:00:00 2001 From: vyacheslav-shubin Date: Mon, 5 Apr 2021 02:52:16 +0300 Subject: [PATCH 165/311] Fix FAT delete of items with long name (#21528) --- Marlin/src/sd/SdBaseFile.cpp | 87 ++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 28 deletions(-) diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index ac73a5a806..b357495a3e 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -1049,6 +1049,20 @@ int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { return nbyte; } +/** + * Calculate a checksum for an 8.3 filename + * + * \param name The 8.3 file name to calculate + * + * \return The checksum byte + */ +uint8_t lfn_checksum(const uint8_t *name) { + uint8_t sum = 0; + for (uint8_t i = 11; i; i--) + sum = ((sum & 1) << 7) + (sum >> 1) + *name++; + return sum; +} + /** * Read the next entry in a directory. * @@ -1065,51 +1079,68 @@ int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) { // if not a directory file or miss-positioned return an error if (!isDir() || (0x1F & curPosition_)) return -1; + #define INVALIDATE_LONGNAME() (longFilename[0] = longFilename[1] = '\0') + // If we have a longFilename buffer, mark it as invalid. // If a long filename is found it will be filled automatically. - if (longFilename) { longFilename[0] = '\0'; longFilename[1] = '\0'; } + if (longFilename) INVALIDATE_LONGNAME(); + + uint8_t checksum_error = 0xFF, checksum = 0; while (1) { n = read(dir, sizeof(dir_t)); if (n != sizeof(dir_t)) return n ? -1 : 0; - // last entry if DIR_NAME_FREE + // Last entry if DIR_NAME_FREE if (dir->name[0] == DIR_NAME_FREE) return 0; - // skip deleted entry and entry for . and .. + // Skip deleted entry and entry for . and .. if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.') { - if (longFilename) { longFilename[0] = '\0'; longFilename[1] = '\0'; } // Invalidate erased file long name, if any + if (longFilename) INVALIDATE_LONGNAME(); // Invalidate erased file long name, if any continue; } - // Fill the long filename if we have a long filename entry. - // Long filename entries are stored before the short filename. - if (longFilename && DIR_IS_LONG_NAME(dir)) { - vfat_t *VFAT = (vfat_t*)dir; - // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 - if (VFAT->firstClusterLow == 0) { - const uint8_t seq = VFAT->sequenceNumber & 0x1F; - if (WITHIN(seq, 1, MAX_VFAT_ENTRIES)) { - // TODO: Store the filename checksum to verify if a long-filename-unaware system modified the file table. - n = (seq - 1) * (FILENAME_LENGTH); - LOOP_L_N(i, FILENAME_LENGTH) { - uint16_t utf16_ch = (i < 5) ? VFAT->name1[i] : (i < 11) ? VFAT->name2[i - 5] : VFAT->name3[i - 11]; - #if ENABLED(UTF_FILENAME_SUPPORT) - // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks - // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. - uint16_t idx = (n + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding - longFilename[idx] = utf16_ch & 0xFF; - longFilename[idx + 1] = (utf16_ch >> 8) & 0xFF; - #else - // Replace all multibyte characters to '_' - longFilename[n + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); - #endif + if (longFilename) { + // Fill the long filename if we have a long filename entry. + // Long filename entries are stored before the short filename. + if (DIR_IS_LONG_NAME(dir)) { + vfat_t *VFAT = (vfat_t*)dir; + // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 + if (VFAT->firstClusterLow == 0) { + const uint8_t seq = VFAT->sequenceNumber & 0x1F; + if (WITHIN(seq, 1, MAX_VFAT_ENTRIES)) { + n = (seq - 1) * (FILENAME_LENGTH); + if (n == 0) { + checksum = VFAT->checksum; + checksum_error = 0; + } + else if (checksum != VFAT->checksum) // orphan detected + checksum_error = 1; + + LOOP_L_N(i, FILENAME_LENGTH) { + const uint16_t utf16_ch = (i >= 11) ? VFAT->name3[i - 11] : (i >= 5) ? VFAT->name2[i - 5] : VFAT->name1[i]; + #if ENABLED(UTF_FILENAME_SUPPORT) + // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks + // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. + uint16_t idx = (n + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding + longFilename[idx] = utf16_ch & 0xFF; + longFilename[idx + 1] = (utf16_ch >> 8) & 0xFF; + #else + // Replace all multibyte characters to '_' + longFilename[n + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); + #endif + } + // If this VFAT entry is the last one, add a NUL terminator at the end of the string + if (VFAT->sequenceNumber & 0x40) + longFilename[(n + FILENAME_LENGTH) * LONG_FILENAME_CHARSIZE] = '\0'; } - // If this VFAT entry is the last one, add a NUL terminator at the end of the string - if (VFAT->sequenceNumber & 0x40) longFilename[(n + FILENAME_LENGTH) * LONG_FILENAME_CHARSIZE] = '\0'; } } + else { + if (!checksum_error && lfn_checksum(dir->name) != checksum) checksum_error = 1; // orphan detected + if (checksum_error) INVALIDATE_LONGNAME(); + } } // Post-process normal file or subdirectory longname, if any From 75b790376d1b20e0345efc2b8d2a58e9b201f9d3 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Sun, 4 Apr 2021 17:58:03 -0600 Subject: [PATCH 166/311] Touch UI Bed Mesh Screen refactor, enhancements (#21521) - Split mesh view and edit screen into two screens - The editor now live-updates the graphics - Added Touch UI mesh progress feedback to `G26` - Show positive / negative mesh values in different colors --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 8 +- Marlin/src/gcode/bedlevel/G26.cpp | 9 + .../lib/ftdi_eve_touch_ui/marlin_events.cpp | 4 +- ...{bed_mesh_screen.cpp => bed_mesh_base.cpp} | 243 +++--------------- .../ftdi_eve_touch_ui/screens/bed_mesh_base.h | 46 ++++ .../screens/bed_mesh_edit_screen.cpp | 186 ++++++++++++++ ...d_mesh_screen.h => bed_mesh_edit_screen.h} | 47 +--- .../screens/bed_mesh_view_screen.cpp | 172 +++++++++++++ .../screens/bed_mesh_view_screen.h | 48 ++++ .../screens/leveling_menu.cpp | 11 +- .../ftdi_eve_touch_ui/screens/screen_data.h | 3 +- .../lib/ftdi_eve_touch_ui/screens/screens.cpp | 3 +- .../lib/ftdi_eve_touch_ui/screens/screens.h | 7 +- Marlin/src/lcd/extui/ui_api.h | 12 +- 14 files changed, 535 insertions(+), 264 deletions(-) rename Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/{bed_mesh_screen.cpp => bed_mesh_base.cpp} (50%) create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.h create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp rename Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/{bed_mesh_screen.h => bed_mesh_edit_screen.h} (58%) create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.h diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 9153f369bd..361f3f1285 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -730,7 +730,7 @@ void unified_bed_leveling::shift_mesh_height() { uint8_t count = GRID_MAX_POINTS; mesh_index_pair best; - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_START)); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_START)); do { if (do_ubl_mesh_map) display_map(param.T_map_type); @@ -755,14 +755,14 @@ void unified_bed_leveling::shift_mesh_height() { : find_closest_mesh_point_of_type(INVALID, nearby, true); if (best.pos.x >= 0) { // mesh point found and is reachable by probe - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START)); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_POINT_START)); const float measured_z = probe.probe_at_point( best.meshpos(), stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity ); z_values[best.pos.x][best.pos.y] = measured_z; #if ENABLED(EXTENSIBLE_UI) - ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_FINISH); + ExtUI::onMeshUpdate(best.pos, ExtUI::G29_POINT_FINISH); ExtUI::onMeshUpdate(best.pos, measured_z); #endif } @@ -770,7 +770,7 @@ void unified_bed_leveling::shift_mesh_height() { } while (best.pos.x >= 0 && --count); - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_FINISH)); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_FINISH)); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW TERN_(HAS_LCD_MENU, ui.release()); diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index f3e9a78178..657f906c14 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -113,6 +113,10 @@ #include "../../module/temperature.h" #include "../../lcd/marlinui.h" +#if ENABLED(EXTENSIBLE_UI) + #include "../../lcd/extui/ui_api.h" +#endif + #if ENABLED(UBL_HILBERT_CURVE) #include "../../feature/bedlevel/hilbert_curve.h" #endif @@ -725,11 +729,13 @@ void GcodeSuite::G26() { #endif // !ARC_SUPPORT mesh_index_pair location; + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_START)); do { // Find the nearest confluence location = g26.find_closest_circle_to_print(g26.continue_with_closest ? xy_pos_t(current_position) : g26.xy_pos); if (location.valid()) { + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_POINT_START)); const xy_pos_t circle = _GET_MESH_POS(location.pos); // If this mesh location is outside the printable radius, skip it. @@ -845,6 +851,8 @@ void GcodeSuite::G26() { g26.connect_neighbor_with_line(location.pos, 1, 0); g26.connect_neighbor_with_line(location.pos, 0, -1); g26.connect_neighbor_with_line(location.pos, 0, 1); + planner.synchronize(); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_POINT_FINISH)); if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; } @@ -854,6 +862,7 @@ void GcodeSuite::G26() { LEAVE: ui.set_status_P(GET_TEXT(MSG_G26_LEAVING), -1); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, ExtUI::G26_FINISH)); g26.retract_filament(destination); destination.z = Z_CLEARANCE_BETWEEN_PROBES; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp index 10c873d19c..8193ec24d4 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp @@ -141,11 +141,11 @@ namespace ExtUI { void onMeshLevelingStart() {} void onMeshUpdate(const int8_t x, const int8_t y, const_float_t val) { - BedMeshScreen::onMeshUpdate(x, y, val); + BedMeshViewScreen::onMeshUpdate(x, y, val); } void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { - BedMeshScreen::onMeshUpdate(x, y, state); + BedMeshViewScreen::onMeshUpdate(x, y, state); } #endif 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_base.cpp similarity index 50% rename from Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp rename to Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp index cba27931f2..e83f09f045 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_base.cpp @@ -1,6 +1,6 @@ -/*********************** - * bed_mesh_screen.cpp * - ***********************/ +/********************* + * bed_mesh_base.cpp * + *********************/ /**************************************************************************** * Written By Marcio Teixeira 2020 * @@ -21,43 +21,17 @@ #include "../config.h" #include "screens.h" -#include "screen_data.h" -#ifdef FTDI_BED_MESH_SCREEN +#ifdef FTDI_BED_MESH_BASE using namespace FTDI; -using namespace Theme; -using namespace ExtUI; -constexpr static BedMeshScreenData &mydata = screen_data.BedMeshScreen; -constexpr static float gaugeThickness = 0.25; - -#if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_COLS 3 - #define GRID_ROWS 10 - - #define MESH_POS BTN_POS(1, 2), BTN_SIZE(3,5) - #define MESSAGE_POS BTN_POS(1, 7), BTN_SIZE(3,1) - #define Z_LABEL_POS BTN_POS(1, 8), BTN_SIZE(1,1) - #define Z_VALUE_POS BTN_POS(2, 8), BTN_SIZE(2,1) - #define OKAY_POS BTN_POS(1,10), BTN_SIZE(3,1) -#else - #define GRID_COLS 5 - #define GRID_ROWS 5 - - #define MESH_POS BTN_POS(1,1), BTN_SIZE(3,5) - #define MESSAGE_POS BTN_POS(4,1), BTN_SIZE(2,1) - #define Z_LABEL_POS BTN_POS(4,2), BTN_SIZE(2,1) - #define Z_VALUE_POS BTN_POS(4,3), BTN_SIZE(2,1) - #define OKAY_POS BTN_POS(4,5), BTN_SIZE(2,1) -#endif - -void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::bed_mesh_t data, uint8_t opts, float autoscale_max) { +void BedMeshBase::_drawMesh(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t opts, float autoscale_max, uint8_t highlightedTag, mesh_getter_ptr func, void *data) { constexpr uint8_t rows = GRID_MAX_POINTS_Y; constexpr uint8_t cols = GRID_MAX_POINTS_X; - #define VALUE(X,Y) (data ? data[X][Y] : 0) - #define ISVAL(X,Y) (data ? !isnan(VALUE(X,Y)) : true) + #define VALUE(X,Y) (func ? func(X,Y,data) : 0) + #define ISVAL(X,Y) (func ? !isnan(VALUE(X,Y)) : true) #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0) // Compute the mean, min and max for the points @@ -67,7 +41,7 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI:: float val_min = INFINITY; uint8_t val_cnt = 0; - if (data && (opts & USE_AUTOSCALE)) { + if (opts & USE_AUTOSCALE) { for (uint8_t y = 0; y < rows; y++) { for (uint8_t x = 0; x < cols; x++) { if (ISVAL(x,y)) { @@ -140,7 +114,6 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI:: const uint16_t basePointSize = min(w,h) / max(cols,rows); - CommandProcessor cmd; cmd.cmd(SAVE_CONTEXT()) .cmd(TAG_MASK(false)) .cmd(SAVE_CONTEXT()); @@ -167,10 +140,14 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI:: for (uint8_t x = 0; x < cols; x++) { if (ISVAL(x,y)) { if (opts & USE_COLORS) { - const float val_dev = VALUE(x, y) - val_mean; - const uint8_t neg_byte = sq(val_dev) / (val_dev < 0 ? sq_min : sq_max) * 0xFF; - const uint8_t pos_byte = 255 - neg_byte; - cmd.cmd(COLOR_RGB(pos_byte, pos_byte, 0xFF)); + const float val_dev = sq(VALUE(x, y) - val_mean); + uint8_t r = 0, b = 0; + //*(VALUE(x, y) < 0 ? &r : &b) = val_dev / sq_min * 0xFF; + if (VALUE(x, y) < 0) + r = val_dev / sq_min * 0xFF; + else + b = val_dev / sq_max * 0xFF; + cmd.cmd(COLOR_RGB(0xFF - b, 0xFF - b - r, 0xFF - r)); } cmd.cmd(VERTEX2F(TRANSFORM(x, y, HEIGHT(x, y)))); } @@ -198,7 +175,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 = mydata.highlightedTag; + const uint8_t tag = highlightedTag; xy_uint8_t pt; if (tagToPoint(tag, pt)) { cmd.cmd(COLOR_A(128)) @@ -211,184 +188,32 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI:: cmd.cmd(RESTORE_CONTEXT()); } -uint8_t BedMeshScreen::pointToTag(uint8_t x, uint8_t y) { - return y * (GRID_MAX_POINTS_X) + x + 10; +uint8_t BedMeshBase::pointToTag(uint8_t x, uint8_t y) { + return x >= 0 && x < GRID_MAX_POINTS_X && y >= 0 && y < GRID_MAX_POINTS_Y ? y * (GRID_MAX_POINTS_X) + x + 10 : 0; } -bool BedMeshScreen::tagToPoint(uint8_t tag, xy_uint8_t &pt) { +bool BedMeshBase::tagToPoint(uint8_t tag, xy_uint8_t &pt) { if (tag < 10) return false; pt.x = (tag - 10) % (GRID_MAX_POINTS_X); pt.y = (tag - 10) / (GRID_MAX_POINTS_X); return true; } -void BedMeshScreen::onEntry() { - mydata.allowEditing = true; - mydata.highlightedTag = 0; - mydata.zAdjustment = 0; - mydata.count = GRID_MAX_POINTS; - mydata.message = mydata.MSG_NONE; - BaseScreen::onEntry(); +void BedMeshBase::drawMeshBackground(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h) { + cmd.cmd(COLOR_RGB(Theme::bed_mesh_shadow_rgb)); + _drawMesh(cmd, x, y, w, h, USE_POINTS | USE_TAGS, 0.1, 0, nullptr, nullptr); } -float BedMeshScreen::getHighlightedValue(bool nanAsZero) { - xy_uint8_t pt; - if (tagToPoint(mydata.highlightedTag, pt)) { - const float val = ExtUI::getMeshPoint(pt); - return (isnan(val) && nanAsZero) ? 0 : val; - } - return NAN; +void BedMeshBase::drawMeshForeground(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h, mesh_getter_ptr func, void *data, uint8_t highlightedTag, float progress) { + constexpr float autoscale_max_amplitude = 0.03; + + cmd.cmd(COLOR_RGB(Theme::bed_mesh_lines_rgb)); + _drawMesh(cmd, x, y, w, h, + USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (progress > 0.95 ? USE_COLORS : 0), + autoscale_max_amplitude * progress, + highlightedTag, + func, data + ); } -void BedMeshScreen::setHighlightedValue(float value) { - xy_uint8_t pt; - if (tagToPoint(mydata.highlightedTag, pt)) - ExtUI::setMeshPoint(pt, value); -} - -void BedMeshScreen::moveToHighlightedValue() { - xy_uint8_t pt; - if (tagToPoint(mydata.highlightedTag, pt)) - ExtUI::moveToMeshPoint(pt, gaugeThickness + mydata.zAdjustment); -} - -void BedMeshScreen::adjustHighlightedValue(float increment) { - mydata.zAdjustment += increment; - moveToHighlightedValue(); -} - -void BedMeshScreen::saveAdjustedHighlightedValue() { - if (mydata.zAdjustment) { - BedMeshScreen::setHighlightedValue(BedMeshScreen::getHighlightedValue(true) + mydata.zAdjustment); - mydata.zAdjustment = 0; - } -} - -void BedMeshScreen::changeHighlightedValue(uint8_t tag) { - if (mydata.allowEditing) saveAdjustedHighlightedValue(); - mydata.highlightedTag = tag; - if (mydata.allowEditing) moveToHighlightedValue(); -} - -void BedMeshScreen::drawHighlightedPointValue() { - CommandProcessor cmd; - cmd.font(Theme::font_medium) - .colors(normal_btn) - .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z)) - .font(font_small); - - if (mydata.allowEditing) - draw_adjuster(cmd, Z_VALUE_POS, 2, getHighlightedValue(true) + mydata.zAdjustment, GET_TEXT_F(MSG_UNITS_MM), 4, 3); - else - draw_adjuster_value(cmd, Z_VALUE_POS, getHighlightedValue(true) + mydata.zAdjustment, GET_TEXT_F(MSG_UNITS_MM), 4, 3); - - cmd.colors(action_btn) - .tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY)) - .tag(0); - - 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; - } -} - -void BedMeshScreen::onRedraw(draw_mode_t what) { - #define _INSET_POS(x,y,w,h) x + min(w,h)/10, y + min(w,h)/10, w - min(w,h)/5, h - min(w,h)/5 - #define INSET_POS(pos) _INSET_POS(pos) - - if (what & BACKGROUND) { - CommandProcessor cmd; - cmd.cmd(CLEAR_COLOR_RGB(bg_color)) - .cmd(CLEAR(true,true,true)); - - // Draw the shadow and tags - cmd.cmd(COLOR_RGB(Theme::bed_mesh_shadow_rgb)); - BedMeshScreen::drawMesh(INSET_POS(MESH_POS), nullptr, USE_POINTS | USE_TAGS); - cmd.cmd(COLOR_RGB(bg_text_enabled)); - } - - if (what & FOREGROUND) { - constexpr float autoscale_max_amplitude = 0.03; - const bool gotAllPoints = mydata.count >= GRID_MAX_POINTS; - if (gotAllPoints) { - drawHighlightedPointValue(); - } - CommandProcessor cmd; - cmd.cmd(COLOR_RGB(Theme::bed_mesh_lines_rgb)); - 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 - ); - } -} - -bool BedMeshScreen::onTouchEnd(uint8_t tag) { - constexpr float increment = 0.01; - switch (tag) { - case 1: - saveAdjustedHighlightedValue(); - injectCommands_P(PSTR("G29 S1")); - GOTO_PREVIOUS(); - return true; - case 2: adjustHighlightedValue(-increment); break; - case 3: adjustHighlightedValue( increment); break; - default: - if (tag >= 10) - changeHighlightedValue(tag); - else - return false; - } - return true; -} - -void BedMeshScreen::onMeshUpdate(const int8_t, const int8_t, const float) { - if (AT_SCREEN(BedMeshScreen)) - onRefresh(); -} - -void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { - switch (state) { - case ExtUI::MESH_START: - mydata.allowEditing = false; - mydata.count = 0; - mydata.message = mydata.MSG_NONE; - break; - case ExtUI::MESH_FINISH: - if (mydata.count == GRID_MAX_POINTS && ExtUI::getMeshValid()) - mydata.message = mydata.MSG_MESH_COMPLETE; - else - mydata.message = mydata.MSG_MESH_INCOMPLETE; - mydata.count = GRID_MAX_POINTS; - break; - case ExtUI::PROBE_START: - mydata.highlightedTag = pointToTag(x, y); - break; - case ExtUI::PROBE_FINISH: - mydata.count++; - break; - } - BedMeshScreen::onMeshUpdate(x, y, 0); -} - -void BedMeshScreen::startMeshProbe() { - GOTO_SCREEN(BedMeshScreen); - mydata.allowEditing = false; - mydata.count = 0; - injectCommands_P(PSTR(BED_LEVELING_COMMANDS)); -} - -void BedMeshScreen::showMesh() { - GOTO_SCREEN(BedMeshScreen); - mydata.allowEditing = false; -} - -void BedMeshScreen::showMeshEditor() { - SpinnerDialogBox::enqueueAndWait_P(ExtUI::isMachineHomed() ? F("M420 S1") : F("G28\nM420 S1")); - // After the spinner, go to this screen. - current_screen.forget(); - PUSH_SCREEN(BedMeshScreen); -} - -#endif // FTDI_BED_MESH_SCREEN +#endif // FTDI_BED_MESH_BASE diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.h new file mode 100644 index 0000000000..7cc92793fe --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.h @@ -0,0 +1,46 @@ +/******************* + * bed_mesh_base.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_BASE + +class BedMeshBase : public BaseScreen { + protected: + typedef float (*mesh_getter_ptr)(uint8_t x, uint8_t y, void *data); + + private: + enum MeshOpts { + USE_POINTS = 0x01, + USE_COLORS = 0x02, + USE_TAGS = 0x04, + USE_HIGHLIGHT = 0x08, + USE_AUTOSCALE = 0x10 + }; + + static void _drawMesh(CommandProcessor &, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t opts, float autoscale_max, uint8_t highlightedTag, mesh_getter_ptr func, void *data); + + protected: + static void drawMeshForeground(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h, mesh_getter_ptr func, void *data, uint8_t highlightedTag = 0, float progress = 1.0); + static void drawMeshBackground(CommandProcessor &cmd, int16_t x, int16_t y, int16_t w, int16_t h); + static uint8_t pointToTag(uint8_t x, uint8_t y); + static bool tagToPoint(uint8_t tag, xy_uint8_t &pt); +}; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp new file mode 100644 index 0000000000..117ac0e452 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp @@ -0,0 +1,186 @@ +/**************************** + * bed_mesh_edit_screen.cpp * + ****************************/ + +/**************************************************************************** + * 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: . * + ****************************************************************************/ + +#include "../config.h" +#include "screens.h" +#include "screen_data.h" + +#ifdef FTDI_BED_MESH_EDIT_SCREEN + +using namespace FTDI; +using namespace Theme; +using namespace ExtUI; + +constexpr static BedMeshEditScreenData &mydata = screen_data.BedMeshEditScreen; +constexpr static float gaugeThickness = 0.25; + +#if ENABLED(TOUCH_UI_PORTRAIT) + #define GRID_COLS 3 + #define GRID_ROWS 10 + + #define MESH_POS BTN_POS(1, 2), BTN_SIZE(3,5) + #define MESSAGE_POS BTN_POS(1, 7), BTN_SIZE(3,1) + #define Z_LABEL_POS BTN_POS(1, 8), BTN_SIZE(1,1) + #define Z_VALUE_POS BTN_POS(2, 8), BTN_SIZE(2,1) + #define BACK_POS BTN_POS(1,10), BTN_SIZE(2,1) + #define SAVE_POS BTN_POS(3,10), BTN_SIZE(1,1) +#else + #define GRID_COLS 5 + #define GRID_ROWS 5 + + #define MESH_POS BTN_POS(1,1), BTN_SIZE(3,5) + #define MESSAGE_POS BTN_POS(4,1), BTN_SIZE(2,1) + #define Z_LABEL_POS BTN_POS(4,2), BTN_SIZE(2,1) + #define Z_VALUE_POS BTN_POS(4,3), BTN_SIZE(2,1) + #define BACK_POS BTN_POS(4,5), BTN_SIZE(1,1) + #define SAVE_POS BTN_POS(5,5), BTN_SIZE(1,1) +#endif + +static float meshGetter(uint8_t x, uint8_t y, void*) { + xy_uint8_t pos; + pos.x = x; + pos.y = y; + return ExtUI::getMeshPoint(pos) + (mydata.highlight.x != -1 && mydata.highlight == pos ? mydata.zAdjustment : 0); +} + +void BedMeshEditScreen::onEntry() { + mydata.needSave = false; + mydata.highlight.x = -1; + mydata.zAdjustment = 0; + BaseScreen::onEntry(); +} + +float BedMeshEditScreen::getHighlightedValue() { + const float val = ExtUI::getMeshPoint(mydata.highlight); + return (isnan(val) ? 0 : val) + mydata.zAdjustment; +} + +void BedMeshEditScreen::setHighlightedValue(float value) { + ExtUI::setMeshPoint(mydata.highlight, value); +} + +void BedMeshEditScreen::moveToHighlightedValue() { + if (ExtUI::getMeshValid()) { + ExtUI::setLevelingActive(true); + ExtUI::moveToMeshPoint(mydata.highlight, gaugeThickness + mydata.zAdjustment); + } +} + +void BedMeshEditScreen::adjustHighlightedValue(float increment) { + if(mydata.highlight.x != -1) { + mydata.zAdjustment += increment; + moveToHighlightedValue(); + mydata.needSave = true; + } +} + +void BedMeshEditScreen::saveAdjustedHighlightedValue() { + if (mydata.zAdjustment && mydata.highlight.x != -1) { + setHighlightedValue(getHighlightedValue()); + mydata.zAdjustment = 0; + } +} + +bool BedMeshEditScreen::changeHighlightedValue(uint8_t tag) { + saveAdjustedHighlightedValue(); + if (tagToPoint(tag, mydata.highlight)) { + moveToHighlightedValue(); + return true; + } + return false; +} + +void BedMeshEditScreen::drawHighlightedPointValue() { + CommandProcessor cmd; + cmd.font(Theme::font_medium) + .colors(normal_btn) + .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z)) + .font(font_small); + if(mydata.highlight.x != -1) + draw_adjuster(cmd, Z_VALUE_POS, 3, getHighlightedValue(), GET_TEXT_F(MSG_UNITS_MM), 4, 3); + cmd.colors(mydata.needSave ? normal_btn : action_btn) + .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_BACK)) + .colors(mydata.needSave ? action_btn : normal_btn) + .enabled(mydata.needSave) + .tag(2).button(SAVE_POS, GET_TEXT_F(MSG_TOUCHMI_SAVE)); +} + +void BedMeshEditScreen::onRedraw(draw_mode_t what) { + #define _INSET_POS(x,y,w,h) x + min(w,h)/10, y + min(w,h)/10, w - min(w,h)/5, h - min(w,h)/5 + #define INSET_POS(pos) _INSET_POS(pos) + + CommandProcessor cmd; + + if (what & BACKGROUND) { + cmd.cmd(CLEAR_COLOR_RGB(bg_color)) + .cmd(CLEAR(true,true,true)); + drawMeshBackground(cmd, INSET_POS(MESH_POS)); + } + + if (what & FOREGROUND) { + drawHighlightedPointValue(); + drawMeshForeground(cmd, INSET_POS(MESH_POS), meshGetter, nullptr, pointToTag(mydata.highlight.x,mydata.highlight.y)); + } +} + +bool BedMeshEditScreen::onTouchHeld(uint8_t tag) { + constexpr float increment = 0.01; + switch (tag) { + case 3: adjustHighlightedValue(-increment); return true; + case 4: adjustHighlightedValue( increment); return true; + } + return false; +} + +bool BedMeshEditScreen::onTouchEnd(uint8_t tag) { + switch (tag) { + case 1: + // On Cancel, reload saved mesh, discarding changes + GOTO_PREVIOUS(); + injectCommands_P(PSTR("G29 L1")); + return true; + case 2: + saveAdjustedHighlightedValue(); + injectCommands_P(PSTR("G29 S1")); + mydata.needSave = false; + return true; + case 3: + case 4: + return onTouchHeld(tag); + default: return changeHighlightedValue(tag); + } + return true; +} + +void BedMeshEditScreen::show() { + // On entry, home if needed and save current mesh + if (!ExtUI::isMachineHomed()) { + SpinnerDialogBox::enqueueAndWait_P(F("G28\nG29 S1")); + // After the spinner, go to this screen. + current_screen.forget(); + PUSH_SCREEN(BedMeshEditScreen); + } else { + injectCommands_P(PSTR("G29 S1")); + GOTO_SCREEN(BedMeshEditScreen); + } +} + +#endif // FTDI_BED_MESH_EDIT_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_edit_screen.h similarity index 58% rename from Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.h rename to Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h index 21a7a73729..62121941b1 100644 --- 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_edit_screen.h @@ -1,6 +1,6 @@ -/********************* - * bed_mesh_screen.h * - *********************/ +/************************** + * bed_mesh_edit_screen.h * + *************************/ /**************************************************************************** * Written By Marcio Teixeira 2020 * @@ -21,49 +21,28 @@ #pragma once -#define FTDI_BED_MESH_SCREEN -#define FTDI_BED_MESH_SCREEN_CLASS BedMeshScreen +#define FTDI_BED_MESH_EDIT_SCREEN +#define FTDI_BED_MESH_EDIT_SCREEN_CLASS BedMeshEditScreen -struct BedMeshScreenData { - enum : uint8_t { - MSG_NONE, - MSG_MESH_COMPLETE, - MSG_MESH_INCOMPLETE - } message; - uint8_t count; - uint8_t highlightedTag; +struct BedMeshEditScreenData { + bool needSave; + xy_uint8_t highlight; float zAdjustment; - bool allowEditing; }; -class BedMeshScreen : public BaseScreen, public CachedScreen { +class BedMeshEditScreen : public BedMeshBase, 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, xy_uint8_t &pt); - static float getHighlightedValue(bool nanAsZero); + static float getHighlightedValue(); static void setHighlightedValue(float value); static void moveToHighlightedValue(); static void adjustHighlightedValue(float increment); static void saveAdjustedHighlightedValue(); - static void changeHighlightedValue(uint8_t tag); + static bool changeHighlightedValue(uint8_t tag); 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 onTouchHeld(uint8_t tag); static bool onTouchEnd(uint8_t tag); - - static void startMeshProbe(); - static void showMesh(); - static void showMeshEditor(); + static void show(); }; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp new file mode 100644 index 0000000000..8321bd8bb5 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp @@ -0,0 +1,172 @@ +/**************************** + * bed_mesh_view_screen.cpp * + ****************************/ + +/**************************************************************************** + * 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: . * + ****************************************************************************/ + +#include "../config.h" +#include "screens.h" +#include "screen_data.h" + +#ifdef FTDI_BED_MESH_VIEW_SCREEN + +using namespace FTDI; +using namespace Theme; +using namespace ExtUI; + +constexpr static BedMeshViewScreenData &mydata = screen_data.BedMeshViewScreen; +constexpr static float gaugeThickness = 0.25; + +#if ENABLED(TOUCH_UI_PORTRAIT) + #define GRID_COLS 3 + #define GRID_ROWS 10 + + #define MESH_POS BTN_POS(1, 2), BTN_SIZE(3,5) + #define MESSAGE_POS BTN_POS(1, 7), BTN_SIZE(3,1) + #define Z_LABEL_POS BTN_POS(1, 8), BTN_SIZE(1,1) + #define Z_VALUE_POS BTN_POS(2, 8), BTN_SIZE(2,1) + #define OKAY_POS BTN_POS(1,10), BTN_SIZE(3,1) +#else + #define GRID_COLS 5 + #define GRID_ROWS 5 + + #define MESH_POS BTN_POS(1,1), BTN_SIZE(3,5) + #define MESSAGE_POS BTN_POS(4,1), BTN_SIZE(2,1) + #define Z_LABEL_POS BTN_POS(4,2), BTN_SIZE(2,1) + #define Z_VALUE_POS BTN_POS(4,3), BTN_SIZE(2,1) + #define OKAY_POS BTN_POS(4,5), BTN_SIZE(2,1) +#endif + +static float meshGetter(uint8_t x, uint8_t y, void*) { + xy_uint8_t pos; + pos.x = x; + pos.y = y; + return ExtUI::getMeshPoint(pos); +} + +void BedMeshViewScreen::onEntry() { + mydata.highlight.x = -1; + mydata.count = GRID_MAX_POINTS; + mydata.message = nullptr; + BaseScreen::onEntry(); +} + +void BedMeshViewScreen::drawHighlightedPointValue() { + CommandProcessor cmd; + cmd.font(Theme::font_medium) + .colors(normal_btn) + .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z)) + .font(font_small); + + if(mydata.highlight.x != -1) + draw_adjuster_value(cmd, Z_VALUE_POS, ExtUI::getMeshPoint(mydata.highlight), GET_TEXT_F(MSG_UNITS_MM), 4, 3); + + cmd.colors(action_btn) + .tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY)) + .tag(0); + + if(mydata.message) cmd.text(MESSAGE_POS, mydata.message); +} + +void BedMeshViewScreen::onRedraw(draw_mode_t what) { + #define _INSET_POS(x,y,w,h) x + min(w,h)/10, y + min(w,h)/10, w - min(w,h)/5, h - min(w,h)/5 + #define INSET_POS(pos) _INSET_POS(pos) + + CommandProcessor cmd; + + if (what & BACKGROUND) { + cmd.cmd(CLEAR_COLOR_RGB(bg_color)) + .cmd(CLEAR(true,true,true)); + drawMeshBackground(cmd, INSET_POS(MESH_POS)); + } + + if (what & FOREGROUND) { + const float progress = sq(float(mydata.count) / GRID_MAX_POINTS); + if (progress >= 1.0) + drawHighlightedPointValue(); + drawMeshForeground(cmd, INSET_POS(MESH_POS), meshGetter, nullptr, pointToTag(mydata.highlight.x, mydata.highlight.y), progress); + } +} + +bool BedMeshViewScreen::onTouchEnd(uint8_t tag) { + switch (tag) { + case 1: GOTO_PREVIOUS(); return true; + default: return tagToPoint(tag, mydata.highlight); + } + return true; +} + +void BedMeshViewScreen::onMeshUpdate(const int8_t, const int8_t, const float) { + if (AT_SCREEN(BedMeshViewScreen)) { + onRefresh(); + ExtUI::yield(); + } +} + +void BedMeshViewScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { + switch (state) { + case ExtUI::G29_START: + mydata.message = nullptr; + mydata.count = 0; + break; + case ExtUI::G29_FINISH: + if (mydata.count == GRID_MAX_POINTS && ExtUI::getMeshValid()) + mydata.message = GET_TEXT_F(MSG_BED_MAPPING_DONE); + else + mydata.message = GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE); + mydata.count = GRID_MAX_POINTS; + break; + case ExtUI::G26_START: + GOTO_SCREEN(BedMeshViewScreen); + mydata.message = nullptr; + mydata.count = 0; + break; + case ExtUI::G26_FINISH: + GOTO_SCREEN(StatusScreen); + break; + case ExtUI::G29_POINT_START: + case ExtUI::G26_POINT_START: + mydata.highlight.x = x; + mydata.highlight.y = y; + break; + case ExtUI::G29_POINT_FINISH: + case ExtUI::G26_POINT_FINISH: + mydata.count++; + break; + } + BedMeshViewScreen::onMeshUpdate(x, y, 0); +} + +void BedMeshViewScreen::doProbe() { + GOTO_SCREEN(BedMeshViewScreen); + mydata.count = 0; + injectCommands_P(PSTR(BED_LEVELING_COMMANDS)); +} + +void BedMeshViewScreen::doMeshValidation() { + mydata.count = 0; + GOTO_SCREEN(StatusScreen); + injectCommands_P(PSTR("G28 O\nM117 Heating...\nG26 R X0 Y0")); +} + +void BedMeshViewScreen::show() { + injectCommands_P(PSTR("G29 L1")); + GOTO_SCREEN(BedMeshViewScreen); +} + +#endif // FTDI_BED_MESH_VIEW_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.h new file mode 100644 index 0000000000..0bb88f7f96 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.h @@ -0,0 +1,48 @@ +/************************** + * bed_mesh_view_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_VIEW_SCREEN +#define FTDI_BED_MESH_VIEW_SCREEN_CLASS BedMeshViewScreen + +struct BedMeshViewScreenData { + progmem_str message; + uint8_t count; + xy_uint8_t highlight; +}; + +class BedMeshViewScreen : public BedMeshBase, public CachedScreen { + private: + static float getHighlightedValue(); + static bool changeHighlightedValue(uint8_t tag); + static void drawHighlightedPointValue(); + 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 onTouchEnd(uint8_t tag); + + static void doProbe(); + static void doMeshValidation(); + static void show(); +}; 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 7a540e1311..ffdd69b2dd 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 @@ -111,20 +111,17 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) { #define BED_LEVELING_COMMANDS "G29" #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - BedMeshScreen::startMeshProbe(); + BedMeshViewScreen::doProbe(); #else SpinnerDialogBox::enqueueAndWait_P(F(BED_LEVELING_COMMANDS)); #endif break; #if ENABLED(AUTO_BED_LEVELING_UBL) - case 4: BedMeshScreen::showMesh(); break; - case 5: BedMeshScreen::showMeshEditor(); break; + case 4: BedMeshViewScreen::show(); break; + case 5: BedMeshEditScreen::show(); break; #endif #if ENABLED(G26_MESH_VALIDATION) - case 6: - GOTO_SCREEN(StatusScreen); - injectCommands_P(PSTR("M117 Printing Test Pattern\nG28 O\nG26 R")); - break; + case 6: BedMeshViewScreen::doMeshValidation(); break; #endif #if ENABLED(BLTOUCH) case 7: injectCommands_P(PSTR("M280 P0 S60")); break; 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 06368f0ce7..a5ef7155f9 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 @@ -55,7 +55,8 @@ union screen_data_t { 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_BED_MESH_VIEW_SCREEN) + DECL_DATA_IF_INCLUDED(FTDI_BED_MESH_EDIT_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_STRESS_TEST_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_COCOA_PREHEAT_SCREEN) DECL_DATA_IF_INCLUDED(FTDI_COCOA_LOAD_CHOCOLATE_SCREEN) 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 889ed734cc..f115aecbc7 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 @@ -75,7 +75,8 @@ SCREEN_TABLE { 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_BED_MESH_VIEW_SCREEN) + DECL_SCREEN_IF_INCLUDED(FTDI_BED_MESH_EDIT_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) 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 7aca5800e1..14b8197fbf 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 @@ -61,7 +61,8 @@ enum { ZOFFSET_SCREEN_CACHE, #endif #if HAS_MESH - BED_MESH_SCREEN_CACHE, + BED_MESH_VIEW_SCREEN_CACHE, + BED_MESH_EDIT_SCREEN_CACHE, #endif #endif #if ENABLED(BABYSTEPPING) @@ -206,7 +207,9 @@ enum { #include "z_offset_screen.h" #endif #if HAS_MESH - #include "bed_mesh_screen.h" + #include "bed_mesh_base.h" + #include "bed_mesh_view_screen.h" + #include "bed_mesh_edit_screen.h" #endif #endif diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 24bf284648..c59fe0bd17 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -168,10 +168,14 @@ namespace ExtUI { inline void onMeshUpdate(const xy_int8_t &pos, const_float_t zval) { onMeshUpdate(pos.x, pos.y, zval); } typedef enum : uint8_t { - MESH_START, // Prior to start of probe - MESH_FINISH, // Following probe of all points - PROBE_START, // Beginning probe of grid location - PROBE_FINISH // Finished probe of grid location + G29_START, // Prior to start of probe + G29_FINISH, // Following probe of all points + G29_POINT_START, // Beginning probe of grid location + G29_POINT_FINISH, // Finished probe of grid location + G26_START, + G26_FINISH, + G26_POINT_START, + G26_POINT_FINISH } probe_state_t; void onMeshUpdate(const int8_t xpos, const int8_t ypos, probe_state_t state); inline void onMeshUpdate(const xy_int8_t &pos, probe_state_t state) { onMeshUpdate(pos.x, pos.y, state); } From 916574932167a1bdf76cc90d3e75b69ea87985f2 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 5 Apr 2021 00:36:21 +0000 Subject: [PATCH 167/311] [cron] Bump distribution date (2021-04-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 dc143277d2..d924fc665e 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-04-04" + #define STRING_DISTRIBUTION_DATE "2021-04-05" #endif /** From 98d6c751d3484b1a3d30cefaa692b4f993d81abd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 2 Apr 2021 14:30:13 -0500 Subject: [PATCH 168/311] Fix CardReader string args --- Marlin/src/sd/cardreader.cpp | 6 +++--- Marlin/src/sd/cardreader.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 225f7d9a95..c9668bf8a8 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -515,7 +515,7 @@ void CardReader::endFilePrint(TERN_(SD_RESORT, const bool re_sort/*=false*/)) { TERN_(SD_RESORT, if (re_sort) presort()); } -void CardReader::openLogFile(char * const path) { +void CardReader::openLogFile(const char * const path) { flag.logging = DISABLED(SDCARD_READONLY); IF_DISABLED(SDCARD_READONLY, openFileWrite(path)); } @@ -634,7 +634,7 @@ inline void echo_write_to_file(const char * const fname) { // // Open a file by DOS path for write // -void CardReader::openFileWrite(char * const path) { +void CardReader::openFileWrite(const char * const path) { if (!isMounted()) return; announceOpen(2, path); @@ -722,7 +722,7 @@ void CardReader::report_status() { SERIAL_ECHOLNPGM(STR_SD_NOT_PRINTING); } -void CardReader::write_command(char * const buf) { +void CardReader::write_command(const char * const buf) { char *begin = buf; char *npos = nullptr; char *end = buf + strlen(buf) - 1; diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 9528c4ac28..cf876ce9c7 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -91,8 +91,8 @@ public: static void manage_media(); // SD Card Logging - static void openLogFile(char * const path); - static void write_command(char * const buf); + static void openLogFile(const char * const path); + static void write_command(const char * const buf); #if DISABLED(NO_SD_AUTOSTART) // Auto-Start auto#.g file handling static uint8_t autofile_index; // Next auto#.g index to run, plus one. Ignored by autofile_check when zero. @@ -103,7 +103,7 @@ public: // Basic file ops static void openFileRead(char * const path, const uint8_t subcall=0); - static void openFileWrite(char * const path); + static void openFileWrite(const char * const path); static void closefile(const bool store_location=false); static bool fileExists(const char * const name); static void removeFile(const char * const name); From e3116eed2e488543766cd61e4658363a0d2bd34f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 5 Apr 2021 15:34:51 -0500 Subject: [PATCH 169/311] write_command changes input --- Marlin/src/sd/cardreader.cpp | 8 ++++---- Marlin/src/sd/cardreader.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index c9668bf8a8..f0797d6538 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -722,10 +722,10 @@ void CardReader::report_status() { SERIAL_ECHOLNPGM(STR_SD_NOT_PRINTING); } -void CardReader::write_command(const char * const buf) { - char *begin = buf; - char *npos = nullptr; - char *end = buf + strlen(buf) - 1; +void CardReader::write_command(char * const buf) { + char *begin = buf, + *npos = nullptr, + *end = buf + strlen(buf) - 1; file.writeError = false; if ((npos = strchr(buf, 'N'))) { diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index cf876ce9c7..482fb1c5cc 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -92,7 +92,7 @@ public: // SD Card Logging static void openLogFile(const char * const path); - static void write_command(const char * const buf); + static void write_command(char * const buf); #if DISABLED(NO_SD_AUTOSTART) // Auto-Start auto#.g file handling static uint8_t autofile_index; // Next auto#.g index to run, plus one. Ignored by autofile_check when zero. From 993609b5aae9145d49f42b99de6330c379debbe9 Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Mon, 5 Apr 2021 16:34:31 -0500 Subject: [PATCH 170/311] Make DELAY_NS round up on AVR (#21546) --- Marlin/src/HAL/shared/Delay.h | 35 +++++++++++++++++-- .../dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp | 2 +- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Marlin/src/HAL/shared/Delay.h b/Marlin/src/HAL/shared/Delay.h index dc1f158b44..f7e01ad25c 100644 --- a/Marlin/src/HAL/shared/Delay.h +++ b/Marlin/src/HAL/shared/Delay.h @@ -150,8 +150,37 @@ void calibrate_delay_loop(); #endif -// Delay in nanoseconds -#define DELAY_NS(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL) / 1000UL) - +/************************************************************** + * Delay in nanoseconds. Requires the F_CPU macro. + * These macros follow avr-libc delay conventions. + * + * For AVR there are three possible operation modes, due to its + * slower clock speeds and thus coarser delay resolution. For + * example, when F_CPU = 16000000 the resolution is 62.5ns. + * + * Round up (default) + * Round up the delay according to the CPU clock resolution. + * e.g., 100 will give a delay of 2 cycles (125ns). + * + * Round down (DELAY_NS_ROUND_DOWN) + * Round down the delay according to the CPU clock resolution. + * e.g., 100 will be rounded down to 1 cycle (62.5ns). + * + * Nearest (DELAY_NS_ROUND_CLOSEST) + * Round the delay to the nearest number of clock cycles. + * e.g., 165 will be rounded up to 3 cycles (187.5ns) because + * it's closer to the requested delay than 2 cycle (125ns). + */ +#ifndef __AVR__ + #undef DELAY_NS_ROUND_DOWN + #undef DELAY_NS_ROUND_CLOSEST +#endif +#if ENABLED(DELAY_NS_ROUND_DOWN) + #define DELAY_NS(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL) / 1000UL) // floor +#elif ENABLED(DELAY_NS_ROUND_CLOSEST) + #define DELAY_NS(x) DELAY_CYCLES(((x) * ((F_CPU) / 1000000UL) + 500) / 1000UL) // round +#else + #define DELAY_NS(x) DELAY_CYCLES(((x) * ((F_CPU) / 1000000UL) + 999) / 1000UL) // "ceil" +#endif diff --git a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp index 24baae221e..4abf91edbd 100644 --- a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp @@ -60,7 +60,7 @@ #elif F_CPU == 16000000 #define CPU_ST7920_DELAY_1 DELAY_NS(125) #define CPU_ST7920_DELAY_2 DELAY_NS(0) - #define CPU_ST7920_DELAY_3 DELAY_NS(125) + #define CPU_ST7920_DELAY_3 DELAY_NS(188) #else #error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'" #endif From a6105ef37f8a9682b7c33834fc37363f425fd16d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 6 Apr 2021 00:35:12 +0000 Subject: [PATCH 171/311] [cron] Bump distribution date (2021-04-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 d924fc665e..eb81be3b5c 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-04-05" + #define STRING_DISTRIBUTION_DATE "2021-04-06" #endif /** From 61af08d4993014935a3a378952cd5562ee4e2e14 Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Tue, 6 Apr 2021 04:39:57 +0300 Subject: [PATCH 172/311] MKS LVGL UI: Display/edit fan percentage (#21544) Co-authored-by: Scott Lahteine --- Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp | 50 ++++++-------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp index af8b441f24..700471b4a3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp @@ -32,8 +32,7 @@ #include "../../../../inc/MarlinConfig.h" extern lv_group_t *g; -static lv_obj_t *scr; -static lv_obj_t *fanText; +static lv_obj_t *scr, *fanText; enum { ID_F_ADD = 1, @@ -44,43 +43,23 @@ enum { ID_F_RETURN }; -static uint8_t fanSpeed; - static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; - + uint8_t fanPercent = map(thermalManager.fan_speed[0], 0, 255, 0, 100); switch (obj->mks_obj_id) { - case ID_F_ADD: - if (fanSpeed < 254) fanSpeed++; - break; - case ID_F_DEC: - if (fanSpeed > 0) fanSpeed--; - break; - case ID_F_HIGH: - fanSpeed = 255; - break; - case ID_F_MID: - fanSpeed = 127; - break; - case ID_F_OFF: - gcode.process_subcommands_now_P(PSTR("M107")); - return; - case ID_F_RETURN: - clear_cur_ui(); - draw_return_ui(); - return; + case ID_F_ADD: if (fanPercent < 100) fanPercent++; break; + case ID_F_DEC: if (fanPercent != 0) fanPercent--; break; + case ID_F_HIGH: fanPercent = 100; break; + case ID_F_MID: fanPercent = 50; break; + case ID_F_OFF: fanPercent = 0; break; + case ID_F_RETURN: clear_cur_ui(); draw_return_ui(); return; } - sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed); - gcode.process_subcommands_now(public_buf_l); + thermalManager.set_fan_speed(0, map(fanPercent, 0, 100, 0, 255)); } void lv_draw_fan() { lv_obj_t *buttonAdd; - #if HAS_FAN - fanSpeed = thermalManager.fan_speed[0]; - #endif - scr = lv_screen_create(FAN_UI); // Create an Image button buttonAdd = lv_big_button_create(scr, "F:/bmp_Add.bin", fan_menu.add, INTERVAL_V, titleHeight, event_handler, ID_F_ADD); @@ -97,12 +76,11 @@ void lv_draw_fan() { } void disp_fan_value() { - char buf1[10] = {0}; - public_buf_l[0] = '\0'; - strcat(public_buf_l, fan_menu.state); - strcat_P(public_buf_l, PSTR(": ")); - sprintf_P(buf1, PSTR("%3d"), thermalManager.fan_speed[0]); - strcat(public_buf_l, buf1); + #if HAS_FAN + sprintf_P(public_buf_l, PSTR("%s: %3d%%"), fan_menu.state, (int)map(thermalManager.fan_speed[0], 0, 255, 0, 100)); + #else + sprintf_P(public_buf_l, PSTR("%s: ---"), fan_menu.state); + #endif lv_label_set_text(fanText, public_buf_l); lv_obj_align(fanText, nullptr, LV_ALIGN_CENTER, 0, -65); } From 121b606f9c264995c2c2aa9c215f15d3b3ddb218 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Mon, 5 Apr 2021 22:46:21 -0300 Subject: [PATCH 173/311] Fix Rumba32 variant for Marlin (#21497) --- .../variants/MARLIN_F446VE/PeripheralPins.c | 454 ++++++++++++++++++ .../variants/MARLIN_F446VE/PinNamesVar.h | 30 ++ .../variants/MARLIN_F446VE/ldscript.ld | 184 +++++++ .../variants/MARLIN_F446VE/variant.cpp | 212 ++++++++ .../variants/MARLIN_F446VE/variant.h | 186 +++++++ ini/stm32f4.ini | 21 +- 6 files changed, 1081 insertions(+), 6 deletions(-) create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446VE/PeripheralPins.c create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446VE/PinNamesVar.h create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.cpp create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PeripheralPins.c new file mode 100644 index 0000000000..d4746a39e3 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PeripheralPins.c @@ -0,0 +1,454 @@ +/* + ******************************************************************************* + * Copyright (c) 2020, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + * Automatically generated from STM32F446V(C-E)Tx.xml + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Note: Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + // {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + // {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + // {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + // {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + // {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + // {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + // {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +WEAK const PinMap PinMap_DAC[] = { + // {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + // {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + // {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + // {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + // {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_PWM[] = { + // {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + // {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + // {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + // {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + // {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + // {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + // {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + // {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + // {PB_8, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + // {PB_9, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + // {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + // {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 + {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + // {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + // {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + // {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + // {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + // {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + // {PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + // {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + // {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PE_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + // {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + // {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PE_7, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RTS[] = { + // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + // {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_CTS[] = { + // {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + // {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PD_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + // {PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PD_0, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PD_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + // {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PD_0, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_CAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_TD[] = { + // {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PD_1, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {NC, NP, 0} +}; +#endif + +//*** No ETHERNET *** + +//*** QUADSPI *** + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_DATA0[] = { + // {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 + // {PD_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 + // {PE_7, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO0 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_DATA1[] = { + // {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 + // {PD_12, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 + // {PE_8, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO1 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_DATA2[] = { + // {PE_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO2 + // {PE_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO2 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_DATA3[] = { + {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 + // {PD_13, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 + // {PE_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO3 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_SCLK[] = { + // {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK + // {PD_3, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_SSEL[] = { + // {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS + // {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS + {NC, NP, 0} +}; +#endif + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { + // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_HS[] = { +#ifdef USE_USB_HS_IN_FS + // {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF + // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID + // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + // {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM + // {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP +#else + // {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 + // {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK + // {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 + // {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 + // {PB_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4 + // {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 + // {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 + // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 + // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 + // {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP + // {PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR + // {PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT +#endif /* USE_USB_HS_IN_FS */ + {NC, NP, 0} +}; +#endif + +//*** SD *** + +#ifdef HAL_SD_MODULE_ENABLED +WEAK const PinMap PinMap_SD[] = { + // {PB_0, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + // {PB_1, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + // {PB_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + // {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + // {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + // {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + // {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + // {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + // {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + // {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + // {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 + // {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + // {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD + {NC, NP, 0} +}; +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PinNamesVar.h new file mode 100644 index 0000000000..bff3f21349 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PinNamesVar.h @@ -0,0 +1,30 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, /* SYS_WKUP0 */ +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld new file mode 100644 index 0000000000..503472806e --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld @@ -0,0 +1,184 @@ +/* +***************************************************************************** +** +** File : lscript.ld +** +** Abstract : Linker script for STM32F446VE Device with +** 512KByte FLASH, 128KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2014 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text ALIGN(4): + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata ALIGN(4): + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + /*_siccmram = LOADADDR(.ccmram);*/ + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.cpp new file mode 100644 index 0000000000..16e11f0a91 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.cpp @@ -0,0 +1,212 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +const PinName digitalPin[] = { + PA_0, //D0 //A7 + PA_1, //D1 //A8 + PA_2, //D2 //A9 + PA_3, //D3 //A0 + PA_4, //D4 //A1 + PA_5, //D5 //A10 + PA_6, //D6 //A11 + PA_7, //D7 //A12 + PA_8, //D8 + PA_9, //D9 + PA_10, //D10 + PA_11, //D11 + PA_12, //D12 + PA_13, //D13 + PA_14, //D14 + PA_15, //D15 + PB_0, //D16 //A13 + PB_1, //D17 //A14 + PB_2, //D18 + PB_3, //D19 + PB_4, //D20 + PB_5, //D21 + PB_6, //D22 + PB_7, //D23 + PB_8, //D24 + PB_9, //D25 + PB_10, //D26 + PB_11, //D27 + PB_12, //D28 + PB_13, //D29 + PB_14, //D30 + PB_15, //D31 + PC_0, //D32 //A2 + PC_1, //D33 //A3 + PC_2, //D34 //A4 + PC_3, //D35 //A5 + PC_4, //D36 //A6 + PC_5, //D37 //A15 + PC_6, //D38 + PC_7, //D39 + PC_8, //D40 + PC_9, //D41 + PC_10, //D42 + PC_11, //D43 + PC_12, //D44 + PC_13, //D45 + PC_14, //D46 + PC_15, //D47 + PD_0, //D48 + PD_1, //D49 + PD_2, //D50 + PD_3, //D51 + PD_4, //D52 + PD_5, //D53 + PD_6, //D54 + PD_7, //D55 + PD_8, //D56 + PD_9, //D57 + PD_10, //D58 + PD_11, //D59 + PD_12, //D60 + PD_13, //D61 + PD_14, //D62 + PD_15, //D63 + PE_0, //D64 + PE_1, //D65 + PE_2, //D66 + PE_3, //D67 + PE_4, //D68 + PE_5, //D69 + PE_6, //D70 + PE_7, //D71 + PE_8, //D72 + PE_9, //D73 + PE_10, //D74 + PE_11, //D75 + PE_12, //D76 + PE_13, //D77 + PE_14, //D78 + PE_15 //D79 +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 3, //D3 //A0 + 4, //D4 //A1 + 32, //D32 //A2 + 33, //D33 //A3 + 34, //D34 //A4 + 35, //D35 //A5 + 36, //D36 //A6 + 0, //D0 //A7 + 1, //D1 //A8 + 2, //D2 //A9 + 5, //D5 //A10 + 6, //D6 //A11 + 7, //D7 //A12 + 16, //D16 //A13 + 17, //D17 //A14 + 37 //D37 //A15 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 168000000 + * HCLK(Hz) = 168000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 4 + * APB2 Prescaler = 2 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 8 + * PLL_N = 336 + * PLL_P = 2 + * PLL_Q = 7 + * VDD(V) = 3.3 + * Main regulator output voltage = Scale1 mode + * Flash Latency(WS) = 5 + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; + + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + +#ifdef HAL_PWR_MODULE_ENABLED + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); +#endif + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 6; + RCC_OscInitStruct.PLL.PLLN = 180; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + RCC_OscInitStruct.PLL.PLLR = 2; + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + HAL_PWREx_EnableOverDrive(); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | + RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLRCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); + + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48; + PeriphClkInitStruct.PLLSAI.PLLSAIM = 6; + PeriphClkInitStruct.PLLSAI.PLLSAIN = 96; + PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2; + PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV4; + PeriphClkInitStruct.PLLSAIDivQ = 1; + PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48CLKSOURCE_PLLSAIP; + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h new file mode 100644 index 0000000000..f00cc5f612 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h @@ -0,0 +1,186 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PA0 PIN_A7 //D0 +#define PA1 PIN_A8 //D1 +#define PA2 PIN_A9 //D2 +#define PA3 PIN_A0 //D3 +#define PA4 PIN_A1 //D4 +#define PA5 PIN_A10 //D5 +#define PA6 PIN_A11 //D6 +#define PA7 PIN_A12 //D7 +#define PA8 8 //D8 +#define PA9 9 //D9 +#define PA10 10 //D10 +#define PA11 11 //D11 +#define PA12 12 //D12 +#define PA13 13 //D13 +#define PA14 14 //D14 +#define PA15 15 //D15 +#define PB0 PIN_A13 //D16 +#define PB1 PIN_A14 //D17 +#define PB2 18 //D18 +#define PB3 19 //D19 +#define PB4 20 //D20 +#define PB5 21 //D21 +#define PB6 22 //D22 +#define PB7 23 //D23 +#define PB8 24 //D24 +#define PB9 25 //D25 +#define PB10 26 //D26 +#define PB11 27 //D27 +#define PB12 28 //D28 +#define PB13 29 //D29 +#define PB14 30 //D30 +#define PB15 31 //D31 +#define PC0 PIN_A2 //D32 +#define PC1 PIN_A3 //D33 +#define PC2 PIN_A4 //D34 +#define PC3 PIN_A5 //D35 +#define PC4 PIN_A6 //D36 +#define PC5 PIN_A15 //D37 +#define PC6 38 //D38 +#define PC7 39 //D39 +#define PC8 40 //D40 +#define PC9 41 //D41 +#define PC10 42 //D42 +#define PC11 43 //D43 +#define PC12 44 //D44 +#define PC13 45 //D45 +#define PC14 46 //D46 +#define PC15 47 //D47 +#define PD0 48 //D48 +#define PD1 49 //D49 +#define PD2 50 //D50 +#define PD3 51 //D51 +#define PD4 52 //D52 +#define PD5 53 //D53 +#define PD6 54 //D54 +#define PD7 55 //D55 +#define PD8 56 //D56 +#define PD9 57 //D57 +#define PD10 58 //D58 +#define PD11 59 //D59 +#define PD12 60 //D60 +#define PD13 61 //D61 +#define PD14 62 //D62 +#define PD15 63 //D63 +#define PE0 64 //D64 +#define PE1 65 //D65 +#define PE2 66 //D66 +#define PE3 67 //D67 +#define PE4 68 //D68 +#define PE5 69 //D69 +#define PE6 70 //D70 +#define PE7 71 //D71 +#define PE8 72 //D72 +#define PE9 73 //D73 +#define PE10 74 //D74 +#define PE11 75 //D75 +#define PE12 76 //D76 +#define PE13 77 //D77 +#define PE14 78 //D78 +#define PE15 79 //D79 + +// This must be a literal +#define NUM_DIGITAL_PINS 80 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 16 + +// PWM resolution +#define PWM_FREQUENCY 20000 // >= 20 Khz => inaudible noise for fans +#define PWM_MAX_DUTY_CYCLE 255 + +// On-board LED pin number +#define LED_BUILTIN PB14 +#define LED_HEARTBEAT LED_BUILTIN + +// SPI Definitions +#define PIN_SPI_SS PA4 +#define PIN_SPI_MOSI PA7 +#define PIN_SPI_MISO PA6 +#define PIN_SPI_SCK PA5 + +// I2C Definitions +#define PIN_WIRE_SDA PB9 +#define PIN_WIRE_SCL PB8 + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE +#define TIMER_TONE TIM6 +#endif + +#ifndef TIMER_SERVO +#define TIMER_SERVO TIM7 +#endif + +#ifndef TIMER_SERIAL +#define TIMER_SERIAL TIM9 +#endif + +// UART Definitions +#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +/* HAL configuration */ +#define HSE_VALUE 12000000U + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #define SERIAL_PORT_MONITOR Serial + #define SERIAL_PORT_HARDWARE_OPEN Serial +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index a15dc8b056..5e700f0e9f 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -277,17 +277,26 @@ build_flags = ${stm_flash_drive.build_flags} # RUMBA32 # [env:rumba32] -platform = ${common_stm32.platform} -extends = common_stm32 -build_flags = ${common_stm32.build_flags} +platform = ${common_stm32.platform} +extends = common_stm32 +build_flags = ${common_stm32.build_flags} -Os -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB -DHAL_UART_MODULE_ENABLED -DTIMER_SERIAL=TIM9 -board = rumba32_f446ve -upload_protocol = dfu -monitor_speed = 500000 +board = rumba32_f446ve +upload_protocol = dfu +monitor_speed = 500000 +board_build.core = stm32 +board_build.variant = MARLIN_F446VE +board_build.ldscript = ldscript.ld +board_build.offset = 0x0000 +board_build.encrypt = No +board_build.firmware = firmware.bin +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py # # MKS Robin Pro V2 From 746eae15f36e4211a22d53b8e12e82edb55a13e5 Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Tue, 6 Apr 2021 04:55:00 +0300 Subject: [PATCH 174/311] Cast celsius to int for MKS LVGL UI (#21502) --- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 2 +- .../extui/lib/mks_ui/draw_filament_change.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 23 +++++++------- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 6 ++-- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 30 +++++++++---------- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 12 ++------ 6 files changed, 34 insertions(+), 41 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index 056e2e5d54..43ed214199 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -195,7 +195,7 @@ void disp_ext_speed() { void disp_hotend_temp() { char buf[20] = {0}; - sprintf(buf, extrude_menu.temp_value, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, extrude_menu.temper_text); strcat(public_buf_l, buf); lv_label_set_text(tempText, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp index 296359bc53..a3313285df 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -154,7 +154,7 @@ void disp_filament_temp() { public_buf_l[0] = '\0'; strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); 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 d23ed0b05f..0395ccde52 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -62,15 +62,15 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { thermalManager.setTargetHotend(max_target, uiCfg.extruderIndex); thermalManager.start_watching_hotend(uiCfg.extruderIndex); } - #if HAS_HEATED_BED - else { + else { + #if HAS_HEATED_BED constexpr int16_t max_target = BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1); thermalManager.temp_bed.target += uiCfg.stepHeat; if (thermalManager.degTargetBed() > max_target) thermalManager.setTargetBed(max_target); thermalManager.start_watching_bed(); - } - #endif + #endif + } disp_desire_temp(); } break; @@ -211,20 +211,19 @@ void disp_temp_type() { } void disp_desire_temp() { - char buf[20] = {0}; - + char buf[20] = { 0 }; public_buf_l[0] = '\0'; if (uiCfg.curTempType == 0) { strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); } - #if HAS_HEATED_BED - else { + else { + #if HAS_HEATED_BED strcat(public_buf_l, preheat_menu.hotbed); - sprintf(buf, preheat_menu.value_state, thermalManager.degBed(), thermalManager.degTargetBed()); - } - #endif + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); + #endif + } strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); lv_label_set_text(tempText1, public_buf_l); 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 9bd120ce15..6025968d3b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -219,18 +219,18 @@ void lv_draw_printing() { } void disp_ext_temp() { - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1)); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, public_buf_l); #endif } void disp_bed_temp() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed()); + sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); #endif } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 5787cfb009..45a2167a05 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -105,14 +105,14 @@ void disp_det_error() { lv_obj_t *e1, *e2, *e3, *bed; void mks_disp_test() { char buf[30] = {0}; - sprintf_P(buf, PSTR("e1:%d"), thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.degHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND - sprintf_P(buf, PSTR("e2:%d"), thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.degHotend(1)); lv_label_set_text(e2, buf); #endif #if HAS_HEATED_BED - sprintf_P(buf, PSTR("bed:%d"), thermalManager.degBed()); + sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.degBed()); lv_label_set_text(bed, buf); #endif } @@ -139,20 +139,20 @@ void lv_draw_ready_print() { e1 = lv_label_create_empty(scr); lv_obj_set_pos(e1, 20, 20); - sprintf_P(buf, PSTR("e1: %d"), thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND e2 = lv_label_create_empty(scr); lv_obj_set_pos(e2, 20, 45); - sprintf_P(buf, PSTR("e1: %d"), thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(1)); lv_label_set_text(e2, buf); #endif #if HAS_HEATED_BED bed = lv_label_create_empty(scr); lv_obj_set_pos(bed, 20, 95); - sprintf_P(buf, PSTR("bed: %d"), thermalManager.degBed()); + sprintf_P(buf, PSTR("bed: %d"), (int)thermalManager.degBed()); lv_label_set_text(bed, buf); #endif @@ -208,27 +208,27 @@ void lv_draw_ready_print() { labelFan = lv_label_create(scr, 380, 80, nullptr); - sprintf_P(buf, PSTR("%d"), thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("%d"), (int)thermalManager.degHotend(0)); lv_label_set_text(labelExt1, buf); lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(0)); + sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1Target, buf); lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #if HAS_MULTI_EXTRUDER - sprintf_P(buf, PSTR("%d"), thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("%d"), (int)thermalManager.degHotend(1)); lv_label_set_text(labelExt2, buf); lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(1)); + sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2Target, buf); lv_obj_align(labelExt2Target, buttonExt2, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #endif #if HAS_HEATED_BED - sprintf_P(buf, PSTR("%d"), thermalManager.degBed()); + sprintf_P(buf, PSTR("%d"), (int)thermalManager.degBed()); lv_label_set_text(labelBed, buf); lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetBed()); + sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetBed()); lv_label_set_text(labelBedTarget, buf); lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #endif @@ -249,15 +249,15 @@ void lv_draw_ready_print() { void lv_temp_refr() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed()); + sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); #endif - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1)); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, 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 a74ecd2f1e..1057a0c689 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -885,9 +885,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { char *outBuf = (char *)tempBuf; char str_1[16], tbuf[34]; - dtostrf(thermalManager.degHotend(0), 1, 1, tbuf); - strcat_P(tbuf, PSTR(" /")); - strcat(tbuf, dtostrf(thermalManager.degTargetHotend(0), 1, 1, str_1)); + sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); const int tlen = strlen(tbuf); @@ -897,9 +895,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcpy_P(outBuf, PSTR(" B:")); outBuf += 3; #if HAS_HEATED_BED - strcpy(outBuf, dtostrf(thermalManager.degBed(), 1, 1, str_1)); - strcat_P(outBuf, PSTR(" /")); - strcat(outBuf, dtostrf(thermalManager.degTargetBed(), 1, 1, str_1)); + sprintf_P(outBuf, PSTR("%d /%d"), (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); #else strcpy_P(outBuf, PSTR("0 /0")); #endif @@ -912,9 +908,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcat_P(outBuf, PSTR(" T1:")); outBuf += 4; #if HAS_MULTI_HOTEND - strcat(outBuf, dtostrf(thermalManager.degHotend(1), 1, 1, str_1)); - strcat_P(outBuf, PSTR(" /")); - strcat(outBuf, dtostrf(thermalManager.degTargetHotend(1), 1, 1, str_1)); + sprintf_P(outBuf, PSTR("%d /%d"), (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); #else strcat_P(outBuf, PSTR("0 /0")); #endif From ed14731146006442f1cc4045b70cefdec00aaa8f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 5 Apr 2021 21:27:05 -0500 Subject: [PATCH 175/311] getHighESpeed => autotemp_task --- Marlin/src/module/planner.cpp | 4 ++-- Marlin/src/module/planner.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 891f6a7ab0..e111a808b2 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1382,7 +1382,7 @@ void Planner::check_axes_activity() { sync_fan_speeds(tail_fan_speed); #endif - TERN_(AUTOTEMP, getHighESpeed()); + TERN_(AUTOTEMP, autotemp_task()); #if ENABLED(BARICUDA) TERN_(HAS_HEATER_1, analogWrite(pin_t(HEATER_1_PIN), tail_valve_pressure)); @@ -1432,7 +1432,7 @@ void Planner::check_axes_activity() { * based on the extrusion speed, which is calculated from the blocks * currently in the planner. */ - void Planner::getHighESpeed() { + void Planner::autotemp_task() { static float oldt = 0; if (!autotemp_enabled) return; diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 6b99c8bcc1..570fcc08af 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -926,7 +926,7 @@ class Planner { static bool autotemp_enabled; static void autotemp_update(); static void autotemp_M104_M109(); - static void getHighESpeed(); + static void autotemp_task(); #endif #if HAS_LINEAR_E_JERK From b483a8d652c18626d57b5a38c78fdd2caa6e91c3 Mon Sep 17 00:00:00 2001 From: BigTreeTech <38851044+bigtreetech@users.noreply.github.com> Date: Tue, 6 Apr 2021 10:40:50 +0800 Subject: [PATCH 176/311] BTT SKR-SE-BX (STM32H743IIT6 ARM Cortex M7) and BIQU_BX_TFT70 (#21536) --- .github/workflows/test-builds.yml | 1 + Marlin/Configuration.h | 5 + Marlin/src/HAL/STM32/MarlinSPI.cpp | 2 +- Marlin/src/HAL/STM32/inc/SanityCheck.h | 4 +- Marlin/src/HAL/STM32/tft/tft_ltdc.cpp | 390 ++++++++ Marlin/src/HAL/STM32/tft/tft_ltdc.h | 155 +++ Marlin/src/HAL/STM32/timers.cpp | 2 +- Marlin/src/core/boards.h | 1 + Marlin/src/inc/Conditionals_LCD.h | 25 +- Marlin/src/inc/SanityCheck.h | 10 +- .../dogm/u8g_dev_tft_upscale_from_128x64.cpp | 4 +- .../screens/bed_mesh_view_screen.cpp | 2 +- Marlin/src/lcd/tft/tft.h | 3 + Marlin/src/lcd/tft/ui_1024x600.cpp | 927 ++++++++++++++++++ Marlin/src/lcd/tft/ui_1024x600.h | 43 + Marlin/src/lcd/tft/ui_common.h | 4 + Marlin/src/lcd/tft_io/tft_io.cpp | 15 +- Marlin/src/lcd/tft_io/tft_io.h | 7 +- Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h | 226 +++++ .../PlatformIO/boards/BTT_SKR_SE_BX.json | 56 ++ .../variants/BTT_SKR_SE_BX/PeripheralPins.c | 491 ++++++++++ .../variants/BTT_SKR_SE_BX/PinNamesVar.h | 50 + .../variants/BTT_SKR_SE_BX/hal_conf_extra.h | 479 +++++++++ .../variants/BTT_SKR_SE_BX/ldscript.ld | 208 ++++ .../variants/BTT_SKR_SE_BX/variant.cpp | 332 +++++++ .../variants/BTT_SKR_SE_BX/variant.h | 222 +++++ buildroot/tests/BTT_SKR_SE_BX | 18 + ini/features.ini | 2 +- ini/stm32f7.ini | 25 + 30 files changed, 3694 insertions(+), 17 deletions(-) create mode 100644 Marlin/src/HAL/STM32/tft/tft_ltdc.cpp create mode 100644 Marlin/src/HAL/STM32/tft/tft_ltdc.h create mode 100644 Marlin/src/lcd/tft/ui_1024x600.cpp create mode 100644 Marlin/src/lcd/tft/ui_1024x600.h create mode 100644 Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h create mode 100644 buildroot/share/PlatformIO/boards/BTT_SKR_SE_BX.json create mode 100644 buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c create mode 100644 buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PinNamesVar.h create mode 100644 buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/hal_conf_extra.h create mode 100644 buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/ldscript.ld create mode 100644 buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.cpp create mode 100644 buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.h create mode 100755 buildroot/tests/BTT_SKR_SE_BX diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index 7b7052e0e1..5a598299f3 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -89,6 +89,7 @@ jobs: - mks_robin_nano35_stm32 - NUCLEO_F767ZI - REMRAM_V1 + - BTT_SKR_SE_BX # Put lengthy tests last diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0847892934..1022dd54dd 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2496,6 +2496,11 @@ // //#define ANET_ET5_TFT35 +// +// 1024x600, 7", RGB Stock Display from BIQU-BX +// +//#define BIQU_BX_TFT70 + // // Generic TFT with detailed options // diff --git a/Marlin/src/HAL/STM32/MarlinSPI.cpp b/Marlin/src/HAL/STM32/MarlinSPI.cpp index 5086b41784..896ec1433f 100644 --- a/Marlin/src/HAL/STM32/MarlinSPI.cpp +++ b/Marlin/src/HAL/STM32/MarlinSPI.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(STM32H7xx) #include "MarlinSPI.h" diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h index 7ee606af7f..12ff2abec7 100644 --- a/Marlin/src/HAL/STM32/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h @@ -52,6 +52,6 @@ #error "SERIAL_STATS_DROPPED_RX is not supported on STM32." #endif -#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32F4xx, STM32F1xx) - #error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32F4 and STM32F1 hardware." +#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32H7xx, STM32F4xx, STM32F1xx) + #error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware." #endif diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp new file mode 100644 index 0000000000..6039593f46 --- /dev/null +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp @@ -0,0 +1,390 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) + +#include "../../../inc/MarlinConfig.h" + +#if HAS_LTDC_TFT + +#include "tft_ltdc.h" +#include "pinconfig.h" + +#define FRAME_BUFFER_ADDRESS 0XC0000000 // SDRAM address + +#define SDRAM_TIMEOUT ((uint32_t)0xFFFF) +#define REFRESH_COUNT ((uint32_t)0x02A5) // SDRAM refresh counter + +#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) +#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) +#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) +#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) +#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) +#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) +#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) +#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) +#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) +#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) +#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) + + +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command) { + + __IO uint32_t tmpmrd =0; + /* Step 1: Configure a clock configuration enable command */ + Command->CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; + Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command->AutoRefreshNumber = 1; + Command->ModeRegisterDefinition = 0; + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT); + + /* Step 2: Insert 100 us minimum delay */ + /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */ + HAL_Delay(1); + + /* Step 3: Configure a PALL (precharge all) command */ + Command->CommandMode = FMC_SDRAM_CMD_PALL; + Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command->AutoRefreshNumber = 1; + Command->ModeRegisterDefinition = 0; + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT); + + /* Step 4 : Configure a Auto-Refresh command */ + Command->CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; + Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command->AutoRefreshNumber = 8; + Command->ModeRegisterDefinition = 0; + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT); + + /* Step 5: Program the external memory mode register */ + tmpmrd = (uint32_t)(SDRAM_MODEREG_BURST_LENGTH_1 | + SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL | + SDRAM_MODEREG_CAS_LATENCY_2 | + SDRAM_MODEREG_OPERATING_MODE_STANDARD | + SDRAM_MODEREG_WRITEBURST_MODE_SINGLE); + + Command->CommandMode = FMC_SDRAM_CMD_LOAD_MODE; + Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command->AutoRefreshNumber = 1; + Command->ModeRegisterDefinition = tmpmrd; + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT); + + /* Step 6: Set the refresh rate counter */ + /* Set the device refresh rate */ + HAL_SDRAM_ProgramRefreshRate(hsdram, REFRESH_COUNT); +} + +void SDRAM_Config() { + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + __HAL_RCC_FMC_CLK_ENABLE(); + + SDRAM_HandleTypeDef hsdram; + FMC_SDRAM_TimingTypeDef SDRAM_Timing; + FMC_SDRAM_CommandTypeDef command; + + /* Configure the SDRAM device */ + hsdram.Instance = FMC_SDRAM_DEVICE; + hsdram.Init.SDBank = FMC_SDRAM_BANK1; + hsdram.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; + hsdram.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; + hsdram.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16; + hsdram.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_2; + hsdram.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + hsdram.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; + hsdram.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + + /* Timing configuration for 100Mhz as SDRAM clock frequency (System clock is up to 200Mhz) */ + SDRAM_Timing.LoadToActiveDelay = 2; + SDRAM_Timing.ExitSelfRefreshDelay = 8; + SDRAM_Timing.SelfRefreshTime = 6; + SDRAM_Timing.RowCycleDelay = 6; + SDRAM_Timing.WriteRecoveryTime = 2; + SDRAM_Timing.RPDelay = 2; + SDRAM_Timing.RCDDelay = 2; + + /* Initialize the SDRAM controller */ + if (HAL_SDRAM_Init(&hsdram, &SDRAM_Timing) != HAL_OK) + { + /* Initialization Error */ + } + + /* Program the SDRAM external device */ + SDRAM_Initialization_Sequence(&hsdram, &command); +} + +void LTDC_Config() { + + __HAL_RCC_LTDC_CLK_ENABLE(); + __HAL_RCC_DMA2D_CLK_ENABLE(); + + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; + + /* The PLL3R is configured to provide the LTDC PCLK clock */ + /* PLL3_VCO Input = HSE_VALUE / PLL3M = 25Mhz / 5 = 5 Mhz */ + /* PLL3_VCO Output = PLL3_VCO Input * PLL3N = 5Mhz * 160 = 800 Mhz */ + /* PLLLCDCLK = PLL3_VCO Output/PLL3R = 800Mhz / 16 = 50Mhz */ + /* LTDC clock frequency = PLLLCDCLK = 50 Mhz */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; + PeriphClkInitStruct.PLL3.PLL3M = 5; + PeriphClkInitStruct.PLL3.PLL3N = 160; + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; + PeriphClkInitStruct.PLL3.PLL3P = 2; + PeriphClkInitStruct.PLL3.PLL3Q = 2; + PeriphClkInitStruct.PLL3.PLL3R = (800 / LTDC_LCD_CLK); + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_2; + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); + + LTDC_HandleTypeDef hltdc_F; + LTDC_LayerCfgTypeDef pLayerCfg; + + /* LTDC Initialization -------------------------------------------------------*/ + + /* Polarity configuration */ + /* Initialize the horizontal synchronization polarity as active low */ + hltdc_F.Init.HSPolarity = LTDC_HSPOLARITY_AL; + /* Initialize the vertical synchronization polarity as active low */ + hltdc_F.Init.VSPolarity = LTDC_VSPOLARITY_AL; + /* Initialize the data enable polarity as active low */ + hltdc_F.Init.DEPolarity = LTDC_DEPOLARITY_AL; + /* Initialize the pixel clock polarity as input pixel clock */ + hltdc_F.Init.PCPolarity = LTDC_PCPOLARITY_IPC; + + /* Timing configuration */ + hltdc_F.Init.HorizontalSync = (LTDC_LCD_HSYNC - 1); + hltdc_F.Init.VerticalSync = (LTDC_LCD_VSYNC - 1); + hltdc_F.Init.AccumulatedHBP = (LTDC_LCD_HSYNC + LTDC_LCD_HBP - 1); + hltdc_F.Init.AccumulatedVBP = (LTDC_LCD_VSYNC + LTDC_LCD_VBP - 1); + hltdc_F.Init.AccumulatedActiveH = (TFT_HEIGHT + LTDC_LCD_VSYNC + LTDC_LCD_VBP - 1); + hltdc_F.Init.AccumulatedActiveW = (TFT_WIDTH + LTDC_LCD_HSYNC + LTDC_LCD_HBP - 1); + hltdc_F.Init.TotalHeigh = (TFT_HEIGHT + LTDC_LCD_VSYNC + LTDC_LCD_VBP + LTDC_LCD_VFP - 1); + hltdc_F.Init.TotalWidth = (TFT_WIDTH + LTDC_LCD_HSYNC + LTDC_LCD_HBP + LTDC_LCD_HFP - 1); + + /* Configure R,G,B component values for LCD background color : all black background */ + hltdc_F.Init.Backcolor.Blue = 0; + hltdc_F.Init.Backcolor.Green = 0; + hltdc_F.Init.Backcolor.Red = 0; + + hltdc_F.Instance = LTDC; + +/* Layer0 Configuration ------------------------------------------------------*/ + + /* Windowing configuration */ + pLayerCfg.WindowX0 = 0; + pLayerCfg.WindowX1 = TFT_WIDTH; + pLayerCfg.WindowY0 = 0; + pLayerCfg.WindowY1 = TFT_HEIGHT; + + /* Pixel Format configuration*/ + pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; + + /* Start Address configuration : frame buffer is located at SDRAM memory */ + pLayerCfg.FBStartAdress = (uint32_t)(FRAME_BUFFER_ADDRESS); + + /* Alpha constant (255 == totally opaque) */ + pLayerCfg.Alpha = 255; + + /* Default Color configuration (configure A,R,G,B component values) : no background color */ + pLayerCfg.Alpha0 = 0; /* fully transparent */ + pLayerCfg.Backcolor.Blue = 0; + pLayerCfg.Backcolor.Green = 0; + pLayerCfg.Backcolor.Red = 0; + + /* Configure blending factors */ + pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA; + pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA; + + /* Configure the number of lines and number of pixels per line */ + pLayerCfg.ImageWidth = TFT_WIDTH; + pLayerCfg.ImageHeight = TFT_HEIGHT; + + /* Configure the LTDC */ + if (HAL_LTDC_Init(&hltdc_F) != HAL_OK) + { + /* Initialization Error */ + } + + /* Configure the Layer*/ + if (HAL_LTDC_ConfigLayer(&hltdc_F, &pLayerCfg, 0) != HAL_OK) + { + /* Initialization Error */ + } +} + +uint16_t TFT_LTDC::x_min = 0; +uint16_t TFT_LTDC::x_max = 0; +uint16_t TFT_LTDC::y_min = 0; +uint16_t TFT_LTDC::y_max = 0; +uint16_t TFT_LTDC::x_cur = 0; +uint16_t TFT_LTDC::y_cur = 0; +uint8_t TFT_LTDC::reg = 0; +volatile uint16_t* TFT_LTDC::framebuffer = (volatile uint16_t* )FRAME_BUFFER_ADDRESS; + +void TFT_LTDC::Init() { + + // SDRAM pins init + for (uint16_t i = 0; PinMap_SDRAM[i].pin != NC; i++) + pinmap_pinout(PinMap_SDRAM[i].pin, PinMap_SDRAM); + + // SDRAM peripheral config + SDRAM_Config(); + + // LTDC pins init + for (uint16_t i = 0; PinMap_LTDC[i].pin != NC; i++) + pinmap_pinout(PinMap_LTDC[i].pin, PinMap_LTDC); + + // LTDC peripheral config + LTDC_Config(); +} + +uint32_t TFT_LTDC::GetID() { + return 0xABAB; +} + +uint32_t TFT_LTDC::ReadID(tft_data_t Reg) { + return 0xABAB; +} + +bool TFT_LTDC::isBusy() { + return false; +} + +uint16_t TFT_LTDC::ReadPoint(uint16_t x, uint16_t y) { + return framebuffer[(TFT_WIDTH * y) + x]; +} + +void TFT_LTDC::DrawPoint(uint16_t x, uint16_t y, uint16_t color) { + framebuffer[(TFT_WIDTH * y) + x] = color; +} + +void TFT_LTDC::DrawRect(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color) { + + if (sx == ex || sy == ey) return; + + uint16_t offline = TFT_WIDTH - (ex - sx); + uint32_t addr = (uint32_t)&framebuffer[(TFT_WIDTH * sy) + sx]; + + DMA2D->CR &= ~(1 << 0); + DMA2D->CR = 3 << 16; + DMA2D->OPFCCR = 0X02; + DMA2D->OOR = offline; + DMA2D->OMAR = addr; + DMA2D->NLR = (ey - sy) | ((ex - sx) << 16); + DMA2D->OCOLR = color; + DMA2D->CR |= 1<<0; + + uint32_t timeout = 0; + while((DMA2D->ISR & (1<<1)) == 0) + { + timeout++; + if(timeout>0X1FFFFF)break; + } + DMA2D->IFCR |= 1<<1; +} + +void TFT_LTDC::DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *colors) { + + if (sx == ex || sy == ey) return; + + uint16_t offline = TFT_WIDTH - (ex - sx); + uint32_t addr = (uint32_t)&framebuffer[(TFT_WIDTH * sy) + sx]; + + DMA2D->CR &= ~(1 << 0); + DMA2D->CR = 0 << 16; + DMA2D->FGPFCCR = 0X02; + DMA2D->FGOR = 0; + DMA2D->OOR = offline; + DMA2D->FGMAR = (uint32_t)colors; + DMA2D->OMAR = addr; + DMA2D->NLR = (ey - sy) | ((ex - sx) << 16); + DMA2D->CR |= 1<<0; + + uint32_t timeout = 0; + while((DMA2D->ISR & (1<<1)) == 0) + { + timeout++; + if(timeout>0X1FFFFF)break; + } + DMA2D->IFCR |= 1<<1; +} + +void TFT_LTDC::WriteData(uint16_t data) { + switch (reg) { + case 0x01: x_cur = x_min = data; return; + case 0x02: x_max = data; return; + case 0x03: y_cur = y_min = data; return; + case 0x04: y_max = data; return; + } + Transmit(data); +} + +void TFT_LTDC::Transmit(tft_data_t Data) { + DrawPoint(x_cur, y_cur, Data); + x_cur++; + if (x_cur > x_max) { + x_cur = x_min; + y_cur++; + if (y_cur > y_max) y_cur = y_min; + } +} + +void TFT_LTDC::WriteReg(uint16_t Reg) { + reg = Reg; +} + +void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + + while (x_cur != x_min && Count) { + Transmit(*Data); + if (MemoryIncrease == DMA_PINC_ENABLE) Data++; + Count--; + } + + uint16_t width = x_max - x_min + 1; + uint16_t height = Count / width; + uint16_t x_end_cnt = Count - (width * height); + + if (height) { + if (MemoryIncrease == DMA_PINC_ENABLE) { + DrawImage(x_min, y_cur, x_min + width, y_cur + height, Data); + Data += width * height; + } else { + DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data); + } + y_cur += height; + } + + while (x_end_cnt) { + Transmit(*Data); + if (MemoryIncrease == DMA_PINC_ENABLE) Data++; + x_end_cnt--; + } +} + +#endif // HAS_LTDC_TFT +#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.h b/Marlin/src/HAL/STM32/tft/tft_ltdc.h new file mode 100644 index 0000000000..7b63d6929b --- /dev/null +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.h @@ -0,0 +1,155 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "../../../inc/MarlinConfig.h" + +#ifdef STM32H7xx + #include "stm32h7xx_hal.h" +#else + #error "LTDC TFT is currently only supported on STM32H7 hardware." +#endif + +#define DATASIZE_8BIT SPI_DATASIZE_8BIT +#define DATASIZE_16BIT SPI_DATASIZE_16BIT +#define TFT_IO_DRIVER TFT_LTDC + +#define TFT_DATASIZE DATASIZE_16BIT +typedef uint16_t tft_data_t; + +class TFT_LTDC { + private: + static volatile uint16_t *framebuffer; + static uint16_t x_min, x_max, y_min, y_max, x_cur, y_cur; + static uint8_t reg; + + static uint32_t ReadID(tft_data_t Reg); + + static uint16_t ReadPoint(uint16_t x, uint16_t y); + static void DrawPoint(uint16_t x, uint16_t y, uint16_t color); + static void DrawRect(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color); + static void DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *colors); + static void Transmit(tft_data_t Data); + static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); + + public: + static void Init(); + static uint32_t GetID(); + static bool isBusy(); + static void Abort() { /*__HAL_DMA_DISABLE(&DMAtx);*/ } + + static void DataTransferBegin(uint16_t DataWidth = TFT_DATASIZE) {} + static void DataTransferEnd() {}; + + static void WriteData(uint16_t Data); + static void WriteReg(uint16_t Reg); + + static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } + static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + static void WriteMultiple(uint16_t Color, uint32_t Count) { + static uint16_t Data; Data = Color; + while (Count > 0) { + TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); + Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + } + } +}; + +const PinMap PinMap_LTDC[] = { + {PF_10, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_DE + {PG_7, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_CLK + {PI_9, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_VSYNC + {PI_10, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_HSYNC + + {PG_6, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R7 + {PH_12, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R6 + {PH_11, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R5 + {PH_10, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R4 + {PH_9, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R3 + + {PI_2, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G7 + {PI_1, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G6 + {PI_0, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G5 + {PH_15, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G4 + {PH_14, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G3 + {PH_13, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G2 + + {PI_7, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B7 + {PI_6, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B6 + {PI_5, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B5 + {PI_4, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B4 + {PG_11, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B3 + {NC, NP, 0} +}; + +const PinMap PinMap_SDRAM[] = { + {PC_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDNWE + {PC_2, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDNE0 + {PC_3, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDCKE0 + {PE_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_NBL0 + {PE_1, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_NBL1 + {PF_11, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDNRAS + {PG_8, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDCLK + {PG_15, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDNCAS + {PG_4, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_BA0 + {PG_5, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_BA1 + {PD_14, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D0 + {PD_15, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D1 + {PD_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D2 + {PD_1, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D3 + {PE_7, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D4 + {PE_8, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D5 + {PE_9, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D6 + {PE_10, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D7 + {PE_11, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D8 + {PE_12, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D9 + {PE_13, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D10 + {PE_14, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D11 + {PE_15, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D12 + {PD_8, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D13 + {PD_9, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D14 + {PD_10, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D15 + {PF_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A0 + {PF_1, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A1 + {PF_2, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A2 + {PF_3, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A3 + {PF_4, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A4 + {PF_5, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A5 + {PF_12, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A6 + {PF_13, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A7 + {PF_14, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A8 + {PF_15, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A9 + {PG_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A10 + {PG_1, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A11 + {PG_2, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A12 + {NC, NP, 0} +}; + +const PinMap PinMap_QUADSPI[] = { + {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_CLK + {PB_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_NCS + {PF_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO3 + {PF_7, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO2 + {PF_8, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO0 + {PF_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO1 + {NC, NP, 0} +}; diff --git a/Marlin/src/HAL/STM32/timers.cpp b/Marlin/src/HAL/STM32/timers.cpp index e8e18a47d4..03353c2ca3 100644 --- a/Marlin/src/HAL/STM32/timers.cpp +++ b/Marlin/src/HAL/STM32/timers.cpp @@ -74,7 +74,7 @@ #elif defined(STM32F401xC) || defined(STM32F401xE) #define MCU_STEP_TIMER 9 #define MCU_TEMP_TIMER 10 -#elif defined(STM32F4xx) || defined(STM32F7xx) +#elif defined(STM32F4xx) || defined(STM32F7xx) || defined(STM32H7xx) #define MCU_STEP_TIMER 6 // STM32F401 has no TIM6, TIM7, or TIM8 #define MCU_TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used. #endif diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index d2e2236a14..beaea57354 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -390,6 +390,7 @@ #define BOARD_TEENSY41 5001 // Teensy 4.1 #define BOARD_T41U5XBB 5002 // T41U5XBB Teensy 4.1 breakout board #define BOARD_NUCLEO_F767ZI 5003 // ST NUCLEO-F767ZI Dev Board +#define BOARD_BTT_SKR_SE_BX 5004 // BigTreeTech SKR SE BX (STM32H743II) // // Espressif ESP32 WiFi diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 88bd382020..7ae1d8dccd 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1119,6 +1119,10 @@ #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY) #define TFT_RES_480x320 #define TFT_INTERFACE_FSMC +#elif ENABLED(BIQU_BX_TFT70) // RGB + #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY) + #define TFT_RES_1024x600 + #define TFT_INTERFACE_LTDC #elif ENABLED(TFT_GENERIC) #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) #if NONE(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320) @@ -1141,9 +1145,13 @@ #define TFT_WIDTH 480 #define TFT_HEIGHT 320 #define GRAPHICAL_TFT_UPSCALE 3 +#elif ENABLED(TFT_RES_1024x600) + #define TFT_WIDTH 1024 + #define TFT_HEIGHT 600 + #define GRAPHICAL_TFT_UPSCALE 4 #endif -// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h +// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi|ltdc).h #if ENABLED(TFT_INTERFACE_FSMC) #define HAS_FSMC_TFT 1 #if TFT_SCALED_DOGLCD @@ -1158,6 +1166,13 @@ #elif HAS_TFT_LVGL_UI #define HAS_TFT_LVGL_UI_SPI 1 #endif +#elif ENABLED(TFT_INTERFACE_LTDC) + #define HAS_LTDC_TFT 1 + #if TFT_SCALED_DOGLCD + #define HAS_LTDC_GRAPHICAL_TFT 1 + #elif HAS_TFT_LVGL_UI + #define HAS_TFT_LVGL_UI_LTDC 1 + #endif #endif #if ENABLED(TFT_COLOR_UI) @@ -1179,6 +1194,10 @@ #elif ENABLED(TFT_INTERFACE_FSMC) #define TFT_480x272 #endif + #elif TFT_HEIGHT == 600 + #if ENABLED(TFT_INTERFACE_LTDC) + #define TFT_1024x600_LTDC + #endif #endif #endif @@ -1188,9 +1207,13 @@ #define HAS_UI_480x320 1 #elif EITHER(TFT_480x272, TFT_480x272_SPI) #define HAS_UI_480x272 1 +#elif defined(TFT_1024x600_LTDC) + #define HAS_UI_1024x600 1 #endif #if ANY(HAS_UI_320x240, HAS_UI_480x320, HAS_UI_480x272) #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) // Fewer lines with touch buttons onscreen +#elif HAS_UI_1024x600 + #define LCD_HEIGHT TERN(TOUCH_SCREEN, 12, 13) // Fewer lines with touch buttons onscreen #endif // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 48a536b531..f6c5cc202a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2404,7 +2404,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #undef IS_EXTUI #undef IS_LEGACY_TFT -#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28, ANET_ET4_TFT28, ANET_ET5_TFT35) +#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28, ANET_ET4_TFT28, ANET_ET5_TFT35, BIQU_BX_TFT70) #if NONE(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI) #error "TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI is required for your TFT. Please enable one." #elif 1 < ENABLED(TFT_COLOR_UI) + ENABLED(TFT_CLASSIC_UI) + ENABLED(TFT_LVGL_UI) @@ -2426,16 +2426,16 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "Please enable only one LCD_SCREEN_ROT_* option: 0, 90, 180, or 270." #endif -#if MANY(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320) - #error "Please select only one of TFT_RES_480x320, TFT_RES_480x320, or TFT_RES_480x272." +#if MANY(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320, TFT_RES_1024x600) + #error "Please select only one of TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320, or TFT_RES_1024x600." #endif #if HAS_TFT_LVGL_UI && DISABLED(TFT_RES_480x320) #error "(FMSC|SPI)TFT_LVGL_UI requires TFT_RES_480x320." #endif -#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 3) - #error "GRAPHICAL_TFT_UPSCALE must be set to 2 or 3." +#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 4) + #error "GRAPHICAL_TFT_UPSCALE must be 2, 3, or 4." #endif /** diff --git a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp index 3842611fdf..682178efe5 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp @@ -55,14 +55,14 @@ #include "../../inc/MarlinConfig.h" -#if HAS_MARLINUI_U8GLIB && (PIN_EXISTS(FSMC_CS) || HAS_SPI_GRAPHICAL_TFT) +#if HAS_MARLINUI_U8GLIB && (PIN_EXISTS(FSMC_CS) || HAS_SPI_GRAPHICAL_TFT || HAS_LTDC_GRAPHICAL_TFT) #include "HAL_LCD_com_defines.h" #include "marlinui_DOGM.h" #include -#if EITHER(LCD_USE_DMA_FSMC, LCD_USE_DMA_SPI) +#if ANY(LCD_USE_DMA_FSMC, LCD_USE_DMA_SPI, HAS_LTDC_GRAPHICAL_TFT) #define HAS_LCD_IO 1 #endif diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp index 8321bd8bb5..dfc51d9505 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_view_screen.cpp @@ -55,7 +55,7 @@ constexpr static float gaugeThickness = 0.25; static float meshGetter(uint8_t x, uint8_t y, void*) { xy_uint8_t pos; pos.x = x; - pos.y = y; + pos.y = y; return ExtUI::getMeshPoint(pos); } diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index 99d335d135..1576518b4b 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -46,6 +46,9 @@ #elif HAS_UI_480x272 #define TFT_WIDTH 480 #define TFT_HEIGHT 272 +#elif HAS_UI_1024x600 + #define TFT_WIDTH 1024 + #define TFT_HEIGHT 600 #else #error "Unsupported display resolution!" #endif diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp new file mode 100644 index 0000000000..e04d589858 --- /dev/null +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -0,0 +1,927 @@ +/** + * 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_UI_1024x600 + +#include "ui_common.h" + +#include "../marlinui.h" +#include "../menu/menu.h" +#include "../../libs/numtostr.h" + +#include "../../sd/cardreader.h" +#include "../../module/temperature.h" +#include "../../module/printcounter.h" +#include "../../module/planner.h" +#include "../../module/motion.h" + +#if DISABLED(LCD_PROGRESS_BAR) && BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) + #include "../../feature/filwidth.h" + #include "../../gcode/parser.h" +#endif + +#if ENABLED(AUTO_BED_LEVELING_UBL) + #include "../../feature/bedlevel/bedlevel.h" +#endif + +void MarlinUI::tft_idle() { + #if ENABLED(TOUCH_SCREEN) + if (draw_menu_navigation) { + add_control(104, TFT_HEIGHT - 34, PAGE_UP, imgPageUp, encoderTopLine > 0); + add_control(344, TFT_HEIGHT - 34, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items); + add_control(224, TFT_HEIGHT - 34, BACK, imgBack); + draw_menu_navigation = false; + } + #endif + + tft.queue.async(); + TERN_(TOUCH_SCREEN, touch.idle()); +} + +#if ENABLED(SHOW_BOOTSCREEN) + void MarlinUI::show_bootscreen() { + tft.queue.reset(); + + tft.canvas(0, 0, TFT_WIDTH, TFT_HEIGHT); + #if ENABLED(BOOT_MARLIN_LOGO_SMALL) + #define BOOT_LOGO_W 195 // MarlinLogo195x59x16 + #define BOOT_LOGO_H 59 + #define SITE_URL_Y (TFT_HEIGHT - 70) + tft.set_background(COLOR_BACKGROUND); + #else + #define BOOT_LOGO_W TFT_WIDTH // MarlinLogo480x320x16 + #define BOOT_LOGO_H TFT_HEIGHT + #define SITE_URL_Y (TFT_HEIGHT - 90) + #endif + tft.add_image((TFT_WIDTH - BOOT_LOGO_W) / 2, (TFT_HEIGHT - BOOT_LOGO_H) / 2, imgBootScreen); + #ifdef WEBSITE_URL + tft_string.set(WEBSITE_URL); + tft.add_text(tft_string.center(TFT_WIDTH), SITE_URL_Y, COLOR_WEBSITE_URL, tft_string); + #endif + + tft.queue.sync(); + safe_delay(BOOTSCREEN_TIMEOUT); + clear_lcd(); + } +#endif + +void MarlinUI::draw_kill_screen() { + tft.queue.reset(); + tft.fill(0, 0, TFT_WIDTH, TFT_HEIGHT, COLOR_KILL_SCREEN_BG); + + uint16_t line = 2; + + menu_line(line++, COLOR_KILL_SCREEN_BG); + tft_string.set(status_message); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); + + line++; + menu_line(line++, COLOR_KILL_SCREEN_BG); + tft_string.set(GET_TEXT(MSG_HALTED)); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); + + menu_line(line++, COLOR_KILL_SCREEN_BG); + tft_string.set(GET_TEXT(MSG_PLEASE_RESET)); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); + + tft.queue.sync(); +} + +void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { + MarlinImage image = imgHotEnd; + uint16_t Color; + celsius_t currentTemperature, targetTemperature; + + if (Heater >= 0) { // HotEnd + currentTemperature = thermalManager.degHotend(Heater); + targetTemperature = thermalManager.degTargetHotend(Heater); + } + #if HAS_HEATED_BED + else if (Heater == H_BED) { + currentTemperature = thermalManager.degBed(); + targetTemperature = thermalManager.degTargetBed(); + } + #endif + #if HAS_TEMP_CHAMBER + else if (Heater == H_CHAMBER) { + currentTemperature = thermalManager.degChamber(); + #if HAS_HEATED_CHAMBER + targetTemperature = thermalManager.degTargetChamber(); + #else + targetTemperature = ABSOLUTE_ZERO; + #endif + } + #endif + #if HAS_TEMP_COOLER + else if (Heater == H_COOLER) { + currentTemperature = thermalManager.degCooler(); + targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO); + } + #endif + else return; + + TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 80, 120, Heater)); + tft.canvas(x, y, 80, 120); + tft.set_background(COLOR_BACKGROUND); + + Color = currentTemperature < 0 ? COLOR_INACTIVE : COLOR_COLD; + + if (Heater >= 0) { // HotEnd + if (currentTemperature >= 50) Color = COLOR_HOTEND; + } + #if HAS_HEATED_BED + else if (Heater == H_BED) { + if (currentTemperature >= 50) Color = COLOR_HEATED_BED; + image = targetTemperature > 0 ? imgBedHeated : imgBed; + } + #endif + #if HAS_TEMP_CHAMBER + else if (Heater == H_CHAMBER) { + if (currentTemperature >= 50) Color = COLOR_CHAMBER; + image = targetTemperature > 0 ? imgChamberHeated : imgChamber; + } + #endif + + tft.add_image(8, 28, image, Color); + + tft_string.set((uint8_t *)i16tostr3rj(currentTemperature)); + tft_string.add(LCD_STR_DEGREE); + tft_string.trim(); + tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string); + + if (targetTemperature >= 0) { + tft_string.set((uint8_t *)i16tostr3rj(targetTemperature)); + tft_string.add(LCD_STR_DEGREE); + tft_string.trim(); + tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string); + } +} + +void draw_fan_status(uint16_t x, uint16_t y, const bool blink) { + TERN_(TOUCH_SCREEN, touch.add_control(FAN, x, y, 80, 120)); + tft.canvas(x, y, 80, 120); + tft.set_background(COLOR_BACKGROUND); + + uint8_t fanSpeed = thermalManager.fan_speed[0]; + MarlinImage image; + + if (fanSpeed >= 127) + image = blink ? imgFanFast1 : imgFanFast0; + else if (fanSpeed > 0) + image = blink ? imgFanSlow1 : imgFanSlow0; + else + image = imgFanIdle; + + tft.add_image(8, 20, image, COLOR_FAN); + + tft_string.set((uint8_t *)ui8tostr4pctrj(thermalManager.fan_speed[0])); + tft_string.trim(); + tft.add_text(tft_string.center(80) + 6, 82, COLOR_FAN, tft_string); +} + +void MarlinUI::draw_status_screen() { + const bool blink = get_blink(); + + TERN_(TOUCH_SCREEN, touch.clear()); + + // heaters and fan + uint16_t i, x, y = TFT_STATUS_TOP_Y; + + for (i = 0 ; i < ITEMS_COUNT; i++) { + x = (TFT_WIDTH / ITEMS_COUNT - 80) / 2 + (TFT_WIDTH * i / ITEMS_COUNT); + switch (i) { + #ifdef ITEM_E0 + case ITEM_E0: draw_heater_status(x, y, H_E0); break; + #endif + #ifdef ITEM_E1 + case ITEM_E1: draw_heater_status(x, y, H_E1); break; + #endif + #ifdef ITEM_E2 + case ITEM_E2: draw_heater_status(x, y, H_E2); break; + #endif + #ifdef ITEM_BED + case ITEM_BED: draw_heater_status(x, y, H_BED); break; + #endif + #ifdef ITEM_CHAMBER + case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break; + #endif + #ifdef ITEM_FAN + case ITEM_FAN: draw_fan_status(x, y, blink); break; + #endif + } + } + + y += 200; + + // coordinates + tft.canvas(4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft.add_rectangle(0, 0, TFT_WIDTH - 8, FONT_LINE_HEIGHT, COLOR_AXIS_HOMED); + + tft.add_text(200, 3, COLOR_AXIS_HOMED , "X"); + tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y"); + tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z"); + + bool not_homed = axis_should_home(X_AXIS); + tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x))); + tft.add_text(300 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + + not_homed = axis_should_home(Y_AXIS); + tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y))); + tft.add_text(600 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + + uint16_t offset = 32; + not_homed = axis_should_home(Z_AXIS); + if (blink && not_homed) + tft_string.set("?"); + else { + const float z = LOGICAL_Z_POSITION(current_position.z); + tft_string.set(ftostr52sp((int16_t)z)); + tft_string.rtrim(); + offset += tft_string.width(); + + tft_string.set(ftostr52sp(z)); + offset -= tft_string.width(); + } + tft.add_text(900 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT)); + + y += 100; + // feed rate + tft.canvas(274, y, 100, 32); + tft.set_background(COLOR_BACKGROUND); + uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; + tft.add_image(0, 0, imgFeedRate, color); + tft_string.set(i16tostr3rj(feedrate_percentage)); + tft_string.add('%'); + tft.add_text(36, 1, color , tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 96, 176, 100, 32)); + + // flow rate + tft.canvas(650, y, 100, 32); + tft.set_background(COLOR_BACKGROUND); + color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED; + tft.add_image(0, 0, imgFlowRate, color); + tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder])); + tft_string.add('%'); + tft.add_text(36, 1, color , tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 284, 176, 100, 32, active_extruder)); + + #if ENABLED(TOUCH_SCREEN) + add_control(404, y, menu_main, imgSettings); + TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED)); + #endif + + y += 100; + // print duration + char buffer[14]; + duration_t elapsed = print_job_timer.duration(); + elapsed.toDigital(buffer); + + tft.canvas((TFT_WIDTH - 128) / 2, y, 128, 29); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(buffer); + tft.add_text(tft_string.center(128), 0, COLOR_PRINT_TIME, tft_string); + + y += 50; + // progress bar + const uint8_t progress = ui.get_progress_percent(); + tft.canvas(4, y, TFT_WIDTH - 8, 9); + tft.set_background(COLOR_PROGRESS_BG); + tft.add_rectangle(0, 0, TFT_WIDTH - 8, 9, COLOR_PROGRESS_FRAME); + if (progress) + tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR); + + y += 50; + // status message + tft.canvas(0, y, TFT_WIDTH, FONT_LINE_HEIGHT - 5); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(status_message); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_STATUS_MESSAGE, tft_string); +} + +// Low-level draw_edit_screen can be used to draw an edit screen from anyplace +void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { + ui.encoder_direction_normal(); + TERN_(TOUCH_SCREEN, touch.clear()); + + uint16_t line = 1; + + menu_line(line++); + tft_string.set(pstr, itemIndex, itemString); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); + + TERN_(AUTO_BED_LEVELING_UBL, if (ui.external_control) line++); // ftostr52() will overwrite *value so *value has to be displayed first + + menu_line(line); + tft_string.set(value); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + + #if ENABLED(AUTO_BED_LEVELING_UBL) + if (ui.external_control) { + menu_line(line - 1); + + tft_string.set(X_LBL); + tft.add_text((TFT_WIDTH / 2 - 120), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); + tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.x))); + tft_string.trim(); + tft.add_text((TFT_WIDTH / 2 - 16) - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + + tft_string.set(Y_LBL); + tft.add_text((TFT_WIDTH / 2 + 16), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); + tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.y))); + tft_string.trim(); + tft.add_text((TFT_WIDTH / 2 + 120) - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + } + #endif + + extern screenFunc_t _manual_move_func_ptr; + if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) { + + #define SLIDER_LENGTH 336 + #define SLIDER_Y_POSITION 186 + + tft.canvas((TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION, SLIDER_LENGTH, 16); + tft.set_background(COLOR_BACKGROUND); + + int16_t position = (SLIDER_LENGTH - 2) * ui.encoderPosition / maxEditValue; + tft.add_bar(0, 7, 1, 2, ui.encoderPosition == 0 ? COLOR_SLIDER_INACTIVE : COLOR_SLIDER); + tft.add_bar(1, 6, position, 4, COLOR_SLIDER); + tft.add_bar(position + 1, 6, SLIDER_LENGTH - 2 - position, 4, COLOR_SLIDER_INACTIVE); + tft.add_bar(SLIDER_LENGTH - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE); + + #if ENABLED(TOUCH_SCREEN) + tft.add_image((SLIDER_LENGTH - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER); + touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGTH, 32, maxEditValue); + #endif + } + + tft.draw_edit_screen_buttons(); +} + +void TFT::draw_edit_screen_buttons() { + #if ENABLED(TOUCH_SCREEN) + add_control(64, TFT_HEIGHT - 64, DECREASE, imgDecrease); + add_control(352, TFT_HEIGHT - 64, INCREASE, imgIncrease); + add_control(208, TFT_HEIGHT - 64, CLICK, imgConfirm); + #endif +} + +// The Select Screen presents a prompt and two "buttons" +void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { + uint16_t line = 1; + + if (!string) line++; + + menu_line(line++); + tft_string.set(pref); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); + + if (string) { + menu_line(line++); + tft_string.set(string); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); + } + + if (suff) { + menu_line(line); + tft_string.set(suff); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); + } + #if ENABLED(TOUCH_SCREEN) + add_control(88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); + add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); + #else + menu_line(++line); + if (no) { + tft_string.set(no); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH / 2), 0, !yesno ? COLOR_RED : COLOR_MENU_TEXT, tft_string); + } + + if (yes) { + tft_string.set(yes); + tft_string.trim(); + tft.add_text(TFT_WIDTH / 2 + tft_string.center(TFT_WIDTH / 2), 0, yesno ? COLOR_RED : COLOR_MENU_TEXT, tft_string); + } + #endif +} + +#if ENABLED(ADVANCED_PAUSE_FEATURE) + + void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) { + #if ENABLED(TOUCH_SCREEN) + touch.clear(); + draw_menu_navigation = false; + touch.add_control(RESUME_CONTINUE , 0, 0, TFT_WIDTH, TFT_HEIGHT); + #endif + + menu_line(row); + tft_string.set(GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE)); + tft_string.add('E'); + tft_string.add((char)('1' + extruder)); + tft_string.add(' '); + tft_string.add(i16tostr3rj(thermalManager.degHotend(extruder))); + tft_string.add(LCD_STR_DEGREE); + tft_string.add(" / "); + tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder))); + tft_string.add(LCD_STR_DEGREE); + tft_string.trim(); + tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); + } + +#endif // ADVANCED_PAUSE_FEATURE + +#if ENABLED(AUTO_BED_LEVELING_UBL) + #define GRID_OFFSET_X 8 + #define GRID_OFFSET_Y 8 + #define GRID_WIDTH 192 + #define GRID_HEIGHT 192 + #define CONTROL_OFFSET 16 + + void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) { + + tft.canvas(GRID_OFFSET_X, GRID_OFFSET_Y, GRID_WIDTH, GRID_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE); + + for (uint16_t x = 0; x < GRID_MAX_POINTS_X ; x++) + for (uint16_t y = 0; y < GRID_MAX_POINTS_Y ; y++) + if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) })) + tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 2, 2, COLOR_UBL); + + tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 6, 6, COLOR_UBL); + + const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, + lpos = pos.asLogical(); + + tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(X_LBL); + tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); + tft_string.set(ftostr52(lpos.x)); + tft_string.trim(); + tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + + tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, 120, MENU_ITEM_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(Y_LBL); + tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); + tft_string.set(ftostr52(lpos.y)); + tft_string.trim(); + tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + + tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 + MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(Z_LBL); + tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); + tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.trim(); + tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + + constexpr uint8_t w = (TFT_WIDTH) / 10; + tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - w) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 5, w, MENU_ITEM_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(ui8tostr3rj(x_plot)); + tft_string.trim(); + tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + + tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET + 16 - 24, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, w, MENU_ITEM_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(ui8tostr3rj(y_plot)); + tft_string.trim(); + tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + + #if ENABLED(TOUCH_SCREEN) + touch.clear(); + draw_menu_navigation = false; + add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgUp); + add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT - CONTROL_OFFSET - 32, UBL, - ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgDown); + add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft); + add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM, imgRight); + add_control(320, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling); + add_control(224, TFT_HEIGHT - 34, BACK, imgBack); + #endif + } +#endif // AUTO_BED_LEVELING_UBL + +#if ENABLED(BABYSTEP_ZPROBE_OFFSET) + #include "../../feature/babystep.h" +#endif + +#if HAS_BED_PROBE + #include "../../module/probe.h" +#endif + +#define Z_SELECTION_Z 1 +#define Z_SELECTION_Z_PROBE -1 + +struct MotionAxisState { + xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; + float currentStepSize = 10.0; + int z_selection = Z_SELECTION_Z; + uint8_t e_selection = 0; + bool homming = false; + bool blocked = false; + char message[32]; +}; + +MotionAxisState motionAxisState; + +#define E_BTN_COLOR COLOR_YELLOW +#define X_BTN_COLOR COLOR_CORAL_RED +#define Y_BTN_COLOR COLOR_VIVID_GREEN +#define Z_BTN_COLOR COLOR_LIGHT_BLUE + +#define BTN_WIDTH 64 +#define BTN_HEIGHT 52 +#define X_MARGIN 20 +#define Y_MARGIN 15 + +static void quick_feedback() { + #if HAS_CHIRP + ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? + #if BOTH(HAS_LCD_MENU, USE_BEEPER) + for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } + #elif HAS_LCD_MENU + delay(10); + #endif + #endif +} + +#define CUR_STEP_VALUE_WIDTH 104 +static void drawCurStepValue() { + tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize)); + tft_string.add("mm"); + tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string); +} + +static void drawCurZSelection() { + tft_string.set("Z"); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + tft.queue.sync(); + tft_string.set("Offset"); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34); + tft.set_background(COLOR_BACKGROUND); + if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + } +} + +static void drawCurESelection() { + tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set("E"); + tft.add_text(0, 0, E_BTN_COLOR , tft_string); + tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); +} + +static void drawMessage(const char *msg) { + tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(0, 0, COLOR_YELLOW, msg); +} + +static void drawAxisValue(AxisEnum axis) { + const float value = + #if HAS_BED_PROBE + axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? + probe.offset.z : + #endif + NATIVE_TO_LOGICAL( + ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset), + axis + ); + xy_int_t pos; + uint16_t color; + switch (axis) { + case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; + case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; + case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; + case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + default: return; + } + tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(ftostr52sp(value)); + tft.add_text(0, 0, color, tft_string); +} + +static void moveAxis(AxisEnum axis, const int8_t direction) { + quick_feedback(); + + if (axis == E_AXIS && thermalManager.temp_hotend[motionAxisState.e_selection].celsius < EXTRUDE_MINTEMP) { + drawMessage("Too cold"); + return; + } + + const float diff = motionAxisState.currentStepSize * direction; + + if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) + const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; + const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; + const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment, + new_probe_offset = probe.offset.z + bsDiff, + new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET + , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff + , new_probe_offset + ); + if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + babystep.add_steps(Z_AXIS, babystep_increment); + if (do_probe) + probe.offset.z = new_offs; + else + TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); + drawMessage(""); // clear the error + drawAxisValue(axis); + } + else { + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + #elif HAS_BED_PROBE + // only change probe.offset.z + probe.offset.z += diff; + if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + else { + drawMessage(""); // clear the error + } + drawAxisValue(axis); + #endif + return; + } + + if (!ui.manual_move.processing) { + // Get motion limit from software endstops, if any + float min, max; + soft_endstop.get_manual_axis_limits(axis, min, max); + + // Delta limits XY based on the current offset from center + // This assumes the center is 0,0 + #if ENABLED(DELTA) + if (axis != Z_AXIS && axis != E_AXIS) { + max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis + min = -max; + } + #endif + + // Get the new position + #if IS_KINEMATIC + ui.manual_move.offset += diff; + if (direction < 0) + NOLESS(ui.manual_move.offset, min - current_position[axis]); + else + NOMORE(ui.manual_move.offset, max - current_position[axis]); + #else + current_position[axis] += diff; + const char *msg = NUL_STR; // clear the error + if (direction < 0 && current_position[axis] < min) { + current_position[axis] = min; + msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS); + } + else if (direction > 0 && current_position[axis] > max) { + current_position[axis] = max; + msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS); + } + drawMessage(msg); + #endif + + ui.manual_move.soon(axis + #if MULTI_MANUAL + , motionAxisState.e_selection + #endif + ); + } + + drawAxisValue(axis); +} + +static void e_plus() { moveAxis(E_AXIS, 1); } +static void e_minus() { moveAxis(E_AXIS, -1); } +static void x_minus() { moveAxis(X_AXIS, -1); } +static void x_plus() { moveAxis(X_AXIS, 1); } +static void y_plus() { moveAxis(Y_AXIS, 1); } +static void y_minus() { moveAxis(Y_AXIS, -1); } +static void z_plus() { moveAxis(Z_AXIS, 1); } +static void z_minus() { moveAxis(Z_AXIS, -1); } + +#if ENABLED(TOUCH_SCREEN) + static void e_select() { + motionAxisState.e_selection++; + if (motionAxisState.e_selection >= EXTRUDERS) { + motionAxisState.e_selection = 0; + } + + quick_feedback(); + drawCurESelection(); + drawAxisValue(E_AXIS); + } + + static void do_home() { + quick_feedback(); + drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING)); + queue.inject_P(G28_STR); + // Disable touch until home is done + TERN_(HAS_TFT_XPT2046, touch.disable()); + drawAxisValue(E_AXIS); + drawAxisValue(X_AXIS); + drawAxisValue(Y_AXIS); + drawAxisValue(Z_AXIS); + } + + static void step_size() { + motionAxisState.currentStepSize = motionAxisState.currentStepSize / 10.0; + if (motionAxisState.currentStepSize < 0.0015) motionAxisState.currentStepSize = 10.0; + quick_feedback(); + drawCurStepValue(); + } +#endif + +#if HAS_BED_PROBE + static void z_select() { + motionAxisState.z_selection *= -1; + quick_feedback(); + drawCurZSelection(); + drawAxisValue(Z_AXIS); + } +#endif + +static void disable_steppers() { + quick_feedback(); + queue.inject_P(PSTR("M84")); +} + +static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { + uint16_t width = Images[imgBtn52Rounded].width; + uint16_t height = Images[imgBtn52Rounded].height; + + if (!enabled) bgColor = COLOR_CONTROL_DISABLED; + + tft.canvas(x, y, width, height); + tft.set_background(COLOR_BACKGROUND); + tft.add_image(0, 0, imgBtn52Rounded, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); + + // TODO: Make an add_text() taking a font arg + if (label) { + tft_string.set(label); + tft_string.trim(); + tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string); + } + else { + tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); + } + + TERN_(HAS_TFT_XPT2046, if (enabled) touch.add_control(BUTTON, x, y, width, height, data)); +} + +void MarlinUI::move_axis_screen() { + // Reset + defer_status_screen(true); + motionAxisState.blocked = false; + TERN_(HAS_TFT_XPT2046, touch.enable()); + + ui.clear_lcd(); + + TERN_(TOUCH_SCREEN, touch.clear()); + + const bool busy = printingIsActive(); + + // Babysteps during printing? Select babystep for Z probe offset + if (busy && ENABLED(BABYSTEP_ZPROBE_OFFSET)) + motionAxisState.z_selection = Z_SELECTION_Z_PROBE; + + // ROW 1 -> E- Y- CurY Z+ + int x = X_MARGIN, y = Y_MARGIN, spacing = 0; + + drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy); + + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy); + + // Cur Y + x += BTN_WIDTH; + motionAxisState.yValuePos.x = x + 2; + motionAxisState.yValuePos.y = y; + drawAxisValue(Y_AXIS); + + x += spacing; + drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + + // ROW 2 -> "Ex" X- HOME X+ "Z" + y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; + x = X_MARGIN; + spacing = (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; + + motionAxisState.eNamePos.x = x; + motionAxisState.eNamePos.y = y; + drawCurESelection(); + TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; //imgHome is 64x64 + TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); + + x += BTN_WIDTH + spacing; + uint16_t xplus_x = x; + drawBtn(x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + motionAxisState.zTypePos.x = x; + motionAxisState.zTypePos.y = y; + drawCurZSelection(); + #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) + if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); + #endif + + // ROW 3 -> E- CurX Y- Z- + y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; + x = X_MARGIN; + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + + drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + + // Cur E + motionAxisState.eValuePos.x = x; + motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(E_AXIS); + + // Cur X + motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos + motionAxisState.xValuePos.y = y - 10; + drawAxisValue(X_AXIS); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + + // Cur Z + motionAxisState.zValuePos.x = x; + motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(Z_AXIS); + + // ROW 4 -> step_size disable steppers back + y = TFT_HEIGHT - Y_MARGIN - 32; // + x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2; + motionAxisState.stepValuePos.x = x; + motionAxisState.stepValuePos.y = y; + if (!busy) { + drawCurStepValue(); + TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); + } + + // aligned with x+ + drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); + + TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); +} + +#undef BTN_WIDTH +#undef BTN_HEIGHT + +#endif // HAS_UI_480x320 diff --git a/Marlin/src/lcd/tft/ui_1024x600.h b/Marlin/src/lcd/tft/ui_1024x600.h new file mode 100644 index 0000000000..dd8c1cc6ec --- /dev/null +++ b/Marlin/src/lcd/tft/ui_1024x600.h @@ -0,0 +1,43 @@ +/** + * 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 MARLIN_LOGO_FULL_SIZE MarlinLogo480x320x16 + +#include "ui_common.h" + +#define TFT_STATUS_TOP_Y 4 +#define TFT_TOP_LINE_Y 4 + +#define MENU_TEXT_X_OFFSET 16 +#define MENU_TEXT_Y_OFFSET 7 + +#define MENU_ITEM_ICON_X 5 +#define MENU_ITEM_ICON_Y 5 +#define MENU_ITEM_ICON_SPACE 42 + +#define MENU_FONT_NAME Helvetica18 +#define SYMBOLS_FONT_NAME Helvetica18_symbols +#define MENU_ITEM_HEIGHT 43 +#define FONT_LINE_HEIGHT 34 + +#define MENU_LINE_HEIGHT (MENU_ITEM_HEIGHT + 2) diff --git a/Marlin/src/lcd/tft/ui_common.h b/Marlin/src/lcd/tft/ui_common.h index d43de1d43b..617447a181 100644 --- a/Marlin/src/lcd/tft/ui_common.h +++ b/Marlin/src/lcd/tft/ui_common.h @@ -39,6 +39,10 @@ #include "ui_320x240.h" #elif HAS_UI_480x320 || HAS_UI_480x272 #include "ui_480x320.h" +#elif HAS_UI_1024x600 + #include "ui_1024x600.h" +#else + #error "Unsupported display resolution!" #endif void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater); diff --git a/Marlin/src/lcd/tft_io/tft_io.cpp b/Marlin/src/lcd/tft_io/tft_io.cpp index cd535458a1..fa81d95a4d 100644 --- a/Marlin/src/lcd/tft_io/tft_io.cpp +++ b/Marlin/src/lcd/tft_io/tft_io.cpp @@ -22,7 +22,7 @@ #include "tft_io.h" -#if HAS_SPI_TFT || HAS_FSMC_TFT +#if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT #include "st7735.h" #include "st7789v.h" @@ -90,6 +90,8 @@ if (lcd_id != 0xFFFFFFFF) return; lcd_id = io.GetID() & 0xFFFF; switch (lcd_id) { + case LTDC_RGB: + break; case ST7796: // ST7796S 480x320 DEBUG_ECHO_MSG(" ST7796S"); write_esc_sequence(st7796s_init); @@ -144,6 +146,17 @@ void TFT_IO::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ym #endif switch (lcd_id) { + case LTDC_RGB: + io.WriteReg(0x01); + io.WriteData(Xmin); + io.WriteReg(0x02); + io.WriteData(Xmax); + io.WriteReg(0x03); + io.WriteData(Ymin); + io.WriteReg(0x04); + io.WriteData(Ymax); + io.WriteReg(0x00); + break; case ST7735: // ST7735 160x128 case ST7789: // ST7789V 320x240 case ST7796: // ST7796 480x320 diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index 2456358571..846b45e8e0 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -23,14 +23,16 @@ #include "../../inc/MarlinConfig.h" -#if HAS_SPI_TFT || HAS_FSMC_TFT +#if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT #if HAS_SPI_TFT #include HAL_PATH(../../HAL, tft/tft_spi.h) #elif HAS_FSMC_TFT #include HAL_PATH(../../HAL, tft/tft_fsmc.h) +#elif HAS_LTDC_TFT + #include HAL_PATH(../../HAL, tft/tft_ltdc.h) #else - #error "TFT IO only supports SPI or FSMC interface" + #error "TFT IO only supports SPI, FSMC or LTDC interface" #endif #define TFT_EXCHANGE_XY (1UL << 1) @@ -91,6 +93,7 @@ #define TOUCH_ORIENTATION TOUCH_LANDSCAPE #endif +#define LTDC_RGB 0xABAB #define SSD1963 0x5761 #define ST7735 0x89F0 #define ST7789 0x8552 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index e4c692a3b9..7634d49199 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -631,6 +631,8 @@ #include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:REMRAM_V1 #elif MB(NUCLEO_F767ZI) #include "stm32f7/pins_NUCLEO_F767ZI.h" // STM32F7 env:NUCLEO_F767ZI +#elif MB(BTT_SKR_SE_BX) + #include "stm32h7/pins_BTT_SKR_SE_BX.h" // STM32H7 env:BTT_SKR_SE_BX #elif MB(TEENSY41) #include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41 #elif MB(T41U5XBB) diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h new file mode 100644 index 0000000000..320d04e0b1 --- /dev/null +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h @@ -0,0 +1,226 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(STM32H7) + #error "Oops! Select an STM32H7 board in 'Tools > Board.'" +#endif + +#define BOARD_INFO_NAME "BTT SKR SE BX" +#define DEFAULT_MACHINE_NAME "BIQU-BX" + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (24C32 ... 32Kb = 4KB) + +// USB Flash Drive support +#define HAS_OTG_USB_HOST_SUPPORT + +// +// Limit Switches +// +#define X_MIN_PIN PB11 +#define X_MAX_PIN PD13 +#define Y_MIN_PIN PB12 +#define Y_MAX_PIN PB13 +#define Z_MIN_PIN PD12 +#define Z_MAX_PIN PD11 + +#define FIL_RUNOUT_PIN PD13 +#define FIL_RUNOUT2_PIN PB13 + +#define LED_PIN PA13 +#define BEEPER_PIN PA14 + +#define TFT_BACKLIGHT_PIN PB5 + +#define POWER_MONITOR_PIN PB0 +#define RPI_POWER_PIN PE5 + +#define SAFE_POWER_PIN PI11 +#define SERVO0_PIN PA2 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PH2 // Probe +#endif + +// +// Steppers +// +#define X_STEP_PIN PG13 +#define X_DIR_PIN PG12 +#define X_ENABLE_PIN PG14 +#define X_CS_PIN PG10 + +#define Y_STEP_PIN PB3 +#define Y_DIR_PIN PD3 +#define Y_ENABLE_PIN PB4 +#define Y_CS_PIN PD4 + +#define Z_STEP_PIN PD7 +#define Z_DIR_PIN PD6 +#define Z_ENABLE_PIN PG9 +#define Z_CS_PIN PD5 + +#define E0_STEP_PIN PC14 +#define E0_DIR_PIN PC13 +#define E0_ENABLE_PIN PC15 +#define E0_CS_PIN PI8 + +#define E1_STEP_PIN PA8 +#define E1_DIR_PIN PC9 +#define E1_ENABLE_PIN PD2 +#define E1_CS_PIN PC8 + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PC6 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PG3 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PC7 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + //#define E5_HARDWARE_SERIAL Serial1 + //#define E6_HARDWARE_SERIAL Serial1 + //#define E7_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + #define X_SERIAL_TX_PIN PG10 + #define X_SERIAL_RX_PIN PG10 + + #define Y_SERIAL_TX_PIN PD4 + #define Y_SERIAL_RX_PIN PD4 + + #define Z_SERIAL_TX_PIN PD5 + #define Z_SERIAL_RX_PIN PD5 + + #define E0_SERIAL_TX_PIN PI8 + #define E0_SERIAL_RX_PIN PI8 + + #define E1_SERIAL_TX_PIN PC8 + #define E1_SERIAL_RX_PIN PC8 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PH4 // TH0 +#define TEMP_1_PIN PA3 // TH1 +#define TEMP_BED_PIN PH5 // TB + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC4 +#define HEATER_1_PIN PC5 +#define HEATER_BED_PIN PA4 + +#define FAN_PIN PA5 // "FAN0" +#define FAN1_PIN PA6 // "FAN1" +#define FAN2_PIN PA7 // "FAN2" + +#define NEOPIXEL_PIN PH3 +#define NEOPIXEL2_PIN PB1 + +#if HAS_LTDC_TFT + + // LTDC_LCD Timing + #define LTDC_LCD_CLK 50 // LTDC clock frequency = 50Mhz + #define LTDC_LCD_HSYNC 30 // Horizontal synchronization + #define LTDC_LCD_HBP 114 // Horizontal back porch + #define LTDC_LCD_HFP 16 // Horizontal front porch + #define LTDC_LCD_VSYNC 3 // Vertical synchronization + #define LTDC_LCD_VBP 32 // Vertical back porch + #define LTDC_LCD_VFP 10 // Vertical front porch + + #define TFT_BACKLIGHT_PIN PB5 + #define LCD_DE_PIN PF10 + #define LCD_CLK_PIN PG7 + #define LCD_VSYNC_PIN PI9 + #define LCD_HSYNC_PIN PI10 + #define LCD_R7_PIN PG6 // R5 + #define LCD_R6_PIN PH12 + #define LCD_R5_PIN PH11 + #define LCD_R4_PIN PH10 + #define LCD_R3_PIN PH9 + #define LCD_G7_PIN PI2 // G6 + #define LCD_G6_PIN PI1 + #define LCD_G5_PIN PI0 + #define LCD_G4_PIN PH15 + #define LCD_G3_PIN PH14 + #define LCD_G2_PIN PH13 + #define LCD_B7_PIN PI7 // B5 + #define LCD_B6_PIN PI6 + #define LCD_B5_PIN PI5 + #define LCD_B4_PIN PI4 + #define LCD_B3_PIN PG11 + +#endif + +#define BTN_EN1 PH6 +#define BTN_EN2 PH7 +#define BTN_ENC PH8 + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define SOFTWARE_SPI +#define SDSS PA15 +#define SS_PIN SDSS +#define SD_SCK_PIN PC10 +#define SD_MISO_PIN PC11 +#define SD_MOSI_PIN PC12 +#define SD_DETECT_PIN PI3 diff --git a/buildroot/share/PlatformIO/boards/BTT_SKR_SE_BX.json b/buildroot/share/PlatformIO/boards/BTT_SKR_SE_BX.json new file mode 100644 index 0000000000..920b2478a9 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/BTT_SKR_SE_BX.json @@ -0,0 +1,56 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m7", + "extra_flags": "-DSTM32H743xx", + "f_cpu": "400000000L", + "mcu": "stm32h743iit6", + "variant": "BTT_SKR_SE_BX" + }, + "debug": { + "jlink_device": "STM32H743II", + "openocd_target": "stm32h7x", + "svd_path": "STM32H7x3.svd", + "tools": { + "stlink": { + "server": { + "arguments": [ + "-f", + "scripts/interface/stlink.cfg", + "-c", + "transport select hla_swd", + "-f", + "scripts/target/stm32h7x.cfg", + "-c", + "reset_config none" + ], + "executable": "bin/openocd", + "package": "tool-openocd" + } + } + } + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32H743II (1024k RAM. 2048k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 1048576, + "maximum_size": 2097152, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink", + "cmsis-dap" + ], + "offset_address": "0x8020000", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32h743ii.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c new file mode 100644 index 0000000000..3defef5fbf --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c @@ -0,0 +1,491 @@ +/* + ******************************************************************************* + * Copyright (c) 2019, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + * Automatically generated from STM32H743ZITx.xml + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Note: Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_INP15 + {PH_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_INP15 + {PH_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC3_INP16 + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_INP16 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, // ADC1_INP17 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_INP14 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC1_INP18 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC1_INP19 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_INP3 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_INP7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_INP9 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_INP5 + {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_INP10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_INN10 + {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_INN0 + {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_INP1 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_INP4 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_INP8 + {PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_INP5 + {PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_INP9 + {PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_INP4 + {PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_INP8 + {PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_INP3 + {PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_INP7 + {PF_9, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_INP2 + {PF_10, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_INP6 + {PF_11, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_INP2 + {PF_12, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_INP6 + {PF_13, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_INP2 + {PF_14, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_INP6 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +WEAK const PinMap PinMap_DAC[] = { + {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC1_OUT1 + {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + // {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // LD2 LED_BLUE (ZI) + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_7, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, // LD2 LED_BLUE (ZI) + // {PB_9, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PD_13, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {PF_0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PF_15, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // USB SOF + // {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // QSPI_CS + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_6, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, // QSPI_CS + // {PB_8, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PD_12, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {PF_1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PF_14, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_PWM[] = { + // {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - ETH RMII Ref Clk + // {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - ETH RMII Ref Clk + // {PA_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N - ETH RMII Ref Clk + // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - ETH RMII MDIO + {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - ETH RMII MDIO + // {PA_2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1 - ETH RMII MDIO + // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + // {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + {PA_3, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 + // {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - Used by ETH when JP6(ZI)/SB31(ZI2) ON + // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - Used by ETH when JP6(ZI)/SB31(ZI2) ON + // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - Used by ETH when JP6(ZI)/SB31(ZI2) ON + {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - Used by ETH when JP6(ZI)/SB31(ZI2) ON + // {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - USB SOF + // {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - USB VBUS + // {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - USB ID + // {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - USB DM + // {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - LD1 LED_GREEN + // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - LD1 LED_GREEN + // {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - LD1 LED_GREEN + // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + // {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + // {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - SWO + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PB_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N + // {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - LD2 LED_BLUE (ZI) + {PB_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N - LD2 LED_BLUE (ZI) + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + // {PB_8, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 + // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_CH1 + // {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + // {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + // {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - Used by ETH when JP7(ZI)/JP6(ZI2) ON + {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - LD3 LED_RED + // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - LD3 LED_RED + // {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 1, 0)}, // TIM12_CH1 - LD3 LED_RED + // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + // {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 2, 0)}, // TIM12_CH2 + // {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + // {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + // {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PE_4, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {PE_5, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1 + {PE_6, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 + {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PF_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 + {PF_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_CH1 + {PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + // {PF_8, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N + {PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + // {PF_9, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // ETH RMII MDIO + // {PA_9, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB VBUS + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB VBUS + // {PA_12, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // USB DP + //{PA_15, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + //{PB_4, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + // {PB_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, + // {PB_6, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_9, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PB_13, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON + // {PB_14, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, // LD3 LED_RED + //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + //{PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // STLink TX + //{PE_1, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, //LD2 LED_YELLOW (ZI2) + //{PE_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + //{PF_7, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + //{PG_14, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // ETH RMII Ref Clk + // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // USB SOF + // {PA_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB ID + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB ID + // {PA_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // USB DM + //{PB_3, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // SWO + //{PB_5, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + // {PB_7, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, // LD2 LED_BLUE (ZI) + // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // LD2 LED_BLUE (ZI) + //{PB_8, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PB_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + //{PB_15, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + //{PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PD_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // STLink RX + //{PE_0, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + //{PE_7, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + //{PF_6, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + //{PG_9, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RTS[] = { + // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // ETH RMII Ref Clk + // {PA_12, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB DP + // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB DP + {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_14, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // LD3 LED_RED + // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // LD3 LED_RED + {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_15, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_9, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PF_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PG_8, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PG_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_CTS[] = { + {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB DM + // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB DM + // {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // LD1 LED_GREEN + // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON + {PB_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_14, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_10, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PF_9, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + // {PG_13, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PG_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // Used by ETH when JP6(ZI)/SB31(ZI2) ON + // {PA_7, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, // Used by ETH when JP6(ZI)/SB31(ZI2) ON + // {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // // {PB_5, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // // {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // ETH RMII MDC + // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + // {PD_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PF_9, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + // {PF_11, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + // {PG_14, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // // {PA_6, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // // {PB_4, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // LD3 LED_RED + // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PF_8, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + // {PG_9, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PG_12, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // // {PA_5, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + // // {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB VBUS + // // {PA_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB DP + // // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // SWO + // // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, // SWO + // {PB_3, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, // SWO + // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // // {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON + // {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PF_7, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + // {PG_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // ETH RMII TX Enable + // {PG_13, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, // ETH RXII TXD0 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // // {PA_4, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + // // {PA_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB DM + // // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // // {PA_15, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI6)}, + // {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + // {PF_6, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + // {PG_8, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + // {PG_10, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + // {PA_11, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, // USB DM + {PB_5, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PB_8, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_12, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PD_0, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_CAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_TD[] = { + // {PA_12, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, // USB DP + {PB_6, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, // QSPI_CS + {PB_7, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, // LD2 LED_BLUE (ZI) + {PB_9, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + // {PB_13, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON + {PD_1, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {NC, NP, 0} +}; +#endif + +//*** ETHERNET *** + +#ifdef HAL_ETH_MODULE_ENABLED +WEAK const PinMap PinMap_Ethernet[] = { + // {PA_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS + {PA_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_REF_CLK|ETH_RX_CLK + {PA_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDIO + // {PA_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_COL + {PA_7, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS_DV|ETH_RX_DV + // {PB_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD2 + // {PB_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD3 + // {PB_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT + // {PB_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 + // {PB_10, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_ER + // {PB_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN + // {PB_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 + {PB_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + {PC_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDC + // {PC_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2 + // {PC_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_CLK + {PC_4, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD0 + {PC_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD1 + // {PE_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 + // {PG_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT + {PG_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN + // {PG_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + {PG_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 + // {PG_14, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + {NC, NP, 0} +}; +#endif + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { + // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_SOF + // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_HS[] = { +#ifdef USE_USB_HS_IN_FS + // {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_SOF + // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_ID + // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS - Used by ETH when JP7(ZI)/JP6(ZI2) ON + {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DM + {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DP +#else + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D0 + {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_CK + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D4 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D6 - Used by ETH when JP7(ZI)/JP6(ZI2) ON + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_NXT +#endif /* USE_USB_HS_IN_FS */ + {NC, NP, 0} +}; +#endif diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PinNamesVar.h b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PinNamesVar.h new file mode 100644 index 0000000000..118bc92f7e --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PinNamesVar.h @@ -0,0 +1,50 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 +SYS_WKUP1 = PA_0, /* SYS_WKUP0 */ +#endif +#ifdef PWR_WAKEUP_PIN2 +SYS_WKUP2 = PA_2, /* SYS_WKUP1 */ +#endif +#ifdef PWR_WAKEUP_PIN3 +SYS_WKUP3 = PC_13, /* SYS_WKUP2 */ +#endif +#ifdef PWR_WAKEUP_PIN4 +SYS_WKUP4 = PI_8, /* SYS_WKUP3 - Manually added */ +#endif +#ifdef PWR_WAKEUP_PIN5 +SYS_WKUP5 = PI_11, /* SYS_WKUP4 - Manually added */ +#endif +#ifdef PWR_WAKEUP_PIN6 +SYS_WKUP6 = PC_1, /* SYS_WKUP5 */ +#endif +#ifdef PWR_WAKEUP_PIN7 +SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 +SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON +USB_OTG_FS_SOF = PA_8, +USB_OTG_FS_VBUS = PA_9, +USB_OTG_FS_ID = PA_10, +USB_OTG_FS_DM = PA_11, +USB_OTG_FS_DP = PA_12, +USB_OTG_HS_ULPI_D0 = PA_3, +USB_OTG_HS_SOF = PA_4, +USB_OTG_HS_ULPI_CK = PA_5, +USB_OTG_HS_ULPI_D1 = PB_0, +USB_OTG_HS_ULPI_D2 = PB_1, +USB_OTG_HS_ULPI_D7 = PB_5, +USB_OTG_HS_ULPI_D3 = PB_10, +USB_OTG_HS_ULPI_D4 = PB_11, +USB_OTG_HS_ID = PB_12, +USB_OTG_HS_ULPI_D5 = PB_12, +USB_OTG_HS_ULPI_D6 = PB_13, +USB_OTG_HS_VBUS = PB_13, +USB_OTG_HS_DM = PB_14, +USB_OTG_HS_DP = PB_15, +USB_OTG_HS_ULPI_STP = PC_0, +USB_OTG_HS_ULPI_DIR = PC_2, +USB_OTG_HS_ULPI_NXT = PC_3, +#endif diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/hal_conf_extra.h new file mode 100644 index 0000000000..4050fe810f --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/hal_conf_extra.h @@ -0,0 +1,479 @@ +/** + ****************************************************************************** + * @file stm32h7xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32H7xx_HAL_CONF_DEFAULT_H +#define __STM32H7xx_HAL_CONF_DEFAULT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief Include the default list of modules to be used in the HAL driver + * and manage module deactivation + */ +#include "stm32yyxx_hal_conf.h" +#if 0 +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CEC_MODULE_ENABLED +#define HAL_COMP_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_ETH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FDCAN_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_HRTIM_MODULE_ENABLED +#define HAL_HSEM_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_I2S_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_JPEG_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_MDIOS_MODULE_ENABLED +#define HAL_MDMA_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_OPAMP_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RAMECC_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SDRAM_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_SPDIFRX_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SWPMI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED +#endif + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal oscillator (CSI) default value. + * This value is the default CSI value after Reset. + */ +#if !defined (CSI_VALUE) +#define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +#if !defined (LSI_VALUE) +#define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature.*/ +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY ((uint32_t)0x00) /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0 +#endif +#if !defined (USE_SD_TRANSCEIVER) +#define USE_SD_TRANSCEIVER 1U /*!< use uSD Transceiver */ +#endif +#if !defined (USE_SPI_CRC) +#define USE_SPI_CRC 0U /*!< use CRC in SPI */ +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 1U /* HCD register callback disabled */ +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################### Ethernet Configuration ######################### */ +#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */ +#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */ + +#define ETH_MAC_ADDR0 ((uint8_t)0x02) +#define ETH_MAC_ADDR1 ((uint8_t)0x00) +#define ETH_MAC_ADDR2 ((uint8_t)0x00) +#define ETH_MAC_ADDR3 ((uint8_t)0x00) +#define ETH_MAC_ADDR4 ((uint8_t)0x00) +#define ETH_MAC_ADDR5 ((uint8_t)0x00) + + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1 */ + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32h7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32h7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32h7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_MDMA_MODULE_ENABLED +#include "stm32h7xx_hal_mdma.h" +#endif /* HAL_MDMA_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32h7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32h7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32h7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32h7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32h7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32h7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32h7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32h7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32h7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_FDCAN_MODULE_ENABLED +#include "stm32h7xx_hal_fdcan.h" +#endif /* HAL_FDCAN_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32h7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED +#include "stm32h7xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32h7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32h7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32h7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32h7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED +#include "stm32h7xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_HSEM_MODULE_ENABLED +#include "stm32h7xx_hal_hsem.h" +#endif /* HAL_HSEM_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32h7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32h7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32h7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32h7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32h7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32h7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED +#include "stm32h7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED +#include "stm32h7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32h7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32h7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32h7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32h7xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32h7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32h7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RAMECC_MODULE_ENABLED +#include "stm32h7xx_hal_ramecc.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32h7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32h7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32h7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32h7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32h7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32h7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32h7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED +#include "stm32h7xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32h7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32h7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32h7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32h7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32h7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32h7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32h7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32h7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32h7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32H7xx_HAL_CONF_DEFAULT_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/ldscript.ld b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/ldscript.ld new file mode 100644 index 0000000000..5e01911d82 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/ldscript.ld @@ -0,0 +1,208 @@ +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Author : Auto-generated by STM32CubeIDE +** +** Abstract : Linker script for NUCLEO-H743II(2) Board embedding STM32H743IITx Device from STM32H7 series +** 2048Kbytes FLASH +** 128Kbytes DTCMRAM +** 64Kbytes ITCMRAM +** 512Kbytes RAM_D1 +** 288Kbytes RAM_D2 +** 64Kbytes RAM_D3 +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed as is without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2019 STMicroelectronics

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of STMicroelectronics nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x24080000; /* end of "RAM_D1" Ram type memory */ + +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K + ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K + RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K + RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K + RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K + FLASH (rx) : ORIGIN = 0x8020000, LENGTH = 2048K - 128K +} + +/* Sections */ +SECTIONS +{ + /* The startup code into "FLASH" Rom type memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data into "FLASH" Rom type memory */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data into "FLASH" Rom type memory */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM : { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into "RAM_D1" Ram type memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + + } >RAM_D1 AT> FLASH + + /* Uninitialized data section into "RAM_D1" Ram type memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM_D1 + + /* User_heap_stack section, used to check that there is enough "RAM_D1" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM_D1 + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.cpp b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.cpp new file mode 100644 index 0000000000..203e9fc9b8 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.cpp @@ -0,0 +1,332 @@ +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +const PinName digitalPin[] = { + PE_2, // D0 + PE_3, // D1 + PE_4, // D2 + PE_5, // D3 + PE_6, // D4 + PI_8, // D5 + PC_13, // D6 + PC_14, // D7 + PC_15, // D8 + PI_9, // D9 + PI_10, // D10 + PI_11, // D11 + PF_0, // D12 + PF_1, // D13 + PF_2, // D14 + PH_0, // D15 + PH_1, // D16 + PB_2, // D17 + PF_15, // D18 + PG_0, // D19 + PG_1, // D20 + PE_7, // D21 + PE_8, // D22 + PE_9, // D23 + PE_10, // D24 + PE_11, // D25 + PE_12, // D26 + PE_13, // D27 + PE_14, // D28 + PE_15, // D29 + PB_10, // D30 + PB_11, // D31 + PH_6, // D32 + PH_7, // D33 + PH_8, // D34 + PH_9, // D35 + PH_10, // D36 + PH_11, // D37 + PH_12, // D38 + PB_12, // D39 + PB_13, // D40 + PB_14, // D41 + PB_15, // D42 + PD_8, // D43 + PD_9, // D44 + PD_10, // D45 + PD_11, // D46 + PD_12, // D47 + PD_13, // D48 + PD_14, // D49 + PD_15, // D50 + PG_2, // D51 + PG_3, // D52 + PG_4, // D53 + PG_5, // D54 + PG_6, // D55 + PG_7, // D56 + PG_8, // D57 + PC_6, // D58 + PC_7, // D59 + PC_8, // D60 + PC_9, // D61 + PA_8, // D62 + PA_9, // D63 + PA_10, // D64 + PA_11, // D65 + PA_12, // D66 + PA_13, // D67 + PH_13, // D68 + PH_14, // D69 + PH_15, // D70 + PI_0, // D71 + PI_1, // D72 + PI_2, // D73 + PI_3, // D74 + PA_14, // D75 + PA_15, // D76 + PC_10, // D77 + PC_11, // D78 + PC_12, // D79 + PD_0, // D80 + PD_1, // D81 + PD_2, // D82 + PD_3, // D83 + PD_4, // D84 + PD_5, // D85 + PD_6, // D86 + PD_7, // D87 + PG_9, // D88 + PG_10, // D89 + PG_11, // D90 + PG_12, // D91 + PG_13, // D92 + PG_14, // D93 + PG_15, // D94 + PB_3, // D95 + PB_4, // D96 + PB_5, // D97 + PB_6, // D98 + PB_7, // D99 + PB_8, // D100 + PB_9, // D101 + PE_0, // D102 + PE_1, // D103 + PI_4, // D104 + PI_5, // D105 + PI_6, // D106 + PI_7, // D107 + PA_0, // D108 / A0 + PA_1, // D109 / A1 + PA_2, // D110 / A2 + PA_3, // D111 / A3 + PA_4, // D112 / A4 + PA_5, // D113 / A5 + PA_6, // D114 / A6 + PA_7, // D115 / A7 + PB_0, // D116 / A8 + PB_1, // D117 / A9 + PH_2, // D118 / A10 + PH_3, // D119 / A11 + PH_4, // D120 / A12 + PH_5, // D121 / A13 + PC_0, // D122 / A14 + PC_1, // D123 / A15 + PC_2, // D124 / A16 + PC_3, // D125 / A17 + PC_4, // D126 / A18 + PC_5, // D127 / A19 + PF_3, // D128 / A20 + PF_4, // D129 / A21 + PF_5, // D130 / A22 + PF_6, // D131 / A23 + PF_7, // D132 / A24 + PF_8, // D133 / A25 + PF_9, // D134 / A26 + PF_10, // D135 / A27 + PF_11, // D136 / A28 + PF_12, // D137 / A29 + PF_13, // D138 / A30 + PF_14, // D139 / A31 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +void SystemClockStartupInit() { + // Confirm is called only once time to avoid hang up caused by repeated calls in USB wakeup interrupt + static bool first_call = true; + if (!first_call) return; + first_call = false; + + // Clear all clock setting register + RCC->CR = 0x00000001; + RCC->CFGR = 0x00000000; + RCC->D1CFGR = 0x00000000; + RCC->D2CFGR = 0x00000000; + RCC->D3CFGR = 0x00000000; + RCC->PLLCKSELR = 0x00000000; + RCC->PLLCFGR = 0x00000000; + RCC->CIER = 0x00000000; + + // AXI_TARG7_FN_MOD for SRAM + *((volatile uint32_t*)0x51008108)=0x00000001; + + // Enable L1-Cache + SCB_EnableICache(); + SCB_EnableDCache(); + SCB->CACR |= 1<<2; + + PWR->CR3 &= ~(1 << 2); // SCUEN=0 + PWR->D3CR |= 3 << 14; // VOS=3,Scale1,1.15~1.26V core voltage + while((PWR->D3CR & (1 << 13)) == 0); // Wait for the voltage to stabilize + RCC->CR |= 1<<16; // Enable HSE + + uint16_t timeout = 0; + while(((RCC->CR & (1 << 17)) == 0) && (timeout < 0X7FFF)) { + timeout++; // Wait for HSE RDY + } + + if(timeout == 0X7FFF) { + Error_Handler(); + } else { + RCC->PLLCKSELR |= 2 << 0; // PLLSRC[1:0] = 2, HSE for PLL clock source + RCC->PLLCKSELR |= 5 << 4; // DIVM1[5:0] = pllm, Prescaler for PLL1 + RCC->PLL1DIVR |= (160 - 1) << 0; // DIVN1[8:0] = plln - 1, Multiplication factor for PLL1 VCO + RCC->PLL1DIVR |= (2 - 1) << 9; // DIVP1[6:0] = pllp - 1, PLL1 DIVP division factor + RCC->PLL1DIVR |= (4 - 1) << 16; // DIVQ1[6:0] = pllq - 1, PLL1 DIVQ division factor + RCC->PLL1DIVR |= 1 << 24; // DIVR1[6:0] = pllr - 1, PLL1 DIVR division factor + RCC->PLLCFGR |= 2 << 2; // PLL1 input (ref1_ck) clock range frequency is between 4 and 8 MHz + RCC->PLLCFGR |= 0 << 1; // PLL1 VCO selection, 0: 192 to 836 MHz, 1 : 150 to 420 MHz + RCC->PLLCFGR |= 3 << 16; // pll1_q_ck and pll1_p_ck output is enabled + RCC->CR |= 1 << 24; // PLL1 enable + while((RCC->CR & (1 << 25)) == 0); // PLL1 clock ready flag + + // PLL2 DIVR clock frequency = 220MHz, so that SDRAM clock can be set to 110MHz + RCC->PLLCKSELR |= 25 << 12; // DIVM2[5:0] = 25, Prescaler for PLL2 + RCC->PLL2DIVR |= (440 - 1) << 0; // DIVN2[8:0] = 440 - 1, Multiplication factor for PLL2 VCO + RCC->PLL2DIVR |= (2 - 1) << 9; // DIVP2[6:0] = 2-1, PLL2 DIVP division factor + RCC->PLL2DIVR |= (2 - 1) << 24; // DIVR2[6:0] = 2-1, PLL2 DIVR division factor + RCC->PLLCFGR |= 0 << 6; // PLL2RGE[1:0]=0, PLL2 input (ref2_ck) clock range frequency is between 1 and 2 MHz + RCC->PLLCFGR |= 0 << 5; // PLL2 VCO selection, 0: 192 to 836 MHz, 1: 150 to 420 MHz + RCC->PLLCFGR |= 1 << 19; // pll2_p_ck output is enabled + RCC->PLLCFGR |= 1 << 21; // pll2_r_ck output is enabled + RCC->D1CCIPR &= ~(3 << 0); // clear FMC kernel clock source selection + RCC->D1CCIPR |= 2 << 0; // pll2_r_ck clock selected as kernel peripheral clock + RCC->CR |= 1 << 26; // PLL2 enable + while((RCC->CR&(1<<27)) == 0); // PLL2 clock ready flag + + RCC->D1CFGR |= 8 << 0; // rcc_hclk3 = sys_d1cpre_ck / 2 = 400 / 2 = 200MHz. AHB1/2/3/4 + RCC->D1CFGR |= 0 << 8; // sys_ck not divided, sys_d1cpre_ck = sys_clk / 1 = 400 / 1 = 400MHz, System Clock = 400MHz + RCC->CFGR |= 3 << 0; // PLL1 selected as system clock (pll1_p_ck). 400MHz + while(1) { + timeout = (RCC->CFGR & (7 << 3)) >> 3; // System clock switch status + if(timeout == 3) break; // Wait for SW[2:0] = 3 (011: PLL1 selected as system clock (pll1_p_ck)) + } + + FLASH->ACR |= 2 << 0; // LATENCY[2:0] = 2 (@VOS1 Level,maxclock=210MHz) + FLASH->ACR |= 2 << 4; // WRHIGHFREQ[1:0] = 2, flash access frequency < 285MHz + + RCC->D1CFGR |= 4 << 4; // D1PPRE[2:0] = 4, rcc_pclk3 = rcc_hclk3 / 2 = 100MHz, APB3. + RCC->D2CFGR |= 4 << 4; // D2PPRE1[2:0] = 4, rcc_pclk1 = rcc_hclk1 / 2 = 100MHz, APB1. + RCC->D2CFGR |= 4 << 8; // D2PPRE2[2:0] = 4, rcc_pclk2 = rcc_hclk1 / 2 = 100MHz, APB2. + RCC->D3CFGR |= 4 << 4; // D3PPRE[2:0] = 4, rcc_pclk4 = rcc_hclk4 / 2 = 100MHz, APB4. + + RCC->CR |= 1 << 7; // CSI clock enable + RCC->APB4ENR |= 1 << 1; // SYSCFG peripheral clock enable + SYSCFG->CCCSR |= 1 << 0; + } + + // USB clock, (use HSI48 clock) + RCC->CR |= 1 << 12; // HSI48 clock enabl + while((RCC->CR & (1 << 13)) == 0);// 1: HSI48 clock is ready + RCC->APB1HENR |= 1 << 1; // CRS peripheral clock enabled + RCC->APB1HRSTR |= 1 << 1; // Resets CRS + RCC->APB1HRSTR &= ~(1 << 1); // Does not reset CRS + CRS->CFGR &= ~(3 << 28); // USB2 SOF selected as SYNC signal source + CRS->CR |= 3 << 5; // Automatic trimming and Frequency error counter enabled + RCC->D2CCIP2R &= ~(3 << 20); // Clear USBOTG 1 and 2 kernel clock source selection + RCC->D2CCIP2R |= 3 << 20; // HSI48_ck clock is selected as kernel clock +} + +uint8_t MPU_Convert_Bytes_To_POT(uint32_t nbytes) +{ + uint8_t count = 0; + while(nbytes != 1) + { + nbytes >>= 1; + count++; + } + return count; +} + +uint8_t MPU_Set_Protection(uint32_t baseaddr, uint32_t size, uint32_t rnum, uint8_t ap, uint8_t sen, uint8_t cen, uint8_t ben) +{ + uint32_t tempreg = 0; + uint8_t rnr = 0; + if ((size % 32) || size == 0) return 1; + rnr = MPU_Convert_Bytes_To_POT(size) - 1; + SCB->SHCSR &= ~(1 << 16); //disable MemManage + MPU->CTRL &= ~(1 << 0); //disable MPU + MPU->RNR = rnum; + MPU->RBAR = baseaddr; + tempreg |= 0 << 28; + tempreg |= ((uint32_t)ap) << 24; + tempreg |= 0 << 19; + tempreg |= ((uint32_t)sen) << 18; + tempreg |= ((uint32_t)cen) << 17; + tempreg |= ((uint32_t)ben) << 16; + tempreg |= 0 << 8; + tempreg |= rnr << 1; + tempreg |= 1 << 0; + MPU->RASR = tempreg; + MPU->CTRL = (1 << 2) | (1 << 0); //enable PRIVDEFENA + SCB->SHCSR |= 1 << 16; //enable MemManage + return 0; +} + +void MPU_Memory_Protection(void) +{ + MPU_Set_Protection(0x20000000, 128 * 1024, 1, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect DTCM 128k, Sharing is prohibited, cache is allowed, and buffering is allowed + + MPU_Set_Protection(0x24000000, 512 * 1024, 2, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect AXI SRAM, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x30000000, 512 * 1024, 3, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM1~SRAM3, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x38000000, 64 * 1024, 4, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM4, Sharing is prohibited, cache is allowed, and buffering is allowed + + MPU_Set_Protection(0x60000000, 64 * 1024 * 1024, 5, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect LCD FMC 64M, No sharing, no cache, no buffering + MPU_Set_Protection(0XC0000000, 32 * 1024 * 1024, 6, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SDRAM 32M, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0X80000000, 256 * 1024 * 1024, 7, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect NAND FLASH 256M, No sharing, no cache, no buffering +} + +/** + * @brief System Clock Configuration + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + SystemClockStartupInit(); + + MPU_Memory_Protection(); + + /* Update current SystemCoreClock value */ + SystemCoreClockUpdate(); + + /* Configure the Systick interrupt time */ + HAL_SYSTICK_Config(SystemCoreClock/1000); + + /* Configure the Systick */ + HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); + + /* SysTick_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.h b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.h new file mode 100644 index 0000000000..5be18f9aa4 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.h @@ -0,0 +1,222 @@ +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ +#ifdef __cplusplus + +extern "C" { +#endif // __cplusplus +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ +#define PE2 0 +#define PE3 1 +#define PE4 2 +#define PE5 3 +#define PE6 4 +#define PI8 5 +#define PC13 6 +#define PC14 7 +#define PC15 8 +#define PI9 9 +#define PI10 10 +#define PI11 11 +#define PF0 12 +#define PF1 13 +#define PF2 14 +#define PH0 15 +#define PH1 16 +#define PB2 17 +#define PF15 18 +#define PG0 19 +#define PG1 20 +#define PE7 21 +#define PE8 22 +#define PE9 23 +#define PE10 24 +#define PE11 25 +#define PE12 26 +#define PE13 27 +#define PE14 28 +#define PE15 29 +#define PB10 30 +#define PB11 31 +#define PH6 32 +#define PH7 33 +#define PH8 34 +#define PH9 35 +#define PH10 36 +#define PH11 37 +#define PH12 38 +#define PB12 39 +#define PB13 40 +#define PB14 41 +#define PB15 42 +#define PD8 43 +#define PD9 44 +#define PD10 45 +#define PD11 46 +#define PD12 47 +#define PD13 48 +#define PD14 49 +#define PD15 50 +#define PG2 51 +#define PG3 52 +#define PG4 53 +#define PG5 54 +#define PG6 55 +#define PG7 56 +#define PG8 57 +#define PC6 58 +#define PC7 59 +#define PC8 60 +#define PC9 61 +#define PA8 62 +#define PA9 63 +#define PA10 64 +#define PA11 65 +#define PA12 66 +#define PA13 67 +#define PH13 68 +#define PH14 69 +#define PH15 70 +#define PI0 71 +#define PI1 72 +#define PI2 73 +#define PI3 74 +#define PA14 75 +#define PA15 76 +#define PC10 77 +#define PC11 78 +#define PC12 79 +#define PD0 80 +#define PD1 81 +#define PD2 82 +#define PD3 83 +#define PD4 84 +#define PD5 85 +#define PD6 86 +#define PD7 87 +#define PG9 88 +#define PG10 89 +#define PG11 90 +#define PG12 91 +#define PG13 92 +#define PG14 93 +#define PG15 94 +#define PB3 95 +#define PB4 96 +#define PB5 97 +#define PB6 98 +#define PB7 99 +#define PB8 100 +#define PB9 101 +#define PE0 102 +#define PE1 103 +#define PI4 104 +#define PI5 105 +#define PI6 106 +#define PI7 107 +#define PA0 108 +#define PA1 109 +#define PA2 110 +#define PA3 111 +#define PA4 112 +#define PA5 113 +#define PA6 114 +#define PA7 115 +#define PB0 116 +#define PB1 117 +#define PH2 118 +#define PH3 119 +#define PH4 120 +#define PH5 121 +#define PC0 122 +#define PC1 123 +#define PC2 124 +#define PC3 125 +#define PC4 126 +#define PC5 127 +#define PF3 128 +#define PF4 129 +#define PF5 130 +#define PF6 131 +#define PF7 132 +#define PF8 133 +#define PF9 134 +#define PF10 135 +#define PF11 136 +#define PF12 137 +#define PF13 138 +#define PF14 139 + +// This must be a literal with the same value as PEND +#define NUM_DIGITAL_PINS 140 + +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 24 +#define NUM_ANALOG_FIRST 108 + +// Timer Definitions +//Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c +#define TIMER_TONE TIM2 +#define TIMER_SERVO TIM5 +#define TIMER_SERIAL TIM7 + +// UART1 for TFT port +#define ENABLE_HWSERIAL1 +#define PIN_SERIAL1_RX PA10 +#define PIN_SERIAL1_TX PA9 + +// UART4 for ESP-01 port +#define ENABLE_HWSERIAL4 +#define PIN_SERIAL4_RX PA1 +#define PIN_SERIAL4_TX PA0 + +// IIC1 for onboard 24C32 EEPROM +#define PIN_WIRE_SDA PB9 +#define PIN_WIRE_SCL PB8 + +// SPI3 for onboard SD card +// #define PIN_SPI_MOSI PC12 +// #define PIN_SPI_MISO PC11 +// #define PIN_SPI_SCK PC10 + +// HSE default value is 25MHz in HAL +// HSE_BYPASS is 25MHz +#ifndef HSE_BYPASS_NOT_USED + #define HSE_VALUE 25000000 +#endif + +// #define USE_USB_FS +/* Extra HAL modules */ +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_DAC_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/buildroot/tests/BTT_SKR_SE_BX b/buildroot/tests/BTT_SKR_SE_BX new file mode 100755 index 0000000000..b5d6f6de83 --- /dev/null +++ b/buildroot/tests/BTT_SKR_SE_BX @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Build tests for BTT_SKR_SE_BX +# + +# exit on first failure +set -e + +# +# Build with the default configurations +# +restore_configs +opt_set MOTHERBOARD BOARD_BTT_SKR_SE_BX +opt_set SERIAL_PORT 1 +exec_test $1 $2 "Default Configuration" "$3" + +# clean up +restore_configs diff --git a/ini/features.ini b/ini/features.ini index 7399a22446..10eafdc559 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -37,7 +37,7 @@ HAS_WIRED_LCD = src_filter=+ HAS_MARLINUI_HD44780 = src_filter=+ HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.1 src_filter=+ -HAS_(FSMC|SPI)_TFT = src_filter=+ + + +HAS_(FSMC|SPI|LTDC)_TFT = src_filter=+ + + HAS_FSMC_TFT = src_filter=+ + HAS_SPI_TFT = src_filter=+ + I2C_EEPROM = src_filter=+ diff --git a/ini/stm32f7.ini b/ini/stm32f7.ini index 442ef5f9b0..d3fec7aebc 100644 --- a/ini/stm32f7.ini +++ b/ini/stm32f7.ini @@ -28,3 +28,28 @@ platform = ${common_stm32.platform} extends = common_stm32 board = remram_v1 build_flags = ${common_stm32.build_flags} + +# +# BigTreeTech SKR SE BX (STM32H743IIT6 ARM Cortex-M7) +# +[env:BTT_SKR_SE_BX] +platform = ${common_stm32.platform} +platform_packages = ${stm_flash_drive.platform_packages} +extends = common_stm32 +board = BTT_SKR_SE_BX +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +build_flags = ${common_stm32.build_flags} + ${stm_flash_drive.build_flags} + -DUSE_USBHOST_HS + -DUSE_USB_HS_IN_FS + #-DUSBD_USE_CDC_MSC + -DVECT_TAB_OFFSET=0x20000 + -DHAL_DMA2D_MODULE_ENABLED + -DHAL_LTDC_MODULE_ENABLED + -DHAL_SDRAM_MODULE_ENABLED + -DHAL_QSPI_MODULE_ENABLED + -DHAL_MDMA_MODULE_ENABLED + -DHAL_SD_MODULE_ENABLED +upload_protocol = cmsis-dap +debug_tool = cmsis-dap From 5ab220fa7680925628a26b2685a1d145e695842a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 7 Apr 2021 00:34:41 +0000 Subject: [PATCH 177/311] [cron] Bump distribution date (2021-04-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 eb81be3b5c..600b4b8971 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-04-06" + #define STRING_DISTRIBUTION_DATE "2021-04-07" #endif /** From d61bc2d136cd18081f2e6a76d10c7cd90b4b80e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20Karni=C5=A1?= <57687985+radimkarnis@users.noreply.github.com> Date: Wed, 7 Apr 2021 21:41:38 +0200 Subject: [PATCH 178/311] Park Magnetic Switching Toolhead at the very end (#21552) --- Marlin/src/module/tool_change.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 71dd6d40ec..ab0595c58b 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1112,7 +1112,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) // If the original position is within tool store area, go to X origin at once if (destination.y < SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR) { - current_position.x = 0; + current_position.x = X_MIN_POS; planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], new_tool); planner.synchronize(); } From facbbba7894675ee9f9593785f45d4b86ecb2db3 Mon Sep 17 00:00:00 2001 From: ellensp Date: Thu, 8 Apr 2021 08:02:09 +1200 Subject: [PATCH 179/311] Sanity Check newer Configs too (#21550) Co-authored-by: Scott Lahteine --- Marlin/src/inc/SanityCheck.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f6c5cc202a..64fcc85aad 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -60,18 +60,23 @@ #undef TEST4 /** - * We try our best to include sanity checks for all changed configuration - * directives because users have a tendency to use outdated config files with - * the bleeding-edge source code, but sometimes this is not enough. This check - * forces a minimum config file revision. Otherwise Marlin will not build. + * This is to alert you about non-matching versions of config files. + * + * You can edit the version tag in your old config files and try the build again. + * The checks below will alert you about options that need to be changed, but they won't + * tell you about new options that you might find useful. So it's recommended to transfer + * your settings to new Configuration files matching your Marlin version as soon as possible. */ #define HEXIFY(H) _CAT(0x,H) #if !defined(CONFIGURATION_H_VERSION) || HEXIFY(CONFIGURATION_H_VERSION) < HEXIFY(REQUIRED_CONFIGURATION_H_VERSION) - #error "You are using an old Configuration.h file, update it before building Marlin." + #error "Your Configuration.h file is for an old version of Marlin. Downgrade Marlin or upgrade your Configuration.h." +#elif HEXIFY(CONFIGURATION_H_VERSION) > HEXIFY(REQUIRED_CONFIGURATION_H_VERSION) + #error "Your Configuration.h file is for a newer version of Marlin. Upgrade Marlin or downgrade your Configuration.h." #endif - #if !defined(CONFIGURATION_ADV_H_VERSION) || HEXIFY(CONFIGURATION_ADV_H_VERSION) < HEXIFY(REQUIRED_CONFIGURATION_ADV_H_VERSION) - #error "You are using an old Configuration_adv.h file, update it before building Marlin." + #error "Your Configuration_adv.h file is for an old version of Marlin. Downgrade Marlin or upgrade your Configuration_adv.h." +#elif HEXIFY(CONFIGURATION_ADV_H_VERSION) > HEXIFY(REQUIRED_CONFIGURATION_ADV_H_VERSION) + #error "Your Configuration_adv.h file is for a newer version of Marlin. Upgrade Marlin or downgrade your Configuration_adv.h." #endif #undef HEXIFY From 1879eede0d2910cac58f2a90b95989ff4531fa6e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 7 Apr 2021 15:43:07 -0500 Subject: [PATCH 180/311] Fix axis char printing --- Marlin/src/core/serial.h | 1 + Marlin/src/feature/fwretract.cpp | 16 +++++++-------- Marlin/src/feature/powerloss.cpp | 2 +- Marlin/src/gcode/calibrate/M666.cpp | 2 +- Marlin/src/gcode/control/M605.cpp | 2 +- Marlin/src/gcode/parser.cpp | 2 +- .../extui/lib/anycubic_chiron/chiron_tft.cpp | 2 +- .../lib/dgus/fysetc/DGUSScreenHandler.cpp | 6 +++--- .../lib/dgus/hiprecy/DGUSScreenHandler.cpp | 6 +++--- .../extui/lib/dgus/mks/DGUSScreenHandler.cpp | 8 ++++---- .../lib/dgus/origin/DGUSScreenHandler.cpp | 6 +++--- .../src/lcd/extui/lib/nextion/nextion_tft.cpp | 8 ++++---- Marlin/src/lcd/marlinui.cpp | 4 ++-- Marlin/src/module/motion.cpp | 20 +++++++++---------- 14 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 45a1ab012e..b503c0f429 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -144,6 +144,7 @@ void SERIAL_ECHO(T x) { SERIAL_IMPL.print(x); } 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 AS_DIGIT(C) AS_CHAR('0' + (C)) // 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); } diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 4e57ba0150..bfcdb8c001 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -111,14 +111,14 @@ void FWRetract::retract(const bool retracting /* // debugging SERIAL_ECHOLNPAIR( - "retracting ", retracting, + "retracting ", AS_DIGIT(retracting), " swapping ", swapping, " active extruder ", active_extruder ); LOOP_L_N(i, EXTRUDERS) { - SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); + SERIAL_ECHOLNPAIR("retracted[", i, "] ", AS_DIGIT(retracted[i])); #if HAS_MULTI_EXTRUDER - SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); + SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i])); #endif } SERIAL_ECHOLNPAIR("current_position.z ", current_position.z); @@ -185,13 +185,13 @@ void FWRetract::retract(const bool retracting #endif /* // debugging - SERIAL_ECHOLNPAIR("retracting ", retracting); - SERIAL_ECHOLNPAIR("swapping ", swapping); + SERIAL_ECHOLNPAIR("retracting ", AS_DIGIT(retracting)); + SERIAL_ECHOLNPAIR("swapping ", AS_DIGIT(swapping)); SERIAL_ECHOLNPAIR("active_extruder ", active_extruder); LOOP_L_N(i, EXTRUDERS) { - SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]); + SERIAL_ECHOLNPAIR("retracted[", i, "] ", AS_DIGIT(retracted[i])); #if HAS_MULTI_EXTRUDER - SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]); + SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i])); #endif } SERIAL_ECHOLNPAIR("current_position.z ", current_position.z); @@ -268,7 +268,7 @@ void FWRetract::M208_report(const bool forReplay/*=false*/) { void FWRetract::M209_report(const bool forReplay/*=false*/) { if (!forReplay) { SERIAL_ECHO_MSG("; Auto-Retract: S=0 to disable, 1 to interpret E-only moves as retract/recover"); SERIAL_ECHO_START(); } - SERIAL_ECHOLNPAIR(" M209 S", autoretract_enabled); + SERIAL_ECHOLNPAIR(" M209 S", AS_DIGIT(autoretract_enabled)); } #endif // FWRETRACT_AUTORETRACT diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index e45864b484..dd4c78726a 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -612,7 +612,7 @@ 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: ", info.flag.dryrun); + DEBUG_ECHOLNPAIR("dryrun: ", AS_DIGIT(info.flag.dryrun)); DEBUG_ECHOLNPAIR("allow_cold_extrusion: ", info.flag.allow_cold_extrusion); } else diff --git a/Marlin/src/gcode/calibrate/M666.cpp b/Marlin/src/gcode/calibrate/M666.cpp index e915aa8ff7..75becf13f3 100644 --- a/Marlin/src/gcode/calibrate/M666.cpp +++ b/Marlin/src/gcode/calibrate/M666.cpp @@ -43,7 +43,7 @@ if (parser.seen(XYZ_CHAR(i))) { const float v = parser.value_linear_units(); if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", XYZ_CHAR(i), "] = ", delta_endstop_adj[i]); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(XYZ_CHAR(i)), "] = ", delta_endstop_adj[i]); } } } diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 3d13cb1c24..e0c79f0e54 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -141,7 +141,7 @@ HOTEND_LOOP() { DEBUG_ECHOPAIR_P(SP_T_STR, e); - LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", e, "].", XYZ_CHAR(a) | 0x20, "=", hotend_offset[e][a]); + LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", e, "].", AS_CHAR(XYZ_CHAR(a) | 0x20), "=", hotend_offset[e][a]); DEBUG_EOL(); } DEBUG_EOL(); diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index ebe9d3b2cd..f7812bf3f6 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 ", p - command_ptr - 1); + SERIAL_ECHOPAIR("Got param ", AS_CHAR(param), " at index ", p - command_ptr - 1); if (has_val) SERIAL_ECHOPGM(" (has_val)"); } #endif diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index aa78fcb539..5eb8611b5e 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -639,7 +639,7 @@ namespace Anycubic { float newposition = atof(&panel_command[6]); #if ACDEBUG(AC_ACTION) - SERIAL_ECHOLNPAIR("Nudge ", panel_command[4], " axis ", newposition); + SERIAL_ECHOLNPAIR("Nudge ", AS_CHAR(panel_command[4]), " axis ", newposition); #endif switch (panel_command[4]) { diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp index 5497dd53cc..26dafeaaab 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSScreenHandler.cpp @@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!movevalue) { // homing - DEBUG_ECHOPAIR(" homing ", axiscode); + DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode)); char buf[6] = "G28 X"; buf[4] = axiscode; //DEBUG_ECHOPAIR(" ", buf); @@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } else { // movement - DEBUG_ECHOPAIR(" move ", axiscode); + DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode)); bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); @@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode)); return; } diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp index c170c288aa..f91c2737e0 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSScreenHandler.cpp @@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!movevalue) { // homing - DEBUG_ECHOPAIR(" homing ", axiscode); + DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode)); char buf[6] = "G28 X"; buf[4] = axiscode; //DEBUG_ECHOPAIR(" ", buf); @@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } else { // movement - DEBUG_ECHOPAIR(" move ", axiscode); + DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode)); bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); @@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode)); return; } diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index 109e9a8ac6..b507c1ec3e 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -835,7 +835,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!movevalue) { // homing - DEBUG_ECHOPAIR(" homing ", axiscode); + DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode)); // char buf[6] = "G28 X"; // buf[4] = axiscode; @@ -850,14 +850,14 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { else if (movevalue == 5) { DEBUG_ECHOPAIR("send M84"); char buf[6]; - snprintf_P(buf,6,PSTR("M84 %c"),axiscode); + snprintf_P(buf,6,PSTR("M84 %c"), axiscode); queue.enqueue_one_now(buf); ForceCompleteUpdate(); return; } else { // movement - DEBUG_ECHOPAIR(" move ", axiscode); + DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode)); bool old_relative_mode = relative_mode; if (!relative_mode) { @@ -895,7 +895,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode)); return; } diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp index ff924f4061..8806623b69 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp @@ -188,7 +188,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (!movevalue) { // homing - DEBUG_ECHOPAIR(" homing ", axiscode); + DEBUG_ECHOPAIR(" homing ", AS_CHAR(axiscode)); char buf[6] = "G28 X"; buf[4] = axiscode; //DEBUG_ECHOPAIR(" ", buf); @@ -199,7 +199,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } else { // movement - DEBUG_ECHOPAIR(" move ", axiscode); + DEBUG_ECHOPAIR(" move ", AS_CHAR(axiscode)); bool old_relative_mode = relative_mode; if (!relative_mode) { //DEBUG_ECHOPGM(" G91"); @@ -235,7 +235,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; cannotmove: - DEBUG_ECHOLNPAIR(" cannot move ", axiscode); + DEBUG_ECHOLNPAIR(" cannot move ", AS_CHAR(axiscode)); return; } diff --git a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp index e2fa6bc518..23857c65c3 100644 --- a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp @@ -144,10 +144,10 @@ bool NextionTFT::ReadTFTCommand() { #if NEXDEBUG(N_SOME) uint8_t req = atoi(&nextion_command[1]); if (req > 7 && req != 20) - DEBUG_ECHOLNPAIR( "> ", nextion_command[0], - "\n> ", nextion_command[1], - "\n> ", nextion_command[2], - "\n> ", nextion_command[3], + DEBUG_ECHOLNPAIR( "> ", AS_CHAR(nextion_command[0]), + "\n> ", AS_CHAR(nextion_command[1]), + "\n> ", AS_CHAR(nextion_command[2]), + "\n> ", AS_CHAR(nextion_command[3]), "\nprinter_state:", printer_state); #endif } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 4d457dc6aa..149da8b54e 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -761,7 +761,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 ", axis, " at FR ", fr_mm_s); + //SERIAL_ECHOLNPAIR("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s); axis = NO_AXIS; @@ -782,7 +782,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 ", axis, " soon."); + //SERIAL_ECHOLNPAIR("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon."); } #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 81c3a81fbe..48535b63d6 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -622,7 +622,7 @@ void restore_feedrate_and_scaling() { #endif if (DEBUGGING(LEVELING)) - SERIAL_ECHOLNPAIR("Axis ", XYZ_CHAR(axis), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]); + SERIAL_ECHOLNPAIR("Axis ", AS_CHAR(XYZ_CHAR(axis)), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]); } /** @@ -1392,12 +1392,12 @@ void prepare_line_to_destination() { * "trusted" position). */ void set_axis_never_homed(const AxisEnum axis) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", axis_codes[axis], ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_never_homed(", AS_CHAR(axis_codes[axis]), ")"); set_axis_untrusted(axis); set_axis_unhomed(axis); - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", axis_codes[axis], ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_never_homed(", AS_CHAR(axis_codes[axis]), ")"); TERN_(I2C_POSITION_ENCODERS, I2CPEM.unhomed(axis)); } @@ -1458,7 +1458,7 @@ void prepare_line_to_destination() { if (ABS(phaseDelta) * planner.steps_to_mm[axis] / phasePerUStep < 0.05f) SERIAL_ECHOLNPAIR("Selected home phase ", home_phase[axis], " too close to endstop trigger phase ", phaseCurrent, - ". Pick a different phase for ", axis_codes[axis]); + ". Pick a different phase for ", AS_CHAR(axis_codes[axis])); // Skip to next if target position is behind current. So it only moves away from endstop. if (phaseDelta < 0) phaseDelta += 1024; @@ -1469,7 +1469,7 @@ void prepare_line_to_destination() { // Optional debug messages if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR( - "Endstop ", axis_codes[axis], " hit at Phase:", phaseCurrent, + "Endstop ", AS_CHAR(axis_codes[axis]), " hit at Phase:", phaseCurrent, " Delta:", phaseDelta, " Distance:", mmDelta ); } @@ -1507,7 +1507,7 @@ void prepare_line_to_destination() { if (!_CAN_HOME(X) && !_CAN_HOME(Y) && !_CAN_HOME(Z)) return; #endif - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", axis_codes[axis], ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", AS_CHAR(axis_codes[axis]), ")"); const int axis_home_dir = TERN0(DUAL_X_CARRIAGE, axis == X_AXIS) ? x_home_dir(active_extruder) : home_dir(axis); @@ -1585,7 +1585,7 @@ void prepare_line_to_destination() { case Z_AXIS: es = Z_ENDSTOP; break; } if (TEST(endstops.state(), es)) { - SERIAL_ECHO_MSG("Bad ", axis_codes[axis], " Endstop?"); + SERIAL_ECHO_MSG("Bad ", AS_CHAR(axis_codes[axis]), " Endstop?"); kill(GET_TEXT(MSG_KILL_HOMING_FAILED)); } #endif @@ -1807,7 +1807,7 @@ void prepare_line_to_destination() { if (axis == Z_AXIS) fwretract.current_hop = 0.0; #endif - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", axis_codes[axis], ")"); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", AS_CHAR(axis_codes[axis]), ")"); } // homeaxis() @@ -1885,14 +1885,14 @@ void set_axis_is_at_home(const AxisEnum 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], ")"); + DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", AS_CHAR(axis_codes[axis]), ")"); } } #if HAS_WORKSPACE_OFFSET void update_workspace_offset(const AxisEnum axis) { workspace_offset[axis] = home_offset[axis] + position_shift[axis]; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", XYZ_CHAR(axis), " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", AS_CHAR(XYZ_CHAR(axis)), " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]); } #endif From aa2601bb9e361d429a6110a3ced31a1a5a0f86dc Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 8 Apr 2021 00:37:38 +0000 Subject: [PATCH 181/311] [cron] Bump distribution date (2021-04-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 600b4b8971..a43eb1a74c 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-04-07" + #define STRING_DISTRIBUTION_DATE "2021-04-08" #endif /** From ecd5ae890f890c4bedd5c913ddba688c3687573d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 9 Apr 2021 00:32:51 +0000 Subject: [PATCH 182/311] [cron] Bump distribution date (2021-04-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 a43eb1a74c..ad87a10ef9 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-04-08" + #define STRING_DISTRIBUTION_DATE "2021-04-09" #endif /** From 7124326808271b4050615c909914ef52185f594a Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Thu, 8 Apr 2021 22:35:21 -0300 Subject: [PATCH 183/311] Delay U8glib init using U8glib-HAL 0.4.4 (#21496) Co-authored-by: Scott Lahteine --- Marlin/src/lcd/dogm/HAL_LCD_class_defines.h | 86 ++++++++++++--------- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 9 ++- ini/features.ini | 2 +- 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h index 30a5361ab9..28ca26134e 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h @@ -30,12 +30,15 @@ extern u8g_dev_t u8g_dev_st7565_64128n_HAL_2x_hw_spi; class U8GLIB_64128N_2X_HAL : public U8GLIB { public: - U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_64128n_HAL_2x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset) - { } - U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_64128n_HAL_2x_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset) - { } + U8GLIB_64128N_2X_HAL() : U8GLIB() { } + U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(cs, a0, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); + } + void init(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); + } }; extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi; @@ -43,12 +46,15 @@ extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi; class U8GLIB_ST7920_128X64_4X_HAL : public U8GLIB { public: - U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_HAL_4x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_HAL_4x_hw_spi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset) // a0 = U8G_PIN_NONE - { } + U8GLIB_ST7920_128X64_4X_HAL() : U8GLIB() { } + U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, reset); } + U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset = U8G_PIN_NONE) { init(cs, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE + } + void init(pin_t cs, pin_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_hw_spi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE + } }; // @@ -59,27 +65,29 @@ extern u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi; class U8GLIB_ST7920_128X64_RRD : public U8GLIB { public: - U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset) // a0 = U8G_PIN_NONE - { } + U8GLIB_ST7920_128X64_RRD() : U8GLIB() { } + U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7920_128x64_rrd_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE + } }; extern u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c_2_wire; class U8GLIB_SH1106_128X64_2X_I2C_2_WIRE : public U8GLIB { public: - U8GLIB_SH1106_128X64_2X_I2C_2_WIRE(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_sh1106_128x64_2x_i2c_2_wire, options) - { } + U8GLIB_SH1106_128X64_2X_I2C_2_WIRE() : U8GLIB() { } + U8GLIB_SH1106_128X64_2X_I2C_2_WIRE(uint8_t options) { init(options); } + void init(uint8_t options = U8G_I2C_OPT_NONE) { U8GLIB::init(&u8g_dev_sh1106_128x64_2x_i2c_2_wire, options); } }; extern u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire; class U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE : public U8GLIB { public: - U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x64_2x_i2c_2_wire, options) - { } + U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE() : U8GLIB() { } + U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE(uint8_t options) { init(options); } + void init(uint8_t options = U8G_I2C_OPT_NONE) { U8GLIB::init(&u8g_dev_ssd1306_128x64_2x_i2c_2_wire, options); } }; // @@ -90,9 +98,9 @@ extern u8g_dev_t u8g_dev_tft_320x240_upscale_from_128x64; class U8GLIB_TFT_320X240_UPSCALE_FROM_128X64 : public U8GLIB { public: - U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset) - { } + U8GLIB_TFT_320X240_UPSCALE_FROM_128X64() : U8GLIB() { } + U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) { init(cs, rs, reset); } + void init(uint8_t cs, uint8_t rs, uint8_t reset = U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset); } }; @@ -100,12 +108,15 @@ extern u8g_dev_t u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, u8g_dev_uc1701_mini1286 class U8GLIB_MINI12864_2X_HAL : public U8GLIB { public: - U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset) - { } + U8GLIB_MINI12864_2X_HAL() : U8GLIB() { } + U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { init(cs, a0, reset); } + void init(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, sck, mosi, cs, a0, reset); + } + void init(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset); + } }; extern u8g_dev_t u8g_dev_ssd1309_sw_spi; @@ -113,10 +124,13 @@ extern u8g_dev_t u8g_dev_ssd1309_hw_spi; class U8GLIB_SSD1309_128X64_HAL : public U8GLIB { public: - U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset) - { } - U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset) - { } + U8GLIB_SSD1309_128X64_HAL() : U8GLIB() { } + U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { init(cs, a0, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); + } + void init(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); + } }; diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 44ada03c7e..dc60c1bff3 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -76,7 +76,7 @@ #define FONT_STATUSMENU_NAME MENU_FONT_NAME #endif -U8G_CLASS u8g(U8G_PARAM); +U8G_CLASS u8g; #include LANGUAGE_DATA_INCL(LCD_LANGUAGE) @@ -252,6 +252,13 @@ bool MarlinUI::detected() { return true; } // Initialize or re-initialize the LCD void MarlinUI::init_lcd() { + + static bool did_init_u8g = false; + if (!did_init_u8g) { + u8g.init(U8G_PARAM); + did_init_u8g = true; + } + #if PIN_EXISTS(LCD_BACKLIGHT) OUT_WRITE(LCD_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); // Illuminate after reset or right away #endif diff --git a/ini/features.ini b/ini/features.ini index 10eafdc559..864befa7a8 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -35,7 +35,7 @@ USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 HAS_WIRED_LCD = src_filter=+ HAS_MARLINUI_HD44780 = src_filter=+ -HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.1 +HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.4 src_filter=+ HAS_(FSMC|SPI|LTDC)_TFT = src_filter=+ + + HAS_FSMC_TFT = src_filter=+ + From 19320a1f8f3e502b745648df672a82bd6b6298dc Mon Sep 17 00:00:00 2001 From: ellensp Date: Fri, 9 Apr 2021 13:36:48 +1200 Subject: [PATCH 184/311] Check for old Marlin files mixed in (#21574) --- .../share/PlatformIO/scripts/preflight-checks.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 2ad1562a31..6b499a8bcd 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -73,3 +73,15 @@ for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]: if os.path.isfile(os.path.join(p, f)): err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p raise SystemExit(err) + +# +# Check for old files indicating an entangled Marlin (mixing old and new code) +# +mixedin = [] +for p in [ os.path.join(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") ]: + for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: + if os.path.isfile(os.path.join(p, f)): + mixedin += [ f ] +if mixedin: + err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) + raise SystemExit(err) From 1a2cbe100c279b0dd12a70f5e9179a6f9b555e32 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Fri, 9 Apr 2021 04:03:34 +0200 Subject: [PATCH 185/311] Macros to eliminate 'f + 0.0' (#21568) --- Marlin/src/core/macros.h | 15 +++++++++++---- Marlin/src/gcode/bedlevel/G35.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_corners.cpp | 2 +- Marlin/src/lcd/menu/menu_motion.cpp | 6 +++--- Marlin/src/lcd/tft/ui_480x320.cpp | 2 +- Marlin/src/module/delta.cpp | 2 +- Marlin/src/module/motion.cpp | 4 ++-- Marlin/src/module/planner.cpp | 2 +- Marlin/src/module/scara.cpp | 6 +++--- Marlin/src/module/tool_change.cpp | 2 +- 10 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index fb129cd939..6092dc4a59 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -187,14 +187,21 @@ #define DISABLED(V...) DO(DIS,&&,V) #define COUNT_ENABLED(V...) DO(ENA,+,V) -#define TERN(O,A,B) _TERN(_ENA_1(O),B,A) // OPTION converted to '0' or '1' -#define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION converted to A or '0' -#define TERN1(O,A) _TERN(_ENA_1(O),1,A) // OPTION converted to A or '1' -#define TERN_(O,A) _TERN(_ENA_1(O),,A) // OPTION converted to A or '' +#define TERN(O,A,B) _TERN(_ENA_1(O),B,A) // OPTION ? 'A' : 'B' +#define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION ? 'A' : '0' +#define TERN1(O,A) _TERN(_ENA_1(O),1,A) // OPTION ? 'A' : '1' +#define TERN_(O,A) _TERN(_ENA_1(O),,A) // OPTION ? 'A' : '' #define _TERN(E,V...) __TERN(_CAT(T_,E),V) // Prepend 'T_' to get 'T_0' or 'T_1' #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. +// Macros to avoid 'f + 0.0' which is not always optimized away. Minus included for symmetry. +// Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc. +#define PLUS_TERN0(O,A) _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '' +#define MINUS_TERN0(O,A) _TERN(_ENA_1(O),,- (A)) // OPTION ? '- (A)' : '' +#define SUM_TERN(O,B,A) ((B) PLUS_TERN0(O,A)) // ((B) (OPTION ? '+ (A)' : '')) +#define DIFF_TERN(O,B,A) ((B) MINUS_TERN0(O,A)) // ((B) (OPTION ? '- (A)' : '')) + #define IF_ENABLED TERN_ #define IF_DISABLED(O,A) TERN(O,,A) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 0fab747618..ad2cc67db0 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -102,7 +102,7 @@ void GcodeSuite::G35() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G35 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - do_blocking_move_to_z((Z_CLEARANCE_BETWEEN_PROBES) + TERN0(BLTOUCH_HS_MODE, 7)); + do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7)); const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 4cfb4e411b..8635661d01 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -269,7 +269,7 @@ static inline void _lcd_level_bed_corners_get_next_position() { do { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + TERN0(BLTOUCH_HS_MODE, 7)); // clearance + do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index dfa7b92a99..fea4fa25a9 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -93,7 +93,7 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) { ui.encoderPosition = 0; if (ui.should_draw()) { const float pos = NATIVE_TO_LOGICAL( - ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset), + ui.manual_move.processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], ui.manual_move.offset), axis ); if (parser.using_inch_units()) { @@ -130,8 +130,8 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); } MenuEditItemBase::draw_edit_screen( GET_TEXT(TERN(MULTI_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)), ftostr41sign(current_position.e - + TERN0(IS_KINEMATIC, ui.manual_move.offset) - - TERN0(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin) + PLUS_TERN0(IS_KINEMATIC, ui.manual_move.offset) + MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin) ) ); } // should_draw diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 21b280ac75..4d5a0b4fda 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -610,7 +610,7 @@ static void drawAxisValue(AxisEnum axis) { probe.offset.z : #endif NATIVE_TO_LOGICAL( - ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset), + ui.manual_move.processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], ui.manual_move.offset), axis ); xy_int_t pos; diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 6ba9f4e9f2..eb42bd1946 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -248,7 +248,7 @@ void home_delta() { #endif // Move all carriages together linearly until an endstop is hit. - current_position.z = (delta_height + 10 - TERN0(HAS_BED_PROBE, probe.offset.z)); + current_position.z = DIFF_TERN(HAS_BED_PROBE, delta_height + 10, probe.offset.z); line_to_current_position(homing_feedrate(Z_AXIS)); planner.synchronize(); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 48535b63d6..afd30a44e0 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -583,7 +583,7 @@ void restore_feedrate_and_scaling() { #elif ENABLED(DELTA) soft_endstop.min[axis] = base_min_pos(axis); - soft_endstop.max[axis] = (axis == Z_AXIS) ? delta_height - TERN0(HAS_BED_PROBE, probe.offset.z) : base_max_pos(axis); + soft_endstop.max[axis] = (axis == Z_AXIS) ? DIFF_TERN(HAS_BED_PROBE, delta_height, probe.offset.z) : base_max_pos(axis); switch (axis) { case X_AXIS: @@ -1847,7 +1847,7 @@ void set_axis_is_at_home(const AxisEnum axis) { #if EITHER(MORGAN_SCARA, AXEL_TPARA) scara_set_axis_is_at_home(axis); #elif ENABLED(DELTA) - current_position[axis] = (axis == Z_AXIS) ? delta_height - TERN0(HAS_BED_PROBE, probe.offset.z) : base_home_pos(axis); + current_position[axis] = (axis == Z_AXIS) ? DIFF_TERN(HAS_BED_PROBE, delta_height, probe.offset.z) : base_home_pos(axis); #else current_position[axis] = base_home_pos(axis); #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index e111a808b2..d6356432e7 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2997,7 +2997,7 @@ void Planner::set_e_position_mm(const_float_t e) { const uint8_t axis_index = E_AXIS_N(active_extruder); TERN_(DISTINCT_E_FACTORS, last_extruder = active_extruder); - const float e_new = e - TERN0(FWRETRACT, fwretract.current_retract[active_extruder]); + const float e_new = DIFF_TERN(FWRETRACT, e, fwretract.current_retract[active_extruder]); position.e = LROUND(settings.axis_steps_per_mm[axis_index] * e_new); TERN_(HAS_POSITION_FLOAT, position_float.e = e_new); TERN_(IS_KINEMATIC, position_cart.e = e); diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index d02136039a..cc177f76c2 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -51,8 +51,8 @@ float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SE void forward_kinematics(const_float_t a, const_float_t b) { const float a_sin = sin(RADIANS(a)) * L1, a_cos = cos(RADIANS(a)) * L1, - b_sin = sin(RADIANS(b + TERN0(MP_SCARA, a))) * L2, - b_cos = cos(RADIANS(b + TERN0(MP_SCARA, a))) * L2; + b_sin = sin(RADIANS(SUM_TERN(MP_SCARA, b, a))) * L2, + b_cos = cos(RADIANS(SUM_TERN(MP_SCARA, b, a))) * L2; cartes.x = a_cos + b_cos + scara_offset.x; // theta cartes.y = a_sin + b_sin + scara_offset.y; // phi @@ -127,7 +127,7 @@ float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SE // Angle of Arm2 PSI = ATAN2(S2, C2); - delta.set(DEGREES(THETA), DEGREES(PSI + TERN0(MORGAN_SCARA, THETA)), raw.z); + delta.set(DEGREES(THETA), DEGREES(SUM_TERN(MORGAN_SCARA, PSI, THETA)), raw.z); /* DEBUG_POS("SCARA IK", raw); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index ab0595c58b..1ed395dfe4 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -359,7 +359,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a // STEP 6 - current_position.x = midpos - TERN0(HAS_HOTEND_OFFSET, hotend_offset[new_tool].x); + current_position.x = DIFF_TERN(HAS_HOTEND_OFFSET, midpos, hotend_offset[new_tool].x); DEBUG_SYNCHRONIZE(); DEBUG_POS("(6) Move midway between hotends", current_position); From 8048d1411f994499ef9ca82079efb03a54211cfa Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Fri, 9 Apr 2021 04:05:31 +0200 Subject: [PATCH 186/311] Drop return value from Serial::write() (#21567) --- Marlin/src/HAL/AVR/MarlinSerial.cpp | 5 ++--- Marlin/src/HAL/AVR/MarlinSerial.h | 2 +- Marlin/src/core/serial_base.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index 81503e1fe9..7cd4446987 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -454,7 +454,7 @@ void MarlinSerial::flush() { } template -size_t MarlinSerial::write(const uint8_t c) { +void MarlinSerial::write(const uint8_t c) { if (Cfg::TX_SIZE == 0) { _written = true; @@ -480,7 +480,7 @@ size_t MarlinSerial::write(const uint8_t c) { // location". This makes sure flush() won't return until the bytes // actually got written B_TXC = 1; - return 1; + return; } const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); @@ -510,7 +510,6 @@ size_t MarlinSerial::write(const uint8_t c) { // Enable TX ISR - Non atomic, but it will eventually enable TX ISR B_UDRIE = 1; } - return 1; } template diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 31bbaaa531..355ecd41fd 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -210,7 +210,7 @@ static int read(); static void flush(); static ring_buffer_pos_t available(); - static size_t write(const uint8_t c); + static void write(const uint8_t c); static void flushTX(); #if HAS_DGUS_LCD static ring_buffer_pos_t get_tx_buffer_free(); diff --git a/Marlin/src/core/serial_base.h b/Marlin/src/core/serial_base.h index 8b23816b17..d8090eb83a 100644 --- a/Marlin/src/core/serial_base.h +++ b/Marlin/src/core/serial_base.h @@ -100,7 +100,7 @@ struct SerialBase { // Static dispatch methods below: // The most important method here is where it all ends to: - size_t write(uint8_t c) { return SerialChild->write(c); } + void write(uint8_t c) { SerialChild->write(c); } // Called when the parser finished processing an instruction, usually build to nothing void msgDone() const { SerialChild->msgDone(); } From 4cba40f9fd9ea7dae24dbf7aef89091e88f99126 Mon Sep 17 00:00:00 2001 From: Sola <42537573+solawc@users.noreply.github.com> Date: Sat, 10 Apr 2021 04:29:59 +0800 Subject: [PATCH 187/311] Fix manual move with MKS H43 (#21511) Co-authored-by: Scott Lahteine --- Marlin/src/gcode/gcode.cpp | 4 ++ Marlin/src/gcode/gcode.h | 4 ++ .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 6 +-- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.h | 2 +- .../extui/lib/dgus/mks/DGUSScreenHandler.cpp | 54 ++++++++++++++----- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index cdf11e870b..574e93aecc 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -977,6 +977,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 1001: M1001(); break; // M1001: [INTERNAL] Handle SD completion #endif + #if ENABLED(DGUS_LCD_UI_MKS) + case 1002: M1002(); break; // M1002: [INTERNAL] Tool-change and Relative E Move + #endif + #if ENABLED(MAX7219_GCODE) case 7219: M7219(); break; // M7219: Set LEDs, columns, and rows #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 7ea2489584..977fc8bfd8 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -1069,6 +1069,10 @@ private: static void M1001(); #endif + #if ENABLED(DGUS_LCD_UI_MKS) + static void M1002(); + #endif + #if ENABLED(MAX7219_GCODE) static void M7219(); #endif diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index 355565ae5a..911965b9ae 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -45,7 +45,7 @@ uint16_t manualMoveStep = 1; uint16_t distanceFilament = 10; -uint16_t FilamentSpeed = 25; +uint16_t filamentSpeed_mm_s = 25; float ZOffset_distance = 0.1; float mesh_adj_distance = 0.01; float Z_distance = 0.1; @@ -555,7 +555,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_LOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentLoad, nullptr), VPHELPER(VP_UNLOAD_Filament, nullptr, &ScreenHandler.MKS_FilamentUnLoad, nullptr), VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #endif @@ -569,7 +569,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) VPHELPER(VP_Filament_distance, &distanceFilament, &ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_Filament_speed, &FilamentSpeed, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, &ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #if ENABLED(PIDTEMP) diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h index ac0a482ede..f174f38d96 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.h @@ -37,7 +37,7 @@ extern uint16_t manualMoveStep; extern uint16_t distanceFilament; -extern uint16_t FilamentSpeed; +extern uint16_t filamentSpeed_mm_s; extern float ZOffset_distance; extern float mesh_adj_distance; extern float Z_distance; diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index b507c1ec3e..e6e2af42eb 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -840,7 +840,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { // buf[4] = axiscode; char buf[6]; - sprintf(buf,"G28 %c",axiscode); + sprintf(buf, "G28 %c", axiscode); //DEBUG_ECHOPAIR(" ", buf); queue.enqueue_one_now(buf); //DEBUG_ECHOLNPGM(" ✓"); @@ -1190,17 +1190,18 @@ void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ uint16_t value_len = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPAIR_F("FilamentSpeed value:", value_len); + DEBUG_ECHOLNPAIR_F("filamentSpeed_mm_s value:", value_len); - FilamentSpeed = value_len; + filamentSpeed_mm_s = value_len; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) { #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) - char buf[40]; uint8_t swap_tool = 0; + #else + constexpr uint8_t swap_tool = 1; // T0 (or none at all) #endif #if HAS_HOTEND @@ -1215,9 +1216,8 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ default: break; case 0: #if HAS_HOTEND - if (thermalManager.tooColdToExtrude(0)) { + if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; - } else { #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) swap_tool = 1; @@ -1243,15 +1243,41 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ } #endif + if (swap_tool) { + char buf[30]; + snprintf_P(buf, 30 + #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) + , PSTR("M1002T%cE%dF%d"), char('0' + swap_tool - 1) + #else + , PSTR("M1002E%dF%d") + #endif + , (int)distanceFilament * filamentDir, filamentSpeed_mm_s * 60 + ); + queue.inject(buf); + } +} + +/** + * M1002: Do a tool-change and relative move for MKS_FilamentLoadUnload + * within the G-code execution window for best concurrency. + */ +void GcodeSuite::M1002() { #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) - if (swap_tool) { - queue.enqueue_now_P(swap_tool == 2 ? PSTR("T1") : PSTR("T0")); - queue.enqueue_now_P(PSTR("G91")); - snprintf_P(buf, 40, PSTR("G1 E%d F%d"), (int)distanceFilament * filamentDir, FilamentSpeed * 60); - queue.enqueue_one_now(buf); - queue.enqueue_now_P(PSTR("G90")); - } + { + char buf[3]; + sprintf_P(buf, PSTR("T%c"), char('0' + parser.intval('T'))); + process_subcommands_now(buf); + } #endif + + const uint8_t old_axis_relative = axis_relative; + set_e_relative(true); // M83 + { + char buf[20]; + snprintf_P(buf, 20, PSTR("G1E%dF%d"), parser.intval('E'), parser.intval('F')); + process_subcommands_now(buf); + } + axis_relative = old_axis_relative; } void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { @@ -1445,7 +1471,7 @@ void DGUSScreenHandler::LanguagePInit() { void DGUSScreenHandler::DGUS_ExtrudeLoadInit(void) { ex_filament.ex_length = distanceFilament; ex_filament.ex_load_unload_flag = 0; - ex_filament.ex_need_time = FilamentSpeed; + ex_filament.ex_need_time = filamentSpeed_mm_s; ex_filament.ex_speed = 0; ex_filament.ex_status = EX_NONE; ex_filament.ex_tick_end = 0; From 3b3a3fa84563c6a806e38c9be3c47a0bbbd8a630 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 10 Apr 2021 00:34:56 +0000 Subject: [PATCH 188/311] [cron] Bump distribution date (2021-04-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 ad87a10ef9..e307933736 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-04-09" + #define STRING_DISTRIBUTION_DATE "2021-04-10" #endif /** From 37e671612ee224b97e0500a33b887df675e580ec Mon Sep 17 00:00:00 2001 From: BigTreeTech <38851044+bigtreetech@users.noreply.github.com> Date: Sat, 10 Apr 2021 16:44:36 +0800 Subject: [PATCH 189/311] Fix M114 E / R broken by `LIN_ADVANCE` (#21579) --- Marlin/src/module/stepper.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 8c377bf7bf..5a5fa3afe6 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1697,12 +1697,12 @@ void Stepper::pulse_phase_isr() { #if EITHER(LIN_ADVANCE, MIXING_EXTRUDER) delta_error.e += advance_dividend.e; if (delta_error.e >= 0) { - count_position.e += count_direction.e; #if ENABLED(LIN_ADVANCE) delta_error.e -= advance_divisor; // Don't step E here - But remember the number of steps to perform motor_direction(E_AXIS) ? --LA_steps : ++LA_steps; #else + count_position.e += count_direction.e; step_needed.e = true; #endif } @@ -2283,15 +2283,23 @@ uint32_t Stepper::block_phase_isr() { #if ENABLED(MIXING_EXTRUDER) // We don't know which steppers will be stepped because LA loop follows, // with potentially multiple steps. Set all. - if (LA_steps > 0) + if (LA_steps > 0) { MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); - else if (LA_steps < 0) + count_direction.e = 1; + } + else if (LA_steps < 0) { MIXER_STEPPER_LOOP(j) REV_E_DIR(j); + count_direction.e = -1; + } #else - if (LA_steps > 0) + if (LA_steps > 0) { NORM_E_DIR(stepper_extruder); - else if (LA_steps < 0) + count_direction.e = 1; + } + else if (LA_steps < 0) { REV_E_DIR(stepper_extruder); + count_direction.e = -1; + } #endif DIR_WAIT_AFTER(); @@ -2312,6 +2320,8 @@ uint32_t Stepper::block_phase_isr() { AWAIT_LOW_PULSE(); #endif + count_position.e += count_direction.e; + // Set the STEP pulse ON #if ENABLED(MIXING_EXTRUDER) E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); From 62f992af23b0dd3160db049aa83e541fe164630a Mon Sep 17 00:00:00 2001 From: ellensp Date: Sun, 11 Apr 2021 08:35:45 +1200 Subject: [PATCH 190/311] Followup to "no status for serial::write" (#21577) --- Marlin/src/core/serial_hook.h | 8 +++----- Marlin/src/feature/meatpack.h | 2 +- buildroot/tests/mega2560 | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index 7bc04a5e88..512ebdec97 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -209,11 +209,9 @@ struct MultiSerial : public SerialBase< MultiSerial> { uint8_t charCount; uint8_t readIndex; - NO_INLINE size_t write(uint8_t c) { return out.write(c); } + NO_INLINE void write(uint8_t c) { out.write(c); } void flush() { out.flush(); } void begin(long br) { out.begin(br); readIndex = 0; } void end() { out.end(); } diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 3c8f720238..4ed199df2f 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -171,11 +171,11 @@ exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" # Test Laser features with 12864 LCD # restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 EXTRUDERS 0 TEMP_SENSOR_1 0 SERIAL_PORT_2 2 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ - LASER_FEATURE LASER_COOLANT_FLOW_METER + LASER_FEATURE LASER_COOLANT_FLOW_METER MEATPACK_ON_SERIAL_PORT_1 -exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Cooler | Flowmeter | 12864 LCD " "$3" +exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Cooler | Flowmeter | 12864 LCD | meatpack | SERIAL_PORT_2 " "$3" # # Test Laser features with 44780 LCD From f86423972fa5ca9769df34142fbcc9854d1a13fa Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 10 Apr 2021 18:27:15 -0500 Subject: [PATCH 191/311] EXP2_01_PIN for BTT BTT002 1.0 --- Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 6029031a63..9fb13c84fe 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -194,6 +194,7 @@ #define EXP1_09_PIN PB1 #define EXP1_10_PIN PE7 +#define EXP2_01_PIN PA3 #define EXP2_03_PIN -1 #define EXP2_04_PIN PC4 #define EXP2_05_PIN PA7 From 1114bdbb042469f66f31a94e4b8a46d40c22c21b Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 11 Apr 2021 00:37:24 +0000 Subject: [PATCH 192/311] [cron] Bump distribution date (2021-04-11) --- 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 e307933736..0db2a080d4 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-04-10" + #define STRING_DISTRIBUTION_DATE "2021-04-11" #endif /** From 6ab7baa413b520fde11f588e288b391b39bf4cd8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 8 Apr 2021 15:43:16 -0500 Subject: [PATCH 193/311] tick() => isr() to spotlight interrupt-time --- Marlin/src/module/planner.h | 6 ++---- Marlin/src/module/temperature.cpp | 10 +++++----- Marlin/src/module/temperature.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 570fcc08af..d4ed00d2fa 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -885,11 +885,9 @@ class Planner { // Wait for moves to finish and disable all steppers static void finish_and_disable(); - // Periodic tick to handle cleaning timeouts + // Periodic handler to manage the cleaning buffer counter // Called from the Temperature ISR at ~1kHz - static void tick() { - if (cleaning_buffer_counter) --cleaning_buffer_counter; - } + static void isr() { if (cleaning_buffer_counter) --cleaning_buffer_counter; } /** * Does the buffer have any blocks queued? diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 992681632d..faa5bb5b10 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2835,12 +2835,12 @@ void Temperature::readings_ready() { * - Step the babysteps value for each axis towards 0 * - For PINS_DEBUGGING, monitor and report endstop pins * - For ENDSTOP_INTERRUPTS_FEATURE check endstops if flagged - * - Call planner.tick to count down its "ignore" time + * - Call planner.isr to count down its "ignore" time */ HAL_TEMP_TIMER_ISR() { HAL_timer_isr_prologue(TEMP_TIMER_NUM); - Temperature::tick(); + Temperature::isr(); HAL_timer_isr_epilogue(TEMP_TIMER_NUM); } @@ -2879,7 +2879,7 @@ public: * - Endstop polling * - Planner clean buffer */ -void Temperature::tick() { +void Temperature::isr() { static int8_t temp_count = -1; static ADCSensorState adc_sensor_state = StartupDelay; @@ -3363,8 +3363,8 @@ void Temperature::tick() { // Poll endstops state, if required endstops.poll(); - // Periodically call the planner timer - planner.tick(); + // Periodically call the planner timer service routine + planner.isr(); } #if HAS_TEMP_SENSOR diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 92e436c73f..13dcca2932 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -600,8 +600,8 @@ class Temperature { /** * Called from the Temperature ISR */ + static void isr(); static void readings_ready(); - static void tick(); /** * Call periodically to manage heaters From c35e271dba2f608cb72f48357a1d36a8bfa66a12 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 10 Apr 2021 20:09:15 -0500 Subject: [PATCH 194/311] Clean up, update some variants --- .../variants/BIGTREE_BTT002/PeripheralPins.c | 52 +- .../variants/BIGTREE_BTT002/hal_conf_extra.h | 72 +-- .../variants/BIGTREE_GTR_V1/PeripheralPins.c | 81 ++-- .../variants/BIGTREE_GTR_V1/hal_conf_extra.h | 2 +- .../BIGTREE_SKR_PRO_1v1/PeripheralPins.c | 2 - .../BIGTREE_SKR_PRO_1v1/hal_conf_extra.h | 2 +- .../variants/BTT_SKR_SE_BX/PeripheralPins.c | 326 ++++++------- .../FYSETC_CHEETAH_V20/PeripheralPins.c | 46 +- .../FYSETC_CHEETAH_V20/hal_conf_custom.h | 29 +- .../variants/LERDGE/PeripheralPins.c | 18 - .../variants/MARLIN_F103Vx/PeripheralPins.c | 168 +++---- .../variants/MARLIN_F103Zx/PeripheralPins.c | 158 +++--- .../variants/MARLIN_F103Zx/hal_conf_custom.h | 71 ++- .../variants/MARLIN_F407VE/hal_conf_custom.h | 74 ++- .../variants/MARLIN_F446VE/PeripheralPins.c | 454 ++++++++---------- .../variants/MARLIN_F4x7Vx/PeripheralPins.c | 270 +++++------ .../variants/MARLIN_F4x7Vx/hal_conf_extra.h | 27 +- .../MARLIN_FYSETC_S6/PeripheralPins.c | 306 ++++++------ .../variants/STEVAL_F401VE/PeripheralPins.c | 222 ++++----- .../variants/STEVAL_F401VE/hal_conf_custom.h | 71 ++- 20 files changed, 1141 insertions(+), 1310 deletions(-) diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/PeripheralPins.c b/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/PeripheralPins.c index bee09b15b1..933b62ae9b 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/PeripheralPins.c @@ -41,32 +41,32 @@ #ifdef HAL_ADC_MODULE_ENABLED const PinMap PinMap_ADC[] = { - {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 E0_DIR - {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 BLTOUCH_2 - {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 BLTOUCH_4 - {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 E1_EN - {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 TF_SS - {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 TF_SCLK - {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 TF_MISO - {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 LED - {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 HEATER2 - {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 HEATER0 - {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 Z_EN - {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 EXP_14 - {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 Z_DIR - {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 E0_EN - {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 EXP_8 - {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 EXP_7 + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 TEMP_1 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 TEMP_BED + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 TEMP_0 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 EXP2-1 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 TF_SS SD_SS (CUSTOM_SPI_PINS) + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 TF_SCLK SD_SCK + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 TF_MISO SD_MISO + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 LED SD_MOSI + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 BTN_EN2 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 BTN_ENC + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 --- + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 --- + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 --- + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 TEMP_PROBE + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 SD_DETECT + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 BTN_EN1 - #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio, 24 ADC - {PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 TH_0 + #if STM32F4X_PIN_NUM >= 144 // 144 pins mcu, 114 gpio, 24 ADC + {PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 TH_0 {PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 TH_1 {PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 TH_2 - {PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 TH_3 - {PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 EXP_13 - {PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 EXP_3 - {PF_9, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_IN7 EXP_6 - {PF_10, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_IN8 EXP_5 + {PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 TH_3 + {PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 EXP_13 + {PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 EXP_3 + {PF_9, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_IN7 EXP_6 + {PF_10, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_IN8 EXP_5 #endif {NC, NP, 0} }; @@ -95,9 +95,7 @@ const PinMap PinMap_I2C_SDA[] = { #endif {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, @@ -114,8 +112,8 @@ const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED const PinMap PinMap_PWM[] = { - {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 BED - {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 HEATER0 + {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 BED + {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 HEATER0 {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 FAN0 {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 FAN1 diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/hal_conf_extra.h index e0e8239aac..40b340c205 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/hal_conf_extra.h @@ -8,45 +8,45 @@ #define HAL_I2C_MODULE_ENABLED #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED -//#define HAL_RTC_MODULE_ENABLED Real Time Clock...do we use it? +//#define HAL_RTC_MODULE_ENABLED // Real Time Clock...do we use it? #define HAL_SPI_MODULE_ENABLED #define HAL_TIM_MODULE_ENABLED #define HAL_USART_MODULE_ENABLED #define HAL_CORTEX_MODULE_ENABLED //#define HAL_UART_MODULE_ENABLED // by default -//#define HAL_PCD_MODULE_ENABLED // Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) +//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) -#undef HAL_SD_MODULE_ENABLED -#undef HAL_DAC_MODULE_ENABLED -#undef HAL_FLASH_MODULE_ENABLED -#undef HAL_CAN_MODULE_ENABLED -#undef HAL_CAN_LEGACY_MODULE_ENABLED -#undef HAL_CEC_MODULE_ENABLED -#undef HAL_CRYP_MODULE_ENABLED -#undef HAL_DCMI_MODULE_ENABLED -#undef HAL_DMA2D_MODULE_ENABLED -#undef HAL_ETH_MODULE_ENABLED -#undef HAL_NAND_MODULE_ENABLED -#undef HAL_NOR_MODULE_ENABLED -#undef HAL_PCCARD_MODULE_ENABLED -#undef HAL_SRAM_MODULE_ENABLED -#undef HAL_SDRAM_MODULE_ENABLED -#undef HAL_HASH_MODULE_ENABLED -#undef HAL_EXTI_MODULE_ENABLED -#undef HAL_SMBUS_MODULE_ENABLED -#undef HAL_I2S_MODULE_ENABLED -#undef HAL_IWDG_MODULE_ENABLED -#undef HAL_LTDC_MODULE_ENABLED -#undef HAL_DSI_MODULE_ENABLED -#undef HAL_QSPI_MODULE_ENABLED -#undef HAL_RNG_MODULE_ENABLED -#undef HAL_SAI_MODULE_ENABLED -#undef HAL_IRDA_MODULE_ENABLED -#undef HAL_SMARTCARD_MODULE_ENABLED -#undef HAL_WWDG_MODULE_ENABLED -#undef HAL_HCD_MODULE_ENABLED -#undef HAL_FMPI2C_MODULE_ENABLED -#undef HAL_SPDIFRX_MODULE_ENABLED -#undef HAL_DFSDM_MODULE_ENABLED -#undef HAL_LPTIM_MODULE_ENABLED -#undef HAL_MMC_MODULE_ENABLED +//#define HAL_SD_MODULE_ENABLED +//#define HAL_DAC_MODULE_ENABLED +//#define HAL_FLASH_MODULE_ENABLED +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED +//#define HAL_EXTI_MODULE_ENABLED +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c index db0a439562..48e05e45ad 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c @@ -48,7 +48,7 @@ const PinMap PinMap_ADC[] = { {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 TF_SS {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 TF_SCLK {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 TF_MISO - {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 LED + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 LED (MOSI) {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 HEATER2 {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 HEATER0 {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 Z_EN @@ -100,9 +100,7 @@ const PinMap PinMap_I2C_SDA[] = { #endif {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, @@ -154,7 +152,6 @@ const PinMap PinMap_PWM[] = { {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 FAN6 {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 FAN7 - // Alternate timer assignments for pins commonly using PWM //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N HEATER0 //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N HEATER0 @@ -179,55 +176,55 @@ const PinMap PinMap_PWM[] = { * WARNING: check timers' usage first to avoid conflicts. * If you don't know what you're doing leave things as they are or you WILL break something (including hardware) */ - //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 - //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - //{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 - //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 - //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - //{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 - //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 - //{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 - //{PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + //{PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N //{PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 //{PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 //{PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 //{PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - //{PH_10, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PH_10, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 //{PH_6, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 - //{PH_11, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PH_11, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 {NC, NP, 0} }; #endif diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h index cbce513d1b..e6d558b3e1 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h @@ -14,7 +14,7 @@ #define HAL_USART_MODULE_ENABLED #define HAL_CORTEX_MODULE_ENABLED //#define HAL_UART_MODULE_ENABLED // by default -//#define HAL_PCD_MODULE_ENABLED // Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) +//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) //#define HAL_SD_MODULE_ENABLED //#define HAL_DAC_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c index 6dc8b05158..4ea275d4cf 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c @@ -100,9 +100,7 @@ const PinMap PinMap_I2C_SDA[] = { #endif {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h index cbce513d1b..e6d558b3e1 100644 --- a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h @@ -14,7 +14,7 @@ #define HAL_USART_MODULE_ENABLED #define HAL_CORTEX_MODULE_ENABLED //#define HAL_UART_MODULE_ENABLED // by default -//#define HAL_PCD_MODULE_ENABLED // Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) +//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) //#define HAL_SD_MODULE_ENABLED //#define HAL_DAC_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c index 3defef5fbf..c9194cc293 100644 --- a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c @@ -89,26 +89,24 @@ WEAK const PinMap PinMap_DAC[] = { #ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SDA[] = { - // {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // LD2 LED_BLUE (ZI) + //{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // LD2 LED_BLUE (ZI) {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_7, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, // LD2 LED_BLUE (ZI) - // {PB_9, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + //{PB_9, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, - // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PD_13, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, {PF_0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PF_15, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { - // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // USB SOF - // {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // QSPI_CS + //{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // USB SOF + //{PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // QSPI_CS {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_6, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, // QSPI_CS - // {PB_8, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + //{PB_8, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PD_12, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, {PF_1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, @@ -121,64 +119,64 @@ WEAK const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED WEAK const PinMap PinMap_PWM[] = { - // {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - ETH RMII Ref Clk - // {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - ETH RMII Ref Clk - // {PA_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N - ETH RMII Ref Clk - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - ETH RMII MDIO + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - ETH RMII Ref Clk + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - ETH RMII Ref Clk + //{PA_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N - ETH RMII Ref Clk + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - ETH RMII MDIO {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - ETH RMII MDIO - // {PA_2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1 - ETH RMII MDIO - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - // {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + //{PA_2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1 - ETH RMII MDIO + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 {PA_3, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 - // {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 - // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - Used by ETH when JP6(ZI)/SB31(ZI2) ON - // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - Used by ETH when JP6(ZI)/SB31(ZI2) ON - // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - Used by ETH when JP6(ZI)/SB31(ZI2) ON + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - Used by ETH when JP6(ZI)/SB31(ZI2) ON + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - Used by ETH when JP6(ZI)/SB31(ZI2) ON + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - Used by ETH when JP6(ZI)/SB31(ZI2) ON {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - Used by ETH when JP6(ZI)/SB31(ZI2) ON - // {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - USB SOF - // {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - USB VBUS - // {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - USB ID - // {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - USB DM - // {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - USB SOF + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - USB VBUS + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - USB ID + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - USB DM + //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - LD1 LED_GREEN - // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - LD1 LED_GREEN - // {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - LD1 LED_GREEN - // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - LD1 LED_GREEN + //{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - LD1 LED_GREEN + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - // {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N - // {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - SWO + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - SWO {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PB_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N - // {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - LD2 LED_BLUE (ZI) + //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - LD2 LED_BLUE (ZI) {PB_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N - LD2 LED_BLUE (ZI) {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - // {PB_8, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 - // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_8, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 {PB_9, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_CH1 - // {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - // {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - // {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - Used by ETH when JP7(ZI)/JP6(ZI2) ON + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - Used by ETH when JP7(ZI)/JP6(ZI2) ON {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - LD3 LED_RED - // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - LD3 LED_RED - // {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 1, 0)}, // TIM12_CH1 - LD3 LED_RED - // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - LD3 LED_RED + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 1, 0)}, // TIM12_CH1 - LD3 LED_RED + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N - // {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 2, 0)}, // TIM12_CH2 - // {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 2, 0)}, // TIM12_CH2 + //{PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 - // {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + //{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - // {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + //{PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 @@ -196,9 +194,9 @@ WEAK const PinMap PinMap_PWM[] = { {PF_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 {PF_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_CH1 {PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 - // {PF_8, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N + //{PF_8, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N {PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - // {PF_9, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N + //{PF_9, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N {NC, NP, 0} }; #endif @@ -208,22 +206,22 @@ WEAK const PinMap PinMap_PWM[] = { #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_TX[] = { {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // ETH RMII MDIO - // {PA_9, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB VBUS + //{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // ETH RMII MDIO + //{PA_9, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB VBUS {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB VBUS - // {PA_12, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // USB DP + //{PA_12, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // USB DP //{PA_15, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, //{PB_4, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, - // {PB_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, - // {PB_6, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + //{PB_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, + //{PB_6, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, //{PB_9, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PB_13, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON - // {PB_14, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, // LD3 LED_RED + //{PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PB_13, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON + //{PB_14, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, // LD3 LED_RED //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, //{PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, //{PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, //{PD_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, //{PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, @@ -234,27 +232,25 @@ WEAK const PinMap PinMap_UART_TX[] = { //{PG_14, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // ETH RMII Ref Clk - // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // USB SOF - // {PA_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB ID + //{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // USB SOF + //{PA_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB ID {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB ID - // {PA_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // USB DM + //{PA_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, // USB DM //{PB_3, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, // SWO //{PB_5, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, - // {PB_7, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, // LD2 LED_BLUE (ZI) - // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // LD2 LED_BLUE (ZI) + //{PB_7, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, // LD2 LED_BLUE (ZI) + //{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // LD2 LED_BLUE (ZI) //{PB_8, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, //{PB_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, //{PB_15, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, //{PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, //{PD_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, //{PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, //{PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, @@ -265,16 +261,14 @@ WEAK const PinMap PinMap_UART_RX[] = { //{PG_9, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RTS[] = { - // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // ETH RMII Ref Clk - // {PA_12, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB DP - // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB DP + //{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // ETH RMII Ref Clk + //{PA_12, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB DP + //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB DP {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PB_14, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // LD3 LED_RED - // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // LD3 LED_RED + //{PB_14, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // LD3 LED_RED + //{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // LD3 LED_RED {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, @@ -285,15 +279,13 @@ WEAK const PinMap PinMap_UART_RTS[] = { {PG_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB DM - // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB DM - // {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // LD1 LED_GREEN - // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON + //{PA_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, // USB DM + //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // USB DM + //{PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // LD1 LED_GREEN + //{PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON {PB_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, @@ -301,7 +293,7 @@ WEAK const PinMap PinMap_UART_CTS[] = { {PD_14, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, {PE_10, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, {PF_9, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, - // {PG_13, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + //{PG_13, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, {PG_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, {NC, NP, 0} }; @@ -313,83 +305,77 @@ WEAK const PinMap PinMap_UART_CTS[] = { WEAK const PinMap PinMap_SPI_MOSI[] = { {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, //{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // Used by ETH when JP6(ZI)/SB31(ZI2) ON - // {PA_7, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, // Used by ETH when JP6(ZI)/SB31(ZI2) ON - // {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, - // // {PB_5, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, - // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // // {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // ETH RMII MDC - // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, - // {PD_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PF_9, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, - // {PF_11, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, - // {PG_14, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + //{PA_7, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, // Used by ETH when JP6(ZI)/SB31(ZI2) ON + //{PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + //{PB_5, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + //{PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // ETH RMII MDC + //{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + //{PD_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PF_9, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + //{PF_11, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + //{PG_14, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // // {PA_6, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, - // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // // {PB_4, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, - // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // LD3 LED_RED - // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PF_8, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, - // {PG_9, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PG_12, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + //{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_6, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_4, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + //{PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // LD3 LED_RED + //{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PF_8, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + //{PG_9, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PG_12, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // // {PA_5, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, - // // {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB VBUS - // // {PA_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB DP - // // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // SWO - // // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, // SWO - // {PB_3, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, // SWO - // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // // {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON - // {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PF_7, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, - // {PG_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // ETH RMII TX Enable - // {PG_13, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, // ETH RXII TXD0 + //{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_5, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + //{PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB VBUS + //{PA_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB DP + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // SWO + //{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, // SWO + //{PB_3, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, // SWO + //{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON + //{PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PF_7, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + //{PG_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // ETH RMII TX Enable + //{PG_13, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, // ETH RXII TXD0 {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // // {PA_4, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, - // // {PA_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB DM - // // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // // {PA_15, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI6)}, - // {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, - // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PF_6, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, - // {PG_8, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, - // {PG_10, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_4, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + //{PA_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // USB DM + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_15, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI6)}, + //{PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + //{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PF_6, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + //{PG_8, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + //{PG_10, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {NC, NP, 0} }; #endif @@ -398,22 +384,20 @@ WEAK const PinMap PinMap_SPI_SSEL[] = { #ifdef HAL_CAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_RD[] = { - // {PA_11, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, // USB DM + //{PA_11, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, // USB DM {PB_5, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, {PB_8, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {PB_12, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, {PD_0, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {NC, NP, 0} }; -#endif -#ifdef HAL_CAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_TD[] = { - // {PA_12, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, // USB DP + //{PA_12, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, // USB DP {PB_6, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, // QSPI_CS {PB_7, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, // LD2 LED_BLUE (ZI) {PB_9, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, - // {PB_13, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON + //{PB_13, CANFD2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, // Used by ETH when JP7(ZI)/JP6(ZI2) ON {PD_1, CANFD1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, {NC, NP, 0} }; @@ -423,30 +407,30 @@ WEAK const PinMap PinMap_CAN_TD[] = { #ifdef HAL_ETH_MODULE_ENABLED WEAK const PinMap PinMap_Ethernet[] = { - // {PA_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS + //{PA_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS {PA_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_REF_CLK|ETH_RX_CLK {PA_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDIO - // {PA_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_COL + //{PA_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_COL {PA_7, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS_DV|ETH_RX_DV - // {PB_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD2 - // {PB_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD3 - // {PB_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT - // {PB_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 - // {PB_10, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_ER - // {PB_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN - // {PB_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 + //{PB_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD2 + //{PB_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD3 + //{PB_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT + //{PB_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 + //{PB_10, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_ER + //{PB_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN + //{PB_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 {PB_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 {PC_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDC - // {PC_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2 - // {PC_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_CLK + //{PC_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2 + //{PC_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_CLK {PC_4, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD0 {PC_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD1 - // {PE_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 - // {PG_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT + //{PE_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 + //{PG_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT {PG_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN - // {PG_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + //{PG_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 {PG_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 - // {PG_14, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + //{PG_14, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 {NC, NP, 0} }; #endif @@ -455,21 +439,19 @@ WEAK const PinMap PinMap_Ethernet[] = { #ifdef HAL_PCD_MODULE_ENABLED WEAK const PinMap PinMap_USB_OTG_FS[] = { - // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_SOF - // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS - // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_ID + //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_SOF + //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_ID {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DM {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DP {NC, NP, 0} }; -#endif -#ifdef HAL_PCD_MODULE_ENABLED WEAK const PinMap PinMap_USB_OTG_HS[] = { #ifdef USE_USB_HS_IN_FS - // {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_SOF - // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_ID - // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS - Used by ETH when JP7(ZI)/JP6(ZI2) ON + //{PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_SOF + //{PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_ID + //{PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS - Used by ETH when JP7(ZI)/JP6(ZI2) ON {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DM {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DP #else diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/PeripheralPins.c b/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/PeripheralPins.c index 3957069f28..418ef5aa7a 100644 --- a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/PeripheralPins.c @@ -74,9 +74,7 @@ WEAK const PinMap PinMap_I2C_SDA[] = { {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, @@ -90,28 +88,28 @@ WEAK const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED WEAK const PinMap PinMap_PWM[] = { - // {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 @@ -119,9 +117,9 @@ WEAK const PinMap PinMap_PWM[] = { {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - // {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N @@ -145,9 +143,7 @@ WEAK const PinMap PinMap_UART_TX[] = { {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, @@ -156,17 +152,13 @@ WEAK const PinMap PinMap_UART_RX[] = { {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, @@ -179,44 +171,38 @@ WEAK const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h index 6c56b97a74..395bfcd4b7 100644 --- a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h @@ -33,49 +33,48 @@ extern "C" { */ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) + //#define HAL_CAN_MODULE_ENABLED //#define HAL_CAN_LEGACY_MODULE_ENABLED -#define HAL_CRC_MODULE_ENABLED //#define HAL_CEC_MODULE_ENABLED //#define HAL_CRYP_MODULE_ENABLED //#define HAL_DAC_MODULE_ENABLED //#define HAL_DCMI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED //#define HAL_DMA2D_MODULE_ENABLED //#define HAL_ETH_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED //#define HAL_NAND_MODULE_ENABLED //#define HAL_NOR_MODULE_ENABLED //#define HAL_PCCARD_MODULE_ENABLED //#define HAL_SRAM_MODULE_ENABLED //#define HAL_SDRAM_MODULE_ENABLED //#define HAL_HASH_MODULE_ENABLED -#define HAL_GPIO_MODULE_ENABLED //#define HAL_EXTI_MODULE_ENABLED -#define HAL_I2C_MODULE_ENABLED //#define HAL_SMBUS_MODULE_ENABLED //#define HAL_I2S_MODULE_ENABLED -#define HAL_IWDG_MODULE_ENABLED //#define HAL_LTDC_MODULE_ENABLED //#define HAL_DSI_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED //#define HAL_QSPI_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED //#define HAL_RNG_MODULE_ENABLED -#define HAL_RTC_MODULE_ENABLED //#define HAL_SAI_MODULE_ENABLED //#define HAL_SD_MODULE_ENABLED -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED //#define HAL_UART_MODULE_ENABLED //#define HAL_USART_MODULE_ENABLED //#define HAL_IRDA_MODULE_ENABLED //#define HAL_SMARTCARD_MODULE_ENABLED //#define HAL_WWDG_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED -#ifndef HAL_PCD_MODULE_ENABLED - #define HAL_PCD_MODULE_ENABLED //Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) -#endif //#define HAL_HCD_MODULE_ENABLED //#define HAL_FMPI2C_MODULE_ENABLED //#define HAL_SPDIFRX_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/LERDGE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/LERDGE/PeripheralPins.c index 8cb0776ffa..044f555a41 100644 --- a/buildroot/share/PlatformIO/variants/LERDGE/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/LERDGE/PeripheralPins.c @@ -114,9 +114,7 @@ const PinMap PinMap_I2C_SDA[] = { {PF_0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, @@ -225,9 +223,7 @@ const PinMap PinMap_UART_TX[] = { {PG_14, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED const PinMap PinMap_UART_RX[] = { {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, @@ -243,9 +239,7 @@ const PinMap PinMap_UART_RX[] = { {PG_9, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED const PinMap PinMap_UART_RTS[] = { {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, @@ -256,9 +250,7 @@ const PinMap PinMap_UART_RTS[] = { {PG_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED const PinMap PinMap_UART_CTS[] = { {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, @@ -283,9 +275,7 @@ const PinMap PinMap_SPI_MOSI[] = { {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, @@ -295,9 +285,7 @@ const PinMap PinMap_SPI_MISO[] = { {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, @@ -307,9 +295,7 @@ const PinMap PinMap_SPI_SCLK[] = { {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, @@ -332,9 +318,7 @@ const PinMap PinMap_CAN_RD[] = { {PD_0, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {NC, NP, 0} }; -#endif -#ifdef HAL_CAN_MODULE_ENABLED const PinMap PinMap_CAN_TD[] = { {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, @@ -389,9 +373,7 @@ const PinMap PinMap_USB_OTG_FS[] = { {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP {NC, NP, 0} }; -#endif -#ifdef HAL_PCD_MODULE_ENABLED const PinMap PinMap_USB_OTG_HS[] = { #ifdef USE_USB_HS_IN_FS {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c index c9d2bb88b8..339a55916c 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c @@ -25,61 +25,61 @@ #ifdef HAL_ADC_MODULE_ENABLED WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + //{PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + //{PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 #endif {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + //{PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + //{PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 #endif {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 - // {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + //{PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + //{PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 #endif {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + //{PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + //{PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 #endif {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - // {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + //{PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + //{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - // {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + //{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - // {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + //{PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + //{PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - // {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + //{PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + //{PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 #endif {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + //{PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + //{PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 #endif {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 - // {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + //{PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + //{PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 #endif {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + //{PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + //{PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 #endif {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - // {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + //{PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + //{PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 {NC, NP, 0} }; #endif @@ -105,9 +105,7 @@ WEAK const PinMap PinMap_I2C_SDA[] = { {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_NONE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_NONE)}, {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_I2C1_ENABLE)}, @@ -121,105 +119,105 @@ WEAK const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED WEAK const PinMap PinMap_PWM[] = { {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM2_CH1 - // {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 1, 0)}, // TIM2_CH1 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM5_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM5_CH1 #endif {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM2_CH2 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 2, 0)}, // TIM2_CH2 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 2, 0)}, // TIM2_CH2 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM5_CH2 + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM5_CH2 #endif {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM2_CH3 - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 3, 0)}, // TIM2_CH3 + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 3, 0)}, // TIM2_CH3 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM5_CH3 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM5_CH3 #endif #ifdef STM32F103xG - // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM9_CH1 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM9_CH1 #endif - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 4, 0)}, // TIM2_CH4 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM5_CH4 #else {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 #endif #if defined(STM32F103xG) - // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM9_CH2 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM9_CH2 #endif {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM3_CH1 #if defined(STM32F103xG) - // {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM13_CH1 + //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM13_CH1 #endif {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 1)}, // TIM1_CH1N - // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM3_CH2 - // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM8_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM8_CH1N #if defined(STM32F103xG) - // {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM14_CH1 + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM14_CH1 #endif {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM1_CH1 - // {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 0)}, // TIM1_CH1 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 0)}, // TIM1_CH1 {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM1_CH2 - // {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 2, 0)}, // TIM1_CH2 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 2, 0)}, // TIM1_CH2 {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM1_CH3 - // {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 3, 0)}, // TIM1_CH3 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 3, 0)}, // TIM1_CH3 {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM1_CH4 - // {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 4, 0)}, // TIM1_CH4 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 4, 0)}, // TIM1_CH4 {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 1, 0)}, // TIM2_CH1 - // {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 1, 0)}, // TIM2_CH1 - // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 2, 1)}, // TIM1_CH2N + //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 1, 0)}, // TIM2_CH1 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 2, 1)}, // TIM1_CH2N {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM3_CH3 - // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 3, 0)}, // TIM3_CH3 + //{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 3, 0)}, // TIM3_CH3 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM8_CH2N + //{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM8_CH2N #endif {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 3, 1)}, // TIM1_CH3N - // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM3_CH4 - // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 4, 0)}, // TIM3_CH4 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM8_CH3N + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM8_CH3N #endif {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 2, 0)}, // TIM2_CH2 - // {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 2, 0)}, // TIM2_CH2 + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 2, 0)}, // TIM2_CH2 {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 1, 0)}, // TIM3_CH1 {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 2, 0)}, // TIM3_CH2 {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM4_CH1 {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM4_CH2 {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM4_CH3 #if defined(STM32F103xG) - // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM10_CH1 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM10_CH1 #endif {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM4_CH4 #if defined(STM32F103xG) - // {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM11_CH1 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM11_CH1 #endif {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 3, 0)}, // TIM2_CH3 - // {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 3, 0)}, // TIM2_CH3 + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 3, 0)}, // TIM2_CH3 {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 4, 0)}, // TIM2_CH4 - // {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 4, 0)}, // TIM2_CH4 + //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 4, 0)}, // TIM2_CH4 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM1_CH1N {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM1_CH2N #if defined(STM32F103xG) - // {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM12_CH1 + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM12_CH1 #endif {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM1_CH3N #if defined(STM32F103xG) - // {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM12_CH2 + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM12_CH2 #endif {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 1, 0)}, // TIM3_CH1 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM8_CH1 + //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM8_CH1 #endif {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 2, 0)}, // TIM3_CH2 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM8_CH2 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM8_CH2 #endif {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 3, 0)}, // TIM3_CH3 - // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM8_CH3 + //{PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM8_CH3 {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 4, 0)}, // TIM3_CH4 #if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM8_CH4 + //{PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM8_CH4 #endif {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 1, 0)}, // TIM4_CH1 {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 2, 0)}, // TIM4_CH2 @@ -248,29 +246,27 @@ WEAK const PinMap PinMap_UART_TX[] = { {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART1_ENABLE)}, {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, -#if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, - {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, -#else - {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, -#endif -#if defined(STM32F103xE) || defined(STM32F103xG) - {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, -#endif + #if defined(STM32F103xE) || defined(STM32F103xG) + //{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, + #else + {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + #endif + #if defined(STM32F103xE) || defined(STM32F103xG) + {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, + #endif {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART2_ENABLE)}, {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_ENABLE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { {PA_3, USART2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, {PA_10, USART1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, {PB_7, USART1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART1_ENABLE)}, {PB_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, #if defined(STM32F103xE) || defined(STM32F103xG) - // {PC_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + //{PC_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, {PC_11, UART4, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, #else {PC_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, @@ -282,26 +278,22 @@ WEAK const PinMap PinMap_UART_RX[] = { {PD_9, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_ENABLE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + //{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART2_ENABLE)}, {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_ENABLE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + //{PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART2_ENABLE)}, {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_ENABLE)}, {NC, NP, 0} @@ -314,7 +306,7 @@ WEAK const PinMap PinMap_UART_CTS[] = { WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #if defined(STM32F103xE) || defined(STM32F103xG) - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #else {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, @@ -322,13 +314,11 @@ WEAK const PinMap PinMap_SPI_MOSI[] = { {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #if defined(STM32F103xE) || defined(STM32F103xG) - // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #else {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, @@ -336,13 +326,11 @@ WEAK const PinMap PinMap_SPI_MISO[] = { {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #if defined(STM32F103xE) || defined(STM32F103xG) - // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #else {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, @@ -350,13 +338,11 @@ WEAK const PinMap PinMap_SPI_SCLK[] = { {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #if defined(STM32F103xE) || defined(STM32F103xG) - // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #else {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, @@ -375,9 +361,7 @@ WEAK const PinMap PinMap_CAN_RD[] = { {PD_0, CAN1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, AFIO_CAN1_3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_CAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, AFIO_NONE)}, {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, AFIO_CAN1_2)}, diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/PeripheralPins.c index 5736e5206e..0d7365c9c5 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/PeripheralPins.c @@ -25,45 +25,45 @@ #ifdef HAL_ADC_MODULE_ENABLED WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 - // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + //{PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + //{PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 - // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 - // {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + //{PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + //{PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + //{PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 - // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + //{PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 - // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 - // {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + //{PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + //{PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + //{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 - // {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + //{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 - // {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 - // {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + //{PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + //{PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 - // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + //{PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 - // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 - // {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + //{PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + //{PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + //{PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 - // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + //{PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 - // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 - // {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + //{PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + //{PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + //{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + //{PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 {PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 {PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 {PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 @@ -92,9 +92,7 @@ WEAK const PinMap PinMap_I2C_SDA[] = { {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_NONE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_NONE)}, {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_I2C1_ENABLE)}, @@ -108,86 +106,86 @@ WEAK const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED WEAK const PinMap PinMap_PWM[] = { {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM2_CH1 - // {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 1, 0)}, // TIM2_CH1 - // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM5_CH1 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM2_CH2 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 2, 0)}, // TIM2_CH2 + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM5_CH1 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM2_CH2 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 2, 0)}, // TIM2_CH2 {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM5_CH2 {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM2_CH3 - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 3, 0)}, // TIM2_CH3 - // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM5_CH3 + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 3, 0)}, // TIM2_CH3 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM5_CH3 #ifdef STM32F103xG - // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM9_CH1 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM9_CH1 #endif - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 4, 0)}, // TIM2_CH4 {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM5_CH4 #ifdef STM32F103xG - // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM9_CH2 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM9_CH2 #endif {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM3_CH1 #ifdef STM32F103xG - // {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM13_CH1 + //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM13_CH1 #endif - // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 1)}, // TIM1_CH1N - // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM3_CH2 {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM8_CH1N #ifdef STM32F103xG - // {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM14_CH1 + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM14_CH1 #endif {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM1_CH1 - // {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 0)}, // TIM1_CH1 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 0)}, // TIM1_CH1 {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM1_CH2 - // {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 2, 0)}, // TIM1_CH2 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 2, 0)}, // TIM1_CH2 {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM1_CH3 - // {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 3, 0)}, // TIM1_CH3 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 3, 0)}, // TIM1_CH3 {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM1_CH4 - // {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 4, 0)}, // TIM1_CH4 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 4, 0)}, // TIM1_CH4 {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 1, 0)}, // TIM2_CH1 - // {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 1, 0)}, // TIM2_CH1 - // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 2, 1)}, // TIM1_CH2N + //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 1, 0)}, // TIM2_CH1 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 2, 1)}, // TIM1_CH2N {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM3_CH3 - // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 3, 0)}, // TIM3_CH3 + //{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 3, 0)}, // TIM3_CH3 {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM8_CH2N {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 3, 1)}, // TIM1_CH3N - // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM3_CH4 - // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 4, 0)}, // TIM3_CH4 - // {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM8_CH3N + //{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM8_CH3N {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 2, 0)}, // TIM2_CH2 - // {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 2, 0)}, // TIM2_CH2 + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 2, 0)}, // TIM2_CH2 {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 1, 0)}, // TIM3_CH1 {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 2, 0)}, // TIM3_CH2 {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM4_CH1 {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM4_CH2 {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM4_CH3 #ifdef STM32F103xG - // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM10_CH1 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM10_CH1 #endif {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM4_CH4 #ifdef STM32F103xG - // {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM11_CH1 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM11_CH1 #endif - // {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 3, 0)}, // TIM2_CH3 + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 3, 0)}, // TIM2_CH3 {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 3, 0)}, // TIM2_CH3 - // {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 4, 0)}, // TIM2_CH4 + //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 4, 0)}, // TIM2_CH4 {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 4, 0)}, // TIM2_CH4 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM1_CH1N {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM1_CH2N #ifdef STM32F103xG - // {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM12_CH1 + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM12_CH1 #endif {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM1_CH3N #ifdef STM32F103xG - // {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM12_CH2 + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM12_CH2 #endif - // {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 1, 0)}, // TIM3_CH1 + //{PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 1, 0)}, // TIM3_CH1 {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM8_CH1 - // {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 2, 0)}, // TIM3_CH2 + //{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 2, 0)}, // TIM3_CH2 {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM8_CH2 {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 3, 0)}, // TIM3_CH3 - // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM8_CH3 + //{PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM8_CH3 {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 4, 0)}, // TIM3_CH4 - // {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM8_CH4 + //{PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM8_CH4 {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 1, 0)}, // TIM4_CH1 {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 2, 0)}, // TIM4_CH2 {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 3, 0)}, // TIM4_CH3 @@ -222,47 +220,41 @@ WEAK const PinMap PinMap_UART_TX[] = { {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART1_ENABLE)}, {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + //{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART2_ENABLE)}, {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_ENABLE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { {PA_3, USART2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, {PA_10, USART1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, {PB_7, USART1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART1_ENABLE)}, {PB_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, {PC_11, UART4, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, - // {PC_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + //{PC_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, {PD_2, UART5, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, {PD_6, USART2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART2_ENABLE)}, {PD_9, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_ENABLE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + //{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART2_ENABLE)}, {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_ENABLE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, + //{PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART2_ENABLE)}, {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_ENABLE)}, {NC, NP, 0} @@ -274,37 +266,31 @@ WEAK const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, - // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)}, {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, {NC, NP, 0} @@ -320,9 +306,7 @@ WEAK const PinMap PinMap_CAN_RD[] = { {PD_0, CAN1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, AFIO_CAN1_3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_CAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, AFIO_NONE)}, {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, AFIO_CAN1_2)}, @@ -353,10 +337,10 @@ WEAK const PinMap PinMap_USB[] = { #ifdef HAL_SD_MODULE_ENABLED WEAK const PinMap PinMap_SD[] = { - // {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D4 - // {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D5 - // {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D6 - // {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D7 + //{PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D4 + //{PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D5 + //{PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D6 + //{PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D7 {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D0 {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D1 {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, // SDIO_D2 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h index 014943f311..4e55fe1240 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h @@ -33,45 +33,44 @@ extern "C" { * and manage module deactivation */ #include "stm32yyxx_hal_conf.h" -#if 0 + /** * @brief This is the list of modules to be used in the HAL driver */ -#define HAL_MODULE_ENABLED -#define HAL_ADC_MODULE_ENABLED -#define HAL_CAN_MODULE_ENABLED -/*#define HAL_CAN_LEGACY_MODULE_ENABLED*/ -#define HAL_CEC_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED -#define HAL_CRC_MODULE_ENABLED -#define HAL_DAC_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_ETH_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_GPIO_MODULE_ENABLED -#define HAL_HCD_MODULE_ENABLED -#define HAL_I2C_MODULE_ENABLED -#define HAL_I2S_MODULE_ENABLED -#define HAL_IRDA_MODULE_ENABLED -#define HAL_IWDG_MODULE_ENABLED -#define HAL_NAND_MODULE_ENABLED -#define HAL_NOR_MODULE_ENABLED -#define HAL_PCCARD_MODULE_ENABLED -#define HAL_PCD_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_RTC_MODULE_ENABLED -#define HAL_SD_MODULE_ENABLED -#define HAL_SMARTCARD_MODULE_ENABLED -#define HAL_SPI_MODULE_ENABLED -#define HAL_SRAM_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED -#define HAL_USART_MODULE_ENABLED -#define HAL_WWDG_MODULE_ENABLED -#define HAL_MMC_MODULE_ENABLED -#endif +//#define HAL_MODULE_ENABLED +//#define HAL_ADC_MODULE_ENABLED +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CORTEX_MODULE_ENABLED +//#define HAL_CRC_MODULE_ENABLED +//#define HAL_DAC_MODULE_ENABLED +//#define HAL_DMA_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_EXTI_MODULE_ENABLED +//#define HAL_FLASH_MODULE_ENABLED +//#define HAL_GPIO_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_I2C_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_PCD_MODULE_ENABLED +//#define HAL_PWR_MODULE_ENABLED +//#define HAL_RCC_MODULE_ENABLED +//#define HAL_RTC_MODULE_ENABLED +//#define HAL_SD_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_SPI_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_TIM_MODULE_ENABLED +//#define HAL_UART_MODULE_ENABLED +//#define HAL_USART_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED /* ########################## Oscillator Values adaptation ####################*/ /** diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h index 92e9fecb4d..1252bc7059 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h @@ -33,55 +33,54 @@ extern "C" { */ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ #define HAL_CRC_MODULE_ENABLED -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ #define HAL_DAC_MODULE_ENABLED -/* #define HAL_DCMI_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -/* #define HAL_SDRAM_MODULE_ENABLED */ -/* #define HAL_HASH_MODULE_ENABLED */ #define HAL_GPIO_MODULE_ENABLED -/* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_I2C_MODULE_ENABLED -/* #define HAL_SMBUS_MODULE_ENABLED */ -/* #define HAL_I2S_MODULE_ENABLED */ -/* #define HAL_IWDG_MODULE_ENABLED */ -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ #define HAL_PWR_MODULE_ENABLED -/* #define HAL_QSPI_MODULE_ENABLED */ #define HAL_RCC_MODULE_ENABLED -/* #define HAL_RNG_MODULE_ENABLED */ #define HAL_RTC_MODULE_ENABLED -/* #define HAL_SAI_MODULE_ENABLED */ #define HAL_SD_MODULE_ENABLED #define HAL_SPI_MODULE_ENABLED #define HAL_TIM_MODULE_ENABLED -/* #define HAL_UART_MODULE_ENABLED */ -/* #define HAL_USART_MODULE_ENABLED */ -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED -#ifndef HAL_PCD_MODULE_ENABLED - #define HAL_PCD_MODULE_ENABLED //Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) -#endif -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ +//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) + +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED +//#define HAL_EXTI_MODULE_ENABLED +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_UART_MODULE_ENABLED +//#define HAL_USART_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED /* ########################## HSE/HSI Values adaptation ##################### */ /** @@ -204,7 +203,7 @@ in voltage and temperature. */ * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ -/* #define USE_FULL_ASSERT 1U */ +//#define USE_FULL_ASSERT 1U /* ################## Ethernet peripheral configuration ##################### */ @@ -492,5 +491,4 @@ void assert_failed(uint8_t *file, uint32_t line); #endif /* __STM32F4xx_HAL_CONF_CUSTOM_H */ - /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PeripheralPins.c index d4746a39e3..54439083d4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/PeripheralPins.c @@ -25,45 +25,45 @@ #ifdef HAL_ADC_MODULE_ENABLED WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 - // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + //{PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + //{PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 - // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + //{PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + //{PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 - // {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 - // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + //{PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + //{PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 - // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + //{PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + //{PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - // {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + //{PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + //{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - // {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + //{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - // {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + //{PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + //{PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - // {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 - // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + //{PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + //{PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 - // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + //{PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + //{PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 - // {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 - // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + //{PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + //{PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 - // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + //{PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + //{PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - // {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + //{PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + //{PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 {NC, NP, 0} }; #endif @@ -72,8 +72,8 @@ WEAK const PinMap PinMap_ADC[] = { #ifdef HAL_DAC_MODULE_ENABLED WEAK const PinMap PinMap_DAC[] = { - // {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 - // {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2 + //{PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + //{PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2 {NC, NP, 0} }; #endif @@ -82,22 +82,20 @@ WEAK const PinMap PinMap_DAC[] = { #ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SDA[] = { - // {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, - // {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - // {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + //{PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + //{PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - // {PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + //{PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { - // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - // {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + //{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - // {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + //{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {NC, NP, 0} }; #endif @@ -106,75 +104,75 @@ WEAK const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED WEAK const PinMap PinMap_PWM[] = { - // {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - // {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 - // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - // {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - // {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - // {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - // {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - // {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - // {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - // {PB_8, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - // {PB_9, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - // {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PB_8, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PB_9, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - // {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 - // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + //{PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - // {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + //{PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - // {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - // {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - // {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - // {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - // {PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {NC, NP, 0} }; @@ -184,62 +182,56 @@ WEAK const PinMap PinMap_PWM[] = { #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_TX[] = { - // {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - // {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, - // {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PE_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { - // {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, - // {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PE_7, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RTS[] = { - // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, - // {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + //{PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { - // {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, - // {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + //{PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {NC, NP, 0} }; #endif @@ -249,67 +241,61 @@ WEAK const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, - // {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, - // {PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, - // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PD_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, - // {PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + //{PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + //{PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + //{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PD_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + //{PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PD_0, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PD_0, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, - // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PD_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, - // {PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + //{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PD_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + //{PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; #endif @@ -318,22 +304,20 @@ WEAK const PinMap PinMap_SPI_SSEL[] = { #ifdef HAL_CAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_RD[] = { - // {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, - // {PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, - // {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, - // {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, - // {PD_0, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PD_0, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {NC, NP, 0} }; -#endif -#ifdef HAL_CAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_TD[] = { - // {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, - // {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, - // {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, - // {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, - // {PD_1, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PD_1, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {NC, NP, 0} }; #endif @@ -344,51 +328,41 @@ WEAK const PinMap PinMap_CAN_TD[] = { #ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_DATA0[] = { - // {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 - // {PD_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 - // {PE_7, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO0 + //{PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 + //{PD_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 + //{PE_7, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO0 {NC, NP, 0} }; -#endif -#ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_DATA1[] = { - // {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 - // {PD_12, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 - // {PE_8, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO1 + //{PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 + //{PD_12, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 + //{PE_8, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO1 {NC, NP, 0} }; -#endif -#ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_DATA2[] = { - // {PE_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO2 - // {PE_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO2 + //{PE_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO2 + //{PE_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO2 {NC, NP, 0} }; -#endif -#ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_DATA3[] = { {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 - // {PD_13, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 - // {PE_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO3 + //{PD_13, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 + //{PE_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK2_IO3 {NC, NP, 0} }; -#endif -#ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_SCLK[] = { - // {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK - // {PD_3, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK + //{PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK + //{PD_3, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK {NC, NP, 0} }; -#endif -#ifdef HAL_QSPI_MODULE_ENABLED WEAK const PinMap PinMap_QUADSPI_SSEL[] = { - // {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS - // {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS + //{PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS + //{PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS {NC, NP, 0} }; #endif @@ -397,36 +371,34 @@ WEAK const PinMap PinMap_QUADSPI_SSEL[] = { #ifdef HAL_PCD_MODULE_ENABLED WEAK const PinMap PinMap_USB_OTG_FS[] = { - // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF - // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS - // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP {NC, NP, 0} }; -#endif -#ifdef HAL_PCD_MODULE_ENABLED WEAK const PinMap PinMap_USB_OTG_HS[] = { #ifdef USE_USB_HS_IN_FS - // {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF - // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID - // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS - // {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM - // {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP + //{PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF + //{PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID + //{PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + //{PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM + //{PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP #else - // {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 - // {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK - // {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 - // {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 - // {PB_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4 - // {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 - // {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 - // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 - // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 - // {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP - // {PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR - // {PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT + //{PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 + //{PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK + //{PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 + //{PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 + //{PB_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4 + //{PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 + //{PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 + //{PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 + //{PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 + //{PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP + //{PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR + //{PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT #endif /* USE_USB_HS_IN_FS */ {NC, NP, 0} }; @@ -436,19 +408,19 @@ WEAK const PinMap PinMap_USB_OTG_HS[] = { #ifdef HAL_SD_MODULE_ENABLED WEAK const PinMap PinMap_SD[] = { - // {PB_0, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 - // {PB_1, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 - // {PB_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK - // {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 - // {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 - // {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 - // {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 - // {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 - // {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 - // {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 - // {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 - // {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK - // {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD + //{PB_0, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + //{PB_1, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + //{PB_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + //{PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + //{PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + //{PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + //{PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + //{PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + //{PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + //{PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + //{PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 + //{PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + //{PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD {NC, NP, 0} }; #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c index 51ebf60581..83e71035fa 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c @@ -14,6 +14,10 @@ #include "Arduino.h" #include "PeripheralPins.h" +/** + * Variant for: mks_robin_pro2, mks_robin_nano_v3, Anet_ET4_OpenBLT + */ + /* ===== * Note: Commented lines are alternative possibilities which are not used per default. * If you change them, you will have to know what you do @@ -24,46 +28,46 @@ #ifdef HAL_ADC_MODULE_ENABLED WEAK const PinMap PinMap_ADC[] = { - {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 - // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 - {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 - // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 - {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 - // {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 - // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 - {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 - // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 - {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - // {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 - {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 - {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - // {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 - {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 - {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - // {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 - {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 - {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - // {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 - // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 - {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 - // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 - {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 - // {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 - // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 - {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 - // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 - {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - // {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 - {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + //{PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + //{PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + //{PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + //{PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + //{PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + //{PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + //{PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + //{PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + //{PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + //{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + //{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + //{PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + //{PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + //{PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + //{PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + //{PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + //{PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + //{PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + //{PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + //{PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + //{PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + //{PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + //{PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 {NC, NP, 0} }; #endif @@ -88,9 +92,7 @@ WEAK const PinMap PinMap_I2C_SDA[] = { {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, @@ -116,75 +118,75 @@ WEAK const PinMap PinMap_I2C_SCL[] = { // No timer = [FAN1 ] WEAK const PinMap PinMap_PWM[] = { - {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 - // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - // {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N - {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 - {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N - // {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 - // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N - // {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 - {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 - // {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 - {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 - // {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 - {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - {PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 + {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {NC, NP, 0} }; #endif @@ -206,9 +208,7 @@ WEAK const PinMap PinMap_UART_TX[] = { {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, @@ -216,30 +216,26 @@ WEAK const PinMap PinMap_UART_RX[] = { {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, @@ -252,44 +248,38 @@ WEAK const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, @@ -308,9 +298,7 @@ WEAK const PinMap PinMap_CAN_RD[] = { {PD_0, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {NC, NP, 0} }; -#endif -#ifdef HAL_CAN_MODULE_ENABLED WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, @@ -354,21 +342,19 @@ WEAK const PinMap PinMap_Ethernet[] = { #ifdef HAL_PCD_MODULE_ENABLED WEAK const PinMap PinMap_USB_OTG_FS[] = { - // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF - // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS - // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP {NC, NP, 0} }; -#endif -#ifdef HAL_PCD_MODULE_ENABLED WEAK const PinMap PinMap_USB_OTG_HS[] = { #ifdef USE_USB_HS_IN_FS - // {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF - // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID - // {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + //{PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF + //{PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID + //{PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP #else diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h index a8500c595f..0c44f08742 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h @@ -36,14 +36,25 @@ */ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED -//#define HAL_CAN_MODULE_ENABLED #define HAL_CAN_LEGACY_MODULE_ENABLED #define HAL_CRC_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +//#define HAL_UART_MODULE_ENABLED +//#define HAL_PCD_MODULE_ENABLED + +//#define HAL_CAN_MODULE_ENABLED //#define HAL_CEC_MODULE_ENABLED //#define HAL_CRYP_MODULE_ENABLED -#define HAL_DAC_MODULE_ENABLED //#define HAL_DCMI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED //#define HAL_DMA2D_MODULE_ENABLED //#define HAL_ETH_MODULE_ENABLED //#define HAL_FLASH_MODULE_ENABLED @@ -53,30 +64,20 @@ //#define HAL_SRAM_MODULE_ENABLED //#define HAL_SDRAM_MODULE_ENABLED //#define HAL_HASH_MODULE_ENABLED -#define HAL_GPIO_MODULE_ENABLED //#define HAL_EXTI_MODULE_ENABLED -#define HAL_I2C_MODULE_ENABLED //#define HAL_SMBUS_MODULE_ENABLED //#define HAL_I2S_MODULE_ENABLED //#define HAL_IWDG_MODULE_ENABLED //#define HAL_LTDC_MODULE_ENABLED //#define HAL_DSI_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED //#define HAL_QSPI_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED //#define HAL_RNG_MODULE_ENABLED //#define HAL_RTC_MODULE_ENABLED //#define HAL_SAI_MODULE_ENABLED //#define HAL_SD_MODULE_ENABLED -#define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -//#define HAL_UART_MODULE_ENABLED -#define HAL_USART_MODULE_ENABLED //#define HAL_IRDA_MODULE_ENABLED //#define HAL_SMARTCARD_MODULE_ENABLED //#define HAL_WWDG_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED -//#define HAL_PCD_MODULE_ENABLED //#define HAL_HCD_MODULE_ENABLED //#define HAL_FMPI2C_MODULE_ENABLED //#define HAL_SPDIFRX_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c index cc700201aa..ec28776ebe 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/PeripheralPins.c @@ -40,46 +40,46 @@ #ifdef HAL_ADC_MODULE_ENABLED const PinMap PinMap_ADC[] = { - // {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 - // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 - // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 - // {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 - // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 - // {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 - // {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 - // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + //{PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + //{PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + //{PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + //{PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + //{PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + //{PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + //{PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + //{PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + //{PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 - // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + //{PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + //{PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - // {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 - // {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 - // {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - // {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 - // {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 - // {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - // {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 - // {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + //{PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + //{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + //{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + //{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + //{PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + //{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + //{PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - // {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 - // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + //{PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + //{PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 - // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + //{PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + //{PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 - // {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 - // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + //{PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + //{PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 - // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + //{PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + //{PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - // {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 - // {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + //{PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + //{PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + //{PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 {NC, NP, 0} }; #endif @@ -88,8 +88,8 @@ const PinMap PinMap_ADC[] = { #ifdef HAL_DAC_MODULE_ENABLED const PinMap PinMap_DAC[] = { - // {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 - // {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2 + //{PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + //{PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2 {NC, NP, 0} }; #endif @@ -98,24 +98,22 @@ const PinMap PinMap_DAC[] = { #ifdef HAL_I2C_MODULE_ENABLED const PinMap PinMap_I2C_SDA[] = { - // {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, - // {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - // {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + //{PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + //{PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - // {PC_7, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, - // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - // {PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + //{PC_7, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, + //{PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED const PinMap PinMap_I2C_SCL[] = { - // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - // {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + //{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - // {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, - // {PC_6, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, + //{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + //{PC_6, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {NC, NP, 0} }; #endif @@ -125,33 +123,33 @@ const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED const PinMap PinMap_PWM[] = { {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - STLink Tx - // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - STLink Tx - // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - STLink Tx - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - STLink Rx - // {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - STLink Rx - // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - STLink Rx + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - STLink Tx + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - STLink Tx + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - STLink Tx + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - STLink Rx + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - STLink Rx + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - STLink Rx {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 - // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 - // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N - // {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // Fan0, TIM8_CH2N - // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // Fan1, TIM8_CH3N {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // Fan2, TIM2_CH4 {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // E0 Heater, TIM2_CH2 @@ -159,27 +157,27 @@ const PinMap PinMap_PWM[] = { {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // LED G, TIM3_CH2 {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // LED R, TIM4_CH1 {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // LED B, TIM4_CH2 - // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - // {PB_8, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PB_8, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 - // {PB_9, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_9, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 - // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 - // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 - // {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 - // {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 @@ -192,52 +190,46 @@ const PinMap PinMap_PWM[] = { #ifdef HAL_UART_MODULE_ENABLED const PinMap PinMap_UART_TX[] = { - // {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - // {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED const PinMap PinMap_UART_RX[] = { - // {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED const PinMap PinMap_UART_RTS[] = { - // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + //{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED const PinMap PinMap_UART_CTS[] = { - // {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, - // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, - // {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + //{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, {NC, NP, 0} }; #endif @@ -247,54 +239,48 @@ const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, - // {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, - // {PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, - // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + //{PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + //{PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + //{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, - // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + //{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {NC, NP, 0} }; #endif @@ -303,20 +289,18 @@ const PinMap PinMap_SPI_SSEL[] = { #ifdef HAL_CAN_MODULE_ENABLED const PinMap PinMap_CAN_RD[] = { - // {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, - // {PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, - // {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, - // {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {NC, NP, 0} }; -#endif -#ifdef HAL_CAN_MODULE_ENABLED const PinMap PinMap_CAN_TD[] = { - // {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, - // {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, - // {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, - // {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {NC, NP, 0} }; #endif @@ -329,12 +313,12 @@ const PinMap PinMap_CAN_TD[] = { #ifdef HAL_QSPI_MODULE_ENABLED const PinMap PinMap_QUADSPI[] = { - // {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 - // {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK - // {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS - // {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 - // {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 - // {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS + //{PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 + //{PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK + //{PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS + //{PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 + //{PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 + //{PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS {NC, NP, 0} }; #endif @@ -343,19 +327,15 @@ const PinMap PinMap_QUADSPI[] = { #ifdef HAL_PCD_MODULE_ENABLED const PinMap PinMap_USB_OTG_FS[] = { - // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF - // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_OTG_FS_VBUS - // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_OTG_FS_VBUS + //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP {NC, NP, 0} }; -#endif -#ifdef HAL_PCD_MODULE_ENABLED const PinMap PinMap_USB_OTG_HS[] = { {NC, NP, 0} }; #endif - - diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/STEVAL_F401VE/PeripheralPins.c index 5335361a6a..d3d754b689 100644 --- a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/STEVAL_F401VE/PeripheralPins.c @@ -29,18 +29,18 @@ WEAK const PinMap PinMap_ADC[] = { {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - // {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - // {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - // {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - // {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - // {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - // {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - // {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - // {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + //{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + //{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + //{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + //{PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + //{PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - // {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - // {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + //{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + //{PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 {NC, NP, 0} }; #endif @@ -51,21 +51,19 @@ WEAK const PinMap PinMap_ADC[] = { #ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SDA[] = { - // {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)}, - // {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + //{PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)}, + //{PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - // {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + //{PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {NC, NP, 0} }; -#endif -#ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { - // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + //{PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - // {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - // {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + //{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + //{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {NC, NP, 0} }; #endif @@ -74,58 +72,58 @@ WEAK const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED WEAK const PinMap PinMap_PWM[] = { - // {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 - // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - // {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 - // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - // {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - // {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - // {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - // {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - // {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 - // {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 - // {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - // {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - // {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - // {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 - // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - // {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - // {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 - // {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - // {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - // {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N - // {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - // {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N - // {PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - // {PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N - // {PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 {PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {NC, NP, 0} }; @@ -135,41 +133,35 @@ WEAK const PinMap PinMap_PWM[] = { #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_TX[] = { - // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - // {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { - // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, - // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - // {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RTS[] = { - // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {NC, NP, 0} }; -#endif -#ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { - // {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {NC, NP, 0} }; @@ -180,57 +172,51 @@ WEAK const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; -#endif -#ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - // {PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - // {PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + //{PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, {NC, NP, 0} }; #endif @@ -245,9 +231,9 @@ WEAK const PinMap PinMap_SPI_SSEL[] = { #ifdef HAL_PCD_MODULE_ENABLED WEAK const PinMap PinMap_USB_OTG_FS[] = { - // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF - // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS - // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP {NC, NP, 0} @@ -259,10 +245,10 @@ WEAK const PinMap PinMap_USB_OTG_FS[] = { #ifdef HAL_SD_MODULE_ENABLED WEAK const PinMap PinMap_SD[] = { - // {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 - // {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 - // {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 - // {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + //{PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + //{PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + //{PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + //{PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/STEVAL_F401VE/hal_conf_custom.h index 0c7781997f..aeaaf890f2 100644 --- a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/STEVAL_F401VE/hal_conf_custom.h @@ -33,55 +33,54 @@ extern "C" { */ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ #define HAL_CRC_MODULE_ENABLED -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ -//#define HAL_DAC_MODULE_ENABLED -/* #define HAL_DCMI_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -/* #define HAL_SDRAM_MODULE_ENABLED */ -/* #define HAL_HASH_MODULE_ENABLED */ #define HAL_GPIO_MODULE_ENABLED -/* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_I2C_MODULE_ENABLED -/* #define HAL_SMBUS_MODULE_ENABLED */ -/* #define HAL_I2S_MODULE_ENABLED */ #define HAL_IWDG_MODULE_ENABLED -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ #define HAL_PWR_MODULE_ENABLED -/* #define HAL_QSPI_MODULE_ENABLED */ #define HAL_RCC_MODULE_ENABLED -/* #define HAL_RNG_MODULE_ENABLED */ #define HAL_RTC_MODULE_ENABLED -/* #define HAL_SAI_MODULE_ENABLED */ #define HAL_SD_MODULE_ENABLED #define HAL_SPI_MODULE_ENABLED #define HAL_TIM_MODULE_ENABLED -/* #define HAL_UART_MODULE_ENABLED */ -/* #define HAL_USART_MODULE_ENABLED */ -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED -#ifndef HAL_PCD_MODULE_ENABLED - #define HAL_PCD_MODULE_ENABLED //Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) -#endif -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ +//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) + +//#define HAL_CAN_MODULE_ENABLED +//#define HAL_CAN_LEGACY_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED +//#define HAL_DAC_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED +//#define HAL_EXTI_MODULE_ENABLED +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_UART_MODULE_ENABLED // by default +//#define HAL_USART_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED /* ########################## HSE/HSI Values adaptation ##################### */ /** From 76cc736755c757ea12b93427ec09ae8a8183419f Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Mon, 12 Apr 2021 00:32:28 +0300 Subject: [PATCH 195/311] MKS LVGL UI: Fix icon layout (#21595) --- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 45a2167a05..a4515734a0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -45,7 +45,6 @@ #define ICON_POS_Y 38 #define TARGET_LABEL_MOD_Y -36 #define LABEL_MOD_Y 30 -#define SECOND_EXT_MOD_Y 100 extern lv_group_t* g; static lv_obj_t *scr; @@ -186,24 +185,33 @@ void lv_draw_ready_print() { // Monitoring lv_obj_t *buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT); #if HAS_MULTI_EXTRUDER - lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 55, ICON_POS_Y + SECOND_EXT_MOD_Y, event_handler, ID_INFO_EXT); - #endif - #if HAS_HEATED_BED + lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 163, ICON_POS_Y, event_handler, ID_INFO_EXT); + #if HAS_HEATED_BED + lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 271, ICON_POS_Y, event_handler, ID_INFO_BED); + #endif + #else + #if HAS_HEATED_BED lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 210, ICON_POS_Y, event_handler, ID_INFO_BED); + #endif #endif + lv_obj_t *buttonFanstate = lv_big_button_create(scr, "F:/bmp_fan_state.bin", " ", 380, ICON_POS_Y, event_handler, ID_INFO_FAN); labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); #if HAS_MULTI_EXTRUDER - labelExt2 = lv_label_create(scr, 55, LABEL_MOD_Y + SECOND_EXT_MOD_Y, nullptr); - labelExt2Target = lv_label_create(scr, 55, LABEL_MOD_Y + SECOND_EXT_MOD_Y, nullptr); - #endif - - #if HAS_HEATED_BED - labelBed = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr); - labelBedTarget = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr); + labelExt2 = lv_label_create(scr, 163, LABEL_MOD_Y, nullptr); + labelExt2Target = lv_label_create(scr, 163, LABEL_MOD_Y, nullptr); + #if HAS_HEATED_BED + labelBed = lv_label_create(scr, 271, LABEL_MOD_Y, nullptr); + labelBedTarget = lv_label_create(scr, 271, LABEL_MOD_Y, nullptr); + #endif + #else + #if HAS_HEATED_BED + labelBed = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr); + labelBedTarget = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr); + #endif #endif labelFan = lv_label_create(scr, 380, 80, nullptr); From 1742fb86555a33fdcda1468a00a64690e957685a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 12 Apr 2021 00:36:20 +0000 Subject: [PATCH 196/311] [cron] Bump distribution date (2021-04-12) --- 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 0db2a080d4..b066c5ba4e 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-04-11" + #define STRING_DISTRIBUTION_DATE "2021-04-12" #endif /** From 24a095c5c14b60bcbffc2807d2c8cc8e9af46e90 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Apr 2021 16:49:53 -0500 Subject: [PATCH 197/311] Reduce math library code size by 3.4KB (#21575) --- Marlin/src/core/macros.h | 3 ++ Marlin/src/feature/bedlevel/abl/abl.cpp | 14 +++---- Marlin/src/feature/bedlevel/bedlevel.cpp | 4 +- .../feature/bedlevel/mbl/mesh_bed_leveling.h | 7 +++- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 10 ++--- Marlin/src/feature/bedlevel/ubl/ubl.h | 42 +++++++------------ Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 40 +++++++++--------- .../src/feature/bedlevel/ubl/ubl_motion.cpp | 18 ++++---- Marlin/src/gcode/bedlevel/G35.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 22 +++++----- Marlin/src/gcode/bedlevel/ubl/M421.cpp | 2 +- Marlin/src/gcode/calibrate/G33.cpp | 6 +-- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 6 +-- Marlin/src/gcode/calibrate/M48.cpp | 4 +- Marlin/src/gcode/probe/G30.cpp | 2 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 4 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 2 +- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 2 +- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 10 +++-- .../ftdi_eve_lib/extended/adjuster_widget.cpp | 2 +- .../screens/bed_mesh_base.cpp | 2 +- .../screens/bed_mesh_edit_screen.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 4 +- Marlin/src/lcd/menu/menu_tramming.cpp | 2 +- Marlin/src/lcd/tft/ui_1024x600.cpp | 2 +- Marlin/src/lcd/tft/ui_320x240.cpp | 2 +- Marlin/src/lcd/tft/ui_480x320.cpp | 2 +- Marlin/src/module/probe.cpp | 20 ++++----- Marlin/src/module/probe.h | 8 ++-- Marlin/src/module/settings.cpp | 14 +++---- Marlin/src/module/temperature.h | 6 +-- Marlin/src/sd/cardreader.cpp | 2 +- Marlin/src/sd/cardreader.h | 2 +- platformio.ini | 14 +++---- 35 files changed, 141 insertions(+), 145 deletions(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 6092dc4a59..ce88458412 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -112,6 +112,9 @@ #define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);}) #define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1))) +#define MFNAN 999999.0f +#define ISNAN(V) ((V) == MFNAN) + // Macros to constrain values #ifdef __cplusplus diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index 7390656563..3d5e6723eb 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -43,7 +43,7 @@ bed_mesh_t z_values; * Extrapolate a single point from its neighbors */ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { - if (!isnan(z_values[x][y])) return; + if (!ISNAN(z_values[x][y])) return; if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Extrapolate ["); if (x < 10) DEBUG_CHAR(' '); @@ -63,12 +63,12 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t c1 = z_values[x1][y1], c2 = z_values[x2][y2]; // Treat far unprobed points as zero, near as equal to far - if (isnan(a2)) a2 = 0.0; - if (isnan(a1)) a1 = a2; - if (isnan(b2)) b2 = 0.0; - if (isnan(b1)) b1 = b2; - if (isnan(c2)) c2 = 0.0; - if (isnan(c1)) c1 = c2; + if (ISNAN(a2)) a2 = 0.0; + if (ISNAN(a1)) a1 = a2; + if (ISNAN(b2)) b2 = 0.0; + if (ISNAN(b1)) b1 = b2; + if (ISNAN(c2)) c2 = 0.0; + if (ISNAN(c1)) c1 = c2; const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2; diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 30fafbf57b..0a7c0c5a0c 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -132,7 +132,7 @@ void reset_bed_level() { bilinear_start.reset(); bilinear_grid_spacing.reset(); GRID_LOOP(x, y) { - z_values[x][y] = NAN; + z_values[x][y] = MFNAN; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0)); } #elif ABL_PLANAR @@ -177,7 +177,7 @@ void reset_bed_level() { LOOP_L_N(x, sx) { SERIAL_CHAR(' '); const float offset = fn(x, y); - if (!isnan(offset)) { + if (!ISNAN(offset)) { if (offset >= 0) SERIAL_CHAR('+'); SERIAL_ECHO_F(offset, int(precision)); } diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index eadcc28aa4..eaab7775f5 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -97,6 +97,7 @@ public: static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); } static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) { + if (ISNAN(a0) || ISNAN(a1) || ISNAN(z1) || ISNAN(a2) || ISNAN(z2)) return MFNAN; const float delta_z = (z2 - z1) / (a2 - a1), delta_a = a0 - a1; return z1 + delta_a * delta_z; @@ -114,9 +115,11 @@ public: const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1], y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1], z1 = calc_z0(pos.x, x1, z_values[ind.x][ind.y ], x2, z_values[ind.x+1][ind.y ]), - z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]); + z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]), + zf = calc_z0(pos.y, y1, z1, y2, z2); - return z_offset + calc_z0(pos.y, y1, z1, y2, z2) * factor; + + return ISNAN(zf) ? zf : z_offset + zf * factor; } #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 164d267ceb..70b7863fab 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -48,7 +48,7 @@ void unified_bed_leveling::report_current_mesh() { if (!leveling_is_valid()) return; SERIAL_ECHO_MSG(" G29 I999"); GRID_LOOP(x, y) - if (!isnan(z_values[x][y])) { + if (!ISNAN(z_values[x][y])) { SERIAL_ECHO_START(); SERIAL_ECHOPAIR(" M421 I", x, " J", y); SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4); @@ -99,7 +99,7 @@ void unified_bed_leveling::reset() { void unified_bed_leveling::invalidate() { set_bed_leveling_enabled(false); - set_all_mesh_points_to_value(NAN); + set_all_mesh_points_to_value(MFNAN); } void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) { @@ -116,7 +116,7 @@ void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) { void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) { auto z_to_store = [](const_float_t z) { - if (isnan(z)) return Z_STEPS_NAN; + if (ISNAN(z)) return Z_STEPS_NAN; const int32_t z_scaled = TRUNC(z * mesh_store_scaling); if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX)) return Z_STEPS_NAN; // If Z is out of range, return our custom 'NaN' @@ -127,7 +127,7 @@ void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) { void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) { auto store_to_z = [](const int16_t z_scaled) { - return z_scaled == Z_STEPS_NAN ? NAN : z_scaled / mesh_store_scaling; + return z_scaled == Z_STEPS_NAN ? MFNAN : z_scaled / mesh_store_scaling; }; GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]); } @@ -211,7 +211,7 @@ void unified_bed_leveling::display_map(const int map_type) { if (lcd) { // TODO: Display on Graphical LCD } - else if (isnan(f)) + else if (ISNAN(f)) SERIAL_ECHOPGM_P(human ? PSTR(" . ") : PSTR("NAN")); else if (human || csv) { if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index dd6c261341..a086c20ba8 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -196,7 +196,7 @@ public: #ifdef UBL_Z_RAISE_WHEN_OFF_MESH #define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH #else - #define _UBL_OUTER_Z_RAISE NAN + #define _UBL_OUTER_Z_RAISE MFNAN #endif /** @@ -264,39 +264,25 @@ public: return UBL_Z_RAISE_WHEN_OFF_MESH; #endif - const float z1 = calc_z0(rx0, - mesh_index_to_xpos(cx), z_values[cx][cy], - mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1][cy]); + const uint8_t mx = _MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1, my = _MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1; + const float z1 = calc_z0(rx0, mesh_index_to_xpos(cx), z_values[cx][cy], mesh_index_to_xpos(cx + 1), z_values[mx][cy]); + const float z2 = calc_z0(rx0, mesh_index_to_xpos(cx), z_values[cx][my], mesh_index_to_xpos(cx + 1), z_values[mx][my]); + float z0 = calc_z0(ry0, mesh_index_to_ypos(cy), z1, mesh_index_to_ypos(cy + 1), z2); - const float z2 = calc_z0(rx0, - mesh_index_to_xpos(cx), z_values[cx][_MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1], - mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1][_MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1]); - - float z0 = calc_z0(ry0, - mesh_index_to_ypos(cy), z1, - mesh_index_to_ypos(cy + 1), z2); - - if (DEBUGGING(MESH_ADJUST)) { - DEBUG_ECHOPAIR(" raw get_z_correction(", rx0); - DEBUG_CHAR(','); DEBUG_ECHO(ry0); - DEBUG_ECHOPAIR_F(") = ", z0, 6); - DEBUG_ECHOLNPAIR_F(" >>>---> ", z0, 6); - } - - if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN + if (ISNAN(z0)) { // if part of the Mesh is undefined, it will show up as MFNAN z0 = 0.0; // in ubl.z_values[][] and propagate through the // calculations. If our correction is NAN, we throw it out // because part of the Mesh is undefined and we don't have the // information we need to complete the height correction. - if (DEBUGGING(MESH_ADJUST)) { - DEBUG_ECHOPAIR("??? Yikes! NAN in get_z_correction(", rx0); - DEBUG_CHAR(','); - DEBUG_ECHO(ry0); - DEBUG_CHAR(')'); - DEBUG_EOL(); - } + if (DEBUGGING(MESH_ADJUST)) DEBUG_ECHOLNPAIR("??? Yikes! NAN in "); } + + if (DEBUGGING(MESH_ADJUST)) { + DEBUG_ECHOPAIR("get_z_correction(", rx0, ", ", ry0); + DEBUG_ECHOLNPAIR_F(") => ", z0, 6); + } + return z0; } static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); } @@ -315,7 +301,7 @@ public: #endif static inline bool mesh_is_valid() { - GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false; + GRID_LOOP(x, y) if (ISNAN(z_values[x][y])) return false; return true; } diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 361f3f1285..ed2d4c6a94 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -331,7 +331,7 @@ void unified_bed_leveling::G29() { // to invalidate the ENTIRE mesh, which can't be done with // find_closest_mesh_point (which only returns REAL points). if (closest.pos.x < 0) { invalidate_all = true; break; } - z_values[closest.pos.x][closest.pos.y] = NAN; + z_values[closest.pos.x][closest.pos.y] = MFNAN; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(closest.pos, 0.0f)); } } @@ -516,7 +516,7 @@ void unified_bed_leveling::G29() { if (cpos.x < 0) { // No more REAL INVALID mesh points to populate, so we ASSUME // user meant to populate ALL INVALID mesh points to value - GRID_LOOP(x, y) if (isnan(z_values[x][y])) z_values[x][y] = param.C_constant; + GRID_LOOP(x, y) if (ISNAN(z_values[x][y])) z_values[x][y] = param.C_constant; break; // No more invalid Mesh Points to populate } else { @@ -675,7 +675,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o float sum = 0; int n = 0; GRID_LOOP(x, y) - if (!isnan(z_values[x][y])) { + if (!ISNAN(z_values[x][y])) { sum += z_values[x][y]; n++; } @@ -687,7 +687,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o // float sum_of_diff_squared = 0; GRID_LOOP(x, y) - if (!isnan(z_values[x][y])) + if (!ISNAN(z_values[x][y])) sum_of_diff_squared += sq(z_values[x][y] - mean); SERIAL_ECHOLNPAIR("# of samples: ", n); @@ -698,7 +698,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o if (cflag) GRID_LOOP(x, y) - if (!isnan(z_values[x][y])) { + if (!ISNAN(z_values[x][y])) { z_values[x][y] -= mean + offset; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); } @@ -709,7 +709,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o */ void unified_bed_leveling::shift_mesh_height() { GRID_LOOP(x, y) - if (!isnan(z_values[x][y])) { + if (!ISNAN(z_values[x][y])) { z_values[x][y] += param.C_constant; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); } @@ -1017,7 +1017,7 @@ void set_message_with_feedback(PGM_P const msg_P) { ui.refresh(); float new_z = z_values[lpos.x][lpos.y]; - if (isnan(new_z)) new_z = 0; // Invalid points begin at 0 + if (ISNAN(new_z)) new_z = 0; // Invalid points begin at 0 new_z = FLOOR(new_z * 1000) * 0.001f; // Chop off digits after the 1000ths place ui.ubl_mesh_edit_start(new_z); @@ -1227,7 +1227,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { mesh_index_pair farthest { -1, -1, -99999.99 }; GRID_LOOP(i, j) { - if (!isnan(z_values[i][j])) continue; // Skip valid mesh points + if (!ISNAN(z_values[i][j])) continue; // Skip valid mesh points // Skip unreachable points if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j))) @@ -1238,7 +1238,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { xy_int8_t nearby { -1, -1 }; float d1, d2 = 99999.9f; GRID_LOOP(k, l) { - if (isnan(z_values[k][l])) continue; + if (ISNAN(z_values[k][l])) continue; found_a_real = true; @@ -1282,7 +1282,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { static bool test_func(uint8_t i, uint8_t j, void *data) { find_closest_t *d = (find_closest_t*)data; - if ( (d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL)) + if ( (d->type == (ISNAN(ubl.z_values[i][j]) ? INVALID : REAL)) || (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j)) ) { // Found a Mesh Point of the specified type! @@ -1326,7 +1326,7 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh float best_so_far = 99999.99f; GRID_LOOP(i, j) { - if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL)) + if ( (type == (ISNAN(z_values[i][j]) ? INVALID : REAL)) || (type == SET_IN_BITMAP && !done_flags->marked(i, j)) ) { // Found a Mesh Point of the specified type! @@ -1367,12 +1367,12 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh bool unified_bed_leveling::smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { const float v = z_values[x][y]; - if (isnan(v)) { // A NAN... + if (ISNAN(v)) { // A NAN... const int8_t dx = x + xdir, dy = y + ydir; const float v1 = z_values[dx][dy]; - if (!isnan(v1)) { // ...next to a pair of real values? + if (!ISNAN(v1)) { // ...next to a pair of real values? const float v2 = z_values[dx + xdir][dy + ydir]; - if (!isnan(v2)) { + if (!ISNAN(v2)) { z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); return true; @@ -1441,7 +1441,7 @@ void unified_bed_leveling::smart_fill_mesh() { TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity); - if (isnan(measured_z)) + if (ISNAN(measured_z)) abort_flag = true; else { measured_z -= get_z_correction(points[0]); @@ -1463,7 +1463,7 @@ void unified_bed_leveling::smart_fill_mesh() { #ifdef VALIDATE_MESH_TILT z2 = measured_z; #endif - if (isnan(measured_z)) + if (ISNAN(measured_z)) abort_flag = true; else { measured_z -= get_z_correction(points[1]); @@ -1483,7 +1483,7 @@ void unified_bed_leveling::smart_fill_mesh() { #ifdef VALIDATE_MESH_TILT z3 = measured_z; #endif - if (isnan(measured_z)) + if (ISNAN(measured_z)) abort_flag = true; else { measured_z -= get_z_correction(points[2]); @@ -1522,7 +1522,7 @@ void unified_bed_leveling::smart_fill_mesh() { measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling - abort_flag = isnan(measured_z); + abort_flag = ISNAN(measured_z); #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { @@ -1673,14 +1673,14 @@ void unified_bed_leveling::smart_fill_mesh() { const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST); - GRID_LOOP(jx, jy) if (!isnan(z_values[jx][jy])) SBI(bitmap[jx], jy); + GRID_LOOP(jx, jy) if (!ISNAN(z_values[jx][jy])) SBI(bitmap[jx], jy); xy_pos_t ppos; LOOP_L_N(ix, GRID_MAX_POINTS_X) { ppos.x = mesh_index_to_xpos(ix); LOOP_L_N(iy, GRID_MAX_POINTS_Y) { ppos.y = mesh_index_to_ypos(iy); - if (isnan(z_values[ix][iy])) { + if (ISNAN(z_values[ix][iy])) { // undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points. incremental_LSF_reset(&lsf_results); xy_pos_t rpos; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 3ebc5fc2bd..cb3f7d3bbe 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -85,7 +85,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (!isnan(z0)) end.z += z0; + if (!ISNAN(z0)) end.z += z0; planner.buffer_segment(end, scaled_fr_mm_s, extruder); current_position = destination; return; @@ -150,7 +150,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (isnan(z0)) z0 = 0.0; + if (ISNAN(z0)) z0 = 0.0; const float ry = mesh_index_to_ypos(icell.y); @@ -198,7 +198,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (isnan(z0)) z0 = 0.0; + if (ISNAN(z0)) z0 = 0.0; /** * Without this check, it's possible to generate a zero length move, as in the case where @@ -253,7 +253,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (isnan(z0)) z0 = 0.0; + if (ISNAN(z0)) z0 = 0.0; if (!inf_normalized_flag) { on_axis_distance = use_x_dist ? rx - start.x : next_mesh_line_y - start.y; @@ -276,7 +276,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (isnan(z0)) z0 = 0.0; + if (ISNAN(z0)) z0 = 0.0; if (!inf_normalized_flag) { on_axis_distance = use_x_dist ? next_mesh_line_x - start.x : ry - start.y; @@ -405,10 +405,10 @@ z_x0y1 = z_values[icell.x ][icell.y+1], // z at lower right corner z_x1y1 = z_values[icell.x+1][icell.y+1]; // z at upper right corner - if (isnan(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A) - if (isnan(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points - if (isnan(z_x0y1)) z_x0y1 = 0; // in order to avoid isnan tests per cell, - if (isnan(z_x1y1)) z_x1y1 = 0; // thus guessing zero for undefined points + if (ISNAN(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A) + if (ISNAN(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points + if (ISNAN(z_x0y1)) z_x0y1 = 0; // in order to avoid ISNAN tests per cell, + if (ISNAN(z_x1y1)) z_x1y1 = 0; // thus guessing zero for undefined points const xy_pos_t pos = { mesh_index_to_xpos(icell.x), mesh_index_to_ypos(icell.y) }; xy_pos_t cell = raw - pos; diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index ad2cc67db0..f1c3ce028d 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -105,7 +105,7 @@ void GcodeSuite::G35() { do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7)); const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true); - if (isnan(z_probed_height)) { + if (ISNAN(z_probed_height)) { SERIAL_ECHOPAIR("G35 failed at point ", i, " ("); SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i])); SERIAL_CHAR(')'); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 654a381383..423857dbb0 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -287,11 +287,11 @@ G29_TYPE GcodeSuite::G29() { G29_RETURN(false); } - const float rx = RAW_X_POSITION(parser.linearval('X', NAN)), - ry = RAW_Y_POSITION(parser.linearval('Y', NAN)); + const float rx = RAW_X_POSITION(parser.linearval('X', MFNAN)), + ry = RAW_Y_POSITION(parser.linearval('Y', MFNAN)); int8_t i = parser.byteval('I', -1), j = parser.byteval('J', -1); - if (!isnan(rx) && !isnan(ry)) { + if (!ISNAN(rx) && !ISNAN(ry)) { // Get nearest i / j from rx / ry i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x; j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y; @@ -608,7 +608,7 @@ G29_TYPE GcodeSuite::G29() { // Outer loop is X with PROBE_Y_FIRST enabled // Outer loop is Y with PROBE_Y_FIRST disabled - for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !isnan(abl.measured_z); PR_OUTER_VAR++) { + for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !ISNAN(abl.measured_z); PR_OUTER_VAR++) { int8_t inStart, inStop, inInc; @@ -644,7 +644,7 @@ G29_TYPE GcodeSuite::G29() { abl.measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level); - if (isnan(abl.measured_z)) { + if (ISNAN(abl.measured_z)) { set_bed_leveling_enabled(abl.reenable); break; // Breaks out of both loops } @@ -690,14 +690,14 @@ G29_TYPE GcodeSuite::G29() { // Retain the last probe position abl.probePos = points[i]; abl.measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level); - if (isnan(abl.measured_z)) { + if (ISNAN(abl.measured_z)) { set_bed_leveling_enabled(abl.reenable); break; } points[i].z = abl.measured_z; } - if (!abl.dryrun && !isnan(abl.measured_z)) { + if (!abl.dryrun && !ISNAN(abl.measured_z)) { vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal(); if (planeNormal.z < 0) planeNormal *= -1; planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal); @@ -713,7 +713,7 @@ G29_TYPE GcodeSuite::G29() { // Stow the probe. No raise for FIX_MOUNTED_PROBE. if (probe.stow()) { set_bed_leveling_enabled(abl.reenable); - abl.measured_z = NAN; + abl.measured_z = MFNAN; } } #endif // !PROBE_MANUALLY @@ -736,7 +736,7 @@ G29_TYPE GcodeSuite::G29() { #endif // Calculate leveling, print reports, correct the position - if (!isnan(abl.measured_z)) { + if (!ISNAN(abl.measured_z)) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) if (!abl.dryrun) extrapolate_unprobed_bed_level(); @@ -873,7 +873,7 @@ G29_TYPE GcodeSuite::G29() { // Auto Bed Leveling is complete! Enable if possible. planner.leveling_active = !abl.dryrun || abl.reenable; - } // !isnan(abl.measured_z) + } // !ISNAN(abl.measured_z) // Restore state after probing if (!faux) restore_feedrate_and_scaling(); @@ -897,7 +897,7 @@ G29_TYPE GcodeSuite::G29() { report_current_position(); - G29_RETURN(isnan(abl.measured_z)); + G29_RETURN(ISNAN(abl.measured_z)); } #endif // HAS_ABL_NOT_UBL diff --git a/Marlin/src/gcode/bedlevel/ubl/M421.cpp b/Marlin/src/gcode/bedlevel/ubl/M421.cpp index 600c1fc8ba..694ad7ab81 100644 --- a/Marlin/src/gcode/bedlevel/ubl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/M421.cpp @@ -62,7 +62,7 @@ void GcodeSuite::M421() { SERIAL_ERROR_MSG(STR_ERR_MESH_XY); else { float &zval = ubl.z_values[ij.x][ij.y]; - zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); + zval = hasN ? MFNAN : parser.value_linear_units() + (hasQ ? zval : 0); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval)); } } diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 1b8eb889c6..0bcab206af 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -212,7 +212,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center const xy_pos_t center{0}; z_pt[CEN] += calibration_probe(center, stow_after_each); - if (isnan(z_pt[CEN])) return false; + if (ISNAN(z_pt[CEN])) return false; } if (_7p_calibration) { // probe extra center points @@ -223,7 +223,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi r = dcr * 0.1; const xy_pos_t vec = { cos(a), sin(a) }; z_pt[CEN] += calibration_probe(vec * r, stow_after_each); - if (isnan(z_pt[CEN])) return false; + if (ISNAN(z_pt[CEN])) return false; } z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points); } @@ -248,7 +248,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi interpol = FMOD(rad, 1); const xy_pos_t vec = { cos(a), sin(a) }; const float z_temp = calibration_probe(vec * r, stow_after_each); - if (isnan(z_temp)) return false; + if (ISNAN(z_temp)) return false; // split probe point to neighbouring calibration points z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90))); z_pt[uint8_t(LROUND(rad - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90))); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 1614dd6fbd..959d0f9c09 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -229,7 +229,7 @@ void GcodeSuite::G34() { // Probing sanity check is disabled, as it would trigger even in normal cases because // current_position.z has been manually altered in the "dirty trick" above. const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false); - if (isnan(z_probed_height)) { + if (ISNAN(z_probed_height)) { SERIAL_ECHOLNPGM("Probing failed"); LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); err_break = true; diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index 8cfe6fee7b..db1a6db76d 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -113,7 +113,7 @@ void GcodeSuite::G76() { auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) { do_z_clearance(5.0); // Raise nozzle before probing const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false - if (isnan(measured_z)) + if (ISNAN(measured_z)) SERIAL_ECHOLNPGM("!Received NAN. Aborting."); else { SERIAL_ECHOLNPAIR_F("Measured: ", measured_z); @@ -208,7 +208,7 @@ void GcodeSuite::G76() { report_temps(next_temp_report); const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); - if (isnan(measured_z) || target_bed > BED_MAX_TARGET) break; + if (ISNAN(measured_z) || target_bed > BED_MAX_TARGET) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); @@ -267,7 +267,7 @@ void GcodeSuite::G76() { if (timeout) break; const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz); - if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break; + if (ISNAN(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 19b11f602a..07e248fc3d 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -134,7 +134,7 @@ void GcodeSuite::M48() { // Move to the first point, deploy, and probe const float t = probe.probe_at_point(test_position, raise_after, verbose_level); - bool probing_good = !isnan(t); + bool probing_good = !ISNAN(t); if (probing_good) { randomSeed(millis()); @@ -219,7 +219,7 @@ void GcodeSuite::M48() { const float pz = probe.probe_at_point(test_position, raise_after, 0); // Break the loop if the probe fails - probing_good = !isnan(pz); + probing_good = !ISNAN(pz); if (!probing_good) break; // Store the new sample diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index 4347f55aa8..ebdc19f582 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -52,7 +52,7 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); - if (!isnan(measured_z)) + if (!ISNAN(measured_z)) SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); restore_feedrate_and_scaling(); diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 98ca1c0930..874fcc143d 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -1457,7 +1457,7 @@ void MarlinUI::draw_status_screen() { * Print Z values */ _ZLABEL(_LCD_W_POS, 1); - if (!isnan(ubl.z_values[x_plot][y_plot])) + if (!ISNAN(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else lcd_put_u8str_P(PSTR(" -----")); @@ -1476,7 +1476,7 @@ void MarlinUI::draw_status_screen() { * Show the location value */ _ZLABEL(_LCD_W_POS, 3); - if (!isnan(ubl.z_values[x_plot][y_plot])) + if (!ISNAN(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else lcd_put_u8str_P(PSTR(" -----")); diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 6976bfed22..cc54354ed1 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -941,7 +941,7 @@ void MarlinUI::draw_status_screen() { // Show the location value lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str_P(PSTR("Z:")); - if (!isnan(ubl.z_values[x_plot][y_plot])) + if (!ISNAN(ubl.z_values[x_plot][y_plot])) lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot])); else lcd_put_u8str_P(PSTR(" -----")); diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index dc60c1bff3..89f7746438 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -569,7 +569,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Show the location value lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL); - if (!isnan(ubl.z_values[x_plot][y_plot])) + if (!ISNAN(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else lcd_put_u8str_P(PSTR(" -----")); diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 921dee0e34..793bcd752f 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -835,13 +835,17 @@ void MarlinUI::draw_status_screen() { mix_label = PSTR("Mx"); } - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wformat-overflow" + #if GCC_VERSION <= 50000 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wformat-overflow" + #endif sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1])); lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages); - #pragma GCC diagnostic pop + #if GCC_VERSION <= 50000 + #pragma GCC diagnostic pop + #endif #else diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp index 26be9f4e59..531f759c49 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp @@ -32,7 +32,7 @@ namespace FTDI { void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) { char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)]; - if (isnan(value)) + if (ISNAN(value)) strcpy_P(str, PSTR("-")); else dtostrf(value, width, precision, str); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp index e83f09f045..d64238808c 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp @@ -31,7 +31,7 @@ void BedMeshBase::_drawMesh(CommandProcessor &cmd, int16_t x, int16_t y, int16_t constexpr uint8_t cols = GRID_MAX_POINTS_X; #define VALUE(X,Y) (func ? func(X,Y,data) : 0) - #define ISVAL(X,Y) (func ? !isnan(VALUE(X,Y)) : true) + #define ISVAL(X,Y) (func ? !ISNAN(VALUE(X,Y)) : true) #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0) // Compute the mean, min and max for the points diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp index 117ac0e452..01d4d1428b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp @@ -70,7 +70,7 @@ void BedMeshEditScreen::onEntry() { float BedMeshEditScreen::getHighlightedValue() { const float val = ExtUI::getMeshPoint(mydata.highlight); - return (isnan(val) ? 0 : val) + mydata.zAdjustment; + return (ISNAN(val) ? 0 : val) + mydata.zAdjustment; } void BedMeshEditScreen::setHighlightedValue(float value) { diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 2cac0f8e77..9d89447e3e 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -421,7 +421,7 @@ namespace ExtUI { #if AXIS_IS_TMC(Z2) case Z2: return stepperZ2.getMilliamps(); #endif - default: return NAN; + default: return MFNAN; }; } @@ -451,7 +451,7 @@ namespace ExtUI { #if AXIS_IS_TMC(E7) case E7: return stepperE7.getMilliamps(); #endif - default: return NAN; + default: return MFNAN; }; } diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index da7afd86ef..0dc468e805 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -54,7 +54,7 @@ static bool probe_single_point() { z_measured[tram_index] = z_probed_height; move_to_tramming_wait_pos(); - return !isnan(z_probed_height); + return !ISNAN(z_probed_height); } static void _menu_single_probe(const uint8_t point) { diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index e04d589858..819414b828 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -505,7 +505,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 5563d3069b..8429907f96 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 4d5a0b4fda..4b02b21ea6 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index d4b8409efa..d408dd236d 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -583,7 +583,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { * @details Used by probe_at_point to get the bed Z height at the current XY. * Leaves current_position.z at the height where the probe triggered. * - * @return The Z position of the bed at the current XY or NAN on error. + * @return The Z position of the bed at the current XY or MFNAN on error. */ float Probe::run_z_probe(const bool sanity_check/*=true*/) { DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING)); @@ -617,11 +617,11 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { #if TOTAL_PROBING == 2 // Attempt to tare the probe - if (TERN0(PROBE_TARE, tare())) return NAN; + if (TERN0(PROBE_TARE, tare())) return MFNAN; // Do a first probe at the fast speed if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s, - sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN; + sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return MFNAN; const float first_probe_z = current_position.z; @@ -662,7 +662,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { // Probe downward slowly to find the bed if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW), - sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN; + sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return MFNAN; TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe()); @@ -765,29 +765,29 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai if (probe_relative) { // The given position is in terms of the probe if (!can_reach(npos)) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable"); - return NAN; + return MFNAN; } npos -= offset_xy; // Get the nozzle position } - else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle + else if (!position_is_reachable(npos)) return MFNAN; // The given position is in terms of the nozzle // Move the probe to the starting XYZ do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S)); - float measured_z = NAN; + float measured_z = MFNAN; if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z; - if (!isnan(measured_z)) { + if (!ISNAN(measured_z)) { const bool big_raise = raise_after == PROBE_PT_BIG_RAISE; if (big_raise || raise_after == PROBE_PT_RAISE) do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s); else if (raise_after == PROBE_PT_STOW) - if (stow()) measured_z = NAN; // Error on stow? + if (stow()) measured_z = MFNAN; // Error on stow? if (verbose_level > 2) SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z); } - if (isnan(measured_z)) { + if (ISNAN(measured_z)) { stow(); LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); #if DISABLED(G29_RETRY_AND_RECOVER) diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index d8272c31b6..75aba76ef3 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -185,10 +185,10 @@ public: ); } - static float min_x() { return _min_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); } - static float max_x() { return _max_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); } - static float min_y() { return _min_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); } - static float max_y() { return _max_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); } + static float min_x() { return _min_x() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.x)); } + static float max_x() { return _max_x() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.x)); } + static float min_y() { return _min_y() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.y)); } + static float max_y() { return _max_y() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.y)); } // constexpr helpers used in build-time static_asserts, relying on default probe offsets. class build_time { diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 915886fe4a..d1fd719cfb 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -900,8 +900,8 @@ void MarlinSettings::postprocess() { HOTEND_LOOP() { PIDCF_t pidcf = { #if DISABLED(PIDTEMP) - NAN, NAN, NAN, - NAN, NAN + MFNAN, MFNAN, MFNAN, + MFNAN, MFNAN #else PID_PARAM(Kp, e), unscalePID_i(PID_PARAM(Ki, e)), @@ -928,7 +928,7 @@ void MarlinSettings::postprocess() { const PID_t bed_pid = { #if DISABLED(PIDTEMPBED) - NAN, NAN, NAN + MFNAN, MFNAN, MFNAN #else // Store the unscaled PID values thermalManager.temp_bed.pid.Kp, @@ -947,7 +947,7 @@ void MarlinSettings::postprocess() { const PID_t chamber_pid = { #if DISABLED(PIDTEMPCHAMBER) - NAN, NAN, NAN + MFNAN, MFNAN, MFNAN #else // Store the unscaled PID values thermalManager.temp_chamber.pid.Kp, @@ -1786,7 +1786,7 @@ void MarlinSettings::postprocess() { PIDCF_t pidcf; EEPROM_READ(pidcf); #if ENABLED(PIDTEMP) - if (!validating && !isnan(pidcf.Kp)) { + if (!validating && !ISNAN(pidcf.Kp)) { // Scale PID values since EEPROM values are unscaled PID_PARAM(Kp, e) = pidcf.Kp; PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki); @@ -1818,7 +1818,7 @@ void MarlinSettings::postprocess() { PID_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPBED) - if (!validating && !isnan(pid.Kp)) { + if (!validating && !ISNAN(pid.Kp)) { // Scale PID values since EEPROM values are unscaled thermalManager.temp_bed.pid.Kp = pid.Kp; thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki); @@ -1834,7 +1834,7 @@ void MarlinSettings::postprocess() { PID_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPCHAMBER) - if (!validating && !isnan(pid.Kp)) { + if (!validating && !ISNAN(pid.Kp)) { // Scale PID values since EEPROM values are unscaled thermalManager.temp_chamber.pid.Kp = pid.Kp; thermalManager.temp_chamber.pid.Ki = scalePID_i(pid.Ki); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 13dcca2932..9633c9733c 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -74,9 +74,9 @@ hotend_pid_t; #endif #define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0 & H)) // Always use 'H' to suppress warning -#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, NAN) -#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, NAN) -#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, NAN) +#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, MFNAN) +#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, MFNAN) +#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, MFNAN) #if ENABLED(PIDTEMP) #define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1) #define _PID_Kf(H) TERN(PID_FAN_SCALING, Temperature::temp_hotend[H].pid.Kf, 0) diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index f0797d6538..07a57cc658 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -565,7 +565,7 @@ void announceOpen(const uint8_t doing, const char * const path) { // - 1 : (no file open) Opening a macro (M98). // - 2 : Resuming from a sub-procedure // -void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*/) { +void CardReader::openFileRead(const char * const path, const uint8_t subcall_type/*=0*/) { if (!isMounted()) return; switch (subcall_type) { diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 482fb1c5cc..f1002e1dab 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -102,7 +102,7 @@ public: #endif // Basic file ops - static void openFileRead(char * const path, const uint8_t subcall=0); + static void openFileRead(const char * const path, const uint8_t subcall=0); static void openFileWrite(const char * const path); static void closefile(const bool store_location=false); static bool fileExists(const char * const name); diff --git a/platformio.ini b/platformio.ini index 913bb44ae0..53db8fc4b1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -38,6 +38,13 @@ extra_configs = # The 'common' values are used for most Marlin builds # [common] +build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants -fno-signed-zeros -ffinite-math-only +extra_scripts = + pre:buildroot/share/PlatformIO/scripts/common-dependencies.py + pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py + pre:buildroot/share/PlatformIO/scripts/preflight-checks.py + post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py +lib_deps = default_src_filter = + - - + - - - - - - - - @@ -227,13 +234,6 @@ default_src_filter = + - - + - - - - - -extra_scripts = - pre:buildroot/share/PlatformIO/scripts/common-dependencies.py - pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py - pre:buildroot/share/PlatformIO/scripts/preflight-checks.py - post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py -build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants -lib_deps = # # Default values apply to all 'env:' prefixed environments From f69da7d00dc69d4234068fd16a33167e0f85f460 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Tue, 13 Apr 2021 00:39:22 +0200 Subject: [PATCH 198/311] Add 'jump relaxing' compile flag to AVR targets (#21566) --- ini/avr.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/ini/avr.ini b/ini/avr.ini index 944646190a..1b208400a3 100644 --- a/ini/avr.ini +++ b/ini/avr.ini @@ -13,6 +13,7 @@ # AVR (8-bit) Common Environment values # [common_avr8] +build_flags = ${common.build_flags} -Wl,--relax board_build.f_cpu = 16000000L src_filter = ${common.default_src_filter} + From 1e357b3c74b6c2fa0642484f0cfa5efbe32e802d Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Mon, 12 Apr 2021 17:52:18 -0500 Subject: [PATCH 199/311] Tweak cooler / flowmeter icons (#21573) --- Marlin/src/lcd/dogm/dogm_Statusscreen.h | 4 +- Marlin/src/lcd/dogm/status/cooler.h | 153 ++++++++++++------------ 2 files changed, 81 insertions(+), 76 deletions(-) diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index f0e37aa249..6d2c5369dc 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -547,7 +547,7 @@ #endif #ifndef STATUS_COOLER_TEXT_X - #define STATUS_COOLER_TEXT_X (STATUS_COOLER_X + 8) + #define STATUS_COOLER_TEXT_X (STATUS_COOLER_X + 12) #endif static_assert( @@ -583,7 +583,7 @@ #endif #ifndef STATUS_FLOWMETER_TEXT_X - #define STATUS_FLOWMETER_TEXT_X (STATUS_FLOWMETER_X + 8) + #define STATUS_FLOWMETER_TEXT_X (STATUS_FLOWMETER_X + 12) #endif static_assert( diff --git a/Marlin/src/lcd/dogm/status/cooler.h b/Marlin/src/lcd/dogm/status/cooler.h index df596b5c5a..6cf67a4b62 100644 --- a/Marlin/src/lcd/dogm/status/cooler.h +++ b/Marlin/src/lcd/dogm/status/cooler.h @@ -25,90 +25,95 @@ // lcd/dogm/status/cooler.h - Status Screen Laser Cooler bitmaps // #if HAS_COOLER - #define STATUS_COOLER_WIDTH 16 + + #define STATUS_COOLER_WIDTH 22 + const unsigned char status_cooler_bmp2[] PROGMEM = { - B00010000,B00001000, - B00010010,B01001001, - B01010100,B00101010, - B00111000,B00011100, - B11111110,B11111111, - B00111000,B00011100, - B01010100,B00101010, - B10010000,B10001001, - B00010000,B10000000, - B00000100,B10010000, - B00000010,B10100000, - B00000001,B11000000, - B00011111,B11111100, - B00000001,B11000000, - B00000010,B10100000, - B00000100,B10010000 + B00000100,B00000010,B00000000, + B00000100,B10010010,B01000000, + B00010101,B00001010,B10000000, + B00001110,B00000111,B00000000, + B00111111,B10111111,B11000000, + B00001110,B00000111,B00000000, + B00010101,B00001010,B10000000, + B00100100,B00100010,B01000000, + B00000100,B00100000,B00000000, + B00000001,B00100100,B00000000, + B00000000,B10101000,B00000000, + B00000000,B01110000,B00000000, + B00000111,B11111111,B00000000, + B00000000,B01110000,B00000000, + B00000000,B10101000,B00000000, + B00000001,B00100100,B00000000 }; const unsigned char status_cooler_bmp1[] PROGMEM = { - B00010000,B00001000, - B00010010,B01001001, - B01010100,B00101010, - B00101000,B00010100, - B11000111,B01100011, - B00101000,B00010100, - B01010100,B00101010, - B10010000,B10001001, - B00010000,B10000000, - B00000100,B10010000, - B00000010,B10100000, - B00000001,B01000000, - B00011110,B00111100, - B00000001,B01000000, - B00000010,B10100000, - B00000100,B10010000 + B00000100,B00000010,B00000000, + B00000100,B10010010,B01000000, + B00010101,B00001010,B10000000, + B00001010,B00000101,B00000000, + B00110001,B11011000,B11000000, + B00001010,B00000101,B00000000, + B00010101,B00001010,B10000000, + B00100100,B00100010,B01000000, + B00000100,B00100000,B00000000, + B00000001,B00100100,B00000000, + B00000000,B10101000,B00000000, + B00000000,B01010000,B00000000, + B00000111,B10001111,B00000000, + B00000000,B01010000,B00000000, + B00000000,B10101000,B00000000, + B00000001,B00100100,B00000000 }; + #endif #if ENABLED(LASER_COOLANT_FLOW_METER) + #define STATUS_FLOWMETER_WIDTH 24 + const unsigned char status_flowmeter_bmp2[] PROGMEM = { - B00000001,B11111000,B00000000, - B00000110,B00000110,B00000000, - B00001000,B01100001,B00000000, - B00010000,B01100000,B10000000, - B00100000,B01100000,B01000000, - B00100000,B01100000,B01000000, - B01000000,B01100000,B00100000, - B01000000,B01100000,B00100000, - B01011111,B11111111,B10100000, - B01011111,B11111111,B10100000, - B01000000,B01100000,B00100000, - B01000000,B01100000,B00100000, - B00100000,B01100000,B01000000, - B00100000,B01100000,B01000000, - B00010000,B01100000,B10000000, - B00001000,B01100001,B00000000, - B00000110,B00000110,B00000000, - B00000001,B11111000,B00000000, - B00000000,B01100000,B00000000, - B00011111,B11111111,B10000000 + B00000000,B01111110,B00000000, + B00000001,B10000001,B10000000, + B00000010,B00011000,B01000000, + B00000100,B00011000,B00100000, + B00001000,B00011000,B00010000, + B00001000,B00011000,B00010000, + B00010000,B00011000,B00001000, + B00010000,B00011000,B00001000, + B00010111,B11111111,B11101000, + B00010111,B11111111,B11101000, + B00010000,B00011000,B00001000, + B00010000,B00011000,B00001000, + B00001000,B00011000,B00010000, + B00001000,B00011000,B00010000, + B00000100,B00011000,B00100000, + B00000010,B00011000,B01000000, + B00000001,B10000001,B10000000, + B00000000,B01111110,B00000000, + B00000000,B00011000,B00000000, + B00000111,B11111111,B11100000 }; const unsigned char status_flowmeter_bmp1[] PROGMEM = { - B00000001,B11111000,B00000000, - B00000110,B00000110,B00000000, - B00001000,B00000001,B00000000, - B00010100,B00000010,B10000000, - B00101110,B00000111,B01000000, - B00100111,B00001110,B01000000, - B01000011,B10011100,B00100000, - B01000001,B11111000,B00100000, - B01000000,B11110000,B00100000, - B01000000,B11110000,B00100000, - B01000001,B11111000,B00100000, - B01000011,B10011100,B00100000, - B00100111,B00001110,B01000000, - B00101110,B00000111,B01000000, - B00010100,B00000010,B10000000, - B00001000,B00000001,B00000000, - B00000110,B00000110,B00000000, - B00000001,B11111000,B00000000, - B00000000,B01100000,B00000000, - B00011111,B11111111,B10000000 + B00000000,B01111110,B00000000, + B00000001,B10000001,B10000000, + B00000010,B00000000,B01000000, + B00000101,B00000000,B10100000, + B00001011,B10000001,B11010000, + B00001001,B11000011,B10010000, + B00010000,B11100111,B00001000, + B00010000,B01111110,B00001000, + B00010000,B00111100,B00001000, + B00010000,B00111100,B00001000, + B00010000,B01111110,B00001000, + B00010000,B11100111,B00001000, + B00001001,B11000011,B10010000, + B00001011,B10000001,B11010000, + B00000101,B00000000,B10100000, + B00000010,B00000000,B01000000, + B00000001,B10000001,B10000000, + B00000000,B01111110,B00000000, + B00000000,B00011000,B00000000, + B00000111,B11111111,B11100000 }; -#endif +#endif From 4a1d2d816c4dff8b3c3e472f7b8022362e1ad109 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Apr 2021 19:34:31 -0500 Subject: [PATCH 200/311] Update old-style axis indexes --- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 6 +++--- Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 10 +++++----- Marlin/src/module/tool_change.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index cc54354ed1..faac398a4a 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -668,9 +668,9 @@ void MarlinUI::draw_status_screen() { // lcd.setCursor(0, 0); - _draw_axis_value(X_AXIS, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])), blink); lcd.write(' '); - _draw_axis_value(Y_AXIS, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])), blink); lcd.write(' '); - _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])), blink); + _draw_axis_value(X_AXIS, ftostr4sign(LOGICAL_X_POSITION(current_position.x)), blink); lcd.write(' '); + _draw_axis_value(Y_AXIS, ftostr4sign(LOGICAL_Y_POSITION(current_position.y)), blink); lcd.write(' '); + _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink); #if HAS_LEVELING && !HAS_HEATED_BED lcd.write(planner.leveling_active || blink ? '_' : ' '); 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 6025968d3b..a1818e6ddd 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -252,7 +252,7 @@ void disp_print_time() { void disp_fan_Zpos() { char str_1[16]; - sprintf_P(public_buf_l, PSTR("%s"), dtostrf(current_position[Z_AXIS], 1, 3, str_1)); + sprintf_P(public_buf_l, PSTR("%s"), dtostrf(current_position.z, 1, 3, str_1)); lv_label_set_text(labelZpos, public_buf_l); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 9d89447e3e..17e869d44f 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -870,19 +870,19 @@ namespace ExtUI { const feedRate_t old_feedrate = feedrate_mm_s; const float x_target = MESH_MIN_X + pos.x * (MESH_X_DIST), y_target = MESH_MIN_Y + pos.y * (MESH_Y_DIST); - if (x_target != current_position[X_AXIS] || y_target != current_position[Y_AXIS]) { + if (x_target != current_position.x || y_target != current_position.y) { // If moving across bed, raise nozzle to safe height over bed feedrate_mm_s = Z_PROBE_FEEDRATE_FAST; destination = current_position; - destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; + destination.z = Z_CLEARANCE_BETWEEN_PROBES; prepare_line_to_destination(); feedrate_mm_s = XY_PROBE_FEEDRATE; - destination[X_AXIS] = x_target; - destination[Y_AXIS] = y_target; + destination.x = x_target; + destination.y = y_target; prepare_line_to_destination(); } feedrate_mm_s = Z_PROBE_FEEDRATE_FAST; - destination[Z_AXIS] = z; + destination.z = z; prepare_line_to_destination(); feedrate_mm_s = old_feedrate; #else diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 1ed395dfe4..0475af6ad2 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -846,9 +846,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a // Cutting recover unscaled_e_move(toolchange_settings.extra_resume + TOOLCHANGE_FS_WIPE_RETRACT, MMM_TO_MMS(toolchange_settings.unretract_speed)); - planner.synchronize(); + // Resume at the old E position current_position.e = destination.e; - sync_plan_position_e(); // Resume at the old E position + sync_plan_position_e(); } } From 41c55a30cd6ef2834ad82e1edcf6cac2434770f5 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 13 Apr 2021 00:45:21 +0000 Subject: [PATCH 201/311] [cron] Bump distribution date (2021-04-13) --- 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 b066c5ba4e..e16c01ceb9 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-04-12" + #define STRING_DISTRIBUTION_DATE "2021-04-13" #endif /** From a5d6f6ac9880090d2412bbea0027885b95c98ea2 Mon Sep 17 00:00:00 2001 From: espr14 Date: Tue, 13 Apr 2021 03:10:21 +0200 Subject: [PATCH 202/311] Fix Resume Print with UBL (#21564) Co-authored-by: Scott Lahteine --- Marlin/src/feature/pause.cpp | 10 ++++++---- Marlin/src/gcode/feature/pause/M701_M702.cpp | 17 ++++++++++++----- .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 13 +++++++++++-- Marlin/src/module/tool_change.cpp | 5 +++-- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 5990c09a90..8a1701d0b6 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -597,11 +597,13 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ unscaled_e_move(-(PAUSE_PARK_RETRACT_LENGTH), feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE)); if (!axes_should_home()) { - // Move XY to starting position, then Z - do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE)); + // Move XY back to saved position + destination.set(resume_position.x, resume_position.y, current_position.z); + prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE); - // Move Z_AXIS to saved position - do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); + // Move Z back to saved position + destination.z = resume_position.z; + prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE); } // Unretract diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index 9a2b774936..6be63346dc 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -88,9 +88,17 @@ void GcodeSuite::M701() { tool_change(target_extruder, false); #endif - // Lift Z axis - if (park_point.z > 0) - do_blocking_move_to_z(_MIN(current_position.z + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); + auto move_z_by = [](const_float_t zdist) { + if (zdist) { + destination = current_position; + destination.z += zdist; + prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE); + } + }; + + // Raise the Z axis (with max limit) + const float park_raise = _MIN(0, park_point.z, (Z_MAX_POS) - current_position.z); + move_z_by(park_raise); // Load filament #if HAS_PRUSA_MMU2 @@ -113,8 +121,7 @@ void GcodeSuite::M701() { #endif // Restore Z axis - if (park_point.z > 0) - do_blocking_move_to_z(_MAX(current_position.z - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); + move_z_by(-park_raise); #if HAS_MULTI_EXTRUDER && (HAS_PRUSA_MMU1 || !HAS_MMU) // Restore toolhead if it was changed diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index 911965b9ae..01c3adbda7 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -75,9 +75,18 @@ xyz_pos_t position_before_pause; void MKS_pause_print_move() { queue.exhaust(); position_before_pause = current_position; - do_blocking_move_to(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y, current_position.z + mks_park_pos.z); + destination.z = _MIN(current_position.z + mks_park_pos.z, Z_MAX_POS); + prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE); + destination.set(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y); + prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE); +} + +void MKS_resume_print_move() { + destination.set(position_before_pause.x, position_before_pause.y); + prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE); + destination.z = position_before_pause.z; + prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE); } -void MKS_resume_print_move() { do_blocking_move_to(position_before_pause); } float z_offset_add = 0; diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 0475af6ad2..3dd63e814c 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -836,9 +836,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a #if ENABLED(TOOLCHANGE_PARK) if (ok) { #if ENABLED(TOOLCHANGE_NO_RETURN) - do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]); + destination.set(current_position.x, current_position.y); + prepare_internal_move_to_destination(planner.settings.max_feedrate_mm_s[Z_AXIS]); #else - do_blocking_move_to(destination, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE)); + prepare_internal_move_to_destination(MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE)); #endif } #endif From 4044ed8783c71dd66d64737173ca31c8a0ea0f5a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Apr 2021 20:15:41 -0500 Subject: [PATCH 203/311] Add 'blocking move' comments --- Marlin/src/module/motion.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index afd30a44e0..9c1f8cd4ad 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -367,12 +367,13 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ planner.e_factor[active_extruder] = 1.0f; #endif - #if IS_KINEMATIC - if (is_fast) - prepare_fast_move_to_destination(); - else + #if !IS_KINEMATIC + constexpr bool is_fast = false; #endif - prepare_line_to_destination(); + if (is_fast) + prepare_fast_move_to_destination(); + else + prepare_line_to_destination(); feedrate_mm_s = old_feedrate; feedrate_percentage = old_pct; @@ -382,7 +383,12 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ } /** - * Plan a move to (X, Y, Z) and set the current_position + * Plan a move to (X, Y, Z) with separation of the XY and Z components. + * + * - If Z is moving up, the Z move is done before XY. + * - If Z is moving down, the Z move is done after XY. + * - Delta may lower Z first to get into the free motion zone. + * - Before returning, wait for the planner buffer to empty. */ void do_blocking_move_to(const float rx, const float ry, const float rz, const_feedRate_t fr_mm_s/*=0.0*/) { DEBUG_SECTION(log_move, "do_blocking_move_to", DEBUGGING(LEVELING)); @@ -391,20 +397,21 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const_f const feedRate_t z_feedrate = fr_mm_s ?: homing_feedrate(Z_AXIS), xy_feedrate = fr_mm_s ?: feedRate_t(XY_PROBE_FEEDRATE_MM_S); + #if EITHER(DELTA, IS_SCARA) + if (!position_is_reachable(rx, ry)) return; + destination = current_position; // sync destination at the start + #endif + #if ENABLED(DELTA) - if (!position_is_reachable(rx, ry)) return; - REMEMBER(fr, feedrate_mm_s, xy_feedrate); - destination = current_position; // sync destination at the start - if (DEBUGGING(LEVELING)) DEBUG_POS("destination = current_position", destination); // when in the danger zone if (current_position.z > delta_clip_start_height) { - if (rz > delta_clip_start_height) { // staying in the danger zone - destination.set(rx, ry, rz); // move directly (uninterpolated) + if (rz > delta_clip_start_height) { // staying in the danger zone + destination.set(rx, ry, rz); // move directly (uninterpolated) prepare_internal_fast_move_to_destination(); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position); return; @@ -432,10 +439,6 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const_f #elif IS_SCARA - if (!position_is_reachable(rx, ry)) return; - - destination = current_position; - // If Z needs to raise, do it before moving XY if (destination.z < rz) { destination.z = rz; From 7f56538602d5cfeb20da143e896e74c881d94d29 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Tue, 13 Apr 2021 03:28:13 +0200 Subject: [PATCH 204/311] Chamber Fan mode 3 (#21594) --- Marlin/Configuration_adv.h | 5 ++++- Marlin/src/module/temperature.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a2f357501b..fd598e59e4 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -163,7 +163,7 @@ //#define CHAMBER_FAN // Enable a fan on the chamber #if ENABLED(CHAMBER_FAN) - #define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve. + #define CHAMBER_FAN_MODE 2 // Fan control mode: 0=Static; 1=Linear increase when temp is higher than target; 2=V-shaped curve; 3=similar to 1 but fan is always on. #if CHAMBER_FAN_MODE == 0 #define CHAMBER_FAN_BASE 255 // Chamber fan PWM (0-255) #elif CHAMBER_FAN_MODE == 1 @@ -172,6 +172,9 @@ #elif CHAMBER_FAN_MODE == 2 #define CHAMBER_FAN_BASE 128 // Minimum chamber fan PWM (0-255) #define CHAMBER_FAN_FACTOR 25 // PWM increase per °C difference from target + #elif CHAMBER_FAN_MODE == 3 + #define CHAMBER_FAN_BASE 128 // Base chamber fan PWM (0-255) + #define CHAMBER_FAN_FACTOR 25 // PWM increase per °C above target #endif #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index faa5bb5b10..f0bb81bce7 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1406,6 +1406,8 @@ void Temperature::manage_heater() { fan_chamber_pwm = (CHAMBER_FAN_BASE) + (CHAMBER_FAN_FACTOR) * ABS(temp_chamber.celsius - temp_chamber.target); if (temp_chamber.soft_pwm_amount) fan_chamber_pwm += (CHAMBER_FAN_FACTOR) * 2; + #elif CHAMBER_FAN_MODE == 3 + fan_chamber_pwm = CHAMBER_FAN_BASE + _MAX((CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target), 0); #endif NOMORE(fan_chamber_pwm, 225); set_fan_speed(2, fan_chamber_pwm); // TODO: instead of fan 2, set to chamber fan From 3517fbdcbdbb3ba790b0aac55e3ffb03e94f3307 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Apr 2021 20:58:34 -0500 Subject: [PATCH 205/311] Blocking move followup --- Marlin/src/module/motion.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 9c1f8cd4ad..6058db37b3 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -367,11 +367,8 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ planner.e_factor[active_extruder] = 1.0f; #endif - #if !IS_KINEMATIC - constexpr bool is_fast = false; - #endif - if (is_fast) - prepare_fast_move_to_destination(); + if (TERN0(IS_KINEMATIC, is_fast)) + TERN(IS_KINEMATIC, NOOP, prepare_line_to_destination()); else prepare_line_to_destination(); From 5fb3ee610140c9895be5495d84b6d853514e5e2d Mon Sep 17 00:00:00 2001 From: ellensp Date: Tue, 13 Apr 2021 14:02:21 +1200 Subject: [PATCH 206/311] Fix Max Temperature not enforced (#21592) --- Marlin/src/module/temperature.cpp | 6 ++-- Marlin/src/module/thermistor/thermistors.h | 36 ++++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f0bb81bce7..306f5c5886 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2196,19 +2196,19 @@ void Temperature::init() { #if HAS_HOTEND #define _TEMP_MIN_E(NR) do{ \ - const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \ + const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int)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 celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \ + const celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int)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 && TEMP_SENSOR_ ##N## THERMISTOR_ID && TEMP_SENSOR_ ##N## THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## THERMISTOR_ID != 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); diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 0871844e39..97d268c303 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -335,7 +335,8 @@ 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) REVERSE_TEMP_SENSOR_RANGE_##N +#define _TT_REV(N) __TT_REV(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)) @@ -343,72 +344,72 @@ static_assert( #ifdef TEMPTABLE_0 #if TT_REV(0) #define TEMP_SENSOR_0_MINTEMP_IND 0 - #define TEMPTABLE_0_MAXTEMP_IND HEATER_0_LEN - 1 + #define TEMP_SENSOR_0_MAXTEMP_IND TEMPTABLE_0_LEN - 1 #else - #define TEMPTABLE_0_MINTEMP_IND HEATER_0_LEN - 1 + #define TEMP_SENSOR_0_MINTEMP_IND TEMPTABLE_0_LEN - 1 #define TEMP_SENSOR_0_MAXTEMP_IND 0 #endif #endif #ifdef TEMPTABLE_1 #if TT_REV(1) #define TEMP_SENSOR_1_MINTEMP_IND 0 - #define TEMPTABLE_1_MAXTEMP_IND HEATER_1_LEN - 1 + #define TEMP_SENSOR_1_MAXTEMP_IND TEMPTABLE_1_LEN - 1 #else - #define TEMPTABLE_1_MINTEMP_IND HEATER_1_LEN - 1 + #define TEMP_SENSOR_1_MINTEMP_IND TEMPTABLE_1_LEN - 1 #define TEMP_SENSOR_1_MAXTEMP_IND 0 #endif #endif #ifdef TEMPTABLE_2 #if TT_REV(2) #define TEMP_SENSOR_2_MINTEMP_IND 0 - #define TEMPTABLE_2_MAXTEMP_IND HEATER_2_LEN - 1 + #define TEMP_SENSOR_2_MAXTEMP_IND TEMPTABLE_2_LEN - 1 #else - #define TEMPTABLE_2_MINTEMP_IND HEATER_2_LEN - 1 + #define TEMP_SENSOR_2_MINTEMP_IND TEMPTABLE_2_LEN - 1 #define TEMP_SENSOR_2_MAXTEMP_IND 0 #endif #endif #ifdef TEMPTABLE_3 #if TT_REV(3) #define TEMP_SENSOR_3_MINTEMP_IND 0 - #define TEMPTABLE_3_MAXTEMP_IND HEATER_3_LEN - 1 + #define TEMP_SENSOR_3_MAXTEMP_IND TEMPTABLE_3_LEN - 1 #else - #define TEMPTABLE_3_MINTEMP_IND HEATER_3_LEN - 1 + #define TEMP_SENSOR_3_MINTEMP_IND TEMPTABLE_3_LEN - 1 #define TEMP_SENSOR_3_MAXTEMP_IND 0 #endif #endif #ifdef TEMPTABLE_4 #if TT_REV(4) #define TEMP_SENSOR_4_MINTEMP_IND 0 - #define TEMPTABLE_4_MAXTEMP_IND HEATER_4_LEN - 1 + #define TEMP_SENSOR_4_MAXTEMP_IND TEMPTABLE_4_LEN - 1 #else - #define TEMPTABLE_4_MINTEMP_IND HEATER_4_LEN - 1 + #define TEMP_SENSOR_4_MINTEMP_IND TEMPTABLE_4_LEN - 1 #define TEMP_SENSOR_4_MAXTEMP_IND 0 #endif #endif #ifdef TEMPTABLE_5 #if TT_REV(5) #define TEMP_SENSOR_5_MINTEMP_IND 0 - #define TEMPTABLE_5_MAXTEMP_IND HEATER_5_LEN - 1 + #define TEMP_SENSOR_5_MAXTEMP_IND TEMPTABLE_5_LEN - 1 #else - #define TEMPTABLE_5_MINTEMP_IND HEATER_5_LEN - 1 + #define TEMP_SENSOR_5_MINTEMP_IND TEMPTABLE_5_LEN - 1 #define TEMP_SENSOR_5_MAXTEMP_IND 0 #endif #endif #ifdef TEMPTABLE_6 #if TT_REV(6) #define TEMP_SENSOR_6_MINTEMP_IND 0 - #define TEMPTABLE_6_MAXTEMP_IND HEATER_6_LEN - 1 + #define TEMP_SENSOR_6_MAXTEMP_IND TEMPTABLE_6_LEN - 1 #else - #define TEMPTABLE_6_MINTEMP_IND HEATER_6_LEN - 1 + #define TEMP_SENSOR_6_MINTEMP_IND TEMPTABLE_6_LEN - 1 #define TEMP_SENSOR_6_MAXTEMP_IND 0 #endif #endif #ifdef TEMPTABLE_7 #if TT_REV(7) #define TEMP_SENSOR_7_MINTEMP_IND 0 - #define TEMPTABLE_7_MAXTEMP_IND HEATER_7_LEN - 1 + #define TEMP_SENSOR_7_MAXTEMP_IND TEMPTABLE_7_LEN - 1 #else - #define TEMPTABLE_7_MINTEMP_IND HEATER_7_LEN - 1 + #define TEMP_SENSOR_7_MINTEMP_IND TEMPTABLE_7_LEN - 1 #define TEMP_SENSOR_7_MAXTEMP_IND 0 #endif #endif @@ -522,6 +523,7 @@ static_assert( #endif #endif +#undef __TT_REV #undef _TT_REV #undef TT_REV #undef _TT_REVRAW From 41eb5813e05451e6634d73551913acc44a0448ea Mon Sep 17 00:00:00 2001 From: pinchies Date: Tue, 13 Apr 2021 12:14:34 +1000 Subject: [PATCH 207/311] Fix Flash size (512KB) for STM32F103ZE (#21590) --- Marlin/src/HAL/STM32F1/HAL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 4f430ab4d9..94b0ad7ead 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -53,7 +53,7 @@ // ------------------------ #ifndef STM32_FLASH_SIZE - #if EITHER(MCU_STM32F103RE, MCU_STM32F103VE) + #if ANY(MCU_STM32F103RE, MCU_STM32F103VE, MCU_STM32F103ZE) #define STM32_FLASH_SIZE 512 #else #define STM32_FLASH_SIZE 256 From e0ed57db67ff191452f00808dc696c80dd8e03f7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 12 Apr 2021 23:40:32 -0500 Subject: [PATCH 208/311] Remove extraneous MKS UI sprintf --- .../lib/mks_ui/draw_acceleration_settings.cpp | 7 +- .../draw_auto_level_offset_settings.cpp | 7 +- .../extui/lib/mks_ui/draw_jerk_settings.cpp | 9 +- .../lcd/extui/lib/mks_ui/draw_manuaLevel.cpp | 2 +- .../lib/mks_ui/draw_max_feedrate_settings.cpp | 11 +- .../lcd/extui/lib/mks_ui/draw_number_key.cpp | 129 +++++++++--------- .../extui/lib/mks_ui/draw_pause_position.cpp | 7 +- .../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 +- .../lib/mks_ui/draw_tramming_pos_settings.cpp | 20 +-- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 20 +-- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 2 +- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 4 +- 14 files changed, 116 insertions(+), 127 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 4bc01c9e2d..7bc5a263b4 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,14 @@ 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("%s"), dtostrf(planner.settings.acceleration, 1, 1, str_1)); + dtostrf(planner.settings.acceleration, 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.retract_acceleration, 1, 1, str_1)); + dtostrf(planner.settings.retract_acceleration, 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.travel_acceleration, 1, 1, str_1)); + dtostrf(planner.settings.travel_acceleration, 1, 1, public_buf_l); 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 f1cdbfe414..3de078f375 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,16 +65,15 @@ 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("%s"), TERN(HAS_PROBE_XY_OFFSET, dtostrf(probe.offset.x, 1, 1, str_1) , 0)); + dtostrf(TERN0(HAS_PROBE_XY_OFFSET, probe.offset.x), 1, 1, public_buf_l); 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("%s"), TERN(HAS_PROBE_XY_OFFSET, dtostrf(probe.offset.y, 1, 1, str_1) , 0)); + dtostrf(TERN0(HAS_PROBE_XY_OFFSET, probe.offset.y), 1, 1, public_buf_l); 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("%s"), TERN(HAS_PROBE_XY_OFFSET, dtostrf(probe.offset.z, 1, 1, str_1) , 0)); + dtostrf(TERN0(HAS_PROBE_XY_OFFSET, probe.offset.z), 1, 1, public_buf_l); 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_jerk_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp index c911b09128..4067262f20 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,19 +71,18 @@ 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("%s"), dtostrf(planner.max_jerk[X_AXIS], 1, 1, str_1)); + dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.max_jerk[Y_AXIS], 1, 1, str_1)); + dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.max_jerk[Z_AXIS], 1, 1, str_1)); + dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.max_jerk[E_AXIS], 1, 1, str_1)); + dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_l); 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_manuaLevel.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp index 9734dd94ae..e296a73590 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp @@ -54,7 +54,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { queue.inject_P(G28_STR); } const int ind = obj->mks_obj_id - ID_M_POINT1; - sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), (int)gCfgItems.trammingPos[ind][X_AXIS], (int)gCfgItems.trammingPos[ind][Y_AXIS]); + sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), gCfgItems.trammingPos[ind].x, gCfgItems.trammingPos[ind].y); queue.inject(public_buf_l); } break; 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 cf74f42ee7..238a9af6ae 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,26 +80,25 @@ 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("%s"), dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, public_buf_l); 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_number_key.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp index 092dcce083..70e1bba990 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,214 +73,211 @@ enum { static void disp_key_value() { char *temp; - char str_1[16]; - #if HAS_TRINAMIC_CONFIG - float milliamps; - #endif + TERN_(HAS_TRINAMIC_CONFIG, float milliamps); switch (value) { case PrintAcceleration: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.acceleration, 1, 1, str_1)); + dtostrf(planner.settings.acceleration, 1, 1, public_buf_m); break; case RetractAcceleration: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.retract_acceleration, 1, 1, str_1)); + dtostrf(planner.settings.retract_acceleration, 1, 1, public_buf_m); break; case TravelAcceleration: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.travel_acceleration, 1, 1, str_1)); + dtostrf(planner.settings.travel_acceleration, 1, 1, public_buf_m); break; case XAcceleration: - sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]); + itoa(planner.settings.max_acceleration_mm_per_s2[X_AXIS], public_buf_m, 10); break; case YAcceleration: - sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + itoa(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], public_buf_m, 10); break; case ZAcceleration: - sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + itoa(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], public_buf_m, 10); break; case E0Acceleration: - sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]); + itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS], public_buf_m, 10); break; case E1Acceleration: - sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]); + itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], public_buf_m, 10); break; case XMaxFeedRate: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_m); break; case YMaxFeedRate: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_m); break; case ZMaxFeedRate: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_m); break; case E0MaxFeedRate: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, public_buf_m); break; case E1MaxFeedRate: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, str_1)); + dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, public_buf_m); break; case XJerk: #if HAS_CLASSIC_JERK - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.max_jerk[X_AXIS], 1, 1, str_1)); + dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_m); #endif break; case YJerk: #if HAS_CLASSIC_JERK - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.max_jerk[Y_AXIS], 1, 1, str_1)); + dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_m); #endif break; case ZJerk: #if HAS_CLASSIC_JERK - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.max_jerk[Z_AXIS], 1, 1, str_1)); + dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_m); #endif break; case EJerk: #if HAS_CLASSIC_JERK - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.max_jerk[E_AXIS], 1, 1, str_1)); + dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_m); #endif break; case Xstep: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_m); break; case Ystep: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_m); break; case Zstep: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_m); break; case E0step: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, public_buf_m); break; case E1step: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, public_buf_m); break; case Xcurrent: #if AXIS_IS_TMC(X) milliamps = stepperX.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_m); #endif break; case Ycurrent: #if AXIS_IS_TMC(Y) milliamps = stepperY.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_m); #endif break; case Zcurrent: #if AXIS_IS_TMC(Z) milliamps = stepperZ.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_m); #endif break; case E0current: #if AXIS_IS_TMC(E0) milliamps = stepperE0.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_m); #endif break; case E1current: #if AXIS_IS_TMC(E1) milliamps = stepperE1.getMilliamps(); - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_m); #endif break; case pause_pos_x: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(gCfgItems.pausePosX, 1, 1, str_1)); + dtostrf(gCfgItems.pausePosX, 1, 1, public_buf_m); break; case pause_pos_y: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(gCfgItems.pausePosY, 1, 1, str_1)); + dtostrf(gCfgItems.pausePosY, 1, 1, public_buf_m); break; case pause_pos_z: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(gCfgItems.pausePosZ, 1, 1, str_1)); + dtostrf(gCfgItems.pausePosZ, 1, 1, public_buf_m); break; case level_pos_x1: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[0][X_AXIS]); + itoa(gCfgItems.trammingPos[0].x, public_buf_m, 10); break; case level_pos_y1: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[0][Y_AXIS]); + itoa(gCfgItems.trammingPos[0].y, public_buf_m, 10); break; case level_pos_x2: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[1][X_AXIS]); + itoa(gCfgItems.trammingPos[1].x, public_buf_m, 10); break; case level_pos_y2: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[1][Y_AXIS]); + itoa(gCfgItems.trammingPos[1].y, public_buf_m, 10); break; case level_pos_x3: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[2][X_AXIS]); + itoa(gCfgItems.trammingPos[2].x, public_buf_m, 10); break; case level_pos_y3: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[2][Y_AXIS]); + itoa(gCfgItems.trammingPos[2].y, public_buf_m, 10); break; case level_pos_x4: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[3][X_AXIS]); + itoa(gCfgItems.trammingPos[3].x, public_buf_m, 10); break; case level_pos_y4: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[3][Y_AXIS]); + itoa(gCfgItems.trammingPos[3].y, public_buf_m, 10); break; case level_pos_x5: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[4][X_AXIS]); + itoa(gCfgItems.trammingPos[4].x, public_buf_m, 10); break; case level_pos_y5: - sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.trammingPos[4][Y_AXIS]); + itoa(gCfgItems.trammingPos[4].y, public_buf_m, 10); break; #if HAS_BED_PROBE case x_offset: #if HAS_PROBE_XY_OFFSET - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(probe.offset.x, 1, 3, str_1)); + dtostrf(probe.offset.x, 1, 3, public_buf_m); #endif break; case y_offset: #if HAS_PROBE_XY_OFFSET - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(probe.offset.y, 1, 3, str_1)); + dtostrf(probe.offset.y, 1, 3, public_buf_m); #endif break; case z_offset: - sprintf_P(public_buf_m, PSTR("%s"), dtostrf(probe.offset.z, 1, 3, str_1)); + dtostrf(probe.offset.z, 1, 3, public_buf_m); break; #endif case load_length: - sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_load_length); + itoa(gCfgItems.filamentchange_load_length, public_buf_m, 10); break; case load_speed: - sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_load_speed); + itoa(gCfgItems.filamentchange_load_speed, public_buf_m, 10); break; case unload_length: - sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_length); + itoa(gCfgItems.filamentchange_unload_length, public_buf_m, 10); break; case unload_speed: - sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_speed); + itoa(gCfgItems.filamentchange_unload_speed, public_buf_m, 10); break; case filament_temp: - sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temp); + itoa(gCfgItems.filament_limit_temp, public_buf_m, 10); break; case x_sensitivity: #if X_SENSORLESS - sprintf_P(public_buf_m, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0)); + itoa(TERN(X_SENSORLESS, stepperX.homing_threshold(), 0), public_buf_m, 10); #endif break; case y_sensitivity: #if Y_SENSORLESS - sprintf_P(public_buf_m, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0)); + itoa(TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0), public_buf_m, 10); #endif break; case z_sensitivity: #if Z_SENSORLESS - sprintf_P(public_buf_m, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0)); + itoa(TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0), public_buf_m, 10); #endif break; case z2_sensitivity: #if Z2_SENSORLESS - sprintf_P(public_buf_m, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0)); + itoa(TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0), public_buf_m, 10); #endif break; } @@ -346,16 +343,16 @@ static void set_value_confirm() { case pause_pos_x: gCfgItems.pausePosX = atof(key_value); update_spi_flash(); break; case pause_pos_y: gCfgItems.pausePosY = atof(key_value); update_spi_flash(); break; case pause_pos_z: gCfgItems.pausePosZ = atof(key_value); update_spi_flash(); break; - case level_pos_x1: gCfgItems.trammingPos[0][X_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_y1: gCfgItems.trammingPos[0][Y_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_x2: gCfgItems.trammingPos[1][X_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_y2: gCfgItems.trammingPos[1][Y_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_x3: gCfgItems.trammingPos[2][X_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_y3: gCfgItems.trammingPos[2][Y_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_x4: gCfgItems.trammingPos[3][X_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_y4: gCfgItems.trammingPos[3][Y_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_x5: gCfgItems.trammingPos[4][X_AXIS] = atoi(key_value); update_spi_flash(); break; - case level_pos_y5: gCfgItems.trammingPos[4][Y_AXIS] = atoi(key_value); update_spi_flash(); break; + case level_pos_x1: gCfgItems.trammingPos[0].x = atoi(key_value); update_spi_flash(); break; + case level_pos_y1: gCfgItems.trammingPos[0].y = atoi(key_value); update_spi_flash(); break; + case level_pos_x2: gCfgItems.trammingPos[1].x = atoi(key_value); update_spi_flash(); break; + case level_pos_y2: gCfgItems.trammingPos[1].y = atoi(key_value); update_spi_flash(); break; + case level_pos_x3: gCfgItems.trammingPos[2].x = atoi(key_value); update_spi_flash(); break; + case level_pos_y3: gCfgItems.trammingPos[2].y = atoi(key_value); update_spi_flash(); break; + case level_pos_x4: gCfgItems.trammingPos[3].x = atoi(key_value); update_spi_flash(); break; + case level_pos_y4: gCfgItems.trammingPos[3].y = atoi(key_value); update_spi_flash(); break; + case level_pos_x5: gCfgItems.trammingPos[4].x = atoi(key_value); update_spi_flash(); break; + case level_pos_y5: gCfgItems.trammingPos[4].y = atoi(key_value); update_spi_flash(); break; #if HAS_BED_PROBE case x_offset: { #if HAS_PROBE_XY_OFFSET 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 385276af39..2f60bc6685 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,16 +60,15 @@ 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("%s"), dtostrf(gCfgItems.pausePosX, 1, 1, str_1)); + dtostrf(gCfgItems.pausePosX, 1, 1, public_buf_l); 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("%s"), dtostrf(gCfgItems.pausePosY, 1, 1, str_1)); + dtostrf(gCfgItems.pausePosY, 1, 1, public_buf_l); 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("%s"), dtostrf(gCfgItems.pausePosZ, 1, 1, str_1)); + dtostrf(gCfgItems.pausePosZ, 1, 1, public_buf_l); 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_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index a1818e6ddd..606ef31917 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -251,8 +251,7 @@ void disp_print_time() { } void disp_fan_Zpos() { - char str_1[16]; - sprintf_P(public_buf_l, PSTR("%s"), dtostrf(current_position.z, 1, 3, str_1)); + dtostrf(current_position.z, 1, 3, public_buf_l); 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 a88669f371..f48d533691 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,26 +79,25 @@ 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("%s"), dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, public_buf_l); 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("%s"), dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, str_1)); + dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, public_buf_l); 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 7f889461ea..7c0fc97c93 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,14 +95,13 @@ 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("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_l); 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) @@ -110,7 +109,7 @@ void lv_draw_tmc_current_settings() { #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_l); 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) @@ -118,7 +117,7 @@ void lv_draw_tmc_current_settings() { #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_l); 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) @@ -126,7 +125,7 @@ void lv_draw_tmc_current_settings() { #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_l); 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); @@ -137,7 +136,7 @@ void lv_draw_tmc_current_settings() { #else milliamps = -1; #endif - sprintf_P(public_buf_l, PSTR("%s"), dtostrf(milliamps, 1, 1, str_1)); + dtostrf(milliamps, 1, 1, public_buf_l); 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/draw_tramming_pos_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp index d5307232d6..9b6c11d335 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp @@ -107,27 +107,27 @@ void lv_draw_tramming_pos_settings() { scr = lv_screen_create(MANUAL_LEVELING_POSIGION_UI, machine_menu.LevelingParaConfTitle); if (!uiCfg.para_ui_page) { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[0][X_AXIS]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[0][Y_AXIS]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[0].x); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[0].y); lv_screen_menu_item_2_edit(scr, leveling_menu.position1, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y1, 0, buf2, ID_MANUAL_POS_X1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[1][X_AXIS]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[1][Y_AXIS]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[1].x); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[1].y); lv_screen_menu_item_2_edit(scr, leveling_menu.position2, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MANUAL_POS_Y2, 1, buf2, ID_MANUAL_POS_X2, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[2][X_AXIS]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[2][Y_AXIS]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[2].x); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[2].y); lv_screen_menu_item_2_edit(scr, leveling_menu.position3, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MANUAL_POS_Y3, 2, buf2, ID_MANUAL_POS_X3, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[3][X_AXIS]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[3][Y_AXIS]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[3].x); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[3].y); lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_MANUAL_POS_Y4, 3, buf2, ID_MANUAL_POS_X4, 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_MANUAL_POS_DOWN, true); } else { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[4][X_AXIS]); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[4][Y_AXIS]); + sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[4].x); + sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[4].y); lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y5, 0, buf2, ID_MANUAL_POS_X5, 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_MANUAL_POS_UP, true); 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 68baea30c7..51e187435c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -125,16 +125,16 @@ void gCfgItems_init() { gCfgItems.pausePosX = -1; gCfgItems.pausePosY = -1; gCfgItems.pausePosZ = 5; - gCfgItems.trammingPos[0][X_AXIS] = X_MIN_POS + 30; - gCfgItems.trammingPos[0][Y_AXIS] = Y_MIN_POS + 30; - gCfgItems.trammingPos[1][X_AXIS] = X_MAX_POS - 30; - gCfgItems.trammingPos[1][Y_AXIS] = Y_MIN_POS + 30; - gCfgItems.trammingPos[2][X_AXIS] = X_MAX_POS - 30; - gCfgItems.trammingPos[2][Y_AXIS] = Y_MAX_POS - 30; - gCfgItems.trammingPos[3][X_AXIS] = X_MIN_POS + 30; - gCfgItems.trammingPos[3][Y_AXIS] = Y_MAX_POS - 30; - gCfgItems.trammingPos[4][X_AXIS] = X_BED_SIZE / 2; - gCfgItems.trammingPos[4][Y_AXIS] = Y_BED_SIZE / 2; + gCfgItems.trammingPos[0].x = X_MIN_POS + 30; + gCfgItems.trammingPos[0].y = Y_MIN_POS + 30; + gCfgItems.trammingPos[1].x = X_MAX_POS - 30; + gCfgItems.trammingPos[1].y = Y_MIN_POS + 30; + gCfgItems.trammingPos[2].x = X_MAX_POS - 30; + gCfgItems.trammingPos[2].y = Y_MAX_POS - 30; + gCfgItems.trammingPos[3].x = X_MIN_POS + 30; + gCfgItems.trammingPos[3].y = Y_MAX_POS - 30; + gCfgItems.trammingPos[4].x = X_BED_SIZE / 2; + gCfgItems.trammingPos[4].y = Y_BED_SIZE / 2; gCfgItems.cloud_enable = false; gCfgItems.wifi_mode_sel = STA_MODEL; gCfgItems.fileSysType = FILE_SYS_SD; 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 2be4f7d70b..6577d80cdf 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -197,7 +197,7 @@ typedef struct { uint8_t wifi_type; bool cloud_enable, encoder_enable; - int trammingPos[5][2]; // XY + xy_int_t trammingPos[5]; int filamentchange_load_length, filamentchange_load_speed, filamentchange_unload_length, 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 1057a0c689..957e245882 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -883,7 +883,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { SEND_OK_TO_WIFI; char *outBuf = (char *)tempBuf; - char str_1[16], tbuf[34]; + char tbuf[34]; sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); @@ -1313,7 +1313,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); return; } - sprintf_P((char *)saveFilePath, PSTR("%s"), dosName); + strcpy(saveFilePath, dosName); card.cdroot(); upload_file.close(); From 776c1e66db9e86e70b976fb80560bb658431c782 Mon Sep 17 00:00:00 2001 From: Veisen Date: Tue, 13 Apr 2021 10:09:21 +0200 Subject: [PATCH 209/311] Fix ANYCUBIC_LCD_I3MEGA compile (#21585) --- .../src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp index aa08f683f7..ecc516108c 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 @@ -583,8 +583,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { } break; case 4: { // A4 GET FAN SPEED - const float fanPercent = getActualFan_percent(FAN0); - SEND_PGM_VAL("A4V ", int(LIMIT(fanPercent, 0, 100))); + SEND_PGM_VAL("A4V ", int(getActualFan_percent(FAN0))); } break; case 5: { // A5 GET CURRENT COORDINATE From 4e314ef6d4b29ea453431b5a37416dee39163c66 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 13 Apr 2021 03:49:20 -0500 Subject: [PATCH 210/311] More MKS UI sprintf --- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) 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 957e245882..51c492703e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -478,7 +478,7 @@ char wait_ip_back_flag = 0; typedef struct { int write_index; - uint8_t saveFileName[30]; + char saveFileName[30]; uint8_t fileTransfer; uint32_t fileLen; uint32_t tick_begin; @@ -593,7 +593,7 @@ uint8_t Explore_Disk(char *path , uint8_t recu_level) { } static void wifi_gcode_exec(uint8_t *cmd_line) { - int8_t tempBuf[100] = { 0 }; + char tempBuf[100] = { 0 }; uint8_t *tmpStr = 0; int cmd_value; volatile int print_rate; @@ -631,7 +631,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { while (tmpStr[index] == ' ') index++; if (gCfgItems.wifi_type == ESP_WIFI) { - char *path = (char *)tempBuf; + char *path = tempBuf; if (strlen((char *)&tmpStr[index]) < 80) { send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n")); @@ -828,8 +828,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) { print_rate = uiCfg.totalSend; ZERO(tempBuf); - sprintf_P((char *)tempBuf, PSTR("M27 %d\r\n"), print_rate); - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + sprintf_P(tempBuf, PSTR("M27 %d\r\n"), print_rate); + send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); } break; @@ -841,15 +841,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { while (tmpStr[index] == ' ') index++; if (strstr_P((char *)&tmpStr[index], PSTR(".g")) || strstr_P((char *)&tmpStr[index], PSTR(".G"))) { - strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); + strcpy(file_writer.saveFileName, (char *)&tmpStr[index]); if (gCfgItems.fileSysType == FILE_SYS_SD) { ZERO(tempBuf); - sprintf_P((char *)tempBuf, PSTR("%s"), file_writer.saveFileName); + sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName); } else if (gCfgItems.fileSysType == FILE_SYS_USB) { ZERO(tempBuf); - sprintf_P((char *)tempBuf, PSTR("%s"), (char *)file_writer.saveFileName); + sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName); } mount_file_sys(gCfgItems.fileSysType); @@ -858,11 +858,11 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { card.openFileWrite(cur_name); if (card.isFileOpen()) { ZERO(file_writer.saveFileName); - strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); + strcpy(file_writer.saveFileName, (char *)&tmpStr[index]); ZERO(tempBuf); - sprintf_P((char *)tempBuf, PSTR("Writing to file: %s\r\n"), (char *)file_writer.saveFileName); + sprintf_P(tempBuf, PSTR("Writing to file: %s\r\n"), file_writer.saveFileName); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); wifi_link_state = WIFI_WAIT_TRANS_START; } else { @@ -882,7 +882,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { SEND_OK_TO_WIFI; - char *outBuf = (char *)tempBuf; + char *outBuf = tempBuf; char tbuf[34]; sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); @@ -917,7 +917,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { 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"), + sprintf_P(tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"), thermalManager.degHotend(0), thermalManager.degTargetHotend(0), #if HAS_HEATED_BED thermalManager.degBed(), thermalManager.degTargetBed(), @@ -933,16 +933,16 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { ); } - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); queue.enqueue_one_P(PSTR("M105")); break; case 992: if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { ZERO(tempBuf); - sprintf_P((char *)tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10); + sprintf_P(tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); } break; @@ -950,9 +950,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { ZERO(tempBuf); if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return; - sprintf_P((char *)tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize); + sprintf_P(tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); + send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); } break; @@ -1279,7 +1279,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { ZERO(public_buf); - if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath)) + if (strlen(file_writer.saveFileName) > sizeof(saveFilePath)) return; ZERO(saveFilePath); @@ -1303,9 +1303,9 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { #if ENABLED(SDSUPPORT) - uint8_t dosName[FILENAME_LENGTH]; + char dosName[FILENAME_LENGTH]; - if (!longName2DosName((const char *)file_writer.saveFileName,dosName)) { + if (!longName2DosName(file_writer.saveFileName, dosName)) { clear_cur_ui(); upload_result = 2; wifiTransError.flag = 1; From fd99ea09ecb41bc1dfc5e4109e0d6c7de1f87424 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 13 Apr 2021 04:00:39 -0500 Subject: [PATCH 211/311] Add fan percent accessors --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 2 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 7 +++---- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 2 +- .../lcd/dogm/status_screen_lite_ST7920.cpp | 6 ++---- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 4 ++-- Marlin/src/module/temperature.cpp | 20 +++++++++---------- Marlin/src/module/temperature.h | 20 ++++++++++--------- 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 874fcc143d..57af2b782a 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -944,7 +944,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(ADAPTIVE_FAN_SLOWING) else { c = '*'; spd = thermalManager.scaledFanSpeed(0, spd); } #endif - per = thermalManager.fanPercent(spd); + per = thermalManager.pwmToPercent(spd); } else #endif diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index faac398a4a..5b48cb1ac8 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -750,7 +750,7 @@ void MarlinUI::draw_status_screen() { #if HOTENDS > 2 _draw_heater_status(H_E2, "HE3", blink); // Hotend 3 Temperature #endif - #endif // HOTENDS <= 1 + #endif #if HAS_HEATED_BED #if HAS_LEVELING @@ -758,16 +758,15 @@ void MarlinUI::draw_status_screen() { #else _draw_heater_status(H_BED, "BED", blink); #endif - #endif // HAS_HEATED_BED + #endif #if HAS_FAN uint16_t spd = thermalManager.fan_speed[0]; - #if ENABLED(ADAPTIVE_FAN_SLOWING) if (!blink) spd = thermalManager.scaledFanSpeed(0, spd); #endif + uint16_t per = thermalManager.pwmToPercent(spd); - uint16_t per = thermalManager.fanPercent(spd); #if HOTENDS < 2 #define FANX 11 #else diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 793bcd752f..7e638a645e 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -696,7 +696,7 @@ void MarlinUI::draw_status_screen() { c = '*'; } #endif - lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.fanPercent(spd))); + lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.pwmToPercent(spd))); lcd_put_wchar(c); } } diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index a2dfb74a57..b67688cb57 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -733,14 +733,12 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { TERN_(HAS_MULTI_HOTEND, draw_extruder_2_temp(extruder_2_temp, extruder_2_target, forceUpdate)); TERN_(HAS_HEATED_BED, draw_bed_temp(bed_temp, bed_target, forceUpdate)); - uint16_t spd = thermalManager.fan_speed[0]; - + uint8_t spd = thermalManager.fan_speed[0]; #if ENABLED(ADAPTIVE_FAN_SLOWING) if (!blink && thermalManager.fan_speed_scaler[0] < 128) spd = thermalManager.scaledFanSpeed(0, spd); #endif - - draw_fan_speed(thermalManager.fanPercent(spd)); + draw_fan_speed(thermalManager.pwmToPercent(spd)); // Draw elapsed/remaining time const bool show_remaining = ENABLED(SHOW_REMAINING_TIME) && (DISABLED(ROTATE_PROGRESS_DISPLAY) || blink); 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 606ef31917..e9cfd8179a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -236,7 +236,7 @@ void disp_bed_temp() { } void disp_fan_speed() { - sprintf_P(public_buf_l, PSTR("%d%%"), thermalManager.fanPercent(thermalManager.fan_speed[0])); + sprintf_P(public_buf_l, PSTR("%d%%"), thermalManager.fanSpeedPercent(0)); lv_label_set_text(labelFan, public_buf_l); } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index a4515734a0..d02e774b94 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -241,7 +241,7 @@ void lv_draw_ready_print() { lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #endif - sprintf_P(buf, PSTR("%d%%"), thermalManager.fanPercent(thermalManager.fan_speed[0])); + sprintf_P(buf, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0)); lv_label_set_text(labelFan, buf); lv_obj_align(labelFan, buttonFanstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 17e869d44f..c03a10fcd3 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -297,7 +297,7 @@ namespace ExtUI { float getTargetFan_percent(const fan_t fan) { #if HAS_FAN - return thermalManager.fanPercent(thermalManager.fan_speed[fan - FAN0]); + return thermalManager.fanSpeedPercent(fan - FAN0); #else UNUSED(fan); return 0; @@ -306,7 +306,7 @@ namespace ExtUI { float getActualFan_percent(const fan_t fan) { #if HAS_FAN - return thermalManager.fanPercent(thermalManager.scaledFanSpeed(fan - FAN0)); + return thermalManager.scaledFanSpeedPercent(fan - FAN0); #else UNUSED(fan); return 0; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 306f5c5886..08583676da 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -315,34 +315,34 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, /** * Set the print fan speed for a target extruder */ - void Temperature::set_fan_speed(uint8_t target, uint16_t speed) { + void Temperature::set_fan_speed(uint8_t fan, uint16_t speed) { NOMORE(speed, 255U); #if ENABLED(SINGLENOZZLE_STANDBY_FAN) - if (target != active_extruder) { - if (target < EXTRUDERS) singlenozzle_fan_speed[target] = speed; + if (fan != active_extruder) { + if (fan < EXTRUDERS) singlenozzle_fan_speed[fan] = speed; return; } #endif - TERN_(SINGLENOZZLE, target = 0); // Always use fan index 0 with SINGLENOZZLE + TERN_(SINGLENOZZLE, fan = 0); // Always use fan index 0 with SINGLENOZZLE - if (target >= FAN_COUNT) return; + if (fan >= FAN_COUNT) return; - fan_speed[target] = speed; + fan_speed[fan] = speed; - TERN_(REPORT_FAN_CHANGE, report_fan_speed(target)); + TERN_(REPORT_FAN_CHANGE, report_fan_speed(fan)); } #if ENABLED(REPORT_FAN_CHANGE) /** * Report print fan speed for a target extruder */ - void Temperature::report_fan_speed(const uint8_t target) { - if (target >= FAN_COUNT) return; + void Temperature::report_fan_speed(const uint8_t fan) { + if (fan >= FAN_COUNT) return; PORT_REDIRECT(SerialMask::All); - SERIAL_ECHOLNPAIR("M106 P", target, " S", fan_speed[target]); + SERIAL_ECHOLNPAIR("M106 P", fan, " S", fan_speed[fan]); } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 9633c9733c..bcb451064e 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -553,10 +553,10 @@ class Temperature { static uint8_t fan_speed[FAN_COUNT]; #define FANS_LOOP(I) LOOP_L_N(I, FAN_COUNT) - static void set_fan_speed(const uint8_t target, const uint16_t speed); + static void set_fan_speed(const uint8_t fan, const uint16_t speed); #if ENABLED(REPORT_FAN_CHANGE) - static void report_fan_speed(const uint8_t target); + static void report_fan_speed(const uint8_t fan); #endif #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE) @@ -564,21 +564,23 @@ class Temperature { static uint8_t saved_fan_speed[FAN_COUNT]; #endif - static constexpr inline uint8_t fanPercent(const uint8_t speed) { return ui8_to_percent(speed); } - #if ENABLED(ADAPTIVE_FAN_SLOWING) static uint8_t fan_speed_scaler[FAN_COUNT]; #endif - static inline uint8_t scaledFanSpeed(const uint8_t target, const uint8_t fs) { - UNUSED(target); // Potentially unused! - return (fs * uint16_t(TERN(ADAPTIVE_FAN_SLOWING, fan_speed_scaler[target], 128))) >> 7; + static inline uint8_t scaledFanSpeed(const uint8_t fan, const uint8_t fs) { + UNUSED(fan); // Potentially unused! + return (fs * uint16_t(TERN(ADAPTIVE_FAN_SLOWING, fan_speed_scaler[fan], 128))) >> 7; } - static inline uint8_t scaledFanSpeed(const uint8_t target) { - return scaledFanSpeed(target, fan_speed[target]); + static inline uint8_t scaledFanSpeed(const uint8_t fan) { + return scaledFanSpeed(fan, fan_speed[fan]); } + static constexpr inline uint8_t pwmToPercent(const uint8_t speed) { return ui8_to_percent(speed); } + static inline uint8_t fanSpeedPercent(const uint8_t fan) { return ui8_to_percent(fan_speed[fan]); } + static inline uint8_t scaledFanSpeedPercent(const uint8_t fan) { return ui8_to_percent(scaledFanSpeed(fan)); } + #if ENABLED(EXTRA_FAN_SPEED) typedef struct { uint8_t saved, speed; } extra_fan_t; static extra_fan_t extra_fan_speed[FAN_COUNT]; From 84c79d753156a396fca43dd62cd693454efac882 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 13 Apr 2021 15:07:25 -0500 Subject: [PATCH 212/311] Followup to sprintf cleanup --- .../lcd/extui/lib/mks_ui/draw_cloud_bind.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_keyboard.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_manuaLevel.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 54 +++++++++---------- Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h | 14 ++--- .../variants/megaextendedpins/pins_arduino.h | 4 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp index ae8fe3a321..c6752939dd 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp @@ -190,7 +190,7 @@ void display_qrcode(uint8_t *qrcode_data) { } void cloud_unbind() { - package_to_wifi(WIFI_CLOUD_UNBIND, (uint8_t *)0, 0); + package_to_wifi(WIFI_CLOUD_UNBIND, nullptr, 0); unbinding_flag = 1; } 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 1f84ca6f59..a05c558beb 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp @@ -137,7 +137,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { gCfgItems.wifi_mode_sel = STA_MODEL; - package_to_wifi(WIFI_PARA_SET, (uint8_t *)0, 0); + package_to_wifi(WIFI_PARA_SET, nullptr, 0); public_buf_l[0] = 0xA5; public_buf_l[1] = 0x09; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp index e296a73590..f25c7c0c25 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp @@ -54,7 +54,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { queue.inject_P(G28_STR); } const int ind = obj->mks_obj_id - ID_M_POINT1; - sprintf_P(public_buf_l, PSTR("G1 Z10\nG1 X%d Y%d\nG1 Z0"), gCfgItems.trammingPos[ind].x, gCfgItems.trammingPos[ind].y); + sprintf_P(public_buf_l, PSTR("G1Z10\nG1X%dY%d\nG1Z0"), gCfgItems.trammingPos[ind].x, gCfgItems.trammingPos[ind].y); queue.inject(public_buf_l); } break; 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 51c492703e..6c2afeafd3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -178,14 +178,14 @@ void changeFlashMode(const bool dmaMode) { } } -static bool longName2DosName(const char *longName, uint8_t *dosName) { +static bool longName2DosName(const char *longName, char *dosName) { uint8_t i; for (i = FILENAME_LENGTH; i--;) dosName[i] = '\0'; while (*longName) { uint8_t c = *longName++; if (c == '.') { // For a dot... if (i == 0) return false; - strcat_P((char *)dosName, PSTR(".GCO")); + strcat_P(dosName, PSTR(".GCO")); break; } else { @@ -196,7 +196,7 @@ static bool longName2DosName(const char *longName, uint8_t *dosName) { dosName[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name } if (i >= 5) { - strcat_P((char *)dosName, PSTR("~1.GCO")); + strcat_P(dosName, PSTR("~1.GCO")); break; } } @@ -478,7 +478,7 @@ char wait_ip_back_flag = 0; typedef struct { int write_index; - char saveFileName[30]; + uint8_t saveFileName[30]; uint8_t fileTransfer; uint32_t fileLen; uint32_t tick_begin; @@ -593,7 +593,7 @@ uint8_t Explore_Disk(char *path , uint8_t recu_level) { } static void wifi_gcode_exec(uint8_t *cmd_line) { - char tempBuf[100] = { 0 }; + int8_t tempBuf[100] = { 0 }; uint8_t *tmpStr = 0; int cmd_value; volatile int print_rate; @@ -631,7 +631,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { while (tmpStr[index] == ' ') index++; if (gCfgItems.wifi_type == ESP_WIFI) { - char *path = tempBuf; + char *path = (char *)tempBuf; if (strlen((char *)&tmpStr[index]) < 80) { send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n")); @@ -680,7 +680,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcat_P((char *)list_file.file_name[sel_id], PSTR("/")); if (file_writer.fileTransfer == 1) { - uint8_t dosName[FILENAME_LENGTH]; + char dosName[FILENAME_LENGTH]; uint8_t fileName[sizeof(list_file.file_name[sel_id])]; fileName[0] = '\0'; if (has_path_selected == 1) { @@ -690,8 +690,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { else strcat((char *)fileName, (char *)&tmpStr[index]); if (!longName2DosName((const char *)fileName, dosName)) strcpy_P(list_file.file_name[sel_id], PSTR("notValid")); - strcat((char *)list_file.file_name[sel_id], (char *)dosName); - strcat((char *)list_file.long_name[sel_id], (char *)dosName); + strcat((char *)list_file.file_name[sel_id], dosName); + strcat((char *)list_file.long_name[sel_id], dosName); } else { strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]); @@ -828,8 +828,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)|| (uiCfg.print_state == REPRINTING)) { print_rate = uiCfg.totalSend; ZERO(tempBuf); - sprintf_P(tempBuf, PSTR("M27 %d\r\n"), print_rate); - send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); + sprintf_P((char *)tempBuf, PSTR("M27 %d\r\n"), print_rate); + send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); } break; @@ -841,15 +841,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { while (tmpStr[index] == ' ') index++; if (strstr_P((char *)&tmpStr[index], PSTR(".g")) || strstr_P((char *)&tmpStr[index], PSTR(".G"))) { - strcpy(file_writer.saveFileName, (char *)&tmpStr[index]); + strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); if (gCfgItems.fileSysType == FILE_SYS_SD) { ZERO(tempBuf); - sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName); + sprintf_P((char *)tempBuf, PSTR("%s"), file_writer.saveFileName); } else if (gCfgItems.fileSysType == FILE_SYS_USB) { ZERO(tempBuf); - sprintf_P(tempBuf, PSTR("%s"), file_writer.saveFileName); + sprintf_P((char *)tempBuf, PSTR("%s"), (char *)file_writer.saveFileName); } mount_file_sys(gCfgItems.fileSysType); @@ -858,11 +858,11 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { card.openFileWrite(cur_name); if (card.isFileOpen()) { ZERO(file_writer.saveFileName); - strcpy(file_writer.saveFileName, (char *)&tmpStr[index]); + strcpy((char *)file_writer.saveFileName, (char *)&tmpStr[index]); ZERO(tempBuf); - sprintf_P(tempBuf, PSTR("Writing to file: %s\r\n"), file_writer.saveFileName); + sprintf_P((char *)tempBuf, PSTR("Writing to file: %s\r\n"), (char *)file_writer.saveFileName); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); + send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); wifi_link_state = WIFI_WAIT_TRANS_START; } else { @@ -882,7 +882,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { SEND_OK_TO_WIFI; - char *outBuf = tempBuf; + char *outBuf = (char *)tempBuf; char tbuf[34]; sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); @@ -917,7 +917,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcat_P(outBuf, PSTR(" @:0 B@:0\r\n")); } else { - sprintf_P(tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"), + sprintf_P((char *)tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"), thermalManager.degHotend(0), thermalManager.degTargetHotend(0), #if HAS_HEATED_BED thermalManager.degBed(), thermalManager.degTargetBed(), @@ -933,16 +933,16 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { ); } - send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); + send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); queue.enqueue_one_P(PSTR("M105")); break; case 992: if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { ZERO(tempBuf); - sprintf_P(tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10); + sprintf_P((char *)tempBuf, PSTR("M992 %d%d:%d%d:%d%d\r\n"), print_time.hours/10, print_time.hours%10, print_time.minutes/10, print_time.minutes%10, print_time.seconds/10, print_time.seconds%10); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); + send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); } break; @@ -950,9 +950,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if ((uiCfg.print_state == WORKING) || (uiCfg.print_state == PAUSED)) { ZERO(tempBuf); if (strlen((char *)list_file.file_name[sel_id]) > (100 - 1)) return; - sprintf_P(tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize); + sprintf_P((char *)tempBuf, PSTR("M994 %s;%d\n"), list_file.file_name[sel_id], (int)gCfgItems.curFilesize); wifi_ret_ack(); - send_to_wifi((uint8_t *)tempBuf, strlen(tempBuf)); + send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf)); } break; @@ -1279,7 +1279,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { ZERO(public_buf); - if (strlen(file_writer.saveFileName) > sizeof(saveFilePath)) + if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath)) return; ZERO(saveFilePath); @@ -1305,7 +1305,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { char dosName[FILENAME_LENGTH]; - if (!longName2DosName(file_writer.saveFileName, dosName)) { + if (!longName2DosName((const char *)file_writer.saveFileName, dosName)) { clear_cur_ui(); upload_result = 2; wifiTransError.flag = 1; @@ -1313,7 +1313,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); return; } - strcpy(saveFilePath, dosName); + strcpy((char *)saveFilePath, dosName); card.cdroot(); upload_file.close(); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h index 048996e919..0886641b2d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h @@ -178,18 +178,18 @@ extern CLOUD_PARA cloud_para; extern WIFI_GCODE_BUFFER espGcodeFifo; -extern uint32_t getWifiTick(); -extern uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick); +uint32_t getWifiTick(); +uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick); void mks_esp_wifi_init(); -extern int cfg_cloud_flag; -extern int send_to_wifi(uint8_t *buf, int len); +extern int cfg_cloud_flag; +int send_to_wifi(uint8_t *buf, int len); void wifi_looping(); -extern int raw_send_to_wifi(uint8_t *buf, int len); -extern int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len); +int raw_send_to_wifi(uint8_t *buf, int len); +int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len); void get_wifi_list_command_send(); void get_wifi_commands(); -extern int readWifiBuf(int8_t *buf, int32_t len); +int readWifiBuf(int8_t *buf, int32_t len); void mks_wifi_firmware_update(); #ifdef __cplusplus diff --git a/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h b/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h index 81f2ae3e19..dbbb7b4832 100644 --- a/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h +++ b/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h @@ -89,7 +89,7 @@ static const uint8_t A15 = PIN_A15; #define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \ (((p) >= 50) && ((p) <= 53)) || \ - (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) ) + (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : nullptr ) #define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \ ( (((p) >= 62) && ((p) <= 69)) ? 2 : \ @@ -97,7 +97,7 @@ static const uint8_t A15 = PIN_A15; #define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \ ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \ - ((uint8_t *)0) ) ) + nullptr ) ) #define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \ ( ((p) == 50) ? 3 : \ From a5f0075a600b6cc607e7e3b2d7c2571d39c91280 Mon Sep 17 00:00:00 2001 From: gmarsh Date: Tue, 13 Apr 2021 17:17:52 -0300 Subject: [PATCH 213/311] Fix and improve Power Monitor (#21551) --- Marlin/Configuration_adv.h | 13 +++++++---- Marlin/src/feature/power_monitor.cpp | 9 +++++--- Marlin/src/feature/power_monitor.h | 22 ++++++++----------- .../src/gcode/feature/power_monitor/M430.cpp | 6 ++--- Marlin/src/inc/Conditionals_adv.h | 9 +++----- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 8 +++---- Marlin/src/lcd/menu/menu_power_monitor.cpp | 2 +- Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h | 4 ++-- 8 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index fd598e59e4..95e93eb288 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3306,13 +3306,18 @@ */ //#define POWER_MONITOR_CURRENT // Monitor the system current //#define POWER_MONITOR_VOLTAGE // Monitor the system voltage -#if EITHER(POWER_MONITOR_CURRENT, POWER_MONITOR_VOLTAGE) - #define POWER_MONITOR_VOLTS_PER_AMP 0.05000 // Input voltage to the MCU analog pin per amp - DO NOT apply more than ADC_VREF! - #define POWER_MONITOR_CURRENT_OFFSET -1 // Offset value for current sensors with linear function output - #define POWER_MONITOR_VOLTS_PER_VOLT 0.11786 // Input voltage to the MCU analog pin per volt - DO NOT apply more than ADC_VREF! + +#if ENABLED(POWER_MONITOR_CURRENT) + #define POWER_MONITOR_VOLTS_PER_AMP 0.05000 // Input voltage to the MCU analog pin per amp - DO NOT apply more than ADC_VREF! + #define POWER_MONITOR_CURRENT_OFFSET 0 // Offset (in amps) applied to the calculated current #define POWER_MONITOR_FIXED_VOLTAGE 13.6 // Voltage for a current sensor with no voltage sensor (for power display) #endif +#if ENABLED(POWER_MONITOR_VOLTAGE) + #define POWER_MONITOR_VOLTS_PER_VOLT 0.077933 // Input voltage to the MCU analog pin per volt - DO NOT apply more than ADC_VREF! + #define POWER_MONITOR_VOLTAGE_OFFSET 0 // Offset (in volts) applied to the calculated voltage +#endif + /** * CNC Coordinate Systems * diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 97c4a93363..1937a54102 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -26,8 +26,11 @@ #include "power_monitor.h" -#include "../lcd/marlinui.h" -#include "../lcd/lcdprint.h" +#if HAS_LCD_MENU + #include "../lcd/marlinui.h" + #include "../lcd/lcdprint.h" +#endif + #include "../libs/numtostr.h" uint8_t PowerMonitor::flags; // = 0 @@ -54,7 +57,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor } #endif - #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) void PowerMonitor::draw_voltage() { const float volts = getVolts(); lcd_put_u8str(volts < 100 ? ftostr31ns(volts) : ui16tostr4rj((uint16_t)volts)); diff --git a/Marlin/src/feature/power_monitor.h b/Marlin/src/feature/power_monitor.h index f378ee2a10..f6e0b292e3 100644 --- a/Marlin/src/feature/power_monitor.h +++ b/Marlin/src/feature/power_monitor.h @@ -23,7 +23,7 @@ #include "../inc/MarlinConfig.h" -#define PM_SAMPLE_RANGE 1024 +#define PM_SAMPLE_RANGE HAL_ADC_RANGE #define PM_K_VALUE 6 #define PM_K_SCALE 6 @@ -35,7 +35,7 @@ struct pm_lpf_t { filter_buf = filter_buf - (filter_buf >> K_VALUE) + (uint32_t(sample) << K_SCALE); } void capture() { - value = filter_buf * (SCALE * (1.0f / (1UL << (PM_K_VALUE + PM_K_SCALE)))) + (POWER_MONITOR_CURRENT_OFFSET); + value = filter_buf * (SCALE * (1.0f / (1UL << (PM_K_VALUE + PM_K_SCALE)))); } void reset(uint16_t reset_value = 0) { filter_buf = uint32_t(reset_value) << (K_VALUE + K_SCALE); @@ -69,19 +69,15 @@ public: }; #if ENABLED(POWER_MONITOR_CURRENT) - FORCE_INLINE static float getAmps() { return amps.value; } + FORCE_INLINE static float getAmps() { return amps.value + (POWER_MONITOR_CURRENT_OFFSET); } void add_current_sample(const uint16_t value) { amps.add_sample(value); } #endif - #if HAS_POWER_MONITOR_VREF - #if ENABLED(POWER_MONITOR_VOLTAGE) - FORCE_INLINE static float getVolts() { return volts.value; } - #else - FORCE_INLINE static float getVolts() { return POWER_MONITOR_FIXED_VOLTAGE; } // using a specified fixed valtage as the voltage measurement - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - void add_voltage_sample(const uint16_t value) { volts.add_sample(value); } - #endif + #if ENABLED(POWER_MONITOR_VOLTAGE) + FORCE_INLINE static float getVolts() { return volts.value + (POWER_MONITOR_VOLTAGE_OFFSET); } + void add_voltage_sample(const uint16_t value) { volts.add_sample(value); } + #else + FORCE_INLINE static float getVolts() { return POWER_MONITOR_FIXED_VOLTAGE; } #endif #if HAS_POWER_MONITOR_WATTS @@ -98,7 +94,7 @@ public: FORCE_INLINE static void set_current_display(const bool b) { SET_BIT_TO(flags, PM_DISP_BIT_I, b); } FORCE_INLINE static void toggle_current_display() { TBI(flags, PM_DISP_BIT_I); } #endif - #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) static void draw_voltage(); FORCE_INLINE static bool voltage_display_enabled() { return TEST(flags, PM_DISP_BIT_V); } FORCE_INLINE static void set_voltage_display(const bool b) { SET_BIT_TO(flags, PM_DISP_BIT_V, b); } diff --git a/Marlin/src/gcode/feature/power_monitor/M430.cpp b/Marlin/src/gcode/feature/power_monitor/M430.cpp index 9559404456..34430fbc38 100644 --- a/Marlin/src/gcode/feature/power_monitor/M430.cpp +++ b/Marlin/src/gcode/feature/power_monitor/M430.cpp @@ -42,7 +42,7 @@ void GcodeSuite::M430() { #if ENABLED(POWER_MONITOR_CURRENT) if (parser.seen('I')) { power_monitor.set_current_display(parser.value_bool()); do_report = false; } #endif - #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) if (parser.seen('V')) { power_monitor.set_voltage_display(parser.value_bool()); do_report = false; } #endif #if HAS_POWER_MONITOR_WATTS @@ -53,11 +53,11 @@ void GcodeSuite::M430() { SERIAL_ECHOLNPAIR( #if ENABLED(POWER_MONITOR_CURRENT) "Current: ", power_monitor.getAmps(), "A" - #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) " " #endif #endif - #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) "Voltage: ", power_monitor.getVolts(), "V" #endif #if HAS_POWER_MONITOR_WATTS diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 2177dc4861..3bd77d7545 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -498,12 +498,9 @@ // Power Monitor sensors #if EITHER(POWER_MONITOR_CURRENT, POWER_MONITOR_VOLTAGE) #define HAS_POWER_MONITOR 1 -#endif -#if ENABLED(POWER_MONITOR_CURRENT) && defined(POWER_MONITOR_FIXED_VOLTAGE) - #define HAS_POWER_MONITOR_VREF 1 -#endif -#if BOTH(HAS_POWER_MONITOR_VREF, POWER_MONITOR_CURRENT) - #define HAS_POWER_MONITOR_WATTS 1 + #if ENABLED(POWER_MONITOR_CURRENT) && (ENABLED(POWER_MONITOR_VOLTAGE) || defined(POWER_MONITOR_FIXED_VOLTAGE)) + #define HAS_POWER_MONITOR_WATTS 1 + #endif #endif // Flag if an EEPROM type is pre-selected diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 7e638a645e..119de19d9d 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -136,7 +136,7 @@ #if ENABLED(POWER_MONITOR_CURRENT) const bool iflag = power_monitor.current_display_enabled(); #endif - #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) const bool vflag = power_monitor.voltage_display_enabled(); #endif @@ -148,7 +148,7 @@ } #elif ENABLED(POWER_MONITOR_CURRENT) power_monitor.display_item = 0; - #elif HAS_POWER_MONITOR_VREF + #elif ENABLED(POWER_MONITOR_VOLTAGE) power_monitor.display_item = 1; #endif @@ -157,7 +157,7 @@ #if ENABLED(POWER_MONITOR_CURRENT) if (power_monitor.display_item == 0 && !iflag) ++power_monitor.display_item; #endif - #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) if (power_monitor.display_item == 1 && !vflag) ++power_monitor.display_item; #endif #if HAS_POWER_MONITOR_WATTS @@ -170,7 +170,7 @@ #if ENABLED(POWER_MONITOR_CURRENT) // Current case 0: if (iflag) power_monitor.draw_current(); break; #endif - #if HAS_POWER_MONITOR_VREF // Voltage + #if ENABLED(POWER_MONITOR_VOLTAGE) // Voltage case 1: if (vflag) power_monitor.draw_voltage(); break; #endif #if HAS_POWER_MONITOR_WATTS // Power diff --git a/Marlin/src/lcd/menu/menu_power_monitor.cpp b/Marlin/src/lcd/menu/menu_power_monitor.cpp index d31ebd36b2..b43327f63b 100644 --- a/Marlin/src/lcd/menu/menu_power_monitor.cpp +++ b/Marlin/src/lcd/menu/menu_power_monitor.cpp @@ -42,7 +42,7 @@ void menu_power_monitor() { } #endif - #if HAS_POWER_MONITOR_VREF + #if ENABLED(POWER_MONITOR_VOLTAGE) { bool ena = power_monitor.voltage_display_enabled(); EDIT_ITEM(bool, MSG_VOLTAGE, &ena, power_monitor.toggle_voltage_display); diff --git a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h index 0df8b10292..cbf6ca2d3c 100644 --- a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h +++ b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h @@ -119,6 +119,7 @@ // Misc. Functions // #define LED_PIN P1_31 +#define POWER_MONITOR_VOLTAGE_PIN P0_25_A2 // // LCD @@ -156,9 +157,8 @@ #define SD_MISO_PIN P0_17 #define SD_MOSI_PIN P0_18 #define SD_SS_PIN P0_16 + #define SD_DETECT_PIN P1_22 #elif SD_CONNECTION_IS(ONBOARD) - #undef SD_DETECT_PIN - #define SD_DETECT_PIN P0_27 #define SD_SCK_PIN P0_07 #define SD_MISO_PIN P0_08 #define SD_MOSI_PIN P0_09 From 138340ee99a852bc116e2a436932bed074624fde Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Tue, 13 Apr 2021 19:34:19 -0300 Subject: [PATCH 214/311] Multi-Volume. Select Media for LVGL (#21344) --- Marlin/Configuration_adv.h | 9 + Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp | 18 +- Marlin/src/HAL/STM32/msc_sd.cpp | 38 ++-- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/inc/Conditionals_adv.h | 2 +- Marlin/src/inc/Conditionals_post.h | 9 + .../lcd/extui/lib/mks_ui/draw_keyboard.cpp | 4 +- .../extui/lib/mks_ui/draw_media_select.cpp | 73 +++++++ .../lcd/extui/lib/mks_ui/draw_media_select.h | 33 ++++ .../lcd/extui/lib/mks_ui/draw_print_file.cpp | 3 +- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 178 +++++++----------- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h | 4 +- .../src/lcd/extui/lib/mks_ui/pic_manager.cpp | 7 + .../lcd/extui/lib/mks_ui/tft_Language_en.h | 1 + .../extui/lib/mks_ui/tft_multi_language.cpp | 5 + .../lcd/extui/lib/mks_ui/tft_multi_language.h | 8 + .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 2 +- Marlin/src/sd/Sd2Card.cpp | 48 ++--- Marlin/src/sd/Sd2Card.h | 119 ++++++------ Marlin/src/sd/Sd2Card_sdio.h | 30 ++- Marlin/src/sd/SdFatConfig.h | 2 +- Marlin/src/sd/SdVolume.cpp | 6 +- Marlin/src/sd/SdVolume.h | 23 ++- Marlin/src/sd/cardreader.cpp | 27 ++- Marlin/src/sd/cardreader.h | 43 ++++- Marlin/src/sd/disk_io_driver.h | 67 +++++++ .../sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 18 +- .../sd/usb_flashdrive/Sd2Card_FlashDrive.h | 44 ++--- 29 files changed, 546 insertions(+), 279 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.cpp create mode 100644 Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.h create mode 100644 Marlin/src/sd/disk_io_driver.h diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 95e93eb288..fa1b470ab2 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1478,6 +1478,15 @@ // Enable if SD detect is rendered useless (e.g., by using an SD extender) //#define NO_SD_DETECT + // Multiple volume support - EXPERIMENTAL. + //#define MULTI_VOLUME + #if ENABLED(MULTI_VOLUME) + #define VOLUME_SD_ONBOARD + #define VOLUME_USB_FLASH_DRIVE + #define DEFAULT_VOLUME SD_ONBOARD + #define DEFAULT_SHARED_VOLUME USB_FLASH_DRIVE + #endif + #endif // SDSUPPORT /** diff --git a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp index d92d332c1e..3dcbbaecd2 100644 --- a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp +++ b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp @@ -32,7 +32,7 @@ Ctrl_status sd_mmc_spi_test_unit_ready() { Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) { if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted()) return CTRL_NO_PRESENT; - *nb_sector = card.getSd2Card().cardSize() - 1; + *nb_sector = card.diskIODriver()->cardSize() - 1; return CTRL_GOOD; } @@ -74,24 +74,24 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) { #endif // Start reading - if (!card.getSd2Card().readStart(addr)) + if (!card.diskIODriver()->readStart(addr)) return CTRL_FAIL; // For each specified sector while (nb_sector--) { // Read a sector - card.getSd2Card().readData(sector_buf); + card.diskIODriver()->readData(sector_buf); // RAM -> USB if (!udi_msc_trans_block(true, sector_buf, SD_MMC_BLOCK_SIZE, nullptr)) { - card.getSd2Card().readStop(); + card.diskIODriver()->readStop(); return CTRL_FAIL; } } // Stop reading - card.getSd2Card().readStop(); + card.diskIODriver()->readStop(); // Done return CTRL_GOOD; @@ -113,7 +113,7 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) { } #endif - if (!card.getSd2Card().writeStart(addr, nb_sector)) + if (!card.diskIODriver()->writeStart(addr, nb_sector)) return CTRL_FAIL; // For each specified sector @@ -121,16 +121,16 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) { // USB -> RAM if (!udi_msc_trans_block(false, sector_buf, SD_MMC_BLOCK_SIZE, nullptr)) { - card.getSd2Card().writeStop(); + card.diskIODriver()->writeStop(); return CTRL_FAIL; } // Write a sector - card.getSd2Card().writeData(sector_buf); + card.diskIODriver()->writeData(sector_buf); } // Stop writing - card.getSd2Card().writeStop(); + card.diskIODriver()->writeStop(); // Done return CTRL_GOOD; diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp index 63ce7808f1..20e1ab3cf9 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -30,54 +30,66 @@ class Sd2CardUSBMscHandler : public USBMscHandler { public: + DiskIODriver* diskIODriver() { + #if ENABLED(MULTI_VOLUME) + #if SHARED_VOLUME_IS(SD_ONBOARD) + return &card.media_sd_spi; + #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) + return &card.media_usbFlashDrive; + #endif + #else + return diskIODriver(); + #endif + } + bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize) { - *pBlockNum = card.getSd2Card().cardSize(); + *pBlockNum = diskIODriver()->cardSize(); *pBlockSize = BLOCK_SIZE; return true; } bool Write(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) { - auto sd2card = card.getSd2Card(); + auto sd2card = diskIODriver(); // single block if (blkLen == 1) { watchdog_refresh(); - sd2card.writeBlock(blkAddr, pBuf); + sd2card->writeBlock(blkAddr, pBuf); return true; } // multi block optmization - sd2card.writeStart(blkAddr, blkLen); + sd2card->writeStart(blkAddr, blkLen); while (blkLen--) { watchdog_refresh(); - sd2card.writeData(pBuf); + sd2card->writeData(pBuf); pBuf += BLOCK_SIZE; } - sd2card.writeStop(); + sd2card->writeStop(); return true; } bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) { - auto sd2card = card.getSd2Card(); + auto sd2card = diskIODriver(); // single block if (blkLen == 1) { watchdog_refresh(); - sd2card.readBlock(blkAddr, pBuf); + sd2card->readBlock(blkAddr, pBuf); return true; } // multi block optmization - sd2card.readStart(blkAddr); + sd2card->readStart(blkAddr); while (blkLen--) { watchdog_refresh(); - sd2card.readData(pBuf); + sd2card->readData(pBuf); pBuf += BLOCK_SIZE; } - sd2card.readStop(); + sd2card->readStop(); return true; } bool IsReady() { - return card.isMounted(); + return diskIODriver()->isReady(); } }; @@ -105,8 +117,8 @@ USBMscHandler *pSingleMscHandler = &usbMscHandler; void MSC_SD_init() { USBDevice.end(); delay(200); - USBDevice.begin(); USBDevice.registerMscHandlers(1, &pSingleMscHandler, Marlin_STORAGE_Inquirydata); + USBDevice.begin(); } #endif // __STM32F1__ && HAS_SD_HOST_DRIVE diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 738f9a8d78..842429a407 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -757,7 +757,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { TERN_(SDSUPPORT, card.manage_media()); // Handle USB Flash Drive insert / remove - TERN_(USB_FLASH_DRIVE_SUPPORT, Sd2Card::idle()); + TERN_(USB_FLASH_DRIVE_SUPPORT, card.diskIODriver()->idle()); // Announce Host Keepalive state (if any) TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive()); diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 3bd77d7545..735e6464d9 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -245,7 +245,7 @@ #define _CUTTER_POWER_PERCENT 2 #define _CUTTER_POWER_RPM 3 #define _CUTTER_POWER(V) _CAT(_CUTTER_POWER_, V) - #define CUTTER_UNIT_IS(V) (_CUTTER_POWER(CUTTER_POWER_UNIT) == _CUTTER_POWER(V)) + #define CUTTER_UNIT_IS(V) (_CUTTER_POWER(CUTTER_POWER_UNIT) == _CUTTER_POWER(V)) #endif // Add features that need hardware PWM here diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 337cf2a950..f00dd6ec97 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -356,6 +356,15 @@ #define SD_DETECT_STATE LOW #endif #endif + + #if DISABLED(USB_FLASH_DRIVE_SUPPORT) || BOTH(MULTI_VOLUME, VOLUME_SD_ONBOARD) + #if ENABLED(SDIO_SUPPORT) + #define NEED_SD2CARD_SDIO 1 + #else + #define NEED_SD2CARD_SPI 1 + #endif + #endif + #endif #if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT) || !PIN_EXISTS(SD_DETECT) 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 a05c558beb..3572991813 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp @@ -148,7 +148,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { public_buf_l[6] = 0x00; raw_send_to_wifi((uint8_t*)public_buf_l, 6); - last_disp_state = KEY_BOARD_UI; + last_disp_state = KEYBOARD_UI; lv_clear_keyboard(); wifi_tips_type = TIPS_TYPE_JOINING; lv_draw_wifi_tips(); @@ -216,7 +216,7 @@ static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) { } void lv_draw_keyboard() { - scr = lv_screen_create(KEY_BOARD_UI, ""); + scr = lv_screen_create(KEYBOARD_UI, ""); // Create styles for the keyboard static lv_style_t rel_style, pr_style; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.cpp new file mode 100644 index 0000000000..6dc816cc23 --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.cpp @@ -0,0 +1,73 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "../../../../inc/MarlinConfigPre.h" + +#if BOTH(HAS_TFT_LVGL_UI, MULTI_VOLUME) + +#include "draw_ui.h" +#include + +#include "../../../../inc/MarlinConfig.h" +#include "../../../../sd/cardreader.h" + +extern lv_group_t *g; +static lv_obj_t *scr; + +enum { + ID_T_USB_DISK = 1, + ID_T_SD_DISK, + ID_T_RETURN +}; + +#if ENABLED(MKS_TEST) + extern uint8_t curent_disp_ui; +#endif + +static void event_handler(lv_obj_t *obj, lv_event_t event) { + if (event != LV_EVENT_RELEASED) return; + lv_clear_media_select(); + switch (obj->mks_obj_id) { + case ID_T_USB_DISK: card.changeMedia(&card.media_usbFlashDrive); break; + case ID_T_SD_DISK: card.changeMedia(&card.media_sd_spi); break; + case ID_T_RETURN: + TERN_(MKS_TEST, curent_disp_ui = 1); + lv_draw_ready_print(); + return; + } + lv_draw_print_file(); +} + +void lv_draw_media_select() { + scr = lv_screen_create(MEDIA_SELECT_UI); + lv_big_button_create(scr, "F:/bmp_sd.bin", media_select_menu.sd_disk, INTERVAL_V, titleHeight, event_handler, ID_T_SD_DISK); + lv_big_button_create(scr, "F:/bmp_usb_disk.bin", media_select_menu.usb_disk, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_USB_DISK); + 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); +} + +void lv_clear_media_select() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.h new file mode 100644 index 0000000000..a698714a9d --- /dev/null +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_media_select.h @@ -0,0 +1,33 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#ifdef __cplusplus + extern "C" { /* C-declarations for C++ */ +#endif + +extern void lv_draw_media_select(); +extern void lv_clear_media_select(); + +#ifdef __cplusplus + } /* C-declarations for C++ */ +#endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp index d32851f761..17f5d95d2a 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp @@ -177,7 +177,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } else { lv_clear_print_file(); - lv_draw_ready_print(); + TERN(MULTI_VOLUME, lv_draw_media_select(), lv_draw_ready_print()); } } else { @@ -248,6 +248,7 @@ static char test_public_buf_l[40]; void disp_gcode_icon(uint8_t file_num) { uint8_t i; + // TODO: set current media title?! scr = lv_screen_create(PRINT_FILE_UI, ""); // Create image buttons diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index d02e774b94..09784b5184 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -73,7 +73,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_INFO_EXT: uiCfg.curTempType = 0; lv_draw_preHeat(); break; case ID_INFO_BED: uiCfg.curTempType = 1; lv_draw_preHeat(); break; case ID_INFO_FAN: lv_draw_fan(); break; - case ID_PRINT: lv_draw_print_file(); break; + case ID_PRINT: TERN(MULTI_VOLUME, lv_draw_media_select(), lv_draw_print_file()); break; } } 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 51e187435c..0a99df08e5 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -447,111 +447,63 @@ char *getDispText(int index) { ZERO(public_buf_l); switch (disp_state_stack._disp_state[index]) { - case PRINT_READY_UI: - strcpy(public_buf_l, main_menu.title); - break; - case PRINT_FILE_UI: - strcpy(public_buf_l, file_menu.title); - break; + case PRINT_READY_UI: strcpy(public_buf_l, main_menu.title); break; + case PRINT_FILE_UI: strcpy(public_buf_l, file_menu.title); break; case PRINTING_UI: - if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI - #ifndef TFT35 - || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI - || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI - #endif - ) strcpy(public_buf_l, common_menu.print_special_title); - else strcpy(public_buf_l, printing_menu.title); - break; - case MOVE_MOTOR_UI: - strcpy(public_buf_l, move_menu.title); + switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { + IF_DISABLED(TFT35, case OPERATE_UI: case PAUSE_UI:) + case PRINTING_UI: strcpy(public_buf_l, common_menu.print_special_title); break; + default: strcpy(public_buf_l, printing_menu.title); break; + } break; + case MOVE_MOTOR_UI: strcpy(public_buf_l, move_menu.title); break; case OPERATE_UI: - if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI - #ifndef TFT35 - || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI - || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI - #endif - ) strcpy(public_buf_l, common_menu.operate_special_title); - else strcpy(public_buf_l, operation_menu.title); + switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { + IF_DISABLED(TFT35, case OPERATE_UI: case PAUSE_UI:) + case PRINTING_UI: strcpy(public_buf_l, common_menu.operate_special_title); break; + default: strcpy(public_buf_l, operation_menu.title); break; + } break; case PAUSE_UI: - if (disp_state_stack._disp_state[disp_state_stack._disp_index] == PRINTING_UI - || disp_state_stack._disp_state[disp_state_stack._disp_index] == OPERATE_UI - || disp_state_stack._disp_state[disp_state_stack._disp_index] == PAUSE_UI - ) strcpy(public_buf_l, common_menu.pause_special_title); - else strcpy(public_buf_l, pause_menu.title); - break; - - case EXTRUSION_UI: - strcpy(public_buf_l, extrude_menu.title); - break; - case CHANGE_SPEED_UI: - strcpy(public_buf_l, speed_menu.title); - break; - case FAN_UI: - strcpy(public_buf_l, fan_menu.title); + switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { + case OPERATE_UI: + case PAUSE_UI: + case PRINTING_UI: strcpy(public_buf_l, common_menu.pause_special_title); break; + default: strcpy(public_buf_l, pause_menu.title); break; + } break; + case EXTRUSION_UI: strcpy(public_buf_l, extrude_menu.title); break; + case CHANGE_SPEED_UI: strcpy(public_buf_l, speed_menu.title); break; + case FAN_UI: strcpy(public_buf_l, fan_menu.title); break; case PRE_HEAT_UI: - if ((disp_state_stack._disp_state[disp_state_stack._disp_index - 1] == OPERATE_UI)) - strcpy(public_buf_l, preheat_menu.adjust_title); - else strcpy(public_buf_l, preheat_menu.title); - break; - case SET_UI: - strcpy(public_buf_l, set_menu.title); - break; - case ZERO_UI: - strcpy(public_buf_l, home_menu.title); - break; - case SPRAYER_UI: break; - case MACHINE_UI: break; - case LANGUAGE_UI: - strcpy(public_buf_l, language_menu.title); - break; - case ABOUT_UI: - strcpy(public_buf_l, about_menu.title); - break; - case LOG_UI: break; - case DISK_UI: - strcpy(public_buf_l, filesys_menu.title); - break; - case DIALOG_UI: - strcpy(public_buf_l, common_menu.dialog_confirm_title); - break; - case WIFI_UI: - strcpy(public_buf_l, wifi_menu.title); + switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { + case OPERATE_UI: strcpy(public_buf_l, preheat_menu.adjust_title); + default: strcpy(public_buf_l, preheat_menu.title); break; + } break; + case SET_UI: strcpy(public_buf_l, set_menu.title); break; + case ZERO_UI: strcpy(public_buf_l, home_menu.title); break; + case SPRAYER_UI: break; + case MACHINE_UI: break; + case LANGUAGE_UI: strcpy(public_buf_l, language_menu.title); break; + case ABOUT_UI: strcpy(public_buf_l, about_menu.title); break; + case LOG_UI: break; + case DISK_UI: strcpy(public_buf_l, filesys_menu.title); break; + case DIALOG_UI: strcpy(public_buf_l, common_menu.dialog_confirm_title); break; + case WIFI_UI: strcpy(public_buf_l, wifi_menu.title); break; case MORE_UI: - case PRINT_MORE_UI: - strcpy(public_buf_l, more_menu.title); - break; - case FILAMENTCHANGE_UI: - strcpy(public_buf_l, filament_menu.title); - break; + case PRINT_MORE_UI: strcpy(public_buf_l, more_menu.title); break; + case FILAMENTCHANGE_UI: strcpy(public_buf_l, filament_menu.title); break; case LEVELING_UI: - case MESHLEVELING_UI: - strcpy(public_buf_l, leveling_menu.title); - break; - case BIND_UI: - strcpy(public_buf_l, cloud_menu.title); - break; - case TOOL_UI: - strcpy(public_buf_l, tool_menu.title); - break; - case WIFI_LIST_UI: - #if ENABLED(MKS_WIFI_MODULE) - strcpy(public_buf_l, list_menu.title); - break; - #endif - case MACHINE_PARA_UI: - strcpy(public_buf_l, MachinePara_menu.title); - break; - case BABY_STEP_UI: - strcpy(public_buf_l, operation_menu.babystep); - break; - case EEPROM_SETTINGS_UI: - strcpy(public_buf_l, eeprom_menu.title); - break; + case MESHLEVELING_UI: strcpy(public_buf_l, leveling_menu.title); break; + case BIND_UI: strcpy(public_buf_l, cloud_menu.title); break; + case TOOL_UI: strcpy(public_buf_l, tool_menu.title); break; + case WIFI_LIST_UI: TERN_(MKS_WIFI_MODULE, strcpy(public_buf_l, list_menu.title)); break; + case MACHINE_PARA_UI: strcpy(public_buf_l, MachinePara_menu.title); break; + case BABY_STEP_UI: strcpy(public_buf_l, operation_menu.babystep); break; + case EEPROM_SETTINGS_UI: strcpy(public_buf_l, eeprom_menu.title); break; + case MEDIA_SELECT_UI: strcpy(public_buf_l, media_select_menu.title); break; default: break; } @@ -828,11 +780,9 @@ void GUI_RefreshPage() { } break; - case OPERATE_UI: - break; + case OPERATE_UI: break; - case PAUSE_UI: - break; + case PAUSE_UI: break; case FAN_UI: if (temps_update_flag) { @@ -841,8 +791,7 @@ void GUI_RefreshPage() { } break; - case MOVE_MOTOR_UI: - break; + case MOVE_MOTOR_UI: break; #if ENABLED(MKS_WIFI_MODULE) case WIFI_UI: @@ -852,10 +801,9 @@ void GUI_RefreshPage() { } break; - case BIND_UI: - refresh_bind_ui(); - break; + case BIND_UI: refresh_bind_ui(); break; #endif + case FILAMENTCHANGE_UI: if (temps_update_flag) { temps_update_flag = false; @@ -866,10 +814,8 @@ void GUI_RefreshPage() { filament_dialog_handle(); TERN_(MKS_WIFI_MODULE, wifi_scan_handle()); break; - case MESHLEVELING_UI: - break; - case HARDWARE_TEST_UI: - break; + case MESHLEVELING_UI: break; + case HARDWARE_TEST_UI: break; case WIFI_LIST_UI: #if ENABLED(MKS_WIFI_MODULE) if (printing_rate_update_flag) { @@ -878,8 +824,8 @@ void GUI_RefreshPage() { } #endif break; - case KEY_BOARD_UI: - break; + case KEYBOARD_UI: break; + #if ENABLED(MKS_WIFI_MODULE) case WIFI_TIPS_UI: switch (wifi_tips_type) { @@ -932,6 +878,7 @@ void GUI_RefreshPage() { disp_z_offset_value(); } break; + default: break; } @@ -982,7 +929,7 @@ void clear_cur_ui() { #if ENABLED(MKS_WIFI_MODULE) case WIFI_LIST_UI: lv_clear_wifi_list(); break; #endif - case KEY_BOARD_UI: lv_clear_keyboard(); break; + case KEYBOARD_UI: lv_clear_keyboard(); break; #if ENABLED(MKS_WIFI_MODULE) case WIFI_TIPS_UI: lv_clear_wifi_tips(); break; #endif @@ -1013,9 +960,9 @@ void clear_cur_ui() { case NUMBER_KEY_UI: lv_clear_number_key(); break; case BABY_STEP_UI: lv_clear_baby_stepping(); break; case PAUSE_POS_UI: lv_clear_pause_position(); break; - #if HAS_TRINAMIC_CONFIG - case TMC_CURRENT_UI: lv_clear_tmc_current_settings(); break; - #endif + #if HAS_TRINAMIC_CONFIG + case TMC_CURRENT_UI: lv_clear_tmc_current_settings(); break; + #endif case EEPROM_SETTINGS_UI: lv_clear_eeprom_settings(); break; #if HAS_STEALTHCHOP case TMC_MODE_UI: lv_clear_tmc_step_mode_settings(); break; @@ -1032,6 +979,9 @@ void clear_cur_ui() { #if ENABLED(TOUCH_SCREEN_CALIBRATION) case TOUCH_CALIBRATION_UI: lv_clear_touch_calibration_screen(); break; #endif + #if ENABLED(MULTI_VOLUME) + case MEDIA_SELECT_UI: lv_clear_media_select(); break; + #endif default: break; } } @@ -1087,7 +1037,7 @@ void draw_return_ui() { #if ENABLED(MKS_WIFI_MODULE) case WIFI_LIST_UI: lv_draw_wifi_list(); break; #endif - case KEY_BOARD_UI: lv_draw_keyboard(); break; + case KEYBOARD_UI: lv_draw_keyboard(); break; #if ENABLED(MKS_WIFI_MODULE) case WIFI_TIPS_UI: lv_draw_wifi_tips(); break; #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h index 6577d80cdf..2809e4e937 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h @@ -76,6 +76,7 @@ #include "draw_homing_sensitivity_settings.h" #include "draw_baby_stepping.h" #include "draw_keyboard.h" +#include "draw_media_select.h" #include "draw_encoder_settings.h" #include "../../../../inc/MarlinConfigPre.h" @@ -289,7 +290,7 @@ typedef enum { TOOL_UI, HARDWARE_TEST_UI, WIFI_LIST_UI, - KEY_BOARD_UI, + KEYBOARD_UI, WIFI_TIPS_UI, MACHINE_PARA_UI, MACHINE_SETTINGS_UI, @@ -327,6 +328,7 @@ typedef enum { ENCODER_SETTINGS_UI, TOUCH_CALIBRATION_UI, GCODE_UI, + MEDIA_SELECT_UI, } DISP_STATE; typedef struct { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp index 36f276c21b..9318b50d2b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp @@ -197,6 +197,13 @@ static const char assets[][LONG_FILENAME_LENGTH] = { "bmp_cloud.bin", #endif + #if ENABLED(MULTI_VOLUME) + "bmp_usb_disk.bin", + // "bmp_usb_disk_sel.bin", + "bmp_sd.bin", + // "bmp_sd_sel.bin", + #endif + // Babystep screen "bmp_baby_move0_01.bin", "bmp_baby_move0_05.bin", 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 104e1fdcaf..b6eef18368 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 @@ -540,6 +540,7 @@ #define USB_DRIVE_BACK_EN "< Back" #define FILE_PAGES_EN "%d/%d" #define FILE_NEXT_PAGE_EN "Next Page" +#define MEDIA_SELECT_TITLE_EN "Select Media" //BUILD PLATE #define PLATE_TITLE_EN "Build Plate" 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 20b7d5f606..5e37acb2b4 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 @@ -56,6 +56,7 @@ tool_menu_def tool_menu; MachinePara_menu_def MachinePara_menu; pause_msg_def pause_msg_menu; eeprom_def eeprom_menu; +media_select_menu_def media_select_menu; machine_common_def machine_menu; void machine_setting_disp() { @@ -821,6 +822,10 @@ void disp_language_init() { filament_menu.stat_temp = TEXT_VALUE; + media_select_menu.title = MEDIA_SELECT_TITLE_EN; + media_select_menu.sd_disk = SD_CARD_TITLE_EN; + media_select_menu.usb_disk = USB_DRIVE_TITLE_EN; + machine_menu.key_0 = KEYBOARD_KEY0_EN; machine_menu.key_1 = KEYBOARD_KEY1_EN; machine_menu.key_2 = KEYBOARD_KEY2_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 61e3524c58..79faad74e2 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 @@ -706,6 +706,14 @@ typedef struct tool_menu_disp { extern tool_menu_def tool_menu; +typedef struct media_select_menu_disp { + const char *title; + const char *sd_disk; + const char *usb_disk; +} media_select_menu_def; + +extern media_select_menu_def media_select_menu; + typedef struct MachinePara_menu_disp { const char *title; const char *MachineSetting; 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 6c2afeafd3..1162f7a228 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -1142,7 +1142,7 @@ static void wifi_list_msg_handle(uint8_t * msg, uint16_t msgLen) { int8_t valid_name_num; if (msgLen <= 0) return; - if (disp_state == KEY_BOARD_UI) return; + if (disp_state == KEYBOARD_UI) return; wifi_list.getNameNum = msg[0]; diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index 28049c7e7e..3e714fe9fe 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -30,7 +30,7 @@ #include "../inc/MarlinConfig.h" -#if ENABLED(SDSUPPORT) && NONE(USB_FLASH_DRIVE_SUPPORT, SDIO_SUPPORT) +#if NEED_SD2CARD_SPI /* Enable FAST CRC computations - You can trade speed for FLASH space if * needed by disabling the following define */ @@ -88,7 +88,7 @@ #endif // Send command and return error code. Return zero for OK -uint8_t Sd2Card::cardCommand(const uint8_t cmd, const uint32_t arg) { +uint8_t DiskIODriver_SPI_SD::cardCommand(const uint8_t cmd, const uint32_t arg) { // Select card chipSelect(); @@ -133,7 +133,7 @@ uint8_t Sd2Card::cardCommand(const uint8_t cmd, const uint32_t arg) { * \return The number of 512 byte data blocks in the card * or zero if an error occurs. */ -uint32_t Sd2Card::cardSize() { +uint32_t DiskIODriver_SPI_SD::cardSize() { csd_t csd; if (!readCSD(&csd)) return 0; if (csd.v1.csd_ver == 0) { @@ -155,12 +155,12 @@ uint32_t Sd2Card::cardSize() { } } -void Sd2Card::chipDeselect() { +void DiskIODriver_SPI_SD::chipDeselect() { extDigitalWrite(chipSelectPin_, HIGH); spiSend(0xFF); // Ensure MISO goes high impedance } -void Sd2Card::chipSelect() { +void DiskIODriver_SPI_SD::chipSelect() { spiInit(spiRate_); extDigitalWrite(chipSelectPin_, LOW); } @@ -178,7 +178,7 @@ void Sd2Card::chipSelect() { * * \return true for success, false for failure. */ -bool Sd2Card::erase(uint32_t firstBlock, uint32_t lastBlock) { +bool DiskIODriver_SPI_SD::erase(uint32_t firstBlock, uint32_t lastBlock) { if (ENABLED(SDCARD_READONLY)) return false; csd_t csd; @@ -216,7 +216,7 @@ bool Sd2Card::erase(uint32_t firstBlock, uint32_t lastBlock) { * \return true if single block erase is supported. * false if single block erase is not supported. */ -bool Sd2Card::eraseSingleBlockEnable() { +bool DiskIODriver_SPI_SD::eraseSingleBlockEnable() { csd_t csd; return readCSD(&csd) ? csd.v1.erase_blk_en : false; } @@ -230,7 +230,7 @@ bool Sd2Card::eraseSingleBlockEnable() { * \return true for success, false for failure. * The reason for failure can be determined by calling errorCode() and errorData(). */ -bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) { +bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPin) { #if IS_TEENSY_35_36 || IS_TEENSY_40_41 chipSelectPin_ = BUILTIN_SDCARD; const uint8_t ret = SDHC_CardInit(); @@ -324,10 +324,12 @@ bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) { } chipDeselect(); + ready = true; return setSckRate(sckRateID); FAIL: chipDeselect(); + ready = false; return false; } @@ -338,7 +340,7 @@ bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) { * \param[out] dst Pointer to the location that will receive the data. * \return true for success, false for failure. */ -bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t *dst) { +bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t *dst) { #if IS_TEENSY_35_36 || IS_TEENSY_40_41 return 0 == SDHC_CardReadBlock(dst, blockNumber); #endif @@ -378,7 +380,7 @@ bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t *dst) { * * \return true for success, false for failure. */ -bool Sd2Card::readData(uint8_t *dst) { +bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { chipSelect(); return readData(dst, 512); } @@ -445,7 +447,7 @@ bool Sd2Card::readData(uint8_t *dst) { #endif #endif // SD_CHECK_AND_RETRY -bool Sd2Card::readData(uint8_t *dst, const uint16_t count) { +bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) { bool success = false; const millis_t read_timeout = millis() + SD_READ_TIMEOUT; @@ -477,7 +479,7 @@ bool Sd2Card::readData(uint8_t *dst, const uint16_t count) { } /** read CID or CSR register */ -bool Sd2Card::readRegister(const uint8_t cmd, void *buf) { +bool DiskIODriver_SPI_SD::readRegister(const uint8_t cmd, void *buf) { uint8_t *dst = reinterpret_cast(buf); if (cardCommand(cmd, 0)) { error(SD_CARD_ERROR_READ_REG); @@ -497,7 +499,7 @@ bool Sd2Card::readRegister(const uint8_t cmd, void *buf) { * * \return true for success, false for failure. */ -bool Sd2Card::readStart(uint32_t blockNumber) { +bool DiskIODriver_SPI_SD::readStart(uint32_t blockNumber) { if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; const bool success = !cardCommand(CMD18, blockNumber); @@ -511,7 +513,7 @@ bool Sd2Card::readStart(uint32_t blockNumber) { * * \return true for success, false for failure. */ -bool Sd2Card::readStop() { +bool DiskIODriver_SPI_SD::readStop() { chipSelect(); const bool success = !cardCommand(CMD12, 0); if (!success) error(SD_CARD_ERROR_CMD12); @@ -531,7 +533,7 @@ bool Sd2Card::readStop() { * \return The value one, true, is returned for success and the value zero, * false, is returned for an invalid value of \a sckRateID. */ -bool Sd2Card::setSckRate(const uint8_t sckRateID) { +bool DiskIODriver_SPI_SD::setSckRate(const uint8_t sckRateID) { const bool success = (sckRateID <= 6); if (success) spiRate_ = sckRateID; else error(SD_CARD_ERROR_SCK_RATE); return success; @@ -542,12 +544,14 @@ bool Sd2Card::setSckRate(const uint8_t sckRateID) { * \param[in] timeout_ms Timeout to abort. * \return true for success, false for timeout. */ -bool Sd2Card::waitNotBusy(const millis_t timeout_ms) { +bool DiskIODriver_SPI_SD::waitNotBusy(const millis_t timeout_ms) { const millis_t wait_timeout = millis() + timeout_ms; while (spiRec() != 0xFF) if (ELAPSED(millis(), wait_timeout)) return false; return true; } +void DiskIODriver_SPI_SD::error(const uint8_t code) { errorCode_ = code; } + /** * Write a 512 byte block to an SD card. * @@ -555,7 +559,7 @@ bool Sd2Card::waitNotBusy(const millis_t timeout_ms) { * \param[in] src Pointer to the location of the data to be written. * \return true for success, false for failure. */ -bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) { if (ENABLED(SDCARD_READONLY)) return false; #if IS_TEENSY_35_36 || IS_TEENSY_40_41 @@ -586,7 +590,7 @@ bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t *src) { * \param[in] src Pointer to the location of the data to be written. * \return true for success, false for failure. */ -bool Sd2Card::writeData(const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) { if (ENABLED(SDCARD_READONLY)) return false; bool success = true; @@ -601,7 +605,7 @@ bool Sd2Card::writeData(const uint8_t *src) { } // Send one block of data for write block or write multiple blocks -bool Sd2Card::writeData(const uint8_t token, const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeData(const uint8_t token, const uint8_t *src) { if (ENABLED(SDCARD_READONLY)) return false; const uint16_t crc = TERN(SD_CHECK_AND_RETRY, CRC_CCITT(src, 512), 0xFFFF); @@ -629,7 +633,7 @@ bool Sd2Card::writeData(const uint8_t token, const uint8_t *src) { * * \return true for success, false for failure. */ -bool Sd2Card::writeStart(uint32_t blockNumber, const uint32_t eraseCount) { +bool DiskIODriver_SPI_SD::writeStart(uint32_t blockNumber, const uint32_t eraseCount) { if (ENABLED(SDCARD_READONLY)) return false; bool success = false; @@ -650,7 +654,7 @@ bool Sd2Card::writeStart(uint32_t blockNumber, const uint32_t eraseCount) { * * \return true for success, false for failure. */ -bool Sd2Card::writeStop() { +bool DiskIODriver_SPI_SD::writeStop() { if (ENABLED(SDCARD_READONLY)) return false; bool success = false; @@ -666,4 +670,4 @@ bool Sd2Card::writeStop() { return success; } -#endif // SDSUPPORT +#endif // NEED_SD2CARD_SPI diff --git a/Marlin/src/sd/Sd2Card.h b/Marlin/src/sd/Sd2Card.h index eb7f9bb2ca..e0dce02a02 100644 --- a/Marlin/src/sd/Sd2Card.h +++ b/Marlin/src/sd/Sd2Card.h @@ -35,47 +35,50 @@ #include "SdFatConfig.h" #include "SdInfo.h" +#include "disk_io_driver.h" #include -uint16_t const SD_INIT_TIMEOUT = 2000, // init timeout ms - SD_ERASE_TIMEOUT = 10000, // erase timeout ms - SD_READ_TIMEOUT = 300, // read timeout ms - SD_WRITE_TIMEOUT = 600; // write time out ms +uint16_t const SD_INIT_TIMEOUT = 2000, // (ms) Init timeout + SD_ERASE_TIMEOUT = 10000, // (ms) Erase timeout + SD_READ_TIMEOUT = 300, // (ms) Read timeout + SD_WRITE_TIMEOUT = 600; // (ms) Write timeout // SD card errors -uint8_t const SD_CARD_ERROR_CMD0 = 0x01, // timeout error for command CMD0 (initialize card in SPI mode) - SD_CARD_ERROR_CMD8 = 0x02, // CMD8 was not accepted - not a valid SD card - SD_CARD_ERROR_CMD12 = 0x03, // card returned an error response for CMD12 (write stop) - SD_CARD_ERROR_CMD17 = 0x04, // card returned an error response for CMD17 (read block) - SD_CARD_ERROR_CMD18 = 0x05, // card returned an error response for CMD18 (read multiple block) - SD_CARD_ERROR_CMD24 = 0x06, // card returned an error response for CMD24 (write block) - SD_CARD_ERROR_CMD25 = 0x07, // WRITE_MULTIPLE_BLOCKS command failed - SD_CARD_ERROR_CMD58 = 0x08, // card returned an error response for CMD58 (read OCR) - SD_CARD_ERROR_ACMD23 = 0x09, // SET_WR_BLK_ERASE_COUNT failed - SD_CARD_ERROR_ACMD41 = 0x0A, // ACMD41 initialization process timeout - SD_CARD_ERROR_BAD_CSD = 0x0B, // card returned a bad CSR version field - SD_CARD_ERROR_ERASE = 0x0C, // erase block group command failed - SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0x0D, // card not capable of single block erase - SD_CARD_ERROR_ERASE_TIMEOUT = 0x0E, // Erase sequence timed out - SD_CARD_ERROR_READ = 0x0F, // card returned an error token instead of read data - SD_CARD_ERROR_READ_REG = 0x10, // read CID or CSD failed - SD_CARD_ERROR_READ_TIMEOUT = 0x11, // timeout while waiting for start of read data - SD_CARD_ERROR_STOP_TRAN = 0x12, // card did not accept STOP_TRAN_TOKEN - SD_CARD_ERROR_WRITE = 0x13, // card returned an error token as a response to a write operation - SD_CARD_ERROR_WRITE_BLOCK_ZERO = 0x14, // REMOVE - not used ... attempt to write protected block zero - SD_CARD_ERROR_WRITE_MULTIPLE = 0x15, // card did not go ready for a multiple block write - SD_CARD_ERROR_WRITE_PROGRAMMING = 0x16, // card returned an error to a CMD13 status check after a write - SD_CARD_ERROR_WRITE_TIMEOUT = 0x17, // timeout occurred during write programming - SD_CARD_ERROR_SCK_RATE = 0x18, // incorrect rate selected - SD_CARD_ERROR_INIT_NOT_CALLED = 0x19, // init() not called - // 0x1A is unused now, it was: card returned an error for CMD59 (CRC_ON_OFF) - SD_CARD_ERROR_READ_CRC = 0x1B; // invalid read CRC +typedef enum : uint8_t { + SD_CARD_ERROR_CMD0 = 0x01, // Timeout error for command CMD0 (initialize card in SPI mode) + SD_CARD_ERROR_CMD8 = 0x02, // CMD8 was not accepted - not a valid SD card + SD_CARD_ERROR_CMD12 = 0x03, // Card returned an error response for CMD12 (write stop) + SD_CARD_ERROR_CMD17 = 0x04, // Card returned an error response for CMD17 (read block) + SD_CARD_ERROR_CMD18 = 0x05, // Card returned an error response for CMD18 (read multiple block) + SD_CARD_ERROR_CMD24 = 0x06, // Card returned an error response for CMD24 (write block) + SD_CARD_ERROR_CMD25 = 0x07, // WRITE_MULTIPLE_BLOCKS command failed + SD_CARD_ERROR_CMD58 = 0x08, // Card returned an error response for CMD58 (read OCR) + SD_CARD_ERROR_ACMD23 = 0x09, // SET_WR_BLK_ERASE_COUNT failed + SD_CARD_ERROR_ACMD41 = 0x0A, // ACMD41 initialization process timeout + SD_CARD_ERROR_BAD_CSD = 0x0B, // Card returned a bad CSR version field + SD_CARD_ERROR_ERASE = 0x0C, // Erase block group command failed + SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0x0D, // Card not capable of single block erase + SD_CARD_ERROR_ERASE_TIMEOUT = 0x0E, // Erase sequence timed out + SD_CARD_ERROR_READ = 0x0F, // Card returned an error token instead of read data + SD_CARD_ERROR_READ_REG = 0x10, // Read CID or CSD failed + SD_CARD_ERROR_READ_TIMEOUT = 0x11, // Timeout while waiting for start of read data + SD_CARD_ERROR_STOP_TRAN = 0x12, // Card did not accept STOP_TRAN_TOKEN + SD_CARD_ERROR_WRITE = 0x13, // Card returned an error token as a response to a write operation + SD_CARD_ERROR_WRITE_BLOCK_ZERO = 0x14, // REMOVE - not used ... attempt to write protected block zero + SD_CARD_ERROR_WRITE_MULTIPLE = 0x15, // Card did not go ready for a multiple block write + SD_CARD_ERROR_WRITE_PROGRAMMING = 0x16, // Card returned an error to a CMD13 status check after a write + SD_CARD_ERROR_WRITE_TIMEOUT = 0x17, // Timeout occurred during write programming + SD_CARD_ERROR_SCK_RATE = 0x18, // Incorrect rate selected + SD_CARD_ERROR_INIT_NOT_CALLED = 0x19, // Init() not called + // 0x1A is unused now, it was: card returned an error for CMD59 (CRC_ON_OFF) + SD_CARD_ERROR_READ_CRC = 0x1B // Invalid read CRC +} sd_error_code_t; // card types -uint8_t const SD_CARD_TYPE_SD1 = 1, // Standard capacity V1 SD card - SD_CARD_TYPE_SD2 = 2, // Standard capacity V2 SD card - SD_CARD_TYPE_SDHC = 3; // High Capacity SD card +uint8_t const SD_CARD_TYPE_SD1 = 1, // Standard capacity V1 SD card + SD_CARD_TYPE_SD2 = 2, // Standard capacity V2 SD card + SD_CARD_TYPE_SDHC = 3; // High Capacity SD card /** * Define SOFTWARE_SPI to use bit-bang SPI @@ -93,12 +96,11 @@ uint8_t const SD_CARD_TYPE_SD1 = 1, // Standard capacity V1 * \class Sd2Card * \brief Raw access to SD and SDHC flash memory cards. */ -class Sd2Card { +class DiskIODriver_SPI_SD : public DiskIODriver { public: - Sd2Card() : errorCode_(SD_CARD_ERROR_INIT_NOT_CALLED), type_(0) {} + DiskIODriver_SPI_SD() : errorCode_(SD_CARD_ERROR_INIT_NOT_CALLED), type_(0) {} - uint32_t cardSize(); bool erase(uint32_t firstBlock, uint32_t lastBlock); bool eraseSingleBlockEnable(); @@ -106,7 +108,7 @@ public: * Set SD error code. * \param[in] code value for error code. */ - inline void error(const uint8_t code) { errorCode_ = code; } + void error(const uint8_t code); /** * \return error code for last error. See Sd2Card.h for a list of error codes. @@ -122,9 +124,15 @@ public: * * \return true for success or false for failure. */ - bool init(const uint8_t sckRateID, const pin_t chipSelectPin); + bool init(const uint8_t sckRateID, const pin_t chipSelectPin) override; - bool readBlock(uint32_t block, uint8_t *dst); + bool setSckRate(const uint8_t sckRateID); + + /** + * Return the card type: SD V1, SD V2 or SDHC + * \return 0 - SD V1, 1 - SD V2, or 3 - SDHC. + */ + int type() const { return type_; } /** * Read a card's CID register. The CID contains card identification @@ -145,24 +153,27 @@ public: * * \return true for success or false for failure. */ - inline bool readCSD(csd_t *csd) { return readRegister(CMD9, csd); } + inline bool readCSD(csd_t *csd) override { return readRegister(CMD9, csd); } - bool readData(uint8_t *dst); - bool readStart(uint32_t blockNumber); - bool readStop(); - bool setSckRate(const uint8_t sckRateID); + bool readData(uint8_t *dst) override; + bool readStart(uint32_t blockNumber) override; + bool readStop() override; - /** - * Return the card type: SD V1, SD V2 or SDHC - * \return 0 - SD V1, 1 - SD V2, or 3 - SDHC. - */ - int type() const {return type_;} - bool writeBlock(uint32_t blockNumber, const uint8_t *src); - bool writeData(const uint8_t *src); - bool writeStart(uint32_t blockNumber, const uint32_t eraseCount); - bool writeStop(); + bool writeData(const uint8_t *src) override; + bool writeStart(const uint32_t blockNumber, const uint32_t eraseCount) override; + bool writeStop() override; + + bool readBlock(uint32_t block, uint8_t *dst) override; + bool writeBlock(uint32_t blockNumber, const uint8_t *src) override; + + uint32_t cardSize() override; + + bool isReady() override { return ready; }; + + void idle() override {} private: + bool ready = false; uint8_t chipSelectPin_, errorCode_, spiRate_, diff --git a/Marlin/src/sd/Sd2Card_sdio.h b/Marlin/src/sd/Sd2Card_sdio.h index 10fb757359..1580344805 100644 --- a/Marlin/src/sd/Sd2Card_sdio.h +++ b/Marlin/src/sd/Sd2Card_sdio.h @@ -23,17 +23,33 @@ #include "../inc/MarlinConfig.h" -#if ENABLED(SDIO_SUPPORT) +#include "SdInfo.h" +#include "disk_io_driver.h" bool SDIO_Init(); bool SDIO_ReadBlock(uint32_t block, uint8_t *dst); bool SDIO_WriteBlock(uint32_t block, const uint8_t *src); -class Sd2Card { +class DiskIODriver_SDIO : public DiskIODriver { public: - bool init(uint8_t sckRateID = 0, uint8_t chipSelectPin = 0) { return SDIO_Init(); } - bool readBlock(uint32_t block, uint8_t *dst) { return SDIO_ReadBlock(block, dst); } - bool writeBlock(uint32_t block, const uint8_t *src) { return SDIO_WriteBlock(block, src); } -}; + bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=0) override { return SDIO_Init(); } -#endif // SDIO_SUPPORT + bool readCSD(csd_t *csd) override { return false; } + + bool readStart(const uint32_t block) override { return false; } + bool readData(uint8_t *dst) override { return false; } + bool readStop() override { return false; } + + bool writeStart(const uint32_t block, const uint32_t) override { return false; } + bool writeData(const uint8_t *src) override { return false; } + bool writeStop() override { return false; } + + bool readBlock(uint32_t block, uint8_t *dst) override { return SDIO_ReadBlock(block, dst); } + bool writeBlock(uint32_t block, const uint8_t *src) override { return SDIO_WriteBlock(block, src); } + + uint32_t cardSize() override { return 0; } + + bool isReady() override { return true; } + + void idle() override {} +}; diff --git a/Marlin/src/sd/SdFatConfig.h b/Marlin/src/sd/SdFatConfig.h index 13ac3a7487..dfba641295 100644 --- a/Marlin/src/sd/SdFatConfig.h +++ b/Marlin/src/sd/SdFatConfig.h @@ -39,7 +39,7 @@ * * Each card requires about 550 bytes of SRAM so use of a Mega is recommended. */ -#define USE_MULTIPLE_CARDS 0 +#define USE_MULTIPLE_CARDS 0 //TODO? ENABLED(MULTI_VOLUME) /** * Call flush for endl if ENDL_CALLS_FLUSH is nonzero diff --git a/Marlin/src/sd/SdVolume.cpp b/Marlin/src/sd/SdVolume.cpp index 7fcebd640d..1b1fdc5a7c 100644 --- a/Marlin/src/sd/SdVolume.cpp +++ b/Marlin/src/sd/SdVolume.cpp @@ -41,10 +41,10 @@ // raw block cache uint32_t SdVolume::cacheBlockNumber_; // current block number cache_t SdVolume::cacheBuffer_; // 512 byte cache for Sd2Card - Sd2Card* SdVolume::sdCard_; // pointer to SD card object + DiskIODriver *SdVolume::sdCard_; // pointer to SD card object bool SdVolume::cacheDirty_; // cacheFlush() will write block if true uint32_t SdVolume::cacheMirrorBlock_; // mirror block for second FAT -#endif // USE_MULTIPLE_CARDS +#endif // find a contiguous group of clusters bool SdVolume::allocContiguous(uint32_t count, uint32_t *curCluster) { @@ -326,7 +326,7 @@ int32_t SdVolume::freeClusterCount() { * Reasons for failure include not finding a valid partition, not finding a valid * FAT file system in the specified partition or an I/O error. */ -bool SdVolume::init(Sd2Card* dev, uint8_t part) { +bool SdVolume::init(DiskIODriver* dev, uint8_t part) { uint32_t totalBlocks, volumeStartBlock = 0; fat32_boot_t *fbs; diff --git a/Marlin/src/sd/SdVolume.h b/Marlin/src/sd/SdVolume.h index c2eaf0bd13..b8e70ca9d7 100644 --- a/Marlin/src/sd/SdVolume.h +++ b/Marlin/src/sd/SdVolume.h @@ -36,9 +36,11 @@ #if ENABLED(USB_FLASH_DRIVE_SUPPORT) #include "usb_flashdrive/Sd2Card_FlashDrive.h" -#elif ENABLED(SDIO_SUPPORT) +#endif + +#if NEED_SD2CARD_SDIO #include "Sd2Card_sdio.h" -#else +#elif NEED_SD2CARD_SPI #include "Sd2Card.h" #endif @@ -47,6 +49,7 @@ //============================================================================== // SdVolume class + /** * \brief Cache for an SD data block */ @@ -84,14 +87,14 @@ class SdVolume { * Initialize a FAT volume. Try partition one first then try super * floppy format. * - * \param[in] dev The Sd2Card where the volume is located. + * \param[in] dev The DiskIODriver where the volume is located. * * \return true for success, false for failure. * Reasons for failure include not finding a valid partition, not finding * a valid FAT file system or an I/O error. */ - bool init(Sd2Card *dev) { return init(dev, 1) ? true : init(dev, 0); } - bool init(Sd2Card *dev, uint8_t part); + bool init(DiskIODriver *dev) { return init(dev, 1) || init(dev, 0); } + bool init(DiskIODriver *dev, uint8_t part); // inline functions that return volume info uint8_t blocksPerCluster() const { return blocksPerCluster_; } //> \return The volume's cluster size in blocks. @@ -112,10 +115,10 @@ class SdVolume { uint32_t rootDirStart() const { return rootDirStart_; } /** - * Sd2Card object for this volume - * \return pointer to Sd2Card object. + * DiskIODriver object for this volume + * \return pointer to DiskIODriver object. */ - Sd2Card* sdCard() { return sdCard_; } + DiskIODriver* sdCard() { return sdCard_; } /** * Debug access to FAT table @@ -138,13 +141,13 @@ class SdVolume { #if USE_MULTIPLE_CARDS cache_t cacheBuffer_; // 512 byte cache for device blocks uint32_t cacheBlockNumber_; // Logical number of block in the cache - Sd2Card *sdCard_; // Sd2Card object for cache + DiskIODriver *sdCard_; // DiskIODriver object for cache bool cacheDirty_; // cacheFlush() will write block if true uint32_t cacheMirrorBlock_; // block number for mirror FAT #else static cache_t cacheBuffer_; // 512 byte cache for device blocks static uint32_t cacheBlockNumber_; // Logical number of block in the cache - static Sd2Card *sdCard_; // Sd2Card object for cache + static DiskIODriver *sdCard_; // DiskIODriver object for cache static bool cacheDirty_; // cacheFlush() will write block if true static uint32_t cacheMirrorBlock_; // block number for mirror FAT #endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 07a57cc658..a54884bec1 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -120,7 +120,16 @@ uint8_t CardReader::workDirDepth; #endif // SDCARD_SORT_ALPHA -Sd2Card CardReader::sd2card; +#if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) + DiskIODriver_USBFlash CardReader::media_usbFlashDrive; +#endif +#if NEED_SD2CARD_SDIO + DiskIODriver_SDIO CardReader::media_sdio; +#elif NEED_SD2CARD_SPI + DiskIODriver_SPI_SD CardReader::media_sd_spi; +#endif + +DiskIODriver* CardReader::driver = nullptr; SdVolume CardReader::volume; SdFile CardReader::file; @@ -133,6 +142,16 @@ SdFile CardReader::file; uint32_t CardReader::filesize, CardReader::sdpos; CardReader::CardReader() { + changeMedia(& + #if SHARED_VOLUME_IS(SD_ONBOARD) + media_sd_spi + #elif SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) + media_usbFlashDrive + #else + TERN(SDIO_SUPPORT, media_sdio, media_sd_spi) + #endif + ); + #if ENABLED(SDCARD_SORT_ALPHA) sort_count = 0; #if ENABLED(SDSORT_GCODE) @@ -383,12 +402,12 @@ void CardReader::mount() { flag.mounted = false; if (root.isOpen()) root.close(); - if (!sd2card.init(SD_SPI_SPEED, SDSS) + if (!driver->init(SD_SPI_SPEED, SDSS) #if defined(LCD_SDSS) && (LCD_SDSS != SDSS) - && !sd2card.init(SD_SPI_SPEED, LCD_SDSS) + && !driver->init(SD_SPI_SPEED, LCD_SDSS) #endif ) SERIAL_ECHO_MSG(STR_SD_INIT_FAIL); - else if (!volume.init(&sd2card)) + else if (!volume.init(driver)) SERIAL_ERROR_MSG(STR_SD_VOL_INIT_FAIL); else if (!root.openRoot(&volume)) SERIAL_ERROR_MSG(STR_SD_OPENROOT_FAIL); diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index f1002e1dab..5fdd1222ae 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -42,6 +42,29 @@ extern const char M23_STR[], M24_STR[]; #define MAXPATHNAMELENGTH (1 + (MAXDIRNAMELENGTH + 1) * (MAX_DIR_DEPTH) + 1 + FILENAME_LENGTH) // "/" + N * ("ADIRNAME/") + "filename.ext" #include "SdFile.h" +#include "disk_io_driver.h" + +#if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #include "usb_flashdrive/Sd2Card_FlashDrive.h" +#endif + +#if NEED_SD2CARD_SDIO + #include "Sd2Card_sdio.h" +#elif NEED_SD2CARD_SPI + #include "Sd2Card.h" +#endif + +#if ENABLED(MULTI_VOLUME) + #define SV_SD_ONBOARD 1 + #define SV_USB_FLASH_DRIVE 2 + #define _VOLUME_ID(N) _CAT(SV_, N) + #define SHARED_VOLUME_IS(N) (DEFAULT_SHARED_VOLUME == _VOLUME_ID(N)) + #if !SHARED_VOLUME_IS(SD_ONBOARD) && !SHARED_VOLUME_IS(USB_FLASH_DRIVE) + #error "DEFAULT_SHARED_VOLUME must be either SD_ONBOARD or USB_FLASH_DRIVE." + #endif +#else + #define SHARED_VOLUME_IS(...) 0 +#endif typedef struct { bool saving:1, @@ -80,6 +103,8 @@ public: CardReader(); + static void changeMedia(DiskIODriver *_driver) { driver = _driver; } + static SdFile getroot() { return root; } static void mount(); @@ -171,7 +196,8 @@ public: static inline int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } static inline int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } - static Sd2Card& getSd2Card() { return sd2card; } + // TODO: rename to diskIODriver() + static DiskIODriver* diskIODriver() { return driver; } #if ENABLED(AUTO_REPORT_SD_STATUS) // @@ -181,6 +207,15 @@ public: static AutoReporter auto_reporter; #endif + #if SHARED_VOLUME_IS(USB_FLASH_DRIVE) || ENABLED(USB_FLASH_DRIVE_SUPPORT) + static DiskIODriver_USBFlash media_usbFlashDrive; + #endif + #if NEED_SD2CARD_SDIO + static DiskIODriver_SDIO media_sdio; + #elif NEED_SD2CARD_SPI + static DiskIODriver_SPI_SD media_sd_spi; + #endif + private: // // Working directory and parents @@ -236,7 +271,7 @@ private: #if ENABLED(SDSORT_DYNAMIC_RAM) static uint8_t *isDir; #elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK) - static uint8_t isDir[(SDSORT_LIMIT+7)>>3]; + static uint8_t isDir[(SDSORT_LIMIT + 7) >> 3]; #endif #endif @@ -244,7 +279,7 @@ private: #endif // SDCARD_SORT_ALPHA - static Sd2Card sd2card; + static DiskIODriver *driver; static SdVolume volume; static SdFile file; @@ -275,7 +310,7 @@ private: }; #if ENABLED(USB_FLASH_DRIVE_SUPPORT) - #define IS_SD_INSERTED() Sd2Card::isInserted() + #define IS_SD_INSERTED() DiskIODriver_USBFlash::isInserted() #elif PIN_EXISTS(SD_DETECT) #define IS_SD_INSERTED() (READ(SD_DETECT_PIN) == SD_DETECT_STATE) #else diff --git a/Marlin/src/sd/disk_io_driver.h b/Marlin/src/sd/disk_io_driver.h new file mode 100644 index 0000000000..73c12efcfa --- /dev/null +++ b/Marlin/src/sd/disk_io_driver.h @@ -0,0 +1,67 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include + +/** + * DiskIO Interace + * + * Interface for low level disk io + */ +class DiskIODriver { +public: + /** + * Initialize an SD flash memory card with default clock rate and chip + * select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin). + * + * \return true for success or false for failure. + */ + virtual bool init(const uint8_t sckRateID, const pin_t chipSelectPin) = 0; //TODO: only for SPI + + /** + * Read a card's CSD register. The CSD contains Card-Specific Data that + * provides information regarding access to the card's contents. + * + * \param[out] csd pointer to area for returned data. + * + * \return true for success or false for failure. + */ + virtual bool readCSD(csd_t* csd) = 0; + + virtual bool readStart(const uint32_t block) = 0; + virtual bool readData(uint8_t* dst) = 0; + virtual bool readStop() = 0; + + virtual bool writeStart(const uint32_t block, const uint32_t) = 0; + virtual bool writeData(const uint8_t* src) = 0; + virtual bool writeStop() = 0; + + virtual bool readBlock(uint32_t block, uint8_t* dst) = 0; + virtual bool writeBlock(uint32_t blockNumber, const uint8_t* src) = 0; + + virtual uint32_t cardSize() = 0; + + virtual bool isReady() = 0; + + virtual void idle() = 0; +}; diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index dc9efcb672..1975418415 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -121,7 +121,7 @@ static enum { uint32_t lun0_capacity; #endif -bool Sd2Card::usbStartup() { +bool DiskIODriver_USBFlash::usbStartup() { if (state <= DO_STARTUP) { SERIAL_ECHOPGM("Starting USB host..."); if (!UHS_START) { @@ -147,7 +147,7 @@ bool Sd2Card::usbStartup() { // the USB library to monitor for such events. This function also takes care // of initializing the USB library for the first time. -void Sd2Card::idle() { +void DiskIODriver_USBFlash::idle() { usb.Task(); const uint8_t task_state = usb.getUsbTaskState(); @@ -258,16 +258,16 @@ void Sd2Card::idle() { // Marlin calls this function to check whether an USB drive is inserted. // This is equivalent to polling the SD_DETECT when using SD cards. -bool Sd2Card::isInserted() { +bool DiskIODriver_USBFlash::isInserted() { return state == MEDIA_READY; } -bool Sd2Card::isReady() { - return state > DO_STARTUP; +bool DiskIODriver_USBFlash::isReady() { + return state > DO_STARTUP && usb.getUsbTaskState() == UHS_STATE(RUNNING); } // Marlin calls this to initialize an SD card once it is inserted. -bool Sd2Card::init(const uint8_t, const pin_t) { +bool DiskIODriver_USBFlash::init(const uint8_t, const pin_t) { if (!isInserted()) return false; #if USB_DEBUG >= 1 @@ -286,7 +286,7 @@ bool Sd2Card::init(const uint8_t, const pin_t) { } // Returns the capacity of the card in blocks. -uint32_t Sd2Card::cardSize() { +uint32_t DiskIODriver_USBFlash::cardSize() { if (!isInserted()) return false; #if USB_DEBUG < 3 const uint32_t @@ -295,7 +295,7 @@ uint32_t Sd2Card::cardSize() { return lun0_capacity; } -bool Sd2Card::readBlock(uint32_t block, uint8_t *dst) { +bool DiskIODriver_USBFlash::readBlock(uint32_t block, uint8_t *dst) { if (!isInserted()) return false; #if USB_DEBUG >= 3 if (block >= lun0_capacity) { @@ -309,7 +309,7 @@ bool Sd2Card::readBlock(uint32_t block, uint8_t *dst) { return bulk.Read(0, block, 512, 1, dst) == 0; } -bool Sd2Card::writeBlock(uint32_t block, const uint8_t *src) { +bool DiskIODriver_USBFlash::writeBlock(uint32_t block, const uint8_t *src) { if (!isInserted()) return false; #if USB_DEBUG >= 3 if (block >= lun0_capacity) { diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h index 320678d091..3390bc51be 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h @@ -27,6 +27,7 @@ */ #include "../SdFatConfig.h" #include "../SdInfo.h" +#include "../disk_io_driver.h" #if DISABLED(USE_OTG_USB_HOST) /** @@ -46,7 +47,7 @@ #endif #endif -class Sd2Card { +class DiskIODriver_USBFlash : public DiskIODriver { private: uint32_t pos; @@ -54,25 +55,26 @@ class Sd2Card { public: static bool usbStartup(); - - bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=TERN(USE_OTG_USB_HOST, 0, SD_CHIP_SELECT_PIN)); - - static void idle(); - - inline bool readStart(const uint32_t block) { pos = block; return isReady(); } - inline bool readData(uint8_t *dst) { return readBlock(pos++, dst); } - inline bool readStop() const { return true; } - - inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return isReady(); } - inline bool writeData(uint8_t *src) { return writeBlock(pos++, src); } - inline bool writeStop() const { return true; } - - bool readBlock(uint32_t block, uint8_t *dst); - bool writeBlock(uint32_t blockNumber, const uint8_t *src); - - bool readCSD(csd_t*) { return true; } - - uint32_t cardSize(); static bool isInserted(); - bool isReady(); + + bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=TERN(USE_OTG_USB_HOST, 0, SD_CHIP_SELECT_PIN)) override; + + inline bool readCSD(csd_t*) override { return true; } + + inline bool readStart(const uint32_t block) override { pos = block; return isReady(); } + inline bool readData(uint8_t *dst) override { return readBlock(pos++, dst); } + inline bool readStop() override { return true; } + + inline bool writeStart(const uint32_t block, const uint32_t) override { pos = block; return isReady(); } + inline bool writeData(const uint8_t *src) override { return writeBlock(pos++, src); } + inline bool writeStop() override { return true; } + + bool readBlock(uint32_t block, uint8_t *dst) override; + bool writeBlock(uint32_t blockNumber, const uint8_t *src) override; + + uint32_t cardSize() override; + + bool isReady() override; + + void idle() override; }; From 3ec5cd312beb3077b661129144e214c83a232d69 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Tue, 13 Apr 2021 17:31:12 -0600 Subject: [PATCH 215/311] Enhance and fix FTDI Eve Touch UI (#21607) --- .../ftdi_eve_touch_ui/language/language_en.h | 1 + .../screens/bed_mesh_edit_screen.cpp | 20 ++++++-- .../screens/bed_mesh_edit_screen.h | 3 +- .../screens/bed_mesh_view_screen.cpp | 4 +- .../screens/move_axis_screen.cpp | 11 ++++- .../screens/move_axis_screen.h | 1 + .../ftdi_eve_touch_ui/screens/screen_data.h | 1 + .../screens/status_screen.cpp | 4 +- .../screens/z_offset_screen.cpp | 46 ++++++++++++++++++- .../screens/z_offset_screen.h | 8 ++++ 10 files changed, 86 insertions(+), 13 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h index c34d5b7756..9de9623e19 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h @@ -147,6 +147,7 @@ namespace Language_en { PROGMEM Language_Str MSG_PROBE_BED = u8"Probe Mesh"; PROGMEM Language_Str MSG_SHOW_MESH = u8"View Mesh"; PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test"; + PROGMEM Language_Str MSG_MOVE_Z_TO_TOP = u8"Raise Z to Top"; #if ENABLED(TOUCH_UI_LULZBOT_BIO) PROGMEM Language_Str MSG_MOVE_TO_HOME = u8"Move to Home"; diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp index 01d4d1428b..94e43bdec1 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp @@ -30,7 +30,7 @@ using namespace Theme; using namespace ExtUI; constexpr static BedMeshEditScreenData &mydata = screen_data.BedMeshEditScreen; -constexpr static float gaugeThickness = 0.25; +constexpr static float gaugeThickness = 0.1; #if ENABLED(TOUCH_UI_PORTRAIT) #define GRID_COLS 3 @@ -54,20 +54,29 @@ constexpr static float gaugeThickness = 0.25; #define SAVE_POS BTN_POS(5,5), BTN_SIZE(1,1) #endif +constexpr uint8_t NONE = 255; + static float meshGetter(uint8_t x, uint8_t y, void*) { xy_uint8_t pos; pos.x = x; pos.y = y; - return ExtUI::getMeshPoint(pos) + (mydata.highlight.x != -1 && mydata.highlight == pos ? mydata.zAdjustment : 0); + return ExtUI::getMeshPoint(pos) + (mydata.highlight.x != NONE && mydata.highlight == pos ? mydata.zAdjustment : 0); } void BedMeshEditScreen::onEntry() { mydata.needSave = false; - mydata.highlight.x = -1; + mydata.highlight.x = NONE; mydata.zAdjustment = 0; + mydata.savedMeshLevelingState = ExtUI::getLevelingActive(); + mydata.savedEndstopState = ExtUI::getSoftEndstopState(); BaseScreen::onEntry(); } +void BedMeshEditScreen::onExit() { + ExtUI::setLevelingActive(mydata.savedMeshLevelingState); + ExtUI::setSoftEndstopState(mydata.savedEndstopState); +} + float BedMeshEditScreen::getHighlightedValue() { const float val = ExtUI::getMeshPoint(mydata.highlight); return (ISNAN(val) ? 0 : val) + mydata.zAdjustment; @@ -80,12 +89,13 @@ void BedMeshEditScreen::setHighlightedValue(float value) { void BedMeshEditScreen::moveToHighlightedValue() { if (ExtUI::getMeshValid()) { ExtUI::setLevelingActive(true); + ExtUI::setSoftEndstopState(false); ExtUI::moveToMeshPoint(mydata.highlight, gaugeThickness + mydata.zAdjustment); } } void BedMeshEditScreen::adjustHighlightedValue(float increment) { - if(mydata.highlight.x != -1) { + if (mydata.highlight.x != NONE) { mydata.zAdjustment += increment; moveToHighlightedValue(); mydata.needSave = true; @@ -114,7 +124,7 @@ void BedMeshEditScreen::drawHighlightedPointValue() { .colors(normal_btn) .text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z)) .font(font_small); - if(mydata.highlight.x != -1) + if (mydata.highlight.x != NONE) draw_adjuster(cmd, Z_VALUE_POS, 3, getHighlightedValue(), GET_TEXT_F(MSG_UNITS_MM), 4, 3); cmd.colors(mydata.needSave ? normal_btn : action_btn) .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_BACK)) diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h index 62121941b1..b856b9b33b 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.h @@ -25,7 +25,7 @@ #define FTDI_BED_MESH_EDIT_SCREEN_CLASS BedMeshEditScreen struct BedMeshEditScreenData { - bool needSave; + bool needSave, savedMeshLevelingState, savedEndstopState; xy_uint8_t highlight; float zAdjustment; }; @@ -41,6 +41,7 @@ class BedMeshEditScreen : public BedMeshBase, public CachedScreen { + private: + static void move(float inc); + static void runWizard(); public: + static void onEntry(); static void onRedraw(draw_mode_t); static bool onTouchHeld(uint8_t tag); }; From 4849d313fd418832f591fbbc2236bc9d02a843d2 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 14 Apr 2021 00:32:34 +0000 Subject: [PATCH 216/311] [cron] Bump distribution date (2021-04-14) --- 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 e16c01ceb9..568897ef95 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-04-13" + #define STRING_DISTRIBUTION_DATE "2021-04-14" #endif /** From 0e9836649eef298c6fd84e7585cee5d84898c939 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 13 Apr 2021 21:34:21 -0500 Subject: [PATCH 217/311] Misc. formatting, serial out --- .../shared/cpu_exception/exception_arm.cpp | 8 +- Marlin/src/core/bug_on.h | 4 +- Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp | 2 +- .../extui/lib/anycubic_chiron/FileNavigator.h | 41 +- .../extui/lib/anycubic_chiron/chiron_tft.cpp | 1574 ++++++++--------- .../extui/lib/anycubic_chiron/chiron_tft.h | 76 +- .../lib/anycubic_chiron/chiron_tft_defs.h | 6 - 7 files changed, 855 insertions(+), 856 deletions(-) diff --git a/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp b/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp index ae9600038a..124f0b7c43 100644 --- a/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp +++ b/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp @@ -320,8 +320,8 @@ void hook_cpu_exceptions() { // So we'll simply mask the top 8 bits of the first handler as an hint of being in the flash or not -that's poor and will // probably break if the flash happens to be more than 128MB, but in this case, we are not magician, we need help from outside. - unsigned long * vecAddr = (unsigned long*)get_vtor(); - SERIAL_ECHO("Vector table addr: "); + unsigned long *vecAddr = (unsigned long*)get_vtor(); + SERIAL_ECHOPGM("Vector table addr: "); SERIAL_PRINTLN(get_vtor(), HEX); #ifdef VECTOR_TABLE_SIZE @@ -348,7 +348,7 @@ void hook_cpu_exceptions() { // 128 bytes alignement is required for writing the VTOR register alignas(128) static unsigned long vectable[VECTOR_TABLE_SENTINEL]; - SERIAL_ECHO("Detected vector table size: "); + SERIAL_ECHOPGM("Detected vector table size: "); SERIAL_PRINTLN(vec_size, HEX); #endif @@ -372,7 +372,7 @@ void hook_cpu_exceptions() { HW_REG(0xE000ED08) = (unsigned long)vectable | _BV32(29); // 29th bit is for telling the CPU the table is now in SRAM (should be present already) - SERIAL_ECHOLN("Installed fault handlers"); + SERIAL_ECHOLNPGM("Installed fault handlers"); #endif } diff --git a/Marlin/src/core/bug_on.h b/Marlin/src/core/bug_on.h index 3c9dec0f96..cc745f259b 100644 --- a/Marlin/src/core/bug_on.h +++ b/Marlin/src/core/bug_on.h @@ -28,11 +28,11 @@ // This is used like SERIAL_ECHOPAIR, that is: a key-value call of the local variables you want // to dump to the serial port before stopping the CPU. // \/ Don't replace by SERIAL_ECHOPAIR since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building - #define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLN(": "); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0) + #define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": "); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0) #elif ENABLED(MARLIN_DEV_MODE) // Don't stop the CPU here, but at least dump the bug on the serial port // \/ Don't replace by SERIAL_ECHOPAIR since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building - #define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLN(": BUG!"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0) + #define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": BUG!"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0) #else // Release mode, let's ignore the bug #define BUG_ON(V...) NOOP diff --git a/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp b/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp index 8ba19216b1..7b4c470afe 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp @@ -88,7 +88,7 @@ static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = { }; uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { - switch(msg) { + switch (msg) { case U8G_DEV_MSG_INIT: u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS); u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_init_seq); diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h index 8e03614a46..c709415879 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h @@ -35,22 +35,27 @@ using namespace ExtUI; namespace Anycubic { - class FileNavigator { - public: - FileNavigator(); - void reset(); - void getFiles(uint16_t); - void upDIR(); - void changeDIR(char *); - void sendFile(); - void refresh(); - char * getCurrentFolderName(); - private: - static FileList filelist; - static char currentfoldername[MAX_PATH_LEN]; - static uint16_t lastindex; - static uint8_t folderdepth; - static uint16_t currentindex; - }; - extern FileNavigator filenavigator; + +class FileNavigator { + public: + FileNavigator(); + void reset(); + void getFiles(uint16_t, panel_type_t, uint8_t filesneeded=4); + void upDIR(); + void changeDIR(const char *); + void sendFile(panel_type_t); + void refresh(); + void skiptofileindex(uint16_t); + + static FileList filelist; + private: + static uint16_t lastpanelindex; + static uint16_t currentindex; + static uint8_t currentfolderdepth; + static uint16_t currentfolderindex[MAX_FOLDER_DEPTH]; + static char currentfoldername[MAX_PATH_LEN]; +}; + +extern FileNavigator filenavigator; + } diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index 5eb8611b5e..065e4e1789 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -43,843 +43,843 @@ namespace Anycubic { - printer_state_t ChironTFT::printer_state; - paused_state_t ChironTFT::pause_state; - heater_state_t ChironTFT::hotend_state; - heater_state_t ChironTFT::hotbed_state; - xy_uint8_t ChironTFT::selectedmeshpoint; - char ChironTFT::selectedfile[MAX_PATH_LEN]; - char ChironTFT::panel_command[MAX_CMND_LEN]; - uint8_t ChironTFT::command_len; - float ChironTFT::live_Zoffset; - file_menu_t ChironTFT::file_menu; +printer_state_t ChironTFT::printer_state; +paused_state_t ChironTFT::pause_state; +heater_state_t ChironTFT::hotend_state; +heater_state_t ChironTFT::hotbed_state; +xy_uint8_t ChironTFT::selectedmeshpoint; +char ChironTFT::selectedfile[MAX_PATH_LEN]; +char ChironTFT::panel_command[MAX_CMND_LEN]; +uint8_t ChironTFT::command_len; +float ChironTFT::live_Zoffset; +file_menu_t ChironTFT::file_menu; - ChironTFT Chiron; +ChironTFT Chiron; - ChironTFT::ChironTFT(){} +ChironTFT::ChironTFT(){} - void ChironTFT::Startup() { - selectedfile[0] = '\0'; - panel_command[0] = '\0'; - command_len = 0; - printer_state = AC_printer_idle; - pause_state = AC_paused_idle; - hotend_state = AC_heater_off; - hotbed_state = AC_heater_off; - live_Zoffset = 0.0; - file_menu = AC_menu_file; +void ChironTFT::Startup() { + selectedfile[0] = '\0'; + panel_command[0] = '\0'; + command_len = 0; + printer_state = AC_printer_idle; + pause_state = AC_paused_idle; + hotend_state = AC_heater_off; + hotbed_state = AC_heater_off; + live_Zoffset = 0.0; + file_menu = AC_menu_file; - // Setup pins for powerloss detection - // Two IO pins are connected on the Trigorilla Board - // On a power interruption the OUTAGECON_PIN goes low. + // Setup pins for powerloss detection + // Two IO pins are connected on the Trigorilla Board + // On a power interruption the OUTAGECON_PIN goes low. - #if ENABLED(POWER_LOSS_RECOVERY) - OUT_WRITE(OUTAGECON_PIN, HIGH); - #endif + #if ENABLED(POWER_LOSS_RECOVERY) + OUT_WRITE(OUTAGECON_PIN, HIGH); + #endif - // Filament runout is handled by Marlin settings in Configuration.h - // opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present. - // opt_enable FIL_RUNOUT_PULLUP + // Filament runout is handled by Marlin settings in Configuration.h + // opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present. + // opt_enable FIL_RUNOUT_PULLUP - TFTSer.begin(115200); + TFTSer.begin(115200); - // Signal Board has reset - SendtoTFTLN(AC_msg_main_board_has_reset); + // Signal Board has reset + SendtoTFTLN(AC_msg_main_board_has_reset); - safe_delay(200); + safe_delay(200); - // Enable leveling and Disable end stops during print - // as Z home places nozzle above the bed so we need to allow it past the end stops - injectCommands_P(AC_cmnd_enable_leveling); + // Enable leveling and Disable end stops during print + // as Z home places nozzle above the bed so we need to allow it past the end stops + injectCommands_P(AC_cmnd_enable_leveling); - // Startup tunes are defined in Tunes.h - //PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1); - PlayTune(BEEPER_PIN, GB_PowerOn, 1); - #if ACDEBUGLEVEL - SERIAL_ECHOLNPAIR("AC Debug Level ", ACDEBUGLEVEL); - #endif - SendtoTFTLN(AC_msg_ready); + // Startup tunes are defined in Tunes.h + //PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1); + PlayTune(BEEPER_PIN, GB_PowerOn, 1); + #if ACDEBUGLEVEL + SERIAL_ECHOLNPAIR("AC Debug Level ", ACDEBUGLEVEL); + #endif + SendtoTFTLN(AC_msg_ready); +} + +void ChironTFT::IdleLoop() { + if (ReadTFTCommand()) { + ProcessPanelRequest(); + command_len = 0; } + CheckHeaters(); +} - void ChironTFT::IdleLoop() { - if (ReadTFTCommand()) { - ProcessPanelRequest(); - command_len = 0; - } - CheckHeaters(); +void ChironTFT::PrinterKilled(PGM_P error,PGM_P component) { + SendtoTFTLN(AC_msg_kill_lcd); + #if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("PrinterKilled()\nerror: ", error , "\ncomponent: ", component); + #endif +} + +void ChironTFT::MediaEvent(media_event_t event) { + #if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("ProcessMediaStatus() ", event); + #endif + switch (event) { + case AC_media_inserted: + SendtoTFTLN(AC_msg_sd_card_inserted); + break; + + case AC_media_removed: + SendtoTFTLN(AC_msg_sd_card_removed); + break; + + case AC_media_error: + SendtoTFTLN(AC_msg_no_sd_card); + break; } +} - void ChironTFT::PrinterKilled(PGM_P error,PGM_P component) { - SendtoTFTLN(AC_msg_kill_lcd); - #if ACDEBUG(AC_MARLIN) - SERIAL_ECHOLNPAIR("PrinterKilled()\nerror: ", error , "\ncomponent: ", component); - #endif +void ChironTFT::TimerEvent(timer_event_t event) { + #if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("TimerEvent() ", event); + SERIAL_ECHOLNPAIR("Printer State: ", printer_state); + #endif + + switch (event) { + case AC_timer_started: { + live_Zoffset = 0.0; // reset print offset + setSoftEndstopState(false); // disable endstops to print + printer_state = AC_printer_printing; + SendtoTFTLN(AC_msg_print_from_sd_card); + } break; + + case AC_timer_paused: { + printer_state = AC_printer_paused; + pause_state = AC_paused_idle; + SendtoTFTLN(AC_msg_paused); + } break; + + case AC_timer_stopped: { + if (printer_state != AC_printer_idle) { + printer_state = AC_printer_stopping; + SendtoTFTLN(AC_msg_print_complete); + } + setSoftEndstopState(true); // enable endstops + } break; } +} - void ChironTFT::MediaEvent(media_event_t event) { - #if ACDEBUG(AC_MARLIN) - SERIAL_ECHOLNPAIR("ProcessMediaStatus() ", event); - #endif - switch (event) { - case AC_media_inserted: - SendtoTFTLN(AC_msg_sd_card_inserted); - break; +void ChironTFT::FilamentRunout() { + #if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("FilamentRunout() printer_state ", printer_state); + #endif + // 1 Signal filament out + SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block); + //printer_state = AC_printer_filament_out; + PlayTune(BEEPER_PIN, FilamentOut, 1); +} - case AC_media_removed: - SendtoTFTLN(AC_msg_sd_card_removed); - break; - - case AC_media_error: - SendtoTFTLN(AC_msg_no_sd_card); - break; - } - } - - void ChironTFT::TimerEvent(timer_event_t event) { - #if ACDEBUG(AC_MARLIN) - SERIAL_ECHOLNPAIR("TimerEvent() ", event); - SERIAL_ECHOLNPAIR("Printer State: ", printer_state); - #endif - - switch (event) { - case AC_timer_started: { - live_Zoffset = 0.0; // reset print offset - setSoftEndstopState(false); // disable endstops to print - printer_state = AC_printer_printing; - SendtoTFTLN(AC_msg_print_from_sd_card); - } break; - - case AC_timer_paused: { +void ChironTFT::ConfirmationRequest(const char * const msg) { + // M108 continue + #if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("ConfirmationRequest() ", msg, " printer_state:", printer_state); + #endif + switch (printer_state) { + case AC_printer_pausing: { + if (strcmp_P(msg, MARLIN_msg_print_paused) == 0 || strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0) { + SendtoTFTLN(AC_msg_paused); // enable continue button printer_state = AC_printer_paused; - pause_state = AC_paused_idle; + } + } break; + + case AC_printer_resuming_from_power_outage: + case AC_printer_printing: + case AC_printer_paused: { + // Heater timout, send acknowledgement + if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0) { + pause_state = AC_paused_heater_timed_out; + SendtoTFTLN(AC_msg_paused); // enable continue button + PlayTune(BEEPER_PIN,Heater_Timedout,1); + } + // Reheat finished, send acknowledgement + else if (strcmp_P(msg, MARLIN_msg_reheat_done) == 0) { + pause_state = AC_paused_idle; + SendtoTFTLN(AC_msg_paused); // enable continue button + } + // Filament Purging, send acknowledgement enter run mode + else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0) { + pause_state = AC_paused_purging_filament; + SendtoTFTLN(AC_msg_paused); // enable continue button + } + } break; + default: + break; + } +} + +void ChironTFT::StatusChange(const char * const msg) { + #if ACDEBUG(AC_MARLIN) + SERIAL_ECHOLNPAIR("StatusChange() ", msg); + SERIAL_ECHOLNPAIR("printer_state:", printer_state); + #endif + bool msg_matched = false; + // The only way to get printer status is to parse messages + // Use the state to minimise the work we do here. + switch (printer_state) { + case AC_printer_probing: { + // If probing completes ok save the mesh and park + // Ignore the custom machine name + if (strcmp_P(msg + strlen(CUSTOM_MACHINE_NAME), MARLIN_msg_ready) == 0) { + injectCommands_P(PSTR("M500\nG27")); + SendtoTFTLN(AC_msg_probing_complete); + printer_state = AC_printer_idle; + msg_matched = true; + } + // If probing fails dont save the mesh raise the probe above the bad point + if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) { + PlayTune(BEEPER_PIN, BeepBeepBeeep, 1); + injectCommands_P(PSTR("G1 Z50 F500")); + SendtoTFTLN(AC_msg_probing_complete); + printer_state = AC_printer_idle; + msg_matched = true; + } + } break; + + case AC_printer_printing: { + if (strcmp_P(msg, MARLIN_msg_reheating) == 0) { + SendtoTFTLN(AC_msg_paused); // enable continue button + msg_matched = true; + } + } break; + + case AC_printer_pausing: { + if (strcmp_P(msg, MARLIN_msg_print_paused) == 0) { SendtoTFTLN(AC_msg_paused); - } break; + printer_state = AC_printer_paused; + pause_state = AC_paused_idle; + msg_matched = true; + } + } break; - case AC_timer_stopped: { - if (printer_state != AC_printer_idle) { - printer_state = AC_printer_stopping; - SendtoTFTLN(AC_msg_print_complete); - } - setSoftEndstopState(true); // enable endstops - } break; + case AC_printer_stopping: { + if (strcmp_P(msg, MARLIN_msg_print_aborted) == 0) { + SendtoTFTLN(AC_msg_stop); + printer_state = AC_printer_idle; + msg_matched = true; + } + } break; + default: + break; + } + + // If not matched earlier see if this was a heater message + if (!msg_matched) { + if (strcmp_P(msg, MARLIN_msg_extruder_heating) == 0) { + SendtoTFTLN(AC_msg_nozzle_heating); + hotend_state = AC_heater_temp_set; + } + else if (strcmp_P(msg, MARLIN_msg_bed_heating) == 0) { + SendtoTFTLN(AC_msg_bed_heating); + hotbed_state = AC_heater_temp_set; } } +} - void ChironTFT::FilamentRunout() { - #if ACDEBUG(AC_MARLIN) - SERIAL_ECHOLNPAIR("FilamentRunout() printer_state ", printer_state); +void ChironTFT::PowerLossRecovery() { + printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover. + PlayTune(BEEPER_PIN, SOS, 1); + SERIAL_ECHOLNPGM("Resuming from power outage..."); + SERIAL_ECHOLNPGM("Select SD file then press resume"); +} + +void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel + #if ACDEBUG(AC_SOME) + SERIAL_ECHOPGM_P(str); + #endif + while (const char c = pgm_read_byte(str++)) TFTSer.write(c); +} + +void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) { + if (str) { + #if ACDEBUG(AC_SOME) + SERIAL_ECHOPGM("> "); + #endif + SendtoTFT(str); + #if ACDEBUG(AC_SOME) + SERIAL_EOL(); #endif - // 1 Signal filament out - SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block); - //printer_state = AC_printer_filament_out; - PlayTune(BEEPER_PIN, FilamentOut, 1); } + TFTSer.println(); +} - void ChironTFT::ConfirmationRequest(const char * const msg) { - // M108 continue - #if ACDEBUG(AC_MARLIN) - SERIAL_ECHOLNPAIR("ConfirmationRequest() ", msg, " printer_state:", printer_state); - #endif - switch (printer_state) { - case AC_printer_pausing: { - if (strcmp_P(msg, MARLIN_msg_print_paused) == 0 || strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0) { - SendtoTFTLN(AC_msg_paused); // enable continue button - printer_state = AC_printer_paused; - } - } break; - - case AC_printer_resuming_from_power_outage: - case AC_printer_printing: - case AC_printer_paused: { - // Heater timout, send acknowledgement - if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0) { - pause_state = AC_paused_heater_timed_out; - SendtoTFTLN(AC_msg_paused); // enable continue button - PlayTune(BEEPER_PIN,Heater_Timedout,1); - } - // Reheat finished, send acknowledgement - else if (strcmp_P(msg, MARLIN_msg_reheat_done) == 0) { - pause_state = AC_paused_idle; - SendtoTFTLN(AC_msg_paused); // enable continue button - } - // Filament Purging, send acknowledgement enter run mode - else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0) { - pause_state = AC_paused_purging_filament; - SendtoTFTLN(AC_msg_paused); // enable continue button - } - } break; - default: +bool ChironTFT::ReadTFTCommand() { + bool command_ready = false; + while (TFTSer.available() > 0 && command_len < MAX_CMND_LEN) { + panel_command[command_len] = TFTSer.read(); + if (panel_command[command_len] == '\n') { + command_ready = true; break; } + command_len++; } - void ChironTFT::StatusChange(const char * const msg) { - #if ACDEBUG(AC_MARLIN) - SERIAL_ECHOLNPAIR("StatusChange() ", msg); - SERIAL_ECHOLNPAIR("printer_state:", printer_state); + if (command_ready) { + panel_command[command_len] = 0x00; + #if ACDEBUG(AC_ALL) + SERIAL_ECHOLNPAIR("< ", panel_command); #endif - bool msg_matched = false; - // The only way to get printer status is to parse messages - // Use the state to minimise the work we do here. - switch (printer_state) { - case AC_printer_probing: { - // If probing completes ok save the mesh and park - // Ignore the custom machine name - if (strcmp_P(msg + strlen(CUSTOM_MACHINE_NAME), MARLIN_msg_ready) == 0) { - injectCommands_P(PSTR("M500\nG27")); - SendtoTFTLN(AC_msg_probing_complete); - printer_state = AC_printer_idle; - msg_matched = true; - } - // If probing fails dont save the mesh raise the probe above the bad point - if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) { - PlayTune(BEEPER_PIN, BeepBeepBeeep, 1); - injectCommands_P(PSTR("G1 Z50 F500")); - SendtoTFTLN(AC_msg_probing_complete); - printer_state = AC_printer_idle; - msg_matched = true; - } - } break; + #if ACDEBUG(AC_SOME) + // Ignore status request commands + uint8_t req = atoi(&panel_command[1]); + if (req > 7 && req != 20) { + SERIAL_ECHOLNPAIR("> ", panel_command); + SERIAL_ECHOLNPAIR("printer_state:", printer_state); + } + #endif + } + return command_ready; +} - case AC_printer_printing: { - if (strcmp_P(msg, MARLIN_msg_reheating) == 0) { - SendtoTFTLN(AC_msg_paused); // enable continue button - msg_matched = true; - } - } break; +int8_t ChironTFT::Findcmndpos(const char * buff, char q) { + int8_t pos = 0; + do { if (buff[pos] == q) return pos; } while (++pos < MAX_CMND_LEN); + return -1; +} - case AC_printer_pausing: { - if (strcmp_P(msg, MARLIN_msg_print_paused) == 0) { - SendtoTFTLN(AC_msg_paused); - printer_state = AC_printer_paused; - pause_state = AC_paused_idle; - msg_matched = true; - } - } break; +void ChironTFT::CheckHeaters() { + uint8_t faultDuration = 0; + float temp = 0; - case AC_printer_stopping: { - if (strcmp_P(msg, MARLIN_msg_print_aborted) == 0) { - SendtoTFTLN(AC_msg_stop); - printer_state = AC_printer_idle; - msg_matched = true; - } - } break; - default: + // if the hotend temp is abnormal, confirm state before signalling panel + temp = getActualTemp_celsius(E0); + while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) { + faultDuration++; + if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { + SendtoTFTLN(AC_msg_nozzle_temp_abnormal); + SERIAL_ECHOLNPAIR("Extruder temp abnormal! : ", temp); break; } + delay_ms(500); + temp = getActualTemp_celsius(E0); + } - // If not matched earlier see if this was a heater message - if (!msg_matched) { - if (strcmp_P(msg, MARLIN_msg_extruder_heating) == 0) { - SendtoTFTLN(AC_msg_nozzle_heating); + // If the hotbed temp is abnormal, confirm state before signaling panel + faultDuration = 0; + temp = getActualTemp_celsius(BED); + while (!WITHIN(temp, BED_MINTEMP, BED_MAXTEMP)) { + faultDuration++; + if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { + SendtoTFTLN(AC_msg_nozzle_temp_abnormal); + SERIAL_ECHOLNPAIR("Bed temp abnormal! : ", temp); + break; + } + delay_ms(500); + temp = getActualTemp_celsius(E0); + } + + // Update panel with hotend heater status + if (hotend_state != AC_heater_temp_reached) { + if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -1, 1)) { + SendtoTFTLN(AC_msg_nozzle_heating_done); + hotend_state = AC_heater_temp_reached; + } + } + + // Update panel with bed heater status + if (hotbed_state != AC_heater_temp_reached) { + if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -0.5, 0.5)) { + SendtoTFTLN(AC_msg_bed_heating_done); + hotbed_state = AC_heater_temp_reached; + } + } +} + +void ChironTFT::SendFileList(int8_t startindex) { + // Respond to panel request for 4 files starting at index + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("## SendFileList ## ", startindex); + #endif + SendtoTFTLN(PSTR("FN ")); + filenavigator.getFiles(startindex); + SendtoTFTLN(PSTR("END")); +} + +void ChironTFT::SelectFile() { + strncpy(selectedfile, panel_command + 4, command_len - 4); + selectedfile[command_len - 5] = '\0'; + #if ACDEBUG(AC_FILE) + SERIAL_ECHOLNPAIR_F(" Selected File: ",selectedfile); + #endif + switch (selectedfile[0]) { + case '/': // Valid file selected + SendtoTFTLN(AC_msg_sd_file_open_success); + break; + + case '<': // .. (go up folder level) + filenavigator.upDIR(); + SendtoTFTLN(AC_msg_sd_file_open_failed); + SendFileList( 0 ); + break; + default: // enter sub folder + filenavigator.changeDIR(selectedfile); + SendtoTFTLN(AC_msg_sd_file_open_failed); + SendFileList( 0 ); + break; + } +} + +void ChironTFT::InjectCommandandWait(PGM_P cmd) { + //injectCommands_P(cmnd); queue.enqueue_now_P(cmd); + //SERIAL_ECHOLN(PSTR("Inject>")); +} + +void ChironTFT::ProcessPanelRequest() { + // Break these up into logical blocks // as its easier to navigate than one huge switch case! + int8_t req = atoi(&panel_command[1]); + + // Information requests A0 - A8 and A33 + if (req <= 8 || req == 33) PanelInfo(req); + + // Simple Actions A9 - A28 + else if ( req <= 28) PanelAction(req); + + // Process Initiation + else if (req <= 34) PanelProcess(req); + + else SendtoTFTLN(); +} + +void ChironTFT::PanelInfo(uint8_t req) { + // information requests A0-A8 and A33 + switch (req) { + case 0: // A0 Get HOTEND Temp + SendtoTFT(PSTR("A0V ")); + TFTSer.println(getActualTemp_celsius(E0)); + break; + + case 1: // A1 Get HOTEND Target Temp + SendtoTFT(PSTR("A1V ")); + TFTSer.println(getTargetTemp_celsius(E0)); + break; + + case 2: // A2 Get BED Temp + SendtoTFT(PSTR("A2V ")); + TFTSer.println(getActualTemp_celsius(BED)); + break; + + case 3: // A3 Get BED Target Temp + SendtoTFT(PSTR("A3V ")); + TFTSer.println(getTargetTemp_celsius(BED)); + break; + + case 4: // A4 Get FAN Speed + SendtoTFT(PSTR("A4V ")); + TFTSer.println(getActualFan_percent(FAN0)); + break; + + case 5: // A5 Get Current Coordinates + SendtoTFT(PSTR("A5V X: ")); + TFTSer.print(getAxisPosition_mm(X)); + SendtoTFT(PSTR(" Y: ")); + TFTSer.print(getAxisPosition_mm(Y)); + SendtoTFT(PSTR(" Z: ")); + TFTSer.println(getAxisPosition_mm(Z)); + break; + + case 6: // A6 Get printing progress + if (isPrintingFromMedia()) { + SendtoTFT(PSTR("A6V ")); + TFTSer.println(ui8tostr2(getProgress_percent())); + } + else + SendtoTFTLN(PSTR("A6V ---")); + break; + + case 7: { // A7 Get Printing Time + uint32_t time = getProgress_seconds_elapsed() / 60; + SendtoTFT(PSTR("A7V ")); + TFTSer.print(ui8tostr2(time / 60)); + SendtoTFT(PSTR(" H ")); + TFTSer.print(ui8tostr2(time % 60)); + SendtoTFT(PSTR(" M")); + #if ACDEBUG(AC_ALL) + SERIAL_ECHOLNPAIR("Print time ", ui8tostr2(time / 60), ":", ui8tostr2(time % 60)); + #endif + } break; + + case 8: // A8 Get SD Card list A8 S0 + if (!isMediaInserted()) safe_delay(500); + if (!isMediaInserted()) // Make sure the card is removed + SendtoTFTLN(AC_msg_no_sd_card); + else if (panel_command[3] == 'S') + SendFileList( atoi( &panel_command[4] ) ); + break; + + case 33: // A33 Get firmware info + SendtoTFT(PSTR("J33 ")); + SendtoTFTLN(PSTR(SHORT_BUILD_VERSION)); + break; + } +} + +void ChironTFT::PanelAction(uint8_t req) { + switch (req) { + case 9: // A9 Pause SD print + if (isPrintingFromMedia()) { + SendtoTFTLN(AC_msg_pause); + pausePrint(); + printer_state = AC_printer_pausing; + } + else + SendtoTFTLN(AC_msg_stop); + break; + + case 10: // A10 Resume SD Print + if (pause_state == AC_paused_idle || printer_state == AC_printer_resuming_from_power_outage) + resumePrint(); + else + setUserConfirmed(); + break; + + case 11: // A11 Stop SD print + if (isPrintingFromMedia()) { + printer_state = AC_printer_stopping; + stopPrint(); + } + else { + if (printer_state == AC_printer_resuming_from_power_outage) + injectCommands_P(PSTR("M1000 C")); // Cancel recovery + SendtoTFTLN(AC_msg_stop); + printer_state = AC_printer_idle; + } + break; + + case 12: // A12 Kill printer + kill(); // from marlincore.h + break; + + case 13: // A13 Select file + SelectFile(); + break; + + case 14: { // A14 Start Printing + // Allows printer to restart the job if we dont want to recover + if (printer_state == AC_printer_resuming_from_power_outage) { + injectCommands_P(PSTR("M1000 C")); // Cancel recovery + printer_state = AC_printer_idle; + } + #if ACDebugLevel >= 1 + SERIAL_ECHOLNPAIR_F("Print: ", selectedfile); + #endif + // the card library needs a path starting // but the File api doesn't... + char file[MAX_PATH_LEN]; + file[0] = '/'; + strcpy(file + 1, selectedfile); + printFile(file); + SendtoTFTLN(AC_msg_print_from_sd_card); + } break; + + case 15: // A15 Resuming from outage + if (printer_state == AC_printer_resuming_from_power_outage) { + // Need to home here to restore the Z position + injectCommands_P(AC_cmnd_power_loss_recovery); + injectCommands_P(PSTR("M1000")); // home and start recovery + } + break; + + case 16: { // A16 Set HotEnd temp A17 S170 + const float set_Htemp = atof(&panel_command[5]); + hotend_state = set_Htemp ? AC_heater_temp_set : AC_heater_off; + switch ((char)panel_command[4]) { + // Set Temp + case 'S': case 'C': setTargetTemp_celsius(set_Htemp, E0); + } + } break; + + case 17: { // A17 Set bed temp + const float set_Btemp = atof(&panel_command[5]); + hotbed_state = set_Btemp ? AC_heater_temp_set : AC_heater_off; + if (panel_command[4] == 'S') + setTargetTemp_celsius(set_Btemp, BED); + } break; + + case 18: // A18 Set Fan Speed + if (panel_command[4] == 'S') + setTargetFan_percent(atof(&panel_command[5]), FAN0); + break; + + case 19: // A19 Motors off + if (!isPrinting()) { + disable_all_steppers(); // from marlincore.h + SendtoTFTLN(AC_msg_ready); + } + break; + + case 20: // A20 Read/write print speed + if (panel_command[4] == 'S') + setFeedrate_percent(atoi(&panel_command[5])); + else { + SendtoTFT(PSTR("A20V ")); + TFTSer.println(getFeedrate_percent()); + } + break; + + case 21: // A21 Home Axis A21 X + if (!isPrinting()) { + switch ((char)panel_command[4]) { + case 'X': injectCommands_P(PSTR("G28X")); break; + case 'Y': injectCommands_P(PSTR("G28Y")); break; + case 'Z': injectCommands_P(PSTR("G28Z")); break; + case 'C': injectCommands_P(G28_STR); break; + } + } + break; + + case 22: // A22 Move Axis A22 Y +10F3000 + // Ignore request if printing + if (!isPrinting()) { + // setAxisPosition_mm() uses pre defined manual feedrates so ignore the feedrate from the panel + setSoftEndstopState(true); // enable endstops + float newposition = atof(&panel_command[6]); + + #if ACDEBUG(AC_ACTION) + SERIAL_ECHOLNPAIR("Nudge ", AS_CHAR(panel_command[4]), " axis ", newposition); + #endif + + switch (panel_command[4]) { + case 'X': setAxisPosition_mm(getAxisPosition_mm(X) + newposition, X); break; + case 'Y': setAxisPosition_mm(getAxisPosition_mm(Y) + newposition, Y); break; + case 'Z': setAxisPosition_mm(getAxisPosition_mm(Z) + newposition, Z); break; + case 'E': // The only time we get this command is from the filament load/unload menu + // the standard movement is too slow so we will use the load unlod GCode to speed it up a bit + if (canMove(E0) && !commandsInQueue()) + injectCommands_P(newposition > 0 ? AC_cmnd_manual_load_filament : AC_cmnd_manual_unload_filament); + break; + } + } + break; + + case 23: // A23 Preheat PLA + // Ignore request if printing + if (!isPrinting()) { + // Temps defined in configuration.h + setTargetTemp_celsius(PREHEAT_1_TEMP_BED, BED); + setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, E0); + SendtoTFTLN(); + hotbed_state = AC_heater_temp_set; hotend_state = AC_heater_temp_set; } - else if (strcmp_P(msg, MARLIN_msg_bed_heating) == 0) { - SendtoTFTLN(AC_msg_bed_heating); - hotbed_state = AC_heater_temp_set; - } - } - } + break; - void ChironTFT::PowerLossRecovery() { - printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover. - PlayTune(BEEPER_PIN, SOS, 1); - SERIAL_ECHOLNPGM("Resuming from power outage..."); - SERIAL_ECHOLNPGM("Select SD file then press resume"); - } - - void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel - #if ACDEBUG(AC_SOME) - SERIAL_ECHOPGM_P(str); - #endif - while (const char c = pgm_read_byte(str++)) TFTSer.write(c); - } - - void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) { - if (str) { - #if ACDEBUG(AC_SOME) - SERIAL_ECHOPGM("> "); - #endif - SendtoTFT(str); - #if ACDEBUG(AC_SOME) - SERIAL_EOL(); - #endif - } - TFTSer.println(); - } - - bool ChironTFT::ReadTFTCommand() { - bool command_ready = false; - while (TFTSer.available() > 0 && command_len < MAX_CMND_LEN) { - panel_command[command_len] = TFTSer.read(); - if (panel_command[command_len] == '\n') { - command_ready = true; - break; - } - command_len++; - } - - if (command_ready) { - panel_command[command_len] = 0x00; - #if ACDEBUG(AC_ALL) - SERIAL_ECHOLNPAIR("< ", panel_command); - #endif - #if ACDEBUG(AC_SOME) - // Ignore status request commands - uint8_t req = atoi(&panel_command[1]); - if (req > 7 && req != 20) { - SERIAL_ECHOLNPAIR("> ", panel_command); - SERIAL_ECHOLNPAIR("printer_state:", printer_state); - } - #endif - } - return command_ready; - } - - int8_t ChironTFT::Findcmndpos(const char * buff, char q) { - int8_t pos = 0; - do { if (buff[pos] == q) return pos; } while (++pos < MAX_CMND_LEN); - return -1; - } - - void ChironTFT::CheckHeaters() { - uint8_t faultDuration = 0; - float temp = 0; - - // if the hotend temp is abnormal, confirm state before signalling panel - temp = getActualTemp_celsius(E0); - while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) { - faultDuration++; - if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { - SendtoTFTLN(AC_msg_nozzle_temp_abnormal); - SERIAL_ECHOLNPAIR("Extruder temp abnormal! : ", temp); - break; - } - delay_ms(500); - temp = getActualTemp_celsius(E0); - } - - // If the hotbed temp is abnormal, confirm state before signaling panel - faultDuration = 0; - temp = getActualTemp_celsius(BED); - while (!WITHIN(temp, BED_MINTEMP, BED_MAXTEMP)) { - faultDuration++; - if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { - SendtoTFTLN(AC_msg_nozzle_temp_abnormal); - SERIAL_ECHOLNPAIR("Bed temp abnormal! : ", temp); - break; - } - delay_ms(500); - temp = getActualTemp_celsius(E0); - } - - // Update panel with hotend heater status - if (hotend_state != AC_heater_temp_reached) { - if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -1, 1)) { - SendtoTFTLN(AC_msg_nozzle_heating_done); - hotend_state = AC_heater_temp_reached; - } - } - - // Update panel with bed heater status - if (hotbed_state != AC_heater_temp_reached) { - if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -0.5, 0.5)) { - SendtoTFTLN(AC_msg_bed_heating_done); - hotbed_state = AC_heater_temp_reached; - } - } - } - - void ChironTFT::SendFileList(int8_t startindex) { - // Respond to panel request for 4 files starting at index - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("## SendFileList ## ", startindex); - #endif - SendtoTFTLN(PSTR("FN ")); - filenavigator.getFiles(startindex); - SendtoTFTLN(PSTR("END")); - } - - void ChironTFT::SelectFile() { - strncpy(selectedfile, panel_command + 4, command_len - 4); - selectedfile[command_len - 5] = '\0'; - #if ACDEBUG(AC_FILE) - SERIAL_ECHOLNPAIR_F(" Selected File: ",selectedfile); - #endif - switch (selectedfile[0]) { - case '/': // Valid file selected - SendtoTFTLN(AC_msg_sd_file_open_success); - break; - - case '<': // .. (go up folder level) - filenavigator.upDIR(); - SendtoTFTLN(AC_msg_sd_file_open_failed); - SendFileList( 0 ); - break; - default: // enter sub folder - filenavigator.changeDIR(selectedfile); - SendtoTFTLN(AC_msg_sd_file_open_failed); - SendFileList( 0 ); - break; - } - } - - void ChironTFT::InjectCommandandWait(PGM_P cmd) { - //injectCommands_P(cmnd); queue.enqueue_now_P(cmd); - //SERIAL_ECHOLN(PSTR("Inject>")); - } - - void ChironTFT::ProcessPanelRequest() { - // Break these up into logical blocks // as its easier to navigate than one huge switch case! - int8_t req = atoi(&panel_command[1]); - - // Information requests A0 - A8 and A33 - if (req <= 8 || req == 33) PanelInfo(req); - - // Simple Actions A9 - A28 - else if ( req <= 28) PanelAction(req); - - // Process Initiation - else if (req <= 34) PanelProcess(req); - - else SendtoTFTLN(); - } - - void ChironTFT::PanelInfo(uint8_t req) { - // information requests A0-A8 and A33 - switch (req) { - case 0: // A0 Get HOTEND Temp - SendtoTFT(PSTR("A0V ")); - TFTSer.println(getActualTemp_celsius(E0)); - break; - - case 1: // A1 Get HOTEND Target Temp - SendtoTFT(PSTR("A1V ")); - TFTSer.println(getTargetTemp_celsius(E0)); - break; - - case 2: // A2 Get BED Temp - SendtoTFT(PSTR("A2V ")); - TFTSer.println(getActualTemp_celsius(BED)); - break; - - case 3: // A3 Get BED Target Temp - SendtoTFT(PSTR("A3V ")); - TFTSer.println(getTargetTemp_celsius(BED)); - break; - - case 4: // A4 Get FAN Speed - SendtoTFT(PSTR("A4V ")); - TFTSer.println(getActualFan_percent(FAN0)); - break; - - case 5: // A5 Get Current Coordinates - SendtoTFT(PSTR("A5V X: ")); - TFTSer.print(getAxisPosition_mm(X)); - SendtoTFT(PSTR(" Y: ")); - TFTSer.print(getAxisPosition_mm(Y)); - SendtoTFT(PSTR(" Z: ")); - TFTSer.println(getAxisPosition_mm(Z)); - break; - - case 6: // A6 Get printing progress - if (isPrintingFromMedia()) { - SendtoTFT(PSTR("A6V ")); - TFTSer.println(ui8tostr2(getProgress_percent())); - } - else - SendtoTFTLN(PSTR("A6V ---")); - break; - - case 7: { // A7 Get Printing Time - uint32_t time = getProgress_seconds_elapsed() / 60; - SendtoTFT(PSTR("A7V ")); - TFTSer.print(ui8tostr2(time / 60)); - SendtoTFT(PSTR(" H ")); - TFTSer.print(ui8tostr2(time % 60)); - SendtoTFT(PSTR(" M")); - #if ACDEBUG(AC_ALL) - SERIAL_ECHOLNPAIR("Print time ", ui8tostr2(time / 60), ":", ui8tostr2(time % 60)); - #endif - } break; - - case 8: // A8 Get SD Card list A8 S0 - if (!isMediaInserted()) safe_delay(500); - if (!isMediaInserted()) // Make sure the card is removed - SendtoTFTLN(AC_msg_no_sd_card); - else if (panel_command[3] == 'S') - SendFileList( atoi( &panel_command[4] ) ); - break; - - case 33: // A33 Get firmware info - SendtoTFT(PSTR("J33 ")); - SendtoTFTLN(PSTR(SHORT_BUILD_VERSION)); - break; - } - } - - void ChironTFT::PanelAction(uint8_t req) { - switch (req) { - case 9: // A9 Pause SD print - if (isPrintingFromMedia()) { - SendtoTFTLN(AC_msg_pause); - pausePrint(); - printer_state = AC_printer_pausing; - } - else - SendtoTFTLN(AC_msg_stop); - break; - - case 10: // A10 Resume SD Print - if (pause_state == AC_paused_idle || printer_state == AC_printer_resuming_from_power_outage) - resumePrint(); - else - setUserConfirmed(); - break; - - case 11: // A11 Stop SD print - if (isPrintingFromMedia()) { - printer_state = AC_printer_stopping; - stopPrint(); - } - else { - if (printer_state == AC_printer_resuming_from_power_outage) - injectCommands_P(PSTR("M1000 C")); // Cancel recovery - SendtoTFTLN(AC_msg_stop); - printer_state = AC_printer_idle; - } - break; - - case 12: // A12 Kill printer - kill(); // from marlincore.h - break; - - case 13: // A13 Select file - SelectFile(); - break; - - case 14: { // A14 Start Printing - // Allows printer to restart the job if we dont want to recover - if (printer_state == AC_printer_resuming_from_power_outage) { - injectCommands_P(PSTR("M1000 C")); // Cancel recovery - printer_state = AC_printer_idle; - } - #if ACDebugLevel >= 1 - SERIAL_ECHOLNPAIR_F("Print: ", selectedfile); - #endif - // the card library needs a path starting // but the File api doesn't... - char file[MAX_PATH_LEN]; - file[0] = '/'; - strcpy(file + 1, selectedfile); - printFile(file); - SendtoTFTLN(AC_msg_print_from_sd_card); - } break; - - case 15: // A15 Resuming from outage - if (printer_state == AC_printer_resuming_from_power_outage) { - // Need to home here to restore the Z position - injectCommands_P(AC_cmnd_power_loss_recovery); - injectCommands_P(PSTR("M1000")); // home and start recovery - } - break; - - case 16: { // A16 Set HotEnd temp A17 S170 - const float set_Htemp = atof(&panel_command[5]); - hotend_state = set_Htemp ? AC_heater_temp_set : AC_heater_off; - switch ((char)panel_command[4]) { - // Set Temp - case 'S': case 'C': setTargetTemp_celsius(set_Htemp, E0); - } - } break; - - case 17: { // A17 Set bed temp - const float set_Btemp = atof(&panel_command[5]); - hotbed_state = set_Btemp ? AC_heater_temp_set : AC_heater_off; - if (panel_command[4] == 'S') - setTargetTemp_celsius(set_Btemp, BED); - } break; - - case 18: // A18 Set Fan Speed - if (panel_command[4] == 'S') - setTargetFan_percent(atof(&panel_command[5]), FAN0); - break; - - case 19: // A19 Motors off - if (!isPrinting()) { - disable_all_steppers(); // from marlincore.h - SendtoTFTLN(AC_msg_ready); - } - break; - - case 20: // A20 Read/write print speed - if (panel_command[4] == 'S') - setFeedrate_percent(atoi(&panel_command[5])); - else { - SendtoTFT(PSTR("A20V ")); - TFTSer.println(getFeedrate_percent()); - } - break; - - case 21: // A21 Home Axis A21 X - if (!isPrinting()) { - switch ((char)panel_command[4]) { - case 'X': injectCommands_P(PSTR("G28X")); break; - case 'Y': injectCommands_P(PSTR("G28Y")); break; - case 'Z': injectCommands_P(PSTR("G28Z")); break; - case 'C': injectCommands_P(G28_STR); break; - } - } - break; - - case 22: // A22 Move Axis A22 Y +10F3000 - // Ignore request if printing - if (!isPrinting()) { - // setAxisPosition_mm() uses pre defined manual feedrates so ignore the feedrate from the panel - setSoftEndstopState(true); // enable endstops - float newposition = atof(&panel_command[6]); - - #if ACDEBUG(AC_ACTION) - SERIAL_ECHOLNPAIR("Nudge ", AS_CHAR(panel_command[4]), " axis ", newposition); - #endif - - switch (panel_command[4]) { - case 'X': setAxisPosition_mm(getAxisPosition_mm(X) + newposition, X); break; - case 'Y': setAxisPosition_mm(getAxisPosition_mm(Y) + newposition, Y); break; - case 'Z': setAxisPosition_mm(getAxisPosition_mm(Z) + newposition, Z); break; - case 'E': // The only time we get this command is from the filament load/unload menu - // the standard movement is too slow so we will use the load unlod GCode to speed it up a bit - if (canMove(E0) && !commandsInQueue()) - injectCommands_P(newposition > 0 ? AC_cmnd_manual_load_filament : AC_cmnd_manual_unload_filament); - break; - } - } - break; - - case 23: // A23 Preheat PLA - // Ignore request if printing - if (!isPrinting()) { - // Temps defined in configuration.h - setTargetTemp_celsius(PREHEAT_1_TEMP_BED, BED); - setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, E0); - SendtoTFTLN(); - hotbed_state = AC_heater_temp_set; - hotend_state = AC_heater_temp_set; - } - break; - - case 24: // A24 Preheat ABS - // Ignore request if printing - if (!isPrinting()) { - setTargetTemp_celsius(PREHEAT_2_TEMP_BED, BED); - setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, E0); - SendtoTFTLN(); - hotbed_state = AC_heater_temp_set; - hotend_state = AC_heater_temp_set; - } - break; - - case 25: // A25 Cool Down - // Ignore request if printing - if (!isPrinting()) { - setTargetTemp_celsius(0, E0); - setTargetTemp_celsius(0, BED); - SendtoTFTLN(AC_msg_ready); - hotbed_state = AC_heater_off; - hotend_state = AC_heater_off; - } - break; - - case 26: // A26 Refresh SD - // M22 M21 maybe needed here to reset sd card - filenavigator.reset(); - break; - - case 27: // A27 Servo Angles adjust - break; - - case 28: // A28 Filament set A28 O/C - // Ignore request if printing - if (isPrinting()) break; + case 24: // A24 Preheat ABS + // Ignore request if printing + if (!isPrinting()) { + setTargetTemp_celsius(PREHEAT_2_TEMP_BED, BED); + setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, E0); SendtoTFTLN(); - break; - } - } + hotbed_state = AC_heater_temp_set; + hotend_state = AC_heater_temp_set; + } + break; - void ChironTFT::PanelProcess(uint8_t req) { - switch (req) { - case 29: { // A29 Read Mesh Point A29 X1 Y1 + case 25: // A25 Cool Down + // Ignore request if printing + if (!isPrinting()) { + setTargetTemp_celsius(0, E0); + setTargetTemp_celsius(0, BED); + SendtoTFTLN(AC_msg_ready); + hotbed_state = AC_heater_off; + hotend_state = AC_heater_off; + } + break; + + case 26: // A26 Refresh SD + // M22 M21 maybe needed here to reset sd card + filenavigator.reset(); + break; + + case 27: // A27 Servo Angles adjust + break; + + case 28: // A28 Filament set A28 O/C + // Ignore request if printing + if (isPrinting()) break; + SendtoTFTLN(); + break; + } +} + +void ChironTFT::PanelProcess(uint8_t req) { + switch (req) { + case 29: { // A29 Read Mesh Point A29 X1 Y1 + xy_uint8_t pos; + float pos_z; + pos.x = atoi(&panel_command[5]); + pos.y = atoi(&panel_command[8]); + pos_z = getMeshPoint(pos); + + SendtoTFT(PSTR("A29V ")); + TFTSer.println(pos_z * 100); + if (!isPrinting()) { + setSoftEndstopState(true); // disable endstops + // If the same meshpoint is selected twice in a row, move the head to that ready for adjustment + if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) { + if (!isPositionKnown()) + injectCommands_P(G28_STR); // home + + if (isPositionKnown()) { + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Moving to mesh point at x: ", pos.x, " y: ", pos.y, " z: ", pos_z); + #endif + // Go up before moving + setAxisPosition_mm(3.0,Z); + + setAxisPosition_mm(17 + (93 * pos.x), X); + setAxisPosition_mm(20 + (93 * pos.y), Y); + setAxisPosition_mm(0.0, Z); + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Current Z: ", getAxisPosition_mm(Z)); + #endif + } + } + selectedmeshpoint.x = pos.x; + selectedmeshpoint.y = pos.y; + } + } break; + + case 30: { // A30 Auto leveling + if (panel_command[3] == 'S') { // Start probing + // Ignore request if printing + if (isPrinting()) + SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling + else { + injectCommands_P(PSTR("G28O\nG29")); + printer_state = AC_printer_probing; + SendtoTFTLN(AC_msg_start_probing); + } + } + else SendtoTFTLN(AC_msg_start_probing); + } break; + + case 31: { // A31 Adjust all Probe Points + switch (panel_command[3]) { + case 'C': // Restore and apply original offsets + if (!isPrinting()) { + injectCommands_P(PSTR("M501\nM420 S1")); + selectedmeshpoint.x = selectedmeshpoint.y = 99; + } + break; + case 'D': // Save Z Offset tables and restore leveling state + if (!isPrinting()) { + setAxisPosition_mm(1.0,Z); + injectCommands_P(PSTR("M500")); + selectedmeshpoint.x = selectedmeshpoint.y = 99; + } + break; + case 'G': // Get current offset + SendtoTFT(PSTR("A31V ")); + // When printing use the live z Offset position + // we will use babystepping to move the print head + if (isPrinting()) + TFTSer.println(live_Zoffset); + else { + TFTSer.println(getZOffset_mm()); + selectedmeshpoint.x = selectedmeshpoint.y = 99; + } + break; + case 'S': { // Set offset (adjusts all points by value) + float Zshift = atof(&panel_command[4]); + setSoftEndstopState(false); // disable endstops + // Allow temporary Z position nudging during print + // From the leveling panel use the all points UI to adjust the print pos. + if (isPrinting()) { + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Change Zoffset from:", live_Zoffset, " to ", live_Zoffset + Zshift); + #endif + if (isAxisPositionKnown(Z)) { + #if ACDEBUG(AC_INFO) + const float currZpos = getAxisPosition_mm(Z); + SERIAL_ECHOLNPAIR("Nudge Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05)); + #endif + // Use babystepping to adjust the head position + int16_t steps = mmToWholeSteps(constrain(Zshift,-0.05,0.05), Z); + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Steps to move Z: ", steps); + #endif + babystepAxis_steps(steps, Z); + live_Zoffset += Zshift; + } + SendtoTFT(PSTR("A31V ")); + TFTSer.println(live_Zoffset); + } + else { + GRID_LOOP(x, y) { + const xy_uint8_t pos { x, y }; + const float currval = getMeshPoint(pos); + setMeshPoint(pos, constrain(currval + Zshift, AC_LOWEST_MESHPOINT_VAL, 2)); + } + const float currZOffset = getZOffset_mm(); + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Change probe offset from ", currZOffset, " to ", currZOffset + Zshift); + #endif + + setZOffset_mm(currZOffset + Zshift); + SendtoTFT(PSTR("A31V ")); + TFTSer.println(getZOffset_mm()); + + if (isAxisPositionKnown(Z)) { + // Move Z axis + const float currZpos = getAxisPosition_mm(Z); + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Move Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05)); + #endif + setAxisPosition_mm(currZpos+constrain(Zshift,-0.05,0.05),Z); + } + } + } + } + } break; + + case 32: { // A32 clean leveling beep flag + // Ignore request if printing + //if (isPrinting()) break; + //injectCommands_P(PSTR("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000")); + //TFTSer.println(); + } break; + + // A33 firmware info request see PanelInfo() + + case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123 + if (panel_command[3] == 'C') { // Restore original offsets + injectCommands_P(PSTR("M501\nM420 S1")); + selectedmeshpoint.x = selectedmeshpoint.y = 99; + //printer_state = AC_printer_idle; + } + else { xy_uint8_t pos; - float pos_z; pos.x = atoi(&panel_command[5]); pos.y = atoi(&panel_command[8]); - pos_z = getMeshPoint(pos); - SendtoTFT(PSTR("A29V ")); - TFTSer.println(pos_z * 100); - if (!isPrinting()) { - setSoftEndstopState(true); // disable endstops - // If the same meshpoint is selected twice in a row, move the head to that ready for adjustment - if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) { - if (!isPositionKnown()) - injectCommands_P(G28_STR); // home - - if (isPositionKnown()) { - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("Moving to mesh point at x: ", pos.x, " y: ", pos.y, " z: ", pos_z); - #endif - // Go up before moving - setAxisPosition_mm(3.0,Z); - - setAxisPosition_mm(17 + (93 * pos.x), X); - setAxisPosition_mm(20 + (93 * pos.y), Y); - setAxisPosition_mm(0.0, Z); - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("Current Z: ", getAxisPosition_mm(Z)); - #endif - } - } - selectedmeshpoint.x = pos.x; - selectedmeshpoint.y = pos.y; - } - } break; - - case 30: { // A30 Auto leveling - if (panel_command[3] == 'S') { // Start probing - // Ignore request if printing - if (isPrinting()) - SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling - else { - injectCommands_P(PSTR("G28O\nG29")); - printer_state = AC_printer_probing; - SendtoTFTLN(AC_msg_start_probing); + float currmesh = getMeshPoint(pos); + float newval = atof(&panel_command[11])/100; + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Change mesh point x:", pos.x, " y:", pos.y); + SERIAL_ECHOLNPAIR("from ", currmesh, " to ", newval); + #endif + // Update Meshpoint + setMeshPoint(pos,newval); + if (printer_state == AC_printer_idle || printer_state == AC_printer_probing /*!isPrinting()*/) { + // if we are at the current mesh point indicated on the panel Move Z pos +/- 0.05mm + // (The panel changes the mesh value by +/- 0.05mm on each button press) + if (selectedmeshpoint.x == pos.x && selectedmeshpoint.y == pos.y) { + setSoftEndstopState(false); + float currZpos = getAxisPosition_mm(Z); + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Move Z pos from ", currZpos, " to ", currZpos + constrain(newval - currmesh, -0.05, 0.05)); + #endif + setAxisPosition_mm(currZpos + constrain(newval - currmesh, -0.05, 0.05), Z); } } - else SendtoTFTLN(AC_msg_start_probing); - } break; - - case 31: { // A31 Adjust all Probe Points - switch (panel_command[3]) { - case 'C': // Restore and apply original offsets - if (!isPrinting()) { - injectCommands_P(PSTR("M501\nM420 S1")); - selectedmeshpoint.x = selectedmeshpoint.y = 99; - } - break; - case 'D': // Save Z Offset tables and restore leveling state - if (!isPrinting()) { - setAxisPosition_mm(1.0,Z); - injectCommands_P(PSTR("M500")); - selectedmeshpoint.x = selectedmeshpoint.y = 99; - } - break; - case 'G': // Get current offset - SendtoTFT(PSTR("A31V ")); - // When printing use the live z Offset position - // we will use babystepping to move the print head - if (isPrinting()) - TFTSer.println(live_Zoffset); - else { - TFTSer.println(getZOffset_mm()); - selectedmeshpoint.x = selectedmeshpoint.y = 99; - } - break; - case 'S': { // Set offset (adjusts all points by value) - float Zshift = atof(&panel_command[4]); - setSoftEndstopState(false); // disable endstops - // Allow temporary Z position nudging during print - // From the leveling panel use the all points UI to adjust the print pos. - if (isPrinting()) { - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("Change Zoffset from:", live_Zoffset, " to ", live_Zoffset + Zshift); - #endif - if (isAxisPositionKnown(Z)) { - #if ACDEBUG(AC_INFO) - const float currZpos = getAxisPosition_mm(Z); - SERIAL_ECHOLNPAIR("Nudge Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05)); - #endif - // Use babystepping to adjust the head position - int16_t steps = mmToWholeSteps(constrain(Zshift,-0.05,0.05), Z); - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("Steps to move Z: ", steps); - #endif - babystepAxis_steps(steps, Z); - live_Zoffset += Zshift; - } - SendtoTFT(PSTR("A31V ")); - TFTSer.println(live_Zoffset); - } - else { - GRID_LOOP(x, y) { - const xy_uint8_t pos { x, y }; - const float currval = getMeshPoint(pos); - setMeshPoint(pos, constrain(currval + Zshift, AC_LOWEST_MESHPOINT_VAL, 2)); - } - const float currZOffset = getZOffset_mm(); - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("Change probe offset from ", currZOffset, " to ", currZOffset + Zshift); - #endif - - setZOffset_mm(currZOffset + Zshift); - SendtoTFT(PSTR("A31V ")); - TFTSer.println(getZOffset_mm()); - - if (isAxisPositionKnown(Z)) { - // Move Z axis - const float currZpos = getAxisPosition_mm(Z); - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("Move Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05)); - #endif - setAxisPosition_mm(currZpos+constrain(Zshift,-0.05,0.05),Z); - } - } - } break; - } // end switch - } break; - - case 32: { // A32 clean leveling beep flag - // Ignore request if printing - //if (isPrinting()) break; - //injectCommands_P(PSTR("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000")); - //TFTSer.println(); - } break; - - // A33 firmware info request seet PanelInfo() - - case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123 - if (panel_command[3] == 'C') { // Restore original offsets - injectCommands_P(PSTR("M501\nM420 S1")); - selectedmeshpoint.x = selectedmeshpoint.y = 99; - //printer_state = AC_printer_idle; - } - else { - xy_uint8_t pos; - pos.x = atoi(&panel_command[5]); - pos.y = atoi(&panel_command[8]); - - float currmesh = getMeshPoint(pos); - float newval = atof(&panel_command[11])/100; - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("Change mesh point x:", pos.x, " y:", pos.y); - SERIAL_ECHOLNPAIR("from ", currmesh, " to ", newval); - #endif - // Update Meshpoint - setMeshPoint(pos,newval); - if (printer_state == AC_printer_idle || printer_state == AC_printer_probing /*!isPrinting()*/) { - // if we are at the current mesh point indicated on the panel Move Z pos +/- 0.05mm - // (The panel changes the mesh value by +/- 0.05mm on each button press) - if (selectedmeshpoint.x == pos.x && selectedmeshpoint.y == pos.y) { - setSoftEndstopState(false); - float currZpos = getAxisPosition_mm(Z); - #if ACDEBUG(AC_INFO) - SERIAL_ECHOLNPAIR("Move Z pos from ", currZpos, " to ", currZpos + constrain(newval - currmesh, -0.05, 0.05)); - #endif - setAxisPosition_mm(currZpos + constrain(newval - currmesh, -0.05, 0.05), Z); - } - } - } - } break; - } + } + } break; } +} } // Anycubic diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h index e7bbd3cbbf..3c26cc0aec 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h @@ -35,46 +35,46 @@ namespace Anycubic { - class ChironTFT { - private: - static printer_state_t printer_state; - static paused_state_t pause_state; - static heater_state_t hotend_state; - static heater_state_t hotbed_state; - static xy_uint8_t selectedmeshpoint; - static char panel_command[MAX_CMND_LEN]; - static uint8_t command_len; - static char selectedfile[MAX_PATH_LEN]; - static float live_Zoffset; - static file_menu_t file_menu; +class ChironTFT { + private: + static printer_state_t printer_state; + static paused_state_t pause_state; + static heater_state_t hotend_state; + static heater_state_t hotbed_state; + static xy_uint8_t selectedmeshpoint; + static char panel_command[MAX_CMND_LEN]; + static uint8_t command_len; + static char selectedfile[MAX_PATH_LEN]; + static float live_Zoffset; + static file_menu_t file_menu; - public: - ChironTFT(); - static void Startup(); - static void IdleLoop(); - static void PrinterKilled(PGM_P,PGM_P); - static void MediaEvent(media_event_t); - static void TimerEvent(timer_event_t); - static void FilamentRunout(); - static void ConfirmationRequest(const char * const ); - static void StatusChange(const char * const ); - static void PowerLossRecovery(); + public: + ChironTFT(); + static void Startup(); + static void IdleLoop(); + static void PrinterKilled(PGM_P,PGM_P); + static void MediaEvent(media_event_t); + static void TimerEvent(timer_event_t); + static void FilamentRunout(); + static void ConfirmationRequest(const char * const ); + static void StatusChange(const char * const ); + static void PowerLossRecovery(); - private: - static void SendtoTFT(PGM_P); - static void SendtoTFTLN(PGM_P); - static bool ReadTFTCommand(); - static int8_t Findcmndpos(const char *, char); - static void CheckHeaters(); - static void SendFileList(int8_t); - static void SelectFile(); - static void InjectCommandandWait(PGM_P); - static void ProcessPanelRequest(); - static void PanelInfo(uint8_t); - static void PanelAction(uint8_t); - static void PanelProcess(uint8_t); - }; + private: + static void SendtoTFT(PGM_P); + static void SendtoTFTLN(PGM_P); + static bool ReadTFTCommand(); + static int8_t Findcmndpos(const char *, char); + static void CheckHeaters(); + static void SendFileList(int8_t); + static void SelectFile(); + static void InjectCommandandWait(PGM_P); + static void ProcessPanelRequest(); + static void PanelInfo(uint8_t); + static void PanelAction(uint8_t); + static void PanelProcess(uint8_t); +}; - extern ChironTFT Chiron; +extern ChironTFT Chiron; } // Anycubic diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h index 3087d83801..a8ebe9c776 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h @@ -109,19 +109,16 @@ #define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position namespace Anycubic { - enum heater_state_t : uint8_t { AC_heater_off, AC_heater_temp_set, AC_heater_temp_reached }; - enum paused_state_t : uint8_t { AC_paused_heater_timed_out, AC_paused_purging_filament, AC_paused_idle }; - enum printer_state_t : uint8_t { AC_printer_idle, AC_printer_probing, @@ -131,13 +128,11 @@ namespace Anycubic { AC_printer_stopping, AC_printer_resuming_from_power_outage }; - enum timer_event_t : uint8_t { AC_timer_started, AC_timer_paused, AC_timer_stopped }; - enum media_event_t : uint8_t { AC_media_inserted, AC_media_removed, @@ -149,5 +144,4 @@ namespace Anycubic { AC_menu_change_to_file, AC_menu_change_to_command }; - } // Anycubic From d705a5b45efa4c7a47650fc2c187ff1d025db8fa Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 13 Apr 2021 23:22:57 -0500 Subject: [PATCH 218/311] Fix long acceleration overflow --- Marlin/src/module/planner.cpp | 23 +++++++++++------------ Marlin/src/module/planner.h | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index d6356432e7..b528eb9d3b 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -207,7 +207,7 @@ skew_factor_t Planner::skew_factor; // Initialized by settings.load() xyze_long_t Planner::position{0}; -uint32_t Planner::cutoff_long; +uint32_t Planner::acceleration_long_cutoff; xyze_float_t Planner::previous_speed; float Planner::previous_nominal_speed_sqr; @@ -2271,23 +2271,22 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Compute and limit the acceleration rate for the trapezoid generator. const float steps_per_mm = block->step_event_count * inverse_millimeters; uint32_t accel; - if (!block->steps.a && !block->steps.b && !block->steps.c) { - // convert to: acceleration steps/sec^2 - accel = CEIL(settings.retract_acceleration * steps_per_mm); - TERN_(LIN_ADVANCE, block->use_advance_lead = false); + if (!block->steps.a && !block->steps.b && !block->steps.c) { // Is this a retract / recover move? + accel = CEIL(settings.retract_acceleration * steps_per_mm); // Convert to: acceleration steps/sec^2 + TERN_(LIN_ADVANCE, block->use_advance_lead = false); // No linear advance for simple retract/recover } else { #define LIMIT_ACCEL_LONG(AXIS,INDX) do{ \ if (block->steps[AXIS] && max_acceleration_steps_per_s2[AXIS+INDX] < accel) { \ - const uint32_t comp = max_acceleration_steps_per_s2[AXIS+INDX] * block->step_event_count; \ - if (accel * block->steps[AXIS] > comp) accel = comp / block->steps[AXIS]; \ + const uint32_t max_possible = max_acceleration_steps_per_s2[AXIS+INDX] * block->step_event_count / block->steps[AXIS]; \ + NOMORE(accel, max_possible); \ } \ }while(0) #define LIMIT_ACCEL_FLOAT(AXIS,INDX) do{ \ if (block->steps[AXIS] && max_acceleration_steps_per_s2[AXIS+INDX] < accel) { \ - const float comp = (float)max_acceleration_steps_per_s2[AXIS+INDX] * (float)block->step_event_count; \ - if ((float)accel * (float)block->steps[AXIS] > comp) accel = comp / (float)block->steps[AXIS]; \ + const float max_possible = float(max_acceleration_steps_per_s2[AXIS+INDX]) * float(block->step_event_count) / float(block->steps[AXIS]); \ + NOMORE(accel, max_possible); \ } \ }while(0) @@ -2336,7 +2335,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif // Limit acceleration per axis - if (block->step_event_count <= cutoff_long) { + if (block->step_event_count <= acceleration_long_cutoff) { LIMIT_ACCEL_LONG(A_AXIS, 0); LIMIT_ACCEL_LONG(B_AXIS, 0); LIMIT_ACCEL_LONG(C_AXIS, 0); @@ -2352,7 +2351,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->acceleration_steps_per_s2 = accel; block->acceleration = accel / steps_per_mm; #if DISABLED(S_CURVE_ACCELERATION) - block->acceleration_rate = (uint32_t)(accel * (4096.0f * 4096.0f / (STEPPER_TIMER_RATE))); + block->acceleration_rate = (uint32_t)(accel * (sq(4096.0f) / (STEPPER_TIMER_RATE))); #endif #if ENABLED(LIN_ADVANCE) if (block->use_advance_lead) { @@ -3020,7 +3019,7 @@ void Planner::reset_acceleration_rates() { max_acceleration_steps_per_s2[i] = settings.max_acceleration_mm_per_s2[i] * settings.axis_steps_per_mm[i]; if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]); } - cutoff_long = 4294967295UL / highest_rate; // 0xFFFFFFFFUL + acceleration_long_cutoff = 4294967295UL / highest_rate; // 0xFFFFFFFFUL TERN_(HAS_LINEAR_E_JERK, recalculate_max_e_jerk()); } diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index d4ed00d2fa..398339f04e 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -443,7 +443,7 @@ class Planner { /** * Limit where 64bit math is necessary for acceleration calculation */ - static uint32_t cutoff_long; + static uint32_t acceleration_long_cutoff; #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) static float last_fade_z; From 1595fdb54b1f10f2e3e01393d6b7aceb09f96b6d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 13 Apr 2021 23:23:06 -0500 Subject: [PATCH 219/311] Use sq --- Marlin/src/module/scara.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index cc177f76c2..e058804c90 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -204,7 +204,7 @@ float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SE y = r * sin(RADIANS(a)), rho2 = L1_2 + L2_2 - 2.0f * L1 * L2 * cos(RADIANS(w)); - cartes = robot_offset + xyz_pos_t({ x, y, SQRT(rho2 - x * x - y * y) }); + cartes = robot_offset + xyz_pos_t({ x, y, SQRT(rho2 - sq(x) - sq(y)) }); } // Home YZ together, then X (or all at once). Based on quick_home_xy & home_delta From cc5297d637d2a0a784e336210c366baf250785d0 Mon Sep 17 00:00:00 2001 From: XDA-Bam <1209896+XDA-Bam@users.noreply.github.com> Date: Wed, 14 Apr 2021 11:42:04 +0200 Subject: [PATCH 220/311] Space-separate scrolling Status Message (#21523) Co-authored-by: Scott Lahteine --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 13 ++++++++----- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 13 ++++++++----- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 13 ++++++++----- Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp | 13 ++++++++----- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 57af2b782a..0444c9e185 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -684,12 +684,15 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < LCD_WIDTH) { - lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - if (--chars) { // Draw a second dot if there's space - lcd_put_wchar('.'); - if (--chars) - lcd_put_u8str_max(status_message, chars); // Print a second copy of the message + lcd_put_wchar(' '); // Always at 1+ spaces left, draw a space + if (--chars) { // Draw a second space if there's room + lcd_put_wchar(' '); + if (--chars) { // Draw a third space if there's room + lcd_put_wchar(' '); + if (--chars) + lcd_put_u8str_max(status_message, chars); // Print a second copy of the message + } } } if (last_blink != blink) { diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 5b48cb1ac8..6edde2c604 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -581,12 +581,15 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < LCD_WIDTH) { - lcd.write('.'); // Always at 1+ spaces left, draw a dot uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - if (--chars) { // Draw a second dot if there's space - lcd.write('.'); - if (--chars) - lcd_put_u8str_max(status_message, chars); // Print a second copy of the message + lcd.write(' '); // Always at 1+ spaces left, draw a space + if (--chars) { // Draw a second space if there's room + lcd.write(' '); + if (--chars) { // Draw a third space if there's room + lcd.write(' '); + if (--chars) + lcd_put_u8str_max(status_message, chars); // Print a second copy of the message + } } } if (last_blink != blink) { diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 119de19d9d..e2bffb7fe0 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -959,13 +959,16 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < lcd_width) { - lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot uint8_t chars = lcd_width - rlen; // Amount of space left in characters - if (--chars) { // Draw a second dot if there's space - lcd_put_wchar('.'); - if (--chars) { // Print a second copy of the message - lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH)); + lcd_put_wchar(' '); // Always at 1+ spaces left, draw a space + if (--chars) { // Draw a second space if there's room + lcd_put_wchar(' '); + if (--chars) { // Draw a third space if there's room lcd_put_wchar(' '); + if (--chars) { // Print a second copy of the message + lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH)); + lcd_put_wchar(' '); + } } } } diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index b67688cb57..b8257d32ff 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -642,11 +642,14 @@ void ST7920_Lite_Status_Screen::draw_status_message() { // If the remaining string doesn't completely fill the screen if (rlen < TEXT_MODE_LCD_WIDTH) { - write_byte('.'); // Always at 1+ spaces left, draw a dot - uint8_t chars = TEXT_MODE_LCD_WIDTH - rlen; // Amount of space left in characters - if (--chars) { // Draw a second dot if there's space - write_byte('.'); - if (--chars) write_str(str, chars); // Print a second copy of the message + uint8_t chars = TEXT_MODE_LCD_WIDTH - rlen; // Amount of space left in characters + write_byte(' '); // Always at 1+ spaces left, draw a space + if (--chars) { // Draw a second space if there's room + write_byte(' '); + if (--chars) { // Draw a third space if there's room + write_byte(' '); + if (--chars) write_str(str, chars); // Print a second copy of the message + } } } ui.advance_status_scroll(); From 0561d5bea3ee7774d0b63cf505005afdb56b644a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 14 Apr 2021 05:54:12 -0500 Subject: [PATCH 221/311] Add E1 for RAMPS 1.4.4 / AGC --- Marlin/src/pins/samd/pins_RAMPS_144.h | 65 +++++++-------------------- 1 file changed, 17 insertions(+), 48 deletions(-) diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 7a72ef651f..8311ac9012 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -89,13 +89,6 @@ #define Z_CS_PIN 32 #endif -#define Z2_STEP_PIN 36 -#define Z2_DIR_PIN 34 -#define Z2_ENABLE_PIN 30 -#ifndef Z2_CS_PIN - #define Z2_CS_PIN 22 -#endif - #define E0_STEP_PIN 26 #define E0_DIR_PIN 28 #define E0_ENABLE_PIN 24 @@ -103,18 +96,33 @@ #define E0_CS_PIN 43 #endif +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 +#ifndef E1_CS_PIN + #define E1_CS_PIN 22 +#endif + // // Temperature Sensors // #define TEMP_0_PIN 13 -#define TEMP_BED_PIN 14 +#if TEMP_SENSOR_BED + #define TEMP_BED_PIN 14 +#else + #define TEMP_1_PIN 14 +#endif #define TEMP_CHAMBER_PIN 15 // // Heaters / Fans // #define HEATER_0_PIN 10 -#define HEATER_BED_PIN 8 +#if TEMP_SENSOR_BED + #define HEATER_BED_PIN 8 +#else + #define HEATER_1_PIN 8 +#endif #define FAN_PIN 9 #define FAN1_PIN 7 #define FAN2_PIN 12 @@ -186,9 +194,6 @@ //#define Z2_HARDWARE_SERIAL Serial1 //#define E0_HARDWARE_SERIAL Serial1 //#define E1_HARDWARE_SERIAL Serial1 - //#define E2_HARDWARE_SERIAL Serial1 - //#define E3_HARDWARE_SERIAL Serial1 - //#define E4_HARDWARE_SERIAL Serial1 // // Software serial @@ -245,42 +250,6 @@ #ifndef E1_SERIAL_RX_PIN #define E1_SERIAL_RX_PIN -1 #endif - #ifndef E2_SERIAL_TX_PIN - #define E2_SERIAL_TX_PIN -1 - #endif - #ifndef E2_SERIAL_RX_PIN - #define E2_SERIAL_RX_PIN -1 - #endif - #ifndef E3_SERIAL_TX_PIN - #define E3_SERIAL_TX_PIN -1 - #endif - #ifndef E3_SERIAL_RX_PIN - #define E3_SERIAL_RX_PIN -1 - #endif - #ifndef E4_SERIAL_TX_PIN - #define E4_SERIAL_TX_PIN -1 - #endif - #ifndef E4_SERIAL_RX_PIN - #define E4_SERIAL_RX_PIN -1 - #endif - #ifndef E5_SERIAL_TX_PIN - #define E5_SERIAL_TX_PIN -1 - #endif - #ifndef E5_SERIAL_RX_PIN - #define E5_SERIAL_RX_PIN -1 - #endif - #ifndef E6_SERIAL_TX_PIN - #define E6_SERIAL_TX_PIN -1 - #endif - #ifndef E6_SERIAL_RX_PIN - #define E6_SERIAL_RX_PIN -1 - #endif - #ifndef E7_SERIAL_TX_PIN - #define E7_SERIAL_TX_PIN -1 - #endif - #ifndef E7_SERIAL_RX_PIN - #define E7_SERIAL_RX_PIN -1 - #endif #endif ////////////////////////// From 2d8ee3a496fc3e7b6edaa925a3b087ad5074f2ee Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 15 Apr 2021 00:34:28 +0000 Subject: [PATCH 222/311] [cron] Bump distribution date (2021-04-15) --- 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 568897ef95..9e7cbe454c 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-04-14" + #define STRING_DISTRIBUTION_DATE "2021-04-15" #endif /** From 63673d3ce088935d8f4931698df627fc916e458c Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 15 Apr 2021 11:37:37 +0200 Subject: [PATCH 223/311] Fix Custom Menu audio and return (#21616) --- Marlin/src/lcd/menu/menu_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 525b8c8a70..34d1d6c6f4 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -105,8 +105,8 @@ void menu_configuration(); void _lcd_custom_menu_main_gcode(PGM_P const cmd) { queue.inject_P(cmd); - TERN_(MAIN_MENU_ITEM_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); - TERN_(MAIN_MENU_ITEM_SCRIPT_RETURN, ui.return_to_status()); + TERN_(CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); + TERN_(CUSTOM_MENU_MAIN_SCRIPT_RETURN, ui.return_to_status()); } void custom_menus_main() { From 3cdf363cceda864d9ca4e48b2328adc474fe14fa Mon Sep 17 00:00:00 2001 From: Sola <42537573+solawc@users.noreply.github.com> Date: Thu, 15 Apr 2021 17:45:30 +0800 Subject: [PATCH 224/311] Fix MKS H43 compile (#21619) --- Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp | 11 +++++++---- .../src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp index 01c3adbda7..667442b31c 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp @@ -72,20 +72,23 @@ void MKS_reset_settings() { } xyz_pos_t position_before_pause; +constexpr feedRate_t park_speed_xy = TERN(NOZZLE_PARK_FEATURE, NOZZLE_PARK_XY_FEEDRATE, 100), + park_speed_z = TERN(NOZZLE_PARK_FEATURE, NOZZLE_PARK_Z_FEEDRATE, 5); + void MKS_pause_print_move() { queue.exhaust(); position_before_pause = current_position; destination.z = _MIN(current_position.z + mks_park_pos.z, Z_MAX_POS); - prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE); + prepare_internal_move_to_destination(park_speed_z); destination.set(X_MIN_POS + mks_park_pos.x, Y_MIN_POS + mks_park_pos.y); - prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE); + prepare_internal_move_to_destination(park_speed_xy); } void MKS_resume_print_move() { destination.set(position_before_pause.x, position_before_pause.y); - prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE); + prepare_internal_move_to_destination(park_speed_xy); destination.z = position_before_pause.z; - prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE); + prepare_internal_move_to_destination(park_speed_z); } float z_offset_add = 0; diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp index e6e2af42eb..8833423b37 100644 --- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp @@ -1271,7 +1271,7 @@ void GcodeSuite::M1002() { #endif const uint8_t old_axis_relative = axis_relative; - set_e_relative(true); // M83 + set_e_relative(); // M83 { char buf[20]; snprintf_P(buf, 20, PSTR("G1E%dF%d"), parser.intval('E'), parser.intval('F')); From 795253a9d5abe4136b449938fcaf2dba778af536 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 16 Apr 2021 00:32:47 +0000 Subject: [PATCH 225/311] [cron] Bump distribution date (2021-04-16) --- 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 9e7cbe454c..54020e6c44 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-04-15" + #define STRING_DISTRIBUTION_DATE "2021-04-16" #endif /** From 58cc4b7043a9ff3b60df6c8f08591cb58213fbab Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 15 Apr 2021 20:06:08 -0500 Subject: [PATCH 226/311] Use celsius_t for temperature accessors --- Marlin/src/gcode/bedlevel/G26.cpp | 4 ++-- Marlin/src/module/temperature.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 657f906c14..fe039def73 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -205,8 +205,8 @@ typedef struct { layer_height = MESH_TEST_LAYER_HEIGHT, prime_length = PRIME_LENGTH; - int16_t bed_temp = MESH_TEST_BED_TEMP, - hotend_temp = MESH_TEST_HOTEND_TEMP; + celsius_t bed_temp = MESH_TEST_BED_TEMP, + hotend_temp = MESH_TEST_HOTEND_TEMP; float nozzle = MESH_TEST_NOZZLE_SIZE, filament_diameter = DEFAULT_NOMINAL_FILAMENT_DIA, diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index bcb451064e..e1e7f56d17 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -631,7 +631,7 @@ class Temperature { //inline so that there is no performance decrease. //deg=degreeCelsius - FORCE_INLINE static float degHotend(const uint8_t E_NAME) { + FORCE_INLINE static celsius_t degHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius); } @@ -736,7 +736,7 @@ class Temperature { #if ENABLED(SHOW_TEMP_ADC_VALUES) FORCE_INLINE static int16_t rawProbeTemp() { return temp_probe.raw; } #endif - FORCE_INLINE static float degProbe() { return temp_probe.celsius; } + FORCE_INLINE static celsius_t degProbe() { return temp_probe.celsius; } FORCE_INLINE static bool isProbeBelowTemp(const_float_t target_temp) { return temp_probe.celsius < target_temp; } FORCE_INLINE static bool isProbeAboveTemp(const_float_t target_temp) { return temp_probe.celsius > target_temp; } static bool wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling=true); @@ -752,7 +752,7 @@ class Temperature { #if ENABLED(SHOW_TEMP_ADC_VALUES) FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; } #endif - FORCE_INLINE static float degChamber() { return temp_chamber.celsius; } + FORCE_INLINE static celsius_t degChamber() { return temp_chamber.celsius; } #if HAS_HEATED_CHAMBER FORCE_INLINE static celsius_t degTargetChamber() { return temp_chamber.target; } FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } @@ -778,7 +778,7 @@ class Temperature { #if ENABLED(SHOW_TEMP_ADC_VALUES) FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; } #endif - FORCE_INLINE static float degCooler() { return temp_cooler.celsius; } + FORCE_INLINE static celsius_t degCooler() { return temp_cooler.celsius; } #if HAS_COOLER FORCE_INLINE static celsius_t degTargetCooler() { return temp_cooler.target; } FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } From 32dba5e0c735166d3bb54783efbf0d5d1b275b66 Mon Sep 17 00:00:00 2001 From: fedetony <45215920+fedetony@users.noreply.github.com> Date: Fri, 16 Apr 2021 08:59:28 +0200 Subject: [PATCH 227/311] Realtime Reporting, S000, P000, R000 (#19330) --- Marlin/Configuration_adv.h | 9 ++ Marlin/src/feature/e_parser.h | 134 +++++++++++++++----------- Marlin/src/gcode/bedlevel/abl/G29.cpp | 5 +- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 4 + Marlin/src/gcode/bedlevel/ubl/G29.cpp | 13 ++- Marlin/src/gcode/calibrate/G28.cpp | 4 + Marlin/src/gcode/calibrate/G33.cpp | 4 + Marlin/src/gcode/gcode.cpp | 11 ++- Marlin/src/gcode/host/M114.cpp | 4 + Marlin/src/gcode/motion/G0_G1.cpp | 4 + Marlin/src/gcode/motion/G2_G3.cpp | 4 + Marlin/src/gcode/parser.cpp | 23 ++++- Marlin/src/module/motion.cpp | 58 +++++++++++ Marlin/src/module/motion.h | 39 +++++++- Marlin/src/module/planner.cpp | 18 ++++ Marlin/src/module/planner.h | 7 ++ buildroot/tests/LPC1768 | 4 +- 17 files changed, 275 insertions(+), 70 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index fa1b470ab2..578bf144fc 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2115,6 +2115,15 @@ */ //#define EMERGENCY_PARSER +/** + * Realtime Reporting + * Add support for commands S000 State, P000 Pause, and R000 Resume + */ +//#define REALTIME_REPORTING_COMMANDS +#if ENABLED(REALTIME_REPORTING_COMMANDS) + //#define FULL_REPORT_TO_HOST_FEATURE // Auto-report the machine status like Grbl CNC +#endif + // Bad Serial-connections can miss a received command by sending an 'ok' // Therefore some clients abort after 30 seconds in a timeout. // Some other clients start sending commands while receiving a 'wait'. diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index 659e516787..c12fd14ad1 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -34,29 +34,33 @@ // External references extern bool wait_for_user, wait_for_heatup; +#if ENABLED(REALTIME_REPORTING_COMMANDS) + // From motion.h, which cannot be included here + void report_current_position_moving(); + void quickpause_stepper(); + void quickresume_stepper(); +#endif + class EmergencyParser { public: - // Currently looking for: M108, M112, M410, M876 - enum State : char { + // Currently looking for: M108, M112, M410, M876 S[0-9], S000, P000, R000 + enum State : uint8_t { EP_RESET, EP_N, EP_M, EP_M1, - EP_M10, - EP_M108, - EP_M11, - EP_M112, - EP_M4, - EP_M41, - EP_M410, + EP_M10, EP_M108, + EP_M11, EP_M112, + EP_M4, EP_M41, EP_M410, #if ENABLED(HOST_PROMPT_SUPPORT) - EP_M8, - EP_M87, - EP_M876, - EP_M876S, - EP_M876SN, + EP_M8, EP_M87, EP_M876, EP_M876S, EP_M876SN, + #endif + #if ENABLED(REALTIME_REPORTING_COMMANDS) + EP_S, EP_S0, EP_S00, EP_GRBL_STATUS, + EP_R, EP_R0, EP_R00, EP_GRBL_RESUME, + EP_P, EP_P0, EP_P00, EP_GRBL_PAUSE, #endif EP_IGNORE // to '\n' }; @@ -71,7 +75,6 @@ public: EmergencyParser() { enable(); } FORCE_INLINE static void enable() { enabled = true; } - FORCE_INLINE static void disable() { enabled = false; } FORCE_INLINE static void update(State &state, const uint8_t c) { @@ -79,21 +82,45 @@ public: case EP_RESET: switch (c) { case ' ': case '\n': case '\r': break; - case 'N': state = EP_N; break; - case 'M': state = EP_M; break; - default: state = EP_IGNORE; + case 'N': state = EP_N; break; + case 'M': state = EP_M; break; + #if ENABLED(REALTIME_REPORTING_COMMANDS) + case 'S': state = EP_S; break; + case 'P': state = EP_P; break; + case 'R': state = EP_R; break; + #endif + default: state = EP_IGNORE; } break; case EP_N: switch (c) { case '0' ... '9': - case '-': case ' ': break; - case 'M': state = EP_M; break; - default: state = EP_IGNORE; + case '-': case ' ': break; + case 'M': state = EP_M; break; + #if ENABLED(REALTIME_REPORTING_COMMANDS) + case 'S': state = EP_S; break; + case 'P': state = EP_P; break; + case 'R': state = EP_R; break; + #endif + default: state = EP_IGNORE; } break; + #if ENABLED(REALTIME_REPORTING_COMMANDS) + case EP_S: state = (c == '0') ? EP_S0 : EP_IGNORE; break; + case EP_S0: state = (c == '0') ? EP_S00 : EP_IGNORE; break; + case EP_S00: state = (c == '0') ? EP_GRBL_STATUS : EP_IGNORE; break; + + case EP_R: state = (c == '0') ? EP_R0 : EP_IGNORE; break; + case EP_R0: state = (c == '0') ? EP_R00 : EP_IGNORE; break; + case EP_R00: state = (c == '0') ? EP_GRBL_RESUME : EP_IGNORE; break; + + case EP_P: state = (c == '0') ? EP_P0 : EP_IGNORE; break; + case EP_P0: state = (c == '0') ? EP_P00 : EP_IGNORE; break; + case EP_P00: state = (c == '0') ? EP_GRBL_PAUSE : EP_IGNORE; break; + #endif + case EP_M: switch (c) { case ' ': break; @@ -114,48 +141,34 @@ public: } break; - case EP_M10: - state = (c == '8') ? EP_M108 : EP_IGNORE; - break; - - case EP_M11: - state = (c == '2') ? EP_M112 : EP_IGNORE; - break; - - case EP_M4: - state = (c == '1') ? EP_M41 : EP_IGNORE; - break; - - case EP_M41: - state = (c == '0') ? EP_M410 : EP_IGNORE; - break; + case EP_M10: state = (c == '8') ? EP_M108 : EP_IGNORE; break; + case EP_M11: state = (c == '2') ? EP_M112 : EP_IGNORE; break; + case EP_M4: state = (c == '1') ? EP_M41 : EP_IGNORE; break; + case EP_M41: state = (c == '0') ? EP_M410 : EP_IGNORE; break; #if ENABLED(HOST_PROMPT_SUPPORT) - case EP_M8: - state = (c == '7') ? EP_M87 : EP_IGNORE; - break; - case EP_M87: - state = (c == '6') ? EP_M876 : EP_IGNORE; - break; + case EP_M8: state = (c == '7') ? EP_M87 : EP_IGNORE; break; + case EP_M87: state = (c == '6') ? EP_M876 : EP_IGNORE; break; - case EP_M876: - switch (c) { - case ' ': break; - case 'S': state = EP_M876S; break; - default: state = EP_IGNORE; break; - } - break; + case EP_M876: + switch (c) { + case ' ': break; + case 'S': state = EP_M876S; break; + default: state = EP_IGNORE; break; + } + break; + + case EP_M876S: + switch (c) { + case ' ': break; + case '0' ... '9': + state = EP_M876SN; + M876_reason = uint8_t(c - '0'); + break; + } + break; - case EP_M876S: - switch (c) { - case ' ': break; - case '0' ... '9': - state = EP_M876SN; - M876_reason = (uint8_t)(c - '0'); - break; - } - break; #endif case EP_IGNORE: @@ -171,6 +184,11 @@ public: #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M876SN: host_response_handler(M876_reason); break; #endif + #if ENABLED(REALTIME_REPORTING_COMMANDS) + case EP_GRBL_STATUS: report_current_position_moving(); break; + case EP_GRBL_PAUSE: quickpause_stepper(); break; + case EP_GRBL_RESUME: quickresume_stepper(); break; + #endif default: break; } state = EP_RESET; diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 423857dbb0..a10b2b89b1 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -217,9 +217,10 @@ public: * There's no extra effect if you have a fixed Z probe. */ G29_TYPE GcodeSuite::G29() { - TERN_(PROBE_MANUALLY, static) G29_State abl; + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); + reset_stepper_timeout(); const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q'); @@ -897,6 +898,8 @@ G29_TYPE GcodeSuite::G29() { report_current_position(); + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); + G29_RETURN(ISNAN(abl.measured_z)); } diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 1ec514c3ec..2da584fd49 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -60,6 +60,8 @@ inline void echo_not_entered(const char c) { SERIAL_CHAR(c); SERIAL_ECHOLNPGM(" */ void GcodeSuite::G29() { + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); + static int mbl_probe_index = -1; MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport); @@ -187,6 +189,8 @@ void GcodeSuite::G29() { } report_current_position(); + + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); } #endif // MESH_BED_LEVELING diff --git a/Marlin/src/gcode/bedlevel/ubl/G29.cpp b/Marlin/src/gcode/bedlevel/ubl/G29.cpp index 2ef3ab4cec..932503d72b 100644 --- a/Marlin/src/gcode/bedlevel/ubl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/G29.cpp @@ -31,6 +31,17 @@ #include "../../gcode.h" #include "../../../feature/bedlevel/bedlevel.h" -void GcodeSuite::G29() { ubl.G29(); } +#if ENABLED(FULL_REPORT_TO_HOST_FEATURE) + #include "../../../module/motion.h" +#endif + +void GcodeSuite::G29() { + + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); + + ubl.G29(); + + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); +} #endif // AUTO_BED_LEVELING_UBL diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 73bfc3bdc6..10e094cba7 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -211,6 +211,8 @@ void GcodeSuite::G28() { TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_HOMING)); + #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; DualXMode IDEX_saved_mode = dual_x_carriage_mode; @@ -479,6 +481,8 @@ void GcodeSuite::G28() { if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS))) SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP); + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); + #if HAS_L64XX // Set L6470 absolute position registers to counts // constexpr *might* move this to PROGMEM. diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 0bcab206af..db1d456d70 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -387,6 +387,8 @@ static float auto_tune_a() { */ void GcodeSuite::G33() { + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); + const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS); if (!WITHIN(probe_points, 0, 10)) { SERIAL_ECHOLNPGM("?(P)oints implausible (0-10)."); @@ -645,6 +647,8 @@ void GcodeSuite::G33() { while (((zero_std_dev < test_precision && iterations < 31) || iterations <= force_iterations) && zero_std_dev > calibration_precision); ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index)); + + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); } #endif // DELTA_AUTO_CALIBRATION diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 574e93aecc..efea087602 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -289,8 +289,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { } #endif - // Handle a known G, M, or T + // Handle a known command or reply "unknown command" + switch (parser.command_letter) { + case 'G': switch (parser.codenum) { case 0: case 1: // G0: Fast Move, G1: Linear Move @@ -995,6 +997,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 'D': D(parser.codenum); break; // Dn: Debug codes #endif + #if ENABLED(REALTIME_REPORTING_COMMANDS) + case 'S': case 'P': case 'R': break; // Invalid S, P, R commands already filtered + #endif + default: #if ENABLED(WIFI_CUSTOM_COMMAND) if (wifi_custom_command(parser.command_ptr)) break; @@ -1087,12 +1093,15 @@ void GcodeSuite::process_subcommands_now(char * gcode) { case IN_HANDLER: case IN_PROCESS: SERIAL_ECHO_MSG(STR_BUSY_PROCESSING); + TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_position_moving()); break; case PAUSED_FOR_USER: SERIAL_ECHO_MSG(STR_BUSY_PAUSED_FOR_USER); + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_HOLD)); break; case PAUSED_FOR_INPUT: SERIAL_ECHO_MSG(STR_BUSY_PAUSED_FOR_INPUT); + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_HOLD)); break; default: break; diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index 75356ff66f..dd62f0ad2e 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -176,6 +176,8 @@ const xyze_float_t diff = from_steppers - leveled; SERIAL_ECHOPGM("Diff: "); report_xyze(diff); + + TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving()); } #endif // M114_DETAIL @@ -211,4 +213,6 @@ void GcodeSuite::M114() { TERN_(M114_LEGACY, planner.synchronize()); report_current_position_projected(); + + TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving()); } diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 9ac49bd93c..64c07d1d89 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -54,6 +54,7 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { | (parser.seen('Z') ? _BV(Z_AXIS) : 0) ) #endif ) { + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_RUNNING)); #ifdef G0_FEEDRATE feedRate_t old_feedrate; @@ -116,6 +117,9 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { planner.synchronize(); SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP); } + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); + #else + TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving()); #endif } } diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 61e50247f3..5a8324362a 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -306,6 +306,8 @@ void plan_arc( void GcodeSuite::G2_G3(const bool clockwise) { if (MOTION_CONDITIONS) { + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_RUNNING)); + #if ENABLED(SF_ARC_FIX) const bool relative_mode_backup = relative_mode; relative_mode = true; @@ -364,6 +366,8 @@ void GcodeSuite::G2_G3(const bool clockwise) { } else SERIAL_ERROR_MSG(STR_ERR_ARC_ARGS); + + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); } } diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index f7812bf3f6..9f0d09563e 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -106,8 +106,10 @@ void GCodeParser::reset() { #endif -// Populate all fields by parsing a single line of GCode -// 58 bytes of SRAM are used to speed up seen/value +/** + * Populate the command line state (command_letter, codenum, subcode, and string_arg) + * by parsing a single line of GCode. 58 bytes of SRAM are used to speed up seen/value. + */ void GCodeParser::parse(char *p) { reset(); // No codes to report @@ -147,10 +149,12 @@ void GCodeParser::parse(char *p) { #define SIGNED_CODENUM 1 #endif - // Bail if the letter is not G, M, or T - // (or a valid parameter for the current motion mode) + /** + * Screen for good command letters. G, M, and T are always accepted. + * With Motion Modes enabled any axis letter can come first. + * With Realtime Reporting, commands S000, P000, and R000 are allowed. + */ switch (letter) { - case 'G': case 'M': case 'T': TERN_(MARLIN_DEV_MODE, case 'D':) // Skip spaces to get the numeric part while (*p == ' ') p++; @@ -227,6 +231,15 @@ void GCodeParser::parse(char *p) { break; #endif // GCODE_MOTION_MODES + #if ENABLED(REALTIME_REPORTING_COMMANDS) + case 'S': case 'P': case 'R': { + codenum = 0; // The only valid codenum is 0 + uint8_t digits = 0; + while (*p++ == '0') digits++; // Count up '0' characters + command_letter = (digits == 3) ? letter : '?'; // Three '0' digits is a good command + } return; // No parameters, so return + #endif + default: return; } diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 6058db37b3..584e894ae6 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -230,6 +230,50 @@ void report_current_position_projected() { stepper.report_a_position(planner.position); } +#if EITHER(FULL_REPORT_TO_HOST_FEATURE, REALTIME_REPORTING_COMMANDS) + + M_StateEnum M_State_grbl = M_INIT; + + /** + * Output the current grbl compatible state to serial while moving + */ + void report_current_grblstate_moving() { SERIAL_ECHOLNPAIR("S_XYZ:", int(M_State_grbl)); } + + /** + * Output the current position (processed) to serial while moving + */ + void report_current_position_moving() { + + get_cartesian_from_steppers(); + const xyz_pos_t lpos = cartes.asLogical(); + SERIAL_ECHOPAIR("X:", lpos.x, " Y:", lpos.y, " Z:", lpos.z, " E:", current_position.e); + + stepper.report_positions(); + #if IS_SCARA + scara_report_positions(); + #endif + + report_current_grblstate_moving(); + } + + /** + * Set a Grbl-compatible state from the current marlin_state + */ + M_StateEnum grbl_state_for_marlin_state() { + switch (marlin_state) { + case MF_INITIALIZING: return M_INIT; + case MF_SD_COMPLETE: return M_ALARM; + case MF_WAITING: return M_IDLE; + case MF_STOPPED: return M_END; + case MF_RUNNING: return M_RUNNING; + case MF_PAUSED: return M_HOLD; + case MF_KILLED: return M_ERROR; + default: return M_IDLE; + } + } + +#endif + /** * Run out the planner buffer and re-sync the current * position from the last-updated stepper positions. @@ -241,6 +285,20 @@ void quickstop_stepper() { sync_plan_position(); } +#if ENABLED(REALTIME_REPORTING_COMMANDS) + + void quickpause_stepper() { + planner.quick_pause(); + //planner.synchronize(); + } + + void quickresume_stepper() { + planner.quick_resume(); + //planner.synchronize(); + } + +#endif + /** * Set the planner/stepper positions directly from current_position with * no kinematic translation. Used for homing axes and cartesian/core syncing. diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 2cfc8406a5..647b3af52a 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -211,14 +211,49 @@ void report_real_position(); void report_current_position(); void report_current_position_projected(); +#if EITHER(FULL_REPORT_TO_HOST_FEATURE, REALTIME_REPORTING_COMMANDS) + #define HAS_GRBL_STATE 1 + /** + * Machine states for GRBL or TinyG + */ + enum M_StateEnum : uint8_t { + M_INIT = 0, // 0 machine is initializing + M_RESET, // 1 machine is ready for use + M_ALARM, // 2 machine is in alarm state (soft shut down) + M_IDLE, // 3 program stop or no more blocks (M0, M1, M60) + M_END, // 4 program end via M2, M30 + M_RUNNING, // 5 motion is running + M_HOLD, // 6 motion is holding + M_PROBE, // 7 probe cycle active + M_CYCLING, // 8 machine is running (cycling) + M_HOMING, // 9 machine is homing + M_JOGGING, // 10 machine is jogging + M_ERROR // 11 machine is in hard alarm state (shut down) + }; + extern M_StateEnum M_State_grbl; + M_StateEnum grbl_state_for_marlin_state(); + void report_current_grblstate_moving(); + void report_current_position_moving(); + + #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) + inline void set_and_report_grblstate(const M_StateEnum state) { + M_State_grbl = state; + report_current_grblstate_moving(); + } + #endif + + #if ENABLED(REALTIME_REPORTING_COMMANDS) + void quickpause_stepper(); + void quickresume_stepper(); + #endif +#endif + void get_cartesian_from_steppers(); void set_current_from_steppers_for_axis(const AxisEnum axis); void quickstop_stepper(); /** - * sync_plan_position - * * Set the planner/stepper positions directly from current_position with * no kinematic translation. Used for homing axes and cartesian/core syncing. */ diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index b528eb9d3b..f11f273867 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1650,6 +1650,24 @@ void Planner::quick_stop() { stepper.quick_stop(); } +#if ENABLED(REALTIME_REPORTING_COMMANDS) + + void Planner::quick_pause() { + // Suspend until quick_resume is called + // Don't empty buffers or queues + const bool did_suspend = stepper.suspend(); + if (did_suspend) + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_HOLD)); + } + + // Resume if suspended + void Planner::quick_resume() { + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(grbl_state_for_marlin_state())); + stepper.wake_up(); + } + +#endif + void Planner::endstop_triggered(const AxisEnum axis) { // Record stepper position and discard the current block stepper.endstop_triggered(axis); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 398339f04e..30eeb758a4 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -873,6 +873,13 @@ class Planner { // a Full Shutdown is required, or when endstops are hit) static void quick_stop(); + #if ENABLED(REALTIME_REPORTING_COMMANDS) + // Force a quick pause of the machine (e.g., when a pause is required in the middle of move). + // NOTE: Hard-stops will lose steps so encoders are highly recommended if using these! + static void quick_pause(); + static void quick_resume(); + #endif + // Called when an endstop is triggered. Causes the machine to stop inmediately static void endstop_triggered(const AxisEnum axis); diff --git a/buildroot/tests/LPC1768 b/buildroot/tests/LPC1768 index eef0857dac..152a49852a 100755 --- a/buildroot/tests/LPC1768 +++ b/buildroot/tests/LPC1768 @@ -26,8 +26,8 @@ restore_configs opt_set MOTHERBOARD BOARD_MKS_SBASE \ EXTRUDERS 2 TEMP_SENSOR_1 1 \ NUM_SERVOS 2 SERVO_DELAY '{ 300, 300 }' -opt_enable SWITCHING_NOZZLE SWITCHING_NOZZLE_E1_SERVO_NR ULTIMAKERCONTROLLER -exec_test $1 $2 "MKS SBASE with SWITCHING_NOZZLE" "$3" +opt_enable SWITCHING_NOZZLE SWITCHING_NOZZLE_E1_SERVO_NR ULTIMAKERCONTROLLER REALTIME_REPORTING_COMMANDS FULL_REPORT_TO_HOST_FEATURE +exec_test $1 $2 "MKS SBASE with SWITCHING_NOZZLE, Grbl Realtime Report" "$3" restore_configs opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EEB \ From 528b9bd8729656d7ebcd3dc7898ceddc2f377354 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 16 Apr 2021 02:43:59 -0500 Subject: [PATCH 228/311] Revert experimental NAN patch Hold changes from #21575 (24a095c) for more testing. --- Marlin/src/core/macros.h | 3 -- Marlin/src/feature/bedlevel/abl/abl.cpp | 14 +++---- Marlin/src/feature/bedlevel/bedlevel.cpp | 4 +- .../feature/bedlevel/mbl/mesh_bed_leveling.h | 4 +- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 10 ++--- Marlin/src/feature/bedlevel/ubl/ubl.h | 6 +-- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 40 +++++++++---------- .../src/feature/bedlevel/ubl/ubl_motion.cpp | 18 ++++----- Marlin/src/gcode/bedlevel/G35.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 22 +++++----- Marlin/src/gcode/bedlevel/ubl/M421.cpp | 2 +- Marlin/src/gcode/calibrate/G33.cpp | 6 +-- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 6 +-- Marlin/src/gcode/calibrate/M48.cpp | 4 +- Marlin/src/gcode/probe/G30.cpp | 2 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 4 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 2 +- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 2 +- .../ftdi_eve_lib/extended/adjuster_widget.cpp | 2 +- .../screens/bed_mesh_base.cpp | 2 +- .../screens/bed_mesh_edit_screen.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 4 +- Marlin/src/lcd/menu/menu_tramming.cpp | 2 +- Marlin/src/lcd/tft/ui_1024x600.cpp | 2 +- Marlin/src/lcd/tft/ui_320x240.cpp | 2 +- Marlin/src/lcd/tft/ui_480x320.cpp | 2 +- Marlin/src/module/probe.cpp | 20 +++++----- Marlin/src/module/settings.cpp | 14 +++---- Marlin/src/module/temperature.h | 6 +-- platformio.ini | 2 +- 31 files changed, 104 insertions(+), 109 deletions(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index ce88458412..6092dc4a59 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -112,9 +112,6 @@ #define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);}) #define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1))) -#define MFNAN 999999.0f -#define ISNAN(V) ((V) == MFNAN) - // Macros to constrain values #ifdef __cplusplus diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index 3d5e6723eb..7390656563 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -43,7 +43,7 @@ bed_mesh_t z_values; * Extrapolate a single point from its neighbors */ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { - if (!ISNAN(z_values[x][y])) return; + if (!isnan(z_values[x][y])) return; if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Extrapolate ["); if (x < 10) DEBUG_CHAR(' '); @@ -63,12 +63,12 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t c1 = z_values[x1][y1], c2 = z_values[x2][y2]; // Treat far unprobed points as zero, near as equal to far - if (ISNAN(a2)) a2 = 0.0; - if (ISNAN(a1)) a1 = a2; - if (ISNAN(b2)) b2 = 0.0; - if (ISNAN(b1)) b1 = b2; - if (ISNAN(c2)) c2 = 0.0; - if (ISNAN(c1)) c1 = c2; + if (isnan(a2)) a2 = 0.0; + if (isnan(a1)) a1 = a2; + if (isnan(b2)) b2 = 0.0; + if (isnan(b1)) b1 = b2; + if (isnan(c2)) c2 = 0.0; + if (isnan(c1)) c1 = c2; const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2; diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 0a7c0c5a0c..30fafbf57b 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -132,7 +132,7 @@ void reset_bed_level() { bilinear_start.reset(); bilinear_grid_spacing.reset(); GRID_LOOP(x, y) { - z_values[x][y] = MFNAN; + z_values[x][y] = NAN; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0)); } #elif ABL_PLANAR @@ -177,7 +177,7 @@ void reset_bed_level() { LOOP_L_N(x, sx) { SERIAL_CHAR(' '); const float offset = fn(x, y); - if (!ISNAN(offset)) { + if (!isnan(offset)) { if (offset >= 0) SERIAL_CHAR('+'); SERIAL_ECHO_F(offset, int(precision)); } diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index eaab7775f5..1ae8135458 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -97,7 +97,6 @@ public: static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); } static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) { - if (ISNAN(a0) || ISNAN(a1) || ISNAN(z1) || ISNAN(a2) || ISNAN(z2)) return MFNAN; const float delta_z = (z2 - z1) / (a2 - a1), delta_a = a0 - a1; return z1 + delta_a * delta_z; @@ -118,8 +117,7 @@ public: z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]), zf = calc_z0(pos.y, y1, z1, y2, z2); - - return ISNAN(zf) ? zf : z_offset + zf * factor; + return z_offset + zf * factor; } #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 70b7863fab..164d267ceb 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -48,7 +48,7 @@ void unified_bed_leveling::report_current_mesh() { if (!leveling_is_valid()) return; SERIAL_ECHO_MSG(" G29 I999"); GRID_LOOP(x, y) - if (!ISNAN(z_values[x][y])) { + if (!isnan(z_values[x][y])) { SERIAL_ECHO_START(); SERIAL_ECHOPAIR(" M421 I", x, " J", y); SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4); @@ -99,7 +99,7 @@ void unified_bed_leveling::reset() { void unified_bed_leveling::invalidate() { set_bed_leveling_enabled(false); - set_all_mesh_points_to_value(MFNAN); + set_all_mesh_points_to_value(NAN); } void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) { @@ -116,7 +116,7 @@ void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) { void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) { auto z_to_store = [](const_float_t z) { - if (ISNAN(z)) return Z_STEPS_NAN; + if (isnan(z)) return Z_STEPS_NAN; const int32_t z_scaled = TRUNC(z * mesh_store_scaling); if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX)) return Z_STEPS_NAN; // If Z is out of range, return our custom 'NaN' @@ -127,7 +127,7 @@ void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) { void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) { auto store_to_z = [](const int16_t z_scaled) { - return z_scaled == Z_STEPS_NAN ? MFNAN : z_scaled / mesh_store_scaling; + return z_scaled == Z_STEPS_NAN ? NAN : z_scaled / mesh_store_scaling; }; GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]); } @@ -211,7 +211,7 @@ void unified_bed_leveling::display_map(const int map_type) { if (lcd) { // TODO: Display on Graphical LCD } - else if (ISNAN(f)) + else if (isnan(f)) SERIAL_ECHOPGM_P(human ? PSTR(" . ") : PSTR("NAN")); else if (human || csv) { if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index a086c20ba8..0a758a57e9 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -196,7 +196,7 @@ public: #ifdef UBL_Z_RAISE_WHEN_OFF_MESH #define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH #else - #define _UBL_OUTER_Z_RAISE MFNAN + #define _UBL_OUTER_Z_RAISE NAN #endif /** @@ -269,7 +269,7 @@ public: const float z2 = calc_z0(rx0, mesh_index_to_xpos(cx), z_values[cx][my], mesh_index_to_xpos(cx + 1), z_values[mx][my]); float z0 = calc_z0(ry0, mesh_index_to_ypos(cy), z1, mesh_index_to_ypos(cy + 1), z2); - if (ISNAN(z0)) { // if part of the Mesh is undefined, it will show up as MFNAN + if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN z0 = 0.0; // in ubl.z_values[][] and propagate through the // calculations. If our correction is NAN, we throw it out // because part of the Mesh is undefined and we don't have the @@ -301,7 +301,7 @@ public: #endif static inline bool mesh_is_valid() { - GRID_LOOP(x, y) if (ISNAN(z_values[x][y])) return false; + GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false; return true; } diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index ed2d4c6a94..361f3f1285 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -331,7 +331,7 @@ void unified_bed_leveling::G29() { // to invalidate the ENTIRE mesh, which can't be done with // find_closest_mesh_point (which only returns REAL points). if (closest.pos.x < 0) { invalidate_all = true; break; } - z_values[closest.pos.x][closest.pos.y] = MFNAN; + z_values[closest.pos.x][closest.pos.y] = NAN; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(closest.pos, 0.0f)); } } @@ -516,7 +516,7 @@ void unified_bed_leveling::G29() { if (cpos.x < 0) { // No more REAL INVALID mesh points to populate, so we ASSUME // user meant to populate ALL INVALID mesh points to value - GRID_LOOP(x, y) if (ISNAN(z_values[x][y])) z_values[x][y] = param.C_constant; + GRID_LOOP(x, y) if (isnan(z_values[x][y])) z_values[x][y] = param.C_constant; break; // No more invalid Mesh Points to populate } else { @@ -675,7 +675,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o float sum = 0; int n = 0; GRID_LOOP(x, y) - if (!ISNAN(z_values[x][y])) { + if (!isnan(z_values[x][y])) { sum += z_values[x][y]; n++; } @@ -687,7 +687,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o // float sum_of_diff_squared = 0; GRID_LOOP(x, y) - if (!ISNAN(z_values[x][y])) + if (!isnan(z_values[x][y])) sum_of_diff_squared += sq(z_values[x][y] - mean); SERIAL_ECHOLNPAIR("# of samples: ", n); @@ -698,7 +698,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o if (cflag) GRID_LOOP(x, y) - if (!ISNAN(z_values[x][y])) { + if (!isnan(z_values[x][y])) { z_values[x][y] -= mean + offset; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); } @@ -709,7 +709,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o */ void unified_bed_leveling::shift_mesh_height() { GRID_LOOP(x, y) - if (!ISNAN(z_values[x][y])) { + if (!isnan(z_values[x][y])) { z_values[x][y] += param.C_constant; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); } @@ -1017,7 +1017,7 @@ void set_message_with_feedback(PGM_P const msg_P) { ui.refresh(); float new_z = z_values[lpos.x][lpos.y]; - if (ISNAN(new_z)) new_z = 0; // Invalid points begin at 0 + if (isnan(new_z)) new_z = 0; // Invalid points begin at 0 new_z = FLOOR(new_z * 1000) * 0.001f; // Chop off digits after the 1000ths place ui.ubl_mesh_edit_start(new_z); @@ -1227,7 +1227,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { mesh_index_pair farthest { -1, -1, -99999.99 }; GRID_LOOP(i, j) { - if (!ISNAN(z_values[i][j])) continue; // Skip valid mesh points + if (!isnan(z_values[i][j])) continue; // Skip valid mesh points // Skip unreachable points if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j))) @@ -1238,7 +1238,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { xy_int8_t nearby { -1, -1 }; float d1, d2 = 99999.9f; GRID_LOOP(k, l) { - if (ISNAN(z_values[k][l])) continue; + if (isnan(z_values[k][l])) continue; found_a_real = true; @@ -1282,7 +1282,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { static bool test_func(uint8_t i, uint8_t j, void *data) { find_closest_t *d = (find_closest_t*)data; - if ( (d->type == (ISNAN(ubl.z_values[i][j]) ? INVALID : REAL)) + if ( (d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL)) || (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j)) ) { // Found a Mesh Point of the specified type! @@ -1326,7 +1326,7 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh float best_so_far = 99999.99f; GRID_LOOP(i, j) { - if ( (type == (ISNAN(z_values[i][j]) ? INVALID : REAL)) + if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL)) || (type == SET_IN_BITMAP && !done_flags->marked(i, j)) ) { // Found a Mesh Point of the specified type! @@ -1367,12 +1367,12 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh bool unified_bed_leveling::smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { const float v = z_values[x][y]; - if (ISNAN(v)) { // A NAN... + if (isnan(v)) { // A NAN... const int8_t dx = x + xdir, dy = y + ydir; const float v1 = z_values[dx][dy]; - if (!ISNAN(v1)) { // ...next to a pair of real values? + if (!isnan(v1)) { // ...next to a pair of real values? const float v2 = z_values[dx + xdir][dy + ydir]; - if (!ISNAN(v2)) { + if (!isnan(v2)) { z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); return true; @@ -1441,7 +1441,7 @@ void unified_bed_leveling::smart_fill_mesh() { TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity); - if (ISNAN(measured_z)) + if (isnan(measured_z)) abort_flag = true; else { measured_z -= get_z_correction(points[0]); @@ -1463,7 +1463,7 @@ void unified_bed_leveling::smart_fill_mesh() { #ifdef VALIDATE_MESH_TILT z2 = measured_z; #endif - if (ISNAN(measured_z)) + if (isnan(measured_z)) abort_flag = true; else { measured_z -= get_z_correction(points[1]); @@ -1483,7 +1483,7 @@ void unified_bed_leveling::smart_fill_mesh() { #ifdef VALIDATE_MESH_TILT z3 = measured_z; #endif - if (ISNAN(measured_z)) + if (isnan(measured_z)) abort_flag = true; else { measured_z -= get_z_correction(points[2]); @@ -1522,7 +1522,7 @@ void unified_bed_leveling::smart_fill_mesh() { measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling - abort_flag = ISNAN(measured_z); + abort_flag = isnan(measured_z); #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { @@ -1673,14 +1673,14 @@ void unified_bed_leveling::smart_fill_mesh() { const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST); - GRID_LOOP(jx, jy) if (!ISNAN(z_values[jx][jy])) SBI(bitmap[jx], jy); + GRID_LOOP(jx, jy) if (!isnan(z_values[jx][jy])) SBI(bitmap[jx], jy); xy_pos_t ppos; LOOP_L_N(ix, GRID_MAX_POINTS_X) { ppos.x = mesh_index_to_xpos(ix); LOOP_L_N(iy, GRID_MAX_POINTS_Y) { ppos.y = mesh_index_to_ypos(iy); - if (ISNAN(z_values[ix][iy])) { + if (isnan(z_values[ix][iy])) { // undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points. incremental_LSF_reset(&lsf_results); xy_pos_t rpos; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index cb3f7d3bbe..3ebc5fc2bd 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -85,7 +85,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (!ISNAN(z0)) end.z += z0; + if (!isnan(z0)) end.z += z0; planner.buffer_segment(end, scaled_fr_mm_s, extruder); current_position = destination; return; @@ -150,7 +150,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (ISNAN(z0)) z0 = 0.0; + if (isnan(z0)) z0 = 0.0; const float ry = mesh_index_to_ypos(icell.y); @@ -198,7 +198,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (ISNAN(z0)) z0 = 0.0; + if (isnan(z0)) z0 = 0.0; /** * Without this check, it's possible to generate a zero length move, as in the case where @@ -253,7 +253,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (ISNAN(z0)) z0 = 0.0; + if (isnan(z0)) z0 = 0.0; if (!inf_normalized_flag) { on_axis_distance = use_x_dist ? rx - start.x : next_mesh_line_y - start.y; @@ -276,7 +276,7 @@ // Undefined parts of the Mesh in z_values[][] are NAN. // Replace NAN corrections with 0.0 to prevent NAN propagation. - if (ISNAN(z0)) z0 = 0.0; + if (isnan(z0)) z0 = 0.0; if (!inf_normalized_flag) { on_axis_distance = use_x_dist ? next_mesh_line_x - start.x : ry - start.y; @@ -405,10 +405,10 @@ z_x0y1 = z_values[icell.x ][icell.y+1], // z at lower right corner z_x1y1 = z_values[icell.x+1][icell.y+1]; // z at upper right corner - if (ISNAN(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A) - if (ISNAN(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points - if (ISNAN(z_x0y1)) z_x0y1 = 0; // in order to avoid ISNAN tests per cell, - if (ISNAN(z_x1y1)) z_x1y1 = 0; // thus guessing zero for undefined points + if (isnan(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A) + if (isnan(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points + if (isnan(z_x0y1)) z_x0y1 = 0; // in order to avoid isnan tests per cell, + if (isnan(z_x1y1)) z_x1y1 = 0; // thus guessing zero for undefined points const xy_pos_t pos = { mesh_index_to_xpos(icell.x), mesh_index_to_ypos(icell.y) }; xy_pos_t cell = raw - pos; diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index f1c3ce028d..ad2cc67db0 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -105,7 +105,7 @@ void GcodeSuite::G35() { do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7)); const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true); - if (ISNAN(z_probed_height)) { + if (isnan(z_probed_height)) { SERIAL_ECHOPAIR("G35 failed at point ", i, " ("); SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i])); SERIAL_CHAR(')'); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a10b2b89b1..8cc0a66216 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -288,11 +288,11 @@ G29_TYPE GcodeSuite::G29() { G29_RETURN(false); } - const float rx = RAW_X_POSITION(parser.linearval('X', MFNAN)), - ry = RAW_Y_POSITION(parser.linearval('Y', MFNAN)); + const float rx = RAW_X_POSITION(parser.linearval('X', NAN)), + ry = RAW_Y_POSITION(parser.linearval('Y', NAN)); int8_t i = parser.byteval('I', -1), j = parser.byteval('J', -1); - if (!ISNAN(rx) && !ISNAN(ry)) { + if (!isnan(rx) && !isnan(ry)) { // Get nearest i / j from rx / ry i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x; j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y; @@ -609,7 +609,7 @@ G29_TYPE GcodeSuite::G29() { // Outer loop is X with PROBE_Y_FIRST enabled // Outer loop is Y with PROBE_Y_FIRST disabled - for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !ISNAN(abl.measured_z); PR_OUTER_VAR++) { + for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !isnan(abl.measured_z); PR_OUTER_VAR++) { int8_t inStart, inStop, inInc; @@ -645,7 +645,7 @@ G29_TYPE GcodeSuite::G29() { abl.measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level); - if (ISNAN(abl.measured_z)) { + if (isnan(abl.measured_z)) { set_bed_leveling_enabled(abl.reenable); break; // Breaks out of both loops } @@ -691,14 +691,14 @@ G29_TYPE GcodeSuite::G29() { // Retain the last probe position abl.probePos = points[i]; abl.measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level); - if (ISNAN(abl.measured_z)) { + if (isnan(abl.measured_z)) { set_bed_leveling_enabled(abl.reenable); break; } points[i].z = abl.measured_z; } - if (!abl.dryrun && !ISNAN(abl.measured_z)) { + if (!abl.dryrun && !isnan(abl.measured_z)) { vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal(); if (planeNormal.z < 0) planeNormal *= -1; planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal); @@ -714,7 +714,7 @@ G29_TYPE GcodeSuite::G29() { // Stow the probe. No raise for FIX_MOUNTED_PROBE. if (probe.stow()) { set_bed_leveling_enabled(abl.reenable); - abl.measured_z = MFNAN; + abl.measured_z = NAN; } } #endif // !PROBE_MANUALLY @@ -737,7 +737,7 @@ G29_TYPE GcodeSuite::G29() { #endif // Calculate leveling, print reports, correct the position - if (!ISNAN(abl.measured_z)) { + if (!isnan(abl.measured_z)) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) if (!abl.dryrun) extrapolate_unprobed_bed_level(); @@ -874,7 +874,7 @@ G29_TYPE GcodeSuite::G29() { // Auto Bed Leveling is complete! Enable if possible. planner.leveling_active = !abl.dryrun || abl.reenable; - } // !ISNAN(abl.measured_z) + } // !isnan(abl.measured_z) // Restore state after probing if (!faux) restore_feedrate_and_scaling(); @@ -900,7 +900,7 @@ G29_TYPE GcodeSuite::G29() { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); - G29_RETURN(ISNAN(abl.measured_z)); + G29_RETURN(isnan(abl.measured_z)); } #endif // HAS_ABL_NOT_UBL diff --git a/Marlin/src/gcode/bedlevel/ubl/M421.cpp b/Marlin/src/gcode/bedlevel/ubl/M421.cpp index 694ad7ab81..600c1fc8ba 100644 --- a/Marlin/src/gcode/bedlevel/ubl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/M421.cpp @@ -62,7 +62,7 @@ void GcodeSuite::M421() { SERIAL_ERROR_MSG(STR_ERR_MESH_XY); else { float &zval = ubl.z_values[ij.x][ij.y]; - zval = hasN ? MFNAN : parser.value_linear_units() + (hasQ ? zval : 0); + zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval)); } } diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index db1d456d70..d60099a330 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -212,7 +212,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center const xy_pos_t center{0}; z_pt[CEN] += calibration_probe(center, stow_after_each); - if (ISNAN(z_pt[CEN])) return false; + if (isnan(z_pt[CEN])) return false; } if (_7p_calibration) { // probe extra center points @@ -223,7 +223,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi r = dcr * 0.1; const xy_pos_t vec = { cos(a), sin(a) }; z_pt[CEN] += calibration_probe(vec * r, stow_after_each); - if (ISNAN(z_pt[CEN])) return false; + if (isnan(z_pt[CEN])) return false; } z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points); } @@ -248,7 +248,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi interpol = FMOD(rad, 1); const xy_pos_t vec = { cos(a), sin(a) }; const float z_temp = calibration_probe(vec * r, stow_after_each); - if (ISNAN(z_temp)) return false; + if (isnan(z_temp)) return false; // split probe point to neighbouring calibration points z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90))); z_pt[uint8_t(LROUND(rad - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90))); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 959d0f9c09..1614dd6fbd 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -229,7 +229,7 @@ void GcodeSuite::G34() { // Probing sanity check is disabled, as it would trigger even in normal cases because // current_position.z has been manually altered in the "dirty trick" above. const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false); - if (ISNAN(z_probed_height)) { + if (isnan(z_probed_height)) { SERIAL_ECHOLNPGM("Probing failed"); LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); err_break = true; diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index db1a6db76d..8cfe6fee7b 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -113,7 +113,7 @@ void GcodeSuite::G76() { auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) { do_z_clearance(5.0); // Raise nozzle before probing const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false - if (ISNAN(measured_z)) + if (isnan(measured_z)) SERIAL_ECHOLNPGM("!Received NAN. Aborting."); else { SERIAL_ECHOLNPAIR_F("Measured: ", measured_z); @@ -208,7 +208,7 @@ void GcodeSuite::G76() { report_temps(next_temp_report); const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); - if (ISNAN(measured_z) || target_bed > BED_MAX_TARGET) break; + if (isnan(measured_z) || target_bed > BED_MAX_TARGET) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); @@ -267,7 +267,7 @@ void GcodeSuite::G76() { if (timeout) break; const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz); - if (ISNAN(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break; + if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 07e248fc3d..19b11f602a 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -134,7 +134,7 @@ void GcodeSuite::M48() { // Move to the first point, deploy, and probe const float t = probe.probe_at_point(test_position, raise_after, verbose_level); - bool probing_good = !ISNAN(t); + bool probing_good = !isnan(t); if (probing_good) { randomSeed(millis()); @@ -219,7 +219,7 @@ void GcodeSuite::M48() { const float pz = probe.probe_at_point(test_position, raise_after, 0); // Break the loop if the probe fails - probing_good = !ISNAN(pz); + probing_good = !isnan(pz); if (!probing_good) break; // Store the new sample diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index ebdc19f582..4347f55aa8 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -52,7 +52,7 @@ void GcodeSuite::G30() { const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; const float measured_z = probe.probe_at_point(pos, raise_after, 1); - if (!ISNAN(measured_z)) + if (!isnan(measured_z)) SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); restore_feedrate_and_scaling(); diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 0444c9e185..6ed4d33630 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -1460,7 +1460,7 @@ void MarlinUI::draw_status_screen() { * Print Z values */ _ZLABEL(_LCD_W_POS, 1); - if (!ISNAN(ubl.z_values[x_plot][y_plot])) + if (!isnan(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else lcd_put_u8str_P(PSTR(" -----")); @@ -1479,7 +1479,7 @@ void MarlinUI::draw_status_screen() { * Show the location value */ _ZLABEL(_LCD_W_POS, 3); - if (!ISNAN(ubl.z_values[x_plot][y_plot])) + if (!isnan(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else lcd_put_u8str_P(PSTR(" -----")); diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 6edde2c604..ddc33c4923 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -943,7 +943,7 @@ void MarlinUI::draw_status_screen() { // Show the location value lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str_P(PSTR("Z:")); - if (!ISNAN(ubl.z_values[x_plot][y_plot])) + if (!isnan(ubl.z_values[x_plot][y_plot])) lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot])); else lcd_put_u8str_P(PSTR(" -----")); diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 89f7746438..dc60c1bff3 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -569,7 +569,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Show the location value lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL); - if (!ISNAN(ubl.z_values[x_plot][y_plot])) + if (!isnan(ubl.z_values[x_plot][y_plot])) lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); else lcd_put_u8str_P(PSTR(" -----")); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp index 531f759c49..26be9f4e59 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp @@ -32,7 +32,7 @@ namespace FTDI { void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) { char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)]; - if (ISNAN(value)) + if (isnan(value)) strcpy_P(str, PSTR("-")); else dtostrf(value, width, precision, str); diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp index d64238808c..e83f09f045 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp @@ -31,7 +31,7 @@ void BedMeshBase::_drawMesh(CommandProcessor &cmd, int16_t x, int16_t y, int16_t constexpr uint8_t cols = GRID_MAX_POINTS_X; #define VALUE(X,Y) (func ? func(X,Y,data) : 0) - #define ISVAL(X,Y) (func ? !ISNAN(VALUE(X,Y)) : true) + #define ISVAL(X,Y) (func ? !isnan(VALUE(X,Y)) : true) #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0) // Compute the mean, min and max for the points diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp index 94e43bdec1..f2c775c993 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp @@ -79,7 +79,7 @@ void BedMeshEditScreen::onExit() { float BedMeshEditScreen::getHighlightedValue() { const float val = ExtUI::getMeshPoint(mydata.highlight); - return (ISNAN(val) ? 0 : val) + mydata.zAdjustment; + return (isnan(val) ? 0 : val) + mydata.zAdjustment; } void BedMeshEditScreen::setHighlightedValue(float value) { diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index c03a10fcd3..66bc10c411 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -421,7 +421,7 @@ namespace ExtUI { #if AXIS_IS_TMC(Z2) case Z2: return stepperZ2.getMilliamps(); #endif - default: return MFNAN; + default: return NAN; }; } @@ -451,7 +451,7 @@ namespace ExtUI { #if AXIS_IS_TMC(E7) case E7: return stepperE7.getMilliamps(); #endif - default: return MFNAN; + default: return NAN; }; } diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 0dc468e805..da7afd86ef 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -54,7 +54,7 @@ static bool probe_single_point() { z_measured[tram_index] = z_probed_height; move_to_tramming_wait_pos(); - return !ISNAN(z_probed_height); + return !isnan(z_probed_height); } static void _menu_single_probe(const uint8_t point) { diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 819414b828..e04d589858 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -505,7 +505,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 8429907f96..5563d3069b 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 4b02b21ea6..4d5a0b4fda 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index d408dd236d..d4b8409efa 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -583,7 +583,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { * @details Used by probe_at_point to get the bed Z height at the current XY. * Leaves current_position.z at the height where the probe triggered. * - * @return The Z position of the bed at the current XY or MFNAN on error. + * @return The Z position of the bed at the current XY or NAN on error. */ float Probe::run_z_probe(const bool sanity_check/*=true*/) { DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING)); @@ -617,11 +617,11 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { #if TOTAL_PROBING == 2 // Attempt to tare the probe - if (TERN0(PROBE_TARE, tare())) return MFNAN; + if (TERN0(PROBE_TARE, tare())) return NAN; // Do a first probe at the fast speed if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s, - sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return MFNAN; + sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN; const float first_probe_z = current_position.z; @@ -662,7 +662,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { // Probe downward slowly to find the bed if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW), - sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return MFNAN; + sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN; TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe()); @@ -765,29 +765,29 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai if (probe_relative) { // The given position is in terms of the probe if (!can_reach(npos)) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable"); - return MFNAN; + return NAN; } npos -= offset_xy; // Get the nozzle position } - else if (!position_is_reachable(npos)) return MFNAN; // The given position is in terms of the nozzle + else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle // Move the probe to the starting XYZ do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S)); - float measured_z = MFNAN; + float measured_z = NAN; if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z; - if (!ISNAN(measured_z)) { + if (!isnan(measured_z)) { const bool big_raise = raise_after == PROBE_PT_BIG_RAISE; if (big_raise || raise_after == PROBE_PT_RAISE) do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s); else if (raise_after == PROBE_PT_STOW) - if (stow()) measured_z = MFNAN; // Error on stow? + if (stow()) measured_z = NAN; // Error on stow? if (verbose_level > 2) SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z); } - if (ISNAN(measured_z)) { + if (isnan(measured_z)) { stow(); LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED); #if DISABLED(G29_RETRY_AND_RECOVER) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index d1fd719cfb..915886fe4a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -900,8 +900,8 @@ void MarlinSettings::postprocess() { HOTEND_LOOP() { PIDCF_t pidcf = { #if DISABLED(PIDTEMP) - MFNAN, MFNAN, MFNAN, - MFNAN, MFNAN + NAN, NAN, NAN, + NAN, NAN #else PID_PARAM(Kp, e), unscalePID_i(PID_PARAM(Ki, e)), @@ -928,7 +928,7 @@ void MarlinSettings::postprocess() { const PID_t bed_pid = { #if DISABLED(PIDTEMPBED) - MFNAN, MFNAN, MFNAN + NAN, NAN, NAN #else // Store the unscaled PID values thermalManager.temp_bed.pid.Kp, @@ -947,7 +947,7 @@ void MarlinSettings::postprocess() { const PID_t chamber_pid = { #if DISABLED(PIDTEMPCHAMBER) - MFNAN, MFNAN, MFNAN + NAN, NAN, NAN #else // Store the unscaled PID values thermalManager.temp_chamber.pid.Kp, @@ -1786,7 +1786,7 @@ void MarlinSettings::postprocess() { PIDCF_t pidcf; EEPROM_READ(pidcf); #if ENABLED(PIDTEMP) - if (!validating && !ISNAN(pidcf.Kp)) { + if (!validating && !isnan(pidcf.Kp)) { // Scale PID values since EEPROM values are unscaled PID_PARAM(Kp, e) = pidcf.Kp; PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki); @@ -1818,7 +1818,7 @@ void MarlinSettings::postprocess() { PID_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPBED) - if (!validating && !ISNAN(pid.Kp)) { + if (!validating && !isnan(pid.Kp)) { // Scale PID values since EEPROM values are unscaled thermalManager.temp_bed.pid.Kp = pid.Kp; thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki); @@ -1834,7 +1834,7 @@ void MarlinSettings::postprocess() { PID_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPCHAMBER) - if (!validating && !ISNAN(pid.Kp)) { + if (!validating && !isnan(pid.Kp)) { // Scale PID values since EEPROM values are unscaled thermalManager.temp_chamber.pid.Kp = pid.Kp; thermalManager.temp_chamber.pid.Ki = scalePID_i(pid.Ki); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index e1e7f56d17..d2b3db8747 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -74,9 +74,9 @@ hotend_pid_t; #endif #define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0 & H)) // Always use 'H' to suppress warning -#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, MFNAN) -#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, MFNAN) -#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, MFNAN) +#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, NAN) +#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, NAN) +#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, NAN) #if ENABLED(PIDTEMP) #define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1) #define _PID_Kf(H) TERN(PID_FAN_SCALING, Temperature::temp_hotend[H].pid.Kf, 0) diff --git a/platformio.ini b/platformio.ini index 53db8fc4b1..87b6e8a90b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -38,7 +38,7 @@ extra_configs = # The 'common' values are used for most Marlin builds # [common] -build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants -fno-signed-zeros -ffinite-math-only +build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py From c6c6c5618669665669e3040821d0b662701bcf3a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 16 Apr 2021 02:50:45 -0500 Subject: [PATCH 229/311] SDIO cleanup --- Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp index 824142b889..3353f8c36b 100644 --- a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp +++ b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp @@ -85,8 +85,8 @@ #define SDIO_CMD_PIN PD2 SD_HandleTypeDef hsd; // create SDIO structure - // F4 support one dma for RX and another for TX. - // But Marlin will never do read and write at same time, so we use always one dma for both. + // F4 supports one DMA for RX and another for TX, but Marlin will never + // do read and write at same time, so we use the same DMA for both. DMA_HandleTypeDef hdma_sdio; /* @@ -274,7 +274,7 @@ } static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) { - if(HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false; + if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false; TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); @@ -296,10 +296,10 @@ return false; } - uint32_t timeout = millis() + 500; + millis_t timeout = millis() + 500; // Wait the transfer while (hsd.State != HAL_SD_STATE_READY) { - if (millis() > timeout) { + if (ELAPSED(millis(), timeout)) { HAL_DMA_Abort_IT(&hdma_sdio); HAL_DMA_DeInit(&hdma_sdio); return false; @@ -313,8 +313,7 @@ HAL_DMA_DeInit(&hdma_sdio); timeout = millis() + 500; - while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) - if (millis() > timeout) return false; + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false; return true; } From 2d1d628340a6b4dd38ae808e6423438fa153de57 Mon Sep 17 00:00:00 2001 From: Luca Zimmermann Date: Fri, 16 Apr 2021 11:01:50 +0200 Subject: [PATCH 230/311] Always swap with PRIME_FIRST_USED disabled (#21622) --- Marlin/src/module/tool_change.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 3dd63e814c..080c1e629b 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -928,13 +928,15 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #endif // First tool priming. To prime again, reboot the machine. - #if BOTH(TOOLCHANGE_FILAMENT_SWAP, TOOLCHANGE_FS_PRIME_FIRST_USED) + #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) static bool first_tool_is_primed = false; if (new_tool == old_tool && !first_tool_is_primed && enable_first_prime) { tool_change_prime(); first_tool_is_primed = true; - toolchange_extruder_ready[old_tool] = true; // Primed and initialized + TERN_(TOOLCHANGE_FS_INIT_BEFORE_SWAP, toolchange_extruder_ready[old_tool] = true); // Primed and initialized } + #else + constexpr bool first_tool_is_primed = true; #endif if (new_tool != old_tool || TERN0(PARKING_EXTRUDER, extruder_parked)) { // PARKING_EXTRUDER may need to attach old_tool when homing @@ -970,12 +972,10 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (ENABLED(SINGLENOZZLE)) { active_extruder = new_tool; return; } } else { - #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) - // For first new tool, change without unloading the old. 'Just prime/init the new' - if (first_tool_is_primed) - unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); - first_tool_is_primed = true; // The first new tool will be primed by toolchanging - #endif + // For first new tool, change without unloading the old. 'Just prime/init the new' + if (first_tool_is_primed) + unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); + TERN_(TOOLCHANGE_FS_PRIME_FIRST_USED, first_tool_is_primed = true); // The first new tool will be primed by toolchanging } } #endif From 253ee0c407120526b821c0f3251bda0afb69d934 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 16 Apr 2021 04:04:07 -0500 Subject: [PATCH 231/311] Init pwm_thrs to 0 when HYBRID_THRESHOLD is off (#21623) --- Marlin/src/feature/tmc_util.h | 35 ++++++++++++++++---------- Marlin/src/module/stepper/trinamic.cpp | 17 ++++++------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 1767313ba2..0d6105358d 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -120,12 +120,15 @@ class TMCMarlin : public TMC, public TMCStorage { uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } - void set_pwm_thrs(const uint32_t thrs) { - TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); - } #endif + void set_pwm_thrs(const uint32_t thrs) { + TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); + #if BOTH(HYBRID_THRESHOLD, HAS_LCD_MENU) + this->stored.hybrid_thrs = thrs; + #endif + } + #if USE_SENSORLESS inline int16_t homing_threshold() { return TMC::sgt(); } void homing_threshold(int16_t sgt_val) { @@ -185,19 +188,21 @@ class TMCMarlin : public TMC220 inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } #endif + void set_pwm_thrs(const uint32_t thrs) { + TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); + #if BOTH(HYBRID_THRESHOLD, HAS_LCD_MENU) + this->stored.hybrid_thrs = thrs; + #endif + } + #if ENABLED(HYBRID_THRESHOLD) uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } - void set_pwm_thrs(const uint32_t thrs) { - TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); - } #endif #if HAS_LCD_MENU inline void refresh_stepper_current() { rms_current(this->val_mA); } - #if ENABLED(HYBRID_THRESHOLD) inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } #endif @@ -237,11 +242,15 @@ class TMCMarlin : public TMC220 uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } - void set_pwm_thrs(const uint32_t thrs) { - TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); - } #endif + + void set_pwm_thrs(const uint32_t thrs) { + TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); + #if BOTH(HYBRID_THRESHOLD, HAS_LCD_MENU) + this->stored.hybrid_thrs = thrs; + #endif + } + #if USE_SENSORLESS inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); } void homing_threshold(int16_t sgt_val) { diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index de3d45e4b6..561e947190 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -158,7 +158,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ampl = 180; st.PWMCONF(pwmconf.sr); - TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); + st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); st.GSTAT(); // Clear GSTAT } @@ -196,7 +196,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); + st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); st.GSTAT(); // Clear GSTAT } @@ -517,7 +517,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); + st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); st.GSTAT(0b111); // Clear delay(200); @@ -559,7 +559,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); + st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); st.GSTAT(0b111); // Clear delay(200); @@ -617,7 +617,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ampl = 180; st.PWMCONF(pwmconf.sr); - TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); + st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); st.GSTAT(); // Clear GSTAT } @@ -655,11 +655,8 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - #if ENABLED(HYBRID_THRESHOLD) - st.set_pwm_thrs(hyb_thrs); - #else - UNUSED(hyb_thrs); - #endif + st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); + st.GSTAT(); // Clear GSTAT } #endif // TMC5160 From 07cac80fb028f26fd2b1badfea069c80938dfd0c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 16 Apr 2021 04:28:16 -0500 Subject: [PATCH 232/311] Drop extraneous inlines --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 8635661d01..d28ef1182e 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -102,7 +102,7 @@ static int8_t bed_corner; /** * Select next corner coordinates */ -static inline void _lcd_level_bed_corners_get_next_position() { +static void _lcd_level_bed_corners_get_next_position() { if (level_corners_3_points) { if (bed_corner >= available_points) bed_corner = 0; // Above max position -> move back to first corner @@ -268,7 +268,7 @@ static inline void _lcd_level_bed_corners_get_next_position() { ui.goto_screen(_lcd_draw_probing); do { ui.refresh(LCDVIEW_REDRAW_NOW); - _lcd_draw_probing(); // update screen with # of good points + _lcd_draw_probing(); // update screen with # of good points do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates @@ -308,7 +308,7 @@ static inline void _lcd_level_bed_corners_get_next_position() { #else // !LEVEL_CORNERS_USE_PROBE - static inline void _lcd_goto_next_corner() { + static void _lcd_goto_next_corner() { line_to_z(LEVEL_CORNERS_Z_HOP); // Select next corner coordinates @@ -321,7 +321,7 @@ static inline void _lcd_level_bed_corners_get_next_position() { #endif // !LEVEL_CORNERS_USE_PROBE -static inline void _lcd_level_bed_corners_homing() { +static void _lcd_level_bed_corners_homing() { _lcd_draw_homing(); if (!all_axes_homed()) return; #if ENABLED(LEVEL_CORNERS_USE_PROBE) From 73f6426114d3f307d741d0e9ab8258a8cb103ff1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 14 Apr 2021 00:26:57 -0500 Subject: [PATCH 233/311] Use itoa for sprintf int --- Marlin/src/HAL/DUE/usb/usb_task.c | 2 +- .../lib/mks_ui/draw_acceleration_settings.cpp | 10 +++++----- .../lib/mks_ui/draw_filament_settings.cpp | 10 +++++----- .../draw_homing_sensitivity_settings.cpp | 8 ++++---- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 6 +++--- .../lib/mks_ui/draw_tramming_pos_settings.cpp | 20 +++++++++---------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Marlin/src/HAL/DUE/usb/usb_task.c b/Marlin/src/HAL/DUE/usb/usb_task.c index acb1d5b933..54a808d7f4 100644 --- a/Marlin/src/HAL/DUE/usb/usb_task.c +++ b/Marlin/src/HAL/DUE/usb/usb_task.c @@ -322,7 +322,7 @@ void usb_task_init(void) { char *sptr; // Patch in the filament diameter - sprintf_P(diam, PSTR("%d"), (int)((DEFAULT_NOMINAL_FILAMENT_DIA) * 1000.0)); + itoa((int)((DEFAULT_NOMINAL_FILAMENT_DIA) * 1000), diam, 10); // And copy it to the proper place, expanding it to unicode sptr = &diam[0]; 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 7bc5a263b4..8137c3a909 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 @@ -119,22 +119,22 @@ void lv_draw_acceleration_settings() { dtostrf(planner.settings.travel_acceleration, 1, 1, public_buf_l); 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]); + itoa(planner.settings.max_acceleration_mm_per_s2[X_AXIS], public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.X_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_ACCE_X, 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_ACCE_DOWN, true); } else { - sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + itoa(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ACCE_Y, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + itoa(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_ACCE_Z, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]); + itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS], public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.E0_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_ACCE_E0, 2, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]); + itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.E1_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_ACCE_E1, 3, 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_ACCE_UP, true); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp index 553cb29895..d78c9ed0cb 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp @@ -92,22 +92,22 @@ void lv_draw_filament_settings() { scr = lv_screen_create(FILAMENT_SETTINGS_UI, machine_menu.FilamentConfTitle); if (!uiCfg.para_ui_page) { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length); + itoa(gCfgItems.filamentchange_load_length, public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.InLength, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_IN_LENGTH, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_speed); + itoa(gCfgItems.filamentchange_load_speed, public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.InSpeed, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FILAMENT_SET_IN_SPEED, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_length); + itoa(gCfgItems.filamentchange_unload_length, public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.OutLength, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FILAMENT_SET_OUT_LENGTH, 2, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_speed); + itoa(gCfgItems.filamentchange_unload_speed, public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.OutSpeed, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FILAMENT_SET_OUT_SPEED, 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_FILAMENT_SET_DOWN, true); } else { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temp); + itoa(gCfgItems.filament_limit_temp, public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.FilamentTemperature, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_TEMP, 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_FILAMENT_SET_UP, true); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp index 9a1c9dec2a..696463d3eb 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp @@ -77,17 +77,17 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_draw_homing_sensitivity_settings() { scr = lv_screen_create(HOMING_SENSITIVITY_UI, machine_menu.HomingSensitivityConfTitle); - sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0)); + itoa(TERN(X_SENSORLESS, stepperX.homing_threshold(), 0), public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.X_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_SENSITIVITY_X, 0, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0)); + itoa(TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0), public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_SENSITIVITY_Y, 1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0)); + itoa(TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0), public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_SENSITIVITY_Z, 2, public_buf_l); #if Z2_SENSORLESS - sprintf_P(public_buf_l, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0)); + itoa(TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0), public_buf_l, 10); lv_screen_menu_item_1_edit(scr, machine_menu.Z2_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_SENSITIVITY_Z2, 3, public_buf_l); #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 09784b5184..8340e2ae87 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -216,7 +216,7 @@ void lv_draw_ready_print() { labelFan = lv_label_create(scr, 380, 80, nullptr); - sprintf_P(buf, PSTR("%d"), (int)thermalManager.degHotend(0)); + itoa(thermalManager.degHotend(0), buf, 10); lv_label_set_text(labelExt1, buf); lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(0)); @@ -224,7 +224,7 @@ void lv_draw_ready_print() { lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #if HAS_MULTI_EXTRUDER - sprintf_P(buf, PSTR("%d"), (int)thermalManager.degHotend(1)); + itoa(thermalManager.degHotend(1), buf, 10); lv_label_set_text(labelExt2, buf); lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(1)); @@ -233,7 +233,7 @@ void lv_draw_ready_print() { #endif #if HAS_HEATED_BED - sprintf_P(buf, PSTR("%d"), (int)thermalManager.degBed()); + itoa(thermalManager.degBed(), buf, 10); lv_label_set_text(labelBed, buf); lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetBed()); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp index 9b6c11d335..539c7639dc 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp @@ -107,27 +107,27 @@ void lv_draw_tramming_pos_settings() { scr = lv_screen_create(MANUAL_LEVELING_POSIGION_UI, machine_menu.LevelingParaConfTitle); if (!uiCfg.para_ui_page) { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[0].x); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[0].y); + itoa(gCfgItems.trammingPos[0].x, public_buf_l, 10); + itoa(gCfgItems.trammingPos[0].y, buf2, 10); lv_screen_menu_item_2_edit(scr, leveling_menu.position1, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y1, 0, buf2, ID_MANUAL_POS_X1, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[1].x); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[1].y); + itoa(gCfgItems.trammingPos[1].x, public_buf_l, 10); + itoa(gCfgItems.trammingPos[1].y, buf2, 10); lv_screen_menu_item_2_edit(scr, leveling_menu.position2, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MANUAL_POS_Y2, 1, buf2, ID_MANUAL_POS_X2, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[2].x); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[2].y); + itoa(gCfgItems.trammingPos[2].x, public_buf_l, 10); + itoa(gCfgItems.trammingPos[2].y, buf2, 10); lv_screen_menu_item_2_edit(scr, leveling_menu.position3, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MANUAL_POS_Y3, 2, buf2, ID_MANUAL_POS_X3, public_buf_l); - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[3].x); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[3].y); + itoa(gCfgItems.trammingPos[3].x, public_buf_l, 10); + itoa(gCfgItems.trammingPos[3].y, buf2, 10); lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_MANUAL_POS_Y4, 3, buf2, ID_MANUAL_POS_X4, 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_MANUAL_POS_DOWN, true); } else { - sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.trammingPos[4].x); - sprintf_P(buf2, PSTR("%d"), gCfgItems.trammingPos[4].y); + itoa(gCfgItems.trammingPos[4].x, public_buf_l, 10); + itoa(gCfgItems.trammingPos[4].y, buf2, 10); lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y5, 0, buf2, ID_MANUAL_POS_X5, 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_MANUAL_POS_UP, true); From 553487cc8ab348939c6033910c0aa11d230b2ad6 Mon Sep 17 00:00:00 2001 From: MangaValk Date: Fri, 16 Apr 2021 15:02:31 +0200 Subject: [PATCH 234/311] Tool sensors (#17239) --- Marlin/Configuration_adv.h | 6 + Marlin/src/MarlinCore.cpp | 7 +- Marlin/src/lcd/menu/menu_configuration.cpp | 1 + Marlin/src/module/tool_change.cpp | 156 +++++++++++++++++--- Marlin/src/module/tool_change.h | 9 +- Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h | 16 +- buildroot/tests/BIGTREE_GTR_V1_0 | 7 + 7 files changed, 174 insertions(+), 28 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 578bf144fc..02a5ff0eeb 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2198,6 +2198,12 @@ //#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // Extra G-code to run after tool-change #endif + /** + * Tool Sensors detect when tools have been picked up or dropped. + * Requires the pins TOOL_SENSOR1_PIN, TOOL_SENSOR2_PIN, etc. + */ + //#define TOOL_SENSOR + /** * Retract and prime filament on tool-change to reduce * ooze and stringing and to get cleaner transitions. diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 842429a407..2e1eab86de 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -210,9 +210,7 @@ #include "feature/fanmux.h" #endif -#if DO_SWITCH_EXTRUDER || ANY(SWITCHING_NOZZLE, PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER, ELECTROMAGNETIC_SWITCHING_TOOLHEAD, SWITCHING_TOOLHEAD) - #include "module/tool_change.h" -#endif +#include "module/tool_change.h" #if ENABLED(USE_CONTROLLER_FAN) #include "feature/controllerfan.h" @@ -731,6 +729,9 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) { // Return if setup() isn't completed if (marlin_state == MF_INITIALIZING) goto IDLE_DONE; + // TODO: Still causing errors + (void)check_tool_sensor_stats(active_extruder, true); + // Handle filament runout sensors TERN_(HAS_FILAMENT_SENSOR, runout.run()); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 7ef49f0cf8..7ea355b795 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -130,6 +130,7 @@ void menu_advanced_settings(); #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) #include "../../module/motion.h" // for active_extruder + #include "../../gcode/queue.h" void menu_toolchange_migration() { PGM_P const msg_migrate = GET_TEXT(MSG_TOOL_MIGRATION_SWAP); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 080c1e629b..2b8a434172 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -49,10 +49,14 @@ bool toolchange_extruder_ready[EXTRUDERS]; #endif -#if ENABLED(MAGNETIC_PARKING_EXTRUDER) || defined(EVENT_GCODE_AFTER_TOOLCHANGE) || (ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0) +#if EITHER(MAGNETIC_PARKING_EXTRUDER, TOOL_SENSOR) || defined(EVENT_GCODE_AFTER_TOOLCHANGE) || (ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0) #include "../gcode/gcode.h" #endif +#if ENABLED(TOOL_SENSOR) + #include "../lcd/marlinui.h" +#endif + #if ENABLED(DUAL_X_CARRIAGE) #include "stepper.h" #endif @@ -147,11 +151,11 @@ #endif // SWITCHING_NOZZLE -inline void _line_to_current(const AxisEnum fr_axis, const float fscale=1) { +void _line_to_current(const AxisEnum fr_axis, const float fscale=1) { line_to_current_position(planner.settings.max_feedrate_mm_s[fr_axis] * fscale); } -inline void slow_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.5f); } -inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis); } +void slow_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.2f); } +void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.5f); } #if ENABLED(MAGNETIC_PARKING_EXTRUDER) @@ -370,7 +374,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a DEBUG_POS("PE Tool-Change done.", current_position); parking_extruder_set_parked(false); } - else if (do_solenoid_activation) { // && nomove == true + else if (do_solenoid_activation) { // Deactivate current extruder solenoid pe_solenoid_set_pin_state(active_extruder, !PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE); // Engage new extruder magnetic field @@ -384,12 +388,117 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a #if ENABLED(SWITCHING_TOOLHEAD) - inline void swt_lock(const bool locked=true) { - const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES; - MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, swt_angles[locked ? 0 : 1]); + // Return a bitmask of tool sensor states + inline uint8_t poll_tool_sensor_pins() { + return (0 + #if ENABLED(TOOL_SENSOR) + #if PIN_EXISTS(TOOL_SENSOR1) + | (READ(TOOL_SENSOR1_PIN) << 0) + #endif + #if PIN_EXISTS(TOOL_SENSOR2) + | (READ(TOOL_SENSOR2_PIN) << 1) + #endif + #if PIN_EXISTS(TOOL_SENSOR3) + | (READ(TOOL_SENSOR3_PIN) << 2) + #endif + #if PIN_EXISTS(TOOL_SENSOR4) + | (READ(TOOL_SENSOR4_PIN) << 3) + #endif + #if PIN_EXISTS(TOOL_SENSOR5) + | (READ(TOOL_SENSOR5_PIN) << 4) + #endif + #if PIN_EXISTS(TOOL_SENSOR6) + | (READ(TOOL_SENSOR6_PIN) << 5) + #endif + #if PIN_EXISTS(TOOL_SENSOR7) + | (READ(TOOL_SENSOR7_PIN) << 6) + #endif + #if PIN_EXISTS(TOOL_SENSOR8) + | (READ(TOOL_SENSOR8_PIN) << 7) + #endif + #endif + ); } - void swt_init() { swt_lock(); } + #if ENABLED(TOOL_SENSOR) + + bool tool_sensor_disabled; // = false + + uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) { + static uint8_t sensor_tries; // = 0 + for (;;) { + if (poll_tool_sensor_pins() == _BV(tool_index)) { + sensor_tries = 0; + return tool_index; + } + else if (kill_on_error && (!tool_sensor_disabled || disable)) { + sensor_tries++; + if (sensor_tries > 10) kill(PSTR("Tool Sensor error")); + safe_delay(5); + } + else { + sensor_tries++; + if (sensor_tries > 10) return -1; + safe_delay(5); + } + } + } + + #endif + + inline void switching_toolhead_lock(const bool locked) { + #ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES + const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES; + MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, swt_angles[locked ? 0 : 1]); + #elif PIN_EXISTS(SWT_SOLENOID) + OUT_WRITE(SWT_SOLENOID_PIN, locked); + gcode.dwell(10); + #else + #error "No toolhead locking mechanism configured." + #endif + } + + #include + + void swt_init() { + switching_toolhead_lock(true); + + #if ENABLED(TOOL_SENSOR) + // Init tool sensors + #if PIN_EXISTS(TOOL_SENSOR1) + SET_INPUT_PULLUP(TOOL_SENSOR1_PIN); + #endif + #if PIN_EXISTS(TOOL_SENSOR2) + SET_INPUT_PULLUP(TOOL_SENSOR2_PIN); + #endif + #if PIN_EXISTS(TOOL_SENSOR3) + SET_INPUT_PULLUP(TOOL_SENSOR3_PIN); + #endif + #if PIN_EXISTS(TOOL_SENSOR4) + SET_INPUT_PULLUP(TOOL_SENSOR4_PIN); + #endif + #if PIN_EXISTS(TOOL_SENSOR5) + SET_INPUT_PULLUP(TOOL_SENSOR5_PIN); + #endif + #if PIN_EXISTS(TOOL_SENSOR6) + SET_INPUT_PULLUP(TOOL_SENSOR6_PIN); + #endif + #if PIN_EXISTS(TOOL_SENSOR7) + SET_INPUT_PULLUP(TOOL_SENSOR7_PIN); + #endif + #if PIN_EXISTS(TOOL_SENSOR8) + SET_INPUT_PULLUP(TOOL_SENSOR8_PIN); + #endif + + if (check_tool_sensor_stats(0)) { + ui.set_status_P("TC error"); + switching_toolhead_lock(false); + while (check_tool_sensor_stats(0)) { /* nada */ } + switching_toolhead_lock(true); + } + ui.set_status_P("TC Success"); + #endif + } inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (no_move) return; @@ -398,6 +507,8 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a const float placexpos = toolheadposx[active_extruder], grabxpos = toolheadposx[new_tool]; + (void)check_tool_sensor_stats(active_extruder, true); + /** * 1. Move to switch position of current toolhead * 2. Unlock tool and drop it in the dock @@ -421,13 +532,14 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a DEBUG_SYNCHRONIZE(); DEBUG_POS("Move Y SwitchPos + Security", current_position); - fast_line_to_current(Y_AXIS); + slow_line_to_current(Y_AXIS); // 2. Unlock tool and drop it in the dock + TERN_(TOOL_SENSOR, tool_sensor_disabled = true); planner.synchronize(); DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead"); - swt_lock(false); + switching_toolhead_lock(false); safe_delay(500); current_position.y = SWITCHING_TOOLHEAD_Y_POS; @@ -440,7 +552,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR; DEBUG_POS("Move back Y clear", current_position); - fast_line_to_current(Y_AXIS); // move away from docked toolhead + slow_line_to_current(Y_AXIS); // move away from docked toolhead + + (void)check_tool_sensor_stats(active_extruder); // 3. Move to the new toolhead @@ -457,7 +571,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a DEBUG_SYNCHRONIZE(); DEBUG_POS("Move Y SwitchPos + Security", current_position); - fast_line_to_current(Y_AXIS); + slow_line_to_current(Y_AXIS); // 4. Grab and lock the new toolhead @@ -472,14 +586,19 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a // Wait for move to finish, pause 0.2s, move servo, pause 0.5s planner.synchronize(); safe_delay(200); - swt_lock(); + + (void)check_tool_sensor_stats(new_tool, true, true); + + switching_toolhead_lock(true); safe_delay(500); current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR; DEBUG_POS("Move back Y clear", current_position); - fast_line_to_current(Y_AXIS); // Move away from docked toolhead + slow_line_to_current(Y_AXIS); // Move away from docked toolhead planner.synchronize(); // Always sync the final move + (void)check_tool_sensor_stats(new_tool, true, true); + DEBUG_POS("ST Tool-Change done.", current_position); } @@ -1053,8 +1172,11 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { move_nozzle_servo(new_tool); #endif - // Set the new active extruder - if (DISABLED(DUAL_X_CARRIAGE)) active_extruder = new_tool; + IF_DISABLED(DUAL_X_CARRIAGE, active_extruder = new_tool); // Set the new active extruder + + TERN_(TOOL_SENSOR, tool_sensor_disabled = false); + + (void)check_tool_sensor_stats(active_extruder, true); // The newly-selected extruder XYZ is actually at... DEBUG_ECHOLNPAIR("Offset Tool XYZ by { ", diff.x, ", ", diff.y, ", ", diff.z, " }"); diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index b79ec676a0..bbdc0b6862 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -79,10 +79,9 @@ #if ENABLED(PARKING_EXTRUDER) - #define PE_MAGNET_ON_STATE TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT, !)PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE - void pe_solenoid_set_pin_state(const uint8_t extruder_num, const uint8_t state); + #define PE_MAGNET_ON_STATE TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT, !)PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE inline void pe_solenoid_magnet_on(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, PE_MAGNET_ON_STATE); } inline void pe_solenoid_magnet_off(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, !PE_MAGNET_ON_STATE); } @@ -115,6 +114,12 @@ void swt_init(); #endif +#if ENABLED(TOOL_SENSOR) + uint8_t check_tool_sensor_stats(const uint8_t active_tool, const bool kill_on_error=false, const bool disable=false); +#else + inline uint8_t check_tool_sensor_stats(const uint8_t, const bool=false, const bool=false) { return 0; } +#endif + /** * Perform a tool-change, which may result in moving the * previous tool out of the way and the new tool into place. diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index 6c59f27c5e..cae1261a81 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -38,17 +38,21 @@ // USB Flash Drive support #define HAS_OTG_USB_HOST_SUPPORT -#define TP // Enable to define servo and probe pins #define M5_EXTENDER // The M5 extender is attached // // Servos // -#if ENABLED(TP) - #define SERVO0_PIN PB11 -#endif +#define SERVO0_PIN PB11 // BLTOUCH +#define SOL0_PIN PC7 // Toolchanger -#define PS_ON_PIN PH6 +#if ENABLED(TOOL_SENSOR) + #define TOOL_SENSOR1_PIN PH6 + #define TOOL_SENSOR2_PIN PI4 + //#define TOOL_SENSOR3_PIN PF4 +#else + #define PS_ON_PIN PH6 +#endif // // Trinamic Stallguard pins @@ -110,7 +114,7 @@ #define Z4_STOP_PIN PF6 // M5 M3_STOP #endif -#if ENABLED(TP) && !defined(Z_MIN_PROBE_PIN) +#ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN PH11 // Z Probe must be PH11 #endif diff --git a/buildroot/tests/BIGTREE_GTR_V1_0 b/buildroot/tests/BIGTREE_GTR_V1_0 index 95a1e0acac..24293a4932 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0 +++ b/buildroot/tests/BIGTREE_GTR_V1_0 @@ -26,5 +26,12 @@ opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_INIT_BEFORE_SWAP TOOLCHANGE_FS_PRIME_FIRST_USED PID_PARAMS_PER_HOTEND exec_test $1 $2 "BigTreeTech GTR | 6 Extruders | Triple Z" "$3" +restore_configs +opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ + EXTRUDERS 3 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 \ + SERVO_DELAY '{ 300, 300, 300 }' +opt_enable SWITCHING_TOOLHEAD TOOL_SENSOR +exec_test $1 $2 "BigTreeTech GTR | Switching Toolhead | Tool Sensors" "$3" + # clean up restore_configs From 464b2242e246f47fb3b16b00a12d3d0a80a5f0b1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 16 Apr 2021 09:30:39 -0500 Subject: [PATCH 235/311] Better chopper defaults --- Marlin/Configuration_adv.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 02a5ff0eeb..bd4793c55c 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2680,22 +2680,22 @@ * { , , hysteresis_start[1..8] } */ #define CHOPPER_TIMING CHOPPER_DEFAULT_12V // All axes (override below) - //#define CHOPPER_TIMING_X CHOPPER_DEFAULT_12V // For X Axes (override below) - //#define CHOPPER_TIMING_X2 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_Y CHOPPER_DEFAULT_12V // For Y Axes (override below) - //#define CHOPPER_TIMING_Y2 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_Z CHOPPER_DEFAULT_12V // For Z Axes (override below) - //#define CHOPPER_TIMING_Z2 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_Z3 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_Z4 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_E CHOPPER_DEFAULT_12V // For Extruders (override below) - //#define CHOPPER_TIMING_E1 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_E2 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_E3 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_E4 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_E5 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_E6 CHOPPER_DEFAULT_12V - //#define CHOPPER_TIMING_E7 CHOPPER_DEFAULT_12V + //#define CHOPPER_TIMING_X CHOPPER_TIMING // For X Axes (override below) + //#define CHOPPER_TIMING_X2 CHOPPER_TIMING_X + //#define CHOPPER_TIMING_Y CHOPPER_TIMING // For Y Axes (override below) + //#define CHOPPER_TIMING_Y2 CHOPPER_TIMING_Y + //#define CHOPPER_TIMING_Z CHOPPER_TIMING // For Z Axes (override below) + //#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z + //#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z + //#define CHOPPER_TIMING_Z4 CHOPPER_TIMING_Z + //#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below) + //#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E + //#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E + //#define CHOPPER_TIMING_E3 CHOPPER_TIMING_E + //#define CHOPPER_TIMING_E4 CHOPPER_TIMING_E + //#define CHOPPER_TIMING_E5 CHOPPER_TIMING_E + //#define CHOPPER_TIMING_E6 CHOPPER_TIMING_E + //#define CHOPPER_TIMING_E7 CHOPPER_TIMING_E /** * Monitor Trinamic drivers From 3c4308b7b6c3560f9b880869faa56990cf42676e Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 17 Apr 2021 00:33:21 +0000 Subject: [PATCH 236/311] [cron] Bump distribution date (2021-04-17) --- 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 54020e6c44..080bf38df8 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-04-16" + #define STRING_DISTRIBUTION_DATE "2021-04-17" #endif /** From bca4652c5e48415cf478da229a253a2106da3e59 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 17 Apr 2021 02:03:16 -0500 Subject: [PATCH 237/311] Leave Hybrid Threshold as-is for now Reverting 253ee0c407 --- Marlin/src/feature/tmc_util.h | 35 ++++++++++---------------- Marlin/src/module/stepper/trinamic.cpp | 17 +++++++------ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 0d6105358d..1767313ba2 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -120,15 +120,12 @@ class TMCMarlin : public TMC, public TMCStorage { uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } + void set_pwm_thrs(const uint32_t thrs) { + TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); + TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + } #endif - void set_pwm_thrs(const uint32_t thrs) { - TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - #if BOTH(HYBRID_THRESHOLD, HAS_LCD_MENU) - this->stored.hybrid_thrs = thrs; - #endif - } - #if USE_SENSORLESS inline int16_t homing_threshold() { return TMC::sgt(); } void homing_threshold(int16_t sgt_val) { @@ -188,21 +185,19 @@ class TMCMarlin : public TMC220 inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } #endif - void set_pwm_thrs(const uint32_t thrs) { - TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - #if BOTH(HYBRID_THRESHOLD, HAS_LCD_MENU) - this->stored.hybrid_thrs = thrs; - #endif - } - #if ENABLED(HYBRID_THRESHOLD) uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } + void set_pwm_thrs(const uint32_t thrs) { + TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); + TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + } #endif #if HAS_LCD_MENU inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if ENABLED(HYBRID_THRESHOLD) inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } #endif @@ -242,15 +237,11 @@ class TMCMarlin : public TMC220 uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } + void set_pwm_thrs(const uint32_t thrs) { + TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); + TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + } #endif - - void set_pwm_thrs(const uint32_t thrs) { - TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - #if BOTH(HYBRID_THRESHOLD, HAS_LCD_MENU) - this->stored.hybrid_thrs = thrs; - #endif - } - #if USE_SENSORLESS inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); } void homing_threshold(int16_t sgt_val) { diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index 561e947190..de3d45e4b6 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -158,7 +158,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ampl = 180; st.PWMCONF(pwmconf.sr); - st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); + TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); st.GSTAT(); // Clear GSTAT } @@ -196,7 +196,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); + TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); st.GSTAT(); // Clear GSTAT } @@ -517,7 +517,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); + TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); st.GSTAT(0b111); // Clear delay(200); @@ -559,7 +559,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); + TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); st.GSTAT(0b111); // Clear delay(200); @@ -617,7 +617,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ampl = 180; st.PWMCONF(pwmconf.sr); - st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); + TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs)); st.GSTAT(); // Clear GSTAT } @@ -655,8 +655,11 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; pwmconf.pwm_ofs = 36; st.PWMCONF(pwmconf.sr); - st.set_pwm_thrs(TERN0(HYBRID_THRESHOLD, hyb_thrs)); UNUSED(hyb_thrs); - + #if ENABLED(HYBRID_THRESHOLD) + st.set_pwm_thrs(hyb_thrs); + #else + UNUSED(hyb_thrs); + #endif st.GSTAT(); // Clear GSTAT } #endif // TMC5160 From b8cf818dac851f6d57de49f6f45cdfe2da884a00 Mon Sep 17 00:00:00 2001 From: fedetony <45215920+fedetony@users.noreply.github.com> Date: Sat, 17 Apr 2021 10:54:43 +0200 Subject: [PATCH 238/311] Fix Realtime Reporting with G-code Motion Modes (#21630) --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 1 + Marlin/src/gcode/parser.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 8cc0a66216..735fad015e 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -901,6 +901,7 @@ G29_TYPE GcodeSuite::G29() { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); G29_RETURN(isnan(abl.measured_z)); + } #endif // HAS_ABL_NOT_UBL diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 9f0d09563e..8cbbe1d19d 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -217,10 +217,10 @@ void GCodeParser::parse(char *p) { #if ENABLED(GCODE_MOTION_MODES) #if ENABLED(ARC_SUPPORT) - case 'I' ... 'J': case 'R': + case 'I' ... 'J': if (motion_mode_codenum != 2 && motion_mode_codenum != 3) return; #endif - case 'P' ... 'Q': + case 'Q': if (motion_mode_codenum != 5) return; case 'X' ... 'Z': case 'E' ... 'F': if (motion_mode_codenum < 0) return; @@ -229,15 +229,23 @@ void GCodeParser::parse(char *p) { TERN_(USE_GCODE_SUBCODES, subcode = motion_mode_subcode); p--; // Back up one character to use the current parameter break; - #endif // GCODE_MOTION_MODES + #endif #if ENABLED(REALTIME_REPORTING_COMMANDS) - case 'S': case 'P': case 'R': { + case 'P': case 'R': { + if (letter == 'R') { + #if ENABLED(GCODE_MOTION_MODES) + if (ENABLED(ARC_SUPPORT) && !WITHIN(motion_mode_codenum, 2, 3)) return; + #endif + } + else if (TERN0(GCODE_MOTION_MODES, motion_mode_codenum != 5)) return; + } // fall-thru + case 'S': { codenum = 0; // The only valid codenum is 0 uint8_t digits = 0; while (*p++ == '0') digits++; // Count up '0' characters command_letter = (digits == 3) ? letter : '?'; // Three '0' digits is a good command - } return; // No parameters, so return + } return; // No parameters needed, so return now #endif default: return; From e8af38cc2df433536e6fc584efc251f62e826999 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 17 Apr 2021 14:19:33 -0500 Subject: [PATCH 239/311] Skip scripts during 'platformio init' (#21643) --- .../share/PlatformIO/scripts/common-cxxflags.py | 6 ++++++ .../PlatformIO/scripts/common-dependencies-post.py | 7 ++++++- .../share/PlatformIO/scripts/common-dependencies.py | 13 +++++++++---- .../scripts/copy_marlin_variant_to_framework.py | 7 +++++++ .../share/PlatformIO/scripts/preflight-checks.py | 8 +++++++- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/common-cxxflags.py b/buildroot/share/PlatformIO/scripts/common-cxxflags.py index 856a246fba..02cf124942 100644 --- a/buildroot/share/PlatformIO/scripts/common-cxxflags.py +++ b/buildroot/share/PlatformIO/scripts/common-cxxflags.py @@ -3,6 +3,12 @@ # Convenience script to apply customizations to CPP flags # Import("env") + +# Detect that 'vscode init' is running +from SCons.Script import COMMAND_LINE_TARGETS +if "idedata" in COMMAND_LINE_TARGETS: + env.Exit(0) + env.Append(CXXFLAGS=[ "-Wno-register" #"-Wno-incompatible-pointer-types", diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies-post.py b/buildroot/share/PlatformIO/scripts/common-dependencies-post.py index 2b1b948119..fa095f704c 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies-post.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies-post.py @@ -2,8 +2,13 @@ # common-dependencies-post.py # Convenience script to add build flags for Marlin Enabled Features # - Import("env") + +# Detect that 'vscode init' is running +from SCons.Script import COMMAND_LINE_TARGETS +if "idedata" in COMMAND_LINE_TARGETS: + env.Exit(0) + Import("projenv") def apply_board_build_flags(): diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index fe6ae7dba5..5b17c3586f 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -2,6 +2,15 @@ # common-dependencies.py # Convenience script to check dependencies and add libs and sources for Marlin Enabled Features # +Import("env") + +#print(env.Dump()) + +# Detect that 'vscode init' is running +from SCons.Script import COMMAND_LINE_TARGETS +if "idedata" in COMMAND_LINE_TARGETS: + env.Exit(0) + import subprocess,os,re PIO_VERSION_MIN = (5, 0, 3) @@ -31,10 +40,6 @@ except: from platformio.package.meta import PackageSpec from platformio.project.config import ProjectConfig -Import("env") - -#print(env.Dump()) - try: verbose = int(env.GetProjectOption('custom_verbose')) except: diff --git a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py index 15c953156c..955f002016 100644 --- a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py +++ b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py @@ -1,6 +1,13 @@ # # copy_marlin_variant_to_framework.py # +Import("env") + +# Detect that 'vscode init' is running +from SCons.Script import COMMAND_LINE_TARGETS +if "idedata" in COMMAND_LINE_TARGETS: + env.Exit(0) + import os,shutil from SCons.Script import DefaultEnvironment from platformio import util diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 6b499a8bcd..f89c891323 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -2,9 +2,15 @@ # preflight-checks.py # Check for common issues prior to compiling # -import os,re,sys Import("env") +# Detect that 'vscode init' is running +from SCons.Script import COMMAND_LINE_TARGETS +if "idedata" in COMMAND_LINE_TARGETS: + env.Exit(0) + +import os,re,sys + def get_envs_for_board(board): with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file: From 5d8727a59c0b6a38e7c2cbd73feec3e76036db44 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 18 Apr 2021 00:34:57 +0000 Subject: [PATCH 240/311] [cron] Bump distribution date (2021-04-18) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 080bf38df8..a598a3154c 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-04-17" + #define STRING_DISTRIBUTION_DATE "2021-04-18" #endif /** From c508c2213ee5b0ed130238c058b7cc91beaea654 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Apr 2021 14:07:30 -0500 Subject: [PATCH 241/311] Misc. pio cleanup --- ini/stm32f0.ini | 16 +++++++++++++--- ini/stm32f1.ini | 16 +++++++++++++--- ini/stm32f4.ini | 16 +++++++++++++--- ini/stm32f7.ini | 16 +++++++++++++--- platformio.ini | 13 ++++++------- 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/ini/stm32f0.ini b/ini/stm32f0.ini index fb6ce00dd0..10ac21fc89 100644 --- a/ini/stm32f0.ini +++ b/ini/stm32f0.ini @@ -4,9 +4,19 @@ # ################################# -# # -# STM32F0 Architecture # -# # +# +# STM32F0 Architecture +# +# Naming Example: STM32F070CBT6 +# +# F : Foundation +# 0 : Cortex M0 core +# 70 : Line/Features +# C : 48 pins (R:64 or 66, F:20) +# B : 128KB Flash-memory (C:256KB, D:384KB, E:512KB, G:1024KB) +# T : LQFP package +# 6 : -40...85°C (7: ...105°C) +# ################################# # diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 2ba3d84862..81e9f1dcb8 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -4,9 +4,19 @@ # ################################# -# # -# STM32F1 Architecture # -# # +# +# STM32F1 Architecture +# +# Naming Example: STM32F103RCT6 +# +# F : Foundation (sometimes High Performance F2/F4) +# 1 : Cortex M1 core +# 03 : Line/Features +# R : 64 or 66 pins (V:100, Z:144, I:176) +# C : 256KB Flash-memory (D:384KB, E:512KB, G:1024KB) +# T : LQFP package +# 6 : -40...85°C (7: ...105°C) +# ################################# # diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 5e700f0e9f..0e8a8c6b05 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -4,9 +4,19 @@ # ################################# -# # -# STM32F4 Architecture # -# # +# +# STM32F4 Architecture +# +# Naming Example: STM32F401RGT6 +# +# F : Foundation (sometimes High Performance F2/F4) +# 4 : Cortex M4 core +# 01 : Line/Features +# R : 64 or 66 pins (V:100, Z:144, I:176) +# G : 1024KB Flash-memory (C:256KB, D:384KB, E:512KB) +# T : LQFP package +# 6 : -40...85°C (7: ...105°C) +# ################################# # diff --git a/ini/stm32f7.ini b/ini/stm32f7.ini index d3fec7aebc..afcfc102d5 100644 --- a/ini/stm32f7.ini +++ b/ini/stm32f7.ini @@ -4,9 +4,19 @@ # ################################# -# # -# STM32F7 Architecture # -# # +# +# STM32F7 Architecture +# +# Naming Example: STM32F767ZIT6 +# +# F : Foundation (sometimes High Performance F2/F4) +# 7 : Cortex M7 core +# 67 : Line/Features +# Z : 144 pins +# I : 4096KB Flash-memory +# T : LQFP package +# 6 : -40...85°C (7: ...105°C) +# ################################# # diff --git a/platformio.ini b/platformio.ini index 87b6e8a90b..77abb364e7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,11 +10,6 @@ # Automatic targets - enable auto-uploading #targets = upload -# -# By default platformio build will abort after 5 errors. -# Remove '-fmax-errors=5' from build_flags below to see all. -# - [platformio] src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards @@ -35,10 +30,14 @@ extra_configs = ini/teensy.ini # -# The 'common' values are used for most Marlin builds +# The 'common' section applies to most Marlin builds. +# +# By default platformio build will abort after 5 errors. +# Remove '-fmax-errors=5' from build_flags below to see all. # [common] -build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants +build_flags = -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants + -fmax-errors=5 extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py From 8e60b19662c3c05c935ce76f95a39a40747a1180 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 17 Apr 2021 19:52:23 -0500 Subject: [PATCH 242/311] Disable assert() by default --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 77abb364e7..8a747404e3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -36,7 +36,7 @@ extra_configs = # Remove '-fmax-errors=5' from build_flags below to see all. # [common] -build_flags = -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants +build_flags = -g3 -D__MARLIN_FIRMWARE__ -DNDEBUG -fmerge-constants -fmax-errors=5 extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py From 86397df32d78087c148c0a3c0a002a17b75b4dde Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Apr 2021 14:17:37 -0500 Subject: [PATCH 243/311] BTT E3 RRF Support --- Marlin/src/core/boards.h | 31 +- Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h | 375 ++++++++++++++++++ .../variants/BIGTREE_E3_RRF/PeripheralPins.c | 363 +++++++++++++++++ .../variants/BIGTREE_E3_RRF/PinNamesVar.h | 50 +++ .../variants/BIGTREE_E3_RRF/hal_conf_extra.h | 52 +++ .../variants/BIGTREE_E3_RRF/ldscript.ld | 204 ++++++++++ .../variants/BIGTREE_E3_RRF/variant.cpp | 260 ++++++++++++ .../variants/BIGTREE_E3_RRF/variant.h | 292 ++++++++++++++ ini/stm32f4.ini | 14 + 10 files changed, 1628 insertions(+), 15 deletions(-) create mode 100644 Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h create mode 100644 buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PeripheralPins.c create mode 100644 buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PinNamesVar.h create mode 100644 buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/hal_conf_extra.h create mode 100644 buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/ldscript.ld create mode 100644 buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.cpp create mode 100644 buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index beaea57354..377147504f 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -366,21 +366,22 @@ #define BOARD_BTT_SKR_PRO_V1_1 4207 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) #define BOARD_BTT_SKR_PRO_V1_2 4208 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) #define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VG) -#define BOARD_BTT_GTR_V1_0 4210 // BigTreeTech GTR v1.0 (STM32F407IGT) -#define BOARD_LERDGE_K 4211 // Lerdge K (STM32F407ZG) -#define BOARD_LERDGE_S 4212 // Lerdge S (STM32F407VE) -#define BOARD_LERDGE_X 4213 // Lerdge X (STM32F407VE) -#define BOARD_VAKE403D 4214 // VAkE 403D (STM32F446VET6) -#define BOARD_FYSETC_S6 4215 // FYSETC S6 (STM32F446VET6) -#define BOARD_FYSETC_S6_V2_0 4216 // FYSETC S6 v2.0 (STM32F446VET6) -#define BOARD_FYSETC_SPIDER 4217 // FYSETC Spider (STM32F446VET6) -#define BOARD_FLYF407ZG 4218 // FLYF407ZG (STM32F407ZG) -#define BOARD_MKS_ROBIN2 4219 // MKS_ROBIN2 (STM32F407ZE) -#define BOARD_MKS_ROBIN_PRO_V2 4220 // MKS Robin Pro V2 (STM32F407VE) -#define BOARD_MKS_ROBIN_NANO_V3 4221 // MKS Robin Nano V3 (STM32F407VG) -#define BOARD_ANET_ET4 4222 // ANET ET4 V1.x (STM32F407VGT6) -#define BOARD_ANET_ET4P 4223 // ANET ET4P V1.x (STM32F407VGT6) -#define BOARD_FYSETC_CHEETAH_V20 4224 // FYSETC Cheetah V2.0 +#define BOARD_BTT_E3_RRF 4210 // BigTreeTech E3 RRF (STM32F407VGT6) +#define BOARD_BTT_GTR_V1_0 4211 // BigTreeTech GTR v1.0 (STM32F407IGT) +#define BOARD_LERDGE_K 4212 // Lerdge K (STM32F407ZG) +#define BOARD_LERDGE_S 4213 // Lerdge S (STM32F407VE) +#define BOARD_LERDGE_X 4214 // Lerdge X (STM32F407VE) +#define BOARD_VAKE403D 4215 // VAkE 403D (STM32F446VET6) +#define BOARD_FYSETC_S6 4216 // FYSETC S6 (STM32F446VET6) +#define BOARD_FYSETC_S6_V2_0 4217 // FYSETC S6 v2.0 (STM32F446VET6) +#define BOARD_FYSETC_SPIDER 4218 // FYSETC Spider (STM32F446VET6) +#define BOARD_FLYF407ZG 4219 // FLYF407ZG (STM32F407ZG) +#define BOARD_MKS_ROBIN2 4220 // MKS_ROBIN2 (STM32F407ZE) +#define BOARD_MKS_ROBIN_PRO_V2 4221 // MKS Robin Pro V2 (STM32F407VE) +#define BOARD_MKS_ROBIN_NANO_V3 4222 // MKS Robin Nano V3 (STM32F407VG) +#define BOARD_ANET_ET4 4223 // ANET ET4 V1.x (STM32F407VGT6) +#define BOARD_ANET_ET4P 4224 // ANET ET4P V1.x (STM32F407VGT6) +#define BOARD_FYSETC_CHEETAH_V20 4225 // FYSETC Cheetah V2.0 // // ARM Cortex M7 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 7634d49199..c2d6b30703 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -594,6 +594,8 @@ #include "stm32f4/pins_BTT_GTR_V1_0.h" // STM32F4 env:BIGTREE_GTR_V1_0 env:BIGTREE_GTR_V1_0_usb_flash_drive #elif MB(BTT_BTT002_V1_0) #include "stm32f4/pins_BTT_BTT002_V1_0.h" // STM32F4 env:BIGTREE_BTT002 +#elif MB(BTT_E3_RRF) + #include "stm32f4/pins_BTT_E3_RRF.h" // STM32F4 env:BIGTREE_E3_RRF #elif MB(LERDGE_K) #include "stm32f4/pins_LERDGE_K.h" // STM32F4 env:LERDGEK env:LERDGEK_usb_flash_drive #elif MB(LERDGE_S) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h new file mode 100644 index 0000000000..f808278510 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h @@ -0,0 +1,375 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#if NOT_TARGET(STM32F4) + #error "Oops! Select an STM32F4 board in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT E3 RRF" +#endif + +#define FPC2_PIN PB11 +#define FPC3_PIN PB10 +#define FPC4_PIN PE12 +#define FPC5_PIN PE13 +#define FPC6_PIN PE14 +#define FPC7_PIN PE15 +#define FPC8_PIN PA3 +#define FPC9_PIN PA2 +#define FPC10_PIN PA8 +#define FPC11_PIN PC15 +#define FPC12_PIN PC14 +#define FPC13_PIN PC13 +#define FPC14_PIN PE6 +#define FPC15_PIN PE5 +#define FPC16_PIN PE4 +#define FPC17_PIN PE3 + +//#define BTT_E3_RRF_IDEX_BOARD + +#ifdef BTT_E3_RRF_IDEX_BOARD + + #define X2_ENABLE_PIN FPC13_PIN // X2EN + #define X2_STEP_PIN FPC11_PIN // X2STP + #define X2_DIR_PIN FPC10_PIN // X2DIR + #define X2_SERIAL_TX_PIN FPC12_PIN // X2UART + #define X2_SERIAL_RX_PIN FPC12_PIN // X2UART + #if X_HOME_DIR < 0 + #define X_MAX_PIN FPC2_PIN // X2-STOP + #else + #define X_MIN_PIN FPC2_PIN // X2-STOP + #endif + + #define E1_ENABLE_PIN FPC7_PIN // E1EN + #define E1_STEP_PIN FPC5_PIN // E1STP + #define E1_DIR_PIN FPC4_PIN // E1DIR + #define E1_SERIAL_TX_PIN FPC6_PIN // E1UART + #define E1_SERIAL_RX_PIN FPC6_PIN // E1UART + + #ifndef FIL1_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN FPC3_PIN // E1-STOP + #endif + + #define HEATER_1_PIN FPC16_PIN // "HE1" + + #define PT100_PIN FPC8_PIN // Analog Input "PT100"(INA826) + #define TEMP_1_PIN FPC9_PIN // Analog Input "TH1" + + #define FAN1_PIN FPC15_PIN // "FAN0" in IDEX board + #define FAN2_PIN FPC14_PIN // "FAN1" in IDEX board + +#endif + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB + +// +// Servos +// +#define SERVO0_PIN PB0 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PC0 // X-STOP +#define Y_STOP_PIN PC1 // Y-STOP +#define Z_STOP_PIN PC2 // Z-STOP + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC5 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC3 // E0-STOP +#endif + +// +// Power-loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PE0 // Power Loss Detection: PWR-DET +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PD7 +#define X_STEP_PIN PD5 +#define X_DIR_PIN PD4 + +#define Y_ENABLE_PIN PD3 +#define Y_STEP_PIN PD0 +#define Y_DIR_PIN PA15 + +#define Z_ENABLE_PIN PD14 +#define Z_STEP_PIN PC6 +#define Z_DIR_PIN PC7 + +#define E0_ENABLE_PIN PD10 +#define E0_STEP_PIN PD12 +#define E0_DIR_PIN PD13 + +/** + * TMC2208/TMC2209 stepper drivers + */ +#if HAS_TMC_UART + // + // Software serial + // + #define X_SERIAL_TX_PIN PD6 + #define X_SERIAL_RX_PIN PD6 + + #define Y_SERIAL_TX_PIN PD1 + #define Y_SERIAL_RX_PIN PD1 + + #define Z_SERIAL_TX_PIN PD15 + #define Z_SERIAL_RX_PIN PD15 + + #define E0_SERIAL_TX_PIN PD11 + #define E0_SERIAL_RX_PIN PD11 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA1 // Analog Input "TB" +#define TEMP_0_PIN PA0 // Analog Input "TH0" + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PB4 // "HB" +#define HEATER_0_PIN PB3 // "HE0" + +#define FAN_PIN PB5 // "FAN0" +//#define FAN1_PIN PB6 // "FAN1" + +#ifndef CONTROLLER_FAN_PIN + #define CONTROLLER_FAN_PIN PB6 // "FAN1" +#endif + +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PB7 // LED driving pin +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN PE1 // Power Supply Control +#endif + +/** + * BTT E3 RRF + * _____ + * 5V | 1 2 | GND + * (LCD_EN) PE11 | 3 4 | PB1 (LCD_RS) + * (LCD_D4) PE10 | 5 6 PB2 (BTN_EN2) + * RESET | 7 8 | PE7 (BTN_EN1) + * (BTN_ENC) PE9 | 9 10| PE8 (BEEPER) + * ----- + * EXP1 + */ + +#if HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN PE8 + #define BTN_ENC PE9 + + #define BTN_EN1 PE7 + #define BTN_EN2 PB2 + + #define LCD_PINS_RS PB1 + #define LCD_PINS_ENABLE PE11 + #define LCD_PINS_D4 PE10 + + // CR10_STOCKDISPLAY default timing is too fast + #undef BOARD_ST7920_DELAY_1 + #undef BOARD_ST7920_DELAY_2 + #undef BOARD_ST7920_DELAY_3 + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. Comment out this line to continue." + + #define LCD_PINS_RS PE10 + #define LCD_PINS_ENABLE PE9 + #define LCD_PINS_D4 PB1 + #define LCD_PINS_D5 PB2 + #define LCD_PINS_D6 PE7 + #define LCD_PINS_D7 PE8 + #define ADC_KEYPAD_PIN PB0 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC PE9 + #define BTN_EN1 PE7 + #define BTN_EN2 PB2 + + #define DOGLCD_CS PB1 + #define DOGLCD_A0 PE10 + #define DOGLCD_SCK PE8 + #define DOGLCD_MOSI PE11 + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + + #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. Comment out this line to continue." + + /** + * TFTGLCD_PANEL_SPI display pinout + * + * Board Display + * _____ _____ + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PE11 | 3 4 | PB1 (LCD_CS) (PE7) LCD_CS | 3 4 | SD_CS (PB2) + * (FREE) PE10 | 5 6 | PB2 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) + * RESET | 7 8 | PE7 (MOD_RESET) (PE8) SD_DET | 7 8 | (FREE) + * (BEEPER) PE9 | 9 10| PE8 (SD_DET) GND | 9 10| 5V + * ----- ----- + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * _________ + * EXP1-1 ----------- EXP1-10 + * EXP1-2 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-4 ----------- FREE + * SPI1-3 ----------- EXP1-2 + * EXP1-6 ----------- EXP1-4 + * EXP1-7 ----------- FREE + * EXP1-8 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-10 ----------- EXP1-7 + */ + + #define TFTGLCD_CS PE7 + + #endif + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BTT_E3_RRF." + #endif + + // Alter timing for graphical display + #if HAS_MARLINUI_U8GLIB + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + #endif + #endif + +#endif // HAS_WIRED_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. Comment out this line to continue." + + /** FYSETC TFT TFT81050 display pinout + * + * Board Display + * _____ _____ + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PE11 | 3 4 | PB1 (LCD_CS) (PE7) MOD_RESET | 3 4 | SD_CS (PB2) + * (FREE) PE10 | 5 6 | PB2 (SD_CS) (PB1) LCD_CS | 5 6 | MOSI (SPI1-MOSI) + * RESET | 7 8 | PE7 (MOD_RESET) (PE8) SD_DET | 7 8 | RESET + * (BEEPER) PE9 | 9 10| PE8 (SD_DET) GND | 9 10| 5V + * ----- ----- + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * _________ + * EXP1-1 ----------- EXP1-10 + * EXP1-2 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-4 ----------- EXP1-5 + * SPI1-3 ----------- EXP1-2 + * EXP1-6 ----------- EXP1-4 + * EXP1-7 ----------- EXP1-8 + * EXP1-8 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-10 ----------- EXP1-7 + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN PE9 + + #define CLCD_MOD_RESET PE7 + #define CLCD_SPI_CS PB1 + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT // Use SDIO for onboard SD + #define SDIO_D0_PIN PC8 + #define SDIO_D1_PIN PC9 + #define SDIO_D2_PIN PC10 + #define SDIO_D3_PIN PC11 + #define SDIO_CK_PIN PC12 + #define SDIO_CMD_PIN PD2 + + //#define SDIO_CLOCK 48000000 + #define SD_DETECT_PIN PC4 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with BTT E3 RRF." +#endif + +// +// WIFI +// + +#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN PA4 +#define ESP_WIFI_MODULE_ENABLE_PIN PA5 +#define ESP_WIFI_MODULE_GPIO0_PIN PA6 diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PeripheralPins.c b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PeripheralPins.c new file mode 100644 index 0000000000..9e42baf210 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PeripheralPins.c @@ -0,0 +1,363 @@ +/* + ******************************************************************************* + * Copyright (c) 2019, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + * Automatically generated from STM32F407Z(E-G)Tx.xml + */ +#include +#include + +/* ===== + * Note: Commented lines are alternative possibilities which are not used by default. + * If you change them, you should know what you're doing first. + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +const PinMap PinMap_ADC[] = { + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 TH0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 TB + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 IDEX TH1 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 IDEX INA826 PT100 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio, 24 ADC + {PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 + {PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 + {PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 + {PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 + {PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 + {PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 + {PF_9, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_IN7 + {PF_10, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_IN8 + #endif + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +const PinMap PinMap_DAC[] = { + {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SDA[] = { + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PF_0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + #endif + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SCL[] = { + {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PF_1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + #endif + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +const PinMap PinMap_PWM[] = { + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 HE0 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 BED + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 FAN0 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 FAN1 + {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 IDEX FAN0 + {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 IDEX FAN1 + + /** + * Unused by specifications on BTT E3 RRF. (PLEASE CONFIRM) + * Uncomment the corresponding line if you want to have HardwarePWM on some pins. + * WARNING: check timers' usage first to avoid conflicts. + * If you don't know what you're doing leave things as they are or you WILL break something (including hardware) + * If you alter this section DO NOT report bugs to Marlin team since they are most likely caused by you. Thank you. + */ + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + //{PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)},// TIM13_CH1 + //{PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)},// TIM14_CH1 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + //{PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)},// TIM10_CH1 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)},// TIM11_CH1 + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)},// TIM12_CH1 + //{PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)},// TIM12_CH2 + //{PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + //{PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + //{PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + //{PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + //{PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + //{PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + //{PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + #endif + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_TX[] = { + {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PG_14, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + #endif + {NC, NP, 0} +}; + +const PinMap PinMap_UART_RX[] = { + {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PG_9, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + #endif + {NC, NP, 0} +}; + +const PinMap PinMap_UART_RTS[] = { + {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PG_8, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PG_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + #endif + {NC, NP, 0} +}; + +const PinMap PinMap_UART_CTS[] = { + {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PG_13, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PG_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + #endif + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, + {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +#error "CAN bus isn't available on this board. Driver should be disabled." +#endif + +//*** ETHERNET *** +#ifdef HAL_ETH_MODULE_ENABLED +#error "Ethernet port isn't available on this board. Driver should be disabled." +#endif + +//*** No QUADSPI *** + +//*** USB *** +#ifdef HAL_PCD_MODULE_ENABLED +const PinMap PinMap_USB_OTG_FS[] = { + //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; + +const PinMap PinMap_USB_OTG_HS[] = { /* + #ifdef USE_USB_HS_IN_FS + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM + {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP + #else + #error "USB in HS mode isn't supported by the board" + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT + #endif // USE_USB_HS_IN_FS + */ + {NC, NP, 0} +}; + +#ifdef HAL_SD_MODULE_ENABLED +WEAK const PinMap PinMap_SD[] = { + // {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + // {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + // {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + // {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 + {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD + {NC, NP, 0} +}; +#endif +#endif diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PinNamesVar.h b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PinNamesVar.h new file mode 100644 index 0000000000..b4bb9d45f8 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PinNamesVar.h @@ -0,0 +1,50 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_SOF = PA_8, + USB_OTG_FS_VBUS = PA_9, + USB_OTG_FS_ID = PA_10, + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, + USB_OTG_HS_ULPI_D0 = PA_3, + USB_OTG_HS_SOF = PA_4, + USB_OTG_HS_ULPI_CK = PA_5, + USB_OTG_HS_ULPI_D1 = PB_0, + USB_OTG_HS_ULPI_D2 = PB_1, + USB_OTG_HS_ULPI_D7 = PB_5, + USB_OTG_HS_ULPI_D3 = PB_10, + USB_OTG_HS_ULPI_D4 = PB_11, + USB_OTG_HS_ID = PB_12, + USB_OTG_HS_ULPI_D5 = PB_12, + USB_OTG_HS_ULPI_D6 = PB_13, + USB_OTG_HS_VBUS = PB_13, + USB_OTG_HS_DM = PB_14, + USB_OTG_HS_DP = PB_15, + USB_OTG_HS_ULPI_STP = PC_0, + USB_OTG_HS_ULPI_DIR = PC_2, + USB_OTG_HS_ULPI_NXT = PC_3, +#endif diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/hal_conf_extra.h new file mode 100644 index 0000000000..6c4a991f33 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/hal_conf_extra.h @@ -0,0 +1,52 @@ +#pragma once + +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +//#define HAL_RTC_MODULE_ENABLED Real Time Clock...do we use it? +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +//#define HAL_UART_MODULE_ENABLED // by default +//#define HAL_PCD_MODULE_ENABLED // Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) +#define HAL_SD_MODULE_ENABLED + +#undef HAL_DAC_MODULE_ENABLED +#undef HAL_FLASH_MODULE_ENABLED +#undef HAL_CAN_MODULE_ENABLED +#undef HAL_CAN_LEGACY_MODULE_ENABLED +#undef HAL_CEC_MODULE_ENABLED +#undef HAL_CRYP_MODULE_ENABLED +#undef HAL_DCMI_MODULE_ENABLED +#undef HAL_DMA2D_MODULE_ENABLED +#undef HAL_ETH_MODULE_ENABLED +#undef HAL_NAND_MODULE_ENABLED +#undef HAL_NOR_MODULE_ENABLED +#undef HAL_PCCARD_MODULE_ENABLED +#undef HAL_SRAM_MODULE_ENABLED +#undef HAL_SDRAM_MODULE_ENABLED +#undef HAL_HASH_MODULE_ENABLED +#undef HAL_EXTI_MODULE_ENABLED +#undef HAL_SMBUS_MODULE_ENABLED +#undef HAL_I2S_MODULE_ENABLED +#undef HAL_IWDG_MODULE_ENABLED +#undef HAL_LTDC_MODULE_ENABLED +#undef HAL_DSI_MODULE_ENABLED +#undef HAL_QSPI_MODULE_ENABLED +#undef HAL_RNG_MODULE_ENABLED +#undef HAL_SAI_MODULE_ENABLED +#undef HAL_IRDA_MODULE_ENABLED +#undef HAL_SMARTCARD_MODULE_ENABLED +#undef HAL_WWDG_MODULE_ENABLED +#undef HAL_HCD_MODULE_ENABLED +#undef HAL_FMPI2C_MODULE_ENABLED +#undef HAL_SPDIFRX_MODULE_ENABLED +#undef HAL_DFSDM_MODULE_ENABLED +#undef HAL_LPTIM_MODULE_ENABLED +#undef HAL_MMC_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/ldscript.ld b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/ldscript.ld new file mode 100644 index 0000000000..0c060d1751 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/ldscript.ld @@ -0,0 +1,204 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F407ZGTx Device with +** 1024KByte FLASH, 128KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2014 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20020000; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200;; /* required amount of heap */ +_Min_Stack_Size = 0x400;; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 1024K +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text ALIGN(4): + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata ALIGN(4): + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + _siccmram = LOADADDR(.ccmram); + + /* CCM-RAM section + * + * IMPORTANT NOTE! + * If initialized variables will be placed in this section, + * the startup code needs to be modified to copy the init-values. + */ + .ccmram : + { + . = ALIGN(4); + _sccmram = .; /* create a global symbol at ccmram start */ + *(.ccmram) + *(.ccmram*) + + . = ALIGN(4); + _eccmram = .; /* create a global symbol at ccmram end */ + } >CCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.cpp b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.cpp new file mode 100644 index 0000000000..1486b21830 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.cpp @@ -0,0 +1,260 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +// This array allows to wrap Arduino pin number(Dx or x) +// to STM32 PinName (PX_n) +const PinName digitalPin[] = { +#if STM32F4X_PIN_NUM >= 64 //64 pins mcu, 51 gpio + PC_13, //D0 + PC_14, //D1 - OSC32_IN + PC_15, //D2 - OSC32_OUT + PH_0, //D3 - OSC_IN + PH_1, //D4 - OSC_OUT + PB_2, //D5 - BOOT1 + PB_10, //D6 - 1:SPI2_SCK / I2C2_SCL / USART3_TX / TIM2_CH3 + PB_11, //D7 - 1:I2C2_SDA / USART3_RX / TIM2_CH4 + PB_12, //D8 - 1:SPI2_NSS / OTG_HS_ID + PB_13, //D9 - 1:SPI2_SCK 2:OTG_HS_VBUS + PB_14, //D10 - 1:SPI2_MISO / TIM12_CH1 / OTG_HS_DM + PB_15, //D11 - SPI2_MOSI / TIM12_CH2 / OTG_HS_DP + PC_6, //D12 - 1:TIM8_CH1 / SDIO_D6 / USART6_TX / TIM3_CH1 + PC_7, //D13 - 1:TIM8_CH2 / SDIO_D7 / USART6_RX / TIM3_CH2 + PC_8, //D14 - 1:TIM8_CH3 / SDIO_D0 / TIM3_CH3 + PC_9, //D15 - 1:TIM8_CH4 / SDIO_D1 / TIM3_CH4 + PA_8, //D16 - 1:TIM1_CH1 / I2C3_SCL / OTG_FS_SOF + PA_9, //D17 - 1:USART1_TX / TIM1_CH2 2:OTG_FS_VBUS + PA_10, //D18 - 1:USART1_RX / TIM1_CH3 / OTG_FS_ID + PA_11, //D19 - 1:TIM1_CH4 / OTG_FS_DM + PA_12, //D20 - 1:OTG_FS_DP + PA_13, //D21 - 0:JTMS-SWDIO + PA_14, //D22 - 0:JTCK-SWCLK + PA_15, //D23 - 0:JTDI 1:SPI3_NSS / SPI1_NSS + PC_10, //D24 - 1:UART4_TX / SPI3_SCK / SDIO_D2 / USART3_TX + PC_11, //D25 - 1:UART4_RX / SPI3_MISO / SDIO_D3 / USART3_RX + PC_12, //D26 - 1:UART5_TX / SPI3_MOSI / SDIO_CK + PD_2, //D27 - 1:UART5_RX / SDIO_CMD + PB_3, //D28 - 0:JTDO 1:SPI3_SCK / TIM2_CH2 / SPI1_SCK + PB_4, //D29 - 0:NJTRST 1:SPI3_MISO / TIM3_CH1 / SPI1_MISO + PB_5, //D30 - 1:TIM3_CH2 / SPI1_MOSI / SPI3_MOSI + PB_6, //D31 - 1:I2C1_SCL / TIM4_CH1 / USART1_TX + PB_7, //D32 - 1:I2C1_SDA / TIM4_CH2 / USART1_RX + PB_8, //D33 - 1:I2C1_SCL / TIM4_CH3 / SDIO_D4 / TIM10_CH1 + PB_9, //D34 - 1:I2C1_SDA / TIM4_CH4 / SDIO_D5 / TIM11_CH1 / SPI2_NSS + PA_0, //D35/A0 - 1:UART4_TX / TIM5_CH1 2:ADC123_IN0 + PA_1, //D36/A1 - 1:UART4_RX / TIM5_CH2 / TIM2_CH2 2:ADC123_IN1 + PA_2, //D37/A2 - 1:USART2_TX /TIM5_CH3 / TIM9_CH1 / TIM2_CH3 2:ADC123_IN2 + PA_3, //D38/A3 - 1:USART2_RX /TIM5_CH4 / TIM9_CH2 / TIM2_CH4 2:ADC123_IN3 + PA_4, //D39/A4 - NOT FT 1:SPI1_NSS / SPI3_NSS / USART2_CK 2:ADC12_IN4 / DAC_OUT1 + PA_5, //D40/A5 - NOT FT 1:SPI1_SCK 2:ADC12_IN5 / DAC_OUT2 + PA_6, //D41/A6 - 1:SPI1_MISO / TIM13_CH1 / TIM3_CH1 2:ADC12_IN6 + PA_7, //D42/A7 - 1:SPI1_MOSI / TIM14_CH1 / TIM3_CH2 2:ADC12_IN7 + PB_0, //D43/A8 - 1:TIM3_CH3 2:ADC12_IN8 + PB_1, //D44/A9 - 1:TIM3_CH4 2:ADC12_IN9 + PC_0, //D45/A10 - 1: 2:ADC123_IN10 + PC_1, //D46/A11 - 1: 2:ADC123_IN11 + PC_2, //D47/A12 - 1:SPI2_MISO 2:ADC123_IN12 + PC_3, //D48/A13 - 1:SPI2_MOSI 2:ADC123_IN13 + PC_4, //D49/A14 - 1: 2:ADC12_IN14 + PC_5, //D50/A15 - 1: 2:ADC12_IN15 + #if STM32F4X_PIN_NUM >= 144 + PF_3, //D51/A16 - 1:FSMC_A3 2:ADC3_IN9 + PF_4, //D52/A17 - 1:FSMC_A4 2:ADC3_IN14 + PF_5, //D53/A18 - 1:FSMC_A5 2:ADC3_IN15 + PF_6, //D54/A19 - 1:TIM10_CH1 2:ADC3_IN4 + PF_7, //D55/A20 - 1:TIM11_CH1 2:ADC3_IN5 + PF_8, //D56/A21 - 1:TIM13_CH1 2:ADC3_IN6 + PF_9, //D57/A22 - 1;TIM14_CH1 2:ADC3_IN7 + PF_10, //D58/A23 - 2:ADC3_IN8 + #endif +#endif +#if STM32F4X_PIN_NUM >= 100 //100 pins mcu, 82 gpio + PE_2, //D59 - 1:FSMC_A23 + PE_3, //D60 - 1:FSMC_A19 + PE_4, //D61 - 1:FSMC_A20 + PE_5, //D62 - 1:FSMC_A21 + PE_6, //D63 - 1:FSMC_A22 + PE_7, //D64 - 1:FSMC_D4 + PE_8, //D65 - 1:FSMC_D5 + PE_9, //D66 - 1:FSMC_D6 / TIM1_CH1 + PE_10, //D67 - 1:FSMC_D7 + PE_11, //D68 - 1:FSMC_D8 / TIM1_CH2 + PE_12, //D69 - 1:FSMC_D9 + PE_13, //D70 - 1:FSMC_D10 / TIM1_CH3 + PE_14, //D71 - 1:FSMC_D11 / TIM1_CH4 + PE_15, //D72 - 1:FSMC_D12 + PD_8, //D73 - 1:FSMC_D13 / USART3_TX + PD_9, //D74 - 1:FSMC_D14 / USART3_RX + PD_10, //D75 - 1:FSMC_D15 + PD_11, //D76 - 1:FSMC_A16 + PD_12, //D77 - 1:FSMC_A17 / TIM4_CH1 + PD_13, //D78 - 1:FSMC_A18 / TIM4_CH2 + PD_14, //D79 - 1:FSMC_D0 / TIM4_CH3 + PD_15, //D80 - 1:FSMC_D1 / TIM4_CH4 + PD_0, //D81 - 1:FSMC_D2 + PD_1, //D82 - 1:FSMC_D3 + PD_3, //D83 - 1:FSMC_CLK + PD_4, //D84 - 1:FSMC_NOE + PD_5, //D85 - 1:USART2_TX + PD_6, //D86 - 1:USART2_RX + PD_7, //D87 + PE_0, //D88 + PE_1, //D89 +#endif +#if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + PF_0, //D90 - 1:FSMC_A0 / I2C2_SDA + PF_1, //D91 - 1:FSMC_A1 / I2C2_SCL + PF_2, //D92 - 1:FSMC_A2 + PF_11, //D93 + PF_12, //D94 - 1:FSMC_A6 + PF_13, //D95 - 1:FSMC_A7 + PF_14, //D96 - 1:FSMC_A8 + PF_15, //D97 - 1:FSMC_A9 + PG_0, //D98 - 1:FSMC_A10 + PG_1, //D99 - 1:FSMC_A11 + PG_2, //D100 - 1:FSMC_A12 + PG_3, //D101 - 1:FSMC_A13 + PG_4, //D102 - 1:FSMC_A14 + PG_5, //D103 - 1:FSMC_A15 + PG_6, //D104 + PG_7, //D105 + PG_8, //D106 + PG_9, //D107 - 1:USART6_RX + PG_10, //D108 - 1:FSMC_NE3 + PG_11, //D109 + PG_12, //D110 - 1:FSMC_NE4 + PG_13, //D111 - 1:FSMC_A24 + PG_14, //D112 - 1:FSMC_A25 / USART6_TX + PG_15, //D113 +#endif +#if STM32F4X_PIN_NUM >= 176 //176 pins mcu, 140 gpio + PI_8, //D114 + PI_9, //D115 + PI_10, //D116 + PI_11, //D117 + PH_2, //D118 + PH_3, //D119 + PH_4, //D120 - 1:I2C2_SCL + PH_5, //D121 - 1:I2C2_SDA + PH_6, //D122 - 1:TIM12_CH1 + PH_7, //D123 - 1:I2C3_SCL + PH_8, //D124 - 1:I2C3_SDA + PH_9, //D125 - 1:TIM12_CH2 + PH_10, //D126 - 1:TIM5_CH1 + PH_11, //D127 - 1:TIM5_CH2 + PH_12, //D128 - 1:TIM5_CH3 + PH_13, //D129 + PH_14, //D130 + PH_15, //D131 + PI_0, //D132 - 1:TIM5_CH4 / SPI2_NSS + PI_1, //D133 - 1:SPI2_SCK + PI_2, //D134 - 1:TIM8_CH4 /SPI2_MISO + PI_3, //D135 - 1:SPI2_MOS + PI_4, //D136 + PI_5, //D137 - 1:TIM8_CH1 + PI_6, //D138 - 1:TIM8_CH2 + PI_7, //D139 - 1:TIM8_CH3 +#endif +}; + +#ifdef __cplusplus +} +#endif + +// ------------------------ + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * @brief System Clock Configuration + * @param None + * @retval None + */ +WEAK void SystemClock_Config() { + + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /**Configure the main internal regulator output voltage + */ + __HAL_RCC_PWR_CLK_ENABLE(); + + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /**Initializes the CPU, AHB and APB busses clocks + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + _Error_Handler(__FILE__, __LINE__); + } + + /**Initializes the CPU, AHB and APB busses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK + | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { + _Error_Handler(__FILE__, __LINE__); + } + + /**Configure the Systick interrupt time + */ + HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); + + /**Configure the Systick + */ + HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); + + /* SysTick_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.h b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.h new file mode 100644 index 0000000000..42f21ce5a6 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.h @@ -0,0 +1,292 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#ifdef STM32F405RX + #define STM32F4X_PIN_NUM 64 //64 pins mcu, 51 gpio + #define STM32F4X_GPIO_NUM 51 + #define STM32F4X_ADC_NUM 16 +#elif defined(STM32F407_5VX) + #define STM32F4X_PIN_NUM 100 //100 pins mcu, 82 gpio + #define STM32F4X_GPIO_NUM 82 + #define STM32F4X_ADC_NUM 16 +#elif defined(STM32F407_5ZX) + #define STM32F4X_PIN_NUM 144 //144 pins mcu, 114 gpio + #define STM32F4X_GPIO_NUM 114 + #define STM32F4X_ADC_NUM 24 +#elif defined(STM32F407IX) + #define STM32F4X_PIN_NUM 176 //176 pins mcu, 140 gpio + #define STM32F4X_GPIO_NUM 140 + #define STM32F4X_ADC_NUM 24 +#else + #error "no match MCU defined" +#endif + +#if STM32F4X_PIN_NUM >= 64 //64 pins mcu, 51 gpio + #define PC13 0 + #define PC14 1 //OSC32_IN + #define PC15 2 //OSC32_OUT + #define PH0 3 //OSC_IN + #define PH1 4 //OSC_OUT + #define PB2 5 //BOOT1 + #define PB10 6 //1:SPI2_SCK / I2C2_SCL / USART3_TX / TIM2_CH3 + #define PB11 7 //1:I2C2_SDA / USART3_RX / TIM2_CH4 + #define PB12 8 //1:SPI2_NSS / OTG_HS_ID + #define PB13 9 //1:SPI2_SCK 2:OTG_HS_VBUS + #define PB14 10 //1:SPI2_MISO / TIM12_CH1 / OTG_HS_DM + #define PB15 11 //SPI2_MOSI / TIM12_CH2 / OTG_HS_DP + #define PC6 12 //1:TIM8_CH1 / SDIO_D6 / USART6_TX / TIM3_CH1 + #define PC7 13 //1:TIM8_CH2 / SDIO_D7 / USART6_RX / TIM3_CH2 + #define PC8 14 //1:TIM8_CH3 / SDIO_D0 / TIM3_CH3 + #define PC9 15 //1:TIM8_CH4 / SDIO_D1 / TIM3_CH4 + #define PA8 16 //1:TIM1_CH1 / I2C3_SCL / OTG_FS_SOF + #define PA9 17 //1:USART1_TX / TIM1_CH2 2:OTG_FS_VBUS + #define PA10 18 //1:USART1_RX / TIM1_CH3 / OTG_FS_ID + #define PA11 19 //1:TIM1_CH4 / OTG_FS_DM + #define PA12 20 //1:OTG_FS_DP + #define PA13 21 //0:JTMS-SWDIO + #define PA14 22 //0:JTCK-SWCLK + #define PA15 23 //0:JTDI 1:SPI3_NSS / SPI1_NSS + #define PC10 24 //1:UART4_TX / SPI3_SCK / SDIO_D2 / USART3_TX + #define PC11 25 //1:UART4_RX / SPI3_MISO / SDIO_D3 / USART3_RX + #define PC12 26 //1:UART5_TX / SPI3_MOSI / SDIO_CK + #define PD2 27 //1:UART5_RX / SDIO_CMD + #define PB3 28 //0:JTDO 1:SPI3_SCK / TIM2_CH2 / SPI1_SCK + #define PB4 29 //0:NJTRST 1:SPI3_MISO / TIM3_CH1 / SPI1_MISO + #define PB5 30 //1:TIM3_CH2 / SPI1_MOSI / SPI3_MOSI + #define PB6 31 //1:I2C1_SCL / TIM4_CH1 / USART1_TX + #define PB7 32 //1:I2C1_SDA / TIM4_CH2 / USART1_RX + #define PB8 33 //1:I2C1_SCL / TIM4_CH3 / SDIO_D4 / TIM10_CH1 + #define PB9 34 //1:I2C1_SDA / TIM4_CH4 / SDIO_D5 / TIM11_CH1 / SPI2_NSS + #define PA0 35 //1:UART4_TX / TIM5_CH1 2:ADC123_IN0 + #define PA1 36 //1:UART4_RX / TIM5_CH2 / TIM2_CH2 2:ADC123_IN1 + #define PA2 37 //1:USART2_TX /TIM5_CH3 / TIM9_CH1 / TIM2_CH3 2:ADC123_IN2 + #define PA3 38 //1:USART2_RX /TIM5_CH4 / TIM9_CH2 / TIM2_CH4 2:ADC123_IN3 + #define PA4 39 //NOT FT 1:SPI1_NSS / SPI3_NSS / USART2_CK 2:ADC12_IN4 / DAC_OUT1 + #define PA5 40 //NOT FT 1:SPI1_SCK 2:ADC12_IN5 / DAC_OUT2 + #define PA6 41 //1:SPI1_MISO / TIM13_CH1 / TIM3_CH1 2:ADC12_IN6 + #define PA7 42 //1:SPI1_MOSI / TIM14_CH1 / TIM3_CH2 2:ADC12_IN7 + #define PB0 43 //1:TIM3_CH3 2:ADC12_IN8 + #define PB1 44 //1:TIM3_CH4 2:ADC12_IN9 + #define PC0 45 //1: 2:ADC123_IN10 + #define PC1 46 //1: 2:ADC123_IN11 + #define PC2 47 //1:SPI2_MISO 2:ADC123_IN12 + #define PC3 48 //1:SPI2_MOSI 2:ADC123_IN13 + #define PC4 49 //1: 2:ADC12_IN14 + #define PC5 50 //1: 2:ADC12_IN15 + #if STM32F4X_PIN_NUM >= 144 + #define PF3 51 //1:FSMC_A3 2:ADC3_IN9 + #define PF4 52 //1:FSMC_A4 2:ADC3_IN14 + #define PF5 53 //1:FSMC_A5 2:ADC3_IN15 + #define PF6 54 //1:TIM10_CH1 2:ADC3_IN4 + #define PF7 55 //1:TIM11_CH1 2:ADC3_IN5 + #define PF8 56 //1:TIM13_CH1 2:ADC3_IN6 + #define PF9 57 //1;TIM14_CH1 2:ADC3_IN7 + #define PF10 58 //2:ADC3_IN8 + #endif +#endif +#if STM32F4X_PIN_NUM >= 100 //100 pins mcu, 82 gpio + #define PE2 (35+STM32F4X_ADC_NUM) //1:FSMC_A23 + #define PE3 (36+STM32F4X_ADC_NUM) //1:FSMC_A19 + #define PE4 (37+STM32F4X_ADC_NUM) //1:FSMC_A20 + #define PE5 (38+STM32F4X_ADC_NUM) //1:FSMC_A21 + #define PE6 (39+STM32F4X_ADC_NUM) //1:FSMC_A22 + #define PE7 (40+STM32F4X_ADC_NUM) //1:FSMC_D4 + #define PE8 (41+STM32F4X_ADC_NUM) //1:FSMC_D5 + #define PE9 (42+STM32F4X_ADC_NUM) //1:FSMC_D6 / TIM1_CH1 + #define PE10 (43+STM32F4X_ADC_NUM) //1:FSMC_D7 + #define PE11 (44+STM32F4X_ADC_NUM) //1:FSMC_D8 / TIM1_CH2 + #define PE12 (45+STM32F4X_ADC_NUM) //1:FSMC_D9 + #define PE13 (46+STM32F4X_ADC_NUM) //1:FSMC_D10 / TIM1_CH3 + #define PE14 (47+STM32F4X_ADC_NUM) //1:FSMC_D11 / TIM1_CH4 + #define PE15 (48+STM32F4X_ADC_NUM) //1:FSMC_D12 + #define PD8 (49+STM32F4X_ADC_NUM) //1:FSMC_D13 / USART3_TX + #define PD9 (50+STM32F4X_ADC_NUM) //1:FSMC_D14 / USART3_RX + #define PD10 (51+STM32F4X_ADC_NUM) //1:FSMC_D15 + #define PD11 (52+STM32F4X_ADC_NUM) //1:FSMC_A16 + #define PD12 (53+STM32F4X_ADC_NUM) //1:FSMC_A17 / TIM4_CH1 + #define PD13 (54+STM32F4X_ADC_NUM) //1:FSMC_A18 / TIM4_CH2 + #define PD14 (55+STM32F4X_ADC_NUM) //1:FSMC_D0 / TIM4_CH3 + #define PD15 (56+STM32F4X_ADC_NUM) //1:FSMC_D1 / TIM4_CH4 + #define PD0 (57+STM32F4X_ADC_NUM) //1:FSMC_D2 + #define PD1 (58+STM32F4X_ADC_NUM) //1:FSMC_D3 + #define PD3 (59+STM32F4X_ADC_NUM) //1:FSMC_CLK + #define PD4 (60+STM32F4X_ADC_NUM) //1:FSMC_NOE + #define PD5 (61+STM32F4X_ADC_NUM) //1:USART2_TX + #define PD6 (62+STM32F4X_ADC_NUM) //1:USART2_RX + #define PD7 (63+STM32F4X_ADC_NUM) + #define PE0 (64+STM32F4X_ADC_NUM) + #define PE1 (65+STM32F4X_ADC_NUM) +#endif +#if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + #define PF0 (66+STM32F4X_ADC_NUM) //1:FSMC_A0 / I2C2_SDA + #define PF1 (67+STM32F4X_ADC_NUM) //1:FSMC_A1 / I2C2_SCL + #define PF2 (68+STM32F4X_ADC_NUM) //1:FSMC_A2 + #define PF11 (69+STM32F4X_ADC_NUM) + #define PF12 (70+STM32F4X_ADC_NUM) //1:FSMC_A6 + #define PF13 (71+STM32F4X_ADC_NUM) //1:FSMC_A7 + #define PF14 (72+STM32F4X_ADC_NUM) //1:FSMC_A8 + #define PF15 (73+STM32F4X_ADC_NUM) //1:FSMC_A9 + #define PG0 (74+STM32F4X_ADC_NUM) //1:FSMC_A10 + #define PG1 (75+STM32F4X_ADC_NUM) //1:FSMC_A11 + #define PG2 (76+STM32F4X_ADC_NUM) //1:FSMC_A12 + #define PG3 (77+STM32F4X_ADC_NUM) //1:FSMC_A13 + #define PG4 (78+STM32F4X_ADC_NUM) //1:FSMC_A14 + #define PG5 (79+STM32F4X_ADC_NUM) //1:FSMC_A15 + #define PG6 (80+STM32F4X_ADC_NUM) + #define PG7 (81+STM32F4X_ADC_NUM) + #define PG8 (82+STM32F4X_ADC_NUM) + #define PG9 (83+STM32F4X_ADC_NUM) //1:USART6_RX + #define PG10 (84+STM32F4X_ADC_NUM) //1:FSMC_NE3 + #define PG11 (85+STM32F4X_ADC_NUM) + #define PG12 (86+STM32F4X_ADC_NUM) //1:FSMC_NE4 + #define PG13 (87+STM32F4X_ADC_NUM) //1:FSMC_A24 + #define PG14 (88+STM32F4X_ADC_NUM) //1:FSMC_A25 / USART6_TX + #define PG15 (89+STM32F4X_ADC_NUM) +#endif +#if STM32F4X_PIN_NUM >= 176 //176 pins mcu, 140 gpio + #define PI8 (90+STM32F4X_ADC_NUM) + #define PI9 (91+STM32F4X_ADC_NUM) + #define PI10 (92+STM32F4X_ADC_NUM) + #define PI11 (93+STM32F4X_ADC_NUM) + #define PH2 (94+STM32F4X_ADC_NUM) + #define PH3 (95+STM32F4X_ADC_NUM) + #define PH4 (96+STM32F4X_ADC_NUM) //1:I2C2_SCL + #define PH5 (97+STM32F4X_ADC_NUM) //1:I2C2_SDA + #define PH6 (98+STM32F4X_ADC_NUM) //1:TIM12_CH1 + #define PH7 (99+STM32F4X_ADC_NUM) //1:I2C3_SCL + #define PH8 (100+STM32F4X_ADC_NUM) //1:I2C3_SDA + #define PH9 (101+STM32F4X_ADC_NUM) //1:TIM12_CH2 + #define PH10 (102+STM32F4X_ADC_NUM) //1:TIM5_CH1 + #define PH11 (103+STM32F4X_ADC_NUM) //1:TIM5_CH2 + #define PH12 (104+STM32F4X_ADC_NUM) //1:TIM5_CH3 + #define PH13 (105+STM32F4X_ADC_NUM) + #define PH14 (106+STM32F4X_ADC_NUM) + #define PH15 (107+STM32F4X_ADC_NUM) + #define PI0 (108+STM32F4X_ADC_NUM) //1:TIM5_CH4 / SPI2_NSS + #define PI1 (109+STM32F4X_ADC_NUM) //1:SPI2_SCK + #define PI2 (110+STM32F4X_ADC_NUM) //1:TIM8_CH4 /SPI2_MISO + #define PI3 (111+STM32F4X_ADC_NUM) //1:SPI2_MOS + #define PI4 (112+STM32F4X_ADC_NUM) + #define PI5 (113+STM32F4X_ADC_NUM) //1:TIM8_CH1 + #define PI6 (114+STM32F4X_ADC_NUM) //1:TIM8_CH2 + #define PI7 (115+STM32F4X_ADC_NUM) //1:TIM8_CH3 +#endif + +// This must be a literal +#define NUM_DIGITAL_PINS (STM32F4X_GPIO_NUM) +// This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS (STM32F4X_ADC_NUM) +#define NUM_ANALOG_FIRST 35 + +// Below ADC, DAC and PWM definitions already done in the core +// Could be redefined here if needed +// ADC resolution is 12bits +//#define ADC_RESOLUTION 12 +//#define DACC_RESOLUTION 12 + +// PWM resolution +/* + * BEWARE: + * Changing this value from the default (1000) will affect the PWM output value of analogWrite (to a PWM pin) + * Since the pin is toggled on capture, if you change the frequency of the timer you have to adapt the compare value (analogWrite thinks you did) + */ +//#define PWM_FREQUENCY 20000 +//The bottom values are the default and don't need to be redefined +//#define PWM_RESOLUTION 8 +//#define PWM_MAX_DUTY_CYCLE 255 + +// Below SPI and I2C definitions already done in the core +// Could be redefined here if differs from the default one +// SPI Definitions +#define PIN_SPI_MOSI PA7 +#define PIN_SPI_MISO PA6 +#define PIN_SPI_SCK PA5 +#define PIN_SPI_SS PA4 + +// I2C Definitions +#define PIN_WIRE_SDA PB9 +#define PIN_WIRE_SCL PB8 + +// Timer Definitions +//Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c +#define TIMER_TONE TIM7 +#define TIMER_SERVO TIM5 +#define TIMER_SERIAL TIM8 + +// UART Definitions +// Define here Serial instance number to map on Serial generic name +#define SERIAL_UART_INSTANCE 1 //ex: 2 for Serial2 (USART2) +// DEBUG_UART could be redefined to print on another instance than 'Serial' +//#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 +// DEBUG_UART baudrate, default: 9600 if not defined +//#define DEBUG_UART_BAUDRATE x +// DEBUG_UART Tx pin name, default: the first one found in PinMap_UART_TX for DEBUG_UART +//#define DEBUG_PINNAME_TX PX_n // PinName used for TX + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial1 +#endif diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 0e8a8c6b05..881dd17b01 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -173,6 +173,20 @@ build_unflags = -DUSBCON -DUSBD_USE_CDC build_flags = ${stm_flash_drive.build_flags} -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000 +# +# BigTreeTech E3 RRF (STM32F407VGT6 ARM Cortex-M4) +# +[env:BIGTREE_E3_RRF] +platform = ${common_stm32.platform} +extends = common_stm32 +board = genericSTM32F407VGT6 +board_build.variant = BIGTREE_E3_RRF +build_flags = ${common_stm32.build_flags} + -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000 + -DSERIAL_RX_BUFFER_SIZE=255 -DSERIAL_TX_BUFFER_SIZE=255 +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + # # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) # From dc6c977766a28c26075ff2b5268b3ee1c9660035 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Apr 2021 17:12:56 -0500 Subject: [PATCH 244/311] Fix CHDK warning --- Marlin/src/MarlinCore.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 2e1eab86de..1405f20334 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -453,7 +453,8 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { already_shutdown_steppers = false; } - #if PIN_EXISTS(CHDK) // Check if pin should be set to LOW (after M240 set it HIGH) + #if ENABLED(PHOTO_GCODE) && PIN_EXISTS(CHDK) + // Check if CHDK should be set to LOW (after M240 set it HIGH) extern millis_t chdk_timeout; if (chdk_timeout && ELAPSED(ms, chdk_timeout)) { chdk_timeout = 0; From 550a806d77201e9a228efd587a92af4adaf648b7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Apr 2021 18:24:08 -0500 Subject: [PATCH 245/311] More detailed serial config error --- Marlin/src/HAL/AVR/HAL.h | 8 ++++---- Marlin/src/HAL/DUE/HAL.h | 8 ++++---- Marlin/src/HAL/LPC1768/HAL.h | 8 ++++---- Marlin/src/HAL/SAMD51/HAL.h | 8 ++++---- Marlin/src/HAL/STM32/HAL.h | 8 ++++---- Marlin/src/HAL/STM32F1/HAL.h | 16 ++++++++-------- Marlin/src/HAL/TEENSY31_32/HAL.cpp | 2 ++ Marlin/src/HAL/TEENSY35_36/HAL.h | 2 ++ Marlin/src/HAL/TEENSY40_41/HAL.h | 4 ++-- 9 files changed, 34 insertions(+), 30 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index f6adf1bd31..890798a719 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -93,13 +93,13 @@ typedef int8_t pin_t; #define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0) #else #if !WITHIN(SERIAL_PORT, -1, 3) - #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #define MYSERIAL1 customizedSerial1 #ifdef SERIAL_PORT_2 #if !WITHIN(SERIAL_PORT_2, -1, 3) - #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." + #error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #define MYSERIAL2 customizedSerial2 #endif @@ -107,14 +107,14 @@ typedef int8_t pin_t; #ifdef MMU2_SERIAL_PORT #if !WITHIN(MMU2_SERIAL_PORT, -1, 3) - #error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "MMU2_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #define MMU2_SERIAL mmuSerial #endif #ifdef LCD_SERIAL_PORT #if !WITHIN(LCD_SERIAL_PORT, -1, 3) - #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #define LCD_SERIAL lcdSerial #if HAS_DGUS_LCD diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 095538f6a6..501e2f0b06 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -56,7 +56,7 @@ extern DefaultSerial4 MSerial3; #elif WITHIN(SERIAL_PORT, 0, 3) #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else - #error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "The required SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #ifdef SERIAL_PORT_2 @@ -65,7 +65,7 @@ extern DefaultSerial4 MSerial3; #elif WITHIN(SERIAL_PORT_2, 0, 3) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else - #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." + #error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #endif @@ -73,7 +73,7 @@ extern DefaultSerial4 MSerial3; #if WITHIN(MMU2_SERIAL_PORT, 0, 3) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else - #error "MMU2_SERIAL_PORT must be from 0 to 3. Please update your configuration." + #error "MMU2_SERIAL_PORT must be from 0 to 3." #endif #endif @@ -83,7 +83,7 @@ extern DefaultSerial4 MSerial3; #elif WITHIN(LCD_SERIAL_PORT, 0, 3) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else - #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #endif diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 828e126d70..07385261da 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -71,7 +71,7 @@ extern DefaultSerial1 USBSerial; #elif WITHIN(SERIAL_PORT, 0, 3) #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else - #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #ifdef SERIAL_PORT_2 @@ -80,7 +80,7 @@ extern DefaultSerial1 USBSerial; #elif WITHIN(SERIAL_PORT_2, 0, 3) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else - #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." + #error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #endif @@ -90,7 +90,7 @@ extern DefaultSerial1 USBSerial; #elif WITHIN(MMU2_SERIAL_PORT, 0, 3) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else - #error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "MMU2_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #endif @@ -100,7 +100,7 @@ extern DefaultSerial1 USBSerial; #elif WITHIN(LCD_SERIAL_PORT, 0, 3) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else - #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #if HAS_DGUS_LCD #define SERIAL_GET_TX_BUFFER_FREE() MSerial0.available() diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index de72c476e4..3add6c9b69 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -54,7 +54,7 @@ #elif WITHIN(SERIAL_PORT, 0, 3) #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else - #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #ifdef SERIAL_PORT_2 @@ -63,7 +63,7 @@ #elif WITHIN(SERIAL_PORT_2, 0, 3) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else - #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." + #error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #endif @@ -73,7 +73,7 @@ #elif WITHIN(MMU2_SERIAL_PORT, 0, 3) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else - #error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "MMU2_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #endif @@ -83,7 +83,7 @@ #elif WITHIN(LCD_SERIAL_PORT, 0, 3) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else - #error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration." + #error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #endif #endif diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index ad3a9963d7..d8e45670e6 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -55,7 +55,7 @@ #elif WITHIN(SERIAL_PORT, 1, 6) #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else - #error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." + #error "SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB." #endif #ifdef SERIAL_PORT_2 @@ -64,7 +64,7 @@ #elif WITHIN(SERIAL_PORT_2, 1, 6) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else - #error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration." + #error "SERIAL_PORT_2 must be from 1 to 6. You can also use -1 if the board supports Native USB." #endif #endif @@ -74,7 +74,7 @@ #elif WITHIN(MMU2_SERIAL_PORT, 1, 6) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else - #error "MMU2_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." + #error "MMU2_SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB." #endif #endif @@ -84,7 +84,7 @@ #elif WITHIN(LCD_SERIAL_PORT, 1, 6) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else - #error "LCD_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." + #error "LCD_SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB." #endif #if HAS_DGUS_LCD #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 94b0ad7ead..f37b0f2728 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -87,9 +87,9 @@ #else #define MYSERIAL1 MSERIAL(1) // dummy port #if NUM_UARTS == 5 - #error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." + #error "SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB." #else - #error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #error "SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB." #endif #endif @@ -101,9 +101,9 @@ #else #define MYSERIAL2 MSERIAL(1) // dummy port #if NUM_UARTS == 5 - #error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration." + #error "SERIAL_PORT_2 must be from 1 to 5. You can also use -1 if the board supports Native USB." #else - #error "SERIAL_PORT_2 must be -1 or from 1 to 3. Please update your configuration." + #error "SERIAL_PORT_2 must be from 1 to 3. You can also use -1 if the board supports Native USB." #endif #endif #endif @@ -116,9 +116,9 @@ #else #define MMU2_SERIAL MSERIAL(1) // dummy port #if NUM_UARTS == 5 - #error "MMU2_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." + #error "MMU2_SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB." #else - #error "MMU2_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #error "MMU2_SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB." #endif #endif #endif @@ -131,9 +131,9 @@ #else #define LCD_SERIAL MSERIAL(1) // dummy port #if NUM_UARTS == 5 - #error "LCD_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." + #error "LCD_SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB." #else - #error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration." + #error "LCD_SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB." #endif #endif #if HAS_DGUS_LCD diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index 7b7202547a..67f716c5d3 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -35,6 +35,8 @@ #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) IMPLEMENT_SERIAL(SERIAL_PORT); +#else + #error "SERIAL_PORT must be from 0 to 3." #endif USBSerialType USBSerial(false, SerialUSB); diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 5b120d852d..50008d72f6 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -72,6 +72,8 @@ extern USBSerialType USBSerial; #elif WITHIN(SERIAL_PORT, 0, 3) #define MYSERIAL1 MSERIAL(SERIAL_PORT) DECLARE_SERIAL(SERIAL_PORT); +#else + #error "SERIAL_PORT must be from 0 to 3, or -1 for Native USB." #endif #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index ce985dadb9..701d690382 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -74,7 +74,7 @@ extern USBSerialType USBSerial; DECLARE_SERIAL(SERIAL_PORT); #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else - #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration." + #error "The required SERIAL_PORT must be from 0 to 8, or -1 for Native USB." #endif #ifdef SERIAL_PORT_2 @@ -85,7 +85,7 @@ extern USBSerialType USBSerial; #elif WITHIN(SERIAL_PORT_2, 0, 8) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else - #error "SERIAL_PORT_2 must be from -2 to 8. Please update your configuration." + #error "SERIAL_PORT_2 must be from 0 to 8, or -1 for Native USB, or -2 for Ethernet." #endif #endif From 07c5a4fa040428e99c60d3b54e9374a59ec381df Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 19 Apr 2021 00:34:55 +0000 Subject: [PATCH 246/311] [cron] Bump distribution date (2021-04-19) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index a598a3154c..b21c552e3c 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-04-18" + #define STRING_DISTRIBUTION_DATE "2021-04-19" #endif /** From 59fd6428ae77a153082d8e1dd49c081b79a81a93 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Apr 2021 22:46:43 -0500 Subject: [PATCH 247/311] Skip preflight checks only (#21658) Followup to e8af38cc2d --- .../PlatformIO/scripts/common-cxxflags.py | 6 -- .../scripts/common-dependencies-post.py | 7 +- .../PlatformIO/scripts/common-dependencies.py | 13 +-- .../copy_marlin_variant_to_framework.py | 7 -- .../PlatformIO/scripts/preflight-checks.py | 84 +++++++++---------- 5 files changed, 47 insertions(+), 70 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/common-cxxflags.py b/buildroot/share/PlatformIO/scripts/common-cxxflags.py index 02cf124942..856a246fba 100644 --- a/buildroot/share/PlatformIO/scripts/common-cxxflags.py +++ b/buildroot/share/PlatformIO/scripts/common-cxxflags.py @@ -3,12 +3,6 @@ # Convenience script to apply customizations to CPP flags # Import("env") - -# Detect that 'vscode init' is running -from SCons.Script import COMMAND_LINE_TARGETS -if "idedata" in COMMAND_LINE_TARGETS: - env.Exit(0) - env.Append(CXXFLAGS=[ "-Wno-register" #"-Wno-incompatible-pointer-types", diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies-post.py b/buildroot/share/PlatformIO/scripts/common-dependencies-post.py index fa095f704c..2b1b948119 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies-post.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies-post.py @@ -2,13 +2,8 @@ # common-dependencies-post.py # Convenience script to add build flags for Marlin Enabled Features # + Import("env") - -# Detect that 'vscode init' is running -from SCons.Script import COMMAND_LINE_TARGETS -if "idedata" in COMMAND_LINE_TARGETS: - env.Exit(0) - Import("projenv") def apply_board_build_flags(): diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index 5b17c3586f..fe6ae7dba5 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -2,15 +2,6 @@ # common-dependencies.py # Convenience script to check dependencies and add libs and sources for Marlin Enabled Features # -Import("env") - -#print(env.Dump()) - -# Detect that 'vscode init' is running -from SCons.Script import COMMAND_LINE_TARGETS -if "idedata" in COMMAND_LINE_TARGETS: - env.Exit(0) - import subprocess,os,re PIO_VERSION_MIN = (5, 0, 3) @@ -40,6 +31,10 @@ except: from platformio.package.meta import PackageSpec from platformio.project.config import ProjectConfig +Import("env") + +#print(env.Dump()) + try: verbose = int(env.GetProjectOption('custom_verbose')) except: diff --git a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py index 955f002016..15c953156c 100644 --- a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py +++ b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py @@ -1,13 +1,6 @@ # # copy_marlin_variant_to_framework.py # -Import("env") - -# Detect that 'vscode init' is running -from SCons.Script import COMMAND_LINE_TARGETS -if "idedata" in COMMAND_LINE_TARGETS: - env.Exit(0) - import os,shutil from SCons.Script import DefaultEnvironment from platformio import util diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index f89c891323..27e5c9d70a 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -2,14 +2,8 @@ # preflight-checks.py # Check for common issues prior to compiling # -Import("env") - -# Detect that 'vscode init' is running -from SCons.Script import COMMAND_LINE_TARGETS -if "idedata" in COMMAND_LINE_TARGETS: - env.Exit(0) - import os,re,sys +Import("env") def get_envs_for_board(board): with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file: @@ -50,44 +44,50 @@ def check_envs(build_env, board_envs, config): return True return False -# Sanity checks: -if 'PIOENV' not in env: - raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") +def sanity_check_target(): + # Sanity checks: + if 'PIOENV' not in env: + raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") -if 'MARLIN_FEATURES' not in env: - raise SystemExit("Error: this script should be used after common Marlin scripts") + if 'MARLIN_FEATURES' not in env: + raise SystemExit("Error: this script should be used after common Marlin scripts") -if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: - raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") + if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: + raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") -build_env = env['PIOENV'] -motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] -board_envs = get_envs_for_board(motherboard) -config = env.GetProjectConfig() -result = check_envs("env:"+build_env, board_envs, config) + build_env = env['PIOENV'] + motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] + board_envs = get_envs_for_board(motherboard) + config = env.GetProjectConfig() + result = check_envs("env:"+build_env, board_envs, config) -if not result: - err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ - ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) - raise SystemExit(err) + if not result: + err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ + ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) + raise SystemExit(err) -# -# Check for Config files in two common incorrect places -# -for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]: - for f in [ "Configuration.h", "Configuration_adv.h" ]: - if os.path.isfile(os.path.join(p, f)): - err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p - raise SystemExit(err) + # + # Check for Config files in two common incorrect places + # + for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]: + for f in [ "Configuration.h", "Configuration_adv.h" ]: + if os.path.isfile(os.path.join(p, f)): + err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p + raise SystemExit(err) -# -# Check for old files indicating an entangled Marlin (mixing old and new code) -# -mixedin = [] -for p in [ os.path.join(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") ]: - for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: - if os.path.isfile(os.path.join(p, f)): - mixedin += [ f ] -if mixedin: - err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) - raise SystemExit(err) + # + # Check for old files indicating an entangled Marlin (mixing old and new code) + # + mixedin = [] + for p in [ os.path.join(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") ]: + for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: + if os.path.isfile(os.path.join(p, f)): + mixedin += [ f ] + if mixedin: + err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) + raise SystemExit(err) + +# Detect that 'vscode init' is running +from SCons.Script import COMMAND_LINE_TARGETS +if "idedata" not in COMMAND_LINE_TARGETS: + sanity_check_target() From d5143c2c1503225c291dfb9092b3bd11fc2fe156 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 19 Apr 2021 05:04:38 +0100 Subject: [PATCH 248/311] Support new style Anycubic Chiron TFT (#21597) --- Marlin/Configuration_adv.h | 25 ++ Marlin/src/inc/SanityCheck.h | 4 + .../lib/anycubic_chiron/FileNavigator.cpp | 280 ++++++++++------ .../extui/lib/anycubic_chiron/FileNavigator.h | 17 +- .../extui/lib/anycubic_chiron/chiron_tft.cpp | 308 +++++++++++------- .../extui/lib/anycubic_chiron/chiron_tft.h | 43 ++- .../lib/anycubic_chiron/chiron_tft_defs.h | 39 ++- 7 files changed, 484 insertions(+), 232 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index bd4793c55c..e41d5132a8 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1617,6 +1617,31 @@ #endif #endif // HAS_DGUS_LCD +// +// Additional options for AnyCubic Chiron TFT displays +// +#if ENABLED(ANYCUBIC_LCD_CHIRON) + // By default the type of panel is automatically detected. + // Enable one of these options if you know the panel type. + //#define CHIRON_TFT_STANDARD + //#define CHIRON_TFT_NEW + + // Enable the longer Anycubic powerup startup tune + //#define AC_DEFAULT_STARTUP_TUNE + + /** + * Display Folders + * By default the file browser lists all G-code files (including those in subfolders) in a flat list. + * Enable this option to display a hierarchical file browser. + * + * NOTES: + * - Without this option it helps to enable SDCARD_SORT_ALPHA so files are sorted before/after folders. + * - When used with the "new" panel, folder names will also have '.gcode' appended to their names. + * This hack is currently required to force the panel to show folders. + */ + #define AC_SD_FOLDER_VIEW +#endif + // // Specify additional languages for the UI. Default specified by LCD_LANGUAGE. // diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 64fcc85aad..58d52733e8 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2443,6 +2443,10 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "GRAPHICAL_TFT_UPSCALE must be 2, 3, or 4." #endif +#if BOTH(CHIRON_TFT_STANDARD, CHIRON_TFT_NEW) + #error "Please select only one of CHIRON_TFT_STANDARD or CHIRON_TFT_NEW." +#endif + /** * Some boards forbid the use of -1 Native USB */ diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp index 25847ae96c..9975d0824f 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp @@ -26,139 +26,233 @@ * Extensible_UI implementation for Anycubic Chiron * Written By Nick Wells, 2020 [https://github.com/SwiftNick] * (not affiliated with Anycubic, Ltd.) + * + * The AC panel wants files in block of 4 and can only display a flat list + * This library allows full folder traversal or flat file display and supports both standerd and new style panels. + * + * ## Old Style TFT panel + * Supported chars {}[]-+=_"$%^&*()~<>| + * Max display length 22 chars + * Max path len 29 chars + * (DOS 8.3 filepath max 29chars) + * (long filepath Max 22) + * + * ## New TFT Panel Format file display format + * Supported chars {}[]-+=_!"$%^&*()~<>\| + * Max display length 26 chars + * Max path len 29 chars + * (DOS 8.3 filepath must end '.GCO') + * (long filepath must end '.gcode') + * */ -/*************************************************************************** - * The AC panel wants files in block of 4 and can only display a flat list * - * This library allows full folder traversal. * - ***************************************************************************/ - #include "../../../../inc/MarlinConfigPre.h" #if ENABLED(ANYCUBIC_LCD_CHIRON) - #include "FileNavigator.h" #include "chiron_tft.h" using namespace ExtUI; +#define DEBUG_OUT ACDEBUG(AC_FILE) +#include "../../../../core/debug_out.h" + namespace Anycubic { - FileNavigator filenavigator; +FileNavigator filenavigator; +FileList FileNavigator::filelist; // Instance of the Marlin file API +uint16_t FileNavigator::lastpanelindex; +uint16_t FileNavigator::currentindex; // override the panel request +uint8_t FileNavigator::currentfolderdepth; +uint16_t FileNavigator::currentfolderindex[MAX_FOLDER_DEPTH]; // track folder pos for iteration +char FileNavigator::currentfoldername[MAX_PATH_LEN + 1]; // Current folder path - FileList FileNavigator::filelist; // Instance of the Marlin file API - char FileNavigator::currentfoldername[MAX_PATH_LEN]; // Current folder path - uint16_t FileNavigator::lastindex; - uint8_t FileNavigator::folderdepth; - uint16_t FileNavigator::currentindex; // override the panel request +FileNavigator::FileNavigator() { reset(); } - FileNavigator::FileNavigator() { reset(); } +void FileNavigator::reset() { + DEBUG_ECHOLNPGM("reset()"); + currentfoldername[0] = '\0'; + currentfolderdepth = 0; + currentindex = 0; + lastpanelindex = 0; + ZERO(currentfolderindex) - void FileNavigator::reset() { - currentfoldername[0] = '\0'; - folderdepth = 0; - currentindex = 0; - lastindex = 0; - // Start at root folder - while (!filelist.isAtRootDir()) filelist.upDir(); - refresh(); + // Start at root folder + while (!filelist.isAtRootDir()) filelist.upDir(); + refresh(); +} + +void FileNavigator::refresh() { filelist.refresh(); } + +void FileNavigator::changeDIR(const char *folder) { + if (currentfolderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth + DEBUG_ECHOLNPAIR("FD:" , folderdepth, " FP:",currentindex, " currentfolder:", currentfoldername, " enter:", folder); + currentfolderindex[currentfolderdepth] = currentindex; + strcat(currentfoldername, folder); + strcat(currentfoldername, "/"); + filelist.changeDir(folder); + currentfolderdepth++; + currentindex = 0; +} + +void FileNavigator::upDIR() { + DEBUG_ECHOLNPAIR("upDIR() from D:", currentfolderdepth, " N:", currentfoldername); + if (!filelist.isAtRootDir()) { + filelist.upDir(); + currentfolderdepth--; + currentindex = currentfolderindex[currentfolderdepth]; // restore last position in the folder + filelist.seek(currentindex); // restore file information } - void FileNavigator::refresh() { filelist.refresh(); } + // Remove the child folder from the stored path + if (currentfolderdepth == 0) + currentfoldername[0] = '\0'; + else { + const char *pos = strchr(currentfoldername, '/'); + *(pos + 1) = '\0'; + } +} - void FileNavigator::getFiles(uint16_t index) { - uint8_t files = 4; - if (index == 0) currentindex = 0; - - // Each time we change folder we reset the file index to 0 and keep track - // of the current position as the TFT panel isnt aware of folders trees. - if (index > 0) { - --currentindex; // go back a file to take account of the .. added to the root. - if (index > lastindex) - currentindex += files; +void FileNavigator::skiptofileindex(uint16_t skip) { + if (skip == 0) return; + while (skip > 0) { + if (filelist.seek(currentindex)) { + DEBUG_ECHOLNPAIR("CI:", currentindex, " FD:", currentfolderdepth, " N:", skip, " ", filelist.longFilename()); + if (!filelist.isDir()) { + skip--; + currentindex++; + } else - currentindex = currentindex < 4 ? 0 : currentindex - files; + changeDIR(filelist.shortFilename()); + } // valid file + if (currentindex == filelist.count()) { + if (currentfolderdepth > 0) { + upDIR(); + currentindex++; + } + else break; // end of root folder + } // end of folder + } // files needed + // No more files available. +} + +#if ENABLED(AC_SD_FOLDER_VIEW) // SD Folder navigation + + void FileNavigator::getFiles(uint16_t index, panel_type_t paneltype, uint8_t filesneeded) { + if (index == 0) currentindex = 0; + // Each time we change folder we reset the file index to 0 and keep track + // of the current position, since the TFT panel isn't aware of folder trees. + if (index > 0) { + --currentindex; // go back a file to take account of the .. we added to the root. + if (index > lastpanelindex) + currentindex += filesneeded; + else + currentindex = currentindex < 4 ? 0 : currentindex - filesneeded; } - lastindex = index; + lastpanelindex = index; - #if ACDEBUG(AC_FILE) - SERIAL_ECHOLNPAIR("index=", index, " currentindex=", currentindex); - #endif + DEBUG_ECHOLNPAIR("index=", index, " currentindex=", currentindex); - if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder - TFTSer.println("<<"); - TFTSer.println(".."); - files--; + if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder + // The new panel ignores entries that don't end in .GCO or .gcode so add and pad them. + if (paneltype == AC_panel_new) { + TFTSer.println("<<.GCO"); + Chiron.SendtoTFTLN(PSTR(".. .gcode")); + } + else { + TFTSer.println("<<"); + TFTSer.println(".."); + } + filesneeded--; } - for (uint16_t seek = currentindex; seek < currentindex + files; seek++) { + for (uint16_t seek = currentindex; seek < currentindex + filesneeded; seek++) { if (filelist.seek(seek)) { - sendFile(); - #if ACDEBUG(AC_FILE) - SERIAL_ECHOLNPAIR("-", seek, " '", filelist.longFilename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n"); - #endif + sendFile(paneltype); + DEBUG_ECHOLNPAIR("-", seek, " '", filelist.longFilename(), "' '", currentfoldername, "", filelist.shortFilename(), "'"); } } } - void FileNavigator::sendFile() { - // send the file and folder info to the panel - // this info will be returned when the file is selected - // Permitted special characters in file name -_*#~ - // Panel can display 22 characters per line + void FileNavigator::sendFile(panel_type_t paneltype) { if (filelist.isDir()) { - //TFTSer.print(currentfoldername); - TFTSer.println(filelist.shortFilename()); - TFTSer.print(filelist.shortFilename()); - TFTSer.println("/"); + // Add mandatory tags for new panel otherwise lines are ignored. + if (paneltype == AC_panel_new) { + TFTSer.print(filelist.shortFilename()); + TFTSer.println(".GCO"); + TFTSer.print(filelist.shortFilename()); + TFTSer.write('/'); + // Make sure we fill all 29 chars of the display line to clear the text buffer otherwise the last line is still visible + for (int8_t i = strlen(filelist.shortFilename()); i < 19; i++) + TFTSer.write(' '); + TFTSer.println(".gcode"); + } + else { + TFTSer.println(filelist.shortFilename()); + TFTSer.print(filelist.shortFilename()); + TFTSer.write('/'); + TFTSer.println(); + } } - else { - // Logical Name + else { // Not DIR TFTSer.write('/'); - if (folderdepth > 0) TFTSer.print(currentfoldername); - + if (currentfolderdepth > 0) TFTSer.print(currentfoldername); TFTSer.println(filelist.shortFilename()); + TFTSer.print(filelist.longFilename()); - // Display Name - TFTSer.println(filelist.longFilename()); + // Make sure we fill all 29 chars of the display line to clear the text buffer otherwise the last line is still visible + if (paneltype == AC_panel_new) + for (int8_t i = strlen(filelist.longFilename()); i < 26; i++) + TFTSer.write(' '); + + TFTSer.println(); } - } - void FileNavigator::changeDIR(char *folder) { - #if ACDEBUG(AC_FILE) - SERIAL_ECHOLNPAIR("currentfolder: ", currentfoldername, " New: ", folder); - #endif - if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth - strcat(currentfoldername, folder); - strcat(currentfoldername, "/"); - filelist.changeDir(folder); - refresh(); - folderdepth++; - currentindex = 0; - } + } // AC_SD_FOLDER_VIEW - void FileNavigator::upDIR() { - filelist.upDir(); - refresh(); - folderdepth--; - currentindex = 0; - // Remove the last child folder from the stored path - if (folderdepth == 0) { - currentfoldername[0] = '\0'; +#else // Flat file list + + void FileNavigator::getFiles(uint16_t index, panel_type_t paneltype, uint8_t filesneeded) { + DEBUG_ECHOLNPAIR("getFiles() I:", index," L:", lastpanelindex); + // if we're searching backwards, jump back to start and search forward + if (index < lastpanelindex) { reset(); + skiptofileindex(index); } - else { - char *pos = nullptr; - for (uint8_t f = 0; f < folderdepth; f++) - pos = strchr(currentfoldername, '/'); + lastpanelindex = index; - *(pos + 1) = '\0'; - } - #if ACDEBUG(AC_FILE) - SERIAL_ECHOLNPAIR("depth: ", folderdepth, " currentfoldername: ", currentfoldername); - #endif + while (filesneeded > 0) { + if (filelist.seek(currentindex)) { + if (!filelist.isDir()) { + sendFile(paneltype); + filesneeded--; + currentindex++; + } + else + changeDIR(filelist.shortFilename()); + } // valid file + + if (currentindex == filelist.count()) { + if (currentfolderdepth > 0) { + upDIR(); + currentindex++; + } + else break; // end of root folder + } // end of folder + } // files needed + // No more files available. } - char* FileNavigator::getCurrentFolderName() { return currentfoldername; } -} + void FileNavigator::sendFile(panel_type_t paneltype) { + TFTSer.write('/'); + if (currentfolderdepth > 0) TFTSer.print(currentfoldername); + TFTSer.println(filelist.shortFilename()); + if (currentfolderdepth > 0) TFTSer.print(currentfoldername); + TFTSer.println(filelist.longFilename()); + DEBUG_ECHOLNPAIR("/", currentfoldername, "", filelist.shortFilename(), " ", filelist.longFilename()); + } + +#endif // Flat file list + +} // Anycubic namespace #endif // ANYCUBIC_LCD_CHIRON diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h index c709415879..253b8039e7 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h @@ -38,14 +38,13 @@ namespace Anycubic { class FileNavigator { public: - FileNavigator(); - void reset(); - void getFiles(uint16_t, panel_type_t, uint8_t filesneeded=4); - void upDIR(); - void changeDIR(const char *); - void sendFile(panel_type_t); - void refresh(); - void skiptofileindex(uint16_t); + static void reset(); + static void getFiles(uint16_t, panel_type_t, uint8_t filesneeded=4); + static void upDIR(); + static void changeDIR(const char *); + static void sendFile(panel_type_t); + static void refresh(); + static void skiptofileindex(uint16_t); static FileList filelist; private: @@ -53,7 +52,7 @@ class FileNavigator { static uint16_t currentindex; static uint8_t currentfolderdepth; static uint16_t currentfolderindex[MAX_FOLDER_DEPTH]; - static char currentfoldername[MAX_PATH_LEN]; + static char currentfoldername[MAX_PATH_LEN + 1]; }; extern FileNavigator filenavigator; diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index 065e4e1789..b35d792736 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -43,25 +43,27 @@ namespace Anycubic { +ChironTFT Chiron; +#if AUTO_DETECT_CHIRON_TFT + panel_type_t ChironTFT::panel_type = AC_panel_unknown; +#endif +last_error_t ChironTFT::last_error; printer_state_t ChironTFT::printer_state; paused_state_t ChironTFT::pause_state; heater_state_t ChironTFT::hotend_state; heater_state_t ChironTFT::hotbed_state; xy_uint8_t ChironTFT::selectedmeshpoint; -char ChironTFT::selectedfile[MAX_PATH_LEN]; -char ChironTFT::panel_command[MAX_CMND_LEN]; +char ChironTFT::selectedfile[MAX_PATH_LEN + 1]; +char ChironTFT::panel_command[MAX_CMND_LEN + 1]; uint8_t ChironTFT::command_len; float ChironTFT::live_Zoffset; file_menu_t ChironTFT::file_menu; -ChironTFT Chiron; - -ChironTFT::ChironTFT(){} - void ChironTFT::Startup() { selectedfile[0] = '\0'; panel_command[0] = '\0'; command_len = 0; + last_error = AC_error_none; printer_state = AC_printer_idle; pause_state = AC_paused_idle; hotend_state = AC_heater_off; @@ -80,27 +82,41 @@ void ChironTFT::Startup() { // Filament runout is handled by Marlin settings in Configuration.h // opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present. // opt_enable FIL_RUNOUT_PULLUP - TFTSer.begin(115200); + // wait for the TFT panel to initialise and finish the animation + delay_ms(250); + + // There are different panels for the Chiron with slightly different commands + // So we need to know what we are working with. + + // Panel type can be defined otherwise detect it automatically + if (panel_type == AC_panel_unknown) DetectPanelType(); + // Signal Board has reset SendtoTFTLN(AC_msg_main_board_has_reset); - safe_delay(200); - // Enable leveling and Disable end stops during print // as Z home places nozzle above the bed so we need to allow it past the end stops injectCommands_P(AC_cmnd_enable_leveling); // Startup tunes are defined in Tunes.h - //PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1); - PlayTune(BEEPER_PIN, GB_PowerOn, 1); + PlayTune(BEEPER_PIN, TERN(AC_DEFAULT_STARTUP_TUNE, Anycubic_PowerOn, GB_PowerOn), 1); + #if ACDEBUGLEVEL SERIAL_ECHOLNPAIR("AC Debug Level ", ACDEBUGLEVEL); #endif SendtoTFTLN(AC_msg_ready); } +void ChironTFT::DetectPanelType() { + #if AUTO_DETECT_CHIRON_TFT + // Send a query to the TFT + SendtoTFTLN(AC_Test_for_OldPanel); // The panel will respond with 'SXY 480 320' + SendtoTFTLN(AC_Test_for_NewPanel); // the panel will respond with '[0]=0 ' to '[19]=0 ' + #endif +} + void ChironTFT::IdleLoop() { if (ReadTFTCommand()) { ProcessPanelRequest(); @@ -123,15 +139,16 @@ void ChironTFT::MediaEvent(media_event_t event) { switch (event) { case AC_media_inserted: SendtoTFTLN(AC_msg_sd_card_inserted); - break; + break; case AC_media_removed: SendtoTFTLN(AC_msg_sd_card_removed); - break; + break; case AC_media_error: + last_error = AC_error_noSD; SendtoTFTLN(AC_msg_no_sd_card); - break; + break; } } @@ -170,8 +187,8 @@ void ChironTFT::FilamentRunout() { SERIAL_ECHOLNPAIR("FilamentRunout() printer_state ", printer_state); #endif // 1 Signal filament out + last_error = AC_error_filament_runout; SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block); - //printer_state = AC_printer_filament_out; PlayTune(BEEPER_PIN, FilamentOut, 1); } @@ -278,14 +295,23 @@ void ChironTFT::StatusChange(const char * const msg) { SendtoTFTLN(AC_msg_bed_heating); hotbed_state = AC_heater_temp_set; } + else if (strcmp_P(msg, MARLIN_msg_EEPROM_version) == 0) { + last_error = AC_error_EEPROM; + } } } void ChironTFT::PowerLossRecovery() { printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover. + last_error = AC_error_powerloss; PlayTune(BEEPER_PIN, SOS, 1); - SERIAL_ECHOLNPGM("Resuming from power outage..."); - SERIAL_ECHOLNPGM("Select SD file then press resume"); + SERIAL_ECHOLNPGM_P(AC_msg_powerloss_recovery); +} + +void ChironTFT::PrintComplete() { + SendtoTFT(AC_msg_print_complete); + printer_state = AC_printer_idle; + setSoftEndstopState(true); // enable endstops } void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel @@ -319,26 +345,29 @@ bool ChironTFT::ReadTFTCommand() { command_len++; } - if (command_ready) { - panel_command[command_len] = 0x00; + if (command_ready || command_len == MAX_CMND_LEN) { + panel_command[command_len] = '\0'; #if ACDEBUG(AC_ALL) - SERIAL_ECHOLNPAIR("< ", panel_command); - #endif - #if ACDEBUG(AC_SOME) - // Ignore status request commands - uint8_t req = atoi(&panel_command[1]); - if (req > 7 && req != 20) { - SERIAL_ECHOLNPAIR("> ", panel_command); - SERIAL_ECHOLNPAIR("printer_state:", printer_state); - } + SERIAL_ECHOLNPAIR("len(",command_len,") < ", panel_command); #endif + command_ready = true; } return command_ready; } -int8_t ChironTFT::Findcmndpos(const char * buff, char q) { +int8_t ChironTFT::FindToken(char c) { int8_t pos = 0; - do { if (buff[pos] == q) return pos; } while (++pos < MAX_CMND_LEN); + do { + if (panel_command[pos] == c) { + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Tpos:", pos, " ", c); + #endif + return pos; + } + } while(++pos < command_len); + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Not found: ", c); + #endif return -1; } @@ -352,6 +381,7 @@ void ChironTFT::CheckHeaters() { faultDuration++; if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { SendtoTFTLN(AC_msg_nozzle_temp_abnormal); + last_error = AC_error_abnormal_temp_t0; SERIAL_ECHOLNPAIR("Extruder temp abnormal! : ", temp); break; } @@ -366,6 +396,7 @@ void ChironTFT::CheckHeaters() { faultDuration++; if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { SendtoTFTLN(AC_msg_nozzle_temp_abnormal); + last_error = AC_error_abnormal_temp_bed; SERIAL_ECHOLNPAIR("Bed temp abnormal! : ", temp); break; } @@ -396,15 +427,21 @@ void ChironTFT::SendFileList(int8_t startindex) { SERIAL_ECHOLNPAIR("## SendFileList ## ", startindex); #endif SendtoTFTLN(PSTR("FN ")); - filenavigator.getFiles(startindex); + filenavigator.getFiles(startindex, panel_type, 4); SendtoTFTLN(PSTR("END")); } void ChironTFT::SelectFile() { - strncpy(selectedfile, panel_command + 4, command_len - 4); - selectedfile[command_len - 5] = '\0'; + if (panel_type == AC_panel_new) { + strncpy(selectedfile, panel_command + 4, command_len - 3); + selectedfile[command_len - 4] = '\0'; + } + else { + strncpy(selectedfile, panel_command + 4, command_len - 4); + selectedfile[command_len - 5] = '\0'; + } #if ACDEBUG(AC_FILE) - SERIAL_ECHOLNPAIR_F(" Selected File: ",selectedfile); + SERIAL_ECHOLNPAIR(" Selected File: ",selectedfile); #endif switch (selectedfile[0]) { case '/': // Valid file selected @@ -417,6 +454,9 @@ void ChironTFT::SelectFile() { SendFileList( 0 ); break; default: // enter sub folder + // for new panel remove the '.GCO' tag that was added to the end of the path + if (panel_type == AC_panel_new) + selectedfile[strlen(selectedfile) - 4] = '\0'; filenavigator.changeDIR(selectedfile); SendtoTFTLN(AC_msg_sd_file_open_failed); SendFileList( 0 ); @@ -424,25 +464,48 @@ void ChironTFT::SelectFile() { } } -void ChironTFT::InjectCommandandWait(PGM_P cmd) { - //injectCommands_P(cmnd); queue.enqueue_now_P(cmd); - //SERIAL_ECHOLN(PSTR("Inject>")); -} - void ChironTFT::ProcessPanelRequest() { // Break these up into logical blocks // as its easier to navigate than one huge switch case! - int8_t req = atoi(&panel_command[1]); + const int8_t tpos = FindToken('A'); + // Panel request are 'A0' - 'A36' + if (tpos != -1) { + const int8_t req = atoi(&panel_command[tpos+1]); - // Information requests A0 - A8 and A33 - if (req <= 8 || req == 33) PanelInfo(req); + // Information requests A0 - A8 and A33 + if (req <= 8 || req == 33) PanelInfo(req); - // Simple Actions A9 - A28 - else if ( req <= 28) PanelAction(req); + // Simple Actions A9 - A28 + else if (req <= 28) PanelAction(req); - // Process Initiation - else if (req <= 34) PanelProcess(req); + // Process Initiation + else if (req <= 36) PanelProcess(req); + } + else { + #if AUTO_DETECT_CHIRON_TFT + // This may be a response to a panel type detection query + if (panel_type == AC_panel_unknown) { + tpos = FindToken('S'); // old panel will respond to 'SIZE' with 'SXY 480 320' + if (tpos != -1) { + if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') { + panel_type = AC_panel_standard; + SERIAL_ECHOLNPGM_P(AC_msg_old_panel_detected); + } + } + else { + tpos = FindToken('['); // new panel will respond to 'J200' with '[0]=0' + if (tpos != -1) { + if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') { + panel_type = AC_panel_new; + SERIAL_ECHOLNPGM_P(AC_msg_new_panel_detected); + } + } + } + return; + } + #endif - else SendtoTFTLN(); + SendtoTFTLN(); // Ignore unknown requests + } } void ChironTFT::PanelInfo(uint8_t req) { @@ -513,7 +576,8 @@ void ChironTFT::PanelInfo(uint8_t req) { case 33: // A33 Get firmware info SendtoTFT(PSTR("J33 ")); - SendtoTFTLN(PSTR(SHORT_BUILD_VERSION)); + // If there is an error recorded, show that instead of the FW version + if (!GetLastError()) SendtoTFTLN(PSTR(SHORT_BUILD_VERSION)); break; } } @@ -567,11 +631,7 @@ void ChironTFT::PanelAction(uint8_t req) { #if ACDebugLevel >= 1 SERIAL_ECHOLNPAIR_F("Print: ", selectedfile); #endif - // the card library needs a path starting // but the File api doesn't... - char file[MAX_PATH_LEN]; - file[0] = '/'; - strcpy(file + 1, selectedfile); - printFile(file); + printFile(selectedfile); SendtoTFTLN(AC_msg_print_from_sd_card); } break; @@ -631,29 +691,24 @@ void ChironTFT::PanelAction(uint8_t req) { } break; - case 22: // A22 Move Axis A22 Y +10F3000 - // Ignore request if printing - if (!isPrinting()) { - // setAxisPosition_mm() uses pre defined manual feedrates so ignore the feedrate from the panel - setSoftEndstopState(true); // enable endstops - float newposition = atof(&panel_command[6]); + case 22: { // A22 Move Axis + // The commands have changed on the new panel + // Old TFT A22 X -1F1500 A22 X +1F1500 + // New TFT A22 X-1.0 F1500 A22 X1.0 F1500 + // lets just wrap this in a gcode relative nonprint move and let the controller deal with it + // G91 G0 G90 + + if (!isPrinting()) { // Ignore request if printing + char MoveCmnd[30]; + sprintf_P(MoveCmnd, PSTR("G91\nG0 %s \nG90"), panel_command+3); #if ACDEBUG(AC_ACTION) - SERIAL_ECHOLNPAIR("Nudge ", AS_CHAR(panel_command[4]), " axis ", newposition); + SERIAL_ECHOLNPAIR("Move: ", MoveCmnd); #endif - - switch (panel_command[4]) { - case 'X': setAxisPosition_mm(getAxisPosition_mm(X) + newposition, X); break; - case 'Y': setAxisPosition_mm(getAxisPosition_mm(Y) + newposition, Y); break; - case 'Z': setAxisPosition_mm(getAxisPosition_mm(Z) + newposition, Z); break; - case 'E': // The only time we get this command is from the filament load/unload menu - // the standard movement is too slow so we will use the load unlod GCode to speed it up a bit - if (canMove(E0) && !commandsInQueue()) - injectCommands_P(newposition > 0 ? AC_cmnd_manual_load_filament : AC_cmnd_manual_unload_filament); - break; - } + setSoftEndstopState(true); // enable endstops + injectCommands(MoveCmnd); } - break; + } break; case 23: // A23 Preheat PLA // Ignore request if printing @@ -690,7 +745,9 @@ void ChironTFT::PanelAction(uint8_t req) { break; case 26: // A26 Refresh SD - // M22 M21 maybe needed here to reset sd card + if (card.isMounted())card.release(); + card.mount(); + safe_delay(500); filenavigator.reset(); break; @@ -710,8 +767,8 @@ void ChironTFT::PanelProcess(uint8_t req) { case 29: { // A29 Read Mesh Point A29 X1 Y1 xy_uint8_t pos; float pos_z; - pos.x = atoi(&panel_command[5]); - pos.y = atoi(&panel_command[8]); + pos.x = atoi(&panel_command[FindToken('X')+1]); + pos.y = atoi(&panel_command[FindToken('Y')+1]); pos_z = getMeshPoint(pos); SendtoTFT(PSTR("A29V ")); @@ -743,48 +800,60 @@ void ChironTFT::PanelProcess(uint8_t req) { } } break; - case 30: { // A30 Auto leveling - if (panel_command[3] == 'S') { // Start probing + case 30: { // A30 Auto leveling + if (FindToken('S') != -1) { // Start probing New panel adds spaces.. // Ignore request if printing if (isPrinting()) SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling else { - injectCommands_P(PSTR("G28O\nG29")); - printer_state = AC_printer_probing; + + SendtoTFTLN(AC_msg_start_probing); + injectCommands_P(PSTR("G28\nG29")); + printer_state = AC_printer_probing; } } - else SendtoTFTLN(AC_msg_start_probing); - } break; + else { + SendtoTFTLN(AC_msg_start_probing); // Just enter levelling menu + } + } break; case 31: { // A31 Adjust all Probe Points - switch (panel_command[3]) { - case 'C': // Restore and apply original offsets - if (!isPrinting()) { - injectCommands_P(PSTR("M501\nM420 S1")); - selectedmeshpoint.x = selectedmeshpoint.y = 99; - } - break; - case 'D': // Save Z Offset tables and restore leveling state - if (!isPrinting()) { - setAxisPosition_mm(1.0,Z); - injectCommands_P(PSTR("M500")); - selectedmeshpoint.x = selectedmeshpoint.y = 99; - } - break; - case 'G': // Get current offset - SendtoTFT(PSTR("A31V ")); - // When printing use the live z Offset position - // we will use babystepping to move the print head - if (isPrinting()) - TFTSer.println(live_Zoffset); - else { - TFTSer.println(getZOffset_mm()); - selectedmeshpoint.x = selectedmeshpoint.y = 99; - } - break; - case 'S': { // Set offset (adjusts all points by value) - float Zshift = atof(&panel_command[4]); + // The tokens can occur in different places on the new panel so we need to find it. + + if (FindToken('C') != -1) { // Restore and apply original offsets + if (!isPrinting()) { + injectCommands_P(PSTR("M501\nM420 S1")); + selectedmeshpoint.x = selectedmeshpoint.y = 99; + SERIAL_ECHOLNPGM_P(AC_msg_mesh_changes_abandoned); + } + } + + else if (FindToken('D') != -1) { // Save Z Offset tables and restore leveling state + if (!isPrinting()) { + setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made + injectCommands_P(PSTR("M500")); + SERIAL_ECHOLNPGM_P(AC_msg_mesh_changes_saved); + selectedmeshpoint.x = selectedmeshpoint.y = 99; + } + } + + else if (FindToken('G') != -1) { // Get current offset + SendtoTFT(PSTR("A31V ")); + // When printing use the live z Offset position + // we will use babystepping to move the print head + if (isPrinting()) + TFTSer.println(live_Zoffset); + else { + TFTSer.println(getZOffset_mm()); + selectedmeshpoint.x = selectedmeshpoint.y = 99; + } + } + + else { + int8_t tokenpos = FindToken('S'); + if (tokenpos != -1) { // Set offset (adjusts all points by value) + float Zshift = atof(&panel_command[tokenpos+1]); setSoftEndstopState(false); // disable endstops // Allow temporary Z position nudging during print // From the leveling panel use the all points UI to adjust the print pos. @@ -813,6 +882,9 @@ void ChironTFT::PanelProcess(uint8_t req) { const xy_uint8_t pos { x, y }; const float currval = getMeshPoint(pos); setMeshPoint(pos, constrain(currval + Zshift, AC_LOWEST_MESHPOINT_VAL, 2)); + #if ACDEBUG(AC_INFO) + SERIAL_ECHOLNPAIR("Change mesh point X", x," Y",y ," from ", currval, " to ", getMeshPoint(pos) ); + #endif } const float currZOffset = getZOffset_mm(); #if ACDEBUG(AC_INFO) @@ -878,9 +950,27 @@ void ChironTFT::PanelProcess(uint8_t req) { } } } break; + + case 36: // A36 Auto leveling for new TFT bet that was a typo in the panel code! + SendtoTFTLN(AC_msg_start_probing); + break; } } -} // Anycubic +bool ChironTFT::GetLastError() { + switch (last_error) { + case AC_error_abnormal_temp_bed: SendtoTFTLN(AC_msg_error_bed_temp); break; + case AC_error_abnormal_temp_t0: SendtoTFTLN(AC_msg_error_hotend_temp); break; + case AC_error_noSD: SendtoTFTLN(AC_msg_error_sd_card); break; + case AC_error_powerloss: SendtoTFTLN(AC_msg_power_loss); break; + case AC_error_EEPROM: SendtoTFTLN(AC_msg_eeprom_version); break; + case AC_error_filament_runout: SendtoTFTLN(AC_msg_filament_out); break; + default: return false; + } + last_error = AC_error_none; + return true; +} + +} // Anycubic namespace #endif // ANYCUBIC_LCD_CHIRON diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h index 3c26cc0aec..aeef12afc6 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.h @@ -33,23 +33,30 @@ #include "../../../../inc/MarlinConfigPre.h" #include "../../ui_api.h" +#if NONE(CHIRON_TFT_STANDARD, CHIRON_TFT_NEW) + #define AUTO_DETECT_CHIRON_TFT 1 +#endif + namespace Anycubic { class ChironTFT { - private: - static printer_state_t printer_state; - static paused_state_t pause_state; - static heater_state_t hotend_state; - static heater_state_t hotbed_state; - static xy_uint8_t selectedmeshpoint; - static char panel_command[MAX_CMND_LEN]; - static uint8_t command_len; - static char selectedfile[MAX_PATH_LEN]; - static float live_Zoffset; - static file_menu_t file_menu; - + #if AUTO_DETECT_CHIRON_TFT + static panel_type_t panel_type; + #else + static constexpr panel_type_t panel_type = TERN(CHIRON_TFT_NEW, AC_panel_new, AC_panel_standard); + #endif + static last_error_t last_error; + static printer_state_t printer_state; + static paused_state_t pause_state; + static heater_state_t hotend_state; + static heater_state_t hotbed_state; + static xy_uint8_t selectedmeshpoint; + static char panel_command[MAX_CMND_LEN + 1]; + static uint8_t command_len; + static char selectedfile[MAX_PATH_LEN + 1]; + static float live_Zoffset; + static file_menu_t file_menu; public: - ChironTFT(); static void Startup(); static void IdleLoop(); static void PrinterKilled(PGM_P,PGM_P); @@ -59,12 +66,13 @@ class ChironTFT { static void ConfirmationRequest(const char * const ); static void StatusChange(const char * const ); static void PowerLossRecovery(); - - private: + static void PrintComplete(); static void SendtoTFT(PGM_P); static void SendtoTFTLN(PGM_P); + private: + static void DetectPanelType(); static bool ReadTFTCommand(); - static int8_t Findcmndpos(const char *, char); + static int8_t FindToken(char); static void CheckHeaters(); static void SendFileList(int8_t); static void SelectFile(); @@ -73,8 +81,9 @@ class ChironTFT { static void PanelInfo(uint8_t); static void PanelAction(uint8_t); static void PanelProcess(uint8_t); + static bool GetLastError(); }; extern ChironTFT Chiron; -} // Anycubic +} // Anycubic namespace diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h index a8ebe9c776..83e64e7973 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft_defs.h @@ -30,7 +30,7 @@ #pragma once #include "../../../../inc/MarlinConfigPre.h" -//#define ACDEBUGLEVEL 255 +//#define ACDEBUGLEVEL 4 #if ACDEBUGLEVEL // Bit-masks for selective debug: @@ -54,7 +54,7 @@ #define MAX_PATH_LEN 16 * MAX_FOLDER_DEPTH // Maximum number of characters in a SD file path #define AC_HEATER_FAULT_VALIDATION_TIME 5 // number of 1/2 second loops before signalling a heater fault -#define AC_LOWEST_MESHPOINT_VAL Z_PROBE_LOW_POINT // The lowest value you can set for a single mesh point offset +#define AC_LOWEST_MESHPOINT_VAL -10 // The lowest value you can set for a single mesh point offset // TFT panel commands #define AC_msg_sd_card_inserted PSTR("J00") @@ -85,6 +85,18 @@ #define AC_msg_probing_complete PSTR("J25") #define AC_msg_start_probing PSTR("J26") #define AC_msg_version PSTR("J27") +#define AC_msg_mesh_changes_abandoned PSTR("Mesh changes abandoned, previous mesh restored.") +#define AC_msg_mesh_changes_saved PSTR("Mesh changes saved.") +#define AC_msg_old_panel_detected PSTR("Standard TFT panel detected!") +#define AC_msg_new_panel_detected PSTR("New TFT panel detected!") +#define AC_msg_powerloss_recovery PSTR("Resuming from power outage! select the same SD file then press resume") +// Error messages must not contain spaces +#define AC_msg_error_bed_temp PSTR("Abnormal_bed_temp") +#define AC_msg_error_hotend_temp PSTR("Abnormal_hotend_temp") +#define AC_msg_error_sd_card PSTR("SD_card_error") +#define AC_msg_filament_out PSTR("Filament_runout") +#define AC_msg_power_loss PSTR("Power_failure") +#define AC_msg_eeprom_version PSTR("EEPROM_ver_wrong") #define MARLIN_msg_start_probing PSTR("Probing Point 1/25") #define MARLIN_msg_probing_failed PSTR("Probing Failed") @@ -93,13 +105,14 @@ #define MARLIN_msg_print_aborted PSTR("Print Aborted") #define MARLIN_msg_extruder_heating PSTR("E Heating...") #define MARLIN_msg_bed_heating PSTR("Bed Heating...") - +#define MARLIN_msg_EEPROM_version PSTR("EEPROM Version Error") #define MARLIN_msg_nozzle_parked PSTR("Nozzle Parked") #define MARLIN_msg_heater_timeout PSTR("Heater Timeout") #define MARLIN_msg_reheating PSTR("Reheating...") #define MARLIN_msg_reheat_done PSTR("Reheat finished.") #define MARLIN_msg_filament_purging PSTR("Filament Purging...") #define MARLIN_msg_special_pause PSTR("PB") + #define AC_cmnd_auto_unload_filament PSTR("M701") // Use Marlin unload routine #define AC_cmnd_auto_load_filament PSTR("M702 M0 PB") // Use Marlin load routing then pause for user to clean nozzle @@ -108,6 +121,9 @@ #define AC_cmnd_enable_leveling PSTR("M420SV") #define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position +#define AC_Test_for_OldPanel PSTR("SIZE") // An old panel will respond with 'SXY 480 320' a new panel wont respond. +#define AC_Test_for_NewPanel PSTR("J200") // A new panel will respond with '[0]=0 [1]=0' to '[19]=0 ' an old panel wont respond + namespace Anycubic { enum heater_state_t : uint8_t { AC_heater_off, @@ -120,6 +136,7 @@ namespace Anycubic { AC_paused_idle }; enum printer_state_t : uint8_t { + AC_printer_booting, AC_printer_idle, AC_printer_probing, AC_printer_printing, @@ -144,4 +161,18 @@ namespace Anycubic { AC_menu_change_to_file, AC_menu_change_to_command }; -} // Anycubic + enum panel_type_t : uint8_t { + AC_panel_unknown, + AC_panel_standard, + AC_panel_new + }; + enum last_error_t : uint8_t { + AC_error_none, + AC_error_abnormal_temp_t0, + AC_error_abnormal_temp_bed, + AC_error_noSD, + AC_error_powerloss, + AC_error_filament_runout, + AC_error_EEPROM + }; +} // Anycubic namespace From 2c2984fd29b2ac6cf7a4301541e903e52179cfed Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 19 Apr 2021 00:07:57 -0500 Subject: [PATCH 249/311] Update realtime, DLP comments --- Marlin/Configuration_adv.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e41d5132a8..e1124edf50 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2141,8 +2141,19 @@ //#define EMERGENCY_PARSER /** - * Realtime Reporting - * Add support for commands S000 State, P000 Pause, and R000 Resume + * Realtime Reporting (requires EMERGENCY_PARSER) + * + * - Report position and state of the machine (like Grbl). + * - Auto-report position during long moves. + * - Useful for CNC/LASER. + * + * Adds support for commands: + * S000 : Report State and Position while moving. + * P000 : Instant Pause / Hold while moving. + * R000 : Resume from Pause / Hold. + * + * - During Hold all Emergency Parser commands are available, as usual. + * - Enable NANODLP_Z_SYNC and NANODLP_ALL_AXIS for move command end-state reports. */ //#define REALTIME_REPORTING_COMMANDS #if ENABLED(REALTIME_REPORTING_COMMANDS) @@ -3778,14 +3789,13 @@ /** * NanoDLP Sync support * - * Add support for Synchronized Z moves when using with NanoDLP. G0/G1 axis moves will output "Z_move_comp" - * string to enable synchronization with DLP projector exposure. This change will allow to use - * [[WaitForDoneMessage]] instead of populating your gcode with M400 commands + * Support for Synchronized Z moves when used with NanoDLP. G0/G1 axis moves will + * output a "Z_move_comp" string to enable synchronization with DLP projector exposure. + * This feature allows you to use [[WaitForDoneMessage]] instead of M400 commands. */ //#define NANODLP_Z_SYNC #if ENABLED(NANODLP_Z_SYNC) - //#define NANODLP_ALL_AXIS // Enables "Z_move_comp" output on any axis move. - // Default behavior is limited to Z axis only. + //#define NANODLP_ALL_AXIS // Send a "Z_move_comp" report for any axis move (not just Z). #endif /** From 09de17fb599051a2037aa70ca18098a901351360 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 19 Apr 2021 13:30:21 -0500 Subject: [PATCH 250/311] Trigorilla Pro: Allow for swapped Z-stops --- Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h index dc603cda54..5eefedb141 100644 --- a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h @@ -40,6 +40,8 @@ #define DISABLE_JTAG +//#define SWAPPED_Z_PLUGS + // // EEPROM // @@ -59,10 +61,18 @@ #define X_STOP_PIN PG10 #define Y_STOP_PIN PA12 #ifndef Z_MIN_PIN - #define Z_MIN_PIN PA14 + #ifdef SWAPPED_Z_PLUGS + #define Z_MIN_PIN PA14 + #else + #define Z_MIN_PIN PA13 + #endif #endif #ifndef Z_MAX_PIN - #define Z_MAX_PIN PA13 + #ifdef SWAPPED_Z_PLUGS + #define Z_MAX_PIN PA13 + #else + #define Z_MAX_PIN PA14 + #endif #endif // @@ -185,3 +195,5 @@ #define SDSS PD2 #define SD_DETECT_PIN -1 #endif + +#undef SWAPPED_Z_PLUGS From 7d7200474202925d61c3c06703fd7291fa20a53d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 20 Apr 2021 00:34:39 +0000 Subject: [PATCH 251/311] [cron] Bump distribution date (2021-04-20) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index b21c552e3c..37dfcaa25d 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-04-19" + #define STRING_DISTRIBUTION_DATE "2021-04-20" #endif /** From f52351d116550c22b0a761a94ca7476494064af7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Apr 2021 19:01:51 -0500 Subject: [PATCH 252/311] Update mftest help --- buildroot/bin/mftest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 906e2abf87..ea7472c5da 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -14,13 +14,13 @@ bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; } usage() { echo " -Usage: mftest [-t|--env=] [-n|--num=] [-m|--make] [-y|--build=] +Usage: mftest [-t|--env=] [-n|--num=] [-m|--make] [-y|--build=] mftest [-a|--autobuild] mftest [-r|--rebuild] mftest [-u|--autoupload] [-n|--num=] OPTIONS - -t --env The environment of the test to apply / run. (As named in platformio.ini.) + -t --env The environment to apply / run, or the menu index number. -n --num The index of the test to run. (In file order.) -m --make Use the make / Docker method for the build. -y --build Skip 'Do you want to build this test?' and assume YES. From 6bb10b189897dcaef5a6da496dfd4f1631689f1b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 20 Apr 2021 00:44:19 -0500 Subject: [PATCH 253/311] Changes supporting "Prussia3D" MK3 (#21617) --- Marlin/src/inc/Conditionals_post.h | 4 +++- Marlin/src/lcd/dogm/dogm_Statusscreen.h | 12 ++++++++---- Marlin/src/lcd/marlinui.cpp | 21 +++------------------ Marlin/src/module/settings.cpp | 19 +++++++------------ Marlin/src/pins/rambo/pins_EINSY_RAMBO.h | 19 ++++++++++++++++--- 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index f00dd6ec97..7fabef7e63 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2539,7 +2539,9 @@ #endif #if HAS_TEMPERATURE && EITHER(HAS_LCD_MENU, DWIN_CREALITY_LCD) - #ifdef PREHEAT_5_LABEL + #ifdef PREHEAT_6_LABEL + #define PREHEAT_COUNT 6 + #elif defined(PREHEAT_5_LABEL) #define PREHEAT_COUNT 5 #elif defined(PREHEAT_4_LABEL) #define PREHEAT_COUNT 4 diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index 6d2c5369dc..61d22a28ec 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -281,7 +281,9 @@ #define STATUS_HOTEND8_WIDTH STATUS_HOTEND7_WIDTH #endif - constexpr uint8_t status_hotend_width[HOTENDS] = ARRAY_N(HOTENDS, STATUS_HOTEND1_WIDTH, STATUS_HOTEND2_WIDTH, STATUS_HOTEND3_WIDTH, STATUS_HOTEND4_WIDTH, STATUS_HOTEND5_WIDTH, STATUS_HOTEND6_WIDTH, STATUS_HOTEND7_WIDTH, STATUS_HOTEND8_WIDTH); + #define _SHNAME(N,T) STATUS_HOTEND##N##_##T, + + constexpr uint8_t status_hotend_width[HOTENDS] = { REPEAT2_S(1, INCREMENT(HOTENDS), _SHNAME, WIDTH) }; #define STATUS_HOTEND_WIDTH(N) status_hotend_width[N] #ifndef STATUS_HOTEND1_BYTEWIDTH @@ -309,7 +311,7 @@ #define STATUS_HOTEND8_BYTEWIDTH BW(STATUS_HOTEND8_WIDTH) #endif - constexpr uint8_t status_hotend_bytewidth[HOTENDS] = ARRAY_N(HOTENDS, STATUS_HOTEND1_BYTEWIDTH, STATUS_HOTEND2_BYTEWIDTH, STATUS_HOTEND3_BYTEWIDTH, STATUS_HOTEND4_BYTEWIDTH, STATUS_HOTEND5_BYTEWIDTH, STATUS_HOTEND6_BYTEWIDTH, STATUS_HOTEND7_BYTEWIDTH, STATUS_HOTEND8_BYTEWIDTH); + constexpr uint8_t status_hotend_bytewidth[HOTENDS] = { REPEAT2_S(1, INCREMENT(HOTENDS), _SHNAME, BYTEWIDTH) }; #define STATUS_HOTEND_BYTEWIDTH(N) status_hotend_bytewidth[N] #ifndef STATUS_HOTEND1_X @@ -339,7 +341,7 @@ #define STATUS_HOTEND8_X STATUS_HOTEND7_X + STATUS_HEATERS_XSPACE #endif - constexpr uint8_t status_hotend_x[HOTENDS] = ARRAY_N(HOTENDS, STATUS_HOTEND1_X, STATUS_HOTEND2_X, STATUS_HOTEND3_X, STATUS_HOTEND4_X, STATUS_HOTEND5_X, STATUS_HOTEND6_X, STATUS_HOTEND7_X, STATUS_HOTEND8_X); + constexpr uint8_t status_hotend_x[HOTENDS] = { REPEAT2_S(1, INCREMENT(HOTENDS), _SHNAME, X) }; #define STATUS_HOTEND_X(N) status_hotend_x[N] #elif HAS_MULTI_HOTEND #define STATUS_HOTEND_X(N) ((N) ? STATUS_HOTEND2_X : STATUS_HOTEND1_X) @@ -370,13 +372,15 @@ #ifndef STATUS_HOTEND8_TEXT_X #define STATUS_HOTEND8_TEXT_X STATUS_HOTEND7_TEXT_X + STATUS_HEATERS_XSPACE #endif - constexpr uint8_t status_hotend_text_x[] = ARRAY_N(HOTENDS, STATUS_HOTEND1_TEXT_X, STATUS_HOTEND2_TEXT_X, STATUS_HOTEND3_TEXT_X, STATUS_HOTEND4_TEXT_X, STATUS_HOTEND5_TEXT_X, STATUS_HOTEND6_TEXT_X, STATUS_HOTEND7_TEXT_X, STATUS_HOTEND8_TEXT_X); + constexpr uint8_t status_hotend_text_x[HOTENDS] = { REPEAT2_S(1, INCREMENT(HOTENDS), _SHNAME, TEXT_X) }; #define STATUS_HOTEND_TEXT_X(N) status_hotend_text_x[N] #else #define STATUS_HOTEND_TEXT_X(N) (STATUS_HOTEND1_X + 6 + (N) * (STATUS_HEATERS_XSPACE)) #endif #endif + #undef _SHNAME + #if STATUS_HOTEND_BITMAPS > 1 && DISABLED(STATUS_HOTEND_NUMBERLESS) #define TEST_BITMAP_OFF status_hotend1_a_bmp #define TEST_BITMAP_ON status_hotend1_b_bmp diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 149da8b54e..812dac53b7 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -112,25 +112,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if PREHEAT_COUNT preheat_t MarlinUI::material_preset[PREHEAT_COUNT]; // Initialized by settings.load() PGM_P MarlinUI::get_preheat_label(const uint8_t m) { - #ifdef PREHEAT_1_LABEL - static PGMSTR(preheat_0_label, PREHEAT_1_LABEL); - #endif - #ifdef PREHEAT_2_LABEL - static PGMSTR(preheat_1_label, PREHEAT_2_LABEL); - #endif - #ifdef PREHEAT_3_LABEL - static PGMSTR(preheat_2_label, PREHEAT_3_LABEL); - #endif - #ifdef PREHEAT_4_LABEL - static PGMSTR(preheat_3_label, PREHEAT_4_LABEL); - #endif - #ifdef PREHEAT_5_LABEL - static PGMSTR(preheat_4_label, PREHEAT_5_LABEL); - #endif - + #define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL); #define _PLBL(N) preheat_##N##_label, - static PGM_P const preheat_labels[PREHEAT_COUNT] PROGMEM = { REPEAT(PREHEAT_COUNT, _PLBL) }; - + REPEAT_S(1, INCREMENT(PREHEAT_COUNT), _PDEF); + static PGM_P const preheat_labels[PREHEAT_COUNT] PROGMEM = { REPEAT_S(1, INCREMENT(PREHEAT_COUNT), _PLBL) }; return (PGM_P)pgm_read_ptr(&preheat_labels[m]); } #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 915886fe4a..4273c4b062 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -2780,25 +2780,20 @@ void MarlinSettings::reset() { // Preheat parameters // #if PREHEAT_COUNT + #define _PITEM(N,T) PREHEAT_##N##_##T, #if HAS_HOTEND - constexpr uint16_t hpre[] = ARRAY_N(PREHEAT_COUNT, PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND, PREHEAT_3_TEMP_HOTEND, PREHEAT_4_TEMP_HOTEND, PREHEAT_5_TEMP_HOTEND); + constexpr uint16_t hpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_HOTEND) }; #endif #if HAS_HEATED_BED - constexpr uint16_t bpre[] = ARRAY_N(PREHEAT_COUNT, PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED, PREHEAT_3_TEMP_BED, PREHEAT_4_TEMP_BED, PREHEAT_5_TEMP_BED); + constexpr uint16_t bpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_BED) }; #endif #if HAS_FAN - constexpr uint8_t fpre[] = ARRAY_N(PREHEAT_COUNT, PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED, PREHEAT_3_FAN_SPEED, PREHEAT_4_FAN_SPEED, PREHEAT_5_FAN_SPEED); + constexpr uint8_t fpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, FAN_SPEED) }; #endif LOOP_L_N(i, PREHEAT_COUNT) { - #if HAS_HOTEND - ui.material_preset[i].hotend_temp = hpre[i]; - #endif - #if HAS_HEATED_BED - ui.material_preset[i].bed_temp = bpre[i]; - #endif - #if HAS_FAN - ui.material_preset[i].fan_speed = fpre[i]; - #endif + TERN_(HAS_HOTEND, ui.material_preset[i].hotend_temp = hpre[i]); + TERN_(HAS_HEATED_BED, ui.material_preset[i].bed_temp = bpre[i]); + TERN_(HAS_FAN, ui.material_preset[i].fan_speed = fpre[i]); } #endif diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index 7b05d454af..fb7743605f 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -27,7 +27,10 @@ #include "env_validate.h" -#define BOARD_INFO_NAME "Einsy Rambo" +#define BOARD_INFO_NAME "Einsy Rambo" +#define DEFAULT_MACHINE_NAME "Prusa MK3" + +//#define MK3_FAN_PINS // // TMC2130 Configuration_adv defaults for EinsyRambo @@ -123,11 +126,19 @@ #define HEATER_BED_PIN 4 #ifndef FAN_PIN - #define FAN_PIN 8 + #ifdef MK3_FAN_PINS + #define FAN_PIN 6 + #else + #define FAN_PIN 8 + #endif #endif #ifndef FAN1_PIN - #define FAN1_PIN 6 + #ifdef MK3_FAN_PINS + #define FAN_PIN -1 + #else + #define FAN_PIN 6 + #endif #endif // @@ -192,3 +203,5 @@ #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #endif // HAS_WIRED_LCD + +#undef MK3_FAN_PINS From d87a71bd044a186deebdeeed57ac916e56c8ac86 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 20 Apr 2021 05:11:43 -0500 Subject: [PATCH 254/311] Extra dependency script logging --- .../PlatformIO/scripts/common-dependencies.py | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index fe6ae7dba5..01ee89e25e 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -40,9 +40,9 @@ try: except: verbose = 0 -def blab(str): - if verbose: - print(str) +def blab(str,level=1): + if verbose >= level: + print("[deps] %s" % str) FEATURE_CONFIG = {} @@ -65,13 +65,16 @@ def add_to_feat_cnf(feature, flines): name = parts.pop(0) if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']: feat[name] = '='.join(parts) + blab("[%s] %s=%s" % (feature, name, feat[name]), 3) else: - for dep in line.split(','): + for dep in re.split(r",\s*", line): lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) lib_re = re.compile('(?!^' + lib_name + '\\b)') feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] + blab("[%s] lib_deps = %s" % (feature, dep), 3) def load_config(): + blab("========== Gather [features] entries...") items = ProjectConfig().items('features') for key in items: feature = key[0].upper() @@ -80,16 +83,20 @@ def load_config(): add_to_feat_cnf(feature, key[1]) # Add options matching custom_marlin.MY_OPTION to the pile + blab("========== Gather custom_marlin entries...") all_opts = env.GetProjectOptions() for n in all_opts: - mat = re.match(r'custom_marlin\.(.+)', n[0]) + key = n[0] + mat = re.match(r'custom_marlin\.(.+)', key) if mat: try: - val = env.GetProjectOption(n[0]) + val = env.GetProjectOption(key) except: val = None if val: - add_to_feat_cnf(mat.group(1).upper(), val) + opt = mat.group(1).upper() + blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val )) + add_to_feat_cnf(opt, val) def get_all_known_libs(): known_libs = [] @@ -124,6 +131,7 @@ def force_ignore_unused_libs(): def apply_features_config(): load_config() + blab("========== Apply enabled features...") for feature in FEATURE_CONFIG: if not env.MarlinFeatureIsEnabled(feature): continue @@ -131,12 +139,13 @@ def apply_features_config(): feat = FEATURE_CONFIG[feature] if 'lib_deps' in feat and len(feat['lib_deps']): - blab("Adding lib_deps for %s... " % feature) + blab("========== Adding lib_deps for %s... " % feature, 2) # feat to add deps_to_add = {} for dep in feat['lib_deps']: deps_to_add[PackageSpec(dep).name] = dep + blab("==================== %s... " % dep, 2) # Does the env already have the dependency? deps = env.GetProjectOption('lib_deps') @@ -159,16 +168,16 @@ def apply_features_config(): if 'build_flags' in feat: f = feat['build_flags'] - blab("Adding build_flags for %s: %s" % (feature, f)) + blab("========== Adding build_flags for %s: %s" % (feature, f), 2) new_flags = env.GetProjectOption('build_flags') + [ f ] env.Replace(BUILD_FLAGS=new_flags) if 'extra_scripts' in feat: - blab("Running extra_scripts for %s... " % feature) + blab("Running extra_scripts for %s... " % feature, 2) env.SConscript(feat['extra_scripts'], exports="env") if 'src_filter' in feat: - blab("Adding src_filter for %s... " % feature) + blab("========== Adding src_filter for %s... " % feature, 2) src_filter = ' '.join(env.GetProjectOption('src_filter')) # first we need to remove the references to the same folder my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) @@ -182,7 +191,7 @@ def apply_features_config(): env.Replace(SRC_FILTER=src_filter) if 'lib_ignore' in feat: - blab("Adding lib_ignore for %s... " % feature) + blab("========== Adding lib_ignore for %s... " % feature, 2) lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] set_env_field('lib_ignore', lib_ignore) @@ -200,7 +209,6 @@ def search_compiler(): pass if os.path.exists(GCC_PATH_CACHE): - blab("Getting g++ path from cache") with open(GCC_PATH_CACHE, 'r') as f: return f.read() @@ -227,7 +235,6 @@ def search_compiler(): filepath = os.path.sep.join([pathdir, filepath]) # Cache the g++ path to no search always if os.path.exists(ENV_BUILD_PATH): - blab("Caching g++ for current env") with open(GCC_PATH_CACHE, 'w+') as f: f.write(filepath) @@ -262,7 +269,7 @@ def load_marlin_features(): cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] cmd = ' '.join(cmd) - blab(cmd) + blab(cmd, 4) define_list = subprocess.check_output(cmd, shell=True).splitlines() marlin_features = {} for define in define_list: From 2a7ba427dd840297c9cc253e3ffef6d3ae5ec0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Sep=C3=BAlveda?= Date: Tue, 20 Apr 2021 06:14:21 -0400 Subject: [PATCH 255/311] Fix Grand Central SD dependency (#21660) Co-authored-by: Scott Lahteine --- ini/samd51.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ini/samd51.ini b/ini/samd51.ini index 8e8682da94..34fcc84371 100644 --- a/ini/samd51.ini +++ b/ini/samd51.ini @@ -20,8 +20,7 @@ build_unflags = -std=gnu++11 src_filter = ${common.default_src_filter} + lib_deps = ${common.lib_deps} SoftwareSerialM - Adafruit SPIFlash extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py -custom_marlin.SDSUPPORT = SdFat - Adafruit Fork +custom_marlin.SDSUPPORT = SdFat - Adafruit Fork, Adafruit SPIFlash debug_tool = jlink From 3c46a4062eb9da5a58d46b7ee59afe0b2409e472 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 20 Apr 2021 16:36:19 -0500 Subject: [PATCH 256/311] Fix mfconfig 'copying' message --- buildroot/share/git/mfconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index fe99d6b247..592ecfa603 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -90,7 +90,7 @@ if [[ $ACTION == "init" ]]; then git checkout init-repo -b BASE || exit # Copy all config files into place - echo "- Copying configs from Marlin..." + echo "- Copying all configs from fresh $IMPORT..." cp -R "$TEMP/config" . # Delete anything that's not a Configuration file From 778b8a45e9ca770c7d717bf403a52b51dc123098 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 21 Apr 2021 00:34:13 +0000 Subject: [PATCH 257/311] [cron] Bump distribution date (2021-04-21) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 37dfcaa25d..ade8e2f392 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-04-20" + #define STRING_DISTRIBUTION_DATE "2021-04-21" #endif /** From 57d0f0ce2e8103a6c518741a44f58afd08ec4da9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 20 Apr 2021 19:16:27 -0500 Subject: [PATCH 258/311] Fix Chiron typos, file nav --- Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp | 4 ++-- Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h | 1 + Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp index 9975d0824f..01a871a542 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.cpp @@ -75,7 +75,7 @@ void FileNavigator::reset() { currentfolderdepth = 0; currentindex = 0; lastpanelindex = 0; - ZERO(currentfolderindex) + ZERO(currentfolderindex); // Start at root folder while (!filelist.isAtRootDir()) filelist.upDir(); @@ -108,7 +108,7 @@ void FileNavigator::upDIR() { if (currentfolderdepth == 0) currentfoldername[0] = '\0'; else { - const char *pos = strchr(currentfoldername, '/'); + char * const pos = strchr(currentfoldername, '/'); *(pos + 1) = '\0'; } } diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h index 253b8039e7..0d55eb47b7 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/FileNavigator.h @@ -38,6 +38,7 @@ namespace Anycubic { class FileNavigator { public: + FileNavigator(); static void reset(); static void getFiles(uint16_t, panel_type_t, uint8_t filesneeded=4); static void upDIR(); diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index b35d792736..b6b0eb9eb5 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -466,7 +466,7 @@ void ChironTFT::SelectFile() { void ChironTFT::ProcessPanelRequest() { // Break these up into logical blocks // as its easier to navigate than one huge switch case! - const int8_t tpos = FindToken('A'); + int8_t tpos = FindToken('A'); // Panel request are 'A0' - 'A36' if (tpos != -1) { const int8_t req = atoi(&panel_command[tpos+1]); From 4d34d16bd83f9961f062f662e528d5bebd5aab7d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 22 Apr 2021 00:41:44 +0000 Subject: [PATCH 259/311] [cron] Bump distribution date (2021-04-22) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index ade8e2f392..f9616d52e0 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-04-21" + #define STRING_DISTRIBUTION_DATE "2021-04-22" #endif /** From f075dd0db3496d99c84fcf77242f60731982184c Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Thu, 22 Apr 2021 18:19:41 -0500 Subject: [PATCH 260/311] M10-M11 Air Evacuation for Spindle/Laser (#21668) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 6 +++ Marlin/src/feature/spindle_laser.cpp | 14 +++++++ Marlin/src/feature/spindle_laser.h | 9 +++++ Marlin/src/gcode/control/M10-M11.cpp | 47 ++++++++++++++++++++++ Marlin/src/gcode/gcode.cpp | 4 ++ Marlin/src/gcode/gcode.h | 6 +++ Marlin/src/lcd/language/language_en.h | 2 + Marlin/src/lcd/menu/menu_spindle_laser.cpp | 5 +++ ini/features.ini | 1 + platformio.ini | 1 + 10 files changed, 95 insertions(+) create mode 100644 Marlin/src/gcode/control/M10-M11.cpp diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e1124edf50..ac9b49fe4d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3160,6 +3160,12 @@ #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC) + //#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11 + #if ENABLED(AIR_EVACUATION) + #define AIR_EVACUATION_ACTIVE LOW // Set to "HIGH" if the on/off function is active HIGH + #define AIR_EVACUATION_PIN 42 // Override the default Cutter Vacuum or Laser Blower pin + #endif + //#define SPINDLE_SERVO // A servo converting an angle to spindle power #ifdef SPINDLE_SERVO #define SPINDLE_SERVO_NR 0 // Index of servo used for spindle control diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 66c04a001c..78fa75cac6 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -68,6 +68,9 @@ void SpindleLaser::init() { set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY); #endif + #if ENABLED(AIR_EVACUATION) + OUT_WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); // Init Vacuum/Blower OFF + #endif } #if ENABLED(SPINDLE_LASER_PWM) @@ -135,4 +138,15 @@ void SpindleLaser::apply_power(const uint8_t opwr) { } #endif +#if ENABLED(AIR_EVACUATION) + + // Enable / disable Cutter Vacuum or Laser Blower motor + void SpindleLaser::air_evac_enable() { WRITE(AIR_EVACUATION_PIN, AIR_EVACUATION_ACTIVE); } // Turn ON + + void SpindleLaser::air_evac_disable() { WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); } // Turn OFF + + void SpindleLaser::air_evac_toggle() { TOGGLE(AIR_EVACUATION_PIN); } // Toggle state + +#endif + #endif // HAS_CUTTER diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 88cf372a02..c3454d0b3c 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -212,6 +212,15 @@ public: static bool is_reverse() { return false; } #endif + #if ENABLED(AIR_EVACUATION) + static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor + static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor + static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor + static inline bool air_evac_state() { // Get current state + return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE); + } + #endif + static inline void disable() { isReady = false; set_enabled(false); } #if HAS_LCD_MENU diff --git a/Marlin/src/gcode/control/M10-M11.cpp b/Marlin/src/gcode/control/M10-M11.cpp new file mode 100644 index 0000000000..26f67e6cb6 --- /dev/null +++ b/Marlin/src/gcode/control/M10-M11.cpp @@ -0,0 +1,47 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(AIR_EVACUATION) + +#include "../gcode.h" +#include "../../module/planner.h" +#include "../../feature/spindle_laser.h" + +/** + * M10: Vacuum or Blower On + */ +void GcodeSuite::M10() { + planner.synchronize(); // Wait for move to arrive (TODO: asynchronous) + cutter.air_evac_enable(); // Turn on Vacuum or Blower motor +} + +/** + * M11: Vacuum or Blower OFF + */ +void GcodeSuite::M11() { + planner.synchronize(); // Wait for move to arrive (TODO: asynchronous) + cutter.air_evac_disable(); // Turn off Vacuum or Blower motor +} + +#endif // AIR_EVACUATION diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index efea087602..bf26fe5d89 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -432,6 +432,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 3: M3_M4(false); break; // M3: Turn ON Laser | Spindle (clockwise), set Power | Speed case 4: M3_M4(true ); break; // M4: Turn ON Laser | Spindle (counter-clockwise), set Power | Speed case 5: M5(); break; // M5: Turn OFF Laser | Spindle + #if ENABLED(AIR_EVACUATION) + case 10: M10(); break; // M10: Vacuum or Blower motor ON + case 11: M11(); break; // M11: Vacuum or Blower motor OFF + #endif #endif #if ENABLED(COOLANT_CONTROL) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 977fc8bfd8..2904d30366 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -86,6 +86,8 @@ * M7 - Turn mist coolant ON. (Requires COOLANT_CONTROL) * M8 - Turn flood coolant ON. (Requires COOLANT_CONTROL) * M9 - Turn coolant OFF. (Requires COOLANT_CONTROL) + * M10 - Turn Vacuum or Blower motor ON (Requires AIR_EVACUATION) + * M11 - Turn Vacuum or Blower motor OFF (Requires AIR_EVACUATION) * M12 - Set up closed loop control system. (Requires EXTERNAL_CLOSED_LOOP_CONTROLLER) * M16 - Expected printer check. (Requires EXPECTED_PRINTER_CHECK) * M17 - Enable/Power all stepper motors @@ -548,6 +550,10 @@ private: #if HAS_CUTTER static void M3_M4(const bool is_M4); static void M5(); + #if ENABLED(AIR_EVACUATION) + static void M10(); + static void M11(); + #endif #endif #if ENABLED(COOLANT_CONTROL) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 81450d7385..c911120766 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -114,10 +114,12 @@ namespace Language_en { PROGMEM Language_Str MSG_LASER_POWER = _UxGT("Laser Power"); PROGMEM Language_Str MSG_SPINDLE_POWER = _UxGT("Spindle Pwr"); PROGMEM Language_Str MSG_LASER_TOGGLE = _UxGT("Toggle Laser"); + PROGMEM Language_Str MSG_LASER_EVAC_TOGGLE = _UxGT("Toggle Blower"); PROGMEM Language_Str MSG_LASER_PULSE_MS = _UxGT("Test Pulse ms"); PROGMEM Language_Str MSG_LASER_FIRE_PULSE = _UxGT("Fire Pulse"); PROGMEM Language_Str MSG_FLOWMETER_FAULT = _UxGT("Coolant Flow Fault"); PROGMEM Language_Str MSG_SPINDLE_TOGGLE = _UxGT("Toggle Spindle"); + PROGMEM Language_Str MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Toggle Vacuum"); PROGMEM Language_Str MSG_SPINDLE_FORWARD = _UxGT("Spindle Forward"); PROGMEM Language_Str MSG_SPINDLE_REVERSE = _UxGT("Spindle Reverse"); PROGMEM Language_Str MSG_SWITCH_PS_ON = _UxGT("Switch Power On"); diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index 93ef224e6f..f0e702e2dd 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -51,6 +51,11 @@ editable.state = is_enabled; EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ if (editable.state) cutter.disable(); else cutter.enable_same_dir(); }); + #if ENABLED(AIR_EVACUATION) + bool evac_state = cutter.air_evac_state(); + EDIT_ITEM(bool, MSG_CUTTER(EVAC_TOGGLE), &evac_state, cutter.air_evac_toggle); + #endif + #if ENABLED(SPINDLE_CHANGE_DIR) if (!is_enabled) { editable.state = is_rev; diff --git a/ini/features.ini b/ini/features.ini index 864befa7a8..3121ef7241 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -164,6 +164,7 @@ SD_ABORT_ON_ENDSTOP_HIT = src_filter=+ BAUD_RATE_GCODE = src_filter=+ HAS_SMART_EFF_MOD = src_filter=+ COOLANT_CONTROL = src_filter=+ +AIR_EVACUATION = src_filter=+ HAS_SOFTWARE_ENDSTOPS = src_filter=+ HAS_DUPLICATION_MODE = src_filter=+ LIN_ADVANCE = src_filter=+ diff --git a/platformio.ini b/platformio.ini index 8a747404e3..75e7f6a58b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -155,6 +155,7 @@ default_src_filter = + - - + - - - + - - - - - From a58276c4c1a7dbcac815a65473d1d0f8f36d5978 Mon Sep 17 00:00:00 2001 From: BigTreeTech <38851044+bigtreetech@users.noreply.github.com> Date: Fri, 23 Apr 2021 07:43:28 +0800 Subject: [PATCH 261/311] Enable Purge More / Resume with EP + Host Prompt (#21671) Co-authored-by: Msq001 --- Marlin/src/feature/host_actions.cpp | 4 ++-- Marlin/src/feature/pause.cpp | 12 ++++++++---- Marlin/src/feature/pause.h | 2 +- Marlin/src/inc/Conditionals_post.h | 12 ++++++++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index 203fdaf531..62e60320f7 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -149,13 +149,13 @@ void host_action(PGM_P const pstr, const bool eol) { switch (response) { case 0: // "Purge More" button - #if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE) + #if BOTH(M600_PURGE_MORE_RESUMABLE, ADVANCED_PAUSE_FEATURE) pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // Simulate menu selection (menu exits, doesn't extrude more) #endif break; case 1: // "Continue" / "Disable Runout" button - #if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE) + #if BOTH(M600_PURGE_MORE_RESUMABLE, ADVANCED_PAUSE_FEATURE) pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // Simulate menu selection #endif #if HAS_FILAMENT_SENSOR diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 8a1701d0b6..192c7f6345 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -75,7 +75,7 @@ static xyze_pos_t resume_position; -#if HAS_LCD_MENU +#if M600_PURGE_MORE_RESUMABLE PauseMenuResponse pause_menu_response; PauseMode pause_mode = PAUSE_MODE_PAUSE_PRINT; #endif @@ -257,18 +257,22 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load TERN_(HOST_PROMPT_SUPPORT, filament_load_host_prompt()); // Initiate another host prompt. - #if HAS_LCD_MENU + #if M600_PURGE_MORE_RESUMABLE if (show_lcd) { // Show "Purge More" / "Resume" menu and wait for reply KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = false; - ui.pause_show_message(PAUSE_MESSAGE_OPTION); + #if HAS_LCD_MENU + ui.pause_show_message(PAUSE_MESSAGE_OPTION); // Also sets PAUSE_RESPONSE_WAIT_FOR + #else + pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; + #endif while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle_no_sleep(); } #endif // Keep looping if "Purge More" was selected - } while (TERN0(HAS_LCD_MENU, show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE)); + } while (TERN0(M600_PURGE_MORE_RESUMABLE, show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE)); #endif TERN_(HOST_PROMPT_SUPPORT, host_action_prompt_end()); diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index 2a7ea40b83..facd8d8dee 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -59,7 +59,7 @@ enum PauseMessage : char { PAUSE_MESSAGE_HEATING }; -#if HAS_LCD_MENU +#if M600_PURGE_MORE_RESUMABLE enum PauseMenuResponse : char { PAUSE_RESPONSE_WAIT_FOR, PAUSE_RESPONSE_EXTRUDE_MORE, diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 7fabef7e63..611c13e344 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2716,8 +2716,16 @@ #define HEATER_IDLE_HANDLER 1 #endif -#if ENABLED(ADVANCED_PAUSE_FEATURE) && !defined(FILAMENT_CHANGE_SLOW_LOAD_LENGTH) - #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0 +/** + * Advanced Pause - Filament Change + */ +#if ENABLED(ADVANCED_PAUSE_FEATURE) + #if HAS_LCD_MENU || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) + #define M600_PURGE_MORE_RESUMABLE 1 + #endif + #ifndef FILAMENT_CHANGE_SLOW_LOAD_LENGTH + #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH 0 + #endif #endif #if HAS_MULTI_EXTRUDER && !defined(TOOLCHANGE_FS_EXTRA_PRIME) From a729cdcfdd558d91d977edf70a43d2008586693c Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 23 Apr 2021 00:34:45 +0000 Subject: [PATCH 262/311] [cron] Bump distribution date (2021-04-23) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index f9616d52e0..fb95c4e032 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-04-22" + #define STRING_DISTRIBUTION_DATE "2021-04-23" #endif /** From 4e10f4689994201a2d27c54f59366096c92d4797 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Apr 2021 19:09:35 -0500 Subject: [PATCH 263/311] Use configured temp window for Chiron --- Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index b6b0eb9eb5..08160d52fb 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -406,7 +406,7 @@ void ChironTFT::CheckHeaters() { // Update panel with hotend heater status if (hotend_state != AC_heater_temp_reached) { - if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -1, 1)) { + if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -(TEMP_WINDOW), TEMP_WINDOW)) { SendtoTFTLN(AC_msg_nozzle_heating_done); hotend_state = AC_heater_temp_reached; } @@ -414,7 +414,7 @@ void ChironTFT::CheckHeaters() { // Update panel with bed heater status if (hotbed_state != AC_heater_temp_reached) { - if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -0.5, 0.5)) { + if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -(TEMP_BED_WINDOW), TEMP_BED_WINDOW)) { SendtoTFTLN(AC_msg_bed_heating_done); hotbed_state = AC_heater_temp_reached; } From 51a61c5431aa9153eb7c580214ec0f310b2abb8e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Apr 2021 19:14:58 -0500 Subject: [PATCH 264/311] Nextion cleanup --- .../src/lcd/extui/lib/nextion/nextion_tft.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp index 23857c65c3..3cd99b3163 100644 --- a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp @@ -46,13 +46,7 @@ char NextionTFT::selectedfile[MAX_PATH_LEN]; char NextionTFT::nextion_command[MAX_CMND_LEN]; uint8_t NextionTFT::command_len; -bool last_homed = 0, last_homedX = 0, last_homedY = 0, last_homedZ = 0; -float last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999, last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999; -float last_get_axis_position_mmX = 999, last_get_axis_position_mmY = 999, last_get_axis_position_mmZ = 999; -float last_extruder_advance_K = 999; -uint8_t last_active_extruder = 99, last_fan_speed = 99, last_print_speed = 99, last_flow_speed = 99, last_progress = 99; -uint8_t last_printer_state = 99, last_IDEX_Mode = 99; -uint32_t layer = 0, last_layer = 99; +uint32_t layer = 0; NextionTFT nextion; @@ -601,6 +595,9 @@ void NextionTFT::PanelAction(uint8_t req) { void NextionTFT::UpdateOnChange() { const millis_t ms = millis(); static millis_t next_event_ms = 0; + static float last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999, + last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999; + // tmppage Temperature if (!WITHIN(last_degHotend0 - getActualTemp_celsius(E0), -0.2, 0.2) || !WITHIN(last_degTargetHotend0 - getTargetTemp_celsius(E0), -0.5, 0.5)) { SEND_TEMP("tmppage.t0", ui8tostr3rj(getActualTemp_celsius(E0)), " / ", ui8tostr3rj(getTargetTemp_celsius(E0))); @@ -621,24 +618,28 @@ void NextionTFT::UpdateOnChange() { } // tmppage Tool + static uint8_t last_active_extruder = 99; if (last_active_extruder != getActiveTool()) { SEND_VALasTXT("tmppage.tool", getActiveTool()); last_active_extruder = getActiveTool(); } // tmppage Fan Speed + static uint8_t last_fan_speed = 99; if (last_fan_speed != getActualFan_percent(FAN0)) { SEND_VALasTXT("tmppage.fan", ui8tostr3rj(getActualFan_percent(FAN0))); last_fan_speed = getActualFan_percent(FAN0); } // tmppage Print Speed + static uint8_t last_print_speed = 99; if (last_print_speed != getFeedrate_percent()) { SEND_VALasTXT("tmppage.speed", ui8tostr3rj(getFeedrate_percent())); last_print_speed = getFeedrate_percent(); } // tmppage Flow + static uint8_t last_flow_speed = 99; if (last_flow_speed != getFlowPercentage(getActiveTool())) { SEND_VALasTXT("tmppage.flow", getFlowPercentage(getActiveTool())); last_flow_speed = getFlowPercentage(getActiveTool()); @@ -661,6 +662,7 @@ void NextionTFT::UpdateOnChange() { SEND_VALasTXT("tmppage.elapsed", elapsed_str); } + static uint8_t last_progress = 99; if (last_progress != getProgress_percent()) { SEND_VALasTXT("tmppage.progress", ui8tostr3rj(getProgress_percent())); last_progress = getProgress_percent(); @@ -678,6 +680,8 @@ void NextionTFT::UpdateOnChange() { } // tmppage Axis + static float last_get_axis_position_mmX = 999, last_get_axis_position_mmY = 999, last_get_axis_position_mmZ = 999; + if (!WITHIN(last_get_axis_position_mmX - getAxisPosition_mm(X), -0.1, 0.1)) { if (ELAPSED(ms, next_event_ms)) { next_event_ms = ms + 30; @@ -700,6 +704,8 @@ void NextionTFT::UpdateOnChange() { } // tmppage homed + static bool last_homed = false, last_homedX = false, last_homedY = false, last_homedZ = false; + if (last_homed != isPositionKnown()) { SEND_VAL("tmppage.homed", isPositionKnown()); last_homed = isPositionKnown(); @@ -718,6 +724,7 @@ void NextionTFT::UpdateOnChange() { } // tmppage IDEX Mode + static uint8_t last_IDEX_Mode = 99; #if ENABLED(DUAL_X_CARRIAGE) if (last_IDEX_Mode != getIDEX_Mode()) { SEND_VAL("tmppage.idexmode", getIDEX_Mode()); From 72e3d2492f2085efe9c5fb0b33d67c24baf8a4bc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Apr 2021 19:14:49 -0500 Subject: [PATCH 265/311] Update temperature types --- Marlin/src/core/types.h | 20 ++++---- Marlin/src/feature/probe_temp_comp.cpp | 6 +-- Marlin/src/feature/probe_temp_comp.h | 4 +- Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 12 ++--- Marlin/src/gcode/temp/M303.cpp | 4 +- .../extui/lib/anycubic_chiron/chiron_tft.cpp | 3 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 18 ++++--- .../screens/string_format.cpp | 8 +-- .../ftdi_eve_touch_ui/screens/string_format.h | 8 +-- .../src/lcd/extui/lib/nextion/nextion_tft.cpp | 4 +- Marlin/src/lcd/extui/ui_api.cpp | 8 +-- Marlin/src/lcd/extui/ui_api.h | 8 +-- Marlin/src/module/probe.cpp | 8 +-- Marlin/src/module/probe.h | 2 +- Marlin/src/module/temperature.cpp | 49 +++++++++++-------- Marlin/src/module/temperature.h | 2 +- 16 files changed, 88 insertions(+), 76 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 687ec867d1..79a79b739b 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -77,6 +77,7 @@ typedef float feedRate_t; // For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100 // typedef int16_t celsius_t; +typedef float celsius_float_t; // // On AVR pointers are only 2 bytes so use 'const float &' for 'const float' @@ -87,17 +88,18 @@ typedef int16_t celsius_t; typedef const float const_float_t; #endif typedef const_float_t const_feedRate_t; +typedef const_float_t const_celsius_float_t; // Conversion macros -#define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f) -#define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f) +#define MMM_TO_MMS(MM_M) feedRate_t(static_cast(MM_M) / 60.0f) +#define MMS_TO_MMM(MM_S) (static_cast(MM_S) * 60.0f) // // Coordinates structures for XY, XYZ, XYZE... // // Helpers -#define _RECIP(N) ((N) ? 1.0f / float(N) : 0.0f) +#define _RECIP(N) ((N) ? 1.0f / static_cast(N) : 0.0f) #define _ABS(N) ((N) < 0 ? -(N) : (N)) #define _LS(N) (N = (T)(uint32_t(N) << v)) #define _RS(N) (N = (T)(uint32_t(N) >> v)) @@ -214,8 +216,8 @@ struct XYval { FI XYval asLong() const { return { int32_t(x), int32_t(y) }; } FI XYval ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)) }; } FI XYval ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)) }; } - FI XYval asFloat() { return { float(x), float(y) }; } - FI XYval asFloat() const { return { float(x), float(y) }; } + FI XYval asFloat() { return { static_cast(x), static_cast(y) }; } + FI XYval asFloat() const { return { static_cast(x), static_cast(y) }; } FI XYval reciprocal() const { return { _RECIP(x), _RECIP(y) }; } FI XYval asLogical() const { XYval o = asFloat(); toLogical(o); return o; } FI XYval asNative() const { XYval o = asFloat(); toNative(o); return o; } @@ -325,8 +327,8 @@ struct XYZval { FI XYZval asLong() const { return { int32_t(x), int32_t(y), int32_t(z) }; } FI XYZval ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; } FI XYZval ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; } - FI XYZval asFloat() { return { float(x), float(y), float(z) }; } - FI XYZval asFloat() const { return { float(x), float(y), float(z) }; } + FI XYZval asFloat() { return { static_cast(x), static_cast(y), static_cast(z) }; } + FI XYZval asFloat() const { return { static_cast(x), static_cast(y), static_cast(z) }; } FI XYZval reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z) }; } FI XYZval asLogical() const { XYZval o = asFloat(); toLogical(o); return o; } FI XYZval asNative() const { XYZval o = asFloat(); toNative(o); return o; } @@ -436,8 +438,8 @@ struct XYZEval { FI XYZEval asLong() const { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; } FI XYZEval ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; } FI XYZEval ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; } - FI XYZEval asFloat() { return { float(x), float(y), float(z), float(e) }; } - FI XYZEval asFloat() const { return { float(x), float(y), float(z), float(e) }; } + FI XYZEval asFloat() { return { static_cast(x), static_cast(y), static_cast(z), static_cast(e) }; } + FI XYZEval asFloat() const { return { static_cast(x), static_cast(y), static_cast(z), static_cast(e) }; } FI XYZEval reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(e) }; } FI XYZEval asLogical() const { XYZEval o = asFloat(); toLogical(o); return o; } FI XYZEval asNative() const { XYZEval o = asFloat(); toNative(o); return o; } diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index b0867817b6..68e669224c 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -52,7 +52,7 @@ const temp_calib_t ProbeTempComp::cali_info[TSI_COUNT] = { constexpr xyz_pos_t ProbeTempComp::park_point; constexpr xy_pos_t ProbeTempComp::measure_point; -constexpr int ProbeTempComp::probe_calib_bed_temp; +constexpr celsius_t ProbeTempComp::probe_calib_bed_temp; uint8_t ProbeTempComp::calib_idx; // = 0 float ProbeTempComp::init_measurement; // = 0.0 @@ -126,7 +126,7 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { SERIAL_ECHOPGM("Applying linear extrapolation"); calib_idx--; for (; calib_idx < measurements; ++calib_idx) { - const float temp = start_temp + float(calib_idx) * res_temp; + const celsius_float_t temp = start_temp + float(calib_idx) * res_temp; data[calib_idx] = static_cast(k * temp + d); } } @@ -174,7 +174,7 @@ float ProbeTempComp::get_offset_for_temperature(const TempSensorID tsi, const_fl return xy_float_t({start_temp + i*res_temp, static_cast(data[i])}); }; - auto linear_interp = [](float x, xy_float_t p1, xy_float_t p2) { + auto linear_interp = [](const_float_t x, xy_float_t p1, xy_float_t p2) { return (p2.y - p1.y) / (p2.x - p2.y) * (x - p1.x) + p1.y; }; diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index e29da7ece1..5fb637a17e 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -100,8 +100,8 @@ class ProbeTempComp { static constexpr xy_pos_t measure_point = PTC_PROBE_POS; // Coordinates to probe //measure_point = { 12.0f, 7.3f }; // Coordinates for the MK52 magnetic heatbed - static constexpr int probe_calib_bed_temp = BED_MAX_TARGET, // Bed temperature while calibrating probe - bed_calib_probe_temp = BTC_PROBE_TEMP; // Probe temperature while calibrating bed + static constexpr celsius_t probe_calib_bed_temp = BED_MAX_TARGET, // Bed temperature while calibrating probe + bed_calib_probe_temp = BTC_PROBE_TEMP; // Probe temperature while calibrating bed static int16_t *sensor_z_offsets[TSI_COUNT], z_offsets_probe[cali_info_init[TSI_PROBE].measurements], // (µm) diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index 8cfe6fee7b..9fc30b794d 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -110,7 +110,7 @@ void GcodeSuite::G76() { return false; }; - auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) { + auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) { do_z_clearance(5.0); // Raise nozzle before probing const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false if (isnan(measured_z)) @@ -170,14 +170,14 @@ void GcodeSuite::G76() { // Report temperatures every second and handle heating timeouts millis_t next_temp_report = millis() + 1000; - auto report_targets = [&](const uint16_t tb, const uint16_t tp) { + auto report_targets = [&](const celsius_t tb, const celsius_t tp) { SERIAL_ECHOLNPAIR("Target Bed:", tb, " Probe:", tp); }; if (do_bed_cal) { - uint16_t target_bed = cali_info_init[TSI_BED].start_temp, - target_probe = temp_comp.bed_calib_probe_temp; + celsius_t target_bed = cali_info_init[TSI_BED].start_temp, + target_probe = temp_comp.bed_calib_probe_temp; say_waiting_for(); SERIAL_ECHOLNPGM(" cooling."); while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe) @@ -236,10 +236,10 @@ void GcodeSuite::G76() { do_blocking_move_to(parkpos); // Initialize temperatures - const uint16_t target_bed = temp_comp.probe_calib_bed_temp; + const celsius_t target_bed = temp_comp.probe_calib_bed_temp; thermalManager.setTargetBed(target_bed); - uint16_t target_probe = cali_info_init[TSI_PROBE].start_temp; + celsius_t target_probe = cali_info_init[TSI_PROBE].start_temp; report_targets(target_bed, target_probe); diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index 0934e04e75..e49381cdf6 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -57,7 +57,7 @@ void GcodeSuite::M303() { #endif const heater_id_t hid = (heater_id_t)parser.intval('E'); - int16_t default_temp; + celsius_t default_temp; switch (hid) { #if ENABLED(PIDTEMP) case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break; @@ -74,7 +74,7 @@ void GcodeSuite::M303() { return; } - const int16_t temp = parser.celsiusval('S', default_temp); + const celsius_t temp = parser.celsiusval('S', default_temp); const int c = parser.intval('C', 5); const bool u = parser.boolval('U'); diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index 08160d52fb..ee8f18cd8e 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -373,10 +373,9 @@ int8_t ChironTFT::FindToken(char c) { void ChironTFT::CheckHeaters() { uint8_t faultDuration = 0; - float temp = 0; // if the hotend temp is abnormal, confirm state before signalling panel - temp = getActualTemp_celsius(E0); + celsius_float_t temp = getActualTemp_celsius(E0); while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) { faultDuration++; if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { 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 ecc516108c..acd4d202b6 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 @@ -534,6 +534,8 @@ void AnycubicTFTClass::OnPrintTimerStopped() { #endif } +#define ROUND(val) int((val)+0.5f) + void AnycubicTFTClass::GetCommandFromTFT() { char *starpos = nullptr; while (LCD_SERIAL.available() > 0 && TFTbuflen < TFTBUFSIZE) { @@ -560,26 +562,26 @@ void AnycubicTFTClass::GetCommandFromTFT() { switch (a_command) { case 0: { // A0 GET HOTEND TEMP - const float hotendActualTemp = getActualTemp_celsius(E0); - SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5)); + const celsius_float_t hotendActualTemp = getActualTemp_celsius(E0); + SEND_PGM_VAL("A0V ", ROUND(hotendActualTemp)); } break; case 1: { // A1 GET HOTEND TARGET TEMP - const float hotendTargetTemp = getTargetTemp_celsius(E0); - SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5)); + const celsius_float_t hotendTargetTemp = getTargetTemp_celsius(E0); + SEND_PGM_VAL("A1V ", ROUND(hotendTargetTemp)); } break; case 2: { // A2 GET HOTBED TEMP - const float heatedBedActualTemp = getActualTemp_celsius(BED); - SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5)); + const celsius_float_t heatedBedActualTemp = getActualTemp_celsius(BED); + SEND_PGM_VAL("A2V ", ROUND(heatedBedActualTemp)); } break; case 3: { // A3 GET HOTBED TARGET TEMP - const float heatedBedTargetTemp = getTargetTemp_celsius(BED); - SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5)); + const celsius_float_t heatedBedTargetTemp = getTargetTemp_celsius(BED); + SEND_PGM_VAL("A3V ", ROUND(heatedBedTargetTemp)); } break; case 4: { // A4 GET FAN SPEED diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp index c3114a3922..ac423c2d07 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.cpp @@ -33,28 +33,28 @@ /** * Formats a temperature string (e.g. "100°C") */ -void format_temp(char *str, float t1) { +void format_temp(char *str, const_celsius_float_t t1) { sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C)); } /** * Formats a temperature string for an idle heater (e.g. "100 °C / idle") */ -void format_temp_and_idle(char *str, float t1) { +void format_temp_and_idle(char *str, const_celsius_float_t t1) { sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE)); } /** * Formats a temperature string for an active heater (e.g. "100 / 200°C") */ -void format_temp_and_temp(char *str, float t1, float t2) { +void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2) { sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C)); } /** * Formats a temperature string for a material (e.g. "100°C (PLA)") */ -void format_temp_and_material(char *str, float t1, const char *material) { +void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material) { sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material); } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h index 545c701700..44583f08ec 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/string_format.h @@ -21,9 +21,9 @@ #pragma once -void format_temp(char *str, float t1); -void format_temp_and_idle(char *str, float t1); -void format_temp_and_temp(char *str, float t1, float t2); -void format_temp_and_material(char *str, float t1, const char *material); +void format_temp(char *str, const_celsius_float_t t1); +void format_temp_and_idle(char *str, const_celsius_float_t t1); +void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2); +void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material); void format_position(char *str, float p, uint8_t decimals = 1); void format_position(char *str, float x, float y, float z); diff --git a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp index 3cd99b3163..679f66d807 100644 --- a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp @@ -595,8 +595,8 @@ void NextionTFT::PanelAction(uint8_t req) { void NextionTFT::UpdateOnChange() { const millis_t ms = millis(); static millis_t next_event_ms = 0; - static float last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999, - last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999; + static celsius_float_t last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999, + last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999; // tmppage Temperature if (!WITHIN(last_degHotend0 - getActualTemp_celsius(E0), -0.2, 0.2) || !WITHIN(last_degTargetHotend0 - getTargetTemp_celsius(E0), -0.5, 0.5)) { diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 66bc10c411..c2f51b3265 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -263,7 +263,7 @@ namespace ExtUI { #define GET_TEMP_ADJUSTMENT(A) A #endif - float getActualTemp_celsius(const heater_t heater) { + celsius_float_t getActualTemp_celsius(const heater_t heater) { switch (heater) { #if ENABLED(HAS_HEATED_BED) case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed()); @@ -275,11 +275,11 @@ namespace ExtUI { } } - float getActualTemp_celsius(const extruder_t extruder) { + celsius_float_t getActualTemp_celsius(const extruder_t extruder) { return GET_TEMP_ADJUSTMENT(thermalManager.degHotend(extruder - E0)); } - float getTargetTemp_celsius(const heater_t heater) { + celsius_float_t getTargetTemp_celsius(const heater_t heater) { switch (heater) { #if ENABLED(HAS_HEATED_BED) case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed()); @@ -291,7 +291,7 @@ namespace ExtUI { } } - float getTargetTemp_celsius(const extruder_t extruder) { + celsius_float_t getTargetTemp_celsius(const extruder_t extruder) { return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(extruder - E0)); } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index c59fe0bd17..bd017c6bd3 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -109,10 +109,10 @@ namespace ExtUI { void setTMCBumpSensitivity(const_float_t , const axis_t); #endif - float getActualTemp_celsius(const heater_t); - float getActualTemp_celsius(const extruder_t); - float getTargetTemp_celsius(const heater_t); - float getTargetTemp_celsius(const extruder_t); + celsius_float_t getActualTemp_celsius(const heater_t); + celsius_float_t getActualTemp_celsius(const extruder_t); + celsius_float_t getTargetTemp_celsius(const heater_t); + celsius_float_t getTargetTemp_celsius(const extruder_t); float getTargetFan_percent(const fan_t); float getActualFan_percent(const fan_t); float getAxisPosition_mm(const axis_t); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index d4b8409efa..910db87f55 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -352,7 +352,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { * - If a preheat input is higher than the current target, raise the target temperature. * - If a preheat input is higher than the current temperature, wait for stabilization. */ - void Probe::preheat_for_probing(const int16_t hotend_temp, const int16_t bed_temp) { + void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp) { #if HAS_HOTEND && (PROBING_NOZZLE_TEMP || LEVELING_NOZZLE_TEMP) #define WAIT_FOR_NOZZLE_HEAT #endif @@ -363,17 +363,17 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { DEBUG_ECHOPGM("Preheating "); #if ENABLED(WAIT_FOR_NOZZLE_HEAT) - const int16_t hotendPreheat = hotend_temp > thermalManager.degTargetHotend(0) ? hotend_temp : 0; + const celsius_t hotendPreheat = hotend_temp > thermalManager.degTargetHotend(0) ? hotend_temp : 0; if (hotendPreheat) { DEBUG_ECHOPAIR("hotend (", hotendPreheat, ")"); thermalManager.setTargetHotend(hotendPreheat, 0); } #elif ENABLED(WAIT_FOR_BED_HEAT) - constexpr int16_t hotendPreheat = 0; + constexpr celsius_t hotendPreheat = 0; #endif #if ENABLED(WAIT_FOR_BED_HEAT) - const int16_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0; + const celsius_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0; if (bedPreheat) { if (hotendPreheat) DEBUG_ECHOPGM(" and "); DEBUG_ECHOPAIR("bed (", bedPreheat, ")"); diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 75aba76ef3..7438a56614 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -61,7 +61,7 @@ public: static xyz_pos_t offset; #if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING) - static void preheat_for_probing(const int16_t hotend_temp, const int16_t bed_temp); + static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp); #endif static bool set_deployed(const bool deploy); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 08583676da..cd93ec1fc8 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -382,7 +382,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, chamber_info_t Temperature::temp_chamber; // = { 0 } #if HAS_HEATED_CHAMBER millis_t next_cool_check_ms_2 = 0; - float old_temp = 9999; + celsius_float_t old_temp = 9999; int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0}); @@ -395,7 +395,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if HAS_COOLER bool flag_cooler_state; //bool flag_cooler_excess = false; - float previous_temp = 9999; + celsius_float_t previous_temp = 9999; int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; #if WATCH_COOLER @@ -421,8 +421,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #endif #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - celsius_t Temperature::redundant_temperature_raw = 0; - float Temperature::redundant_temperature = 0.0; + int16_t Temperature::redundant_temperature_raw = 0; + celsius_float_t Temperature::redundant_temperature = 0.0; #endif volatile bool Temperature::raw_temps_ready = false; @@ -508,7 +508,7 @@ volatile bool Temperature::raw_temps_ready = false; long t_high = 0, t_low = 0; PID_t tune_pid = { 0, 0, 0 }; - float maxT = 0, minT = 10000; + celsius_float_t maxT = 0, minT = 10000; const bool isbed = (heater_id == H_BED); const bool ischamber = (heater_id == H_CHAMBER); @@ -544,9 +544,9 @@ volatile bool Temperature::raw_temps_ready = false; #define GTV(C,B,H) C_GTV(ischamber, C, B_GTV(isbed, B, H)) const uint16_t watch_temp_period = GTV(WATCH_CHAMBER_TEMP_PERIOD, WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD); const uint8_t watch_temp_increase = GTV(WATCH_CHAMBER_TEMP_INCREASE, WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE); - const float watch_temp_target = target - float(watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1); + const celsius_float_t watch_temp_target = celsius_float_t(target - watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1); millis_t temp_change_ms = next_temp_ms + SEC_TO_MS(watch_temp_period); - float next_watch_temp = 0.0; + celsius_float_t next_watch_temp = 0.0; bool heated = false; #endif @@ -567,7 +567,7 @@ volatile bool Temperature::raw_temps_ready = false; SHV(bias); #if ENABLED(PRINTER_EVENT_LEDS) - const float start_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius); + const celsius_float_t start_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius); LEDColor color = ONHEATINGSTART(); #endif @@ -2338,7 +2338,7 @@ void Temperature::init() { * * TODO: Embed the last 3 parameters during init, if not less optimal */ - void Temperature::tr_state_machine_t::run(const_float_t current, const_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) { + void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) { #if HEATER_IDLE_HANDLER // Convert the given heater_id_t to an idle array index @@ -3373,7 +3373,16 @@ void Temperature::isr() { #include "../gcode/gcode.h" - static void print_heater_state(const_float_t c, const_float_t t + /** + * Print a single heater state in the form: + * Bed: " B:nnn.nn /nnn.nn" + * Chamber: " C:nnn.nn /nnn.nn" + * Probe: " P:nnn.nn /nnn.nn" + * Cooler: " L:nnn.nn /nnn.nn" + * Extruder: " T0:nnn.nn /nnn.nn" + * With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)" + */ + static void print_heater_state(const_celsius_float_t c, const_celsius_float_t t #if ENABLED(SHOW_TEMP_ADC_VALUES) , const float r #endif @@ -3557,12 +3566,12 @@ void Temperature::isr() { #endif #if ENABLED(PRINTER_EVENT_LEDS) - const float start_temp = degHotend(target_extruder); + const celsius_float_t start_temp = degHotend(target_extruder); printerEventLEDs.onHotendHeatingStart(); #endif bool wants_to_cool = false; - float target_temp = -1.0, old_temp = 9999.0; + celsius_float_t target_temp = -1.0, old_temp = 9999.0; millis_t now, next_temp_ms = 0, next_cool_check_ms = 0; wait_for_heatup = true; do { @@ -3592,7 +3601,7 @@ void Temperature::isr() { idle(); gcode.reset_stepper_timeout(); // Keep steppers powered - const float temp = degHotend(target_extruder); + const celsius_float_t temp = degHotend(target_extruder); #if ENABLED(PRINTER_EVENT_LEDS) // Gradually change LED strip from violet to red as nozzle heats up @@ -3601,7 +3610,7 @@ void Temperature::isr() { #if TEMP_RESIDENCY_TIME > 0 - const float temp_diff = ABS(target_temp - temp); + const celsius_float_t temp_diff = ABS(target_temp - temp); if (!residency_start_ms) { // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time. @@ -3695,12 +3704,12 @@ void Temperature::isr() { #endif #if ENABLED(PRINTER_EVENT_LEDS) - const float start_temp = degBed(); + const celsius_float_t start_temp = degBed(); printerEventLEDs.onBedHeatingStart(); #endif bool wants_to_cool = false; - float target_temp = -1, old_temp = 9999; + celsius_float_t target_temp = -1, old_temp = 9999; millis_t now, next_temp_ms = 0, next_cool_check_ms = 0; wait_for_heatup = true; do { @@ -3730,7 +3739,7 @@ void Temperature::isr() { idle(); gcode.reset_stepper_timeout(); // Keep steppers powered - const float temp = degBed(); + const celsius_float_t temp = degBed(); #if ENABLED(PRINTER_EVENT_LEDS) // Gradually change LED strip from blue to violet as bed heats up @@ -3739,7 +3748,7 @@ void Temperature::isr() { #if TEMP_BED_RESIDENCY_TIME > 0 - const float temp_diff = ABS(target_temp - temp); + const celsius_float_t temp_diff = ABS(target_temp - temp); if (!residency_start_ms) { // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time. @@ -4021,11 +4030,11 @@ void Temperature::isr() { idle(); gcode.reset_stepper_timeout(); // Keep steppers powered - const float current_temp = degCooler(); + const celsius_float_t current_temp = degCooler(); #if TEMP_COOLER_RESIDENCY_TIME > 0 - const float temp_diff = ABS(target_temp - temp); + const celsius_float_t temp_diff = ABS(target_temp - temp); if (!residency_start_ms) { // Start the TEMP_COOLER_RESIDENCY_TIME timer when we reach target temp for the first time. diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index d2b3db8747..0335733924 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -961,7 +961,7 @@ class Temperature { millis_t timer = 0; TRState state = TRInactive; float running_temp; - void run(const_float_t current, const_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc); + void run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc); } tr_state_machine_t; static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY]; From 3bddbb1110b6ca13a291de426553839b99cae102 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Apr 2021 19:06:55 -0500 Subject: [PATCH 266/311] Clean up formatting, wrap macros --- Marlin/src/HAL/STM32/usb_host.cpp | 2 +- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/feature/hotend_idle.cpp | 2 +- Marlin/src/feature/leds/printer_event_leds.h | 8 +--- Marlin/src/feature/power.cpp | 6 +-- Marlin/src/feature/probe_temp_comp.cpp | 2 +- Marlin/src/feature/probe_temp_comp.h | 6 +-- Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 2 +- .../extui/lib/anycubic_chiron/chiron_tft.cpp | 2 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 12 +++--- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 2 +- Marlin/src/lcd/extui/malyan_lcd.cpp | 6 +-- Marlin/src/lcd/extui/ui_api.cpp | 16 ++----- Marlin/src/lcd/extui/ui_api.h | 42 +++++++++---------- Marlin/src/module/temperature.cpp | 4 +- Marlin/src/module/tool_change.cpp | 4 +- 16 files changed, 49 insertions(+), 69 deletions(-) diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp index ed743361e6..8fa49ccbcc 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -110,7 +110,7 @@ uint8_t BulkStorage::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t bl } uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) { - return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast (buf), blocks) != USBH_OK; + return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast(buf), blocks) != USBH_OK; } #endif // USE_OTG_USB_HOST && USBHOST diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 1405f20334..668f977b03 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -600,7 +600,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check()); #if ENABLED(EXTRUDER_RUNOUT_PREVENT) - if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP + if (thermalManager.degHotend(active_extruder) > (EXTRUDER_RUNOUT_MINTEMP) && ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS)) && !planner.has_blocks_queued() ) { diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index 911cd20e6c..b962743ed0 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -45,7 +45,7 @@ void HotendIdleProtection::check_hotends(const millis_t &ms) { bool do_prot = false; HOTEND_LOOP() { const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued()); - if (thermalManager.degHotend(e) >= HOTEND_IDLE_MIN_TRIGGER && !busy) { + if (thermalManager.degHotend(e) >= (HOTEND_IDLE_MIN_TRIGGER) && !busy) { do_prot = true; break; } } diff --git a/Marlin/src/feature/leds/printer_event_leds.h b/Marlin/src/feature/leds/printer_event_leds.h index a262ddf85e..2e1e589730 100644 --- a/Marlin/src/feature/leds/printer_event_leds.h +++ b/Marlin/src/feature/leds/printer_event_leds.h @@ -36,13 +36,7 @@ private: static bool leds_off_after_print; #endif - static inline void set_done() { - #if ENABLED(LED_COLOR_PRESETS) - leds.set_default(); - #else - leds.set_off(); - #endif - } + static inline void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); } public: #if HAS_TEMP_HOTEND diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 8ab49de2bd..2f19dae7a6 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -85,15 +85,15 @@ bool Power::is_power_needed() { if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0 || thermalManager.temp_bed.soft_pwm_amount > 0)) return true; #if HAS_HOTEND && AUTO_POWER_E_TEMP - HOTEND_LOOP() if (thermalManager.degHotend(e) >= AUTO_POWER_E_TEMP) return true; + HOTEND_LOOP() if (thermalManager.degHotend(e) >= (AUTO_POWER_E_TEMP)) return true; #endif #if HAS_HEATED_CHAMBER && AUTO_POWER_CHAMBER_TEMP - if (thermalManager.degChamber() >= AUTO_POWER_CHAMBER_TEMP) return true; + if (thermalManager.degChamber() >= (AUTO_POWER_CHAMBER_TEMP)) return true; #endif #if HAS_COOLER && AUTO_POWER_COOLER_TEMP - if (thermalManager.degCooler() >= AUTO_POWER_COOLER_TEMP) return true; + if (thermalManager.degCooler() >= (AUTO_POWER_COOLER_TEMP)) return true; #endif return false; diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index 68e669224c..edb33da8ce 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -181,7 +181,7 @@ float ProbeTempComp::get_offset_for_temperature(const TempSensorID tsi, const_fl // Linear interpolation uint8_t idx = static_cast((temp - start_temp) / res_temp); - // offset in um + // offset in µm float offset = 0.0f; #if !defined(PTC_LINEAR_EXTRAPOLATION) || PTC_LINEAR_EXTRAPOLATION <= 0 diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 5fb637a17e..c31d287a1b 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -81,10 +81,10 @@ typedef struct { #endif static constexpr temp_calib_t cali_info_init[TSI_COUNT] = { - { PTC_SAMPLE_COUNT, PTC_SAMPLE_RES, PTC_SAMPLE_START, PTC_SAMPLE_END }, // Probe - { BTC_SAMPLE_COUNT, BTC_SAMPLE_RES, BTC_SAMPLE_START, BTC_SAMPLE_END }, // Bed + { PTC_SAMPLE_COUNT, PTC_SAMPLE_RES, PTC_SAMPLE_START, PTC_SAMPLE_END }, // Probe + { BTC_SAMPLE_COUNT, BTC_SAMPLE_RES, BTC_SAMPLE_START, BTC_SAMPLE_END }, // Bed #if ENABLED(USE_TEMP_EXT_COMPENSATION) - { 20, 5, 180, 180 + 5 * 20 } // Extruder + { 20, 5, 180, 180 + 5 * 20 } // Extruder #endif }; diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index 9fc30b794d..f07d398226 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -208,7 +208,7 @@ void GcodeSuite::G76() { report_temps(next_temp_report); const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); - if (isnan(measured_z) || target_bed > BED_MAX_TARGET) break; + if (isnan(measured_z) || target_bed > (BED_MAX_TARGET)) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index ee8f18cd8e..5ad3895da0 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -700,7 +700,7 @@ void ChironTFT::PanelAction(uint8_t req) { if (!isPrinting()) { // Ignore request if printing char MoveCmnd[30]; - sprintf_P(MoveCmnd, PSTR("G91\nG0 %s \nG90"), panel_command+3); + sprintf_P(MoveCmnd, PSTR("G91\nG0%s\nG90"), panel_command + 3); #if ACDEBUG(AC_ACTION) SERIAL_ECHOLNPAIR("Move: ", MoveCmnd); #endif diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp index acd4d202b6..f3a9472c20 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 @@ -700,13 +700,13 @@ void AnycubicTFTClass::GetCommandFromTFT() { unsigned int tempvalue; if (CodeSeen('S')) { tempvalue = constrain(CodeValue(), 0, 275); - setTargetTemp_celsius(tempvalue, (extruder_t) E0); + setTargetTemp_celsius(tempvalue, (extruder_t)E0); } else if (CodeSeen('C') && !isPrinting()) { if (getAxisPosition_mm(Z) < 10) injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS tempvalue = constrain(CodeValue(), 0, 275); - setTargetTemp_celsius(tempvalue, (extruder_t) E0); + setTargetTemp_celsius(tempvalue, (extruder_t)E0); } } break; @@ -832,8 +832,8 @@ void AnycubicTFTClass::GetCommandFromTFT() { if (getAxisPosition_mm(Z) < 10) injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS - setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (heater_t) BED); - setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (extruder_t) E0); + setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (heater_t)BED); + setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (extruder_t)E0); SENDLINE_PGM("OK"); } break; @@ -843,8 +843,8 @@ void AnycubicTFTClass::GetCommandFromTFT() { if (getAxisPosition_mm(Z) < 10) injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS - setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (heater_t) BED); - setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (extruder_t) E0); + setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (heater_t)BED); + setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (extruder_t)E0); SENDLINE_PGM("OK"); } break; 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 e9cfd8179a..e35027a654 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -236,7 +236,7 @@ void disp_bed_temp() { } void disp_fan_speed() { - sprintf_P(public_buf_l, PSTR("%d%%"), thermalManager.fanSpeedPercent(0)); + sprintf_P(public_buf_l, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0)); lv_label_set_text(labelFan, public_buf_l); } diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index 780401964b..b6a8923a39 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -178,11 +178,7 @@ void process_lcd_eb_command(const char *command) { #else 0, 0, #endif - #if ENABLED(SDSUPPORT) - done_pct, - #else - 0, - #endif + TERN(SDSUPPORT, done_pct, 0), elapsed_buffer ); write_to_lcd(message_buffer); diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index c2f51b3265..23cf26a8ca 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -296,21 +296,13 @@ namespace ExtUI { } float getTargetFan_percent(const fan_t fan) { - #if HAS_FAN - return thermalManager.fanSpeedPercent(fan - FAN0); - #else - UNUSED(fan); - return 0; - #endif + UNUSED(fan); + return TERN0(HAS_FAN, thermalManager.fanSpeedPercent(fan - FAN0)); } float getActualFan_percent(const fan_t fan) { - #if HAS_FAN - return thermalManager.scaledFanSpeedPercent(fan - FAN0); - #else - UNUSED(fan); - return 0; - #endif + UNUSED(fan); + return TERN0(HAS_FAN, thermalManager.scaledFanSpeedPercent(fan - FAN0)); } float getAxisPosition_mm(const axis_t axis) { diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index bd017c6bd3..ba633741f7 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -102,11 +102,11 @@ namespace ExtUI { #if HAS_TRINAMIC_CONFIG float getAxisCurrent_mA(const axis_t); float getAxisCurrent_mA(const extruder_t); - void setAxisCurrent_mA(const_float_t , const axis_t); - void setAxisCurrent_mA(const_float_t , const extruder_t); + void setAxisCurrent_mA(const_float_t, const axis_t); + void setAxisCurrent_mA(const_float_t, const extruder_t); int getTMCBumpSensitivity(const axis_t); - void setTMCBumpSensitivity(const_float_t , const axis_t); + void setTMCBumpSensitivity(const_float_t, const axis_t); #endif celsius_float_t getActualTemp_celsius(const heater_t); @@ -195,18 +195,18 @@ namespace ExtUI { char* getFilamentUsed_str(char buffer[21]); #endif - void setTargetTemp_celsius(const_float_t , const heater_t); - void setTargetTemp_celsius(const_float_t , const extruder_t); - void setTargetFan_percent(const_float_t , const fan_t); + void setTargetTemp_celsius(const_float_t, const heater_t); + void setTargetTemp_celsius(const_float_t, const extruder_t); + void setTargetFan_percent(const_float_t, const fan_t); void coolDown(); - void setAxisPosition_mm(const_float_t , const axis_t, const feedRate_t=0); - void setAxisPosition_mm(const_float_t , const extruder_t, const feedRate_t=0); - void setAxisSteps_per_mm(const_float_t , const axis_t); - void setAxisSteps_per_mm(const_float_t , const extruder_t); + void setAxisPosition_mm(const_float_t, const axis_t, const feedRate_t=0); + void setAxisPosition_mm(const_float_t, const extruder_t, const feedRate_t=0); + void setAxisSteps_per_mm(const_float_t, const axis_t); + void setAxisSteps_per_mm(const_float_t, const extruder_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const axis_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const extruder_t); - void setAxisMaxAcceleration_mm_s2(const_float_t , const axis_t); - void setAxisMaxAcceleration_mm_s2(const_float_t , const extruder_t); + void setAxisMaxAcceleration_mm_s2(const_float_t, const axis_t); + void setAxisMaxAcceleration_mm_s2(const_float_t, const extruder_t); void setFeedrate_mm_s(const feedRate_t); void setMinFeedrate_mm_s(const feedRate_t); void setMinTravelFeedrate_mm_s(const feedRate_t); @@ -220,7 +220,7 @@ namespace ExtUI { #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t); - void setLinearAdvance_mm_mm_s(const_float_t , const extruder_t); + void setLinearAdvance_mm_mm_s(const_float_t, const extruder_t); #endif #if HAS_JUNCTION_DEVIATION @@ -229,8 +229,8 @@ namespace ExtUI { #else float getAxisMaxJerk_mm_s(const axis_t); float getAxisMaxJerk_mm_s(const extruder_t); - void setAxisMaxJerk_mm_s(const_float_t , const axis_t); - void setAxisMaxJerk_mm_s(const_float_t , const extruder_t); + void setAxisMaxJerk_mm_s(const_float_t, const axis_t); + void setAxisMaxJerk_mm_s(const_float_t, const extruder_t); #endif extruder_t getTool(const uint8_t extruder); @@ -246,7 +246,7 @@ namespace ExtUI { #if HAS_HOTEND_OFFSET float getNozzleOffset_mm(const axis_t, const extruder_t); - void setNozzleOffset_mm(const_float_t , const axis_t, const extruder_t); + void setNozzleOffset_mm(const_float_t, const axis_t, const extruder_t); void normalizeNozzleOffset(const axis_t axis); #endif @@ -255,12 +255,12 @@ namespace ExtUI { #if HAS_BED_PROBE float getProbeOffset_mm(const axis_t); - void setProbeOffset_mm(const_float_t , const axis_t); + void setProbeOffset_mm(const_float_t, const axis_t); #endif #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t); - void setAxisBacklash_mm(const_float_t , const axis_t); + void setAxisBacklash_mm(const_float_t, const axis_t); float getBacklashCorrection_percent(); void setBacklashCorrection_percent(const_float_t ); @@ -297,15 +297,15 @@ namespace ExtUI { float getPIDValues_Kp(const extruder_t); float getPIDValues_Ki(const extruder_t); float getPIDValues_Kd(const extruder_t); - void setPIDValues(const_float_t , const_float_t , const_float_t , extruder_t); - void startPIDTune(const_float_t , extruder_t); + void setPIDValues(const_float_t, const_float_t , const_float_t , extruder_t); + void startPIDTune(const_float_t, extruder_t); #endif #if ENABLED(PIDTEMPBED) float getBedPIDValues_Kp(); float getBedPIDValues_Ki(); float getBedPIDValues_Kd(); - void setBedPIDValues(const_float_t , const_float_t , const_float_t ); + void setBedPIDValues(const_float_t, const_float_t , const_float_t ); void startBedPIDTune(const_float_t ); #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index cd93ec1fc8..1ad0303abd 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -567,7 +567,7 @@ volatile bool Temperature::raw_temps_ready = false; SHV(bias); #if ENABLED(PRINTER_EVENT_LEDS) - const celsius_float_t start_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius); + const celsius_float_t start_temp = GHV(degChamber(), degBed(), degHotend(heater_id)); LEDColor color = ONHEATINGSTART(); #endif @@ -583,7 +583,7 @@ volatile bool Temperature::raw_temps_ready = false; updateTemperaturesFromRawValues(); // Get the current temperature and constrain it - current_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius); + current_temp = GHV(degChamber(), degBed(), degHotend(heater_id)); NOLESS(maxT, current_temp); NOMORE(minT, current_temp); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 2b8a434172..8354b8b86a 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1054,8 +1054,6 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { first_tool_is_primed = true; TERN_(TOOLCHANGE_FS_INIT_BEFORE_SWAP, toolchange_extruder_ready[old_tool] = true); // Primed and initialized } - #else - constexpr bool first_tool_is_primed = true; #endif if (new_tool != old_tool || TERN0(PARKING_EXTRUDER, extruder_parked)) { // PARKING_EXTRUDER may need to attach old_tool when homing @@ -1092,7 +1090,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { } else { // For first new tool, change without unloading the old. 'Just prime/init the new' - if (first_tool_is_primed) + if (TERN1(TOOLCHANGE_FS_PRIME_FIRST_USED, first_tool_is_primed)) unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); TERN_(TOOLCHANGE_FS_PRIME_FIRST_USED, first_tool_is_primed = true); // The first new tool will be primed by toolchanging } From 54ad22a4553404e6c777bd0d4794e7edba23152f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Apr 2021 19:36:43 -0500 Subject: [PATCH 267/311] Let compiler do Temperature inlining --- Marlin/src/module/temperature.h | 94 ++++++++++++++++----------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 0335733924..318cdaf075 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -324,7 +324,7 @@ class Temperature { #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) static hotend_info_t temp_hotend[HOTEND_TEMPS]; static const celsius_t hotend_maxtemp[HOTENDS]; - FORCE_INLINE static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } + static inline celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif #if ENABLED(HAS_HEATED_BED) static bed_info_t temp_bed; @@ -357,20 +357,20 @@ class Temperature { #if ENABLED(PREVENT_COLD_EXTRUSION) static bool allow_cold_extrude; static celsius_t extrude_min_temp; - FORCE_INLINE static bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } - FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) { + static inline bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } + static inline bool tooColdToExtrude(const uint8_t E_NAME) { return tooCold(degHotend(HOTEND_INDEX)); } - FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t E_NAME) { + static inline bool targetTooColdToExtrude(const uint8_t E_NAME) { return tooCold(degTargetHotend(HOTEND_INDEX)); } #else - FORCE_INLINE static bool tooColdToExtrude(const uint8_t) { return false; } - FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t) { return false; } + static inline bool tooColdToExtrude(const uint8_t) { return false; } + static inline bool targetTooColdToExtrude(const uint8_t) { return false; } #endif - FORCE_INLINE static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } - FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } + static inline bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } + static inline bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } #if ENABLED(SINGLENOZZLE_STANDBY_FAN) static celsius_t singlenozzle_temp[EXTRUDERS]; @@ -506,25 +506,25 @@ class Temperature { static void log_user_thermistor(const uint8_t t_index, const bool eprom=false); static void reset_user_thermistors(); static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw); - static bool set_pull_up_res(int8_t t_index, float value) { + static inline bool set_pull_up_res(int8_t t_index, float value) { //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false; if (!WITHIN(value, 1, 1000000)) return false; user_thermistor[t_index].series_res = value; return true; } - static bool set_res25(int8_t t_index, float value) { + static inline bool set_res25(int8_t t_index, float value) { if (!WITHIN(value, 1, 10000000)) return false; user_thermistor[t_index].res_25 = value; user_thermistor[t_index].pre_calc = true; return true; } - static bool set_beta(int8_t t_index, float value) { + static inline bool set_beta(int8_t t_index, float value) { if (!WITHIN(value, 1, 1000000)) return false; user_thermistor[t_index].beta = value; user_thermistor[t_index].pre_calc = true; return true; } - static bool set_sh_coeff(int8_t t_index, float value) { + static inline bool set_sh_coeff(int8_t t_index, float value) { if (!WITHIN(value, -0.01f, 0.01f)) return false; user_thermistor[t_index].sh_c_coeff = value; user_thermistor[t_index].pre_calc = true; @@ -614,13 +614,13 @@ class Temperature { * Preheating hotends */ #ifdef MILLISECONDS_PREHEAT_TIME - static bool is_preheating(const uint8_t E_NAME) { + static inline bool is_preheating(const uint8_t E_NAME) { return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]); } - static void start_preheat_time(const uint8_t E_NAME) { + static inline void start_preheat_time(const uint8_t E_NAME) { preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME; } - static void reset_preheat_time(const uint8_t E_NAME) { + static inline void reset_preheat_time(const uint8_t E_NAME) { preheat_end_time[HOTEND_INDEX] = 0; } #else @@ -631,17 +631,17 @@ class Temperature { //inline so that there is no performance decrease. //deg=degreeCelsius - FORCE_INLINE static celsius_t degHotend(const uint8_t E_NAME) { + static inline celsius_t degHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius); } #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawHotendTemp(const uint8_t E_NAME) { + static inline int16_t rawHotendTemp(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw); } #endif - FORCE_INLINE static celsius_t degTargetHotend(const uint8_t E_NAME) { + static inline celsius_t degTargetHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target); } @@ -666,11 +666,11 @@ class Temperature { start_watching_hotend(ee); } - FORCE_INLINE static bool isHeatingHotend(const uint8_t E_NAME) { + static inline bool isHeatingHotend(const uint8_t E_NAME) { return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius; } - FORCE_INLINE static bool isCoolingHotend(const uint8_t E_NAME) { + static inline bool isCoolingHotend(const uint8_t E_NAME) { return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius; } @@ -686,11 +686,11 @@ class Temperature { #endif #endif - FORCE_INLINE static bool still_heating(const uint8_t e) { + static inline bool still_heating(const uint8_t e) { return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS; } - FORCE_INLINE static bool degHotendNear(const uint8_t e, const_float_t temp) { + static inline bool degHotendNear(const uint8_t e, const_float_t temp) { return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS); } @@ -699,12 +699,12 @@ class Temperature { #if HAS_HEATED_BED #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawBedTemp() { return temp_bed.raw; } + static inline int16_t rawBedTemp() { return temp_bed.raw; } #endif - FORCE_INLINE static celsius_t degBed() { return temp_bed.celsius; } - FORCE_INLINE static celsius_t degTargetBed() { return temp_bed.target; } - FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } - FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } + static inline celsius_t degBed() { return temp_bed.celsius; } + static inline celsius_t degTargetBed() { return temp_bed.target; } + static inline bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } + static inline bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } #if WATCH_BED static void start_watching_bed(); @@ -726,7 +726,7 @@ class Temperature { static void wait_for_bed_heating(); - FORCE_INLINE static bool degBedNear(const_float_t temp) { + static inline bool degBedNear(const_float_t temp) { return ABS(degBed() - temp) < (TEMP_BED_HYSTERESIS); } @@ -734,11 +734,11 @@ class Temperature { #if HAS_TEMP_PROBE #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawProbeTemp() { return temp_probe.raw; } + static inline int16_t rawProbeTemp() { return temp_probe.raw; } #endif - FORCE_INLINE static celsius_t degProbe() { return temp_probe.celsius; } - FORCE_INLINE static bool isProbeBelowTemp(const_float_t target_temp) { return temp_probe.celsius < target_temp; } - FORCE_INLINE static bool isProbeAboveTemp(const_float_t target_temp) { return temp_probe.celsius > target_temp; } + static inline celsius_t degProbe() { return temp_probe.celsius; } + static inline bool isProbeBelowTemp(const_float_t target_temp) { return temp_probe.celsius < target_temp; } + static inline bool isProbeAboveTemp(const_float_t target_temp) { return temp_probe.celsius > target_temp; } static bool wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling=true); #endif @@ -750,13 +750,13 @@ class Temperature { #if HAS_TEMP_CHAMBER #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; } + static inline int16_t rawChamberTemp() { return temp_chamber.raw; } #endif - FORCE_INLINE static celsius_t degChamber() { return temp_chamber.celsius; } + static inline celsius_t degChamber() { return temp_chamber.celsius; } #if HAS_HEATED_CHAMBER - FORCE_INLINE static celsius_t degTargetChamber() { return temp_chamber.target; } - FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } - FORCE_INLINE static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } + static inline celsius_t degTargetChamber() { return temp_chamber.target; } + static inline bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } + static inline bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } static bool wait_for_chamber(const bool no_wait_for_cooling=true); #endif #endif @@ -776,13 +776,13 @@ class Temperature { #if HAS_TEMP_COOLER #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; } + static inline int16_t rawCoolerTemp() { return temp_cooler.raw; } #endif - FORCE_INLINE static celsius_t degCooler() { return temp_cooler.celsius; } + static inline celsius_t degCooler() { return temp_cooler.celsius; } #if HAS_COOLER - FORCE_INLINE static celsius_t degTargetCooler() { return temp_cooler.target; } - FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } - FORCE_INLINE static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } + static inline celsius_t degTargetCooler() { return temp_cooler.target; } + static inline bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } + static inline bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } static bool wait_for_cooler(const bool no_wait_for_cooling=true); #endif #endif @@ -794,7 +794,7 @@ class Temperature { #endif #if HAS_COOLER - static void setTargetCooler(const celsius_t celsius) { + static inline void setTargetCooler(const celsius_t celsius) { temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET); start_watching_cooler(); } @@ -839,7 +839,7 @@ class Temperature { * Update the temp manager when PID values change */ #if ENABLED(PIDTEMP) - FORCE_INLINE static void updatePID() { + static inline void updatePID() { TERN_(PID_EXTRUSION_SCALING, last_e_position = 0); } #endif @@ -848,18 +848,18 @@ class Temperature { #if ENABLED(PROBING_HEATERS_OFF) static void pause(const bool p); - FORCE_INLINE static bool is_paused() { return paused; } + static inline bool is_paused() { return paused; } #endif #if HEATER_IDLE_HANDLER - static void reset_hotend_idle_timer(const uint8_t E_NAME) { + static inline void reset_hotend_idle_timer(const uint8_t E_NAME) { heater_idle[HOTEND_INDEX].reset(); start_watching_hotend(HOTEND_INDEX); } #if HAS_HEATED_BED - static void reset_bed_idle_timer() { + static inline void reset_bed_idle_timer() { heater_idle[IDLE_INDEX_BED].reset(); start_watching_bed(); } From 384e09aa7c7866974ff232d1e771e51e89ea0a02 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 24 Apr 2021 00:54:41 +0000 Subject: [PATCH 268/311] [cron] Bump distribution date (2021-04-24) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index fb95c4e032..1eb4cc5567 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-04-23" + #define STRING_DISTRIBUTION_DATE "2021-04-24" #endif /** From c4620bb5285438e41fa4c39229aa2a39859877ca Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Apr 2021 20:19:23 -0500 Subject: [PATCH 269/311] Add whole-degree accessors, simplify some temperature-related features (#21685) --- .../src/feature/leds/printer_event_leds.cpp | 12 +++---- Marlin/src/feature/leds/printer_event_leds.h | 8 ++--- Marlin/src/feature/leds/tempstat.cpp | 6 ++-- Marlin/src/feature/pause.cpp | 2 +- Marlin/src/feature/probe_temp_comp.cpp | 27 ++++++++------- Marlin/src/feature/probe_temp_comp.h | 22 ++++++------ Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 10 +++--- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 10 +++--- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 6 ++-- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 2 +- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 8 ++--- .../lcd/dogm/status_screen_lite_ST7920.cpp | 6 ++-- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 10 +++--- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 6 ++-- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 2 +- .../extui/lib/mks_ui/draw_filament_change.cpp | 10 +++--- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 4 +-- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 6 ++-- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 24 ++++++------- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 14 ++++---- Marlin/src/lcd/extui/malyan_lcd.cpp | 8 ++--- Marlin/src/lcd/extui/ui_api.cpp | 4 +-- Marlin/src/lcd/tft/ui_1024x600.cpp | 10 +++--- Marlin/src/lcd/tft/ui_320x240.cpp | 10 +++--- Marlin/src/lcd/tft/ui_480x320.cpp | 10 +++--- Marlin/src/module/probe.cpp | 4 +-- Marlin/src/module/temperature.cpp | 8 ++--- Marlin/src/module/temperature.h | 34 +++++++++++-------- 28 files changed, 144 insertions(+), 139 deletions(-) diff --git a/Marlin/src/feature/leds/printer_event_leds.cpp b/Marlin/src/feature/leds/printer_event_leds.cpp index fe7db9a8e4..4765f82e56 100644 --- a/Marlin/src/feature/leds/printer_event_leds.cpp +++ b/Marlin/src/feature/leds/printer_event_leds.cpp @@ -40,9 +40,9 @@ PrinterEventLEDs printerEventLEDs; uint8_t PrinterEventLEDs::old_intensity = 0; - inline uint8_t pel_intensity(const_float_t start, const_float_t current, const_float_t target) { - if (uint16_t(start) == uint16_t(target)) return 255; - return (uint8_t)map(constrain(current, start, target), start, target, 0.f, 255.f); + inline uint8_t pel_intensity(const celsius_t start, const celsius_t current, const celsius_t target) { + if (start == target) return 255; + return (uint8_t)map(constrain(current, start, target), start, target, 0, 255); } inline void pel_set_rgb(const uint8_t r, const uint8_t g, const uint8_t b) { @@ -58,7 +58,7 @@ PrinterEventLEDs printerEventLEDs; #if HAS_TEMP_HOTEND - void PrinterEventLEDs::onHotendHeating(const_float_t start, const_float_t current, const_float_t target) { + void PrinterEventLEDs::onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target) { const uint8_t blue = pel_intensity(start, current, target); if (blue != old_intensity) { old_intensity = blue; @@ -70,7 +70,7 @@ PrinterEventLEDs printerEventLEDs; #if HAS_HEATED_BED - void PrinterEventLEDs::onBedHeating(const_float_t start, const_float_t current, const_float_t target) { + void PrinterEventLEDs::onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target) { const uint8_t red = pel_intensity(start, current, target); if (red != old_intensity) { old_intensity = red; @@ -82,7 +82,7 @@ PrinterEventLEDs printerEventLEDs; #if HAS_HEATED_CHAMBER - void PrinterEventLEDs::onChamberHeating(const_float_t start, const_float_t current, const_float_t target) { + void PrinterEventLEDs::onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target) { const uint8_t green = pel_intensity(start, current, target); if (green != old_intensity) { old_intensity = green; diff --git a/Marlin/src/feature/leds/printer_event_leds.h b/Marlin/src/feature/leds/printer_event_leds.h index 2e1e589730..b2201433d8 100644 --- a/Marlin/src/feature/leds/printer_event_leds.h +++ b/Marlin/src/feature/leds/printer_event_leds.h @@ -41,21 +41,21 @@ private: public: #if HAS_TEMP_HOTEND static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); } - static void onHotendHeating(const_float_t start, const_float_t current, const_float_t target); + static void onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_HEATED_BED static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); } - static void onBedHeating(const_float_t start, const_float_t current, const_float_t target); + static void onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_HEATED_CHAMBER static inline LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); } - static void onChamberHeating(const_float_t start, const_float_t current, const_float_t target); + static void onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER - static inline void onHeatingDone() { leds.set_white(); } + static inline void onHeatingDone() { leds.set_white(); } static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); } #endif diff --git a/Marlin/src/feature/leds/tempstat.cpp b/Marlin/src/feature/leds/tempstat.cpp index 880258f852..967b9f4d81 100644 --- a/Marlin/src/feature/leds/tempstat.cpp +++ b/Marlin/src/feature/leds/tempstat.cpp @@ -36,10 +36,10 @@ void handle_status_leds() { static millis_t next_status_led_update_ms = 0; if (ELAPSED(millis(), next_status_led_update_ms)) { next_status_led_update_ms += 500; // Update every 0.5s - float max_temp = TERN0(HAS_HEATED_BED, _MAX(thermalManager.degTargetBed(), thermalManager.degBed())); + celsius_t max_temp = TERN0(HAS_HEATED_BED, _MAX(thermalManager.degTargetBed(), thermalManager.wholeDegBed())); HOTEND_LOOP() - max_temp = _MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e)); - const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red; + max_temp = _MAX(max_temp, thermalManager.wholeDegHotend(e), thermalManager.degTargetHotend(e)); + const int8_t new_red = (max_temp > 55) ? HIGH : (max_temp < 54 || old_red < 0) ? LOW : old_red; if (new_red != old_red) { old_red = new_red; #if PIN_EXISTS(STAT_LED_RED) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 192c7f6345..6552eaa42c 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -143,7 +143,7 @@ static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=P // Allow interruption by Emergency Parser M108 wait_for_heatup = TERN1(PREVENT_COLD_EXTRUSION, !thermalManager.allow_cold_extrude); - while (wait_for_heatup && ABS(thermalManager.degHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > TEMP_WINDOW) + while (wait_for_heatup && ABS(thermalManager.wholeDegHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > (TEMP_WINDOW)) idle(); wait_for_heatup = false; diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index edb33da8ce..c9d6c6cb3f 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -71,7 +71,7 @@ bool ProbeTempComp::set_offset(const TempSensorID tsi, const uint8_t idx, const void ProbeTempComp::print_offsets() { LOOP_L_N(s, TSI_COUNT) { - float temp = cali_info[s].start_temp; + celsius_t temp = cali_info[s].start_temp; for (int16_t i = -1; i < cali_info[s].measurements; ++i) { SERIAL_ECHOPGM_P(s == TSI_BED ? PSTR("Bed") : #if ENABLED(USE_TEMP_EXT_COMPENSATION) @@ -114,8 +114,8 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { } const uint8_t measurements = cali_info[tsi].measurements; - const float start_temp = cali_info[tsi].start_temp, - res_temp = cali_info[tsi].temp_res; + const celsius_t start_temp = cali_info[tsi].start_temp, + res_temp = cali_info[tsi].temp_res; int16_t * const data = sensor_z_offsets[tsi]; // Extrapolate @@ -159,19 +159,19 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { return true; } -void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const_float_t temp, float &meas_z) { +void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z) { if (WITHIN(temp, cali_info[tsi].start_temp, cali_info[tsi].end_temp)) meas_z -= get_offset_for_temperature(tsi, temp); } -float ProbeTempComp::get_offset_for_temperature(const TempSensorID tsi, const_float_t temp) { +float ProbeTempComp::get_offset_for_temperature(const TempSensorID tsi, const celsius_t temp) { const uint8_t measurements = cali_info[tsi].measurements; - const float start_temp = cali_info[tsi].start_temp, - res_temp = cali_info[tsi].temp_res; + const celsius_t start_temp = cali_info[tsi].start_temp, + res_temp = cali_info[tsi].temp_res; const int16_t * const data = sensor_z_offsets[tsi]; - auto point = [&](uint8_t i) { - return xy_float_t({start_temp + i*res_temp, static_cast(data[i])}); + auto point = [&](uint8_t i) -> xy_float_t { + return xy_float_t({ static_cast(start_temp) + i * res_temp, static_cast(data[i]) }); }; auto linear_interp = [](const_float_t x, xy_float_t p1, xy_float_t p2) { @@ -207,17 +207,18 @@ bool ProbeTempComp::linear_regression(const TempSensorID tsi, float &k, float &d if (!WITHIN(calib_idx, 2, cali_info[tsi].measurements)) return false; - const float start_temp = cali_info[tsi].start_temp, - res_temp = cali_info[tsi].temp_res; + const celsius_t start_temp = cali_info[tsi].start_temp, + res_temp = cali_info[tsi].temp_res; const int16_t * const data = sensor_z_offsets[tsi]; float sum_x = start_temp, sum_x2 = sq(start_temp), sum_xy = 0, sum_y = 0; + float xi = static_cast(start_temp); LOOP_L_N(i, calib_idx) { - const float xi = start_temp + (i + 1) * res_temp, - yi = static_cast(data[i]); + const float yi = static_cast(data[i]); + xi += res_temp; sum_x += xi; sum_x2 += sq(xi); sum_xy += xi * yi; diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index c31d287a1b..2eeb7f47ec 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -34,9 +34,9 @@ enum TempSensorID : uint8_t { typedef struct { uint8_t measurements; // Max. number of measurements to be stored (35 - 80°C) - float temp_res, // Resolution in °C between measurements - start_temp, // Base measurement; z-offset == 0 - end_temp; + celsius_t temp_res, // Resolution in °C between measurements + start_temp, // Base measurement; z-offset == 0 + end_temp; } temp_calib_t; /** @@ -50,25 +50,25 @@ typedef struct { #define PTC_SAMPLE_COUNT 10U #endif #ifndef PTC_SAMPLE_RES - #define PTC_SAMPLE_RES 5.0f + #define PTC_SAMPLE_RES 5 #endif #ifndef PTC_SAMPLE_START - #define PTC_SAMPLE_START 30.0f + #define PTC_SAMPLE_START 30 #endif #define PTC_SAMPLE_END ((PTC_SAMPLE_START) + (PTC_SAMPLE_COUNT) * (PTC_SAMPLE_RES)) // Bed temperature calibration constants #ifndef BTC_PROBE_TEMP - #define BTC_PROBE_TEMP 30.0f + #define BTC_PROBE_TEMP 30 #endif #ifndef BTC_SAMPLE_COUNT #define BTC_SAMPLE_COUNT 10U #endif #ifndef BTC_SAMPLE_STEP - #define BTC_SAMPLE_RES 5.0f + #define BTC_SAMPLE_RES 5 #endif #ifndef BTC_SAMPLE_START - #define BTC_SAMPLE_START 60.0f + #define BTC_SAMPLE_START 60 #endif #define BTC_SAMPLE_END ((BTC_SAMPLE_START) + (BTC_SAMPLE_COUNT) * (BTC_SAMPLE_RES)) @@ -77,7 +77,7 @@ typedef struct { #endif #ifndef PTC_PROBE_RAISE - #define PTC_PROBE_RAISE 10.0f + #define PTC_PROBE_RAISE 10 #endif static constexpr temp_calib_t cali_info_init[TSI_COUNT] = { @@ -124,7 +124,7 @@ class ProbeTempComp { static void prepare_new_calibration(const_float_t init_meas_z); static void push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z); static bool finish_calibration(const TempSensorID tsi); - static void compensate_measurement(const TempSensorID tsi, const_float_t temp, float &meas_z); + static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z); private: static uint8_t calib_idx; @@ -135,7 +135,7 @@ class ProbeTempComp { */ static float init_measurement; - static float get_offset_for_temperature(const TempSensorID tsi, const_float_t temp); + static float get_offset_for_temperature(const TempSensorID tsi, const celsius_t temp); /** * Fit a linear function in measured temperature offsets diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index f07d398226..d5266179c7 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -103,9 +103,9 @@ void GcodeSuite::G76() { return (timeout && ELAPSED(ms, timeout)); }; - auto wait_for_temps = [&](const float tb, const float tp, millis_t &ntr, const millis_t timeout=0) { + auto wait_for_temps = [&](const celsius_t tb, const celsius_t tp, millis_t &ntr, const millis_t timeout=0) { say_waiting_for(); SERIAL_ECHOLNPGM("bed and probe temperature."); - while (fabs(thermalManager.degBed() - tb) > 0.1f || thermalManager.degProbe() > tp) + while (thermalManager.wholeDegBed() != tb || thermalManager.wholeDegProbe() > tp) if (report_temps(ntr, timeout)) return true; return false; }; @@ -180,7 +180,7 @@ void GcodeSuite::G76() { target_probe = temp_comp.bed_calib_probe_temp; say_waiting_for(); SERIAL_ECHOLNPGM(" cooling."); - while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe) + while (thermalManager.wholeDegBed() > target_bed || thermalManager.wholeDegProbe() > target_probe) report_temps(next_temp_report); // Disable leveling so it won't mess with us @@ -204,7 +204,7 @@ void GcodeSuite::G76() { do_blocking_move_to(noz_pos_xyz); say_waiting_for_probe_heating(); SERIAL_EOL(); - while (thermalManager.degProbe() < target_probe) + while (thermalManager.wholeDegProbe() < target_probe) report_temps(next_temp_report); const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); @@ -350,7 +350,7 @@ void GcodeSuite::M192() { return; } - const float target_temp = parser.value_celsius(); + const celsius_t target_temp = parser.value_celsius(); ui.set_status_P(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT(MSG_PROBE_HEATING) : GET_TEXT(MSG_PROBE_COOLING)); thermalManager.wait_for_probe(target_temp, no_wait_for_cooling); } diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 6ed4d33630..e91213b5b7 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -525,10 +525,10 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) { #if HAS_HEATED_BED const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0); - const celsius_t t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)), + const celsius_t t1 = (isBed ? thermalManager.wholeDegBed() : thermalManager.wholeDegHotend(heater_id)), t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); #else - const celsius_t t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); + const celsius_t t1 = thermalManager.wholeDegHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); #endif if (prefix >= 0) lcd_put_wchar(prefix); @@ -557,11 +557,11 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr #if HAS_COOLER FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { - const float t1 = thermalManager.degCooler(), t2 = thermalManager.degTargetCooler(); + const celsius_t t2 = thermalManager.degTargetCooler(); if (prefix >= 0) lcd_put_wchar(prefix); - lcd_put_u8str(i16tostr3rj(t1 + 0.5)); + lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); lcd_put_wchar('/'); #if !HEATER_IDLE_HANDLER @@ -574,7 +574,7 @@ FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { } else #endif - lcd_put_u8str(i16tostr3left(t2 + 0.5)); + lcd_put_u8str(i16tostr3left(t2)); if (prefix >= 0) { lcd_put_wchar(LCD_STR_DEGREE[0]); diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index ddc33c4923..31cdc4ac30 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -434,10 +434,10 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p uint8_t pic_hot_bits; #if HAS_HEATED_BED const bool isBed = heater_id < 0; - const celsius_t t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)), + const celsius_t t1 = (isBed ? thermalManager.wholeDegBed() : thermalManager.wholeDegHotend(heater_id)), t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); #else - const celsius_t t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); + const celsius_t t1 = thermalManager.wholeDegHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); #endif #if HOTENDS < 2 @@ -803,7 +803,7 @@ void MarlinUI::draw_status_screen() { if (!PanelDetected) return; lcd.setCursor((LCD_WIDTH - 14) / 2, row + 1); lcd.write(LCD_STR_THERMOMETER[0]); lcd_put_u8str_P(PSTR(" E")); lcd.write('1' + extruder); lcd.write(' '); - lcd.print(i16tostr3rj(thermalManager.degHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.write('/'); + lcd.print(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.write('/'); lcd.print(i16tostr3rj(thermalManager.degTargetHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.print_line(); } diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index dc60c1bff3..f298e7be8b 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -324,7 +324,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop lcd_put_wchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), row_y2, 'E'); lcd_put_wchar((char)('1' + extruder)); lcd_put_wchar(' '); - lcd_put_u8str(i16tostr3rj(thermalManager.degHotend(extruder))); + lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); lcd_put_wchar('/'); if (get_blink() || !thermalManager.heater_idle[extruder].timed_out) diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index e2bffb7fe0..81e89f7cf5 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -213,7 +213,7 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id); - const celsius_t temp = thermalManager.degHotend(heater_id), + const celsius_t temp = thermalManager.wholeDegHotend(heater_id), target = thermalManager.degTargetHotend(heater_id); #if DISABLED(STATUS_HOTEND_ANIM) @@ -310,7 +310,7 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co const uint8_t tx = STATUS_BED_TEXT_X; - const celsius_t temp = thermalManager.degBed(), + const celsius_t temp = thermalManager.wholeDegBed(), target = thermalManager.degTargetBed(); #if ENABLED(STATUS_HEAT_PERCENT) || DISABLED(STATUS_BED_ANIM) @@ -380,14 +380,14 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co _draw_centered_temp(thermalManager.degTargetChamber(), STATUS_CHAMBER_TEXT_X, 7); #endif if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) - _draw_centered_temp(thermalManager.degChamber(), STATUS_CHAMBER_TEXT_X, 28); + _draw_centered_temp(thermalManager.wholeDegChamber(), STATUS_CHAMBER_TEXT_X, 28); } #endif #if DO_DRAW_COOLER FORCE_INLINE void _draw_cooler_status() { if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) - _draw_centered_temp(thermalManager.degCooler(), STATUS_COOLER_TEXT_X, 28); + _draw_centered_temp(thermalManager.wholeDegCooler(), STATUS_COOLER_TEXT_X, 28); } #endif diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index b8257d32ff..2f8b5f67e2 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -721,14 +721,14 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { const duration_t elapsed = print_job_timer.duration(); duration_t remaining = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time()); const uint16_t feedrate_perc = feedrate_percentage; - const celsius_t extruder_1_temp = thermalManager.degHotend(0), + const celsius_t extruder_1_temp = thermalManager.wholeDegHotend(0), extruder_1_target = thermalManager.degTargetHotend(0); #if HAS_MULTI_HOTEND - const celsius_t extruder_2_temp = thermalManager.degHotend(1), + const celsius_t extruder_2_temp = thermalManager.wholeDegHotend(1), extruder_2_target = thermalManager.degTargetHotend(1); #endif #if HAS_HEATED_BED - const celsius_t bed_temp = thermalManager.degBed(), + const celsius_t bed_temp = thermalManager.wholeDegBed(), bed_target = thermalManager.degTargetBed(); #endif diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index b86e7cbe60..cb7fb2728e 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -1583,7 +1583,7 @@ void _draw_xyz_position(const bool force) { void update_variable() { #if HAS_HOTEND static celsius_t _hotendtemp = 0, _hotendtarget = 0; - const celsius_t hc = thermalManager.degHotend(0), + const celsius_t hc = thermalManager.wholeDegHotend(0), ht = thermalManager.degTargetHotend(0); const bool _new_hotend_temp = _hotendtemp != hc, _new_hotend_target = _hotendtarget != ht; @@ -1592,7 +1592,7 @@ void update_variable() { #endif #if HAS_HEATED_BED static celsius_t _bedtemp = 0, _bedtarget = 0; - const celsius_t bc = thermalManager.degBed(), + const celsius_t bc = thermalManager.wholeDegBed(), bt = thermalManager.degTargetBed(); const bool _new_bed_temp = _bedtemp != bc, _new_bed_target = _bedtarget != bt; @@ -1880,7 +1880,7 @@ void Draw_Status_Area(const bool with_update) { #if HAS_HOTEND DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.degHotend(0)); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.wholeDegHotend(0)); DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/")); DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.degTargetHotend(0)); @@ -1891,7 +1891,7 @@ void Draw_Status_Area(const bool with_update) { #if HAS_HEATED_BED DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416); - DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.degBed()); + DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.wholeDegBed()); DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.degTargetBed()); #endif @@ -2709,7 +2709,7 @@ void HMI_AxisMove() { case 4: // Extruder // window tips #ifdef PREVENT_COLD_EXTRUSION - if (thermalManager.degHotend(0) < EXTRUDE_MINTEMP) { + if (thermalManager.wholeDegHotend(0) < (EXTRUDE_MINTEMP)) { HMI_flag.ETempTooLow_flag = true; Popup_Window_ETempTooLow(); DWIN_UpdateLCD(); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index c4056f392a..b4ebc97db3 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -486,7 +486,7 @@ void lv_draw_dialog(uint8_t type) { void filament_sprayer_temp() { char buf[20] = {0}; - sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, uiCfg.extruderIndex < 1 ? extrude_menu.ext1 : extrude_menu.ext2); strcat_P(public_buf_l, PSTR(": ")); @@ -522,7 +522,7 @@ void filament_dialog_handle() { } if (uiCfg.filament_load_heat_flg) { - const celsius_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; + const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; if (abs(diff) < 2 || diff > 0) { uiCfg.filament_load_heat_flg = false; lv_clear_dialog(); @@ -538,7 +538,7 @@ void filament_dialog_handle() { } if (uiCfg.filament_unload_heat_flg) { - const celsius_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; + const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; if (abs(diff) < 2 || diff > 0) { uiCfg.filament_unload_heat_flg = false; lv_clear_dialog(); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index 43ed214199..77ec61c4b7 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -195,7 +195,7 @@ void disp_ext_speed() { void disp_hotend_temp() { char buf[20] = {0}; - sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, extrude_menu.temp_value, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, extrude_menu.temper_text); strcat(public_buf_l, buf); lv_label_set_text(tempText, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp index a3313285df..e3cfde3011 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -50,8 +50,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_FILAMNT_IN: uiCfg.filament_load_heat_flg = true; - if (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1 - || gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex)) { + if (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1 + || gCfgItems.filament_limit_temp <= thermalManager.wholeDegHotend(uiCfg.extruderIndex)) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); } @@ -67,8 +67,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_FILAMNT_OUT: uiCfg.filament_unload_heat_flg = true; if (thermalManager.degTargetHotend(uiCfg.extruderIndex) - && (abs((int)(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1 - || thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp) + && (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1 + || thermalManager.wholeDegHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp) ) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); @@ -154,7 +154,7 @@ void disp_filament_temp() { public_buf_l[0] = '\0'; strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); 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 0395ccde52..5fcfec1534 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -216,12 +216,12 @@ void disp_desire_temp() { if (uiCfg.curTempType == 0) { strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); } else { #if HAS_HEATED_BED strcat(public_buf_l, preheat_menu.hotbed); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); + sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegBed(), thermalManager.degTargetBed()); #endif } strcat_P(public_buf_l, PSTR(": ")); 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 e35027a654..f752d605ed 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -219,18 +219,18 @@ void lv_draw_printing() { } void disp_ext_temp() { - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, public_buf_l); #endif } void disp_bed_temp() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); + sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.wholeDegBed(), thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); #endif } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 8340e2ae87..26cd55d7f5 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -104,14 +104,14 @@ void disp_det_error() { lv_obj_t *e1, *e2, *e3, *bed; void mks_disp_test() { char buf[30] = {0}; - sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("e1:%d"), thermalManager.wholeDegHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND - sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("e2:%d"), thermalManager.wholeDegHotend(1)); lv_label_set_text(e2, buf); #endif #if HAS_HEATED_BED - sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.degBed()); + sprintf_P(buf, PSTR("bed:%d"), thermalManager.wholeDegBed()); lv_label_set_text(bed, buf); #endif } @@ -138,20 +138,20 @@ void lv_draw_ready_print() { e1 = lv_label_create_empty(scr); lv_obj_set_pos(e1, 20, 20); - sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND e2 = lv_label_create_empty(scr); lv_obj_set_pos(e2, 20, 45); - sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(1)); lv_label_set_text(e2, buf); #endif #if HAS_HEATED_BED bed = lv_label_create_empty(scr); lv_obj_set_pos(bed, 20, 95); - sprintf_P(buf, PSTR("bed: %d"), (int)thermalManager.degBed()); + sprintf_P(buf, PSTR("bed: %d"), thermalManager.wholeDegBed()); lv_label_set_text(bed, buf); #endif @@ -219,7 +219,7 @@ void lv_draw_ready_print() { itoa(thermalManager.degHotend(0), buf, 10); lv_label_set_text(labelExt1, buf); lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(0)); + sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1Target, buf); lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); @@ -227,7 +227,7 @@ void lv_draw_ready_print() { itoa(thermalManager.degHotend(1), buf, 10); lv_label_set_text(labelExt2, buf); lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(1)); + sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2Target, buf); lv_obj_align(labelExt2Target, buttonExt2, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #endif @@ -236,7 +236,7 @@ void lv_draw_ready_print() { itoa(thermalManager.degBed(), buf, 10); lv_label_set_text(labelBed, buf); lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetBed()); + sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetBed()); lv_label_set_text(labelBedTarget, buf); lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #endif @@ -257,15 +257,15 @@ void lv_draw_ready_print() { void lv_temp_refr() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); + sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.wholeDegBed(), thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); #endif - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, 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 1162f7a228..4dd092e64b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -885,7 +885,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { char *outBuf = (char *)tempBuf; char tbuf[34]; - sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); + sprintf_P(tbuf, PSTR("%d /%d"), thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0)); const int tlen = strlen(tbuf); @@ -895,7 +895,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcpy_P(outBuf, PSTR(" B:")); outBuf += 3; #if HAS_HEATED_BED - sprintf_P(outBuf, PSTR("%d /%d"), (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); + sprintf_P(outBuf, PSTR("%d /%d"), thermalManager.wholeDegBed(), thermalManager.degTargetBed()); #else strcpy_P(outBuf, PSTR("0 /0")); #endif @@ -908,7 +908,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcat_P(outBuf, PSTR(" T1:")); outBuf += 4; #if HAS_MULTI_HOTEND - sprintf_P(outBuf, PSTR("%d /%d"), (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); + sprintf_P(outBuf, PSTR("%d /%d"), thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1)); #else strcat_P(outBuf, PSTR("0 /0")); #endif @@ -918,15 +918,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { } else { sprintf_P((char *)tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"), - thermalManager.degHotend(0), thermalManager.degTargetHotend(0), + thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0), #if HAS_HEATED_BED - thermalManager.degBed(), thermalManager.degTargetBed(), + thermalManager.wholeDegBed(), thermalManager.degTargetBed(), #else 0, 0, #endif - thermalManager.degHotend(0), thermalManager.degTargetHotend(0), + thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0), #if HAS_MULTI_HOTEND - thermalManager.degHotend(1), thermalManager.degTargetHotend(1) + thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1) #else 0, 0 #endif diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index b6a8923a39..c82ea76457 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -172,9 +172,9 @@ void process_lcd_eb_command(const char *command) { sprintf_P(message_buffer, PSTR("{T0:%03i/%03i}{T1:000/000}{TP:%03i/%03i}{TQ:%03i}{TT:%s}"), - int(thermalManager.degHotend(0)), thermalManager.degTargetHotend(0), + thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0), #if HAS_HEATED_BED - int(thermalManager.degBed()), thermalManager.degTargetBed(), + thermalManager.wholeDegBed(), thermalManager.degTargetBed(), #else 0, 0, #endif @@ -303,9 +303,9 @@ void process_lcd_s_command(const char *command) { // temperature information char message_buffer[MAX_CURLY_COMMAND]; sprintf_P(message_buffer, PSTR("{T0:%03i/%03i}{T1:000/000}{TP:%03i/%03i}"), - int(thermalManager.degHotend(0)), thermalManager.degTargetHotend(0), + thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0), #if HAS_HEATED_BED - int(thermalManager.degBed()), thermalManager.degTargetBed() + thermalManager.wholeDegBed(), thermalManager.degTargetBed() #else 0, 0 #endif diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 23cf26a8ca..accca50d1e 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -918,7 +918,7 @@ namespace ExtUI { thermalManager.updatePID(); } - void startPIDTune(const_float_t temp, extruder_t tool) { + void startPIDTune(const celsius_t temp, extruder_t tool) { thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true); } #endif @@ -935,7 +935,7 @@ namespace ExtUI { thermalManager.updatePID(); } - void startBedPIDTune(const_float_t temp) { + void startBedPIDTune(const celsius_t temp) { thermalManager.PID_autotune(temp, H_BED, 4, true); } #endif diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index e04d589858..7a093ea65d 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -117,18 +117,18 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { celsius_t currentTemperature, targetTemperature; if (Heater >= 0) { // HotEnd - currentTemperature = thermalManager.degHotend(Heater); + currentTemperature = thermalManager.wholeDegHotend(Heater); targetTemperature = thermalManager.degTargetHotend(Heater); } #if HAS_HEATED_BED else if (Heater == H_BED) { - currentTemperature = thermalManager.degBed(); + currentTemperature = thermalManager.wholeDegBed(); targetTemperature = thermalManager.degTargetBed(); } #endif #if HAS_TEMP_CHAMBER else if (Heater == H_CHAMBER) { - currentTemperature = thermalManager.degChamber(); + currentTemperature = thermalManager.wholeDegChamber(); #if HAS_HEATED_CHAMBER targetTemperature = thermalManager.degTargetChamber(); #else @@ -138,7 +138,7 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { #endif #if HAS_TEMP_COOLER else if (Heater == H_COOLER) { - currentTemperature = thermalManager.degCooler(); + currentTemperature = thermalManager.wholeDegCooler(); targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO); } #endif @@ -451,7 +451,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft_string.add('E'); tft_string.add((char)('1' + extruder)); tft_string.add(' '); - tft_string.add(i16tostr3rj(thermalManager.degHotend(extruder))); + tft_string.add(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); tft_string.add(LCD_STR_DEGREE); tft_string.add(" / "); tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder))); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 5563d3069b..68457baa1c 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -117,18 +117,18 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { celsius_t currentTemperature, targetTemperature; if (Heater >= 0) { // HotEnd - currentTemperature = thermalManager.degHotend(Heater); + currentTemperature = thermalManager.wholeDegHotend(Heater); targetTemperature = thermalManager.degTargetHotend(Heater); } #if HAS_HEATED_BED else if (Heater == H_BED) { - currentTemperature = thermalManager.degBed(); + currentTemperature = thermalManager.wholeDegBed(); targetTemperature = thermalManager.degTargetBed(); } #endif #if HAS_TEMP_CHAMBER else if (Heater == H_CHAMBER) { - currentTemperature = thermalManager.degChamber(); + currentTemperature = thermalManager.wholeDegChamber(); #if HAS_HEATED_CHAMBER targetTemperature = thermalManager.degTargetChamber(); #else @@ -138,7 +138,7 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { #endif #if HAS_TEMP_COOLER else if (Heater == H_COOLER) { - currentTemperature = thermalManager.degCooler(); + currentTemperature = thermalManager.wholeDegCooler(); targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO); } #endif @@ -438,7 +438,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft_string.add('E'); tft_string.add((char)('1' + extruder)); tft_string.add(' '); - tft_string.add(i16tostr3rj(thermalManager.degHotend(extruder))); + tft_string.add(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); tft_string.add(LCD_STR_DEGREE); tft_string.add(" / "); tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder))); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 4d5a0b4fda..3150aff058 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -117,18 +117,18 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { celsius_t currentTemperature, targetTemperature; if (Heater >= 0) { // HotEnd - currentTemperature = thermalManager.degHotend(Heater); + currentTemperature = thermalManager.wholeDegHotend(Heater); targetTemperature = thermalManager.degTargetHotend(Heater); } #if HAS_HEATED_BED else if (Heater == H_BED) { - currentTemperature = thermalManager.degBed(); + currentTemperature = thermalManager.wholeDegBed(); targetTemperature = thermalManager.degTargetBed(); } #endif #if HAS_TEMP_CHAMBER else if (Heater == H_CHAMBER) { - currentTemperature = thermalManager.degChamber(); + currentTemperature = thermalManager.wholeDegChamber(); #if HAS_HEATED_CHAMBER targetTemperature = thermalManager.degTargetChamber(); #else @@ -138,7 +138,7 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { #endif #if HAS_TEMP_COOLER else if (Heater == H_COOLER) { - currentTemperature = thermalManager.degCooler(); + currentTemperature = thermalManager.wholeDegCooler(); targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO); } #endif @@ -438,7 +438,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft_string.add('E'); tft_string.add((char)('1' + extruder)); tft_string.add(' '); - tft_string.add(i16tostr3rj(thermalManager.degHotend(extruder))); + tft_string.add(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); tft_string.add(LCD_STR_DEGREE); tft_string.add(" / "); tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder))); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 910db87f55..be991c1d52 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -383,8 +383,8 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { DEBUG_EOL(); - TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.degHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0)); - TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.degBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating()); + TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0)); + TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating()); } #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1ad0303abd..3c8d55c630 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -499,7 +499,7 @@ volatile bool Temperature::raw_temps_ready = false; * Needs sufficient heater power to make some overshoot at target * temperature to succeed. */ - void Temperature::PID_autotune(const_float_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) { + void Temperature::PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) { float current_temp = 0.0; int cycles = 0; bool heating = true; @@ -3815,10 +3815,10 @@ void Temperature::isr() { #define MIN_DELTA_SLOPE_TIME_PROBE 600 #endif - bool Temperature::wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling/*=true*/) { + bool Temperature::wait_for_probe(const celsius_t target_temp, bool no_wait_for_cooling/*=true*/) { - const bool wants_to_cool = isProbeAboveTemp(target_temp); - const bool will_wait = !(wants_to_cool && no_wait_for_cooling); + const bool wants_to_cool = isProbeAboveTemp(target_temp), + will_wait = !(wants_to_cool && no_wait_for_cooling); if (will_wait) SERIAL_ECHOLNPAIR("Waiting for probe to ", (wants_to_cool ? PSTR("cool down") : PSTR("heat up")), " to ", target_temp, " degrees."); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 318cdaf075..a7d41b36f9 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -358,12 +358,8 @@ class Temperature { static bool allow_cold_extrude; static celsius_t extrude_min_temp; static inline bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } - static inline bool tooColdToExtrude(const uint8_t E_NAME) { - return tooCold(degHotend(HOTEND_INDEX)); - } - static inline bool targetTooColdToExtrude(const uint8_t E_NAME) { - return tooCold(degTargetHotend(HOTEND_INDEX)); - } + static inline bool tooColdToExtrude(const uint8_t E_NAME) { return tooCold(wholeDegHotend(HOTEND_INDEX)); } + static inline bool targetTooColdToExtrude(const uint8_t E_NAME) { return tooCold(degTargetHotend(HOTEND_INDEX)); } #else static inline bool tooColdToExtrude(const uint8_t) { return false; } static inline bool targetTooColdToExtrude(const uint8_t) { return false; } @@ -635,6 +631,10 @@ class Temperature { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius); } + static inline celsius_t wholeDegHotend(const uint8_t E_NAME) { + return TERN0(HAS_HOTEND, static_cast(temp_hotend[HOTEND_INDEX].celsius + 0.5f)); + } + #if ENABLED(SHOW_TEMP_ADC_VALUES) static inline int16_t rawHotendTemp(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw); @@ -687,11 +687,11 @@ class Temperature { #endif static inline bool still_heating(const uint8_t e) { - return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS; + return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(wholeDegHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS; } - static inline bool degHotendNear(const uint8_t e, const_float_t temp) { - return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS); + static inline bool degHotendNear(const uint8_t e, const celsius_t temp) { + return ABS(wholeDegHotend(e) - temp) < (TEMP_HYSTERESIS); } #endif // HAS_HOTEND @@ -702,6 +702,7 @@ class Temperature { static inline int16_t rawBedTemp() { return temp_bed.raw; } #endif static inline celsius_t degBed() { return temp_bed.celsius; } + static inline celsius_t wholeDegBed() { return static_cast(degBed() + 0.5f); } static inline celsius_t degTargetBed() { return temp_bed.target; } static inline bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } static inline bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } @@ -726,8 +727,8 @@ class Temperature { static void wait_for_bed_heating(); - static inline bool degBedNear(const_float_t temp) { - return ABS(degBed() - temp) < (TEMP_BED_HYSTERESIS); + static inline bool degBedNear(const celsius_t temp) { + return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); } #endif // HAS_HEATED_BED @@ -737,9 +738,10 @@ class Temperature { static inline int16_t rawProbeTemp() { return temp_probe.raw; } #endif static inline celsius_t degProbe() { return temp_probe.celsius; } - static inline bool isProbeBelowTemp(const_float_t target_temp) { return temp_probe.celsius < target_temp; } - static inline bool isProbeAboveTemp(const_float_t target_temp) { return temp_probe.celsius > target_temp; } - static bool wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling=true); + static inline celsius_t wholeDegProbe() { return static_cast(degProbe() + 0.5f); } + static inline bool isProbeBelowTemp(const celsius_t target_temp) { return wholeDegProbe() < target_temp; } + static inline bool isProbeAboveTemp(const celsius_t target_temp) { return wholeDegProbe() > target_temp; } + static bool wait_for_probe(const celsius_t target_temp, bool no_wait_for_cooling=true); #endif #if WATCH_PROBE @@ -753,6 +755,7 @@ class Temperature { static inline int16_t rawChamberTemp() { return temp_chamber.raw; } #endif static inline celsius_t degChamber() { return temp_chamber.celsius; } + static inline celsius_t wholeDegChamber() { return static_cast(degChamber() + 0.5f); } #if HAS_HEATED_CHAMBER static inline celsius_t degTargetChamber() { return temp_chamber.target; } static inline bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } @@ -779,6 +782,7 @@ class Temperature { static inline int16_t rawCoolerTemp() { return temp_cooler.raw; } #endif static inline celsius_t degCooler() { return temp_cooler.celsius; } + static inline celsius_t wholeDegCooler() { return static_cast(temp_cooler.celsius + 0.5f); } #if HAS_COOLER static inline celsius_t degTargetCooler() { return temp_cooler.target; } static inline bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } @@ -827,7 +831,7 @@ class Temperature { static bool pid_debug_flag; #endif - static void PID_autotune(const_float_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false); + static void PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false); #if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING) static bool adaptive_fan_slowing; From 46f272b66945e4f2fb6e191b83cebeaa57e496f5 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Fri, 23 Apr 2021 22:29:15 -0300 Subject: [PATCH 270/311] Fix Celsius precision, current temp accessors (#21678) --- Marlin/src/module/temperature.cpp | 14 +++++++------- Marlin/src/module/temperature.h | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 3c8d55c630..8e2b2d6b91 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -500,7 +500,7 @@ volatile bool Temperature::raw_temps_ready = false; * temperature to succeed. */ void Temperature::PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) { - float current_temp = 0.0; + celsius_float_t current_temp = 0.0; int cycles = 0; bool heating = true; @@ -1668,7 +1668,7 @@ void Temperature::manage_heater() { SERIAL_EOL(); } - celsius_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) { + celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) { //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB) // static uint32_t clocks_total = 0; // static uint32_t calls = 0; @@ -1717,7 +1717,7 @@ void Temperature::manage_heater() { #if HAS_HOTEND // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. - celsius_t Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) { + celsius_float_t 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(e); @@ -1826,7 +1826,7 @@ void Temperature::manage_heater() { #if HAS_HEATED_BED // For bed temperature measurement. - celsius_t Temperature::analog_to_celsius_bed(const int raw) { + celsius_float_t Temperature::analog_to_celsius_bed(const int raw) { #if TEMP_SENSOR_BED_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BED, raw); #elif TEMP_SENSOR_BED_IS_THERMISTOR @@ -1844,7 +1844,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_CHAMBER // For chamber temperature measurement. - celsius_t Temperature::analog_to_celsius_chamber(const int raw) { + celsius_float_t Temperature::analog_to_celsius_chamber(const int raw) { #if TEMP_SENSOR_CHAMBER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_CHAMBER, raw); #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR @@ -1862,7 +1862,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_COOLER // For cooler temperature measurement. - celsius_t Temperature::analog_to_celsius_cooler(const int raw) { + celsius_float_t Temperature::analog_to_celsius_cooler(const int raw) { #if TEMP_SENSOR_COOLER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_COOLER, raw); #elif TEMP_SENSOR_COOLER_IS_THERMISTOR @@ -1880,7 +1880,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_PROBE // For probe temperature measurement. - celsius_t Temperature::analog_to_celsius_probe(const int raw) { + celsius_float_t Temperature::analog_to_celsius_probe(const int raw) { #if TEMP_SENSOR_PROBE_IS_CUSTOM return user_thermistor_to_deg_c(CTI_PROBE, raw); #elif TEMP_SENSOR_PROBE_IS_THERMISTOR diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index a7d41b36f9..b7d52e8a08 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -179,7 +179,7 @@ enum ADCSensorState : char { typedef struct TempInfo { uint16_t acc; int16_t raw; - celsius_t celsius; + celsius_float_t celsius; inline void reset() { acc = 0; } inline void sample(const uint16_t s) { acc += s; } inline void update() { raw = acc; } @@ -501,7 +501,7 @@ class Temperature { static user_thermistor_t user_thermistor[USER_THERMISTORS]; static void log_user_thermistor(const uint8_t t_index, const bool eprom=false); static void reset_user_thermistors(); - static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw); + static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw); static inline bool set_pull_up_res(int8_t t_index, float value) { //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false; if (!WITHIN(value, 1, 1000000)) return false; @@ -529,19 +529,19 @@ class Temperature { #endif #if HAS_HOTEND - static celsius_t analog_to_celsius_hotend(const int raw, const uint8_t e); + static celsius_float_t analog_to_celsius_hotend(const int raw, const uint8_t e); #endif #if HAS_HEATED_BED - static celsius_t analog_to_celsius_bed(const int raw); + static celsius_float_t analog_to_celsius_bed(const int raw); #endif #if HAS_TEMP_PROBE - static celsius_t analog_to_celsius_probe(const int raw); + static celsius_float_t analog_to_celsius_probe(const int raw); #endif #if HAS_TEMP_CHAMBER - static celsius_t analog_to_celsius_chamber(const int raw); + static celsius_float_t analog_to_celsius_chamber(const int raw); #endif #if HAS_TEMP_COOLER - static celsius_t analog_to_celsius_cooler(const int raw); + static celsius_float_t analog_to_celsius_cooler(const int raw); #endif #if HAS_FAN @@ -627,7 +627,7 @@ class Temperature { //inline so that there is no performance decrease. //deg=degreeCelsius - static inline celsius_t degHotend(const uint8_t E_NAME) { + static inline celsius_float_t degHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius); } @@ -701,7 +701,7 @@ class Temperature { #if ENABLED(SHOW_TEMP_ADC_VALUES) static inline int16_t rawBedTemp() { return temp_bed.raw; } #endif - static inline celsius_t degBed() { return temp_bed.celsius; } + static inline celsius_float_t degBed() { return temp_bed.celsius; } static inline celsius_t wholeDegBed() { return static_cast(degBed() + 0.5f); } static inline celsius_t degTargetBed() { return temp_bed.target; } static inline bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } @@ -737,7 +737,7 @@ class Temperature { #if ENABLED(SHOW_TEMP_ADC_VALUES) static inline int16_t rawProbeTemp() { return temp_probe.raw; } #endif - static inline celsius_t degProbe() { return temp_probe.celsius; } + static inline celsius_float_t degProbe() { return temp_probe.celsius; } static inline celsius_t wholeDegProbe() { return static_cast(degProbe() + 0.5f); } static inline bool isProbeBelowTemp(const celsius_t target_temp) { return wholeDegProbe() < target_temp; } static inline bool isProbeAboveTemp(const celsius_t target_temp) { return wholeDegProbe() > target_temp; } @@ -754,7 +754,7 @@ class Temperature { #if ENABLED(SHOW_TEMP_ADC_VALUES) static inline int16_t rawChamberTemp() { return temp_chamber.raw; } #endif - static inline celsius_t degChamber() { return temp_chamber.celsius; } + static inline celsius_float_t degChamber() { return temp_chamber.celsius; } static inline celsius_t wholeDegChamber() { return static_cast(degChamber() + 0.5f); } #if HAS_HEATED_CHAMBER static inline celsius_t degTargetChamber() { return temp_chamber.target; } @@ -781,7 +781,7 @@ class Temperature { #if ENABLED(SHOW_TEMP_ADC_VALUES) static inline int16_t rawCoolerTemp() { return temp_cooler.raw; } #endif - static inline celsius_t degCooler() { return temp_cooler.celsius; } + static inline celsius_float_t degCooler() { return temp_cooler.celsius; } static inline celsius_t wholeDegCooler() { return static_cast(temp_cooler.celsius + 0.5f); } #if HAS_COOLER static inline celsius_t degTargetCooler() { return temp_cooler.target; } From 0fe30d14a810a43f930c4558eab6ec1842515614 Mon Sep 17 00:00:00 2001 From: Jim Hyslop Date: Sat, 24 Apr 2021 01:08:46 -0400 Subject: [PATCH 271/311] Don't display service prompt unless needed (#21654) --- Marlin/src/module/printcounter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index 2728b8d5a9..4c5f1fc782 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -319,6 +319,7 @@ void PrintCounter::reset() { } bool PrintCounter::needsService(const int index) { + if (!loaded) loadStats(); switch (index) { #if SERVICE_INTERVAL_1 > 0 case 1: return data.nextService1 == 0; From 949d2d9e50d34d7b2111a6c23e153687f59a1b2d Mon Sep 17 00:00:00 2001 From: ellensp Date: Sat, 24 Apr 2021 17:11:11 +1200 Subject: [PATCH 272/311] Fix MP_SCARA compile (#21686) --- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/SanityCheck.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 7ae1d8dccd..78a6f2c821 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -921,7 +921,7 @@ #define NORMAL_AXIS Z_AXIS #endif -#if EITHER(MORGAN_SCARA, AXEL_TPARA) +#if ANY(MORGAN_SCARA, MP_SCARA, AXEL_TPARA) #define IS_SCARA 1 #define IS_KINEMATIC 1 #elif ENABLED(DELTA) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 58d52733e8..a8e3b161eb 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1251,7 +1251,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Allow only one kinematic type to be defined */ -#if MANY(DELTA, MORGAN_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY) +#if MANY(DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY) #error "Please enable only one of DELTA, MORGAN_SCARA, AXEL_TPARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, COREZY, or MARKFORGED_XY." #endif From 5dfe28db2a68c2765ff6742fe7e53e11174e43b5 Mon Sep 17 00:00:00 2001 From: unknownlamer <72777654+unknownlamer@users.noreply.github.com> Date: Sat, 24 Apr 2021 01:59:31 -0400 Subject: [PATCH 273/311] MCP4451 Digipot Support for Azteeg X5 GT (#21680) --- Marlin/src/feature/digipot/digipot_mcp4451.cpp | 3 +++ Marlin/src/inc/SanityCheck.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/digipot/digipot_mcp4451.cpp b/Marlin/src/feature/digipot/digipot_mcp4451.cpp index 1b4cf43923..ba5ecdad05 100644 --- a/Marlin/src/feature/digipot/digipot_mcp4451.cpp +++ b/Marlin/src/feature/digipot/digipot_mcp4451.cpp @@ -40,6 +40,9 @@ #elif MB(AZTEEG_X5_MINI, AZTEEG_X5_MINI_WIFI) #define DIGIPOT_I2C_FACTOR 113.5f #define DIGIPOT_I2C_MAX_CURRENT 2.0f +#elif MB(AZTEEG_X5_GT) + #define DIGIPOT_I2C_FACTOR 51.0f + #define DIGIPOT_I2C_MAX_CURRENT 3.0f #else #define DIGIPOT_I2C_FACTOR 106.7f #define DIGIPOT_I2C_MAX_CURRENT 2.5f diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a8e3b161eb..5a9d6e6040 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2846,7 +2846,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if HAS_MOTOR_CURRENT_I2C #if BOTH(DIGIPOT_MCP4018, DIGIPOT_MCP4451) #error "Enable only one of DIGIPOT_MCP4018 or DIGIPOT_MCP4451." - #elif !MB(MKS_SBASE) \ +#elif !MB(MKS_SBASE, AZTEEG_X5_GT, AZTEEG_X5_MINI, AZTEEG_X5_MINI_WIFI) \ && (!defined(DIGIPOTS_I2C_SDA_X) || !defined(DIGIPOTS_I2C_SDA_Y) || !defined(DIGIPOTS_I2C_SDA_Z) || !defined(DIGIPOTS_I2C_SDA_E0) || !defined(DIGIPOTS_I2C_SDA_E1)) #error "DIGIPOT_MCP4018/4451 requires DIGIPOTS_I2C_SDA_* pins to be defined." #endif From 8b5e7429d7b874e9a9d1a6afbba74c11b36813ba Mon Sep 17 00:00:00 2001 From: Sebastiaan Dammann Date: Sat, 24 Apr 2021 08:01:17 +0200 Subject: [PATCH 274/311] Prevent extrusion on M600 un-park (#21670) Fixes #21669 --- Marlin/src/feature/pause.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 6552eaa42c..867502712c 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -602,7 +602,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ if (!axes_should_home()) { // Move XY back to saved position - destination.set(resume_position.x, resume_position.y, current_position.z); + destination.set(resume_position.x, resume_position.y, current_position.z, current_position.e); prepare_internal_move_to_destination(NOZZLE_PARK_XY_FEEDRATE); // Move Z back to saved position From f424da498a8fabf19a7bdabe23c6d843cd4a5191 Mon Sep 17 00:00:00 2001 From: vyacheslav-shubin Date: Sat, 24 Apr 2021 09:16:14 +0300 Subject: [PATCH 275/311] ExtUI::onPostprocessSettings (#21683) --- Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp | 4 ++++ Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp | 4 ++++ Marlin/src/lcd/extui/dgus_lcd.cpp | 4 ++++ Marlin/src/lcd/extui/example.cpp | 4 ++++ Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp | 4 ++++ Marlin/src/lcd/extui/malyan_lcd.cpp | 1 + Marlin/src/lcd/extui/nextion_lcd.cpp | 4 ++++ Marlin/src/lcd/extui/ui_api.h | 1 + Marlin/src/module/settings.cpp | 2 ++ 9 files changed, 28 insertions(+) diff --git a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp index 10c791cbc5..2ec5104310 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp @@ -88,6 +88,10 @@ namespace ExtUI { // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } + void onPostprocessSettings() { + // Called after loading or resetting stored settings + } + void onConfigurationStoreWritten(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. diff --git a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp index a98da07959..fb66d1f68e 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp @@ -79,6 +79,10 @@ namespace ExtUI { // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } + void onPostprocessSettings() { + // Called after loading or resetting stored settings + } + void onConfigurationStoreWritten(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. diff --git a/Marlin/src/lcd/extui/dgus_lcd.cpp b/Marlin/src/lcd/extui/dgus_lcd.cpp index 73542090c5..4776ceb154 100644 --- a/Marlin/src/lcd/extui/dgus_lcd.cpp +++ b/Marlin/src/lcd/extui/dgus_lcd.cpp @@ -98,6 +98,10 @@ namespace ExtUI { // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } + void onPostprocessSettings() { + // Called after loading or resetting stored settings + } + void onConfigurationStoreWritten(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. diff --git a/Marlin/src/lcd/extui/example.cpp b/Marlin/src/lcd/extui/example.cpp index 38986fba73..8f00d26fd8 100644 --- a/Marlin/src/lcd/extui/example.cpp +++ b/Marlin/src/lcd/extui/example.cpp @@ -84,6 +84,10 @@ namespace ExtUI { // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } + void onPostprocessSettings() { + // Called after loading or resetting stored settings + } + void onConfigurationStoreWritten(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp index 8193ec24d4..b3a9e42766 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp @@ -113,6 +113,10 @@ namespace ExtUI { InterfaceSettingsScreen::loadSettings(buff); } + void onPostprocessSettings() { + // Called after loading or resetting stored settings + } + void onConfigurationStoreWritten(bool success) { #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE if (success && InterfaceSettingsScreen::backupEEPROM()) { diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index c82ea76457..b4e2e328e4 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -519,6 +519,7 @@ namespace ExtUI { void onFactoryReset() {} void onStoreSettings(char*) {} void onLoadSettings(const char*) {} + void onPostprocessSettings() {} void onConfigurationStoreWritten(bool) {} void onConfigurationStoreRead(bool) {} diff --git a/Marlin/src/lcd/extui/nextion_lcd.cpp b/Marlin/src/lcd/extui/nextion_lcd.cpp index fa45f4ef51..2ec8eeb30e 100644 --- a/Marlin/src/lcd/extui/nextion_lcd.cpp +++ b/Marlin/src/lcd/extui/nextion_lcd.cpp @@ -75,6 +75,10 @@ namespace ExtUI { // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } + void onPostprocessSettings() { + // Called after loading or resetting stored settings + } + void onConfigurationStoreWritten(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index ba633741f7..04395bec4e 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -389,6 +389,7 @@ namespace ExtUI { void onFactoryReset(); void onStoreSettings(char *); void onLoadSettings(const char *); + void onPostprocessSettings(); void onConfigurationStoreWritten(bool success); void onConfigurationStoreRead(bool success); #if ENABLED(POWER_LOSS_RECOVERY) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 4273c4b062..13c01954a0 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -533,6 +533,8 @@ void MarlinSettings::postprocess() { TERN_(CASELIGHT_USES_BRIGHTNESS, caselight.update_brightness()); + TERN_(EXTENSIBLE_UI, ExtUI::onPostprocessSettings()); + // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm // and init stepper.count[], planner.position[] with current_position planner.refresh_positioning(); From a73dce4a56447cc9d81224ef9e19a42114765e25 Mon Sep 17 00:00:00 2001 From: Ryan Finnie Date: Fri, 23 Apr 2021 23:26:17 -0700 Subject: [PATCH 276/311] Clean up / improve generate_version script (#21674) --- buildroot/bin/generate_version | 58 ++++++++++++++-------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/buildroot/bin/generate_version b/buildroot/bin/generate_version index b88e3de918..70a108b1fe 100755 --- a/buildroot/bin/generate_version +++ b/buildroot/bin/generate_version @@ -4,47 +4,35 @@ # # Make a Version.h file to accompany CUSTOM_VERSION_FILE # +# Authors: jbrazio, thinkyhead, InsanityAutomation, rfinnie +# -DIR=${1:-"Marlin"} +set -e -# MRCC3=$( git merge-base HEAD upstream/bugfix-2.0.x 2>/dev/null ) -# MRCC2=$( git merge-base HEAD upstream/bugfix-1.1.x 2>/dev/null ) -# MRCC1=$( git merge-base HEAD upstream/1.1.x 2>/dev/null ) +DIR="${1:-Marlin}" +READ_FILE="${READ_FILE:-${DIR}/Version.h}" +WRITE_FILE="${WRITE_FILE:-${READ_FILE}}" -# BASE='?' -# if [[ -n $MRCC3 && $MRCC3 != $MRCC2 ]]; then -# BASE=bugfix-2.0.x -# elif [[ -n $MRCC2 ]]; then -# BASE=bugfix-1.1.x -# elif [[ -n $MRCC1 ]]; then -# BASE=1.1.x -# fi +BRANCH="$(git -C "${DIR}" symbolic-ref -q --short HEAD 2>/dev/null || true)" +VERSION="$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null || true)" -BUILDATE=$(date '+%s') -DISTDATE=$(date '+%Y-%m-%d %H:%M') - -BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD) -VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null) - -[ -z "${BRANCH}" ] && BRANCH=$(echo "${TRAVIS_BRANCH}") -[ -z "${VERSION}" ] && VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null) - -SHORT_BUILD_VERSION=$(echo "${BRANCH}") -DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}") +STRING_DISTRIBUTION_DATE="${STRING_DISTRIBUTION_DATE:-$(date '+%Y-%m-%d %H:%M')}" +SHORT_BUILD_VERSION="${SHORT_BUILD_VERSION:-${BRANCH}}" +DETAILED_BUILD_VERSION="${DETAILED_BUILD_VERSION:-${BRANCH}-${VERSION}}" # Gets some misc options from their defaults -DEFAULT_MACHINE_UUID=$(awk -F'"' \ - '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${DIR}/Version.h") -MACHINE_NAME=$(awk -F'"' \ - '/#define MACHINE_NAME/{ print $2 }' < "${DIR}/Version.h") -PROTOCOL_VERSION=$(awk -F'"' \ - '/#define PROTOCOL_VERSION/{ print $2 }' < "${DIR}/Version.h") -SOURCE_CODE_URL=$(awk -F'"' \ - '/#define SOURCE_CODE_URL/{ print $2 }' < "${DIR}/Version.h") -WEBSITE_URL=$(awk -F'"' \ - '/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h") +DEFAULT_MACHINE_UUID="${DEFAULT_MACHINE_UUID:-$(awk -F'"' \ + '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${READ_FILE}")}" +MACHINE_NAME="${MACHINE_NAME:-$(awk -F'"' \ + '/#define MACHINE_NAME/{ print $2 }' < "${READ_FILE}")}" +PROTOCOL_VERSION="${PROTOCOL_VERSION:-$(awk -F'"' \ + '/#define PROTOCOL_VERSION/{ print $2 }' < "${READ_FILE}")}" +SOURCE_CODE_URL="${SOURCE_CODE_URL:-$(awk -F'"' \ + '/#define SOURCE_CODE_URL/{ print $2 }' < "${READ_FILE}")}" +WEBSITE_URL="${WEBSITE_URL:-$(awk -F'"' \ + '/#define WEBSITE_URL/{ print $2 }' < "${READ_FILE}")}" -cat > "${DIR}/Version.h" < "${WRITE_FILE}" < "${DIR}/Version.h" < Date: Sat, 24 Apr 2021 01:29:30 -0500 Subject: [PATCH 277/311] Move last bootscreen delay to end of setup (#21665) --- Marlin/src/MarlinCore.cpp | 11 ++++++++++- Marlin/src/core/utility.cpp | 12 ++++++++++++ Marlin/src/core/utility.h | 8 ++++++-- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 2 ++ Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 5 ++++- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 16 ++++++++++------ Marlin/src/lcd/marlinui.h | 1 + Marlin/src/lcd/tft/ui_320x240.cpp | 7 ++++++- Marlin/src/lcd/tft/ui_480x320.cpp | 7 ++++++- 9 files changed, 57 insertions(+), 12 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 668f977b03..6cb51bc577 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1214,8 +1214,9 @@ void setup() { DWIN_UpdateLCD(); // Show bootscreen (first image) #else SETUP_RUN(ui.init()); - #if HAS_WIRED_LCD && ENABLED(SHOW_BOOTSCREEN) + #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) SETUP_RUN(ui.show_bootscreen()); + const millis_t bootscreen_ms = millis(); #endif SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) #endif @@ -1501,6 +1502,14 @@ void setup() { SETUP_RUN(tft_lvgl_init()); #endif + #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) + const millis_t elapsed = millis() - bootscreen_ms; + #if ENABLED(MARLIN_DEV_MODE) + SERIAL_ECHOLNPAIR("elapsed=", elapsed); + #endif + SETUP_RUN(ui.bootscreen_completion(elapsed)); + #endif + #if ENABLED(PASSWORD_ON_STARTUP) SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided #endif diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 3d7897f95a..385a572029 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -35,6 +35,18 @@ void safe_delay(millis_t ms) { thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made } +#if ENABLED(MARLIN_DEV_MODE) + void early_safe_delay(millis_t ms) { + while (ms > 50) { + ms -= 50; + delay(50); + watchdog_refresh(); + } + delay(ms); + watchdog_refresh(); + } +#endif + // A delay to provide brittle hosts time to receive bytes #if ENABLED(SERIAL_OVERRUN_PROTECTION) diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index aaa241d460..0e1c109be1 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -25,8 +25,12 @@ #include "../core/types.h" #include "../core/millis_t.h" -// Delay that ensures heaters and watchdog are kept alive -void safe_delay(millis_t ms); +void safe_delay(millis_t ms); // Delay ensuring that temperatures are updated and the watchdog is kept alive. +#if ENABLED(MARLIN_DEV_MODE) + void early_safe_delay(millis_t ms); // Delay ensuring that the watchdog is kept alive. Can be used before the Temperature ISR starts. +#else + inline void early_safe_delay(millis_t ms) { safe_delay(ms); } +#endif #if ENABLED(SERIAL_OVERRUN_PROTECTION) void serial_delay(const millis_t ms); diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index e91213b5b7..75ff1f52c2 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -486,7 +486,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); } CENTER_OR_SCROLL(STRING_SPLASH_LINE3, 1500); #endif } + } + void MarlinUI::bootscreen_completion(const millis_t) { lcd.clear(); safe_delay(100); set_custom_characters(CHARSET_INFO); diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 31cdc4ac30..edb17b69c0 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -397,7 +397,10 @@ static void center_text_P(PGM_P pstart, uint8_t y) { center_text_P(PSTR(MARLIN_WEBSITE_URL), 4); picBits = ICON_LOGO; lcd.print_screen(); - safe_delay(1500); + } + + void MarlinUI::bootscreen_completion(const millis_t sofar) { + if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar); } #endif // SHOW_BOOTSCREEN diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index f298e7be8b..1fdc291642 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -160,20 +160,21 @@ bool MarlinUI::detected() { return true; } #endif u8g.firstPage(); do { draw_custom_bootscreen(f); } while (u8g.nextPage()); - if (frame_time) safe_delay(frame_time); + if (frame_time) early_safe_delay(frame_time); } #ifndef CUSTOM_BOOTSCREEN_TIMEOUT #define CUSTOM_BOOTSCREEN_TIMEOUT 2500 #endif #if CUSTOM_BOOTSCREEN_TIMEOUT - safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); + early_safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); #endif } #endif // SHOW_CUSTOM_BOOTSCREEN // Two-part needed to display all info constexpr bool two_part = ((LCD_PIXEL_HEIGHT) - (START_BMPHEIGHT)) < ((MENU_FONT_ASCENT) * 2); + constexpr uint8_t bootscreen_pages = 1 + two_part; // Draw the static Marlin bootscreen from a u8g loop // or the animated boot screen within its own u8g loop @@ -225,17 +226,16 @@ bool MarlinUI::detected() { return true; } constexpr millis_t frame_time = MARLIN_BOOTSCREEN_FRAME_TIME; LOOP_L_N(f, COUNT(marlin_bootscreen_animation)) { draw_bootscreen_bmp((uint8_t*)pgm_read_ptr(&marlin_bootscreen_animation[f])); - if (frame_time) safe_delay(frame_time); + if (frame_time) early_safe_delay(frame_time); } #endif } // Show the Marlin bootscreen, with the u8g loop and delays void MarlinUI::show_marlin_bootscreen() { - constexpr uint8_t pages = two_part ? 2 : 1; - for (uint8_t q = pages; q--;) { + for (uint8_t q = bootscreen_pages; q--;) { draw_marlin_bootscreen(q == 0); - safe_delay((BOOTSCREEN_TIMEOUT) / pages); + if (q) early_safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages); } } @@ -244,6 +244,10 @@ bool MarlinUI::detected() { return true; } show_marlin_bootscreen(); } + void MarlinUI::bootscreen_completion(const millis_t sofar) { + if ((BOOTSCREEN_TIMEOUT) / bootscreen_pages > sofar) safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages - sofar); + } + #endif // SHOW_BOOTSCREEN #if ENABLED(LIGHTWEIGHT_UI) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 24fedb039e..8cbb9ebd19 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -337,6 +337,7 @@ public: static void draw_marlin_bootscreen(const bool line2=false); static void show_marlin_bootscreen(); static void show_bootscreen(); + static void bootscreen_completion(const millis_t sofar); #endif #if HAS_MARLINUI_U8GLIB diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 68457baa1c..8e7365932b 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -60,6 +60,7 @@ void MarlinUI::tft_idle() { } #if ENABLED(SHOW_BOOTSCREEN) + void MarlinUI::show_bootscreen() { tft.queue.reset(); @@ -81,9 +82,13 @@ void MarlinUI::tft_idle() { #endif tft.queue.sync(); - safe_delay(BOOTSCREEN_TIMEOUT); + } + + void MarlinUI::bootscreen_completion(const millis_t sofar) { + if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar); clear_lcd(); } + #endif void MarlinUI::draw_kill_screen() { diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 3150aff058..0d7e01683f 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -60,6 +60,7 @@ void MarlinUI::tft_idle() { } #if ENABLED(SHOW_BOOTSCREEN) + void MarlinUI::show_bootscreen() { tft.queue.reset(); @@ -81,9 +82,13 @@ void MarlinUI::tft_idle() { #endif tft.queue.sync(); - safe_delay(BOOTSCREEN_TIMEOUT); + } + + void MarlinUI::bootscreen_completion(const millis_t sofar) { + if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar); clear_lcd(); } + #endif void MarlinUI::draw_kill_screen() { From e7f26cabfe1121dfbb9b561e0538c2bae45c4bf5 Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Sat, 24 Apr 2021 10:42:44 +0300 Subject: [PATCH 278/311] Fix Bed Tramming 5th point (#21646) --- .../src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp index 539c7639dc..c87de7caa0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_tramming_pos_settings.cpp @@ -81,7 +81,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { value = level_pos_y4; break; case ID_MANUAL_POS_X5: - value = level_pos_y5; + value = level_pos_x5; break; case ID_MANUAL_POS_Y5: value = level_pos_y5; @@ -128,7 +128,7 @@ void lv_draw_tramming_pos_settings() { else { itoa(gCfgItems.trammingPos[4].x, public_buf_l, 10); itoa(gCfgItems.trammingPos[4].y, buf2, 10); - lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y5, 0, buf2, ID_MANUAL_POS_X5, public_buf_l); + lv_screen_menu_item_2_edit(scr, leveling_menu.position5, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y5, 0, buf2, ID_MANUAL_POS_X5, 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_MANUAL_POS_UP, true); } From 7a8e3cc258bf75be1bfb7d7e43cb3f2f1aabad5b Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Sat, 24 Apr 2021 09:52:34 +0200 Subject: [PATCH 279/311] Avoid + 0.0f in menu items (#21642) --- Marlin/src/lcd/menu/menu_item.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index d3ec359fb1..bcd93e11f8 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -111,17 +111,17 @@ class TMenuEditItem : MenuEditItemBase { // These items call the Edit Item draw method passing the prepared string. #define __DOFIXfloat PROBE() #define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V))) -#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \ +#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, ETC...) \ struct MenuEditItemInfo_##NAME { \ typedef TYPE type_t; \ - static inline float scale(const_float_t value) { return value * (SCALE) + (V+0); } \ - static inline float unscale(const_float_t value) { return value / (SCALE) + (V+0); } \ + static inline float scale(const_float_t value) { return value * (SCALE) ETC; } \ + static inline float unscale(const_float_t value) { return value / (SCALE) ETC; } \ static inline const char* strfunc(const_float_t value) { return STRFUNC(_DOFIX(TYPE,value)); } \ }; \ typedef TMenuEditItem MenuItem_##NAME -// NAME TYPE STRFUNC SCALE +ROUND -DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, 0.5f); // 100% right-justified +// NAME TYPE STRFUNC SCALE ROUND +DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, +0.5f); // 100% right-justified DEFINE_MENU_EDIT_ITEM_TYPE(percent_3 ,uint8_t ,pcttostrpctrj , 1 ); // 100% right-justified DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified From d3a2c6a0b47fba8f560ff9ea60e73eb2610ff527 Mon Sep 17 00:00:00 2001 From: fedetony <45215920+fedetony@users.noreply.github.com> Date: Sat, 24 Apr 2021 09:53:52 +0200 Subject: [PATCH 280/311] Soft Reset via Serial or post-kill button click (#21652) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 6 ++++++ Marlin/src/HAL/AVR/HAL.cpp | 9 +++++++++ Marlin/src/HAL/AVR/HAL.h | 2 +- Marlin/src/HAL/DUE/HAL.cpp | 2 ++ Marlin/src/HAL/DUE/HAL.h | 2 +- Marlin/src/HAL/ESP32/HAL.cpp | 2 ++ Marlin/src/HAL/ESP32/HAL.h | 2 +- Marlin/src/HAL/LINUX/HAL.cpp | 2 ++ Marlin/src/HAL/LINUX/HAL.h | 2 +- Marlin/src/HAL/LPC1768/HAL.cpp | 4 +++- Marlin/src/HAL/LPC1768/HAL.h | 2 +- Marlin/src/HAL/SAMD51/HAL.cpp | 2 ++ Marlin/src/HAL/SAMD51/HAL.h | 2 +- Marlin/src/HAL/STM32/HAL.cpp | 6 ++++-- Marlin/src/HAL/STM32/HAL.h | 2 +- Marlin/src/HAL/STM32F1/HAL.cpp | 4 +++- Marlin/src/HAL/STM32F1/HAL.h | 2 +- Marlin/src/HAL/TEENSY31_32/HAL.cpp | 2 ++ Marlin/src/HAL/TEENSY31_32/HAL.h | 3 +-- Marlin/src/HAL/TEENSY35_36/HAL.cpp | 2 ++ Marlin/src/HAL/TEENSY35_36/HAL.h | 2 +- Marlin/src/HAL/TEENSY40_41/HAL.cpp | 2 ++ Marlin/src/HAL/TEENSY40_41/HAL.h | 2 ++ Marlin/src/MarlinCore.cpp | 18 ++++++++++-------- Marlin/src/feature/e_parser.h | 20 ++++++++++++++++++++ Marlin/src/gcode/gcode_d.cpp | 7 ++++++- Marlin/src/inc/SanityCheck.h | 9 ++++++++- Marlin/src/lcd/marlinui.h | 2 +- buildroot/tests/LPC1768 | 2 +- 29 files changed, 97 insertions(+), 27 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index ac9b49fe4d..d72feab433 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3976,3 +3976,9 @@ * a crash from a remote location. Requires ~400 bytes of SRAM and 5Kb of flash. */ //#define POSTMORTEM_DEBUGGING + +/** + * Software Reset options + */ +//#define SOFT_RESET_VIA_SERIAL // 'KILL' and '^X' commands will soft-reset the controller +//#define SOFT_RESET_ON_KILL // Use a digital button to soft-reset the controller after KILL diff --git a/Marlin/src/HAL/AVR/HAL.cpp b/Marlin/src/HAL/AVR/HAL.cpp index cfa9e47f18..708583b262 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -58,6 +58,15 @@ void HAL_init() { #endif } +void HAL_reboot() { + #if ENABLED(USE_WATCHDOG) + while (1) { /* run out the watchdog */ } + #else + void (*resetFunc)() = 0; // Declare resetFunc() at address 0 + resetFunc(); // Jump to address 0 + #endif +} + #if ENABLED(SDSUPPORT) #include "../../sd/SdFatUtil.h" diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 890798a719..7adf1aad49 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -135,7 +135,7 @@ void HAL_init(); inline void HAL_clear_reset_source() { MCUSR = 0; } inline uint8_t HAL_get_reset_source() { return MCUSR; } -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); #if GCC_VERSION <= 50000 #pragma GCC diagnostic push diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp index 249535723f..a3985652e7 100644 --- a/Marlin/src/HAL/DUE/HAL.cpp +++ b/Marlin/src/HAL/DUE/HAL.cpp @@ -77,6 +77,8 @@ uint8_t HAL_get_reset_source() { } } +void HAL_reboot() { rstc_start_software_reset(RSTC); } + void _delay_ms(const int delay_ms) { // Todo: port for Due? delay(delay_ms); diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 501e2f0b06..1bc3bf7410 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -113,7 +113,7 @@ void sei(); // Enable interrupts void HAL_clear_reset_source(); // clear reset reason uint8_t HAL_get_reset_source(); // get reset reason -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); // // ADC diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 365706c3e2..7818dbdd87 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -141,6 +141,8 @@ void HAL_clear_reset_source() { } uint8_t HAL_get_reset_source() { return rtc_get_reset_reason(1); } +void HAL_reboot() { ESP.restart(); } + void _delay_ms(int delay_ms) { delay(delay_ms); } // return free memory between end of heap (or end bss) and whatever is current diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 9258f97702..0f92052030 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -101,7 +101,7 @@ void HAL_clear_reset_source(); // reset reason uint8_t HAL_get_reset_source(); -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); void _delay_ms(int delay); diff --git a/Marlin/src/HAL/LINUX/HAL.cpp b/Marlin/src/HAL/LINUX/HAL.cpp index 771f1d2a08..0b679170ef 100644 --- a/Marlin/src/HAL/LINUX/HAL.cpp +++ b/Marlin/src/HAL/LINUX/HAL.cpp @@ -73,4 +73,6 @@ void HAL_pwm_init() { } +void HAL_reboot() { /* Reset the application state and GPIO */ } + #endif // __PLAT_LINUX__ diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index f21e3e2c65..36906bffc8 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -107,7 +107,7 @@ uint16_t HAL_adc_get_result(); inline void HAL_clear_reset_source(void) {} inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); // Reset the application state and GPIO /* ---------------- Delay in cycles */ FORCE_INLINE static void DELAY_CYCLES(uint64_t x) { diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index 442c41afe7..cee9cfc5f7 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -67,7 +67,7 @@ void flashFirmware(const int16_t) { delay(500); // Give OS time to disconnect USB_Connect(false); // USB clear connection delay(1000); // Give OS time to notice - NVIC_SystemReset(); + HAL_reboot(); } void HAL_clear_reset_source(void) { @@ -81,4 +81,6 @@ uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } +void HAL_reboot() { NVIC_SystemReset(); } + #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 07385261da..bcfa6c412f 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -218,4 +218,4 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, void HAL_clear_reset_source(void); uint8_t HAL_get_reset_source(void); -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index 39167fc467..5aa23cdaeb 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -436,6 +436,8 @@ uint8_t HAL_get_reset_source() { } #pragma pop_macro("WDT") +void HAL_reboot() { NVIC_SystemReset(); } + extern "C" { void * _sbrk(int incr); diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 3add6c9b69..85ac5dd00c 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -109,7 +109,7 @@ typedef int8_t pin_t; void HAL_clear_reset_source(); // clear reset reason uint8_t HAL_get_reset_source(); // get reset reason -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); // // ADC diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index c66f061d91..3bb12fd9e0 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -133,6 +133,8 @@ uint8_t HAL_get_reset_source() { ; } +void HAL_reboot() { NVIC_SystemReset(); } + void _delay_ms(const int delay_ms) { delay(delay_ms); } extern "C" { @@ -147,8 +149,8 @@ extern "C" { void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); } uint16_t HAL_adc_get_result() { return HAL_adc_result; } -// Reset the system (to initiate a firmware flash) -void flashFirmware(const int16_t) { NVIC_SystemReset(); } +// Reset the system to initiate a firmware flash +void flashFirmware(const int16_t) { HAL_reboot(); } // Maple Compatibility volatile uint32_t systick_uptime_millis = 0; diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index d8e45670e6..469d08e435 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -144,7 +144,7 @@ void HAL_clear_reset_source(); // Reset reason uint8_t HAL_get_reset_source(); -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); void _delay_ms(const int delay); diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index 40452b5d70..2efea4f001 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -453,6 +453,8 @@ void analogWrite(pin_t pin, int pwm_val8) { analogWrite(uint8_t(pin), pwm_val8); } -void flashFirmware(const int16_t) { nvic_sys_reset(); } +void HAL_reboot() { nvic_sys_reset(); } + +void flashFirmware(const int16_t) { HAL_reboot(); } #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index f37b0f2728..af4d27f43e 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -207,7 +207,7 @@ void HAL_clear_reset_source(); // Reset reason uint8_t HAL_get_reset_source(); -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); void _delay_ms(const int delay); diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index 67f716c5d3..f08cf799e9 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -78,6 +78,8 @@ uint8_t HAL_get_reset_source() { return 0; } +void HAL_reboot() { _reboot_Teensyduino_(); } + extern "C" { extern char __bss_end; extern char __heap_start; diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index bbfc50a36f..52904465be 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -34,7 +34,6 @@ #include "fastio.h" #include "watchdog.h" - #include #define ST7920_DELAY_1 DELAY_NS(600) @@ -93,7 +92,7 @@ void HAL_clear_reset_source(); // Get the reason for the reset uint8_t HAL_get_reset_source(); -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index 5d808cd19b..046c00b56e 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -86,6 +86,8 @@ uint8_t HAL_get_reset_source() { return 0; } +void HAL_reboot() { _reboot_Teensyduino_(); } + extern "C" { extern char __bss_end; extern char __heap_start; diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 50008d72f6..26c35223bd 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -101,7 +101,7 @@ void HAL_clear_reset_source(); // Reset reason uint8_t HAL_get_reset_source(); -inline void HAL_reboot() {} // reboot the board or restart the bootloader +void HAL_reboot(); FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index 1eab3d837e..a986c293a9 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -120,6 +120,8 @@ uint8_t HAL_get_reset_source() { return 0; } +void HAL_reboot() { _reboot_Teensyduino_(); } + #define __bss_end _ebss extern "C" { diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 701d690382..1d00447fe8 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -121,6 +121,8 @@ void HAL_clear_reset_source(); // Reset reason uint8_t HAL_get_reset_source(); +void HAL_reboot(); + FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } #if GCC_VERSION <= 50000 diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 6cb51bc577..7139d54f25 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -863,20 +863,22 @@ void minkill(const bool steppers_off/*=false*/) { TERN_(HAS_SUICIDE, suicide()); - #if HAS_KILL + #if EITHER(HAS_KILL, SOFT_RESET_ON_KILL) - // Wait for kill to be released - while (kill_state()) watchdog_refresh(); + // Wait for both KILL and ENC to be released + while (TERN0(HAS_KILL, !kill_state()) || TERN0(SOFT_RESET_ON_KILL, !ui.button_pressed())) + watchdog_refresh(); - // Wait for kill to be pressed - while (!kill_state()) watchdog_refresh(); + // Wait for either KILL or ENC press + while (TERN1(HAS_KILL, kill_state()) && TERN1(SOFT_RESET_ON_KILL, ui.button_pressed())) + watchdog_refresh(); - void (*resetFunc)() = 0; // Declare resetFunc() at address 0 - resetFunc(); // Jump to address 0 + // Reboot the board + HAL_reboot(); #else - for (;;) watchdog_refresh(); // Wait for reset + for (;;) watchdog_refresh(); // Wait for RESET button or power-cycle #endif } diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index c12fd14ad1..3723caa35e 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -41,6 +41,8 @@ extern bool wait_for_user, wait_for_heatup; void quickresume_stepper(); #endif +void HAL_reboot(); + class EmergencyParser { public: @@ -62,6 +64,10 @@ public: EP_R, EP_R0, EP_R00, EP_GRBL_RESUME, EP_P, EP_P0, EP_P00, EP_GRBL_PAUSE, #endif + #if ENABLED(SOFT_RESET_VIA_SERIAL) + EP_ctrl, + EP_K, EP_KI, EP_KIL, EP_KILL, + #endif EP_IGNORE // to '\n' }; @@ -89,6 +95,10 @@ public: case 'P': state = EP_P; break; case 'R': state = EP_R; break; #endif + #if ENABLED(SOFT_RESET_VIA_SERIAL) + case '^': state = EP_ctrl; break; + case 'K': state = EP_K; break; + #endif default: state = EP_IGNORE; } break; @@ -121,6 +131,13 @@ public: case EP_P00: state = (c == '0') ? EP_GRBL_PAUSE : EP_IGNORE; break; #endif + #if ENABLED(SOFT_RESET_VIA_SERIAL) + case EP_ctrl: state = (c == 'X') ? EP_KILL : EP_IGNORE; break; + case EP_K: state = (c == 'I') ? EP_KI : EP_IGNORE; break; + case EP_KI: state = (c == 'L') ? EP_KIL : EP_IGNORE; break; + case EP_KIL: state = (c == 'L') ? EP_KILL : EP_IGNORE; break; + #endif + case EP_M: switch (c) { case ' ': break; @@ -189,6 +206,9 @@ public: case EP_GRBL_PAUSE: quickpause_stepper(); break; case EP_GRBL_RESUME: quickresume_stepper(); break; #endif + #if ENABLED(SOFT_RESET_VIA_SERIAL) + case EP_KILL: HAL_reboot(); break; + #endif default: break; } state = EP_RESET; diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index f87cebc886..74277291e5 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -30,6 +30,7 @@ #include "../HAL/shared/eeprom_if.h" #include "../HAL/shared/Delay.h" #include "../sd/cardreader.h" + #include "../MarlinCore.h" // for kill extern void dump_delay_accuracy_check(); @@ -44,12 +45,16 @@ switch (dcode) { case -1: - for (;;); // forever + for (;;) { /* loop forever (watchdog reset) */ } case 0: HAL_reboot(); break; + case 10: + kill(PSTR("D10"), PSTR("KILL TEST"), parser.seen('P')); + break; + case 1: { // Zero or pattern-fill the EEPROM data #if ENABLED(EEPROM_SETTINGS) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 5a9d6e6040..2d6633b353 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2208,12 +2208,19 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif /** - * emergency-command parser + * Emergency Command Parser */ #if ENABLED(EMERGENCY_PARSER) && defined(__AVR__) && defined(USBCON) #error "EMERGENCY_PARSER does not work on boards with AT90USB processors (USBCON)." #endif +/** + * Software Reset on Kill option + */ +#if ENABLED(SOFT_RESET_ON_KILL) && !BUTTON_EXISTS(ENC) + #error "An encoder button is required or SOFT_RESET_ON_KILL will reset the printer without notice!" +#endif + /** * I2C bus */ diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 8cbb9ebd19..8befa1d980 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -39,7 +39,7 @@ #include "tft_io/touch_calibration.h" #endif -#if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY) +#if ANY(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) #define HAS_ENCODER_ACTION 1 #endif diff --git a/buildroot/tests/LPC1768 b/buildroot/tests/LPC1768 index 152a49852a..6b9f6aaac3 100755 --- a/buildroot/tests/LPC1768 +++ b/buildroot/tests/LPC1768 @@ -45,7 +45,7 @@ opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ADAPTIVE_FAN_SLOWING NO 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 \ - SDSUPPORT SDCARD_SORT_ALPHA AUTO_REPORT_SD_STATUS EMERGENCY_PARSER + SDSUPPORT SDCARD_SORT_ALPHA AUTO_REPORT_SD_STATUS EMERGENCY_PARSER SOFT_RESET_ON_KILL SOFT_RESET_VIA_SERIAL exec_test $1 $2 "Re-ARM with NOZZLE_AS_PROBE and many features." "$3" # clean up From 6f5800bd74e3e2e7db372c4fc4b51a36a7b7b351 Mon Sep 17 00:00:00 2001 From: Nikolay March Date: Sat, 24 Apr 2021 12:38:00 +0300 Subject: [PATCH 281/311] Backlash Compensation for COREnn (#21612) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 3 ++ Marlin/src/feature/backlash.cpp | 47 ++++++++++++++++++++++----- Marlin/src/lcd/menu/menu_backlash.cpp | 11 +++++-- buildroot/tests/teensy35 | 4 +-- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d72feab433..eb3c7b0df8 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -972,6 +972,9 @@ #define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm) #define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction + // Add steps for motor direction changes on CORE kinematics + //#define CORE_BACKLASH + // Set BACKLASH_SMOOTHING_MM to spread backlash correction over multiple segments // to reduce print artifacts. (Enabling this is costly in memory and computation!) //#define BACKLASH_SMOOTHING_MM 3 // (mm) diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index b848214f0c..610cfcb565 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -63,10 +63,24 @@ Backlash backlash; void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const uint8_t dm, block_t * const block) { static uint8_t last_direction_bits; uint8_t changed_dir = last_direction_bits ^ dm; - // Ignore direction change if no steps are taken in that direction - if (da == 0) CBI(changed_dir, X_AXIS); - if (db == 0) CBI(changed_dir, Y_AXIS); - if (dc == 0) CBI(changed_dir, Z_AXIS); + // Ignore direction change unless steps are taken in that direction + #if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY) + if (!da) CBI(changed_dir, X_AXIS); + if (!db) CBI(changed_dir, Y_AXIS); + if (!dc) CBI(changed_dir, Z_AXIS); + #elif CORE_IS_XY + if (!(da + db)) CBI(changed_dir, X_AXIS); + if (!(da - db)) CBI(changed_dir, Y_AXIS); + if (!dc) CBI(changed_dir, Z_AXIS); + #elif CORE_IS_XZ + if (!(da + dc)) CBI(changed_dir, X_AXIS); + if (!(da - dc)) CBI(changed_dir, Z_AXIS); + if (!db) CBI(changed_dir, Y_AXIS); + #elif CORE_IS_YZ + if (!(db + dc)) CBI(changed_dir, Y_AXIS); + if (!(db - dc)) CBI(changed_dir, Z_AXIS); + if (!da) CBI(changed_dir, X_AXIS); + #endif last_direction_bits ^= changed_dir; if (correction == 0) return; @@ -105,18 +119,35 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const // Take up a portion of the residual_error in this segment, but only when // the current segment travels in the same direction as the correction if (reversing == (error_correction < 0)) { - if (segment_proportion == 0) - segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm); + if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm); error_correction = CEIL(segment_proportion * error_correction); } else error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps } #endif - // Making a correction reduces the residual error and adds block steps + + // This correction reduces the residual error and adds block steps if (error_correction) { block->steps[axis] += ABS(error_correction); - residual_error[axis] -= error_correction; + #if ENABLED(CORE_BACKLASH) + switch (axis) { + case CORE_AXIS_1: + //block->steps[CORE_AXIS_2] += influence_distance_mm[axis] * planner.settings.axis_steps_per_mm[CORE_AXIS_2]; + //SERIAL_ECHOLNPAIR("CORE_AXIS_1 dir change. distance=", distance_mm[axis], " r.err=", residual_error[axis], + // " da=", da, " db=", db, " block->steps[axis]=", block->steps[axis], " err_corr=", error_correction); + break; + case CORE_AXIS_2: + //block->steps[CORE_AXIS_1] += influence_distance_mm[axis] * planner.settings.axis_steps_per_mm[CORE_AXIS_1];; + //SERIAL_ECHOLNPAIR("CORE_AXIS_2 dir change. distance=", distance_mm[axis], " r.err=", residual_error[axis], + // " da=", da, " db=", db, " block->steps[axis]=", block->steps[axis], " err_corr=", error_correction); + break; + case NORMAL_AXIS: break; + } + residual_error[axis] = 0; // No residual_error needed for next CORE block, I think... + #else + residual_error[axis] -= error_correction; + #endif } } } diff --git a/Marlin/src/lcd/menu/menu_backlash.cpp b/Marlin/src/lcd/menu/menu_backlash.cpp index 9d0b970ae1..c1dca025b1 100644 --- a/Marlin/src/lcd/menu/menu_backlash.cpp +++ b/Marlin/src/lcd/menu/menu_backlash.cpp @@ -38,10 +38,15 @@ void menu_backlash() { EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &backlash.correction, all_off, all_on); + #if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY) + #define _CAN_CALI AXIS_CAN_CALIBRATE + #else + #define _CAN_CALI(A) true + #endif #define EDIT_BACKLASH_DISTANCE(N) EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &backlash.distance_mm[_AXIS(N)], 0.0f, 9.9f); - if (AXIS_CAN_CALIBRATE(A)) EDIT_BACKLASH_DISTANCE(A); - if (AXIS_CAN_CALIBRATE(B)) EDIT_BACKLASH_DISTANCE(B); - if (AXIS_CAN_CALIBRATE(C)) EDIT_BACKLASH_DISTANCE(C); + if (_CAN_CALI(A)) EDIT_BACKLASH_DISTANCE(A); + if (_CAN_CALI(B)) EDIT_BACKLASH_DISTANCE(B); + if (_CAN_CALI(C)) EDIT_BACKLASH_DISTANCE(C); #ifdef BACKLASH_SMOOTHING_MM EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &backlash.smoothing_mm, 0.0f, 9.9f); diff --git a/buildroot/tests/teensy35 b/buildroot/tests/teensy35 index 36a261a6ae..3352c05525 100755 --- a/buildroot/tests/teensy35 +++ b/buildroot/tests/teensy35 @@ -93,8 +93,8 @@ exec_test $1 $2 "Teensy 3.5/3.6 COREXY" "$3" # restore_configs opt_set MOTHERBOARD BOARD_TEENSY35_36 -opt_enable COREXZ -exec_test $1 $2 "Teensy 3.5/3.6 COREXZ" "$3" +opt_enable COREXZ BACKLASH_COMPENSATION BACKLASH_GCODE CORE_BACKLASH +exec_test $1 $2 "Teensy 3.5/3.6 COREXZ | BACKLASH" "$3" # # Enable Dual Z with Dual Z endstops From dfcccb63a1f3d8098ebfef8c64753f735bcf0b0d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 24 Apr 2021 05:20:55 -0500 Subject: [PATCH 282/311] Use temperature accessors --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 2 +- Marlin/src/lcd/menu/menu_filament.cpp | 2 +- Marlin/src/lcd/menu/menu_temperature.cpp | 4 ++-- Marlin/src/lcd/tft/ui_1024x600.cpp | 2 +- Marlin/src/lcd/tft/ui_480x320.cpp | 2 +- Marlin/src/module/tool_change.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index cb7fb2728e..534975ffc1 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -2709,7 +2709,7 @@ void HMI_AxisMove() { case 4: // Extruder // window tips #ifdef PREVENT_COLD_EXTRUSION - if (thermalManager.wholeDegHotend(0) < (EXTRUDE_MINTEMP)) { + if (thermalManager.tooColdToExtrude(0)) { HMI_flag.ETempTooLow_flag = true; Popup_Window_ETempTooLow(); DWIN_UpdateLCD(); diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 8df2af1dd0..c6b8568085 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -67,7 +67,7 @@ static void _change_filament_with_preset() { } static void _change_filament_with_custom() { - _change_filament_with_temp(thermalManager.temp_hotend[MenuItemBase::itemIndex].target); + _change_filament_with_temp(thermalManager.degTargetHotend(MenuItemBase::itemIndex)); } // diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 85578ea351..47643cfb57 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -147,7 +147,7 @@ void menu_temperature() { #if HAS_TEMP_HOTEND || HAS_HEATED_BED bool has_heat = false; #if HAS_TEMP_HOTEND - HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; } + HOTEND_LOOP() if (thermalManager.degTargetHotend(HOTEND_INDEX)) { has_heat = true; break; } #endif #endif @@ -271,7 +271,7 @@ void menu_temperature() { // // Cooldown // - if (TERN0(HAS_HEATED_BED, thermalManager.temp_bed.target)) has_heat = true; + if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed())) has_heat = true; if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown); #endif diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 7a093ea65d..e4cc116818 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -644,7 +644,7 @@ static void drawAxisValue(AxisEnum axis) { static void moveAxis(AxisEnum axis, const int8_t direction) { quick_feedback(); - if (axis == E_AXIS && thermalManager.temp_hotend[motionAxisState.e_selection].celsius < EXTRUDE_MINTEMP) { + if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { drawMessage("Too cold"); return; } diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 0d7e01683f..e9ea4b0827 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -636,7 +636,7 @@ static void drawAxisValue(AxisEnum axis) { static void moveAxis(AxisEnum axis, const int8_t direction) { quick_feedback(); - if (axis == E_AXIS && thermalManager.temp_hotend[motionAxisState.e_selection].celsius < EXTRUDE_MINTEMP) { + if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { drawMessage("Too cold"); return; } diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 8354b8b86a..2e5e59c0af 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1381,7 +1381,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { // Migrate the temperature to the new hotend #if HAS_MULTI_HOTEND - thermalManager.setTargetHotend(thermalManager.temp_hotend[active_extruder].target, migration_extruder); + thermalManager.setTargetHotend(thermalManager.degTargetHotend(active_extruder), migration_extruder); TERN_(AUTOTEMP, planner.autotemp_update()); TERN_(HAS_STATUS_MESSAGE, thermalManager.set_heating_message(0)); thermalManager.wait_for_hotend(active_extruder); From 836c4e01981bffc5101ba2e6b47ba9910b4bce85 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 24 Apr 2021 05:28:50 -0500 Subject: [PATCH 283/311] Drop Deviot workaround --- .gitignore | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/.gitignore b/.gitignore index f7d49cc1ed..ac2c9b5591 100755 --- a/.gitignore +++ b/.gitignore @@ -122,29 +122,6 @@ tags .gcc-flags.json /lib/ -# Workaround for Deviot+platformio quirks -Marlin/lib -Marlin/platformio.ini -Marlin/*/platformio.ini -Marlin/*/*/platformio.ini -Marlin/*/*/*/platformio.ini -Marlin/*/*/*/*/platformio.ini -Marlin/.travis.yml -Marlin/*/.travis.yml -Marlin/*/*/.travis.yml -Marlin/*/*/*/.travis.yml -Marlin/*/*/*/*/.travis.yml -Marlin/.gitignore -Marlin/*/.gitignore -Marlin/*/*/.gitignore -Marlin/*/*/*/.gitignore -Marlin/*/*/*/*/.gitignore -Marlin/readme.txt -Marlin/*/readme.txt -Marlin/*/*/readme.txt -Marlin/*/*/*/readme.txt -Marlin/*/*/*/*/readme.txt - # Secure Credentials Configuration_Secure.h From 3b8f83a5aec737afd721e8f864f5e8ce5d0e5db7 Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Sat, 24 Apr 2021 06:35:02 -0400 Subject: [PATCH 284/311] Sanity check MIXING_EXTRUDER + DISTINCT_E_FACTORS (#21689) --- Marlin/src/inc/SanityCheck.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 2d6633b353..97f9a6373a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3298,6 +3298,13 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #undef _CLEAN_ASSERT #endif +/** + * Sanity check for MIXING_EXTRUDER & DISTINCT_E_FACTORS these are not compatible + */ +#if ENABLED(MIXING_EXTRUDER) && ENABLED(DISTINCT_E_FACTORS) + #error "MIXING_EXTRUDER can't be used with DISTINCT_E_FACTORS. But you may use SINGLENOZZLE with DISTINCT_E_FACTORS." +#endif + /** * Sanity check for valid stepper driver types */ From f3c7b61f29525d37d6c5bcd97873fd8261674a17 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 24 Apr 2021 15:22:50 -0500 Subject: [PATCH 285/311] Add INO to .editorconfig --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index a0fa3eff17..b8f6ef7f8e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,10 +4,10 @@ root = true [{*.patch,syntax_test_*}] trim_trailing_whitespace = false -[{*.c,*.cpp,*.h}] +[{*.c,*.cpp,*.h,*.ino}] charset = utf-8 -[{*.c,*.cpp,*.h,Makefile}] +[{*.c,*.cpp,*.h,*.ino,Makefile}] trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf From 993f9f3efd4e4d4feeeb676f110de2ca72a20622 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 24 Apr 2021 02:29:20 -0500 Subject: [PATCH 286/311] Remove extra platform_packages line --- ini/stm32f1.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 81e9f1dcb8..a2954e64cf 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -283,7 +283,6 @@ extra_scripts = ${common_stm32f1.extra_scripts} platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC -platform_packages = tool-stm32duino extra_scripts = ${common_stm32f1.extra_scripts} buildroot/share/PlatformIO/scripts/mks_robin_e3.py build_flags = ${common_stm32f1.build_flags} From 770e5398592f2683e6057d44248a9d29bc21c547 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 24 Apr 2021 15:22:38 -0500 Subject: [PATCH 287/311] Use Adafruit LiquidCrystal --- ini/features.ini | 2 +- ini/lpc176x.ini | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ini/features.ini b/ini/features.ini index 3121ef7241..1f4bf98531 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -30,7 +30,7 @@ HAS_L64XX = Arduino-L6470@0.8.0 NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 src_filter=+ TEMP_.+_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 -USES_LIQUIDCRYSTAL = bitbucket-fmalpartida/LiquidCrystal@1.5.0 +USES_LIQUIDCRYSTAL = arduino-libraries/LiquidCrystal@^1.0.7 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 HAS_WIRED_LCD = src_filter=+ diff --git a/ini/lpc176x.ini b/ini/lpc176x.ini index 2a59ba7f50..494d7baac8 100644 --- a/ini/lpc176x.ini +++ b/ini/lpc176x.ini @@ -23,7 +23,6 @@ extra_scripts = ${common.extra_scripts} src_filter = ${common.default_src_filter} + + lib_deps = ${common.lib_deps} Servo -custom_marlin.USES_LIQUIDCRYSTAL = arduino-libraries/LiquidCrystal@~1.0.7 custom_marlin.NEOPIXEL_LED = Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/1.5.0.zip build_flags = ${common.build_flags} -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC1768/include -IMarlin/src/HAL/LPC1768/u8g # debug options for backtrace From 13f3ccb85da31e2e48a22f79568c93d7ba52f3bc Mon Sep 17 00:00:00 2001 From: Miguel Risco-Castillo Date: Sat, 24 Apr 2021 18:50:44 -0500 Subject: [PATCH 288/311] E3V2 DWIN Advanced Settings (#21534) Co-authored-by: Scott Lahteine --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 386 +++++++++++++++++++++++-- Marlin/src/lcd/dwin/e3v2/dwin.h | 27 ++ Marlin/src/lcd/language/language_en.h | 3 + buildroot/tests/STM32F103RET6_creality | 3 +- 4 files changed, 389 insertions(+), 30 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 534975ffc1..891732e641 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -154,18 +154,20 @@ typedef struct { select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0} , select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0} - , select_PLA{0}, select_ABS{0} + , select_advset{0}, select_PLA{0}, select_ABS{0} , select_speed{0} , select_acc{0} , select_jerk{0} , select_step{0} + , select_item{0} ; uint8_t index_file = MROWS, index_prepare = MROWS, index_control = MROWS, index_leveling = MROWS, - index_tune = MROWS; + index_tune = MROWS, + index_advset = MROWS; bool dwin_abort_flag = false; // Flag to reset feedrate, return to Home @@ -462,12 +464,21 @@ void Erase_Menu_Text(const uint8_t line) { DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); } -void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr) { +void Draw_Menu_Item(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false) { if (label) DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(line) - 1, (char*)label); if (icon) Draw_Menu_Icon(line, icon); + if (more) Draw_More_Icon(line); +} + +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false) { + Draw_Menu_Item(line, icon, label, more); DWIN_Draw_Line(Line_Color, 16, MBASE(line) + 33, 256, MBASE(line) + 34); } +void Draw_Chkb_Line(const uint8_t line, const bool mode) { + DWIN_Draw_Checkbox(Color_White, Color_Bg_Black, 225, MBASE(line) - 1, mode); +} + // The "Back" label is always on the first line void Draw_Back_Label() { if (HMI_IsChinese()) @@ -516,7 +527,8 @@ inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valr #define CONTROL_CASE_SAVE (CONTROL_CASE_MOVE + ENABLED(EEPROM_SETTINGS)) #define CONTROL_CASE_LOAD (CONTROL_CASE_SAVE + ENABLED(EEPROM_SETTINGS)) #define CONTROL_CASE_RESET (CONTROL_CASE_LOAD + ENABLED(EEPROM_SETTINGS)) -#define CONTROL_CASE_INFO (CONTROL_CASE_RESET + 1) +#define CONTROL_CASE_ADVSET (CONTROL_CASE_RESET + 1) +#define CONTROL_CASE_INFO (CONTROL_CASE_ADVSET + 1) #define CONTROL_CASE_TOTAL CONTROL_CASE_INFO #define TUNE_CASE_SPEED 1 @@ -539,6 +551,13 @@ inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valr #define PREHEAT_CASE_SAVE (PREHEAT_CASE_FAN + ENABLED(EEPROM_SETTINGS)) #define PREHEAT_CASE_TOTAL PREHEAT_CASE_SAVE +#define ADVSET_CASE_HOMEOFF 1 +#define ADVSET_CASE_PROBEOFF (ADVSET_CASE_HOMEOFF + ENABLED(HAS_ONESTEP_LEVELING)) +#define ADVSET_CASE_HEPID (ADVSET_CASE_PROBEOFF + ENABLED(HAS_HOTEND)) +#define ADVSET_CASE_BEDPID (ADVSET_CASE_HEPID + ENABLED(HAS_HEATED_BED)) +#define ADVSET_CASE_PWRLOSSR (ADVSET_CASE_BEDPID + ENABLED(POWER_LOSS_RECOVERY)) +#define ADVSET_CASE_TOTAL ADVSET_CASE_PWRLOSSR + // // Draw Menus // @@ -770,26 +789,36 @@ void Draw_Control_Menu() { DWIN_Frame_TitleCopy(1, 128, 2, 176, 12); // "Control" #endif #ifdef USE_STRING_TITLES - DWIN_Draw_Label(CLINE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE)); - DWIN_Draw_Label(CLINE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION)); + if (CVISI(CONTROL_CASE_TEMP)) DWIN_Draw_Label(CLINE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE)); + if (CVISI(CONTROL_CASE_MOVE)) DWIN_Draw_Label(CLINE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION)); #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_Label(CLINE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); - DWIN_Draw_Label(CLINE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM)); - DWIN_Draw_Label(CLINE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); + if (CVISI(CONTROL_CASE_SAVE)) DWIN_Draw_Label(CLINE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + if (CVISI(CONTROL_CASE_LOAD)) DWIN_Draw_Label(CLINE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM)); + if (CVISI(CONTROL_CASE_RESET)) DWIN_Draw_Label(CLINE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); #endif #else - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature > - DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion > + if (CVISI(CONTROL_CASE_TEMP)) DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature > + if (CVISI(CONTROL_CASE_MOVE)) DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion > #if ENABLED(EEPROM_SETTINGS) - DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX , CLINE(CONTROL_CASE_SAVE)); // "Store Configuration" - DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX , CLINE(CONTROL_CASE_LOAD)); // "Read" - DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(CONTROL_CASE_LOAD)); // "Configuration" - DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX , CLINE(CONTROL_CASE_RESET)); // "Reset" - DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, CLINE(CONTROL_CASE_RESET)); // "Configuration" + if (CVISI(CONTROL_CASE_SAVE)) DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX , CLINE(CONTROL_CASE_SAVE)); // "Store Configuration" + if (CVISI(CONTROL_CASE_LOAD)) { + DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX , CLINE(CONTROL_CASE_LOAD)); // "Read" + DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(CONTROL_CASE_LOAD)); // "Configuration" + } + if (CVISI(CONTROL_CASE_RESET)) { + DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX , CLINE(CONTROL_CASE_RESET)); // "Reset" + DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, CLINE(CONTROL_CASE_RESET)); // "Configuration" + } #endif #endif } + if (CVISI(CONTROL_CASE_ADVSET)) { + DWIN_Draw_Label(CLINE(CONTROL_CASE_ADVSET), GET_TEXT_F(MSG_ADVANCED_SETTINGS)); // Advanced Settings + Draw_More_Icon(CSCROL(CONTROL_CASE_ADVSET)); + Draw_Menu_Line(CSCROL(CONTROL_CASE_ADVSET), ICON_AdvSet); + } + if (CVISI(CONTROL_CASE_INFO)) Item_Control_Info(CLINE(CONTROL_CASE_INFO)); if (select_control.now && CVISI(select_control.now)) @@ -1785,7 +1814,7 @@ void Draw_SDItem(const uint16_t item, int16_t row=-1) { #if ENABLED(SCROLL_LONG_FILENAMES) - void Draw_SDItem_Shifted(int8_t &shift) { + void Draw_SDItem_Shifted(uint8_t &shift) { // Limit to the number of chars past the cutoff const size_t len = strlen(shift_name); NOMORE(shift, _MAX(len - MENU_CHAR_LIMIT, 0U)); @@ -2060,7 +2089,7 @@ void HMI_SelectFile() { if (ELAPSED(ms, shift_ms)) { const bool was_reset = shift_amt < 0; shift_ms = ms + 375UL + was_reset * 250UL; // ms per character - int8_t shift_new = shift_amt + 1; // Try to shift by... + uint8_t shift_new = shift_amt + 1; // Try to shift by... Draw_SDItem_Shifted(shift_new); // Draw the item if (!was_reset && shift_new == 0) // Was it limited to 0? shift_ms = 0; // No scrolling needed @@ -2331,6 +2360,60 @@ void Draw_Move_Menu() { LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MoveX + i); } +void Draw_AdvSet_Menu() { + Clear_Main_Window(); + + #if ADVSET_CASE_TOTAL >= 6 + const int16_t scroll = MROWS - index_advset; // Scrolled-up lines + #define ASCROL(L) (scroll + (L)) + #else + #define ASCROL(L) (L) + #endif + + #define AVISI(L) WITHIN(ASCROL(L), 0, MROWS) + + Draw_Title(GET_TEXT_F(MSG_ADVANCED_SETTINGS)); + + if (AVISI(0)) Draw_Back_First(select_advset.now == 0); + if (AVISI(ADVSET_CASE_HOMEOFF)) Draw_Menu_Line(ASCROL(ADVSET_CASE_HOMEOFF), ICON_HomeOff, GET_TEXT(MSG_SET_HOME_OFFSETS),true); // Home Offset > + #if HAS_ONESTEP_LEVELING + if (AVISI(ADVSET_CASE_PROBEOFF)) Draw_Menu_Line(ASCROL(ADVSET_CASE_PROBEOFF), ICON_ProbeOff, GET_TEXT(MSG_ZPROBE_OFFSETS),true); // Probe Offset > + #endif + if (AVISI(ADVSET_CASE_HEPID)) Draw_Menu_Line(ASCROL(ADVSET_CASE_HEPID), ICON_PIDNozzle, "Hotend PID", false); // Nozzle PID + if (AVISI(ADVSET_CASE_BEDPID)) Draw_Menu_Line(ASCROL(ADVSET_CASE_BEDPID), ICON_PIDbed, "Bed PID", false); // Bed PID + if (AVISI(ADVSET_CASE_PWRLOSSR)) { + Draw_Menu_Line(ASCROL(ADVSET_CASE_PWRLOSSR), ICON_Motion, "Power-loss recovery", false); // Power-loss recovery + Draw_Chkb_Line(ASCROL(ADVSET_CASE_PWRLOSSR), recovery.enabled); + } + if (select_advset.now) Draw_Menu_Cursor(ASCROL(select_advset.now)); +} + +void Draw_HomeOff_Menu() { + Clear_Main_Window(); + Draw_Title(GET_TEXT_F(MSG_SET_HOME_OFFSETS)); // Home Offsets + Draw_Back_First(select_item.now == 0); + Draw_Menu_Line(1, ICON_HomeOffX, GET_TEXT(MSG_HOME_OFFSET_X)); // Home X Offset + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Home_OffX_scaled); + Draw_Menu_Line(2, ICON_HomeOffY, GET_TEXT(MSG_HOME_OFFSET_Y)); // Home Y Offset + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Home_OffY_scaled); + Draw_Menu_Line(3, ICON_HomeOffZ, GET_TEXT(MSG_HOME_OFFSET_Z)); // Home Y Offset + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Home_OffZ_scaled); + if (select_item.now) Draw_Menu_Cursor(select_item.now); +} + +#if HAS_ONESTEP_LEVELING + void Draw_ProbeOff_Menu() { + Clear_Main_Window(); + Draw_Title(GET_TEXT_F(MSG_ZPROBE_OFFSETS)); // Probe Offsets + Draw_Back_First(select_item.now == 0); + Draw_Menu_Line(1, ICON_ProbeOffX, GET_TEXT(MSG_ZPROBE_XOFFSET)); // Probe X Offset + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Probe_OffX_scaled); + Draw_Menu_Line(2, ICON_ProbeOffY, GET_TEXT(MSG_ZPROBE_YOFFSET)); // Probe Y Offset + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Probe_OffY_scaled); + if (select_item.now) Draw_Menu_Cursor(select_item.now); + } +#endif + #include "../../../libs/buzzer.h" void HMI_AudioFeedback(const bool success=true) { @@ -2566,14 +2649,20 @@ void HMI_Control() { if (select_control.inc(1 + CONTROL_CASE_TOTAL)) { if (select_control.now > MROWS && select_control.now > index_control) { index_control = select_control.now; + + // Scroll up and draw a blank bottom line Scroll_Menu(DWIN_SCROLL_UP); - Draw_Menu_Icon(MROWS, ICON_Temperature + index_control - 1); - Draw_More_Icon(CONTROL_CASE_TEMP + MROWS - index_control); // Temperature > - Draw_More_Icon(CONTROL_CASE_MOVE + MROWS - index_control); // Motion > - if (index_control > MROWS) { - Draw_More_Icon(CONTROL_CASE_INFO + MROWS - index_control); // Info > - Item_Control_Info(MBASE(CONTROL_CASE_INFO - 1)); + + switch (index_control) { // Last menu items + case CONTROL_CASE_ADVSET: // Advance Settings > + Draw_Menu_Item(MROWS, ICON_AdvSet, GET_TEXT(MSG_ADVANCED_SETTINGS), true); + break; + case CONTROL_CASE_INFO: // Info > + Draw_Menu_Item(MROWS, ICON_Info, GET_TEXT(MSG_INFO_SCREEN), true); + break; + default: break; } + } else { Move_Highlight(1, select_control.now + MROWS - index_control); @@ -2585,12 +2674,17 @@ void HMI_Control() { if (select_control.now < index_control - MROWS) { index_control--; Scroll_Menu(DWIN_SCROLL_DOWN); - if (index_control == MROWS) + switch (index_control) { // First menu items + case MROWS : Draw_Back_First(); - else - Draw_Menu_Line(0, ICON_Temperature + select_control.now - 1); - Draw_More_Icon(0 + MROWS - index_control + 1); // Temperature > - Draw_More_Icon(1 + MROWS - index_control + 1); // Motion > + break; + case MROWS + 1: // Temperature > + Draw_Menu_Line(0, ICON_Temperature, GET_TEXT(MSG_TEMPERATURE), true); + break; + case MROWS + 2: // Move > + Draw_Menu_Line(0, ICON_Motion, GET_TEXT(MSG_MOTION), true); + default: break; + } } else { Move_Highlight(-1, select_control.now + MROWS - index_control); @@ -2628,6 +2722,11 @@ void HMI_Control() { HMI_AudioFeedback(); break; #endif + case CONTROL_CASE_ADVSET: // Advance Settings + checkkey = AdvSet; + select_advset.reset(); + Draw_AdvSet_Menu(); + break; case CONTROL_CASE_INFO: // Info checkkey = Info; Draw_Info_Menu(); @@ -3227,6 +3326,217 @@ void HMI_Motion() { DWIN_UpdateLCD(); } +/* Advanced Settings */ +void HMI_AdvSet() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_advset.inc(1 + ADVSET_CASE_TOTAL)) { + if (select_advset.now > MROWS && select_advset.now > index_advset) { + index_advset = select_advset.now; + + // Scroll up and draw a blank bottom line + Scroll_Menu(DWIN_SCROLL_UP); + + //switch (index_advset) { // Redraw last menu items + // default: break; + //} + + } + else { + Move_Highlight(1, select_advset.now + MROWS - index_advset); + } + } + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_advset.dec()) { + if (select_advset.now < index_advset - MROWS) { + index_advset--; + Scroll_Menu(DWIN_SCROLL_DOWN); + + //switch (index_advset) { // Redraw first menu items + // default: break; + //} + } + else { + Move_Highlight(-1, select_advset.now + MROWS - index_advset); + } + } + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_advset.now) { + case 0: // Back + checkkey = Control; + select_control.set(CONTROL_CASE_ADVSET); + index_control = CONTROL_CASE_ADVSET; + Draw_Control_Menu(); + break; + + #if HAS_HOME_OFFSET + case ADVSET_CASE_HOMEOFF: // Home Offsets + checkkey = HomeOff; + select_item.reset(); + HMI_ValueStruct.Home_OffX_scaled = home_offset[X_AXIS] * 10; + HMI_ValueStruct.Home_OffY_scaled = home_offset[Y_AXIS] * 10; + HMI_ValueStruct.Home_OffZ_scaled = home_offset[Z_AXIS] * 10; + Draw_HomeOff_Menu(); + break; + #endif + + #if HAS_ONESTEP_LEVELING + case ADVSET_CASE_PROBEOFF: // Probe Offsets + checkkey = ProbeOff; + select_item.reset(); + HMI_ValueStruct.Probe_OffX_scaled = probe.offset.x * 10; + HMI_ValueStruct.Probe_OffY_scaled = probe.offset.y * 10; + Draw_ProbeOff_Menu(); + break; + #endif + + #if HAS_HOTEND + case ADVSET_CASE_HEPID: // Nozzle PID Autotune + thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0); + thermalManager.PID_autotune(ui.material_preset[0].hotend_temp, H_E0, 10, true); + break; + #endif + + #if HAS_HEATED_BED + case ADVSET_CASE_BEDPID: // Bed PID Autotune + thermalManager.setTargetBed(ui.material_preset[0].bed_temp); + thermalManager.PID_autotune(ui.material_preset[0].bed_temp, H_BED, 10, true); + break; + #endif + + case ADVSET_CASE_PWRLOSSR: // Power-loss recovery + recovery.enable(!recovery.enabled); + Draw_Chkb_Line(ADVSET_CASE_PWRLOSSR + MROWS - index_advset, recovery.enabled); + break; + default: break; + } + } + DWIN_UpdateLCD(); +} + +#if HAS_HOME_OFFSET + + /* Home Offset */ + void HMI_HomeOff() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_item.inc(1 + 3)) Move_Highlight(1, select_item.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_item.dec()) Move_Highlight(-1, select_item.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_item.now) { + case 0: // Back + checkkey = AdvSet; + select_advset.set(ADVSET_CASE_HOMEOFF); + Draw_AdvSet_Menu(); + break; + case 1: // Home Offset X + checkkey = HomeOffX; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Home_OffX_scaled); + EncoderRate.enabled = true; + break; + case 2: // Home Offset Y + checkkey = HomeOffY; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Home_OffY_scaled); + EncoderRate.enabled = true; + break; + case 3: // Home Offset Z + checkkey = HomeOffZ; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Home_OffZ_scaled); + EncoderRate.enabled = true; + break; + default: break; + } + } + DWIN_UpdateLCD(); + } + + void HMI_HomeOffN(float &posScaled, const_float_t lo, const_float_t hi) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (Apply_Encoder(encoder_diffState, posScaled)) { + checkkey = HomeOff; + EncoderRate.enabled = false; + set_home_offset(X_AXIS, posScaled / 10); + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(select_item.now), posScaled); + return; + } + LIMIT(posScaled, lo, hi); + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, UNITFDIGITS, 216, MBASE(select_item.now), posScaled); + } + } + + void HMI_HomeOffX() { HMI_HomeOffN(HMI_ValueStruct.Home_OffX_scaled, -500, 500); } + void HMI_HomeOffY() { HMI_HomeOffN(HMI_ValueStruct.Home_OffY_scaled, -500, 500); } + void HMI_HomeOffZ() { HMI_HomeOffN(HMI_ValueStruct.Home_OffZ_scaled, -20, 20); } + +#endif // HAS_HOME_OFFSET + +#if HAS_ONESTEP_LEVELING + /*Probe Offset */ + void HMI_ProbeOff() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_item.inc(1 + 2)) Move_Highlight(1, select_item.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_item.dec()) Move_Highlight(-1, select_item.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_item.now) { + case 0: // Back + checkkey = AdvSet; + select_advset.set(ADVSET_CASE_PROBEOFF); + Draw_AdvSet_Menu(); + break; + case 1: // Probe Offset X + checkkey = ProbeOffX; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Probe_OffX_scaled); + EncoderRate.enabled = true; + break; + case 2: // Probe Offset X + checkkey = ProbeOffY; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Probe_OffY_scaled); + EncoderRate.enabled = true; + break; + } + } + DWIN_UpdateLCD(); + } + + void HMI_ProbeOffN(float &posScaled, float &offset_ref) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (Apply_Encoder(encoder_diffState, posScaled)) { + checkkey = ProbeOff; + EncoderRate.enabled = false; + offset_ref = posScaled / 10; + DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(select_item.now), posScaled); + return; + } + LIMIT(posScaled, -500, 500); + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, UNITFDIGITS, 216, MBASE(select_item.now), posScaled); + } + } + + void HMI_ProbeOffX() { HMI_ProbeOffN(HMI_ValueStruct.Probe_OffX_scaled, probe.offset.x); } + void HMI_ProbeOffY() { HMI_ProbeOffN(HMI_ValueStruct.Probe_OffY_scaled, probe.offset.y); } + +#endif // HAS_ONESTEP_LEVELING + /* Info */ void HMI_Info() { ENCODER_DiffState encoder_diffState = get_encoder_state(); @@ -3735,6 +4045,18 @@ void DWIN_HandleScreen() { case AxisMove: HMI_AxisMove(); break; case TemperatureID: HMI_Temperature(); break; case Motion: HMI_Motion(); break; + case AdvSet: HMI_AdvSet(); break; + #if HAS_HOME_OFFSET + case HomeOff: HMI_HomeOff(); break; + case HomeOffX: HMI_HomeOffX(); break; + case HomeOffY: HMI_HomeOffY(); break; + case HomeOffZ: HMI_HomeOffZ(); break; + #endif + #if HAS_ONESTEP_LEVELING + case ProbeOff: HMI_ProbeOff(); break; + case ProbeOffX: HMI_ProbeOffX(); break; + case ProbeOffY: HMI_ProbeOffY(); break; + #endif case Info: HMI_Info(); break; case Tune: HMI_Tune(); break; #if HAS_PREHEAT @@ -3801,4 +4123,10 @@ void DWIN_StatusChanged(const char *text) { DWIN_UpdateLCD(); } +// GUI extension +void DWIN_Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool mode=false) { + DWIN_Draw_String(false,true,font8x16,Select_Color,bcolor,x+4,y,F(mode ? "x" : " ")); + DWIN_Draw_Rectangle(0,color,x+2,y+2,x+17,y+17); +} + #endif // DWIN_CREALITY_LCD diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index 7f7c007eed..ad210db27d 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -63,10 +63,20 @@ enum processID : uint8_t { MaxJerk_value, Step, Step_value, + HomeOff, + HomeOffX, + HomeOffY, + HomeOffZ, // Last Process ID Last_Prepare, + // Advance Settings + AdvSet, + ProbeOff, + ProbeOffX, + ProbeOffY, + // Back Process ID Back_Main, Back_Print, @@ -197,6 +207,17 @@ enum processID : uint8_t { #define ICON_Info_0 90 #define ICON_Info_1 91 +#define ICON_AdvSet ICON_Language +#define ICON_HomeOff ICON_AdvSet +#define ICON_HomeOffX ICON_StepX +#define ICON_HomeOffY ICON_StepY +#define ICON_HomeOffZ ICON_StepZ +#define ICON_ProbeOff ICON_AdvSet +#define ICON_ProbeOffX ICON_StepX +#define ICON_ProbeOffY ICON_StepY +#define ICON_PIDNozzle ICON_SetEndTemp +#define ICON_PIDbed ICON_SetBedTemp + /** * 3-.0:The font size, 0x00-0x09, corresponds to the font size below: * 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28 @@ -256,6 +277,11 @@ typedef struct { #endif float offset_value = 0; int8_t show_mode = 0; // -1: Temperature control 0: Printing temperature + float Home_OffX_scaled = 0; + float Home_OffY_scaled = 0; + float Home_OffZ_scaled = 0; + float Probe_OffX_scaled = 0; + float Probe_OffY_scaled = 0; } HMI_value_t; #define DWIN_CHINESE 123 @@ -378,6 +404,7 @@ void DWIN_Update(); void EachMomentUpdate(); void DWIN_HandleScreen(); void DWIN_StatusChanged(const char *text); +void DWIN_Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool mode /* = false*/); inline void DWIN_StartHoming() { HMI_flag.home_flag = true; } diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index c911120766..12c5a6e42d 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -82,6 +82,9 @@ namespace Language_en { PROGMEM Language_Str MSG_LEVEL_BED_DONE = _UxGT("Leveling Done!"); PROGMEM Language_Str MSG_Z_FADE_HEIGHT = _UxGT("Fade Height"); PROGMEM Language_Str MSG_SET_HOME_OFFSETS = _UxGT("Set Home Offsets"); + PROGMEM Language_Str MSG_HOME_OFFSET_X = _UxGT("Home Offset X"); + PROGMEM Language_Str MSG_HOME_OFFSET_Y = _UxGT("Home Offset Y"); + PROGMEM Language_Str MSG_HOME_OFFSET_Z = _UxGT("Home Offset Z"); PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsets Applied"); PROGMEM Language_Str MSG_SET_ORIGIN = _UxGT("Set Origin"); PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Assisted Tramming"); diff --git a/buildroot/tests/STM32F103RET6_creality b/buildroot/tests/STM32F103RET6_creality index ef020a33f1..a3f885147e 100755 --- a/buildroot/tests/STM32F103RET6_creality +++ b/buildroot/tests/STM32F103RET6_creality @@ -16,7 +16,8 @@ exec_test $1 $2 "Ender 3 v2" "$3" use_example_configs "Creality/Ender-3 V2" opt_disable CLASSIC_JERK opt_add SDCARD_EEPROM_EMULATION -exec_test $1 $2 "Ender 3 v2, SD EEPROM, w/o CLASSIC_JERK" "$3" +opt_set TEMP_SENSOR_BED 0 +exec_test $1 $2 "Ender 3 v2, SD EEPROM, no CLASSIC_JERK, no Bed" "$3" restore_configs opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1 From a280077820c932fdb5a308bdfe64eb329e8ffe39 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 25 Apr 2021 00:36:37 +0000 Subject: [PATCH 289/311] [cron] Bump distribution date (2021-04-25) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 1eb4cc5567..2e631d2f57 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-04-24" + #define STRING_DISTRIBUTION_DATE "2021-04-25" #endif /** From a1ee5124d3673077e7812c00f883fca7179b30bd Mon Sep 17 00:00:00 2001 From: pinchies Date: Sun, 25 Apr 2021 18:48:20 +1000 Subject: [PATCH 290/311] Fix usage, commentary of MANUAL_PROBE_START_Z, Z_AFTER_PROBING (#21692) Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 6 ++++- Marlin/src/feature/bedlevel/bedlevel.cpp | 30 +++++++++++------------ Marlin/src/gcode/bedlevel/mbl/G29.cpp | 16 +++++++++--- Marlin/src/inc/Conditionals_LCD.h | 18 +++++--------- Marlin/src/inc/Conditionals_post.h | 14 ++++++++--- Marlin/src/lcd/menu/menu_bed_leveling.cpp | 6 ++--- 6 files changed, 52 insertions(+), 38 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 1022dd54dd..8e2ade8299 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -934,7 +934,6 @@ * or (with LCD_BED_LEVELING) the LCD controller. */ //#define PROBE_MANUALLY -//#define MANUAL_PROBE_START_Z 0.2 /** * A Fix-Mounted Probe either doesn't deploy or needs manual deployment. @@ -1409,6 +1408,11 @@ */ //#define DEBUG_LEVELING_FEATURE +#if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL, PROBE_MANUALLY) + // Set a height for the start of manual adjustment + #define MANUAL_PROBE_START_Z 0.2 // (mm) Comment out to use the last-measured height +#endif + #if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL) // Gradually reduce leveling correction until a set height is reached, // at which point movement will be level to the machine's XY plane. diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 30fafbf57b..8e03632de4 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -213,27 +213,27 @@ void reset_bed_level() { void _manual_goto_xy(const xy_pos_t &pos) { + // Get the resting Z position for after the XY move #ifdef MANUAL_PROBE_START_Z - constexpr float startz = _MAX(0, MANUAL_PROBE_START_Z); - #if MANUAL_PROBE_HEIGHT > 0 - do_blocking_move_to_xy_z(pos, MANUAL_PROBE_HEIGHT); - do_blocking_move_to_z(startz); - #else - do_blocking_move_to_xy_z(pos, startz); - #endif - #elif MANUAL_PROBE_HEIGHT > 0 - const float prev_z = current_position.z; - do_blocking_move_to_xy_z(pos, MANUAL_PROBE_HEIGHT); - do_blocking_move_to_z(prev_z); + constexpr float finalz = _MAX(0, MANUAL_PROBE_START_Z); // If a MANUAL_PROBE_START_Z value is set, always respect it #else - do_blocking_move_to_xy(pos); + #warning "It's recommended to set some MANUAL_PROBE_START_Z value for manual leveling." + #endif + #if Z_CLEARANCE_BETWEEN_MANUAL_PROBES > 0 // A probe/obstacle clearance exists so there is a raise: + #ifndef MANUAL_PROBE_START_Z + const float finalz = current_position.z; // - Use the current Z for starting-Z if no MANUAL_PROBE_START_Z was provided + #endif + do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_MANUAL_PROBES); // - Raise Z, then move to the new XY + do_blocking_move_to_z(finalz); // - Lower down to the starting Z height, ready for adjustment! + #elif defined(MANUAL_PROBE_START_Z) // A starting-Z was provided, but there's no raise: + do_blocking_move_to_xy_z(pos, finalz); // - Move in XY then down to the starting Z height, ready for adjustment! + #else // Zero raise and no starting Z height either: + do_blocking_move_to_xy(pos); // - Move over with no raise, ready for adjustment! #endif - - current_position = pos; TERN_(LCD_BED_LEVELING, ui.wait_for_move = false); } -#endif +#endif // MESH_BED_LEVELING || PROBE_MANUALLY #endif // HAS_LEVELING diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 2da584fd49..afc6aad32c 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -100,7 +100,11 @@ void GcodeSuite::G29() { // For each G29 S2... if (mbl_probe_index == 0) { // Move close to the bed before the first point - do_blocking_move_to_z(MANUAL_PROBE_START_Z); + do_blocking_move_to_z(0.4f + #ifdef MANUAL_PROBE_START_Z + + (MANUAL_PROBE_START_Z) - 0.4f + #endif + ); } else { // Save Z for the previous mesh position @@ -116,8 +120,14 @@ void GcodeSuite::G29() { _manual_goto_xy({ mbl.index_to_xpos[ix], mbl.index_to_ypos[iy] }); } else { - // One last "return to the bed" (as originally coded) at completion - current_position.z = MANUAL_PROBE_HEIGHT; + // Move to the after probing position + current_position.z = ( + #ifdef Z_AFTER_PROBING + Z_AFTER_PROBING + #else + Z_CLEARANCE_BETWEEN_MANUAL_PROBES + #endif + ); line_to_current_position(); planner.synchronize(); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 78a6f2c821..429877ce84 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -788,14 +788,6 @@ #endif #endif // FILAMENT_RUNOUT_SENSOR -#if EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL) - #undef PROBE_MANUALLY -#endif - -#if ANY(HAS_BED_PROBE, PROBE_MANUALLY, MESH_BED_LEVELING) - #define PROBE_SELECTED 1 -#endif - #if HAS_BED_PROBE #if DISABLED(NOZZLE_AS_PROBE) #define HAS_PROBE_XY_OFFSET 1 @@ -865,14 +857,16 @@ #define PLANNER_LEVELING 1 #endif #endif -#if EITHER(HAS_ABL_OR_UBL, Z_MIN_PROBE_REPEATABILITY_TEST) - #define HAS_PROBING_PROCEDURE 1 -#endif #if !HAS_LEVELING - #undef PROBE_MANUALLY #undef RESTORE_LEVELING_AFTER_G28 #undef ENABLE_LEVELING_AFTER_G28 #endif +#if !HAS_LEVELING || EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL) + #undef PROBE_MANUALLY +#endif +#if ANY(HAS_BED_PROBE, PROBE_MANUALLY, MESH_BED_LEVELING) + #define PROBE_SELECTED 1 +#endif #ifdef GRID_MAX_POINTS_X #define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y)) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 611c13e344..772c8bc3c1 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2910,9 +2910,9 @@ #define Z_CLEARANCE_BETWEEN_PROBES Z_HOMING_HEIGHT #endif #if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT - #define MANUAL_PROBE_HEIGHT Z_CLEARANCE_BETWEEN_PROBES + #define Z_CLEARANCE_BETWEEN_MANUAL_PROBES Z_CLEARANCE_BETWEEN_PROBES #else - #define MANUAL_PROBE_HEIGHT Z_HOMING_HEIGHT + #define Z_CLEARANCE_BETWEEN_MANUAL_PROBES Z_HOMING_HEIGHT #endif #ifndef Z_CLEARANCE_MULTI_PROBE #define Z_CLEARANCE_MULTI_PROBE Z_CLEARANCE_BETWEEN_PROBES @@ -2922,8 +2922,14 @@ #endif #endif -#if !defined(MANUAL_PROBE_START_Z) && defined(Z_CLEARANCE_BETWEEN_PROBES) - #define MANUAL_PROBE_START_Z Z_CLEARANCE_BETWEEN_PROBES +// Define a starting height for measuring manual probe points +#ifndef MANUAL_PROBE_START_Z + #if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY) + // Leave MANUAL_PROBE_START_Z undefined so the prior Z height will be used. + // Note: If Z_CLEARANCE_BETWEEN_MANUAL_PROBES is 0 there will be no raise between points + #elif ENABLED(AUTO_BED_LEVELING_UBL) && defined(Z_CLEARANCE_BETWEEN_PROBES) + #define MANUAL_PROBE_START_Z Z_CLEARANCE_BETWEEN_PROBES + #endif #endif #ifndef __SAM3X8E__ //todo: hal: broken hal encapsulation diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 5fc9fbccbd..8e9707de5b 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -63,16 +63,16 @@ // and allow the command queue to be processed. // // When G29 finishes the last move: - // - Raise Z to the "manual probe height" + // - Raise Z to the "Z after probing" height // - Don't return until done. // // ** This blocks the command queue! ** // void _lcd_level_bed_done() { if (!ui.wait_for_move) { - #if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING) + #if Z_AFTER_PROBING > 0 && DISABLED(MESH_BED_LEVELING) // Display "Done" screen and wait for moves to complete - line_to_z(MANUAL_PROBE_HEIGHT); + line_to_z(Z_AFTER_PROBING); ui.synchronize(GET_TEXT(MSG_LEVEL_BED_DONE)); #endif ui.goto_previous_screen_no_defer(); From e59192b9ea6f6fd7fa66192e363c69589c86e652 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 25 Apr 2021 04:15:13 -0500 Subject: [PATCH 291/311] Fix HMI_HomeOffN axis Followup to #21534 --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 891732e641..51d192e26f 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -3461,13 +3461,13 @@ void HMI_AdvSet() { DWIN_UpdateLCD(); } - void HMI_HomeOffN(float &posScaled, const_float_t lo, const_float_t hi) { + void HMI_HomeOffN(const AxisEnum axis, float &posScaled, const_float_t lo, const_float_t hi) { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (Apply_Encoder(encoder_diffState, posScaled)) { checkkey = HomeOff; EncoderRate.enabled = false; - set_home_offset(X_AXIS, posScaled / 10); + set_home_offset(axis, posScaled / 10); DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(select_item.now), posScaled); return; } @@ -3476,9 +3476,9 @@ void HMI_AdvSet() { } } - void HMI_HomeOffX() { HMI_HomeOffN(HMI_ValueStruct.Home_OffX_scaled, -500, 500); } - void HMI_HomeOffY() { HMI_HomeOffN(HMI_ValueStruct.Home_OffY_scaled, -500, 500); } - void HMI_HomeOffZ() { HMI_HomeOffN(HMI_ValueStruct.Home_OffZ_scaled, -20, 20); } + void HMI_HomeOffX() { HMI_HomeOffN(X_AXIS, HMI_ValueStruct.Home_OffX_scaled, -500, 500); } + void HMI_HomeOffY() { HMI_HomeOffN(Y_AXIS, HMI_ValueStruct.Home_OffY_scaled, -500, 500); } + void HMI_HomeOffZ() { HMI_HomeOffN(Z_AXIS, HMI_ValueStruct.Home_OffZ_scaled, -20, 20); } #endif // HAS_HOME_OFFSET From e250f6a2756975e0949fc3deb26a777e0e14d5bb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 25 Apr 2021 17:17:02 -0500 Subject: [PATCH 292/311] whitespace --- Marlin/src/gcode/parser.cpp | 2 +- buildroot/share/PlatformIO/scripts/common-dependencies.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 8cbbe1d19d..7e75783b7a 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -217,7 +217,7 @@ void GCodeParser::parse(char *p) { #if ENABLED(GCODE_MOTION_MODES) #if ENABLED(ARC_SUPPORT) - case 'I' ... 'J': + case 'I' ... 'J': if (motion_mode_codenum != 2 && motion_mode_codenum != 3) return; #endif case 'Q': diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index 9ab437dd0b..18a7303be6 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -37,7 +37,7 @@ #define USES_LIQUIDTWI2 #elif ENABLED(LCD_I2C_TYPE_PCA8574) #define USES_LIQUIDCRYSTAL_I2C -#elif ANY(HAS_MARLINUI_HD44780, LCD_I2C_TYPE_PCF8575, SR_LCD_2W_NL , LCM1602) +#elif ANY(HAS_MARLINUI_HD44780, LCD_I2C_TYPE_PCF8575, SR_LCD_2W_NL, LCM1602) #define USES_LIQUIDCRYSTAL #endif From 7aeb6b52005e739e60ddbcd9feca52633f1e2bd3 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 26 Apr 2021 00:36:31 +0000 Subject: [PATCH 293/311] [cron] Bump distribution date (2021-04-26) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 2e631d2f57..e0727bbb6c 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-04-25" + #define STRING_DISTRIBUTION_DATE "2021-04-26" #endif /** From 5ad473fc6246ddcddf6c5e0920bc7d4d389fd718 Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Sun, 25 Apr 2021 21:55:15 -0400 Subject: [PATCH 294/311] Fix relocated LiquidCrystal library (#21699) Followup to 770e539859 --- ini/features.ini | 2 +- ini/lpc176x.ini | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ini/features.ini b/ini/features.ini index 1f4bf98531..118392d6d7 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -30,7 +30,7 @@ HAS_L64XX = Arduino-L6470@0.8.0 NEOPIXEL_LED = Adafruit NeoPixel@1.5.0 src_filter=+ TEMP_.+_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0 -USES_LIQUIDCRYSTAL = arduino-libraries/LiquidCrystal@^1.0.7 +USES_LIQUIDCRYSTAL = fmalpartida/LiquidCrystal@1.5.0 USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 HAS_WIRED_LCD = src_filter=+ diff --git a/ini/lpc176x.ini b/ini/lpc176x.ini index 494d7baac8..450585b01a 100644 --- a/ini/lpc176x.ini +++ b/ini/lpc176x.ini @@ -23,6 +23,7 @@ extra_scripts = ${common.extra_scripts} src_filter = ${common.default_src_filter} + + lib_deps = ${common.lib_deps} Servo +custom_marlin.USES_LIQUIDCRYSTAL = arduino-libraries/LiquidCrystal@~1.0.7 custom_marlin.NEOPIXEL_LED = Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/1.5.0.zip build_flags = ${common.build_flags} -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC1768/include -IMarlin/src/HAL/LPC1768/u8g # debug options for backtrace From 641bca87bc9391a01a9de06e8d597dda5908590e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 25 Apr 2021 23:33:52 -0500 Subject: [PATCH 295/311] Prettier output from opt scripts (#21707) --- buildroot/bin/opt_disable | 10 ++++++---- buildroot/bin/opt_enable | 10 ++++++---- buildroot/bin/opt_set | 13 +++++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/buildroot/bin/opt_disable b/buildroot/bin/opt_disable index 11526132ef..18ec03aa94 100755 --- a/buildroot/bin/opt_disable +++ b/buildroot/bin/opt_disable @@ -6,8 +6,10 @@ set -e SED=$(which gsed || which sed) for opt in "$@" ; do - # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648 - eval "${SED} -i '/\([[:blank:]]*\)\(\/\/\)*\([[:blank:]]*\)\(#define \b${opt}\b\)/{s//\1\3\/\/\4/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || - eval "${SED} -i '/\([[:blank:]]*\)\(\/\/\)*\([[:blank:]]*\)\(#define \b${opt}\b\)/{s//\1\3\/\/\4/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || - (echo "ERROR: opt_disable Can't find ${opt}" >&2 && exit 9) + DID=0 ; FOUND=0 + for FN in Configuration Configuration_adv; do + "${SED}" -i "/^\(\s*\)\(#define\s\+${opt}\b\s\?\)\(\s\s\)\?/{s//\1\/\/\2/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1 + ((DID||FOUND)) || { grep -E "^\s*//\s*#define\s+${opt}\b" Marlin/$FN.h >/dev/null && FOUND=1 ; } + done + ((DID||FOUND)) || (echo "ERROR: $(basename $0) Can't find ${opt}" >&2 && exit 9) done diff --git a/buildroot/bin/opt_enable b/buildroot/bin/opt_enable index 9161299b6e..d341ee9bd3 100755 --- a/buildroot/bin/opt_enable +++ b/buildroot/bin/opt_enable @@ -6,8 +6,10 @@ set -e SED=$(which gsed || which sed) for opt in "$@" ; do - # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648 - eval "${SED} -i '/^\([[:blank:]]*\/\/\)*[[:blank:]]*\(#define \b${opt}\b\)/{s//\2/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || - eval "${SED} -i '/^\([[:blank:]]*\/\/\)*[[:blank:]]*\(#define \b${opt}\b\)/{s//\2/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || - (echo "ERROR: opt_enable Can't find ${opt}" >&2 && exit 9) + DID=0 ; FOUND=0 + for FN in Configuration Configuration_adv; do + "${SED}" -i "/^\(\s*\)\/\/\(\s*\)\(#define\s\+${opt}\b\)\( \?\)/{s//\1\2\3\4\4\4/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1 + ((DID||FOUND)) || { grep -E "^\s*#define\s+${opt}\b" Marlin/$FN.h >/dev/null && FOUND=1 ; } + done + ((DID||FOUND)) || (echo "ERROR: $(basename $0) Can't find ${opt}" >&2 && exit 9) done diff --git a/buildroot/bin/opt_set b/buildroot/bin/opt_set index 2e63790c69..d2d0cc241f 100755 --- a/buildroot/bin/opt_set +++ b/buildroot/bin/opt_set @@ -5,12 +5,13 @@ set -e SED=$(which gsed || which sed) -ARGC=$# while [[ $# > 1 ]]; do - # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648 - eval "${SED} -i '/^\([[:blank:]]*\)\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\1\3\4 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" || - eval "${SED} -i '/^\([[:blank:]]*\)\(\/\/\)*\([[:blank:]]*\)\(#define\s\+\b${1}\b\).*$/{s//\1\3\4 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" || - eval "echo '#define ${1} ${2}' >>Marlin/Configuration.h" || - (echo "ERROR: opt_set Can't set or add ${1}" >&2 && exit 9) + DID=0 + for FN in Configuration Configuration_adv; do + "${SED}" -i "/^\(\s*\)\/*\s*\(#define\s\+${1}\b\)\(.*\)$/{s//\1\2 ${2} \/\/ \3/;h};\${x;/./{x;q0};x;q9}" Marlin/$FN.h && DID=1 + done + ((DID)) || + eval "echo '#define ${1} ${2}' >>Marlin/Configuration.h" || + (echo "ERROR: opt_set Can't set or add ${1}" >&2 && exit 9) shift 2 done From 40d789ce18e48e9328e3a4d144b889048b809ca5 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sun, 25 Apr 2021 21:34:42 -0700 Subject: [PATCH 296/311] Fix "continuous" typo (#21701) --- Marlin/Configuration_adv.h | 2 +- Marlin/src/HAL/STM32F1/MarlinSerial.cpp | 2 +- Marlin/src/lcd/marlinui.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index eb3c7b0df8..1a10244e55 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2842,7 +2842,7 @@ /** * Enable M122 debugging command for TMC stepper drivers. - * M122 S0/1 will enable continous reporting. + * M122 S0/1 will enable continuous reporting. */ //#define TMC_DEBUG diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp index a46e3ab3ab..fa8bb7eaa8 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp @@ -60,7 +60,7 @@ static inline __always_inline void my_usart_irq(ring_buffer *rb, ring_buffer *wb } else if (srflags & USART_SR_ORE) { // overrun and empty data, just do a dummy read to clear ORE - // and prevent a raise condition where a continous interrupt stream (due to ORE set) occurs + // and prevent a raise condition where a continuous interrupt stream (due to ORE set) occurs // (see chapter "Overrun error" ) in STM32 reference manual regs->DR; } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 812dac53b7..476caf3225 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -855,7 +855,7 @@ void MarlinUI::update() { static bool wait_for_unclick; // = false auto do_click = [&]{ - wait_for_unclick = true; // - Set debounce flag to ignore continous clicks + wait_for_unclick = true; // - Set debounce flag to ignore continuous clicks lcd_clicked = !wait_for_user; // - Keep the click if not waiting for a user-click wait_for_user = false; // - Any click clears wait for user quick_feedback(); // - Always make a click sound From a0a24e9380a5b4d7070b8c5cd261efd3de517fe2 Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Mon, 26 Apr 2021 19:22:27 -0400 Subject: [PATCH 297/311] Help users confused by "bed size" (#21714) --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 8e2ade8299..442f502c3e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1224,7 +1224,7 @@ // @section machine -// The size of the print bed +// The size of the printable area #define X_BED_SIZE 200 #define Y_BED_SIZE 200 From 5301ec618be01dd2794d8f3e420f6172b34dad22 Mon Sep 17 00:00:00 2001 From: hartmannathan <59230071+hartmannathan@users.noreply.github.com> Date: Mon, 26 Apr 2021 19:30:26 -0400 Subject: [PATCH 298/311] typo (#21710) --- Marlin/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index a3ca81abdd..5ff1830822 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -993,5 +993,5 @@ clean: .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter -# Automaticaly include the dependency files created by gcc +# Automatically include the dependency files created by gcc -include ${patsubst %.o, %.d, ${OBJ}} From 36ec7ab150f784f257addcfc2ece753d1a638855 Mon Sep 17 00:00:00 2001 From: Sebastiaan Dammann Date: Tue, 27 Apr 2021 01:32:13 +0200 Subject: [PATCH 299/311] Make Cancel Objects reporting optional (#21698) --- Marlin/Configuration_adv.h | 3 +++ Marlin/src/feature/cancel_object.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 1a10244e55..8cfaa95787 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3641,6 +3641,9 @@ * Implement M486 to allow Marlin to skip objects */ //#define CANCEL_OBJECTS +#if ENABLED(CANCEL_OBJECTS) + #define CANCEL_OBJECTS_REPORTING // Emit the current object as a status message +#endif /** * I2C position encoders for closed loop control. diff --git a/Marlin/src/feature/cancel_object.cpp b/Marlin/src/feature/cancel_object.cpp index 1f92ac5843..ee5716888d 100644 --- a/Marlin/src/feature/cancel_object.cpp +++ b/Marlin/src/feature/cancel_object.cpp @@ -43,7 +43,7 @@ void CancelObject::set_active_object(const int8_t obj) { else skipping = false; - #if HAS_STATUS_MESSAGE + #if BOTH(HAS_STATUS_MESSAGE, CANCEL_OBJECTS_REPORTING) if (active_object >= 0) ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object)); else From a981c33baddb240fb0a48e6c702b9ce6f1128dae Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Mon, 26 Apr 2021 21:30:34 -0300 Subject: [PATCH 300/311] Remove compiler flag merge-constants (#21711) --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 75e7f6a58b..d17c283b72 100644 --- a/platformio.ini +++ b/platformio.ini @@ -36,7 +36,7 @@ extra_configs = # Remove '-fmax-errors=5' from build_flags below to see all. # [common] -build_flags = -g3 -D__MARLIN_FIRMWARE__ -DNDEBUG -fmerge-constants +build_flags = -g3 -D__MARLIN_FIRMWARE__ -DNDEBUG -fmax-errors=5 extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py From 43fc1bd21c5171e324047e147ce41d0bcae5e3df Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 27 Apr 2021 00:35:59 +0000 Subject: [PATCH 301/311] [cron] Bump distribution date (2021-04-27) --- 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 e0727bbb6c..c5c707d067 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-04-26" + #define STRING_DISTRIBUTION_DATE "2021-04-27" #endif /** From 5f9aac2027c241056c83d497054be91c64b086e7 Mon Sep 17 00:00:00 2001 From: ellensp Date: Tue, 27 Apr 2021 16:36:39 +1200 Subject: [PATCH 302/311] Use temp_info_t for temp_redundant (#21715) Fixes #21712 Co-authored-by: Scott Lahteine --- Marlin/src/module/temperature.cpp | 49 +++++++++++++++---------------- Marlin/src/module/temperature.h | 30 +++++++++++-------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8e2b2d6b91..462af7f61a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -256,7 +256,11 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #endif #if HAS_HOTEND - hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 } + hotend_info_t Temperature::temp_hotend[HOTENDS]; + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + temp_info_t Temperature::temp_redundant; + #endif + #define _HMT(N) HEATER_##N##_MAXTEMP, const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); #endif @@ -420,11 +424,6 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, bool Temperature::inited = false; #endif -#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - int16_t Temperature::redundant_temperature_raw = 0; - celsius_float_t Temperature::redundant_temperature = 0.0; -#endif - volatile bool Temperature::raw_temps_ready = false; #if ENABLED(PID_EXTRUSION_SCALING) @@ -1225,12 +1224,12 @@ void Temperature::manage_heater() { #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) #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); + if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); + if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); #endif #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); + if (TERN(TEMP_SENSOR_1_AS_REDUNDANT, degHotendRedundant(), degHotend(1)) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); + if (TERN(TEMP_SENSOR_1_AS_REDUNDANT, degHotendRedundant(), degHotend(1)) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); #endif #endif @@ -1266,7 +1265,7 @@ void Temperature::manage_heater() { #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) // Make sure measured temperatures are close together - if (ABS(temp_hotend[0].celsius - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) + if (ABS(degHotend(0) - degHotendRedundant()) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) _temp_error(H_E0, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP)); #endif @@ -1668,7 +1667,7 @@ void Temperature::manage_heater() { SERIAL_EOL(); } - celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) { + celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw) { //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB) // static uint32_t clocks_total = 0; // static uint32_t calls = 0; @@ -1717,8 +1716,8 @@ void Temperature::manage_heater() { #if HAS_HOTEND // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. - celsius_float_t Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) { - if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) { + celsius_float_t Temperature::analog_to_celsius_hotend(const int16_t raw, const uint8_t e) { + if (e >= HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) { SERIAL_ERROR_START(); SERIAL_ECHO(e); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM); @@ -1826,7 +1825,7 @@ void Temperature::manage_heater() { #if HAS_HEATED_BED // For bed temperature measurement. - celsius_float_t Temperature::analog_to_celsius_bed(const int raw) { + celsius_float_t Temperature::analog_to_celsius_bed(const int16_t raw) { #if TEMP_SENSOR_BED_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BED, raw); #elif TEMP_SENSOR_BED_IS_THERMISTOR @@ -1844,7 +1843,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_CHAMBER // For chamber temperature measurement. - celsius_float_t Temperature::analog_to_celsius_chamber(const int raw) { + celsius_float_t Temperature::analog_to_celsius_chamber(const int16_t raw) { #if TEMP_SENSOR_CHAMBER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_CHAMBER, raw); #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR @@ -1862,7 +1861,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_COOLER // For cooler temperature measurement. - celsius_float_t Temperature::analog_to_celsius_cooler(const int raw) { + celsius_float_t Temperature::analog_to_celsius_cooler(const int16_t raw) { #if TEMP_SENSOR_COOLER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_COOLER, raw); #elif TEMP_SENSOR_COOLER_IS_THERMISTOR @@ -1880,7 +1879,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_PROBE // For probe temperature measurement. - celsius_float_t Temperature::analog_to_celsius_probe(const int raw) { + celsius_float_t Temperature::analog_to_celsius_probe(const int16_t raw) { #if TEMP_SENSOR_PROBE_IS_CUSTOM return user_thermistor_to_deg_c(CTI_PROBE, raw); #elif TEMP_SENSOR_PROBE_IS_THERMISTOR @@ -1904,15 +1903,15 @@ void Temperature::manage_heater() { */ void Temperature::updateTemperaturesFromRawValues() { 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)); + TERN_(TEMP_SENSOR_1_IS_MAX_TC, TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, 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 + TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant.celsius = analog_to_celsius_hotend(temp_redundant.raw, 1)); TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw)); TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw)); TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.raw)); TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw)); - TERN_(TEMP_SENSOR_1_AS_REDUNDANT, redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1)); TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); @@ -2707,7 +2706,7 @@ void Temperature::update_raw_temperatures() { #if HAS_TEMP_ADC_1 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - redundant_temperature_raw = temp_hotend[1].acc; + temp_redundant.update(); #elif !TEMP_SENSOR_1_IS_MAX_TC temp_hotend[1].update(); #endif @@ -2741,7 +2740,7 @@ void Temperature::readings_ready() { #if HAS_HOTEND HOTEND_LOOP() temp_hotend[e].reset(); - TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_hotend[1].reset()); + TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant.reset()); #endif TERN_(HAS_HEATED_BED, temp_bed.reset()); @@ -3245,7 +3244,7 @@ void Temperature::isr() { #if HAS_TEMP_ADC_1 case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break; - case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break; + case MeasureTemp_1: ACCUMULATE_ADC(TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1])); break; #endif #if HAS_TEMP_ADC_2 @@ -3443,9 +3442,9 @@ void Temperature::isr() { #endif ); #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - if (include_r) print_heater_state(redundant_temperature, degTargetHotend(target_extruder) + if (include_r) print_heater_state(degHotendRedundant(), degTargetHotend(0) #if ENABLED(SHOW_TEMP_ADC_VALUES) - , redundant_temperature_raw + , rawHotendTempRedundant() #endif , H_REDUNDANT ); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index b7d52e8a08..2bb773f805 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -321,8 +321,10 @@ class Temperature { public: #if HAS_HOTEND - #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) - static hotend_info_t temp_hotend[HOTEND_TEMPS]; + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + static temp_info_t temp_redundant; + #endif + static hotend_info_t temp_hotend[HOTENDS]; static const celsius_t hotend_maxtemp[HOTENDS]; static inline celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif @@ -423,11 +425,6 @@ class Temperature { static hotend_watch_t watch_hotend[HOTENDS]; #endif - #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - static uint16_t redundant_temperature_raw; - static celsius_t redundant_temperature; - #endif - #if ENABLED(PID_EXTRUSION_SCALING) static int32_t last_e_position, lpq[LPQ_MAX_LEN]; static lpq_ptr_t lpq_ptr; @@ -501,7 +498,7 @@ class Temperature { static user_thermistor_t user_thermistor[USER_THERMISTORS]; static void log_user_thermistor(const uint8_t t_index, const bool eprom=false); static void reset_user_thermistors(); - static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw); + static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw); static inline bool set_pull_up_res(int8_t t_index, float value) { //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false; if (!WITHIN(value, 1, 1000000)) return false; @@ -529,19 +526,19 @@ class Temperature { #endif #if HAS_HOTEND - static celsius_float_t analog_to_celsius_hotend(const int raw, const uint8_t e); + static celsius_float_t analog_to_celsius_hotend(const int16_t raw, const uint8_t e); #endif #if HAS_HEATED_BED - static celsius_float_t analog_to_celsius_bed(const int raw); + static celsius_float_t analog_to_celsius_bed(const int16_t raw); #endif #if HAS_TEMP_PROBE - static celsius_float_t analog_to_celsius_probe(const int raw); + static celsius_float_t analog_to_celsius_probe(const int16_t raw); #endif #if HAS_TEMP_CHAMBER - static celsius_float_t analog_to_celsius_chamber(const int raw); + static celsius_float_t analog_to_celsius_chamber(const int16_t raw); #endif #if HAS_TEMP_COOLER - static celsius_float_t analog_to_celsius_cooler(const int raw); + static celsius_float_t analog_to_celsius_cooler(const int16_t raw); #endif #if HAS_FAN @@ -631,6 +628,10 @@ class Temperature { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius); } + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + static inline celsius_float_t degHotendRedundant() { return temp_redundant.celsius; } + #endif + static inline celsius_t wholeDegHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, static_cast(temp_hotend[HOTEND_INDEX].celsius + 0.5f)); } @@ -639,6 +640,9 @@ class Temperature { static inline int16_t rawHotendTemp(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw); } + #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) + static inline int16_t rawHotendTempRedundant() { return temp_redundant.raw; } + #endif #endif static inline celsius_t degTargetHotend(const uint8_t E_NAME) { From 9c7344487a04940c845d9c39215f0d28ac26208f Mon Sep 17 00:00:00 2001 From: Marcio T Date: Mon, 26 Apr 2021 22:40:59 -0600 Subject: [PATCH 303/311] FTDI EVE Touch UI fixes (#21706) --- .../archim2-flash/media_file_reader.h | 2 +- .../cocoa_press_advanced_settings_menu.cpp | 12 ++--- .../screens/cocoa_press_main_menu.cpp | 31 ++++++------ .../screens/flow_percent_screen.cpp | 50 +++++++++++++++++++ .../screens/flow_percent_screen.h | 31 ++++++++++++ .../screens/leveling_menu.cpp | 3 +- .../lib/ftdi_eve_touch_ui/screens/screens.cpp | 1 + .../lib/ftdi_eve_touch_ui/screens/screens.h | 2 + .../src/lcd/extui/lib/nextion/nextion_tft.cpp | 8 +-- Marlin/src/lcd/extui/ui_api.cpp | 2 +- Marlin/src/lcd/extui/ui_api.h | 2 +- 11 files changed, 112 insertions(+), 32 deletions(-) create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/flow_percent_screen.cpp create mode 100644 Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/flow_percent_screen.h diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h index d9edea8388..3528dd9e15 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h @@ -32,7 +32,7 @@ class MediaFileReader { private: #if ENABLED(SDSUPPORT) - Sd2Card card; + DiskIODriver_SPI_SD card; SdVolume volume; SdFile root, file; #endif 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 8d5a3d793a..7bd149bd46 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 @@ -40,8 +40,7 @@ using namespace Theme; #define DISPLAY_POS BTN_POS(1,3), BTN_SIZE(1,1) #define INTERFACE_POS BTN_POS(2,3), BTN_SIZE(1,1) #define ENDSTOPS_POS BTN_POS(3,3), BTN_SIZE(1,1) -#define CASE_LIGHT_POS BTN_POS(1,4), BTN_SIZE(1,1) -#define RESTORE_DEFAULTS_POS BTN_POS(2,4), BTN_SIZE(1,1) +#define RESTORE_DEFAULTS_POS BTN_POS(1,4), BTN_SIZE(2,1) #define BACK_POS BTN_POS(3,4), BTN_SIZE(1,1) void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { @@ -66,9 +65,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .tag(8) .button(ENDSTOPS_POS, GET_TEXT_F(MSG_LCD_ENDSTOPS)) .tag(9) .button(INTERFACE_POS, GET_TEXT_F(MSG_INTERFACE)) .tag(10).button(DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU)) - .enabled(ENABLED(CASE_LIGHT_ENABLE)) - .tag(11).button(CASE_LIGHT_POS, GET_TEXT_F(MSG_CASE_LIGHT)) - .tag(12).button(RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS)) + .tag(11).button(RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS)) .colors(action_btn) .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); } @@ -90,10 +87,7 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) { case 8: GOTO_SCREEN(EndstopStatesScreen); break; case 9: GOTO_SCREEN(InterfaceSettingsScreen); LockScreen::check_passcode(); break; case 10: GOTO_SCREEN(DisplayTuningScreen); break; - #if ENABLED(CASE_LIGHT_ENABLE) - case 11: GOTO_SCREEN(CaseLightScreen); break; - #endif - case 12: GOTO_SCREEN(RestoreFailsafeDialogBox); LockScreen::check_passcode(); break; + case 11: GOTO_SCREEN(RestoreFailsafeDialogBox); LockScreen::check_passcode(); break; default: return false; } return true; 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 f35b3296d8..7708b38eca 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 @@ -29,7 +29,7 @@ using namespace FTDI; using namespace Theme; -#define GRID_ROWS 5 +#define GRID_ROWS 6 #define GRID_COLS 2 #define ZPROBE_ZOFFSET_POS BTN_POS(1,1), BTN_SIZE(1,1) @@ -37,11 +37,12 @@ using namespace Theme; #define TEMPERATURE_POS BTN_POS(2,1), BTN_SIZE(1,1) #define MOVE_E_POS BTN_POS(2,2), BTN_SIZE(1,1) #define SPEED_POS BTN_POS(1,3), BTN_SIZE(1,1) -#define ADVANCED_SETTINGS_POS BTN_POS(2,3), BTN_SIZE(1,1) -#define DISABLE_STEPPERS_POS BTN_POS(1,4), BTN_SIZE(1,1) -#define LEVELING_POS BTN_POS(2,4), BTN_SIZE(1,1) -#define ABOUT_PRINTER_POS BTN_POS(1,5), BTN_SIZE(1,1) -#define BACK_POS BTN_POS(2,5), BTN_SIZE(1,1) +#define FLOW_POS BTN_POS(2,3), BTN_SIZE(1,1) +#define ADVANCED_SETTINGS_POS BTN_POS(1,4), BTN_SIZE(1,1) +#define DISABLE_STEPPERS_POS BTN_POS(2,4), BTN_SIZE(1,1) +#define LEVELING_POS BTN_POS(1,5), BTN_SIZE(1,1) +#define ABOUT_PRINTER_POS BTN_POS(2,5), BTN_SIZE(1,1) +#define BACK_POS BTN_POS(1,6), BTN_SIZE(2,1) void MainMenu::onRedraw(draw_mode_t what) { if (what & BACKGROUND) { @@ -60,11 +61,12 @@ void MainMenu::onRedraw(draw_mode_t what) { .tag( 4).button(ZPROBE_ZOFFSET_POS, GET_TEXT_F(MSG_ZPROBE_ZOFFSET)) .tag( 5).button(MOVE_E_POS, GET_TEXT_F(MSG_E_MOVE)) .tag( 6).button(SPEED_POS, GET_TEXT_F(MSG_PRINT_SPEED)) - .tag( 7).button(ADVANCED_SETTINGS_POS, GET_TEXT_F(MSG_ADVANCED_SETTINGS)) - .tag( 8).button(DISABLE_STEPPERS_POS, GET_TEXT_F(MSG_DISABLE_STEPPERS)) + .tag( 7).button(FLOW_POS, GET_TEXT_F(MSG_FLOW)) + .tag( 8).button(ADVANCED_SETTINGS_POS, GET_TEXT_F(MSG_ADVANCED_SETTINGS)) + .tag( 9).button(DISABLE_STEPPERS_POS, GET_TEXT_F(MSG_DISABLE_STEPPERS)) .enabled(HAS_LEVELING) - .tag( 9).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING)) - .tag(10).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU)) + .tag(10).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING)) + .tag(11).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU)) .colors(action_btn) .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK)); } @@ -82,12 +84,13 @@ bool MainMenu::onTouchEnd(uint8_t tag) { #endif case 5: GOTO_SCREEN(MoveEScreen); break; case 6: GOTO_SCREEN(FeedratePercentScreen); break; - case 7: GOTO_SCREEN(AdvancedSettingsMenu); break; - case 8: injectCommands_P(PSTR("M84")); break; + case 7: GOTO_SCREEN(FlowPercentScreen); break; + case 8: GOTO_SCREEN(AdvancedSettingsMenu); break; + case 9: injectCommands_P(PSTR("M84")); break; #if HAS_LEVELING - case 9: GOTO_SCREEN(LevelingMenu); break; + case 10: GOTO_SCREEN(LevelingMenu); break; #endif - case 10: GOTO_SCREEN(AboutScreen); break; + case 11: GOTO_SCREEN(AboutScreen); break; default: return false; } diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/flow_percent_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/flow_percent_screen.cpp new file mode 100644 index 0000000000..5280092ced --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/flow_percent_screen.cpp @@ -0,0 +1,50 @@ +/*************************** + * flow_percent_screen.cpp * + ***************************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2021 - 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: . * + ****************************************************************************/ + +#include "../config.h" +#include "screens.h" + +#ifdef FTDI_FLOW_PERCENT_SCREEN + +using namespace FTDI; +using namespace ExtUI; + +void FlowPercentScreen::onRedraw(draw_mode_t what) { + widgets_t w(what); + w.precision(0).units(GET_TEXT_F(MSG_UNITS_PERCENT)); + + w.heading(GET_TEXT_F(MSG_FLOW)); + w.adjuster(4, GET_TEXT_F(MSG_FLOW), getFlow_percent(E0)); + w.increments(); +} + +bool FlowPercentScreen::onTouchHeld(uint8_t tag) { + const float increment = getIncrement(); + switch (tag) { + case 4: UI_DECREMENT(Flow_percent, E0); break; + case 5: UI_INCREMENT(Flow_percent, E0); break; + default: + return false; + } + return true; +} + +#endif // FTDI_FLOW_PERCENT_SCREEN diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/flow_percent_screen.h b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/flow_percent_screen.h new file mode 100644 index 0000000000..3e37531d1d --- /dev/null +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/flow_percent_screen.h @@ -0,0 +1,31 @@ +/************************* + * flow_percent_screen.h * + *************************/ + +/**************************************************************************** + * Written By Marcio Teixeira 2021 - 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_FLOW_PERCENT_SCREEN +#define FTDI_FLOW_PERCENT_SCREEN_CLASS FlowPercentScreen + +class FlowPercentScreen : 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/leveling_menu.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/leveling_menu.cpp index ffdd69b2dd..752b17ee00 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 @@ -81,9 +81,8 @@ void LevelingMenu::onRedraw(draw_mode_t what) { .text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH)) #endif .font(font_medium).colors(normal_btn) - #if EITHER(Z_STEPPER_AUTO_ALIGN,MECHANICAL_GANTRY_CALIBRATION) + .enabled(EITHER(Z_STEPPER_AUTO_ALIGN,MECHANICAL_GANTRY_CALIBRATION)) .tag(2).button(LEVEL_AXIS_POS, GET_TEXT_F(MSG_LEVEL_X_AXIS)) - #endif .tag(3).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED)) .enabled(ENABLED(HAS_MESH)) .tag(4).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH)) 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 f115aecbc7..c3e015d75c 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 @@ -80,6 +80,7 @@ SCREEN_TABLE { 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_FLOW_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) 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 14b8197fbf..a0cb71a6a6 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 @@ -55,6 +55,7 @@ enum { MAX_VELOCITY_SCREEN_CACHE, MAX_ACCELERATION_SCREEN_CACHE, DEFAULT_ACCELERATION_SCREEN_CACHE, + FLOW_PERCENT_SCREEN_CACHE, #if HAS_LEVELING LEVELING_SCREEN_CACHE, #if HAS_BED_PROBE @@ -150,6 +151,7 @@ enum { #include "cocoa_press_preheat_screen.h" #include "cocoa_press_load_chocolate.h" #include "move_axis_screen.h" + #include "flow_percent_screen.h" #include "cocoa_press_move_xyz_screen.h" #include "cocoa_press_move_e_screen.h" #include "tune_menu.h" diff --git a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp index 679f66d807..6272d58970 100644 --- a/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/lib/nextion/nextion_tft.cpp @@ -237,7 +237,7 @@ void NextionTFT::PanelInfo(uint8_t req) { SEND_VALasTXT("tmppage.tool", getActiveTool()); SEND_VALasTXT("tmppage.fan", ui8tostr3rj(getActualFan_percent(FAN0))); SEND_VALasTXT("tmppage.speed", getFeedrate_percent()); - SEND_VALasTXT("tmppage.flow", getFlowPercentage(getActiveTool())); + SEND_VALasTXT("tmppage.flow", getFlow_percent(getActiveTool())); SEND_VALasTXT("tmppage.progress", ui8tostr3rj(getProgress_percent())); SEND_VALasTXT("tmppage.layer", layer); SEND_VALasTXT("tmppage.x", getAxisPosition_mm(X)); @@ -640,9 +640,9 @@ void NextionTFT::UpdateOnChange() { // tmppage Flow static uint8_t last_flow_speed = 99; - if (last_flow_speed != getFlowPercentage(getActiveTool())) { - SEND_VALasTXT("tmppage.flow", getFlowPercentage(getActiveTool())); - last_flow_speed = getFlowPercentage(getActiveTool()); + if (last_flow_speed != getFlow_percent(getActiveTool())) { + SEND_VALasTXT("tmppage.flow", getFlow_percent(getActiveTool())); + last_flow_speed = getFlow_percent(getActiveTool()); } // tmppage Progress + Layer + Time diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index accca50d1e..9cc8b9962c 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -691,7 +691,7 @@ namespace ExtUI { #endif feedRate_t getFeedrate_mm_s() { return feedrate_mm_s; } - int16_t getFlowPercentage(const extruder_t extr) { return planner.flow_percentage[extr]; } + int16_t getFlow_percent(const extruder_t extr) { return planner.flow_percentage[extr]; } feedRate_t getMinFeedrate_mm_s() { return planner.settings.min_feedrate_mm_s; } feedRate_t getMinTravelFeedrate_mm_s() { return planner.settings.min_travel_feedrate_mm_s; } float getPrintingAcceleration_mm_s2() { return planner.settings.acceleration; } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 04395bec4e..e6452243fd 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -129,7 +129,7 @@ namespace ExtUI { float getRetractAcceleration_mm_s2(); float getTravelAcceleration_mm_s2(); float getFeedrate_percent(); - int16_t getFlowPercentage(const extruder_t); + int16_t getFlow_percent(const extruder_t); inline uint8_t getProgress_percent() { return ui.get_progress_percent(); } From fe7f5ca7f4448238f2878efd26ac8dcefe950808 Mon Sep 17 00:00:00 2001 From: Adrian DC Date: Tue, 27 Apr 2021 06:42:28 +0200 Subject: [PATCH 304/311] Fix E3V2 Advanced Settings with PLR off (#21700) Fixes #21534 --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 51d192e26f..9fdf401b57 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -2381,10 +2381,12 @@ void Draw_AdvSet_Menu() { #endif if (AVISI(ADVSET_CASE_HEPID)) Draw_Menu_Line(ASCROL(ADVSET_CASE_HEPID), ICON_PIDNozzle, "Hotend PID", false); // Nozzle PID if (AVISI(ADVSET_CASE_BEDPID)) Draw_Menu_Line(ASCROL(ADVSET_CASE_BEDPID), ICON_PIDbed, "Bed PID", false); // Bed PID - if (AVISI(ADVSET_CASE_PWRLOSSR)) { - Draw_Menu_Line(ASCROL(ADVSET_CASE_PWRLOSSR), ICON_Motion, "Power-loss recovery", false); // Power-loss recovery - Draw_Chkb_Line(ASCROL(ADVSET_CASE_PWRLOSSR), recovery.enabled); - } + #if ENABLED(POWER_LOSS_RECOVERY) + if (AVISI(ADVSET_CASE_PWRLOSSR)) { + Draw_Menu_Line(ASCROL(ADVSET_CASE_PWRLOSSR), ICON_Motion, "Power-loss recovery", false); // Power-loss recovery + Draw_Chkb_Line(ASCROL(ADVSET_CASE_PWRLOSSR), recovery.enabled); + } + #endif if (select_advset.now) Draw_Menu_Cursor(ASCROL(select_advset.now)); } @@ -3409,10 +3411,12 @@ void HMI_AdvSet() { break; #endif - case ADVSET_CASE_PWRLOSSR: // Power-loss recovery - recovery.enable(!recovery.enabled); - Draw_Chkb_Line(ADVSET_CASE_PWRLOSSR + MROWS - index_advset, recovery.enabled); - break; + #if ENABLED(POWER_LOSS_RECOVERY) + case ADVSET_CASE_PWRLOSSR: // Power-loss recovery + recovery.enable(!recovery.enabled); + Draw_Chkb_Line(ADVSET_CASE_PWRLOSSR + MROWS - index_advset, recovery.enabled); + break; + #endif default: break; } } From 69d85cce2da20b88784db68324c228db212af071 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Tue, 27 Apr 2021 00:22:09 -0700 Subject: [PATCH 305/311] BTT SKR V2.0 / Stepper Driver Anti-Reverse Protection (#21503) --- Marlin/Configuration_adv.h | 9 + Marlin/src/MarlinCore.cpp | 17 + Marlin/src/core/boards.h | 37 +- Marlin/src/feature/stepper_driver_safety.cpp | 171 +++++++ Marlin/src/feature/stepper_driver_safety.h | 28 ++ Marlin/src/inc/Conditionals_post.h | 4 + Marlin/src/lcd/language/language_en.h | 2 + Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h | 495 +++++++++++++++++++ ini/features.ini | 1 + ini/stm32f4.ini | 20 + platformio.ini | 1 + 12 files changed, 769 insertions(+), 18 deletions(-) create mode 100644 Marlin/src/feature/stepper_driver_safety.cpp create mode 100644 Marlin/src/feature/stepper_driver_safety.h create mode 100644 Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8cfaa95787..149ac610f5 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3387,6 +3387,15 @@ #define POWER_MONITOR_VOLTAGE_OFFSET 0 // Offset (in volts) applied to the calculated voltage #endif +/** + * Stepper Driver Anti-SNAFU Protection + * + * If the SAFE_POWER_PIN is defined for your board, Marlin will check + * that stepper drivers are properly plugged in before applying power. + * Disable protection if your stepper drivers don't support the feature. + */ +//#define DISABLE_DRIVER_SAFE_POWER_PROTECT + /** * CNC Coordinate Systems * diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 7139d54f25..209c9b59d0 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -232,6 +232,10 @@ #include "lcd/extui/lib/dgus/DGUSScreenHandler.h" #endif +#if HAS_DRIVER_SAFE_POWER_PROTECT + #include "feature/stepper_driver_safety.h" +#endif + PGMSTR(M112_KILL_STR, "M112 Shutdown"); MarlinState marlin_state = MF_INITIALIZING; @@ -1223,6 +1227,15 @@ void setup() { SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) #endif + #if PIN_EXISTS(SAFE_POWER) + #if HAS_DRIVER_SAFE_POWER_PROTECT + SETUP_RUN(stepper_driver_backward_check()); + #else + SETUP_LOG("SAFE_POWER"); + OUT_WRITE(SAFE_POWER_PIN, HIGH); + #endif + #endif + #if ENABLED(PROBE_TARE) SETUP_RUN(probe.tare_init()); #endif @@ -1467,6 +1480,10 @@ void setup() { SETUP_RUN(test_tmc_connection(true, true, true, true)); #endif + #if HAS_DRIVER_SAFE_POWER_PROTECT + SETUP_RUN(stepper_driver_backward_report()); + #endif + #if HAS_PRUSA_MMU2 SETUP_RUN(mmu2.init()); #endif diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 377147504f..614a3b6e9e 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -363,25 +363,26 @@ #define BOARD_BLACK_STM32F407VE 4204 // BLACK_STM32F407VE #define BOARD_BLACK_STM32F407ZE 4205 // BLACK_STM32F407ZE #define BOARD_STEVAL_3DP001V1 4206 // STEVAL-3DP001V1 3D PRINTER BOARD -#define BOARD_BTT_SKR_PRO_V1_1 4207 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) -#define BOARD_BTT_SKR_PRO_V1_2 4208 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) -#define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VG) +#define BOARD_BTT_SKR_PRO_V1_1 4207 // BigTreeTech SKR Pro v1.1 (STM32F407ZGT6) +#define BOARD_BTT_SKR_PRO_V1_2 4208 // BigTreeTech SKR Pro v1.2 (STM32F407ZGT6) +#define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VGT6) #define BOARD_BTT_E3_RRF 4210 // BigTreeTech E3 RRF (STM32F407VGT6) -#define BOARD_BTT_GTR_V1_0 4211 // BigTreeTech GTR v1.0 (STM32F407IGT) -#define BOARD_LERDGE_K 4212 // Lerdge K (STM32F407ZG) -#define BOARD_LERDGE_S 4213 // Lerdge S (STM32F407VE) -#define BOARD_LERDGE_X 4214 // Lerdge X (STM32F407VE) -#define BOARD_VAKE403D 4215 // VAkE 403D (STM32F446VET6) -#define BOARD_FYSETC_S6 4216 // FYSETC S6 (STM32F446VET6) -#define BOARD_FYSETC_S6_V2_0 4217 // FYSETC S6 v2.0 (STM32F446VET6) -#define BOARD_FYSETC_SPIDER 4218 // FYSETC Spider (STM32F446VET6) -#define BOARD_FLYF407ZG 4219 // FLYF407ZG (STM32F407ZG) -#define BOARD_MKS_ROBIN2 4220 // MKS_ROBIN2 (STM32F407ZE) -#define BOARD_MKS_ROBIN_PRO_V2 4221 // MKS Robin Pro V2 (STM32F407VE) -#define BOARD_MKS_ROBIN_NANO_V3 4222 // MKS Robin Nano V3 (STM32F407VG) -#define BOARD_ANET_ET4 4223 // ANET ET4 V1.x (STM32F407VGT6) -#define BOARD_ANET_ET4P 4224 // ANET ET4P V1.x (STM32F407VGT6) -#define BOARD_FYSETC_CHEETAH_V20 4225 // FYSETC Cheetah V2.0 +#define BOARD_BTT_SKR_V2_0 4211 // BigTreeTech SKR v2.0 (STM32F407VGT6) +#define BOARD_BTT_GTR_V1_0 4212 // BigTreeTech GTR v1.0 (STM32F407IGT) +#define BOARD_LERDGE_K 4213 // Lerdge K (STM32F407ZG) +#define BOARD_LERDGE_S 4214 // Lerdge S (STM32F407VE) +#define BOARD_LERDGE_X 4215 // Lerdge X (STM32F407VE) +#define BOARD_VAKE403D 4216 // VAkE 403D (STM32F446VET6) +#define BOARD_FYSETC_S6 4217 // FYSETC S6 (STM32F446VET6) +#define BOARD_FYSETC_S6_V2_0 4218 // FYSETC S6 v2.0 (STM32F446VET6) +#define BOARD_FYSETC_SPIDER 4219 // FYSETC Spider (STM32F446VET6) +#define BOARD_FLYF407ZG 4220 // FLYF407ZG (STM32F407ZG) +#define BOARD_MKS_ROBIN2 4221 // MKS_ROBIN2 (STM32F407ZE) +#define BOARD_MKS_ROBIN_PRO_V2 4222 // MKS Robin Pro V2 (STM32F407VE) +#define BOARD_MKS_ROBIN_NANO_V3 4223 // MKS Robin Nano V3 (STM32F407VG) +#define BOARD_ANET_ET4 4224 // ANET ET4 V1.x (STM32F407VGT6) +#define BOARD_ANET_ET4P 4225 // ANET ET4P V1.x (STM32F407VGT6) +#define BOARD_FYSETC_CHEETAH_V20 4226 // FYSETC Cheetah V2.0 // // ARM Cortex M7 diff --git a/Marlin/src/feature/stepper_driver_safety.cpp b/Marlin/src/feature/stepper_driver_safety.cpp new file mode 100644 index 0000000000..991f5a5906 --- /dev/null +++ b/Marlin/src/feature/stepper_driver_safety.cpp @@ -0,0 +1,171 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include "../inc/MarlinConfig.h" +#include "../lcd/marlinui.h" + +#if HAS_DRIVER_SAFE_POWER_PROTECT + +#include "stepper_driver_safety.h" + +static uint32_t axis_plug_backward = 0; + +void stepper_driver_backward_error(PGM_P str) { + SERIAL_ERROR_START(); + SERIAL_ECHOPGM_P(str); + SERIAL_ECHOLNPGM(" driver is backward!"); + ui.status_printf_P(2, PSTR(S_FMT S_FMT), str, GET_TEXT(MSG_DRIVER_BACKWARD)); +} + +void stepper_driver_backward_check() { + + OUT_WRITE(SAFE_POWER_PIN, LOW); + + #define TEST_BACKWARD(AXIS, BIT) do { \ + SET_INPUT(AXIS##_ENABLE_PIN); \ + OUT_WRITE(AXIS##_STEP_PIN, false); \ + delay(20); \ + if (READ(AXIS##_ENABLE_PIN) == false) { \ + SBI(axis_plug_backward, BIT); \ + stepper_driver_backward_error(PSTR(STRINGIFY(AXIS))); \ + } \ + }while(0) + + #if HAS_X_ENABLE + TEST_BACKWARD(X, 0); + #endif + #if HAS_X2_ENABLE + TEST_BACKWARD(X2, 1); + #endif + + #if HAS_Y_ENABLE + TEST_BACKWARD(Y, 2); + #endif + #if HAS_Y2_ENABLE + TEST_BACKWARD(Y2, 3); + #endif + + #if HAS_Z_ENABLE + TEST_BACKWARD(Z, 4); + #endif + #if HAS_Z2_ENABLE + TEST_BACKWARD(Z2, 5); + #endif + #if HAS_Z3_ENABLE + TEST_BACKWARD(Z3, 6); + #endif + #if HAS_Z4_ENABLE + TEST_BACKWARD(Z4, 7); + #endif + + #if HAS_E0_ENABLE + TEST_BACKWARD(E0, 8); + #endif + #if HAS_E1_ENABLE + TEST_BACKWARD(E1, 9); + #endif + #if HAS_E2_ENABLE + TEST_BACKWARD(E2, 10); + #endif + #if HAS_E3_ENABLE + TEST_BACKWARD(E3, 11); + #endif + #if HAS_E4_ENABLE + TEST_BACKWARD(E4, 12); + #endif + #if HAS_E5_ENABLE + TEST_BACKWARD(E5, 13); + #endif + #if HAS_E6_ENABLE + TEST_BACKWARD(E6, 14); + #endif + #if HAS_E7_ENABLE + TEST_BACKWARD(E7, 15); + #endif + + if (!axis_plug_backward) + WRITE(SAFE_POWER_PIN, HIGH); +} + +void stepper_driver_backward_report() { + if (!axis_plug_backward) return; + + auto _report_if_backward = [](PGM_P axis, uint8_t bit) { + if (TEST(axis_plug_backward, bit)) + stepper_driver_backward_error(axis); + }; + + #define REPORT_BACKWARD(axis, bit) _report_if_backward(PSTR(STRINGIFY(axis)), bit) + + #if HAS_X_ENABLE + REPORT_BACKWARD(X, 0); + #endif + #if HAS_X2_ENABLE + REPORT_BACKWARD(X2, 1); + #endif + + #if HAS_Y_ENABLE + REPORT_BACKWARD(Y, 2); + #endif + #if HAS_Y2_ENABLE + REPORT_BACKWARD(Y2, 3); + #endif + + #if HAS_Z_ENABLE + REPORT_BACKWARD(Z, 4); + #endif + #if HAS_Z2_ENABLE + REPORT_BACKWARD(Z2, 5); + #endif + #if HAS_Z3_ENABLE + REPORT_BACKWARD(Z3, 6); + #endif + #if HAS_Z4_ENABLE + REPORT_BACKWARD(Z4, 7); + #endif + + #if HAS_E0_ENABLE + REPORT_BACKWARD(E0, 8); + #endif + #if HAS_E1_ENABLE + REPORT_BACKWARD(E1, 9); + #endif + #if HAS_E2_ENABLE + REPORT_BACKWARD(E2, 10); + #endif + #if HAS_E3_ENABLE + REPORT_BACKWARD(E3, 11); + #endif + #if HAS_E4_ENABLE + REPORT_BACKWARD(E4, 12); + #endif + #if HAS_E5_ENABLE + REPORT_BACKWARD(E5, 13); + #endif + #if HAS_E6_ENABLE + REPORT_BACKWARD(E6, 14); + #endif + #if HAS_E7_ENABLE + REPORT_BACKWARD(E7, 15); + #endif +} + +#endif // HAS_DRIVER_SAFE_POWER_PROTECT diff --git a/Marlin/src/feature/stepper_driver_safety.h b/Marlin/src/feature/stepper_driver_safety.h new file mode 100644 index 0000000000..46edf3390d --- /dev/null +++ b/Marlin/src/feature/stepper_driver_safety.h @@ -0,0 +1,28 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + + +#include "../inc/MarlinConfigPre.h" + +void stepper_driver_backward_check(); +void stepper_driver_backward_report(); diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 772c8bc3c1..208c875982 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3042,3 +3042,7 @@ #if BUTTONS_EXIST(EN1, EN2, ENC) #define HAS_ROTARY_ENCODER 1 #endif + +#if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT) + #define HAS_DRIVER_SAFE_POWER_PROTECT 1 +#endif diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 12c5a6e42d..f217c96749 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -706,6 +706,8 @@ namespace Language_en { PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Bottom Right"); PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Calibration Completed"); PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Calibration Failed"); + + PROGMEM Language_Str MSG_DRIVER_BACKWARD = _UxGT(" driver backward"); } #if FAN_COUNT == 1 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index c2d6b30703..adcf29e5c6 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -596,6 +596,8 @@ #include "stm32f4/pins_BTT_BTT002_V1_0.h" // STM32F4 env:BIGTREE_BTT002 #elif MB(BTT_E3_RRF) #include "stm32f4/pins_BTT_E3_RRF.h" // STM32F4 env:BIGTREE_E3_RRF +#elif MB(BTT_SKR_V2_0) + #include "stm32f4/pins_BTT_SKR_V2_0.h" // STM32F4 env:BIGTREE_SKR_2 #elif MB(LERDGE_K) #include "stm32f4/pins_LERDGE_K.h" // STM32F4 env:LERDGEK env:LERDGEK_usb_flash_drive #elif MB(LERDGE_S) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h new file mode 100644 index 0000000000..fa08aedbb0 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h @@ -0,0 +1,495 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "BTT SKR V2.0" + +// Use one of these or SDCard-based Emulation will be used +#if NO_EEPROM_SELECTED + //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // Decrease delays and flash wear by spreading writes across the + // 128 kB sector allocated for EEPROM emulation. + #define FLASH_EEPROM_LEVELING +#endif + +// USB Flash Drive support +#define HAS_OTG_USB_HOST_SUPPORT + +// Avoid conflict with TIMER_TONE +#define STEP_TIMER 10 + +// +// Servos +// +#define SERVO0_PIN PE5 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PC1 // X-STOP +#define Y_DIAG_PIN PC3 // Y-STOP +#define Z_DIAG_PIN PC0 // Z-STOP +#define E0_DIAG_PIN PC2 // E0DET +#define E1_DIAG_PIN PA0 // E1DET + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_DIR < 0 + #define X_MAX_PIN PC2 // E0DET + #else + #define X_MIN_PIN PC2 // E0DET + #endif +#elif ENABLED(X_DUAL_ENDSTOPS) + #ifndef X_MIN_PIN + #define X_MIN_PIN PC1 // X-STOP + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN PC2 // E0DET + #endif +#else + #define X_STOP_PIN PC1 // X-STOP +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_DIR < 0 + #define Y_MAX_PIN PA0 // E1DET + #else + #define Y_MIN_PIN PA0 // E1DET + #endif +#elif ENABLED(Y_DUAL_ENDSTOPS) + #ifndef Y_MIN_PIN + #define Y_MIN_PIN PC3 // Y-STOP + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN PA0 // E1DET + #endif +#else + #define Y_STOP_PIN PC3 // Y-STOP +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_DIR < 0 + #define Z_MAX_PIN PC15 // PWRDET + #else + #define Z_MIN_PIN PC15 // PWRDET + #endif +#elif ENABLED(Z_MULTI_ENDSTOPS) + #ifndef Z_MIN_PIN + #define Z_MIN_PIN PC0 // Z-STOP + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN PC15 // PWRDET + #endif +#else + #ifndef Z_STOP_PIN + #define Z_STOP_PIN PC0 // Z-STOP + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PE4 +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PC2 // E0DET +#define FIL_RUNOUT2_PIN PA0 // E1DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN PE8 // PS-ON +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC15 // PWRDET +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PE6 +#endif + +// +// Control pin of driver/heater/fan power supply +// +#define SAFE_POWER_PIN PC13 + +// +// Steppers +// +#define X_STEP_PIN PE2 +#define X_DIR_PIN PE1 +#define X_ENABLE_PIN PE3 +#ifndef X_CS_PIN + #define X_CS_PIN PE0 +#endif + +#define Y_STEP_PIN PD5 +#define Y_DIR_PIN PD4 +#define Y_ENABLE_PIN PD6 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD3 +#endif + +#define Z_STEP_PIN PA15 +#define Z_DIR_PIN PA8 +#define Z_ENABLE_PIN PD1 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD0 +#endif + +#define E0_STEP_PIN PD15 +#define E0_DIR_PIN PD14 +#define E0_ENABLE_PIN PC7 +#ifndef E0_CS_PIN + #define E0_CS_PIN PC6 +#endif + +#define E1_STEP_PIN PD11 +#define E1_DIR_PIN PD10 +#define E1_ENABLE_PIN PD13 +#ifndef E1_CS_PIN + #define E1_CS_PIN PD12 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA1 // TB +#define TEMP_0_PIN PA2 // TH0 +#define TEMP_1_PIN PA3 // TH1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB3 // Heater0 +#define HEATER_1_PIN PB4 // Heater1 +#define HEATER_BED_PIN PD7 // Hotbed +#define FAN_PIN PB7 // Fan0 +#define FAN1_PIN PB6 // Fan1 +#define FAN2_PIN PB5 // Fan2 + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PA14 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE15 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + // + // Software serial + // + #define X_SERIAL_TX_PIN PE0 + #define X_SERIAL_RX_PIN PE0 + + #define Y_SERIAL_TX_PIN PD3 + #define Y_SERIAL_RX_PIN PD3 + + #define Z_SERIAL_TX_PIN PD0 + #define Z_SERIAL_RX_PIN PD0 + + #define E0_SERIAL_TX_PIN PC6 + #define E0_SERIAL_RX_PIN PC6 + + #define E1_SERIAL_TX_PIN PD12 + #define E1_SERIAL_RX_PIN PD12 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// SD Connection +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION LCD +#endif + +/** + * ----- ----- + * NC | 1 2 | GND 5V | 1 2 | GND + * RESET | 3 4 | PC4 (SD_DETECT) (LCD_D7) PE13 | 3 4 | PE12 (LCD_D6) + * (MOSI) PA7 | 5 6 PB2 (BTN_EN2) (LCD_D5) PE11 | 5 6 PE10 (LCD_D4) + * (SD_SS) PA4 | 7 8 | PE7 (BTN_EN1) (LCD_RS) PE9 | 7 8 | PB1 (LCD_EN) + * (SCK) PA5 | 9 10| PA6 (MISO) (BTN_ENC) PB0 | 9 10| PC5 (BEEPER) + * ----- ----- + * EXP2 EXP1 + */ + +#define EXP1_03_PIN PE13 +#define EXP1_04_PIN PE12 +#define EXP1_05_PIN PE11 +#define EXP1_06_PIN PE10 +#define EXP1_07_PIN PE9 +#define EXP1_08_PIN PB1 +#define EXP1_09_PIN PB0 +#define EXP1_10_PIN PC5 + +#define EXP2_03_PIN -1 +#define EXP2_04_PIN PC4 +#define EXP2_05_PIN PA7 +#define EXP2_06_PIN PB2 +#define EXP2_07_PIN PA4 +#define EXP2_08_PIN PE7 +#define EXP2_09_PIN PA5 +#define EXP2_10_PIN PA6 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(ONBOARD) + + #define SDIO_SUPPORT // Use SDIO for onboard SD + #define SDIO_D0_PIN PC8 + #define SDIO_D1_PIN PC9 + #define SDIO_D2_PIN PC10 + #define SDIO_D3_PIN PC11 + #define SDIO_CK_PIN PC12 + #define SDIO_CMD_PIN PD2 + +#elif SD_CONNECTION_IS(LCD) + + #define CUSTOM_SPI_PINS + #define SDSS PA4 + #define SD_SS_PIN SDSS + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define SD_DETECT_PIN PC4 + +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" +#endif + +#if ENABLED(BTT_MOTOR_EXPANSION) + /** + * _____ _____ + * NC | · · | GND NC | · · | GND + * NC | · · | PF12 (M1EN) (M2EN) PG7 | · · | PG6 (M3EN) + * (M1STP) PB15 | · · PF11 (M1DIR) (M1RX) PG3 | · · PG2 (M1DIAG) + * (M2DIR) PB12 | · · | PG10 (M2STP) (M2RX) PD10 | · · | PD11 (M2DIAG) + * (M3DIR) PB13 | · · | PB14 (M3STP) (M3RX) PA8 | · · | PG4 (M3DIAG) + * ----- ----- + * EXP2 EXP1 + */ + + // M1 on Driver Expansion Module + #define E3_STEP_PIN EXP2_05_PIN + #define E3_DIR_PIN EXP2_06_PIN + #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_DIAG_PIN EXP1_06_PIN + #define E3_CS_PIN EXP1_05_PIN + #if HAS_TMC_UART + #define E3_SERIAL_TX_PIN EXP1_05_PIN + #define E3_SERIAL_RX_PIN EXP1_05_PIN + #endif + + // M2 on Driver Expansion Module + #define E4_STEP_PIN EXP2_08_PIN + #define E4_DIR_PIN EXP2_07_PIN + #define E4_ENABLE_PIN EXP1_03_PIN + #define E4_DIAG_PIN EXP1_08_PIN + #define E4_CS_PIN EXP1_07_PIN + #if HAS_TMC_UART + #define E4_SERIAL_TX_PIN EXP1_07_PIN + #define E4_SERIAL_RX_PIN EXP1_07_PIN + #endif + + // M3 on Driver Expansion Module + #define E5_STEP_PIN EXP2_10_PIN + #define E5_DIR_PIN EXP2_09_PIN + #define E5_ENABLE_PIN EXP1_04_PIN + #define E5_DIAG_PIN EXP1_10_PIN + #define E5_CS_PIN EXP1_09_PIN + #if HAS_TMC_UART + #define E5_SERIAL_TX_PIN EXP1_09_PIN + #define E5_SERIAL_RX_PIN EXP1_09_PIN + #endif + +#endif // BTT_MOTOR_EXPANSION + +// +// LCDs and Controllers +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_08_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_10_PIN + #define BTN_ENC EXP1_09_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_06_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + // CR10_STOCKDISPLAY default timing is too fast + #undef BOARD_ST7920_DELAY_1 + #undef BOARD_ST7920_DELAY_2 + #undef BOARD_ST7920_DELAY_3 + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_05_PIN + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + + #else + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_07_PIN + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_05_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_04_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_03_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_05_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_D7 EXP1_03_PIN + + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + + #endif + + #endif + +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if HAS_MARLINUI_U8GLIB + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 DELAY_NS(96) + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 DELAY_NS(48) + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 DELAY_NS(600) + #endif +#endif + +// +// WIFI +// + +/** + * ------- + * GND | 9 | | 8 | 3.3V + * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) + * 3.3V | 11 | | 6 | PB14 (ESP-MISO) + * (ESP-IO0) PB10 | 12 | | 5 | PB13 (ESP-CLK) + * (ESP-IO4) PB11 | 13 | | 4 | NC + * NC | 14 | | 3 | 3.3V (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | NC + * (ESP-TX) PD9 | 16 | | 1 | PC14 (ESP-RST) + * ------- + * WIFI + */ +#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN PC14 +#define ESP_WIFI_MODULE_GPIO0_PIN PB10 +#define ESP_WIFI_MODULE_GPIO4_PIN PB11 diff --git a/ini/features.ini b/ini/features.ini index 118392d6d7..9d8bac5713 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -134,6 +134,7 @@ HAS_FILAMENT_SENSOR = src_filter=+ + + MK2_MULTIPLEXER = src_filter=+ HAS_CUTTER = src_filter=+ + +HAS_DRIVER_SAFE_POWER_PROTECT = src_filter=+ EXPERIMENTAL_I2CBUS = src_filter=+ + MECHANICAL_GANTRY_CAL.+ = src_filter=+ Z_MULTI_ENDSTOPS = src_filter=+ diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 881dd17b01..1678b26d89 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -225,6 +225,26 @@ build_flags = ${common_stm32.build_flags} extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +# +# Bigtreetech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Flash Drive Support +# +[env:BIGTREE_SKR_2] +platform = ${common_stm32.platform} +platform_packages = ${stm_flash_drive.platform_packages} +extends = common_stm32 +board = genericSTM32F407VGT6 +board_build.core = stm32 +board_build.variant = MARLIN_F4x7Vx +board_build.ldscript = ldscript.ld +board_build.offset = 0x8000 +board_upload.offset_address = 0x08008000 +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + buildroot/share/PlatformIO/scripts/stm32_bootloader.py +build_flags = ${stm_flash_drive.build_flags} + -DUSE_USBHOST_HS -DUSE_USB_HS_IN_FS -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 + -DHSE_VALUE=8000000U -DHAL_SD_MODULE_ENABLED + # # Lerdge base # diff --git a/platformio.ini b/platformio.ini index d17c283b72..bbc9ffd904 100644 --- a/platformio.ini +++ b/platformio.ini @@ -136,6 +136,7 @@ default_src_filter = + - - + - - - - - + - - - - - From ee016e605cda97f3934b78994b390ce99ea35f04 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Apr 2021 04:49:21 -0500 Subject: [PATCH 306/311] Rename, clean up boards/variants (#21655) * Consolidate variant scripts * Rename Marlin-local boards * Simplify variants where possible * Rename variants * CHITU_F103 and MEEB_3DP: Maple platform `platformio-build-stm32f1.py` uses the 'board' name, not 'board_build.variant' so folder names match 'board' and not `board_build.variant`. --- .github/workflows/test-builds.yml | 1 + buildroot/share/PlatformIO/boards/LERDGE.json | 65 --------------- .../share/PlatformIO/boards/fysetc_f6.json | 34 -------- ...R_SE_BX.json => marlin_BTT_SKR_SE_BX.json} | 2 +- ...Btt002.json => marlin_BigTree_BTT002.json} | 2 +- ...GTR_v1.json => marlin_BigTree_GTR_v1.json} | 2 +- ...R_Pro.json => marlin_BigTree_SKR_Pro.json} | 2 +- ...CHITU_F103.json => marlin_CHITU_F103.json} | 3 +- ...20.json => marlin_FYSETC_CHEETAH_V20.json} | 2 +- .../{MEEB_3DP.json => marlin_MEEB_3DP.json} | 2 +- ...VE.json => marlin_STEVAL_STM32F401VE.json} | 3 +- ...GT6.json => marlin_STM32F407VGT6_CCM.json} | 0 ...YF407ZG.json => marlin_STM32F407ZGT6.json} | 5 +- .../{archim.json => marlin_archim.json} | 2 +- ...90usb1286.json => marlin_at90usb1286.json} | 0 ...T6.json => marlin_blackSTM32F407VET6.json} | 0 ...malyanM200.json => marlin_malyanM200.json} | 0 ...anM200v2.json => marlin_malyanM200v2.json} | 0 .../scripts/STM32F103RC_MEEB_3DP.py | 10 +-- .../scripts/STM32F103RC_SKR_MINI.py | 23 ------ .../PlatformIO/scripts/STM32F103RC_fysetc.py | 15 +--- .../scripts/STM32F103RET6_creality.py | 20 ----- .../scripts/STM32F103RE_SKR_E3_DIP.py | 19 ----- .../PlatformIO/scripts/STM32F103VE_longer.py | 26 ++---- .../scripts/STM32F1_create_variant.py | 13 +-- .../PlatformIO/scripts/STM32F401VE_STEVAL.py | 13 --- .../share/PlatformIO/scripts/chitu_crypt.py | 24 ++---- .../copy_marlin_variant_to_framework.py | 49 ------------ .../share/PlatformIO/scripts/custom_board.py | 13 +++ .../PlatformIO/scripts/download_mks_assets.py | 3 +- .../share/PlatformIO/scripts/fly_mini.py | 20 ----- .../PlatformIO/scripts/fysetc_cheetah_v20.py | 13 --- .../scripts/generic_create_variant.py | 56 +++++++++---- .../jgaurora_a5s_a1_with_bootloader.py | 51 +++++------- buildroot/share/PlatformIO/scripts/lerdge.py | 24 +++--- buildroot/share/PlatformIO/scripts/marlin.py | 75 ++++++++++++++++++ .../share/PlatformIO/scripts/mks_encrypt.py | 46 +++++------ .../share/PlatformIO/scripts/mks_robin.py | 44 ++-------- .../share/PlatformIO/scripts/mks_robin_e3.py | 45 ++--------- .../share/PlatformIO/scripts/mks_robin_e3p.py | 45 ++--------- .../PlatformIO/scripts/mks_robin_lite.py | 45 ++--------- .../PlatformIO/scripts/mks_robin_lite3.py | 45 ++--------- .../PlatformIO/scripts/mks_robin_mini.py | 45 ++--------- .../PlatformIO/scripts/mks_robin_nano.py | 45 ++--------- .../PlatformIO/scripts/mks_robin_nano35.py | 45 ++--------- .../share/PlatformIO/scripts/mks_robin_pro.py | 44 ++-------- .../PlatformIO/scripts/stm32_bootloader.py | 33 ++++---- .../{archim => MARLIN_ARCHIM}/.gitignore | 0 .../build_gcc/Makefile | 0 .../build_gcc/debug.mk | 0 .../build_gcc/gcc.mk | 0 .../build_gcc/libvariant_arduino_due_x.mk | 0 .../build_gcc/release.mk | 0 .../debug_scripts/gcc/arduino_due_x_flash.gdb | 0 .../debug_scripts/gcc/arduino_due_x_sram.gdb | 0 .../debug_scripts/iar/arduino_due_flash.mac | 0 .../debug_scripts/iar/arduino_due_sram.mac | 0 .../libsam_sam3x8e_gcc_rel.a | Bin .../libsam_sam3x8e_gcc_rel.a.txt | 0 .../linker_scripts/gcc/flash.ld | 0 .../linker_scripts/gcc/sram.ld | 0 .../linker_scripts/iar/flash.icf | 0 .../linker_scripts/iar/sram.icf | 0 .../{archim => MARLIN_ARCHIM}/pins_arduino.h | 0 .../{archim => MARLIN_ARCHIM}/variant.cpp | 0 .../{archim => MARLIN_ARCHIM}/variant.h | 0 .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../hal_conf_extra.h | 0 .../ldscript.ld | 0 .../variant.cpp | 0 .../variant.h | 0 .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../hal_conf_extra.h | 0 .../ldscript.ld | 0 .../variant.cpp | 0 .../variant.h | 0 .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../hal_conf_extra.h | 0 .../ldscript.ld | 0 .../variant.cpp | 0 .../variant.h | 0 .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../hal_conf_extra.h | 0 .../ldscript.ld | 0 .../variant.cpp | 0 .../variant.h | 0 .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../hal_conf_extra.h | 0 .../ldscript.ld | 0 .../variant.cpp | 0 .../variant.h | 0 .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../ldscript.ld | 0 .../variant.cpp | 0 .../variant.h | 0 .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../hal_conf_custom.h | 0 .../ldscript.ld | 0 .../variant.cpp | 0 .../variant.h | 0 .../PeripheralPins.c | 0 .../{LERDGE => MARLIN_LERDGE}/PinNamesVar.h | 0 .../MARLIN_LERDGE/ldscript.ld} | 0 .../{LERDGE => MARLIN_LERDGE}/variant.cpp | 0 .../{LERDGE => MARLIN_LERDGE}/variant.h | 0 .../pins_arduino.h | 0 .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../hal_conf_custom.h | 0 .../ldscript.ld | 0 .../variant.cpp | 0 .../variant.h | 0 .../board.cpp | 0 .../board/board.h | 0 .../ld/common.inc | 0 .../ld/extra_libs.inc | 0 .../marlin_CHITU_F103/ld/flash.ld} | 0 .../ld/stm32f103z_dfu.ld | 0 .../ld/stm32f103zc.ld | 0 .../ld/stm32f103zd.ld | 0 .../ld/stm32f103ze.ld | 0 .../ld/vector_symbols.inc | 0 .../pins_arduino.h | 0 .../variant.h | 0 .../wirish/boards.cpp | 0 .../wirish/boards_setup.cpp | 0 .../wirish/start.S | 0 .../wirish/start_c.c | 0 .../wirish/syscalls.c | 0 .../{MEEB_3DP => marlin_MEEB_3DP}/board.cpp | 0 .../board/board.h | 0 .../ld/bootloader.ld | 0 .../ld/common.inc | 0 .../ld/extra_libs.inc | 0 .../{MEEB_3DP => marlin_MEEB_3DP}/ld/flash.ld | 0 .../{MEEB_3DP => marlin_MEEB_3DP}/ld/jtag.ld | 0 .../ld/mem-flash.inc | 0 .../ld/mem-jtag.inc | 0 .../ld/mem-ram.inc | 0 .../{MEEB_3DP => marlin_MEEB_3DP}/ld/ram.ld | 0 .../ld/stm32f103rb.ld | 0 .../ld/stm32f103rb_bootloader.ld | 0 .../ld/stm32f103rc.ld | 0 .../ld/stm32f103rc_bootloader.ld | 0 .../ld/stm32f103re.ld | 0 .../ld/vector_symbols.inc | 0 .../pins_arduino.h | 0 .../{MEEB_3DP => marlin_MEEB_3DP}/variant.h | 0 .../wirish/boards.cpp | 0 .../wirish/boards_setup.cpp | 0 .../wirish/start.S | 0 .../wirish/start_c.c | 0 .../wirish/syscalls.c | 0 buildroot/tests/chitu_f103 | 16 ++++ ini/avr.ini | 12 +-- ini/due.ini | 2 +- ini/stm32f0.ini | 2 +- ini/stm32f1.ini | 25 ++++-- ini/stm32f4.ini | 47 ++++++----- ini/stm32f7.ini | 2 +- 167 files changed, 340 insertions(+), 840 deletions(-) delete mode 100644 buildroot/share/PlatformIO/boards/LERDGE.json delete mode 100644 buildroot/share/PlatformIO/boards/fysetc_f6.json rename buildroot/share/PlatformIO/boards/{BTT_SKR_SE_BX.json => marlin_BTT_SKR_SE_BX.json} (97%) rename buildroot/share/PlatformIO/boards/{BigTree_Btt002.json => marlin_BigTree_BTT002.json} (96%) rename buildroot/share/PlatformIO/boards/{BigTree_GTR_v1.json => marlin_BigTree_GTR_v1.json} (96%) rename buildroot/share/PlatformIO/boards/{BigTree_SKR_Pro.json => marlin_BigTree_SKR_Pro.json} (95%) rename buildroot/share/PlatformIO/boards/{CHITU_F103.json => marlin_CHITU_F103.json} (93%) rename buildroot/share/PlatformIO/boards/{FYSETC_CHEETAH_V20.json => marlin_FYSETC_CHEETAH_V20.json} (96%) rename buildroot/share/PlatformIO/boards/{MEEB_3DP.json => marlin_MEEB_3DP.json} (97%) rename buildroot/share/PlatformIO/boards/{STEVAL_STM32F401VE.json => marlin_STEVAL_STM32F401VE.json} (95%) rename buildroot/share/PlatformIO/boards/{genericSTM32F407VGT6.json => marlin_STM32F407VGT6_CCM.json} (100%) rename buildroot/share/PlatformIO/boards/{FLYF407ZG.json => marlin_STM32F407ZGT6.json} (94%) rename buildroot/share/PlatformIO/boards/{archim.json => marlin_archim.json} (97%) rename buildroot/share/PlatformIO/boards/{at90usb1286.json => marlin_at90usb1286.json} (100%) rename buildroot/share/PlatformIO/boards/{blackSTM32F407VET6.json => marlin_blackSTM32F407VET6.json} (100%) rename buildroot/share/PlatformIO/boards/{malyanM200.json => marlin_malyanM200.json} (100%) rename buildroot/share/PlatformIO/boards/{malyanM200v2.json => marlin_malyanM200v2.json} (100%) delete mode 100644 buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py delete mode 100644 buildroot/share/PlatformIO/scripts/STM32F103RET6_creality.py delete mode 100644 buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py delete mode 100644 buildroot/share/PlatformIO/scripts/STM32F401VE_STEVAL.py delete mode 100644 buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py create mode 100644 buildroot/share/PlatformIO/scripts/custom_board.py delete mode 100644 buildroot/share/PlatformIO/scripts/fly_mini.py delete mode 100644 buildroot/share/PlatformIO/scripts/fysetc_cheetah_v20.py create mode 100644 buildroot/share/PlatformIO/scripts/marlin.py rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/.gitignore (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/build_gcc/Makefile (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/build_gcc/debug.mk (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/build_gcc/gcc.mk (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/build_gcc/libvariant_arduino_due_x.mk (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/build_gcc/release.mk (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/debug_scripts/gcc/arduino_due_x_flash.gdb (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/debug_scripts/gcc/arduino_due_x_sram.gdb (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/debug_scripts/iar/arduino_due_flash.mac (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/debug_scripts/iar/arduino_due_sram.mac (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/libsam_sam3x8e_gcc_rel.a (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/libsam_sam3x8e_gcc_rel.a.txt (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/linker_scripts/gcc/flash.ld (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/linker_scripts/gcc/sram.ld (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/linker_scripts/iar/flash.icf (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/linker_scripts/iar/sram.icf (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/pins_arduino.h (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{archim => MARLIN_ARCHIM}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_BTT002 => MARLIN_BIGTREE_BTT002}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_BTT002 => MARLIN_BIGTREE_BTT002}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_BTT002 => MARLIN_BIGTREE_BTT002}/hal_conf_extra.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_BTT002 => MARLIN_BIGTREE_BTT002}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_BTT002 => MARLIN_BIGTREE_BTT002}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_BTT002 => MARLIN_BIGTREE_BTT002}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_E3_RRF => MARLIN_BIGTREE_E3_RRF}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_E3_RRF => MARLIN_BIGTREE_E3_RRF}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_E3_RRF => MARLIN_BIGTREE_E3_RRF}/hal_conf_extra.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_E3_RRF => MARLIN_BIGTREE_E3_RRF}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_E3_RRF => MARLIN_BIGTREE_E3_RRF}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_E3_RRF => MARLIN_BIGTREE_E3_RRF}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_GTR_V1 => MARLIN_BIGTREE_GTR_V1}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_GTR_V1 => MARLIN_BIGTREE_GTR_V1}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_GTR_V1 => MARLIN_BIGTREE_GTR_V1}/hal_conf_extra.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_GTR_V1 => MARLIN_BIGTREE_GTR_V1}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_GTR_V1 => MARLIN_BIGTREE_GTR_V1}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_GTR_V1 => MARLIN_BIGTREE_GTR_V1}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_SKR_PRO_1v1 => MARLIN_BIGTREE_SKR_PRO_11}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_SKR_PRO_1v1 => MARLIN_BIGTREE_SKR_PRO_11}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_SKR_PRO_1v1 => MARLIN_BIGTREE_SKR_PRO_11}/hal_conf_extra.h (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_SKR_PRO_1v1 => MARLIN_BIGTREE_SKR_PRO_11}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_SKR_PRO_1v1 => MARLIN_BIGTREE_SKR_PRO_11}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{BIGTREE_SKR_PRO_1v1 => MARLIN_BIGTREE_SKR_PRO_11}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{BTT_SKR_SE_BX => MARLIN_BTT_SKR_SE_BX}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{BTT_SKR_SE_BX => MARLIN_BTT_SKR_SE_BX}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{BTT_SKR_SE_BX => MARLIN_BTT_SKR_SE_BX}/hal_conf_extra.h (100%) rename buildroot/share/PlatformIO/variants/{BTT_SKR_SE_BX => MARLIN_BTT_SKR_SE_BX}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{BTT_SKR_SE_BX => MARLIN_BTT_SKR_SE_BX}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{BTT_SKR_SE_BX => MARLIN_BTT_SKR_SE_BX}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{FLY_F407ZG => MARLIN_FLY_F407ZG}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{FLY_F407ZG => MARLIN_FLY_F407ZG}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{FLY_F407ZG => MARLIN_FLY_F407ZG}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{FLY_F407ZG => MARLIN_FLY_F407ZG}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{FLY_F407ZG => MARLIN_FLY_F407ZG}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{FYSETC_CHEETAH_V20 => MARLIN_FYSETC_CHEETAH_V20}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{FYSETC_CHEETAH_V20 => MARLIN_FYSETC_CHEETAH_V20}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{FYSETC_CHEETAH_V20 => MARLIN_FYSETC_CHEETAH_V20}/hal_conf_custom.h (100%) rename buildroot/share/PlatformIO/variants/{FYSETC_CHEETAH_V20 => MARLIN_FYSETC_CHEETAH_V20}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{FYSETC_CHEETAH_V20 => MARLIN_FYSETC_CHEETAH_V20}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{FYSETC_CHEETAH_V20 => MARLIN_FYSETC_CHEETAH_V20}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{LERDGE => MARLIN_LERDGE}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{LERDGE => MARLIN_LERDGE}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/{ldscripts/lerdge.ld => variants/MARLIN_LERDGE/ldscript.ld} (100%) rename buildroot/share/PlatformIO/variants/{LERDGE => MARLIN_LERDGE}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{LERDGE => MARLIN_LERDGE}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{megaextendedpins => MARLIN_MEGA_EXTENDED}/pins_arduino.h (100%) rename buildroot/share/PlatformIO/variants/{STEVAL_F401VE => MARLIN_STEVAL_F401VE}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{STEVAL_F401VE => MARLIN_STEVAL_F401VE}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{STEVAL_F401VE => MARLIN_STEVAL_F401VE}/hal_conf_custom.h (100%) rename buildroot/share/PlatformIO/variants/{STEVAL_F401VE => MARLIN_STEVAL_F401VE}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{STEVAL_F401VE => MARLIN_STEVAL_F401VE}/variant.cpp (100%) rename buildroot/share/PlatformIO/variants/{STEVAL_F401VE => MARLIN_STEVAL_F401VE}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/board.cpp (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/board/board.h (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/ld/common.inc (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/ld/extra_libs.inc (100%) rename buildroot/share/PlatformIO/{ldscripts/chitu_f103.ld => variants/marlin_CHITU_F103/ld/flash.ld} (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/ld/stm32f103z_dfu.ld (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/ld/stm32f103zc.ld (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/ld/stm32f103zd.ld (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/ld/stm32f103ze.ld (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/ld/vector_symbols.inc (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/pins_arduino.h (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/wirish/boards.cpp (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/wirish/boards_setup.cpp (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/wirish/start.S (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/wirish/start_c.c (100%) rename buildroot/share/PlatformIO/variants/{CHITU_F103 => marlin_CHITU_F103}/wirish/syscalls.c (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/board.cpp (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/board/board.h (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/bootloader.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/common.inc (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/extra_libs.inc (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/flash.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/jtag.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/mem-flash.inc (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/mem-jtag.inc (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/mem-ram.inc (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/ram.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/stm32f103rb.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/stm32f103rb_bootloader.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/stm32f103rc.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/stm32f103rc_bootloader.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/stm32f103re.ld (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/ld/vector_symbols.inc (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/pins_arduino.h (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/variant.h (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/wirish/boards.cpp (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/wirish/boards_setup.cpp (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/wirish/start.S (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/wirish/start_c.c (100%) rename buildroot/share/PlatformIO/variants/{MEEB_3DP => marlin_MEEB_3DP}/wirish/syscalls.c (100%) create mode 100755 buildroot/tests/chitu_f103 diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index 5a598299f3..93bda9726e 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -90,6 +90,7 @@ jobs: - NUCLEO_F767ZI - REMRAM_V1 - BTT_SKR_SE_BX + - chitu_f103 # Put lengthy tests last diff --git a/buildroot/share/PlatformIO/boards/LERDGE.json b/buildroot/share/PlatformIO/boards/LERDGE.json deleted file mode 100644 index 011814a133..0000000000 --- a/buildroot/share/PlatformIO/boards/LERDGE.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "build": { - "core": "stm32", - "cpu": "cortex-m4", - "extra_flags": "-DSTM32F407xx", - "f_cpu": "168000000L", - "hwids": [ - [ - "0x1EAF", - "0x0003" - ], - [ - "0x0483", - "0x3748" - ] - ], - "mcu": "stm32f407zgt6", - "variant": "LERDGE", - "ldscript": "LERDGE.ld" - }, - "debug": { - "jlink_device": "STM32F407ZG", - "openocd_target": "stm32f4x", - "svd_path": "STM32F40x.svd", - "tools": { - "stlink": { - "server": { - "arguments": [ - "-f", - "scripts/interface/stlink.cfg", - "-c", - "transport select hla_swd", - "-f", - "scripts/target/stm32f4x.cfg", - "-c", - "reset_config none" - ], - "executable": "bin/openocd", - "package": "tool-openocd" - } - } - } - }, - "frameworks": [ - "arduino", - "stm32cube" - ], - "name": "STM32F407ZGT6(192k RAM. 1024k Flash)", - "upload": { - "disable_flushing": false, - "maximum_ram_size": 196608, - "maximum_size": 1048576, - "protocol": "stlink", - "protocols": [ - "stlink", - "dfu", - "jlink" - ], - "require_upload_port": true, - "use_1200bps_touch": false, - "wait_for_upload_port": false - }, - "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407ZG.html", - "vendor": "Generic" -} diff --git a/buildroot/share/PlatformIO/boards/fysetc_f6.json b/buildroot/share/PlatformIO/boards/fysetc_f6.json deleted file mode 100644 index 2772f73a65..0000000000 --- a/buildroot/share/PlatformIO/boards/fysetc_f6.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "build": { - "core": "arduino", - "extra_flags": "-DARDUINO_AVR_MEGA2560", - "f_cpu": "16000000L", - "hwids": [ - [ - "0x27b2", - "0x0002" - ] - ], - "mcu": "atmega2560", - "variant": "fysetcf6" - }, - "debug": { - "simavr_target": "atmega2560", - "avr-stub": { - "speed": 115200 - } - }, - "frameworks": [ - "arduino" - ], - "name": "FYSETC F6", - "upload": { - "maximum_ram_size": 8192, - "maximum_size": 258048, - "protocol": "wiring", - "require_upload_port": true, - "speed": 115200 - }, - "url": "https://www.fysetc.com/", - "vendor": "FYSETC" -} diff --git a/buildroot/share/PlatformIO/boards/BTT_SKR_SE_BX.json b/buildroot/share/PlatformIO/boards/marlin_BTT_SKR_SE_BX.json similarity index 97% rename from buildroot/share/PlatformIO/boards/BTT_SKR_SE_BX.json rename to buildroot/share/PlatformIO/boards/marlin_BTT_SKR_SE_BX.json index 920b2478a9..65735d433b 100644 --- a/buildroot/share/PlatformIO/boards/BTT_SKR_SE_BX.json +++ b/buildroot/share/PlatformIO/boards/marlin_BTT_SKR_SE_BX.json @@ -5,7 +5,7 @@ "extra_flags": "-DSTM32H743xx", "f_cpu": "400000000L", "mcu": "stm32h743iit6", - "variant": "BTT_SKR_SE_BX" + "variant": "MARLIN_BTT_SKR_SE_BX" }, "debug": { "jlink_device": "STM32H743II", diff --git a/buildroot/share/PlatformIO/boards/BigTree_Btt002.json b/buildroot/share/PlatformIO/boards/marlin_BigTree_BTT002.json similarity index 96% rename from buildroot/share/PlatformIO/boards/BigTree_Btt002.json rename to buildroot/share/PlatformIO/boards/marlin_BigTree_BTT002.json index d0d092f1ea..28a79271b8 100644 --- a/buildroot/share/PlatformIO/boards/BigTree_Btt002.json +++ b/buildroot/share/PlatformIO/boards/marlin_BigTree_BTT002.json @@ -15,7 +15,7 @@ ] ], "mcu": "stm32f407vgt6", - "variant": "BIGTREE_BTT002" + "variant": "MARLIN_BIGTREE_BTT002" }, "debug": { "jlink_device": "STM32F407VG", diff --git a/buildroot/share/PlatformIO/boards/BigTree_GTR_v1.json b/buildroot/share/PlatformIO/boards/marlin_BigTree_GTR_v1.json similarity index 96% rename from buildroot/share/PlatformIO/boards/BigTree_GTR_v1.json rename to buildroot/share/PlatformIO/boards/marlin_BigTree_GTR_v1.json index 32236301c3..e311ce3b52 100644 --- a/buildroot/share/PlatformIO/boards/BigTree_GTR_v1.json +++ b/buildroot/share/PlatformIO/boards/marlin_BigTree_GTR_v1.json @@ -15,7 +15,7 @@ ] ], "mcu": "stm32f407zgt6", - "variant": "BIGTREE_GTR_V1" + "variant": "MARLIN_BIGTREE_GTR_V1" }, "debug": { "jlink_device": "STM32F407ZG", diff --git a/buildroot/share/PlatformIO/boards/BigTree_SKR_Pro.json b/buildroot/share/PlatformIO/boards/marlin_BigTree_SKR_Pro.json similarity index 95% rename from buildroot/share/PlatformIO/boards/BigTree_SKR_Pro.json rename to buildroot/share/PlatformIO/boards/marlin_BigTree_SKR_Pro.json index 211ceacdca..5e76c2c9e2 100644 --- a/buildroot/share/PlatformIO/boards/BigTree_SKR_Pro.json +++ b/buildroot/share/PlatformIO/boards/marlin_BigTree_SKR_Pro.json @@ -15,7 +15,7 @@ ] ], "mcu": "stm32f407zgt6", - "variant": "BIGTREE_SKR_PRO_1v1" + "variant": "MARLIN_BIGTREE_SKR_PRO_11" }, "debug": { "jlink_device": "STM32F407ZG", diff --git a/buildroot/share/PlatformIO/boards/CHITU_F103.json b/buildroot/share/PlatformIO/boards/marlin_CHITU_F103.json similarity index 93% rename from buildroot/share/PlatformIO/boards/CHITU_F103.json rename to buildroot/share/PlatformIO/boards/marlin_CHITU_F103.json index ecf7bff66c..dbfbc21cb2 100644 --- a/buildroot/share/PlatformIO/boards/CHITU_F103.json +++ b/buildroot/share/PlatformIO/boards/marlin_CHITU_F103.json @@ -15,8 +15,7 @@ ] ], "mcu": "stm32f103zet6", - "variant": "CHITU_F103", - "ldscript": "chitu_f103.ld" + "variant": "marlin_CHITU_F103" }, "debug": { "jlink_device": "STM32F103ZE", diff --git a/buildroot/share/PlatformIO/boards/FYSETC_CHEETAH_V20.json b/buildroot/share/PlatformIO/boards/marlin_FYSETC_CHEETAH_V20.json similarity index 96% rename from buildroot/share/PlatformIO/boards/FYSETC_CHEETAH_V20.json rename to buildroot/share/PlatformIO/boards/marlin_FYSETC_CHEETAH_V20.json index ff082fdc1f..e7b0d28afe 100644 --- a/buildroot/share/PlatformIO/boards/FYSETC_CHEETAH_V20.json +++ b/buildroot/share/PlatformIO/boards/marlin_FYSETC_CHEETAH_V20.json @@ -16,7 +16,7 @@ ], "ldscript": "stm32f401rc.ld", "mcu": "stm32f401rct6", - "variant": "FYSETC_CHEETAH_V20" + "variant": "MARLIN_FYSETC_CHEETAH_V20" }, "debug": { "jlink_device": "STM32F401RC", diff --git a/buildroot/share/PlatformIO/boards/MEEB_3DP.json b/buildroot/share/PlatformIO/boards/marlin_MEEB_3DP.json similarity index 97% rename from buildroot/share/PlatformIO/boards/MEEB_3DP.json rename to buildroot/share/PlatformIO/boards/marlin_MEEB_3DP.json index 870648b325..73ec9aaf48 100644 --- a/buildroot/share/PlatformIO/boards/MEEB_3DP.json +++ b/buildroot/share/PlatformIO/boards/marlin_MEEB_3DP.json @@ -18,7 +18,7 @@ "ldscript": "stm32f103xc.ld" }, "mcu": "stm32f103rct6", - "variant": "MEEB_3DP" + "variant": "marlin_MEEB_3DP" }, "debug": { "jlink_device": "STM32F103RC", diff --git a/buildroot/share/PlatformIO/boards/STEVAL_STM32F401VE.json b/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json similarity index 95% rename from buildroot/share/PlatformIO/boards/STEVAL_STM32F401VE.json rename to buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json index bbfb3fdfa5..e89ca0af73 100644 --- a/buildroot/share/PlatformIO/boards/STEVAL_STM32F401VE.json +++ b/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json @@ -14,9 +14,8 @@ "0x3748" ] ], - "ldscript": "stm32f401xe.ld", "mcu": "stm32f401vet6", - "variant": "STEVAL_F401VE" + "variant": "MARLIN_STEVAL_F401VE" }, "debug": { "jlink_device": "STM32F401VE", diff --git a/buildroot/share/PlatformIO/boards/genericSTM32F407VGT6.json b/buildroot/share/PlatformIO/boards/marlin_STM32F407VGT6_CCM.json similarity index 100% rename from buildroot/share/PlatformIO/boards/genericSTM32F407VGT6.json rename to buildroot/share/PlatformIO/boards/marlin_STM32F407VGT6_CCM.json diff --git a/buildroot/share/PlatformIO/boards/FLYF407ZG.json b/buildroot/share/PlatformIO/boards/marlin_STM32F407ZGT6.json similarity index 94% rename from buildroot/share/PlatformIO/boards/FLYF407ZG.json rename to buildroot/share/PlatformIO/boards/marlin_STM32F407ZGT6.json index 7e585c5057..f6c78f8ab3 100644 --- a/buildroot/share/PlatformIO/boards/FLYF407ZG.json +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F407ZGT6.json @@ -14,8 +14,7 @@ "0x3748" ] ], - "mcu": "stm32f407zgt6", - "variant": "FLY_F407ZG" + "mcu": "stm32f407zgt6" }, "debug": { "jlink_device": "STM32F407ZG", @@ -49,7 +48,7 @@ "disable_flushing": false, "maximum_ram_size": 196608, "maximum_size": 1048576, - "protocol": "dfu", + "protocol": "stlink", "protocols": [ "stlink", "dfu", diff --git a/buildroot/share/PlatformIO/boards/archim.json b/buildroot/share/PlatformIO/boards/marlin_archim.json similarity index 97% rename from buildroot/share/PlatformIO/boards/archim.json rename to buildroot/share/PlatformIO/boards/marlin_archim.json index 60035197f2..6d78c1f195 100644 --- a/buildroot/share/PlatformIO/boards/archim.json +++ b/buildroot/share/PlatformIO/boards/marlin_archim.json @@ -21,7 +21,7 @@ "ldscript": "linker_scripts/gcc/flash.ld", "mcu": "at91sam3x8e", "usb_product": "Archim", - "variant": "archim" + "variant": "MARLIN_ARCHIM" }, "connectivity": [ "can" diff --git a/buildroot/share/PlatformIO/boards/at90usb1286.json b/buildroot/share/PlatformIO/boards/marlin_at90usb1286.json similarity index 100% rename from buildroot/share/PlatformIO/boards/at90usb1286.json rename to buildroot/share/PlatformIO/boards/marlin_at90usb1286.json diff --git a/buildroot/share/PlatformIO/boards/blackSTM32F407VET6.json b/buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json similarity index 100% rename from buildroot/share/PlatformIO/boards/blackSTM32F407VET6.json rename to buildroot/share/PlatformIO/boards/marlin_blackSTM32F407VET6.json diff --git a/buildroot/share/PlatformIO/boards/malyanM200.json b/buildroot/share/PlatformIO/boards/marlin_malyanM200.json similarity index 100% rename from buildroot/share/PlatformIO/boards/malyanM200.json rename to buildroot/share/PlatformIO/boards/marlin_malyanM200.json diff --git a/buildroot/share/PlatformIO/boards/malyanM200v2.json b/buildroot/share/PlatformIO/boards/marlin_malyanM200v2.json similarity index 100% rename from buildroot/share/PlatformIO/boards/malyanM200v2.json rename to buildroot/share/PlatformIO/boards/marlin_malyanM200v2.json diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py index 6d7f21942e..03e121c435 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py @@ -1,5 +1,5 @@ # -# STM32F103RC_MEEB_3DP.py +# buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py # try: import configparser @@ -54,9 +54,5 @@ for define in env['CPPDEFINES']: print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RC_MEEB_3DP.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script +import marlin +marlin.custom_ld_script("STM32F103RC_MEEB_3DP.ld") diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py deleted file mode 100644 index 7e9dc676b6..0000000000 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py +++ /dev/null @@ -1,23 +0,0 @@ -# -# STM32F103RC_SKR_MINI.py -# -import os -Import("env") - -STM32_FLASH_SIZE = 256 - -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) - if define[0] == "STM32_FLASH_SIZE": - STM32_FLASH_SIZE = define[1] - -# Relocate firmware from 0x08000000 to 0x08007000 -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RC_SKR_MINI_" + str(STM32_FLASH_SIZE) + "K.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py index 1a7cc34edb..f64f928787 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -1,24 +1,11 @@ # -# STM32F103RC_fysetc.py +# buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py # import os from os.path import join from os.path import expandvars Import("env") -# Relocate firmware from 0x08000000 to 0x08008000 -#for define in env['CPPDEFINES']: -# if define[0] == "VECT_TAB_ADDR": -# env['CPPDEFINES'].remove(define) -#env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08008000")) - -#custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld") -#for i, flag in enumerate(env["LINKFLAGS"]): -# if "-Wl,-T" in flag: -# env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script -# elif flag == "-T": -# env["LINKFLAGS"][i + 1] = custom_ld_script - # Custom HEX from ELF env.AddPostAction( join("$BUILD_DIR","${PROGNAME}.elf"), diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RET6_creality.py b/buildroot/share/PlatformIO/scripts/STM32F103RET6_creality.py deleted file mode 100644 index e3ef98b03f..0000000000 --- a/buildroot/share/PlatformIO/scripts/STM32F103RET6_creality.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# STM32F103RET6_creality.py -# -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08007000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) - -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/creality.ld") - -for i, flag in enumerate(env['LINKFLAGS']): - if "-Wl,-T" in flag: - env['LINKFLAGS'][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env['LINKFLAGS'][i + 1] = custom_ld_script diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py b/buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py deleted file mode 100644 index 06e586f7f8..0000000000 --- a/buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py +++ /dev/null @@ -1,19 +0,0 @@ -# -# STM32F103RE_SKR_E3_DIP.py -# -import os -Import("env") - -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) - -# Relocate firmware from 0x08000000 to 0x08007000 -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103RE_SKR_E3_DIP.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script diff --git a/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py b/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py index 321dd01b8d..c98059729f 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py @@ -1,36 +1,22 @@ # -# STM32F103VE_longer.py +# buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py # Customizations for env:STM32F103VE_longer # -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08010000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/STM32F103VE_longer.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script +import os,marlin # Rename ${PROGNAME}.bin and save it as 'project.bin' (No encryption on the Longer3D) def encrypt(source, target, env): firmware = open(target[0].path, "rb") - marlin_alfa = open(target[0].dir.path +'/project.bin', "wb") + renamed = open(target[0].dir.path + '/project.bin', "wb") length = os.path.getsize(target[0].path) position = 0 try: while position < length: byte = firmware.read(1) - marlin_alfa.write(byte) + renamed.write(byte) position += 1 finally: firmware.close() - marlin_alfa.close() + renamed.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +marlin.add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py index 91522a9d06..0a38e1ceee 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py @@ -1,19 +1,10 @@ # # STM32F1_create_variant.py # -import os,shutil +import os,shutil,marlin from SCons.Script import DefaultEnvironment from platformio import util -def copytree(src, dst, symlinks=False, ignore=None): - for item in os.listdir(src): - s = os.path.join(src, item) - d = os.path.join(dst, item) - if os.path.isdir(s): - shutil.copytree(s, d, symlinks, ignore) - else: - shutil.copy2(s, d) - env = DefaultEnvironment() platform = env.PioPlatform() board = env.BoardConfig() @@ -36,4 +27,4 @@ if os.path.isdir(variant_dir): if not os.path.isdir(variant_dir): os.mkdir(variant_dir) -copytree(source_dir, variant_dir) +marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/STM32F401VE_STEVAL.py b/buildroot/share/PlatformIO/scripts/STM32F401VE_STEVAL.py deleted file mode 100644 index ffd5bcd42d..0000000000 --- a/buildroot/share/PlatformIO/scripts/STM32F401VE_STEVAL.py +++ /dev/null @@ -1,13 +0,0 @@ -# -# STM32F401VE_STEVAL.py -# Customizations for env:STM32F401VE_STEVAL -# -import os -Import("env") - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/variants/STEVAL_F401VE/ldscript.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script diff --git a/buildroot/share/PlatformIO/scripts/chitu_crypt.py b/buildroot/share/PlatformIO/scripts/chitu_crypt.py index 3d4854b51f..23d81c1721 100644 --- a/buildroot/share/PlatformIO/scripts/chitu_crypt.py +++ b/buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -1,21 +1,11 @@ # -# chitu_crypt.py +# buildroot/share/PlatformIO/scripts/chitu_crypt.py # Customizations for Chitu boards # -Import("env") -import os,random,struct,uuid +import os,random,struct,uuid,marlin # Relocate firmware from 0x08000000 to 0x08008800 -env['CPPDEFINES'].remove(("VECT_TAB_ADDR", "0x8000000")) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08008800")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/chitu_f103.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - +marlin.relocate_firmware("0x08008800") def calculate_crc(contents, seed): accumulating_xor_value = seed; @@ -43,7 +33,7 @@ def xor_block(r0, r1, block_number, block_size, file_key): for loop_counter in range(0, block_size): # meant to make sure different bits of the key are used. - xor_seed = int(loop_counter/key_length) + xor_seed = int(loop_counter / key_length) # IP is a scratch register / R12 ip = loop_counter - (key_length * xor_seed) @@ -69,7 +59,6 @@ def xor_block(r0, r1, block_number, block_size, file_key): #increment the loop_counter loop_counter = loop_counter + 1 - def encrypt_file(input, output_file, file_length): input_file = bytearray(input.read()) block_size = 0x800 @@ -113,11 +102,10 @@ def encrypt_file(input, output_file, file_length): output_file.write(input_file) return - # Encrypt ${PROGNAME}.bin and save it as 'update.cbd' def encrypt(source, target, env): firmware = open(target[0].path, "rb") - update = open(target[0].dir.path +'/update.cbd', "wb") + update = open(target[0].dir.path + '/update.cbd', "wb") length = os.path.getsize(target[0].path) encrypt_file(firmware, update, length) @@ -125,4 +113,4 @@ def encrypt(source, target, env): firmware.close() update.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +marlin.add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py b/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py deleted file mode 100644 index 15c953156c..0000000000 --- a/buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py +++ /dev/null @@ -1,49 +0,0 @@ -# -# copy_marlin_variant_to_framework.py -# -import os,shutil -from SCons.Script import DefaultEnvironment -from platformio import util -from platformio.package.meta import PackageSpec - -def copytree(src, dst, symlinks=False, ignore=None): - for item in os.listdir(src): - s = os.path.join(src, item) - d = os.path.join(dst, item) - if os.path.isdir(s): - shutil.copytree(s, d, symlinks, ignore) - else: - shutil.copy2(s, d) - -env = DefaultEnvironment() -platform = env.PioPlatform() -board = env.BoardConfig() -variant = board.get("build.variant") - -platform_packages = env.GetProjectOption('platform_packages') -# if there's no framework defined, take it from the class name of platform -framewords = { - "Ststm32Platform": "framework-arduinoststm32", - "AtmelavrPlatform": "framework-arduino-avr" -} -if len(platform_packages) == 0: - platform_name = framewords[platform.__class__.__name__] -else: - platform_name = PackageSpec(platform_packages[0]).name - -FRAMEWORK_DIR = platform.get_package_dir(platform_name) -assert os.path.isdir(FRAMEWORK_DIR) -assert os.path.isdir("buildroot/share/PlatformIO/variants") - -variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant) - -source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) -assert os.path.isdir(source_dir) - -if os.path.isdir(variant_dir): - shutil.rmtree(variant_dir) - -if not os.path.isdir(variant_dir): - os.mkdir(variant_dir) - -copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/custom_board.py b/buildroot/share/PlatformIO/scripts/custom_board.py new file mode 100644 index 0000000000..5d3ca3c652 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/custom_board.py @@ -0,0 +1,13 @@ +# +# buildroot/share/PlatformIO/scripts/custom_board.py +# +import marlin +board = marlin.env.BoardConfig() + +address = board.get("build.address", "") +if address: + marlin.relocate_firmware(address) + +ldscript = board.get("build.ldscript", "") +if ldscript: + marlin.custom_ld_script(ldscript) diff --git a/buildroot/share/PlatformIO/scripts/download_mks_assets.py b/buildroot/share/PlatformIO/scripts/download_mks_assets.py index 33acab9e12..e922fed2be 100644 --- a/buildroot/share/PlatformIO/scripts/download_mks_assets.py +++ b/buildroot/share/PlatformIO/scripts/download_mks_assets.py @@ -1,5 +1,6 @@ # -# download_mks_assets.py +# buildroot/share/PlatformIO/scripts/download_mks_assets.py +# Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo # Import("env") import os,requests,zipfile,tempfile,shutil diff --git a/buildroot/share/PlatformIO/scripts/fly_mini.py b/buildroot/share/PlatformIO/scripts/fly_mini.py deleted file mode 100644 index 9c5df359ad..0000000000 --- a/buildroot/share/PlatformIO/scripts/fly_mini.py +++ /dev/null @@ -1,20 +0,0 @@ -# -# fly_mini.py -# Customizations for env:FLY_MINI -# -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08005000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/fly_mini.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - diff --git a/buildroot/share/PlatformIO/scripts/fysetc_cheetah_v20.py b/buildroot/share/PlatformIO/scripts/fysetc_cheetah_v20.py deleted file mode 100644 index f36d51f972..0000000000 --- a/buildroot/share/PlatformIO/scripts/fysetc_cheetah_v20.py +++ /dev/null @@ -1,13 +0,0 @@ -# -# STM32F401VE_STEVAL.py -# Customizations for env:STM32F401VE_STEVAL -# -import os -Import("env") - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/ldscript.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script diff --git a/buildroot/share/PlatformIO/scripts/generic_create_variant.py b/buildroot/share/PlatformIO/scripts/generic_create_variant.py index aa79d39b51..3290dcea19 100644 --- a/buildroot/share/PlatformIO/scripts/generic_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -1,30 +1,54 @@ # -# Generate a generic variant +# generic_create_variant.py # -import os,shutil +# Copy one of the variants from buildroot/platformio/variants into +# the appropriate framework variants folder, so that its contents +# will be picked up by PlatformIO just like any other variant. +# +import os,shutil,marlin from SCons.Script import DefaultEnvironment from platformio import util env = DefaultEnvironment() + +# +# Get the platform name from the 'platform_packages' option, +# or look it up by the platform.class.name. +# platform = env.PioPlatform() + +from platformio.package.meta import PackageSpec +platform_packages = env.GetProjectOption('platform_packages') +if len(platform_packages) == 0: + framewords = { + "Ststm32Platform": "framework-arduinoststm32", + "AtmelavrPlatform": "framework-arduino-avr" + } + platform_name = framewords[platform.__class__.__name__] +else: + platform_name = PackageSpec(platform_packages[0]).name + +if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "tool-stm32duino" ]: + platform_name = "framework-arduinoststm32" + +FRAMEWORK_DIR = platform.get_package_dir(platform_name) +assert os.path.isdir(FRAMEWORK_DIR) + board = env.BoardConfig() -FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32") -assert os.path.isdir(FRAMEWORK_DIR) -assert os.path.isdir("buildroot/share/PlatformIO/variants") - -mcu_type = board.get("build.mcu")[:-2] +#mcu_type = board.get("build.mcu")[:-2] variant = board.get("build.variant") -series = mcu_type[:7].upper() + "xx" +#series = mcu_type[:7].upper() + "xx" + +# Prepare a new empty folder at the destination variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant) - -source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) -assert os.path.isdir(source_dir) - +if os.path.isdir(variant_dir): + shutil.rmtree(variant_dir) if not os.path.isdir(variant_dir): os.mkdir(variant_dir) -for file_name in os.listdir(source_dir): - full_file_name = os.path.join(source_dir, file_name) - if os.path.isfile(full_file_name): - shutil.copy(full_file_name, variant_dir) +# Source dir is a local variant sub-folder +source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) +assert os.path.isdir(source_dir) + +marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py index 6c8a4f6034..a4001a240c 100644 --- a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py @@ -1,30 +1,21 @@ -import os -Import("env") +# +# buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +# Customizations for env:jgaurora_a5s_a1 +# +import os,marlin -# Relocate firmware from 0x08000000 to 0x0800A000 -env['CPPDEFINES'].remove(("VECT_TAB_ADDR", "0x8000000")) -#alternatively, for STSTM <=5.1.0 use line below -#env['CPPDEFINES'].remove(("VECT_TAB_ADDR", 134217728)) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x0800A000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/jgaurora_a5s_a1.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - -#append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' -def addboot(source,target,env): +# Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' +def addboot(source, target, env): firmware = open(target[0].path, "rb") lengthfirmware = os.path.getsize(target[0].path) - bootloader_dir = "buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin" - bootloader = open(bootloader_dir, "rb") - lengthbootloader = os.path.getsize(bootloader_dir) - firmware_with_boothloader_dir = target[0].dir.path +'/firmware_with_bootloader.bin' - if os.path.exists(firmware_with_boothloader_dir): - os.remove(firmware_with_boothloader_dir) - firmwareimage = open(firmware_with_boothloader_dir, "wb") + bootloader_bin = "buildroot/share/PlatformIO/scripts/" + "jgaurora_bootloader.bin" + bootloader = open(bootloader_bin, "rb") + lengthbootloader = os.path.getsize(bootloader_bin) + + firmware_with_boothloader_bin = target[0].dir.path + '/firmware_with_bootloader.bin' + if os.path.exists(firmware_with_boothloader_bin): + os.remove(firmware_with_boothloader_bin) + firmwareimage = open(firmware_with_boothloader_bin, "wb") position = 0 while position < lengthbootloader: byte = bootloader.read(1) @@ -38,11 +29,11 @@ def addboot(source,target,env): bootloader.close() firmware.close() firmwareimage.close() - firmware_without_bootloader_dir = target[0].dir.path+'/firmware_for_sd_upload.bin' - if os.path.exists(firmware_without_bootloader_dir): - os.remove(firmware_without_bootloader_dir) - os.rename(target[0].path, firmware_without_bootloader_dir) + + firmware_without_bootloader_bin = target[0].dir.path + '/firmware_for_sd_upload.bin' + if os.path.exists(firmware_without_bootloader_bin): + os.remove(firmware_without_bootloader_bin) + os.rename(target[0].path, firmware_without_bootloader_bin) #os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin') -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", addboot); - +marlin.add_post_action(addboot); diff --git a/buildroot/share/PlatformIO/scripts/lerdge.py b/buildroot/share/PlatformIO/scripts/lerdge.py index ff4f5e446b..55f0a65ace 100644 --- a/buildroot/share/PlatformIO/scripts/lerdge.py +++ b/buildroot/share/PlatformIO/scripts/lerdge.py @@ -1,20 +1,16 @@ # -# lerdge.py -# Customizations for Lerdge build environments +# buildroot/share/PlatformIO/scripts/lerdge.py +# Customizations for Lerdge build environments: +# env:LERDGEX env:LERDGEX_usb_flash_drive +# env:LERDGES env:LERDGES_usb_flash_drive +# env:LERDGEK env:LERDGEK_usb_flash_drive # -import os,sys +import os,marlin Import("env") from SCons.Script import DefaultEnvironment board = DefaultEnvironment().BoardConfig() -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/lerdge.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - def encryptByte(byte): byte = 0xFF & ((byte << 6) | (byte >> 2)) i = 0x58 + byte @@ -35,16 +31,16 @@ def encrypt_file(input, output_file, file_length): def encrypt(source, target, env): print("Encrypting to:", board.get("build.firmware")) firmware = open(target[0].path, "rb") - result = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb") + renamed = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb") length = os.path.getsize(target[0].path) - encrypt_file(firmware, result, length) + encrypt_file(firmware, renamed, length) firmware.close() - result.close() + renamed.close() if 'firmware' in board.get("build").keys(): - env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); + marlin.add_post_action(encrypt); else: print("You need to define output file via board_build.firmware = 'filename' parameter") exit(1); diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py new file mode 100644 index 0000000000..d83ebceee2 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -0,0 +1,75 @@ +# +# buildroot/share/PlatformIO/scripts/marlin.py +# Helper module with some commonly-used functions +# +import os,shutil + +from SCons.Script import DefaultEnvironment +env = DefaultEnvironment() + +def copytree(src, dst, symlinks=False, ignore=None): + for item in os.listdir(src): + s = os.path.join(src, item) + d = os.path.join(dst, item) + if os.path.isdir(s): + shutil.copytree(s, d, symlinks, ignore) + else: + shutil.copy2(s, d) + +def replace_define(field, value): + for define in env['CPPDEFINES']: + if define[0] == field: + env['CPPDEFINES'].remove(define) + env['CPPDEFINES'].append((field, value)) + +# Relocate the firmware to a new address, such as "0x08005000" +def relocate_firmware(address): + replace_define("VECT_TAB_ADDR", address) + +# Relocate the vector table with a new offset +def relocate_vtab(address): + replace_define("VECT_TAB_OFFSET", address) + +# Replace the existing -Wl,-T with the given ldscript path +def custom_ld_script(ldname): + apath = os.path.abspath("buildroot/share/PlatformIO/ldscripts/" + ldname) + for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,-T" in flag: + env["LINKFLAGS"][i] = "-Wl,-T" + apath + elif flag == "-T": + env["LINKFLAGS"][i + 1] = apath + +# Encrypt ${PROGNAME}.bin and save it with a new name +# Called by specific encrypt() functions, mostly for MKS boards +def encrypt_mks(source, target, env, new_name): + import sys + + key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] + + firmware = open(target[0].path, "rb") + renamed = open(target[0].dir.path + "/" + new_name, "wb") + length = os.path.getsize(target[0].path) + position = 0 + try: + while position < length: + byte = firmware.read(1) + if position >= 320 and position < 31040: + byte = chr(ord(byte) ^ key[position & 31]) + if sys.version_info[0] > 2: + byte = bytes(byte, 'latin1') + renamed.write(byte) + position += 1 + finally: + firmware.close() + renamed.close() + +def add_post_action(action): + env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", action); + +# Apply customizations for a MKS Robin +def prepare_robin(address, ldname, fwname): + def encrypt(source, target, env): + encrypt_mks(source, target, env, fwname) + relocate_firmware(address) + custom_ld_script(ldname) + add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/mks_encrypt.py b/buildroot/share/PlatformIO/scripts/mks_encrypt.py index 0d53cdfbe9..78d7cf349d 100644 --- a/buildroot/share/PlatformIO/scripts/mks_encrypt.py +++ b/buildroot/share/PlatformIO/scripts/mks_encrypt.py @@ -1,32 +1,28 @@ -import os,sys +# +# buildroot/share/PlatformIO/scripts/mks_encrypt.py +# +# Apply encryption and save as 'build.firmware' for these environments: +# - env:mks_robin_stm32 +# - env:flsun_hispeedv1 +# - env:mks_robin_nano35_stm32 +# Import("env") from SCons.Script import DefaultEnvironment board = DefaultEnvironment().BoardConfig() -# Encrypt ${PROGNAME}.bin and save it as build.firmware ('Robin.bin') -def encrypt(source, target, env): - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/'+ board.get("build.firmware"), "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() - if 'firmware' in board.get("build").keys(): - env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); + + import marlin + + # Encrypt ${PROGNAME}.bin and save it as build.firmware + def encrypt(source, target, env): + marlin.encrypt_mks(source, target, env, "build.firmware") + + marlin.add_post_action(encrypt); + else: - print("You need to define output file via board_build.firmware = 'filename' parameter", file=sys.stderr) - exit(1); + + import sys + print("You need to define output file via board_build.firmware = 'filename' parameter", file=sys.stderr) + env.Exit(1); diff --git a/buildroot/share/PlatformIO/scripts/mks_robin.py b/buildroot/share/PlatformIO/scripts/mks_robin.py index dd2342bf0d..8c5e4ae276 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin.py @@ -1,39 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08007000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - -# Encrypt ${PROGNAME}.bin and save it as 'Robin.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/Robin.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin.py +# +import marlin +marlin.prepare_robin("0x08007000", "mks_robin.ld", "Robin.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3.py index 3af623cce0..7f6f538d6a 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3.py @@ -1,40 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08005000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - - -# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/Robin_e3.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin_e3.py +# +import marlin +marlin.prepare_robin("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py index 2aab14bab7..1f3cacf873 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py @@ -1,40 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08007000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - - -# Encrypt ${PROGNAME}.bin and save it as 'mks_robin_e3p.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/Robin_e3p.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +# +import marlin +marlin.prepare_robin("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py index 2f3ae1fa9a..b8c039ada8 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py @@ -1,40 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08005000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - - -# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/mksLite.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin_lite.py +# +import marlin +marlin.prepare_robin("0x08005000", "mks_robin_lite.ld", "mksLite.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py index 67ad442d82..bea8b80ace 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py @@ -1,40 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08005000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - - -# Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/mksLite3.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin_lite3.py +# +import marlin +marlin.prepare_robin("0x08005000", "mks_robin_lite.ld", "mksLite3.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py index d386698301..4c52035965 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py @@ -1,40 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08007000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_mini.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - - -# Encrypt ${PROGNAME}.bin and save it as 'Robin_mini.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/Robin_mini.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin_mini.py +# +import marlin +marlin.prepare_robin("0x08005000", "mks_robin_mini.ld", "Robin_mini.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py index a68fd308d4..319b4d4982 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py @@ -1,40 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08007000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_nano.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - - -# Encrypt ${PROGNAME}.bin and save it as 'Robin_nano.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/Robin_nano.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin_nano.py +# +import marlin +marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py index 0047289adf..310c3d6606 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py @@ -1,40 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08007000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_nano.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - - -# Encrypt ${PROGNAME}.bin and save it as 'Robin_nano35.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/Robin_nano35.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +# +import marlin +marlin.prepare_robin("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py b/buildroot/share/PlatformIO/scripts/mks_robin_pro.py index 2ebf1ffb9d..c624663a33 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_pro.py @@ -1,39 +1,5 @@ -import os -Import("env") - -# Relocate firmware from 0x08000000 to 0x08007000 -for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - env['CPPDEFINES'].remove(define) -env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) - -custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_pro.ld") -for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script - elif flag == "-T": - env["LINKFLAGS"][i + 1] = custom_ld_script - -# Encrypt ${PROGNAME}.bin and save it as 'Robin.bin' -def encrypt(source, target, env): - import sys - - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - - firmware = open(target[0].path, "rb") - robin = open(target[0].dir.path +'/Robin_pro.bin', "wb") - length = os.path.getsize(target[0].path) - position = 0 - try: - while position < length: - byte = firmware.read(1) - if position >= 320 and position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - robin.write(byte) - position += 1 - finally: - firmware.close() - robin.close() -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); +# +# buildroot/share/PlatformIO/scripts/mks_robin_pro.py +# +import marlin +marlin.prepare_robin("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") diff --git a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py index 1ceff84b8f..4e7d2d9c07 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/stm32_bootloader.py @@ -1,7 +1,7 @@ # # stm32_bootloader.py # -import os,sys,shutil +import os,sys,shutil,marlin Import("env") from SCons.Script import DefaultEnvironment @@ -11,35 +11,30 @@ board = DefaultEnvironment().BoardConfig() # Copy the firmware.bin file to build.firmware, no encryption # def noencrypt(source, target, env): - firmware = os.path.join(target[0].dir.path, board.get("build.firmware")) - shutil.copy(target[0].path, firmware) + firmware = os.path.join(target[0].dir.path, board.get("build.firmware")) + shutil.copy(target[0].path, firmware) # # For build.offset define LD_FLASH_OFFSET, used by ldscript.ld # if 'offset' in board.get("build").keys(): - LD_FLASH_OFFSET = board.get("build.offset") + LD_FLASH_OFFSET = board.get("build.offset") - # Remove an existing VECT_TAB_OFFSET from CPPDEFINES - for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_OFFSET": - env['CPPDEFINES'].remove(define) + marlin.relocate_vtab(LD_FLASH_OFFSET) - # Replace VECT_TAB_OFFSET with our LD_FLASH_OFFSET - env['CPPDEFINES'].append(("VECT_TAB_OFFSET", LD_FLASH_OFFSET)) + # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json) + maximum_ram_size = board.get("upload.maximum_ram_size") - # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json) - maximum_ram_size = board.get("upload.maximum_ram_size") - - for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,--defsym=LD_FLASH_OFFSET" in flag: - env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET - if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: - env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) + for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,--defsym=LD_FLASH_OFFSET" in flag: + env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET + if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: + env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) # # Only copy the file if there's no encrypt # board_keys = board.get("build").keys() if 'firmware' in board_keys and not 'encrypt' in board_keys: - env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt) + import marlin + marlin.add_post_action(noencrypt) diff --git a/buildroot/share/PlatformIO/variants/archim/.gitignore b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/.gitignore similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/.gitignore rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/.gitignore diff --git a/buildroot/share/PlatformIO/variants/archim/build_gcc/Makefile b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/Makefile similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/build_gcc/Makefile rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/Makefile diff --git a/buildroot/share/PlatformIO/variants/archim/build_gcc/debug.mk b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/debug.mk similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/build_gcc/debug.mk rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/debug.mk diff --git a/buildroot/share/PlatformIO/variants/archim/build_gcc/gcc.mk b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/gcc.mk similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/build_gcc/gcc.mk rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/gcc.mk diff --git a/buildroot/share/PlatformIO/variants/archim/build_gcc/libvariant_arduino_due_x.mk b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/libvariant_arduino_due_x.mk similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/build_gcc/libvariant_arduino_due_x.mk rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/libvariant_arduino_due_x.mk diff --git a/buildroot/share/PlatformIO/variants/archim/build_gcc/release.mk b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/release.mk similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/build_gcc/release.mk rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/build_gcc/release.mk diff --git a/buildroot/share/PlatformIO/variants/archim/debug_scripts/gcc/arduino_due_x_flash.gdb b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/debug_scripts/gcc/arduino_due_x_flash.gdb similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/debug_scripts/gcc/arduino_due_x_flash.gdb rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/debug_scripts/gcc/arduino_due_x_flash.gdb diff --git a/buildroot/share/PlatformIO/variants/archim/debug_scripts/gcc/arduino_due_x_sram.gdb b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/debug_scripts/gcc/arduino_due_x_sram.gdb similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/debug_scripts/gcc/arduino_due_x_sram.gdb rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/debug_scripts/gcc/arduino_due_x_sram.gdb diff --git a/buildroot/share/PlatformIO/variants/archim/debug_scripts/iar/arduino_due_flash.mac b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/debug_scripts/iar/arduino_due_flash.mac similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/debug_scripts/iar/arduino_due_flash.mac rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/debug_scripts/iar/arduino_due_flash.mac diff --git a/buildroot/share/PlatformIO/variants/archim/debug_scripts/iar/arduino_due_sram.mac b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/debug_scripts/iar/arduino_due_sram.mac similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/debug_scripts/iar/arduino_due_sram.mac rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/debug_scripts/iar/arduino_due_sram.mac diff --git a/buildroot/share/PlatformIO/variants/archim/libsam_sam3x8e_gcc_rel.a b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/libsam_sam3x8e_gcc_rel.a similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/libsam_sam3x8e_gcc_rel.a rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/libsam_sam3x8e_gcc_rel.a diff --git a/buildroot/share/PlatformIO/variants/archim/libsam_sam3x8e_gcc_rel.a.txt b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/libsam_sam3x8e_gcc_rel.a.txt similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/libsam_sam3x8e_gcc_rel.a.txt rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/libsam_sam3x8e_gcc_rel.a.txt diff --git a/buildroot/share/PlatformIO/variants/archim/linker_scripts/gcc/flash.ld b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/linker_scripts/gcc/flash.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/linker_scripts/gcc/flash.ld rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/linker_scripts/gcc/flash.ld diff --git a/buildroot/share/PlatformIO/variants/archim/linker_scripts/gcc/sram.ld b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/linker_scripts/gcc/sram.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/linker_scripts/gcc/sram.ld rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/linker_scripts/gcc/sram.ld diff --git a/buildroot/share/PlatformIO/variants/archim/linker_scripts/iar/flash.icf b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/linker_scripts/iar/flash.icf similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/linker_scripts/iar/flash.icf rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/linker_scripts/iar/flash.icf diff --git a/buildroot/share/PlatformIO/variants/archim/linker_scripts/iar/sram.icf b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/linker_scripts/iar/sram.icf similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/linker_scripts/iar/sram.icf rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/linker_scripts/iar/sram.icf diff --git a/buildroot/share/PlatformIO/variants/archim/pins_arduino.h b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/pins_arduino.h similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/pins_arduino.h rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/pins_arduino.h diff --git a/buildroot/share/PlatformIO/variants/archim/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/archim/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/archim/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_BTT002/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_BTT002/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/hal_conf_extra.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_BTT002/hal_conf_extra.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/hal_conf_extra.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_BTT002/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_BTT002/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_BTT002/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_BTT002/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/hal_conf_extra.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/hal_conf_extra.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/hal_conf_extra.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_E3_RRF/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/hal_conf_extra.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/hal_conf_extra.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/hal_conf_extra.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/hal_conf_extra.h diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/hal_conf_extra.h rename to buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/BTT_SKR_SE_BX/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h diff --git a/buildroot/share/PlatformIO/variants/FLY_F407ZG/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/FLY_F407ZG/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/FLY_F407ZG/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/FLY_F407ZG/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/FLY_F407ZG/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/FLY_F407ZG/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/FLY_F407ZG/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/FLY_F407ZG/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/FLY_F407ZG/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/FLY_F407ZG/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h similarity index 100% rename from buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/hal_conf_custom.h rename to buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/FYSETC_CHEETAH_V20/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h diff --git a/buildroot/share/PlatformIO/variants/LERDGE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/LERDGE/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_LERDGE/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/LERDGE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/LERDGE/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_LERDGE/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/ldscripts/lerdge.ld b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/ldscripts/lerdge.ld rename to buildroot/share/PlatformIO/variants/MARLIN_LERDGE/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/LERDGE/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/LERDGE/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/LERDGE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/LERDGE/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h diff --git a/buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h b/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h similarity index 100% rename from buildroot/share/PlatformIO/variants/megaextendedpins/pins_arduino.h rename to buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/STEVAL_F401VE/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/STEVAL_F401VE/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h similarity index 100% rename from buildroot/share/PlatformIO/variants/STEVAL_F401VE/hal_conf_custom.h rename to buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/STEVAL_F401VE/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/STEVAL_F401VE/variant.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/STEVAL_F401VE/variant.h rename to buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/board.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/board.cpp rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/board.cpp diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/board/board.h b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/board/board.h similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/board/board.h rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/board/board.h diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/ld/common.inc b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/common.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/ld/common.inc rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/common.inc diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/ld/extra_libs.inc b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/extra_libs.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/ld/extra_libs.inc rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/extra_libs.inc diff --git a/buildroot/share/PlatformIO/ldscripts/chitu_f103.ld b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/flash.ld similarity index 100% rename from buildroot/share/PlatformIO/ldscripts/chitu_f103.ld rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/flash.ld diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103z_dfu.ld b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103z_dfu.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103z_dfu.ld rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103z_dfu.ld diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zc.ld b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103zc.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zc.ld rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103zc.ld diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zd.ld b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103zd.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103zd.ld rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103zd.ld diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103ze.ld b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103ze.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/ld/stm32f103ze.ld rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103ze.ld diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/ld/vector_symbols.inc b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/vector_symbols.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/ld/vector_symbols.inc rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/vector_symbols.inc diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/pins_arduino.h b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/pins_arduino.h similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/pins_arduino.h rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/pins_arduino.h diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/variant.h b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/variant.h rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/variant.h diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/boards.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards.cpp rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/boards.cpp diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/boards_setup.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/boards_setup.cpp diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/start.S b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/start.S similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/wirish/start.S rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/start.S diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/start_c.c b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/start_c.c similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/wirish/start_c.c rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/start_c.c diff --git a/buildroot/share/PlatformIO/variants/CHITU_F103/wirish/syscalls.c b/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/syscalls.c similarity index 100% rename from buildroot/share/PlatformIO/variants/CHITU_F103/wirish/syscalls.c rename to buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/syscalls.c diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/board.cpp b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/board.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/board.cpp rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/board.cpp diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/board/board.h b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/board/board.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/board/board.h rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/board/board.h diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/bootloader.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/bootloader.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/bootloader.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/bootloader.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/common.inc b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/common.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/common.inc rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/common.inc diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/extra_libs.inc b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/extra_libs.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/extra_libs.inc rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/extra_libs.inc diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/flash.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/flash.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/flash.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/flash.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/jtag.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/jtag.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/jtag.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/jtag.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/mem-flash.inc b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-flash.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/mem-flash.inc rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-flash.inc diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/mem-jtag.inc b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-jtag.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/mem-jtag.inc rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-jtag.inc diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/mem-ram.inc b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-ram.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/mem-ram.inc rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-ram.inc diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/ram.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/ram.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/ram.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/ram.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103rb.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rb.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103rb.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rb.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103rb_bootloader.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rb_bootloader.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103rb_bootloader.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rb_bootloader.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103rc.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rc.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103rc.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rc.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103rc_bootloader.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rc_bootloader.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103rc_bootloader.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rc_bootloader.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103re.ld b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103re.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/stm32f103re.ld rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103re.ld diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/ld/vector_symbols.inc b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/vector_symbols.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/ld/vector_symbols.inc rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/vector_symbols.inc diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/pins_arduino.h b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/pins_arduino.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/pins_arduino.h rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/pins_arduino.h diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/variant.h b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/variant.h rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/variant.h diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/boards.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/boards.cpp rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/boards.cpp diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/boards_setup.cpp b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/boards_setup.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/boards_setup.cpp rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/boards_setup.cpp diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/start.S b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/start.S similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/start.S rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/start.S diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/start_c.c b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/start_c.c similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/start_c.c rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/start_c.c diff --git a/buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/syscalls.c b/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/syscalls.c similarity index 100% rename from buildroot/share/PlatformIO/variants/MEEB_3DP/wirish/syscalls.c rename to buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/syscalls.c diff --git a/buildroot/tests/chitu_f103 b/buildroot/tests/chitu_f103 new file mode 100755 index 0000000000..139c480e3e --- /dev/null +++ b/buildroot/tests/chitu_f103 @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# Build tests for chitu_f103 (STM32F103ZE) +# + +# exit on first failure +set -e + +# +# Build with the default configurations +# +use_example_configs Tronxy/X5SA +exec_test $1 $2 "Tronxy/X5SA" "$3" + +# clean up +restore_configs diff --git a/ini/avr.ini b/ini/avr.ini index 1b208400a3..cd10f13499 100644 --- a/ini/avr.ini +++ b/ini/avr.ini @@ -35,9 +35,9 @@ board = megaatmega2560 [env:mega2560ext] platform = atmelavr extends = env:mega2560 -board_build.variant = megaextendedpins +board_build.variant = MARLIN_MEGA_EXTENDED extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py # # ATmega1280 @@ -52,9 +52,9 @@ board = megaatmega1280 # [mega_extended_optimized] extends = common_avr8 -board_build.variant = megaextendedpins +board_build.variant = MARLIN_MEGA_EXTENDED extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py upload_speed = 57600 build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues @@ -88,7 +88,7 @@ board = reprap_rambo [env:FYSETC_F6] platform = atmelavr extends = common_avr8 -board = fysetc_f6 +board = fysetc_f6_13 # # Sanguinololu (ATmega644p) @@ -161,7 +161,7 @@ build_flags = ${tuned_1284p.build_flags} [env:at90usb1286_cdc] platform = teensy extends = common_avr8 -board = at90usb1286 +board = marlin_at90usb1286 lib_ignore = ${env:common_avr8.lib_ignore}, Teensy_ADC, NativeEthernet # diff --git a/ini/due.ini b/ini/due.ini index 7abc262eb4..9123af8cdc 100644 --- a/ini/due.ini +++ b/ini/due.ini @@ -31,7 +31,7 @@ board = dueUSB [common_DUE_archim] platform = atmelsam extends = env:DUE -board = archim +board = marlin_archim build_flags = ${common.build_flags} -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSBCON board_build.variants_dir = buildroot/share/PlatformIO/variants/ diff --git a/ini/stm32f0.ini b/ini/stm32f0.ini index 10ac21fc89..64568e4b4c 100644 --- a/ini/stm32f0.ini +++ b/ini/stm32f0.ini @@ -25,7 +25,7 @@ [env:STM32F070RB_malyan] platform = ${common_stm32.platform} extends = common_stm32 -board = malyanM200v2 +board = marlin_malyanM200v2 build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED -O2 -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing -DCUSTOM_STARTUP_FILE diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index a2954e64cf..94693d65a4 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -65,7 +65,7 @@ monitor_speed = 115200 [env:STM32F103RC_meeb] platform = ${common_stm32f1.platform} extends = common_stm32f1 -board = MEEB_3DP +board = marlin_MEEB_3DP build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 @@ -114,8 +114,10 @@ upload_protocol = serial [env:STM32F103RC_btt] platform = ${common_stm32f1.platform} extends = env:STM32F103RC +board_build.address = 0x08007000 +board_build.ldscript = STM32F103RC_SKR_MINI_256K.ld extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/STM32F103RC_SKR_MINI.py + buildroot/share/PlatformIO/scripts/custom_board.py build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 monitor_speed = 115200 @@ -130,6 +132,7 @@ lib_deps = ${env:STM32F103RC_btt.lib_deps} [env:STM32F103RC_btt_512K] platform = ${common_stm32f1.platform} extends = env:STM32F103RC_btt +board_build.ldscript = STM32F103RC_SKR_MINI_512K.ld board_upload.maximum_size=524288 build_flags = ${env:STM32F103RC_btt.build_flags} -DSTM32_FLASH_SIZE=512 @@ -156,8 +159,10 @@ monitor_speed = 115200 [env:STM32F103RE_btt] platform = ${common_stm32f1.platform} extends = env:STM32F103RE +board_build.address = 0x08007000 +board_build.ldscript = STM32F103RE_SKR_E3_DIP.ld extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/STM32F103RE_SKR_E3_DIP.py + buildroot/share/PlatformIO/scripts/custom_board.py build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 debug_tool = stlink upload_protocol = stlink @@ -190,7 +195,10 @@ upload_protocol = serial platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103VE +board_build.address = 0x08010000 +board_build.ldscript = STM32F103VE_longer.ld extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/custom_board.py buildroot/share/PlatformIO/scripts/STM32F103VE_longer.py build_flags = ${common_stm32f1.build_flags} -DMCU_STM32F103VE -DSTM32F1xx -USERIAL_USB -DU20 -DTS_V12 @@ -330,7 +338,10 @@ extra_scripts = ${common_stm32f1.extra_scripts} platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103ZE +board_build.address = 0x0800A000 +board_build.ldscript = jgaurora_a5s_a1.ld extra_scripts = ${common_stm32f1.extra_scripts} + buildroot/share/PlatformIO/scripts/custom_board.py buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py build_flags = ${common_stm32f1.build_flags} -DSTM32F1xx -DSTM32_XL_DENSITY @@ -341,7 +352,7 @@ build_flags = ${common_stm32f1.build_flags} [env:STM32F103CB_malyan] platform = ${common_stm32f1.platform} extends = common_stm32f1 -board = malyanM200 +board = marlin_malyanM200 build_flags = ${common_stm32f1.build_flags} -DMCU_STM32F103CB -D__STM32F1__=1 -std=c++1y -DSERIAL_USB -ffunction-sections -fdata-sections -Wl,--gc-sections -DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__ @@ -354,7 +365,7 @@ lib_ignore = ${common_stm32f1.lib_ignore} [env:chitu_f103] platform = ${common_stm32f1.platform} extends = common_stm32f1 -board = CHITU_F103 +board = marlin_CHITU_F103 extra_scripts = pre:buildroot/share/PlatformIO/scripts/common-dependencies.py pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -379,9 +390,11 @@ build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX platform = ${env:STM32F103RE.platform} extends = env:STM32F103RE build_flags = ${env:STM32F103RE.build_flags} -DTEMP_TIMER_CHAN=4 +board_build.address = 0x08007000 +board_build.ldscript = creality.ld extra_scripts = ${env:STM32F103RE.extra_scripts} pre:buildroot/share/PlatformIO/scripts/random-bin.py - buildroot/share/PlatformIO/scripts/STM32F103RET6_creality.py + buildroot/share/PlatformIO/scripts/custom_board.py debug_tool = jlink upload_protocol = jlink diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 1678b26d89..d6418f439e 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -36,13 +36,12 @@ build_flags = ${common_stm32.build_flags} [env:STM32F401VE_STEVAL] platform = ${common_stm32.platform} extends = common_stm32 -board = STEVAL_STM32F401VE +board = marlin_STEVAL_STM32F401VE build_flags = ${common_stm32.build_flags} -DARDUINO_STEVAL -DSTM32F401xE -DDISABLE_GENERIC_SERIALUSB -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/STM32F401VE_STEVAL.py # # STM32F401RC @@ -50,38 +49,41 @@ extra_scripts = ${common.extra_scripts} [env:FYSETC_CHEETAH_V20] platform = ${common_stm32.platform} extends = common_stm32 -board = FYSETC_CHEETAH_V20 +board = marlin_FYSETC_CHEETAH_V20 build_flags = ${common_stm32.build_flags} -DSTM32F401xC -DVECT_TAB_OFFSET=0xC000 extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py - buildroot/share/PlatformIO/scripts/FYSETC_CHEETAH_V20.py # # FLYF407ZG # [env:FLYF407ZG] -platform = ${common_stm32.platform} -extends = common_stm32 -board = FLYF407ZG -build_flags = ${common_stm32.build_flags} +platform = ${common_stm32.platform} +extends = common_stm32 +board = marlin_STM32F407ZGT6 +board_build.variant = MARLIN_FLY_F407ZG +upload_protocol = dfu +build_flags = ${common_stm32.build_flags} -DVECT_TAB_OFFSET=0x8000 -extra_scripts = ${common.extra_scripts} +extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py # -# FLY MINI(stm32f103rct6) +# FLY MINI (STM32F103RCT6) # [env:FLY_MINI] platform = ${common_stm32f1.platform} extends = common_stm32f1 board = genericSTM32F103RC +board_build.address = 0x08005000 +board_build.ldscript = fly_mini.ld extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/fly_mini.py + buildroot/share/PlatformIO/scripts/custom_board.py build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 -DSS_TIMER=4 + -DDEBUG_LEVEL=0 -DSS_TIMER=4 # -# FYSETC S6 (STM32F446VET6 ARM Cortex-M4) +# FYSETC S6 (STM32F446RET6 ARM Cortex-M4) # [env:FYSETC_S6] platform = ${common_stm32.platform} @@ -105,7 +107,7 @@ upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" [env:STM32F407VE_black] platform = ${common_stm32.platform} extends = common_stm32 -board = blackSTM32F407VET6 +board = marlin_blackSTM32F407VET6 build_flags = ${common_stm32.build_flags} -DARDUINO_BLACK_F407VE -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS @@ -121,7 +123,7 @@ extra_scripts = ${common.extra_scripts} platform = ${common_stm32.platform} extends = common_stm32 build_flags = ${common_stm32.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED -board = genericSTM32F407VGT6 +board = marlin_STM32F407VGT6_CCM board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx board_build.ldscript = ldscript.ld @@ -144,7 +146,7 @@ extra_scripts = ${common.extra_scripts} [env:BIGTREE_SKR_PRO] platform = ${common_stm32.platform} extends = common_stm32 -board = BigTree_SKR_Pro +board = marlin_BigTree_SKR_Pro build_flags = ${common_stm32.build_flags} -DSTM32F407_5ZX -DVECT_TAB_OFFSET=0x8000 extra_scripts = ${common.extra_scripts} @@ -180,7 +182,7 @@ build_flags = ${stm_flash_drive.build_flags} platform = ${common_stm32.platform} extends = common_stm32 board = genericSTM32F407VGT6 -board_build.variant = BIGTREE_E3_RRF +board_build.variant = MARLIN_BIGTREE_E3_RRF build_flags = ${common_stm32.build_flags} -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000 -DSERIAL_RX_BUFFER_SIZE=255 -DSERIAL_TX_BUFFER_SIZE=255 @@ -193,7 +195,7 @@ extra_scripts = ${common.extra_scripts} [env:BIGTREE_GTR_V1_0] platform = ${common_stm32.platform} extends = common_stm32 -board = BigTree_GTR_v1 +board = marlin_BigTree_GTR_v1 extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py build_flags = ${common_stm32.build_flags} @@ -215,7 +217,7 @@ build_flags = ${stm_flash_drive.build_flags} [env:BIGTREE_BTT002] platform = ${common_stm32.platform} extends = common_stm32 -board = BigTree_Btt002 +board = marlin_BigTree_BTT002 build_flags = ${common_stm32.build_flags} -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000 -DHAVE_HWSERIAL2 @@ -251,11 +253,12 @@ build_flags = ${stm_flash_drive.build_flags} [lerdge_common] platform = ${common_stm32.platform} extends = common_stm32 -board = LERDGE +board = marlin_STM32F407ZGT6 +board_build.variant = MARLIN_LERDGE board_build.offset = 0x10000 board_build.encrypt = Yes extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py buildroot/share/PlatformIO/scripts/stm32_bootloader.py buildroot/share/PlatformIO/scripts/lerdge.py build_flags = ${common_stm32.build_flags} @@ -377,7 +380,7 @@ build_flags = -DPIN_WIRE_SCL=PB6 -DPIN_WIRE_SDA=PB7 platform = ${common_stm32.platform} extends = common_stm32 build_flags = ${common_stm32.build_flags} ${stm32f4_I2C1.build_flags} -DHAL_PCD_MODULE_ENABLED -DUSBCON -DUSBD_USE_CDC -board = genericSTM32F407VGT6 +board = marlin_STM32F407VGT6_CCM board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx board_build.ldscript = ldscript.ld diff --git a/ini/stm32f7.ini b/ini/stm32f7.ini index afcfc102d5..76d039533c 100644 --- a/ini/stm32f7.ini +++ b/ini/stm32f7.ini @@ -46,7 +46,7 @@ build_flags = ${common_stm32.build_flags} platform = ${common_stm32.platform} platform_packages = ${stm_flash_drive.platform_packages} extends = common_stm32 -board = BTT_SKR_SE_BX +board = marlin_BTT_SKR_SE_BX extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py build_flags = ${common_stm32.build_flags} From 516fe131bea242be903d0ec6d90a8f6f209ef173 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Tue, 27 Apr 2021 05:16:19 -0700 Subject: [PATCH 307/311] BTT SKR V2 probe and chamber pins (#21717) --- Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h | 32 +++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h index fa08aedbb0..11f954c400 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h @@ -200,15 +200,35 @@ #define TEMP_0_PIN PA2 // TH0 #define TEMP_1_PIN PA3 // TH1 +#if HOTENDS == 1 + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + // // Heaters / Fans // -#define HEATER_0_PIN PB3 // Heater0 -#define HEATER_1_PIN PB4 // Heater1 -#define HEATER_BED_PIN PD7 // Hotbed -#define FAN_PIN PB7 // Fan0 -#define FAN1_PIN PB6 // Fan1 -#define FAN2_PIN PB5 // Fan2 +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PB3 // Heater0 +#endif +#ifndef HEATER_1_PIN + #define HEATER_1_PIN PB4 // Heater1 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PD7 // Hotbed +#endif +#ifndef FAN_PIN + #define FAN_PIN PB7 // Fan0 +#endif +#ifndef FAN1_PIN + #define FAN1_PIN PB6 // Fan1 +#endif +#ifndef FAN2_PIN + #define FAN2_PIN PB5 // Fan2 +#endif // // Software SPI pins for TMC2130 stepper drivers From f04b2a939087f2f6cc04c42a11f8589d82253433 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Tue, 27 Apr 2021 17:21:13 -0700 Subject: [PATCH 308/311] Clean up TFT comments (#21723) --- .../src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp | 5 +++-- Marlin/src/lcd/tft/tft_color.h | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp index 682178efe5..b0cb59a12c 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp @@ -83,7 +83,8 @@ TFT_IO tftio; #define X_HI (UPSCALE(TFT_PIXEL_OFFSET_X, WIDTH) - 1) #define Y_HI (UPSCALE(TFT_PIXEL_OFFSET_Y, HEIGHT) - 1) -// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html +// 16 bit color generator: https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html +// RGB565 color picker: https://trolsoft.ru/en/articles/rgb565-color-picker #define COLOR_BLACK 0x0000 // #000000 #define COLOR_WHITE 0xFFFF // #FFFFFF @@ -91,7 +92,7 @@ TFT_IO tftio; #define COLOR_GREY 0x7BEF // #808080 #define COLOR_DARKGREY 0x4208 // #404040 #define COLOR_DARKGREY2 0x39E7 // #303030 -#define COLOR_DARK 0x0003 // Some dark color +#define COLOR_DARK 0x0003 // #000019 #define COLOR_RED 0xF800 // #FF0000 #define COLOR_LIME 0x7E00 // #00FF00 diff --git a/Marlin/src/lcd/tft/tft_color.h b/Marlin/src/lcd/tft/tft_color.h index d060d3209d..a8668179e5 100644 --- a/Marlin/src/lcd/tft/tft_color.h +++ b/Marlin/src/lcd/tft/tft_color.h @@ -30,7 +30,8 @@ #define COLOR(color) RGB(((color >> 16) & 0xFF), ((color >> 8) & 0xFF), (color & 0xFF)) #define HALF(color) RGB(RED(color) >> 1, GREEN(color) >> 1, BLUE(color) >> 1) -// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html +// 16 bit color generator: https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html +// RGB565 color picker: https://trolsoft.ru/en/articles/rgb565-color-picker #define COLOR_BLACK 0x0000 // #000000 #define COLOR_WHITE 0xFFFF // #FFFFFF @@ -38,7 +39,7 @@ #define COLOR_GREY 0x7BEF // #808080 #define COLOR_DARKGREY 0x4208 // #404040 #define COLOR_DARKGREY2 0x39E7 // #303030 -#define COLOR_DARK 0x0003 // Some dark color +#define COLOR_DARK 0x0003 // #000019 #define COLOR_RED 0xF800 // #FF0000 #define COLOR_SCARLET 0xF904 // #FF2020 @@ -51,7 +52,7 @@ #define COLOR_CYAN 0x07FF // #00FFFF #define COLOR_AQUA 0x07FF // #00FFFF #define COLOR_DODGER_BLUE 0x041F // #0080FF -#define COLOR_VIVID_VIOLET 0x7933 // #772399 +#define COLOR_VIVID_VIOLET 0x7933 // #772399 #define COLOR_DARK_PURPLE 0x9930 // #992380 @@ -73,10 +74,10 @@ #define COLOR_BACKGROUND 0x20AC // #1E156E #endif #ifndef COLOR_SELECTION_BG - #define COLOR_SELECTION_BG 0x9930 // #992380 + #define COLOR_SELECTION_BG 0x9930 // #992380 #endif #ifndef COLOR_WEBSITE_URL - #define COLOR_WEBSITE_URL 0x03B7 + #define COLOR_WEBSITE_URL 0x03B7 // #0075BD #endif #ifndef COLOR_INACTIVE From f7f88b7187624d8687a79f674993648557b94ba2 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 28 Apr 2021 00:34:25 +0000 Subject: [PATCH 309/311] [cron] Bump distribution date (2021-04-28) --- 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 c5c707d067..e3bfb9dd72 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-04-27" + #define STRING_DISTRIBUTION_DATE "2021-04-28" #endif /** From 2e0a1f1afff71a29e5fb5eb99c509d0de5384087 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 28 Apr 2021 11:08:21 +0200 Subject: [PATCH 310/311] Color UI Move Screen for 320x240 TFT (#21708) --- Marlin/src/feature/dac/stepper_dac.h | 2 +- Marlin/src/lcd/marlinui.cpp | 2 +- Marlin/src/lcd/marlinui.h | 23 +- Marlin/src/lcd/menu/menu_motion.cpp | 20 +- .../src/lcd/tft/bitmaps/btn_42x39_rounded.bmp | Bin 0 -> 5046 bytes .../lcd/tft/images/btn_rounded_42x39x4.cpp | 69 +++ Marlin/src/lcd/tft/tft_image.cpp | 2 + Marlin/src/lcd/tft/tft_image.h | 3 + Marlin/src/lcd/tft/ui_1024x600.cpp | 49 +-- Marlin/src/lcd/tft/ui_320x240.cpp | 403 +++++++++++++++++- Marlin/src/lcd/tft/ui_480x320.cpp | 49 +-- 11 files changed, 526 insertions(+), 96 deletions(-) create mode 100644 Marlin/src/lcd/tft/bitmaps/btn_42x39_rounded.bmp create mode 100644 Marlin/src/lcd/tft/images/btn_rounded_42x39x4.cpp diff --git a/Marlin/src/feature/dac/stepper_dac.h b/Marlin/src/feature/dac/stepper_dac.h index 6836335e98..26a0f2f95c 100644 --- a/Marlin/src/feature/dac/stepper_dac.h +++ b/Marlin/src/feature/dac/stepper_dac.h @@ -34,7 +34,7 @@ public: static void set_current_value(const uint8_t channel, uint16_t val); static void print_values(); static void commit_eeprom(); - static uint8_t get_current_percent(AxisEnum axis); + static uint8_t get_current_percent(const AxisEnum axis); static void set_current_percents(xyze_uint8_t &pct); }; diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 476caf3225..1b517f7d21 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -757,7 +757,7 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { // // Tell ui.update() to start a move to current_position after a short delay. // - void ManualMove::soon(AxisEnum move_axis + void ManualMove::soon(const AxisEnum move_axis #if MULTI_MANUAL , const int8_t eindex/*=-1*/ #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 8befa1d980..085e2e0b7e 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -155,13 +155,34 @@ current_position.set(dest); #endif } + float axis_value(const AxisEnum axis) { + return NATIVE_TO_LOGICAL(processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], offset), axis); + } + bool apply_diff(const AxisEnum axis, const_float_t diff, const_float_t min, const_float_t max) { + #if IS_KINEMATIC + float &valref = offset; + const float rmin = min - current_position[axis], rmax = max - current_position[axis]; + #else + float &valref = current_position[axis]; + const float rmin = min, rmax = max; + #endif + valref += diff; + const float pre = valref; + if (min != max) { + if (diff < 0) + NOLESS(valref, rmin); + else + NOMORE(valref, rmax); + } + return pre != valref; + } #if IS_KINEMATIC static bool processing; #else static bool constexpr processing = false; #endif static void task(); - static void soon(AxisEnum axis + static void soon(const AxisEnum axis #if MULTI_MANUAL , const int8_t eindex=-1 #endif diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index fea4fa25a9..6bf6df1897 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -73,29 +73,13 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) { // Get the new position const float diff = float(int32_t(ui.encoderPosition)) * ui.manual_move.menu_scale; - #if IS_KINEMATIC - ui.manual_move.offset += diff; - if (int32_t(ui.encoderPosition) < 0) - NOLESS(ui.manual_move.offset, min - current_position[axis]); - else - NOMORE(ui.manual_move.offset, max - current_position[axis]); - #else - current_position[axis] += diff; - if (int32_t(ui.encoderPosition) < 0) - NOLESS(current_position[axis], min); - else - NOMORE(current_position[axis], max); - #endif - + (void)ui.manual_move.apply_diff(axis, diff, min, max); ui.manual_move.soon(axis); ui.refresh(LCDVIEW_REDRAW_NOW); } ui.encoderPosition = 0; if (ui.should_draw()) { - const float pos = NATIVE_TO_LOGICAL( - ui.manual_move.processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], ui.manual_move.offset), - axis - ); + const float pos = ui.manual_move.axis_value(axis); if (parser.using_inch_units()) { const float imp_pos = LINEAR_UNIT(pos); MenuEditItemBase::draw_edit_screen(name, ftostr63(imp_pos)); diff --git a/Marlin/src/lcd/tft/bitmaps/btn_42x39_rounded.bmp b/Marlin/src/lcd/tft/bitmaps/btn_42x39_rounded.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a89c7964e9fc9c6b17cc36055cd899c834b3ddf8 GIT binary patch literal 5046 zcmZ?r-6qTc24)Nl3>pj!3|b5f4C)LF42%pCVDScF1_o6z2nGuXw$|6zH#9WV z*4CDnmlqZmW@Tk%WMrh%24rSt=H%oQ7Z+DmRkgOZg6*%XtE;ZAE-WleN=gb34-W_k z@bU5S_V)InHt_cL_Vx7*3JQvfiptE)tf{Gi*d9#9v2r^U0wa~;luwl2G5>7tE;PXb8~ZYataR* z2m3!WGjq$9E&u=jzkU1mu3fu!?AWn;_wHT0cI~Dr*tKid;lqcYJbCi}|NqUKH(Od- z`uX`WFf=wcwzs$c|Nnpa^5x;-;pyq=#l^*?rKM%m2BoE?6%`fr_4S7i9s2+Oe|mbl ztE(#mLseDP)vH&pU%zf`Z5KZUte2WTUJ)~^y$-M$Bx<9*f20uR8%~E z{P@U`BW7l1v9Yn`<>ifyjWlxs$l&7Q;_KJ1U%h(O%E}6C|D#8b=x_g(D_2nMH#aw@ zr~gOo9}Rz$^go*ZM)MyX%iq!RXSDnoEq{>OAEV{(X!$$vCOG-*WZFE}V!oos`{npmj3=EZ(m5(1kK6>=1si|pjaBx;uR%K;nO-)U8b#)E3 zK{Xg;WMo{rbm_{KD`5Mps;chazkmMxd0SgsS6A2I;NbZ9_>`2C)YQ}zYJ=3&)TE>& ze}DfA7cQJXe;(ZbtE;QqxpU{gfB$lFa;&VZTwGkdyu4^J_~7H?JM*^))p$RaI3>mMqz}ZQGtb zd#F0_05xpSo;_Q(Y?(WEZb3moX=!O~Z7pp42{QgwUteEURaIVIPVIpQgn8xV<&~9{ Pb#-+O4Gs16^. + * + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if HAS_GRAPHICAL_TFT + +extern const uint8_t btn_rounded_42x39x4[819] = { + 0x87, 0x87, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x78, 0x78, + 0x87, 0x77, 0xab, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xb9, 0x77, 0x78, + 0x87, 0x8e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd7, 0x68, + 0x87, 0xff, 0x84, 0x32, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x37, 0xff, 0x57, + 0x7b, 0xf6, 0x34, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x43, 0x6f, 0x95, + 0x7d, 0xc3, 0x45, 0x56, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x4d, 0xc4, + 0x7e, 0xc3, 0x56, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x6d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7e, 0xc3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x7d, 0xd3, + 0x7d, 0xd3, 0x57, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x77, 0x7e, 0xc3, + 0x88, 0xfa, 0x56, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0xcf, 0x64, + 0x86, 0xbf, 0xdb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xce, 0xfb, 0x34, + 0x87, 0x57, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x74, 0x45, + 0x87, 0x75, 0x33, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x33, 0x34, 0x56, + 0x87, 0x77, 0x65, 0x54, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x55, 0x67, + 0x87, 0x87, 0x77, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x67, 0x78 +}; + +#endif // HAS_GRAPHICAL_TFT diff --git a/Marlin/src/lcd/tft/tft_image.cpp b/Marlin/src/lcd/tft/tft_image.cpp index f3480705e1..3651899dd7 100644 --- a/Marlin/src/lcd/tft/tft_image.cpp +++ b/Marlin/src/lcd/tft/tft_image.cpp @@ -53,6 +53,7 @@ const tImage Fan_Fast1_64x64x4 = { (void *)fan_fast1_64x64x4, 64, 64, GREYS const tImage SD_64x64x4 = { (void *)sd_64x64x4, 64, 64, GREYSCALE4 }; const tImage Home_64x64x4 = { (void *)home_64x64x4, 64, 64, GREYSCALE4 }; const tImage BtnRounded_64x52x4 = { (void *)btn_rounded_64x52x4, 64, 52, GREYSCALE4 }; +const tImage BtnRounded_42x39x4 = { (void *)btn_rounded_42x39x4, 42, 39, GREYSCALE4 }; const tImage Menu_64x64x4 = { (void *)menu_64x64x4, 64, 64, GREYSCALE4 }; const tImage Settings_64x64x4 = { (void *)settings_64x64x4, 64, 64, GREYSCALE4 }; const tImage Confirm_64x64x4 = { (void *)confirm_64x64x4, 64, 64, GREYSCALE4 }; @@ -106,6 +107,7 @@ const tImage Images[imgCount] = { Slider8x16x4, Home_64x64x4, BtnRounded_64x52x4, + BtnRounded_42x39x4, }; #endif // HAS_GRAPHICAL_TFT diff --git a/Marlin/src/lcd/tft/tft_image.h b/Marlin/src/lcd/tft/tft_image.h index 960a4e4356..de046fb0c4 100644 --- a/Marlin/src/lcd/tft/tft_image.h +++ b/Marlin/src/lcd/tft/tft_image.h @@ -42,6 +42,7 @@ extern const uint8_t fan_fast0_64x64x4[], fan_fast1_64x64x4[]; extern const uint8_t sd_64x64x4[]; extern const uint8_t home_64x64x4[]; extern const uint8_t btn_rounded_64x52x4[]; +extern const uint8_t btn_rounded_42x39x4[]; extern const uint8_t menu_64x64x4[]; extern const uint8_t settings_64x64x4[]; extern const uint8_t confirm_64x64x4[]; @@ -95,6 +96,7 @@ enum MarlinImage : uint8_t { imgSlider, imgHome, imgBtn52Rounded, + imgBtn39Rounded, imgCount, noImage = imgCount, imgPageUp = imgLeft, @@ -145,6 +147,7 @@ extern const tImage Fan_Fast1_64x64x4; extern const tImage SD_64x64x4; extern const tImage Home_64x64x4; extern const tImage BtnRounded_64x52x4; +extern const tImage BtnRounded_42x39x4; extern const tImage Menu_64x64x4; extern const tImage Settings_64x64x4; extern const tImage Confirm_64x64x4; diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index e4cc116818..c9c0aae05a 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -165,6 +165,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { image = targetTemperature > 0 ? imgChamberHeated : imgChamber; } #endif + #if HAS_TEMP_COOLER + else if (Heater == H_COOLER) { + if (currentTemperature <= 26) Color = COLOR_COLD; + if (currentTemperature > 26) Color = COLOR_RED; + image = targetTemperature > 26 ? imgCoolerHot : imgCooler; + } + #endif tft.add_image(8, 28, image, Color); @@ -229,6 +236,9 @@ void MarlinUI::draw_status_screen() { #ifdef ITEM_CHAMBER case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break; #endif + #ifdef ITEM_COOLER + case ITEM_COOLER: draw_heater_status(x, y, H_COOLER); break; + #endif #ifdef ITEM_FAN case ITEM_FAN: draw_fan_status(x, y, blink); break; #endif @@ -551,7 +561,6 @@ struct MotionAxisState { float currentStepSize = 10.0; int z_selection = Z_SELECTION_Z; uint8_t e_selection = 0; - bool homming = false; bool blocked = false; char message[32]; }; @@ -616,16 +625,11 @@ static void drawMessage(const char *msg) { tft.add_text(0, 0, COLOR_YELLOW, msg); } -static void drawAxisValue(AxisEnum axis) { - const float value = - #if HAS_BED_PROBE - axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? - probe.offset.z : - #endif - NATIVE_TO_LOGICAL( - ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset), - axis - ); +static void drawAxisValue(const AxisEnum axis) { + const float value = ( + TERN_(HAS_BED_PROBE, axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? probe.offset.z :) + ui.manual_move.axis_value(axis) + ); xy_int_t pos; uint16_t color; switch (axis) { @@ -641,7 +645,7 @@ static void drawAxisValue(AxisEnum axis) { tft.add_text(0, 0, color, tft_string); } -static void moveAxis(AxisEnum axis, const int8_t direction) { +static void moveAxis(const AxisEnum axis, const int8_t direction) { quick_feedback(); if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { @@ -707,23 +711,11 @@ static void moveAxis(AxisEnum axis, const int8_t direction) { #endif // Get the new position + const bool limited = ui.manual_move.apply_diff(axis, diff, min, max); #if IS_KINEMATIC - ui.manual_move.offset += diff; - if (direction < 0) - NOLESS(ui.manual_move.offset, min - current_position[axis]); - else - NOMORE(ui.manual_move.offset, max - current_position[axis]); + UNUSED(limited); #else - current_position[axis] += diff; - const char *msg = NUL_STR; // clear the error - if (direction < 0 && current_position[axis] < min) { - current_position[axis] = min; - msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS); - } - else if (direction > 0 && current_position[axis] > max) { - current_position[axis] = max; - msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS); - } + PGM_P const msg = limited ? GET_TEXT(MSG_LCD_SOFT_ENDSTOPS) : NUL_STR; drawMessage(msg); #endif @@ -921,7 +913,4 @@ void MarlinUI::move_axis_screen() { TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); } -#undef BTN_WIDTH -#undef BTN_HEIGHT - #endif // HAS_UI_480x320 diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index 8e7365932b..31665fdc33 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -241,6 +241,9 @@ void MarlinUI::draw_status_screen() { #ifdef ITEM_CHAMBER case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break; #endif + #ifdef ITEM_COOLER + case ITEM_COOLER: draw_heater_status(x, y, H_COOLER); break; + #endif #ifdef ITEM_FAN case ITEM_FAN: draw_fan_status(x, y, blink); break; #endif @@ -278,6 +281,7 @@ void MarlinUI::draw_status_screen() { offset -= tft_string.width(); } tft.add_text(301 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string); + TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 0, 103, 312, 24)); // feed rate tft.canvas(70, 136, 80, 32); @@ -354,16 +358,16 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const val menu_line(line - 1); tft_string.set(X_LBL); - tft.add_text(52, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); + tft.add_text(TFT_WIDTH / 2 - 120, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.x))); tft_string.trim(); - tft.add_text(144 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + tft.add_text(TFT_WIDTH / 2 - 16 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); tft_string.set(Y_LBL); - tft.add_text(176, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); + tft.add_text(TFT_WIDTH / 2 + 16, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.y))); tft_string.trim(); - tft.add_text(268 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); + tft.add_text(TFT_WIDTH / 2 + 120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); } #endif @@ -393,9 +397,9 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const val void TFT::draw_edit_screen_buttons() { #if ENABLED(TOUCH_SCREEN) - add_control(32, 176, DECREASE, imgDecrease); - add_control(224, 176, INCREASE, imgIncrease); - add_control(128, 176, CLICK, imgConfirm); + add_control(32, TFT_HEIGHT - 64, DECREASE, imgDecrease); + add_control(224, TFT_HEIGHT - 64, INCREASE, imgIncrease); + add_control(128, TFT_HEIGHT - 64, CLICK, imgConfirm); #endif } @@ -424,8 +428,8 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); } #if ENABLED(TOUCH_SCREEN) - add_control(48, 176, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); - add_control(208, 176, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); + add_control(48, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); + add_control(208, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); #endif } @@ -435,7 +439,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const #if ENABLED(TOUCH_SCREEN) touch.clear(); draw_menu_navigation = false; - touch.add_control(RESUME_CONTINUE , 0, 0, 320, 240); + touch.add_control(RESUME_CONTINUE , 0, 0, TFT_WIDTH, TFT_HEIGHT); #endif menu_line(row); @@ -477,7 +481,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, lpos = pos.asLogical(); - tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - 32) / 2 - 32, 96, 32); + tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 96, MENU_ITEM_HEIGHT); tft.set_background(COLOR_BACKGROUND); tft_string.set(X_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); @@ -485,7 +489,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft_string.trim(); tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); - tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - 32) / 2, 96, 32); + tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, 96, MENU_ITEM_HEIGHT); tft.set_background(COLOR_BACKGROUND); tft_string.set(Y_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); @@ -493,7 +497,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft_string.trim(); tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); - tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - 32) / 2 + 32, 96, 32); + tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 + MENU_ITEM_HEIGHT, 96, MENU_ITEM_HEIGHT); tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); @@ -502,13 +506,13 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); constexpr uint8_t w = (TFT_WIDTH) / 10; - tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - w) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 1, w, 32); + tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - w) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 1, w, MENU_ITEM_HEIGHT); tft.set_background(COLOR_BACKGROUND); tft_string.set(ui8tostr3rj(x_plot)); tft_string.trim(); tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); - tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + (GRID_HEIGHT - 27) / 2, w, 32); + tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + (GRID_HEIGHT - 27) / 2, w, MENU_ITEM_HEIGHT); tft.set_background(COLOR_BACKGROUND); tft_string.set(ui8tostr3rj(y_plot)); tft_string.trim(); @@ -527,7 +531,376 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const } #endif // AUTO_BED_LEVELING_UBL +#if ENABLED(BABYSTEP_ZPROBE_OFFSET) + #include "../../feature/babystep.h" +#endif + +#if HAS_BED_PROBE + #include "../../module/probe.h" +#endif + +#define Z_SELECTION_Z 1 +#define Z_SELECTION_Z_PROBE -1 + +struct MotionAxisState { + xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos; + float currentStepSize = 10.0; + int z_selection = Z_SELECTION_Z; + uint8_t e_selection = 0; + bool blocked = false; + char message[32]; +}; + +MotionAxisState motionAxisState; + +#define E_BTN_COLOR COLOR_YELLOW +#define X_BTN_COLOR COLOR_CORAL_RED +#define Y_BTN_COLOR COLOR_VIVID_GREEN +#define Z_BTN_COLOR COLOR_LIGHT_BLUE + +#define BTN_WIDTH 48 +#define BTN_HEIGHT 39 +#define X_MARGIN 15 +#define Y_MARGIN 11 + +static void quick_feedback() { + #if HAS_CHIRP + ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? + #if BOTH(HAS_LCD_MENU, USE_BEEPER) + for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } + #elif HAS_LCD_MENU + delay(10); + #endif + #endif +} + +#define CUR_STEP_VALUE_WIDTH 38 +static void drawCurStepValue() { + tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize)); + tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, 20); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(CUR_STEP_VALUE_WIDTH - tft_string.width(), 0, COLOR_AXIS_HOMED, tft_string); + tft.queue.sync(); + tft_string.set("mm"); + tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y + 20, CUR_STEP_VALUE_WIDTH, 20); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(CUR_STEP_VALUE_WIDTH - tft_string.width(), 0, COLOR_AXIS_HOMED, tft_string); +} + +static void drawCurZSelection() { + tft_string.set("Z"); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 20); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + tft.queue.sync(); + tft_string.set("Offset"); + tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 20); + tft.set_background(COLOR_BACKGROUND); + if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + tft.add_text(0, 0, Z_BTN_COLOR, tft_string); + } +} + +static void drawCurESelection() { + tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT); + tft.set_background(COLOR_BACKGROUND); + tft_string.set("E"); + tft.add_text(0, 0, E_BTN_COLOR , tft_string); + tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); +} + +static void drawMessage(const char *msg) { + tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 29, (TFT_WIDTH / 2) - (BTN_WIDTH / 2) - X_MARGIN, 20); + tft.set_background(COLOR_BACKGROUND); + tft.add_text(0, 0, COLOR_YELLOW, msg); +} + +static void drawAxisValue(const AxisEnum axis) { + const float value = ( + TERN_(HAS_BED_PROBE, axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? probe.offset.z :) + ui.manual_move.axis_value(axis) + ); + xy_int_t pos; + uint16_t color; + switch (axis) { + case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break; + case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break; + case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break; + case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break; + default: return; + } + tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, 20); + tft.set_background(COLOR_BACKGROUND); + tft_string.set(ftostr52sp(value)); + tft.add_text(0, 0, color, tft_string); +} + +static void moveAxis(const AxisEnum axis, const int8_t direction) { + quick_feedback(); + + if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { + drawMessage("Too cold"); + return; + } + + const float diff = motionAxisState.currentStepSize * direction; + + if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) { + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) + const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; + const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; + const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment, + new_probe_offset = probe.offset.z + bsDiff, + new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET + , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff + , new_probe_offset + ); + if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + babystep.add_steps(Z_AXIS, babystep_increment); + if (do_probe) + probe.offset.z = new_offs; + else + TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); + drawMessage(""); // clear the error + drawAxisValue(axis); + } + else { + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + #elif HAS_BED_PROBE + // only change probe.offset.z + probe.offset.z += diff; + if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { + current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; + drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + } + else { + drawMessage(""); // clear the error + } + drawAxisValue(axis); + #endif + return; + } + + if (!ui.manual_move.processing) { + // Get motion limit from software endstops, if any + float min, max; + soft_endstop.get_manual_axis_limits(axis, min, max); + + // Delta limits XY based on the current offset from center + // This assumes the center is 0,0 + #if ENABLED(DELTA) + if (axis != Z_AXIS && axis != E_AXIS) { + max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis + min = -max; + } + #endif + + // Get the new position + const bool limited = ui.manual_move.apply_diff(axis, diff, min, max); + #if IS_KINEMATIC + UNUSED(limited); + #else + PGM_P const msg = limited ? GET_TEXT(MSG_LCD_SOFT_ENDSTOPS) : NUL_STR; + drawMessage(msg); + #endif + + ui.manual_move.soon(axis + #if MULTI_MANUAL + , motionAxisState.e_selection + #endif + ); + } + + drawAxisValue(axis); +} + +static void e_plus() { moveAxis(E_AXIS, 1); } +static void e_minus() { moveAxis(E_AXIS, -1); } +static void x_minus() { moveAxis(X_AXIS, -1); } +static void x_plus() { moveAxis(X_AXIS, 1); } +static void y_plus() { moveAxis(Y_AXIS, 1); } +static void y_minus() { moveAxis(Y_AXIS, -1); } +static void z_plus() { moveAxis(Z_AXIS, 1); } +static void z_minus() { moveAxis(Z_AXIS, -1); } + +#if ENABLED(TOUCH_SCREEN) + static void e_select() { + motionAxisState.e_selection++; + if (motionAxisState.e_selection >= EXTRUDERS) { + motionAxisState.e_selection = 0; + } + + quick_feedback(); + drawCurESelection(); + drawAxisValue(E_AXIS); + } + + static void do_home() { + quick_feedback(); + drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING)); + queue.inject_P(G28_STR); + // Disable touch until home is done + TERN_(HAS_TFT_XPT2046, touch.disable()); + drawAxisValue(E_AXIS); + drawAxisValue(X_AXIS); + drawAxisValue(Y_AXIS); + drawAxisValue(Z_AXIS); + } + + static void step_size() { + motionAxisState.currentStepSize = motionAxisState.currentStepSize / 10.0; + if (motionAxisState.currentStepSize < 0.0015) motionAxisState.currentStepSize = 10.0; + quick_feedback(); + drawCurStepValue(); + } +#endif + +#if HAS_BED_PROBE + static void z_select() { + motionAxisState.z_selection *= -1; + quick_feedback(); + drawCurZSelection(); + drawAxisValue(Z_AXIS); + } +#endif + +static void disable_steppers() { + quick_feedback(); + queue.inject_P(PSTR("M84")); +} + +static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) { + uint16_t width = Images[imgBtn39Rounded].width; + uint16_t height = Images[imgBtn39Rounded].height; + + if (!enabled) bgColor = COLOR_CONTROL_DISABLED; + + tft.canvas(x, y, width, height); + tft.set_background(COLOR_BACKGROUND); + tft.add_image(0, 0, imgBtn39Rounded, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); + + // TODO: Make an add_text() taking a font arg + if (label) { + tft_string.set(label); + tft_string.trim(); + tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string); + } + else { + tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY); + } + + TERN_(HAS_TFT_XPT2046, if (enabled) touch.add_control(BUTTON, x, y, width, height, data)); +} void MarlinUI::move_axis_screen() { + // Reset + defer_status_screen(true); + motionAxisState.blocked = false; + TERN_(HAS_TFT_XPT2046, touch.enable()); + + ui.clear_lcd(); + + TERN_(TOUCH_SCREEN, touch.clear()); + + const bool busy = printingIsActive(); + + // Babysteps during printing? Select babystep for Z probe offset + if (busy && ENABLED(BABYSTEP_ZPROBE_OFFSET)) + motionAxisState.z_selection = Z_SELECTION_Z_PROBE; + + // ROW 1 -> E- Y- CurY Z+ + int x = X_MARGIN, y = Y_MARGIN, spacing = 0; + + drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy); + + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + x += BTN_WIDTH + spacing; + uint16_t yplus_x = x; + drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy); + + // Cur Y + x += BTN_WIDTH; + motionAxisState.yValuePos.x = x + 2; + motionAxisState.yValuePos.y = y; + drawAxisValue(Y_AXIS); + + x += spacing; + drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + + // ROW 2 -> "Ex" X- HOME X+ "Z" + y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; + x = X_MARGIN; + spacing = (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; + + motionAxisState.eNamePos.x = x; + motionAxisState.eNamePos.y = y; + drawCurESelection(); + TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select)); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; //imgHome is 64x64 + TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy)); + + x += BTN_WIDTH + spacing; + uint16_t xplus_x = x; + drawBtn(x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + motionAxisState.zTypePos.x = x; + motionAxisState.zTypePos.y = y; + drawCurZSelection(); + #if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) + if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select); + #endif + + // ROW 3 -> E- CurX Y- Z- + y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3; + x = X_MARGIN; + spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2; + + drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy); + + // Cur E + motionAxisState.eValuePos.x = x; + motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(E_AXIS); + + // Cur X + motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos + motionAxisState.xValuePos.y = y - 10; + drawAxisValue(X_AXIS); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy); + + x += BTN_WIDTH + spacing; + drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step + + // Cur Z + motionAxisState.zValuePos.x = x; + motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2; + drawAxisValue(Z_AXIS); + + // ROW 4 -> step_size disable steppers back + y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; // + x = xplus_x - CUR_STEP_VALUE_WIDTH - 10; + motionAxisState.stepValuePos.x = yplus_x + BTN_WIDTH - CUR_STEP_VALUE_WIDTH; + motionAxisState.stepValuePos.y = TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT; + if (!busy) { + drawCurStepValue(); + TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size)); + } + + // aligned with x+ + drawBtn(xplus_x, y, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy); + + TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); } #endif // HAS_UI_320x240 diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index e9ea4b0827..a5539990d5 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -170,6 +170,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { image = targetTemperature > 0 ? imgChamberHeated : imgChamber; } #endif + #if HAS_TEMP_COOLER + else if (Heater == H_COOLER) { + if (currentTemperature <= 26) Color = COLOR_COLD; + if (currentTemperature > 26) Color = COLOR_RED; + image = targetTemperature > 26 ? imgCoolerHot : imgCooler; + } + #endif tft.add_image(8, 28, image, Color); @@ -234,6 +241,9 @@ void MarlinUI::draw_status_screen() { #ifdef ITEM_CHAMBER case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break; #endif + #ifdef ITEM_COOLER + case ITEM_COOLER: draw_heater_status(x, y, H_COOLER); break; + #endif #ifdef ITEM_FAN case ITEM_FAN: draw_fan_status(x, y, blink); break; #endif @@ -543,7 +553,6 @@ struct MotionAxisState { float currentStepSize = 10.0; int z_selection = Z_SELECTION_Z; uint8_t e_selection = 0; - bool homming = false; bool blocked = false; char message[32]; }; @@ -608,16 +617,11 @@ static void drawMessage(const char *msg) { tft.add_text(0, 0, COLOR_YELLOW, msg); } -static void drawAxisValue(AxisEnum axis) { - const float value = - #if HAS_BED_PROBE - axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? - probe.offset.z : - #endif - NATIVE_TO_LOGICAL( - ui.manual_move.processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], ui.manual_move.offset), - axis - ); +static void drawAxisValue(const AxisEnum axis) { + const float value = ( + TERN_(HAS_BED_PROBE, axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ? probe.offset.z :) + ui.manual_move.axis_value(axis) + ); xy_int_t pos; uint16_t color; switch (axis) { @@ -633,7 +637,7 @@ static void drawAxisValue(AxisEnum axis) { tft.add_text(0, 0, color, tft_string); } -static void moveAxis(AxisEnum axis, const int8_t direction) { +static void moveAxis(const AxisEnum axis, const int8_t direction) { quick_feedback(); if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { @@ -699,23 +703,11 @@ static void moveAxis(AxisEnum axis, const int8_t direction) { #endif // Get the new position + const bool limited = ui.manual_move.apply_diff(axis, diff, min, max); #if IS_KINEMATIC - ui.manual_move.offset += diff; - if (direction < 0) - NOLESS(ui.manual_move.offset, min - current_position[axis]); - else - NOMORE(ui.manual_move.offset, max - current_position[axis]); + UNUSED(limited); #else - current_position[axis] += diff; - const char *msg = NUL_STR; // clear the error - if (direction < 0 && current_position[axis] < min) { - current_position[axis] = min; - msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS); - } - else if (direction > 0 && current_position[axis] > max) { - current_position[axis] = max; - msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS); - } + PGM_P const msg = limited ? GET_TEXT(MSG_LCD_SOFT_ENDSTOPS) : NUL_STR; drawMessage(msg); #endif @@ -913,7 +905,4 @@ void MarlinUI::move_axis_screen() { TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack)); } -#undef BTN_WIDTH -#undef BTN_HEIGHT - #endif // HAS_UI_480x320 From 082fce5e3e68c7b8657201e5de5adba0e4f86a33 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 29 Apr 2021 00:34:04 +0000 Subject: [PATCH 311/311] [cron] Bump distribution date (2021-04-29) --- 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 e3bfb9dd72..266ed629a8 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-04-28" + #define STRING_DISTRIBUTION_DATE "2021-04-29" #endif /**