From c508c2213ee5b0ed130238c058b7cc91beaea654 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Apr 2021 14:07:30 -0500 Subject: [PATCH 001/109] 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 002/109] 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 003/109] 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 004/109] 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 005/109] 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 006/109] [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 007/109] 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 008/109] 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 009/109] 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 010/109] 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 011/109] [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 012/109] 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 013/109] 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 014/109] 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 015/109] 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 016/109] 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 017/109] [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 018/109] 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 019/109] [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 020/109] 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 021/109] 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 022/109] [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 023/109] 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 024/109] 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 025/109] 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 026/109] 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 027/109] 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 028/109] [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 029/109] 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 030/109] 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 031/109] 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 032/109] 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 033/109] 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 034/109] 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 035/109] 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 036/109] 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 037/109] 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 038/109] 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 039/109] 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 040/109] 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 041/109] 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 042/109] 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 043/109] 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 044/109] 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 045/109] 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 046/109] 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 047/109] 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 048/109] 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 049/109] [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 050/109] 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 051/109] 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 052/109] 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 053/109] [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 054/109] 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 055/109] 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 056/109] 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 057/109] 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 058/109] 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 059/109] 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 060/109] 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 061/109] [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 062/109] 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 063/109] 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 064/109] 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 065/109] 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 066/109] 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 067/109] 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 068/109] 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 069/109] [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 070/109] 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 zcmeI0-AZCn6vy{G!@w{vFw8KJMyR1_fs_}e6?I`BXkf`$2pZ;;AF0vTOVnM^10+)F zl~%V#q+SGyANdA#>CBHK%}mVgId*dv?1gM${r6gD?Zy88t&Yq`A(;XHjrE=NmGwb< z#tV_+|1Y0$y6$}ySux+y}h})xv{a~^Z9-#W9#ede!o8y3Pqz)pe6i7 zA`y$lK=yb%PN#ErcGhmUPfbnXPxyLZ8Di8{ARP+fBc7shqw5{!^8c|U&UAJ|EB-d{!{N? zALp++f7JP-&YyqYAL{&7=kNQ^UmoXucz;(amH*~H@BiiH<*ltPMIZkJhiLckVLU=a zA`$q<&CQKoub-cvhy1exGlq`hhSS%1SjguZ7?ZU<(B;(`blarH5h!02^L?+AC)m8ZC$;pYt zzYh)$C^8!_FE0>bm^mte68giyz`)qp81;XCeg>5FFtHqXj_3U-hS+{)OiV@Nc<=hrjU% O&gG)xxP`z;_`d;x*W7Uc literal 0 HcmV?d00001 diff --git a/Marlin/src/lcd/tft/images/btn_rounded_42x39x4.cpp b/Marlin/src/lcd/tft/images/btn_rounded_42x39x4.cpp new file mode 100644 index 0000000000..cd07258dbf --- /dev/null +++ b/Marlin/src/lcd/tft/images/btn_rounded_42x39x4.cpp @@ -0,0 +1,69 @@ +/** + * 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 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 071/109] [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 /** From b5fac1ac9587a495188660c23946b298d065ea6d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 30 Apr 2021 00:24:56 +0000 Subject: [PATCH 072/109] [cron] Bump distribution date (2021-04-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 266ed629a8..11e9cb1456 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-29" + #define STRING_DISTRIBUTION_DATE "2021-04-30" #endif /** From 636facf40d668bee1cc4c866dab340d1d35d73c4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 28 Apr 2021 02:04:07 -0500 Subject: [PATCH 073/109] Silence warning in gcode_D --- Marlin/src/gcode/gcode_d.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 74277291e5..a8a6bdfc3d 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -216,7 +216,8 @@ } break; case 102: { // D102 Test SD Read - card.openFileRead("test.gco"); + char testfile[] = "test.gco"; + card.openFileRead(testfile); if (!card.isFileOpen()) { SERIAL_ECHOLNPAIR("Failed to open test.gco to read."); return; From cfdfd167794de13de75d99c161f61a0898549717 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 30 Apr 2021 08:51:26 +0200 Subject: [PATCH 074/109] Fix Thermal Runaway false-alarm in M303, add HeaterWatch::check (#21743) Co-authored-by: Scott Lahteine --- Marlin/src/module/temperature.cpp | 26 +++++++++++++------------- Marlin/src/module/temperature.h | 2 ++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 462af7f61a..69f5e9b58e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -543,7 +543,7 @@ 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 celsius_float_t watch_temp_target = celsius_float_t(target - 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); celsius_float_t next_watch_temp = 0.0; bool heated = false; @@ -1253,13 +1253,13 @@ void Temperature::manage_heater() { #if WATCH_HOTENDS // Make sure temperature is increasing - if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder? - if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough? + if (watch_hotend[e].elapsed(ms)) { // Enabled and time to check? + if (watch_hotend[e].check(degHotend(e))) // Increased enough? + start_watching_hotend(e); // If temp reached, turn off elapsed check + else { TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); } - else // Start again if the target is still far off - start_watching_hotend(e); } #endif @@ -1296,13 +1296,13 @@ void Temperature::manage_heater() { #if WATCH_BED // Make sure temperature is increasing - if (watch_bed.elapsed(ms)) { // Time to check the bed? - if (degBed() < watch_bed.target) { // Failed to increase enough? + if (watch_bed.elapsed(ms)) { // Time to check the bed? + if (watch_bed.check(degBed())) // Increased enough? + start_watching_bed(); // If temp reached, turn off elapsed check + else { TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); _temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); } - else // Start again if the target is still far off - start_watching_bed(); } #endif // WATCH_BED @@ -1377,11 +1377,11 @@ void Temperature::manage_heater() { #if WATCH_CHAMBER // Make sure temperature is increasing - if (watch_chamber.elapsed(ms)) { // Time to check the chamber? - if (degChamber() < watch_chamber.target) // Failed to increase enough? - _temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); + if (watch_chamber.elapsed(ms)) { // Time to check the chamber? + if (watch_chamber.check(degChamber())) // Increased enough? Error below. + start_watching_chamber(); // If temp reached, turn off elapsed check. else - start_watching_chamber(); // Start again if the target is still far off + _temp_error(H_CHAMBER, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 2bb773f805..adc10c3ccd 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -233,6 +233,8 @@ struct HeaterWatch { inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); } inline bool elapsed() { return elapsed(millis()); } + inline bool check(const celsius_t curr) { return curr >= target; } + inline void restart(const celsius_t curr, const celsius_t tgt) { if (tgt) { const celsius_t newtarget = curr + INCREASE; From f58b923fd4df7c59a14e91fcd5977feb50774b5b Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Fri, 30 Apr 2021 01:07:18 -0700 Subject: [PATCH 075/109] Fix BTT E3 RRF and SKR V2 (Generic PIO) (#21741) Follow-up to #21655 --- ini/stm32f4.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index d6418f439e..ff99296877 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -181,7 +181,7 @@ build_flags = ${stm_flash_drive.build_flags} [env:BIGTREE_E3_RRF] platform = ${common_stm32.platform} extends = common_stm32 -board = genericSTM32F407VGT6 +board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_BIGTREE_E3_RRF build_flags = ${common_stm32.build_flags} -DSTM32F407_5VX -DVECT_TAB_OFFSET=0x8000 @@ -234,7 +234,7 @@ extra_scripts = ${common.extra_scripts} platform = ${common_stm32.platform} platform_packages = ${stm_flash_drive.platform_packages} extends = common_stm32 -board = genericSTM32F407VGT6 +board = marlin_STM32F407VGT6_CCM board_build.core = stm32 board_build.variant = MARLIN_F4x7Vx board_build.ldscript = ldscript.ld From e4f60f82a4cbcac1921b6bf444fa803910e2adf3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 30 Apr 2021 03:21:59 -0500 Subject: [PATCH 076/109] Heater error status --- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 2 +- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 75ff1f52c2..2e5f967c2f 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -535,7 +535,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr if (prefix >= 0) lcd_put_wchar(prefix); - lcd_put_u8str(i16tostr3rj(t1)); + lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1)); lcd_put_wchar('/'); #if !HEATER_IDLE_HANDLER diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 81e89f7cf5..68b75900ef 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -186,10 +186,14 @@ #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) 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]); - lcd_put_wchar(LCD_STR_DEGREE[0]); + if (temp < 0) + lcd_put_u8str(tx - 3 * (INFO_FONT_WIDTH) / 2 + 1, ty, "err"); + else { + 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]); + lcd_put_wchar(LCD_STR_DEGREE[0]); + } } #if DO_DRAW_FLOWMETER From 4e4c3ef8fc68afb66ebc434764ba4079c57baf1c Mon Sep 17 00:00:00 2001 From: lujios <83166168+lujios@users.noreply.github.com> Date: Fri, 30 Apr 2021 11:38:30 +0200 Subject: [PATCH 077/109] Fix compile with DISTINCT_E_FACTORS + SLIM_LCD_MENUS (#21733) Co-authored-by: Scott Lahteine --- Marlin/src/lcd/menu/menu_advanced.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 463433685e..044797b749 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -350,16 +350,6 @@ void menu_backlash(); #if DISABLED(SLIM_LCD_MENUS) - #if ENABLED(DISTINCT_E_FACTORS) - inline void _reset_e_acceleration_rate(const uint8_t e) { if (e == active_extruder) planner.reset_acceleration_rates(); } - inline void _planner_refresh_e_positioning(const uint8_t e) { - if (e == active_extruder) - planner.refresh_positioning(); - else - planner.steps_to_mm[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)]; - } - #endif - // M203 / M205 Velocity options void menu_advanced_velocity() { // M203 Max Feedrate @@ -443,7 +433,10 @@ void menu_backlash(); #if ENABLED(DISTINCT_E_FACTORS) EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ _reset_e_acceleration_rate(MenuItemBase::itemIndex); }); + EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ + if (MenuItemBase::itemIndex == active_extruder) + planner.reset_acceleration_rates(); + }); #elif E_STEPPERS EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); #endif @@ -530,7 +523,13 @@ void menu_advanced_steps_per_mm() { #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ _planner_refresh_e_positioning(MenuItemBase::itemIndex); }); + EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ + const uint8_t e = MenuItemBase::itemIndex; + if (e == active_extruder) + planner.refresh_positioning(); + else + planner.steps_to_mm[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)]; + }); #elif E_STEPPERS EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); #endif From 68c010f82ad7a5c5c3dd15ee985654e0f3bc79b5 Mon Sep 17 00:00:00 2001 From: Nikolay March Date: Fri, 30 Apr 2021 12:45:43 +0300 Subject: [PATCH 078/109] Sanity-check for COREnn backlash (#21731) --- Marlin/src/inc/SanityCheck.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 97f9a6373a..24ea6ce808 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3034,8 +3034,10 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) "BACKLASH_COMPENSATION can only apply to " STRINGIFY(NORMAL_AXIS) " on a MarkForged system."); #elif IS_CORE constexpr float backlash_arr[] = BACKLASH_DISTANCE_MM; - static_assert(!backlash_arr[CORE_AXIS_1] && !backlash_arr[CORE_AXIS_2], + #ifndef CORE_BACKLASH + static_assert(!backlash_arr[CORE_AXIS_1] && !backlash_arr[CORE_AXIS_2], "BACKLASH_COMPENSATION can only apply to " STRINGIFY(NORMAL_AXIS) " with your CORE system."); + #endif #endif #endif From 2f537768bc9481a10b25d9f7c5af3627707c836e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 30 Apr 2021 08:30:31 -0500 Subject: [PATCH 079/109] MKS Robin flash address --- buildroot/share/PlatformIO/scripts/mks_robin_mini.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py index 4c52035965..3ff9ccf4a6 100644 --- a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py +++ b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py @@ -2,4 +2,4 @@ # buildroot/share/PlatformIO/scripts/mks_robin_mini.py # import marlin -marlin.prepare_robin("0x08005000", "mks_robin_mini.ld", "Robin_mini.bin") +marlin.prepare_robin("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin") From ff41bf5be823bd9564045c1c522adec2f9984ac7 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 1 May 2021 01:04:09 +0000 Subject: [PATCH 080/109] [cron] Bump distribution date (2021-05-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 11e9cb1456..74fde2f7ac 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-30" + #define STRING_DISTRIBUTION_DATE "2021-05-01" #endif /** From 8c912d7ece490e9b0598d365248d07d6bfd204ae Mon Sep 17 00:00:00 2001 From: ellensp Date: Sat, 1 May 2021 16:15:16 +1200 Subject: [PATCH 081/109] Fix SDCARD_CONNECTION default for BTT SKR (#21755) --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h | 82 +++++++++++-------- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 12 --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 18 ---- Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h | 16 ++++ 4 files changed, 66 insertions(+), 62 deletions(-) diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h index 8c1396d3fe..05072b6c9e 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h @@ -52,6 +52,37 @@ #define E0_DIR_PIN P2_13 #define E0_ENABLE_PIN P2_12 + +/** + * _____ _____ + * NC | 1 2 | GND 5V | 1 2 | GND + * RESET | 3 4 | 1.31 NC | 3 4 | NC + * 0.18 | 5 6 3.25 NC | 5 6 0.15 + * 1.23 | 7 8 | 3.26 0.16 | 7 8 | 0.18 + * 0.15 | 9 10| 0.17 2.11 | 9 10| 1.30 + * ----- ----- + * EXP2 EXP1 + */ + +#define EXP1_03_PIN -1 +#define EXP1_04_PIN -1 +#define EXP1_05_PIN -1 +#define EXP1_06_PIN P0_15 +#define EXP1_07_PIN P0_16 +#define EXP1_08_PIN P0_18 +#define EXP1_09_PIN P2_11 +#define EXP1_10_PIN P1_30 + +#define EXP2_03_PIN -1 +#define EXP2_04_PIN P1_31 +#define EXP2_05_PIN P0_18 +#define EXP2_06_PIN P3_25 +#define EXP2_07_PIN P1_23 +#define EXP2_08_PIN P3_26 +#define EXP2_09_PIN P0_15 +#define EXP2_10_PIN P0_17 + + /** * LCD / Controller * @@ -68,26 +99,23 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS P3_26 + #define TFTGLCD_CS EXP2_08_PIN #endif - #define SD_DETECT_PIN P1_31 - #elif HAS_WIRED_LCD - #define BTN_EN1 P3_26 - #define BTN_EN2 P3_25 - #define BTN_ENC P2_11 + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_09_PIN - #define SD_DETECT_PIN P1_31 - #define LCD_SDSS P1_23 - #define LCD_PINS_RS P0_16 - #define LCD_PINS_ENABLE P0_18 - #define LCD_PINS_D4 P0_15 + #define LCD_SDSS EXP2_07_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP2_05_PIN + #define LCD_PINS_D4 EXP2_09_PIN #if ENABLED(MKS_MINI_12864) #define DOGLCD_CS P2_06 - #define DOGLCD_A0 P0_16 + #define DOGLCD_A0 EXP1_07_PIN #endif #endif // HAS_WIRED_LCD @@ -106,10 +134,6 @@ #endif #endif -#if SD_CONNECTION_IS(LCD) - #define SD_SS_PIN P1_23 -#endif - // Trinamic driver support #if HAS_TRINAMIC_CONFIG @@ -140,10 +164,10 @@ // When using any TMC SPI-based drivers, software SPI is used // because pins may be shared with the display or SD card. #define TMC_USE_SW_SPI - #define TMC_SW_MOSI P0_18 - #define TMC_SW_MISO P0_17 + #define TMC_SW_MOSI EXP2_05_PIN + #define TMC_SW_MISO EXP2_10_PIN // To minimize pin usage use the same clock pin as the display/SD card reader. (May generate LCD noise.) - #define TMC_SW_SCK P0_15 + #define TMC_SW_SCK EXP2_09_PIN // If pin 2_06 is unused, it can be used for the clock to avoid the LCD noise. //#define TMC_SW_SCK P2_06 @@ -186,14 +210,11 @@ // SDCARD_CONNECTION must not be 'LCD'. Nothing should be connected to EXP1/EXP2. //#define SKR_USE_LCD_PINS_FOR_CS #if ENABLED(SKR_USE_LCD_PINS_FOR_CS) - #if SD_CONNECTION_IS(LCD) - #error "SDCARD_CONNECTION must not be 'LCD' with SKR_USE_LCD_PINS_FOR_CS." - #endif - #define X_CS_PIN P1_23 - #define Y_CS_PIN P3_26 - #define Z_CS_PIN P2_11 - #define E0_CS_PIN P3_25 - #define E1_CS_PIN P1_31 + #define X_CS_PIN EXP2_07_PIN + #define Y_CS_PIN EXP2_08_PIN + #define Z_CS_PIN EXP1_09_PIN + #define E0_CS_PIN EXP2_06_PIN + #define E1_CS_PIN EXP2_04_PIN #endif // Example 2: A REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER @@ -201,19 +222,16 @@ // the pins will be in use. So SDCARD_CONNECTION must not be 'LCD'. //#define SKR_USE_LCD_SD_CARD_PINS_FOR_CS #if ENABLED(SKR_USE_LCD_SD_CARD_PINS_FOR_CS) - #if SD_CONNECTION_IS(LCD) - #error "SDCARD_CONNECTION must not be 'LCD' with SKR_USE_LCD_SD_CARD_PINS_FOR_CS." - #endif #define X_CS_PIN P0_02 #define Y_CS_PIN P0_03 #define Z_CS_PIN P2_06 // We use SD_DETECT_PIN for E0 #undef SD_DETECT_PIN - #define E0_CS_PIN P1_31 + #define E0_CS_PIN EXP2_04_PIN // We use LCD_SDSS pin for E1 #undef LCD_SDSS #define LCD_SDSS -1 - #define E1_CS_PIN P1_23 + #define E1_CS_PIN EXP2_07_PIN #endif // Example 3: Use the driver enable pins for chip-select. diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index 89f0e17832..e671429f84 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -367,18 +367,6 @@ #endif // HAS_WIRED_LCD -// -// SD Support -// - -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION LCD -#endif - -#if SD_CONNECTION_IS(LCD) - #define SD_SS_PIN EXP2_07_PIN -#endif - /** * Special pins * P1_30 (37) (NOT 5V tolerant) 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 94165d3948..f3ecf30fc8 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -31,13 +31,6 @@ #define BOARD_CUSTOM_BUILD_FLAGS -DLPC_PINCFG_UART3_P4_28 #endif -// -// SD Connection -// -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION LCD -#endif - // // Servos // @@ -263,13 +256,6 @@ #define EXP2_09_PIN P0_15 #define EXP2_10_PIN P0_17 -// -// SD Connection -// -#if SD_CONNECTION_IS(LCD) - #define SD_SS_PIN EXP2_07_PIN -#endif - /** * _____ _____ * NC | · · | GND 5V | · · | GND @@ -443,10 +429,6 @@ #define LCD_SDSS EXP2_07_PIN // (16) J3-7 & AUX-4 - #if SD_CONNECTION_IS(LCD) - #define SD_DETECT_PIN EXP2_04_PIN // (49) (NOT 5V tolerant) - #endif - #if ENABLED(FYSETC_MINI_12864) #define DOGLCD_CS EXP1_08_PIN #define DOGLCD_A0 EXP1_07_PIN diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index 98e4f8ee26..eadb91a8b3 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -105,12 +105,28 @@ // // SD Support // +#ifndef SDCARD_CONNECTION + #if HAS_WIRED_LCD + #define SDCARD_CONNECTION LCD + #else + #define SDCARD_CONNECTION ONBOARD + #endif +#endif + + #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card +#if SD_CONNECTION_IS(LCD) && ENABLED(SKR_USE_LCD_SD_CARD_PINS_FOR_CS) + #error "SDCARD_CONNECTION must not be 'LCD' with SKR_USE_LCD_PINS_FOR_CS." +#endif + #if SD_CONNECTION_IS(LCD) #define SD_SCK_PIN P0_15 #define SD_MISO_PIN P0_17 #define SD_MOSI_PIN P0_18 + #define SD_SS_PIN EXP2_07_PIN + #define SD_DETECT_PIN EXP2_04_PIN + #elif SD_CONNECTION_IS(ONBOARD) #undef SD_DETECT_PIN #define SD_DETECT_PIN P0_27 From ef9ca61039514efef6e2bf100c4b6b1db8f0316c Mon Sep 17 00:00:00 2001 From: ellensp Date: Sat, 1 May 2021 20:21:18 +1200 Subject: [PATCH 082/109] Fix Singlenozzle Standby issues (#21759) Fixes #21758 Co-authored-by: Scott Lahteine --- Marlin/src/inc/Conditionals_LCD.h | 10 +++++++++ Marlin/src/lcd/menu/menu_temperature.cpp | 2 +- Marlin/src/lcd/menu/menu_tune.cpp | 2 +- Marlin/src/module/temperature.cpp | 26 +++++++++++++----------- Marlin/src/module/temperature.h | 8 +++++--- Marlin/src/module/tool_change.cpp | 4 +++- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 429877ce84..a6df825ad9 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -640,6 +640,16 @@ #endif #endif +/** + * Disable unused SINGLENOZZLE sub-options + */ +#if DISABLED(SINGLENOZZLE) + #undef SINGLENOZZLE_STANDBY_TEMP +#endif +#if !BOTH(HAS_FAN, SINGLENOZZLE) + #undef SINGLENOZZLE_STANDBY_FAN +#endif + /** * DISTINCT_E_FACTORS affects how some E factors are accessed */ diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 47643cfb57..33a3d2f445 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -171,7 +171,7 @@ void menu_temperature() { #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.hotend_max_target(0)); + EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0)); #endif // diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index feabae437d..1a972f63f2 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -134,7 +134,7 @@ void menu_tune() { #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.hotend_max_target(0)); + EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.hotend_max_target(0)); #endif // diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 69f5e9b58e..53d6c14d5b 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -466,9 +466,9 @@ volatile bool Temperature::raw_temps_ready = false; #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) celsius_t Temperature::singlenozzle_temp[EXTRUDERS]; - #if HAS_FAN - uint8_t Temperature::singlenozzle_fan_speed[EXTRUDERS]; - #endif +#endif +#if ENABLED(SINGLENOZZLE_STANDBY_FAN) + uint8_t Temperature::singlenozzle_fan_speed[EXTRUDERS]; #endif #if ENABLED(PROBING_HEATERS_OFF) @@ -2500,20 +2500,22 @@ void Temperature::disable_all_heaters() { #endif // PROBING_HEATERS_OFF -#if ENABLED(SINGLENOZZLE_STANDBY_TEMP) +#if EITHER(SINGLENOZZLE_STANDBY_TEMP, SINGLENOZZLE_STANDBY_FAN) void Temperature::singlenozzle_change(const uint8_t old_tool, const uint8_t new_tool) { - #if HAS_FAN + #if ENABLED(SINGLENOZZLE_STANDBY_FAN) singlenozzle_fan_speed[old_tool] = fan_speed[0]; fan_speed[0] = singlenozzle_fan_speed[new_tool]; #endif - singlenozzle_temp[old_tool] = temp_hotend[0].target; - 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_STATUS_MESSAGE, set_heating_message(0)); - (void)wait_for_hotend(0, false); // Wait for heating or cooling - } + #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) + singlenozzle_temp[old_tool] = temp_hotend[0].target; + 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_STATUS_MESSAGE, set_heating_message(0)); + (void)wait_for_hotend(0, false); // Wait for heating or cooling + } + #endif } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index adc10c3ccd..702a3ea04d 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -372,9 +372,11 @@ class Temperature { 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]; - #if HAS_FAN + #if EITHER(SINGLENOZZLE_STANDBY_TEMP, SINGLENOZZLE_STANDBY_FAN) + #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) + static celsius_t singlenozzle_temp[EXTRUDERS]; + #endif + #if ENABLED(SINGLENOZZLE_STANDBY_FAN) static uint8_t singlenozzle_fan_speed[EXTRUDERS]; #endif static void singlenozzle_change(const uint8_t old_tool, const uint8_t new_tool); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 2e5e59c0af..0c5673b31c 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1194,7 +1194,9 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { const bool should_move = safe_to_move && !no_move && IsRunning(); if (should_move) { - TERN_(SINGLENOZZLE_STANDBY_TEMP, thermalManager.singlenozzle_change(old_tool, new_tool)); + #if EITHER(SINGLENOZZLE_STANDBY_TEMP, SINGLENOZZLE_STANDBY_FAN) + thermalManager.singlenozzle_change(old_tool, new_tool); + #endif #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) if (should_swap && !too_cold) { From eddce4182b8e3579ae4e74e0f2954d51678ea023 Mon Sep 17 00:00:00 2001 From: hartmannathan <59230071+hartmannathan@users.noreply.github.com> Date: Sat, 1 May 2021 04:43:32 -0400 Subject: [PATCH 083/109] Comment correction (#21729) --- Marlin/src/libs/duration_t.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/libs/duration_t.h b/Marlin/src/libs/duration_t.h index bd654b7bad..148aa23211 100644 --- a/Marlin/src/libs/duration_t.h +++ b/Marlin/src/libs/duration_t.h @@ -115,7 +115,8 @@ struct duration_t { * @brief Formats the duration as a string * @details String will be formated using a "full" representation of duration * - * @param buffer The array pointed to must be able to accommodate 21 bytes + * @param buffer The array pointed to must be able to accommodate 22 bytes + * (21 for the string, 1 more for the terminating nul) * * Output examples: * 123456789012345678901 (strlen) From 05c25b8cdb99fd67047704f65d69e5b8b1797a07 Mon Sep 17 00:00:00 2001 From: tobuh <32395668+tobuh@users.noreply.github.com> Date: Sat, 1 May 2021 10:46:26 +0200 Subject: [PATCH 084/109] Fix Power-Loss Save on Pause (#21749) --- Marlin/src/gcode/feature/pause/M125.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index 9391b8661b..e65b48545b 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -78,8 +78,9 @@ void GcodeSuite::M125() { // If possible, show an LCD prompt with the 'P' flag const bool show_lcd = TERN0(HAS_LCD_MENU, parser.boolval('P')); + TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true)); + if (pause_print(retract, park_point, 0, show_lcd)) { - TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true)); if (ENABLED(EXTENSIBLE_UI) || !sd_printing || show_lcd) { wait_for_confirmation(false, 0); resume_print(0, 0, -retract, 0); From b356b4484948305db9fdd6b049b38ab29cfb7cfa Mon Sep 17 00:00:00 2001 From: Sebastiaan Dammann Date: Sun, 2 May 2021 02:38:31 +0200 Subject: [PATCH 085/109] Fix Z raise in filament load M701 (#21762) Fixes #21750 --- Marlin/src/gcode/feature/pause/M701_M702.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index 6be63346dc..0a649dadd4 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -97,7 +97,7 @@ void GcodeSuite::M701() { }; // Raise the Z axis (with max limit) - const float park_raise = _MIN(0, park_point.z, (Z_MAX_POS) - current_position.z); + const float park_raise = _MIN(park_point.z, (Z_MAX_POS) - current_position.z); move_z_by(park_raise); // Load filament From 9d43570adae1e6835504fc9f42b1fefada54dcb7 Mon Sep 17 00:00:00 2001 From: ellensp Date: Sun, 2 May 2021 12:42:38 +1200 Subject: [PATCH 086/109] Add missing ExtUI method (#21763) Fixes #21761 --- Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp index fb66d1f68e..9055e7b430 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp @@ -100,6 +100,10 @@ namespace ExtUI { void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated } + + void onMeshUpdate(const int8_t xpos, const int8_t ypos, probe_state_t state) { + // Called when any mesh points are updated + } #endif #if ENABLED(POWER_LOSS_RECOVERY) From 741e3c12803077e60bc4842b74a4bf2365e2b3db Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Sat, 1 May 2021 19:59:45 -0500 Subject: [PATCH 087/109] Laser Cutter Air Assist (#21753) --- Marlin/Configuration_adv.h | 14 +++++++++---- Marlin/src/feature/spindle_laser.cpp | 16 ++++++++++++++- Marlin/src/feature/spindle_laser.h | 9 ++++++++ Marlin/src/gcode/control/M10-M11.cpp | 3 --- Marlin/src/gcode/control/M7-M9.cpp | 24 ++++++++++++++++++++++ Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/menu/menu_spindle_laser.cpp | 5 +++++ buildroot/tests/mega2560 | 8 ++++---- 8 files changed, 68 insertions(+), 12 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 149ac610f5..7d89cf5205 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3166,13 +3166,19 @@ //#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 + //#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 + //#define AIR_ASSIST // Air Assist control with G-codes M8-M9 + #if ENABLED(AIR_ASSIST) + #define AIR_ASSIST_ACTIVE LOW // Active state on air assist pin + //#define AIR_ASSIST_PIN 44 // Override the default Air Assist 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 - #define SPINDLE_SERVO_MIN 10 // Minimum angle for servo spindle + #define SPINDLE_SERVO_NR 0 // Index of servo used for spindle control + #define SPINDLE_SERVO_MIN 10 // Minimum angle for servo spindle #endif /** diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 78fa75cac6..100b7c4b26 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -71,6 +71,9 @@ void SpindleLaser::init() { #if ENABLED(AIR_EVACUATION) OUT_WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); // Init Vacuum/Blower OFF #endif + #if ENABLED(AIR_ASSIST) + OUT_WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_ACTIVE); // Init Air Assist OFF + #endif } #if ENABLED(SPINDLE_LASER_PWM) @@ -147,6 +150,17 @@ void SpindleLaser::apply_power(const uint8_t opwr) { void SpindleLaser::air_evac_toggle() { TOGGLE(AIR_EVACUATION_PIN); } // Toggle state -#endif +#endif // AIR_EVACUATION + +#if ENABLED(AIR_ASSIST) + + // Enable / disable air assist + void SpindleLaser::air_assist_enable() { WRITE(AIR_ASSIST_PIN, AIR_ASSIST_PIN); } // Turn ON + + void SpindleLaser::air_assist_disable() { WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_PIN); } // Turn OFF + + void SpindleLaser::air_assist_toggle() { TOGGLE(AIR_ASSIST_PIN); } // Toggle state + +#endif // AIR_ASSIST #endif // HAS_CUTTER diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index c3454d0b3c..da228cf8a7 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -221,6 +221,15 @@ public: } #endif + #if ENABLED(AIR_ASSIST) + static void air_assist_enable(); // Turn on air assist + static void air_assist_disable(); // Turn off air assist + static void air_assist_toggle(); // Toggle air assist + static inline bool air_assist_state() { // Get current state + return (READ(AIR_ASSIST_PIN) == AIR_ASSIST_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 index 26f67e6cb6..d5a69dcfcc 100644 --- a/Marlin/src/gcode/control/M10-M11.cpp +++ b/Marlin/src/gcode/control/M10-M11.cpp @@ -25,14 +25,12 @@ #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 } @@ -40,7 +38,6 @@ void GcodeSuite::M10() { * 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 } diff --git a/Marlin/src/gcode/control/M7-M9.cpp b/Marlin/src/gcode/control/M7-M9.cpp index a33e43288b..f93123eb35 100644 --- a/Marlin/src/gcode/control/M7-M9.cpp +++ b/Marlin/src/gcode/control/M7-M9.cpp @@ -61,3 +61,27 @@ void GcodeSuite::M9() { } #endif // COOLANT_CONTROL + +#if ENABLED(AIR_ASSIST) + +#include "../gcode.h" +#include "../../module/planner.h" +#include "../../feature/spindle_laser.h" + +/** + * M8: Air Assist On + */ +void GcodeSuite::M8() { + planner.synchronize(); + cutter.air_assist_enable(); // Turn on Air Assist pin +} + +/** + * M9: Air Assist Off + */ +void GcodeSuite::M9() { + planner.synchronize(); + cutter.air_assist_disable(); // Turn off Air Assist pin +} + +#endif // AIR_ASSIST diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index f217c96749..5030f82f90 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -118,6 +118,7 @@ namespace Language_en { 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_ASSIST_TOGGLE = _UxGT("Air Assist"); 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"); diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index f0e702e2dd..a28c614c91 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -56,6 +56,11 @@ EDIT_ITEM(bool, MSG_CUTTER(EVAC_TOGGLE), &evac_state, cutter.air_evac_toggle); #endif + #if ENABLED(AIR_ASSIST) + bool air_assist_state = cutter.air_assist_state(); + EDIT_ITEM(bool, MSG_CUTTER(ASSIST_TOGGLE), &air_assist_state, cutter.air_assist_toggle); + #endif + #if ENABLED(SPINDLE_CHANGE_DIR) if (!is_enabled) { editable.state = is_rev; diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 4ed199df2f..6701cf573b 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -173,9 +173,9 @@ exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" restore_configs 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 MEATPACK_ON_SERIAL_PORT_1 + LASER_FEATURE AIR_EVACUATION AIR_ASSIST LASER_COOLANT_FLOW_METER MEATPACK_ON_SERIAL_PORT_1 -exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Cooler | Flowmeter | 12864 LCD | meatpack | SERIAL_PORT_2 " "$3" +exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 12864 LCD | meatpack | SERIAL_PORT_2 " "$3" # # Test Laser features with 44780 LCD @@ -183,9 +183,9 @@ exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Cooler | Flowmeter | 12 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 + LASER_FEATURE AIR_EVACUATION AIR_ASSIST LASER_COOLANT_FLOW_METER -exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Cooler | Flowmeter | 44780 LCD " "$3" +exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 44780 LCD " "$3" # # Language files test with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER From a95a21a3532b51b793b53306476177d714896f79 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 May 2021 19:32:21 -0500 Subject: [PATCH 088/109] Define 'filelist' for dgus/origin --- .../extui/lib/dgus/origin/DGUSDisplayDef.h | 44 +++++++++---------- .../lib/dgus/origin/DGUSScreenHandler.cpp | 2 + 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h index 5c5a315de6..c1890c7c28 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.h @@ -24,29 +24,29 @@ #include "../DGUSDisplayDef.h" enum DGUSLCD_Screens : uint8_t { - DGUSLCD_SCREEN_BOOT = 0, - DGUSLCD_SCREEN_MAIN = 10, - DGUSLCD_SCREEN_TEMPERATURE = 20, - DGUSLCD_SCREEN_STATUS = 30, - DGUSLCD_SCREEN_STATUS2 = 32, - DGUSLCD_SCREEN_MANUALMOVE = 40, - DGUSLCD_SCREEN_MANUALEXTRUDE=42, - DGUSLCD_SCREEN_FANANDFEEDRATE = 44, - DGUSLCD_SCREEN_FLOWRATES = 46, - DGUSLCD_SCREEN_SDFILELIST = 50, + DGUSLCD_SCREEN_BOOT = 0, + DGUSLCD_SCREEN_MAIN = 10, + DGUSLCD_SCREEN_TEMPERATURE = 20, + DGUSLCD_SCREEN_STATUS = 30, + DGUSLCD_SCREEN_STATUS2 = 32, + DGUSLCD_SCREEN_MANUALMOVE = 40, + DGUSLCD_SCREEN_MANUALEXTRUDE = 42, + DGUSLCD_SCREEN_FANANDFEEDRATE = 44, + DGUSLCD_SCREEN_FLOWRATES = 46, + DGUSLCD_SCREEN_SDFILELIST = 50, DGUSLCD_SCREEN_SDPRINTMANIPULATION = 52, - DGUSLCD_SCREEN_POWER_LOSS = 100, - DGUSLCD_SCREEN_PREHEAT=120, - DGUSLCD_SCREEN_UTILITY=110, - DGUSLCD_SCREEN_FILAMENT_HEATING=146, - DGUSLCD_SCREEN_FILAMENT_LOADING=148, - DGUSLCD_SCREEN_FILAMENT_UNLOADING=158, - DGUSLCD_SCREEN_SDPRINTTUNE = 170, - DGUSLCD_SCREEN_CONFIRM = 240, - DGUSLCD_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version") - DGUSLCD_SCREEN_WAITING = 251, - DGUSLCD_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen" - DGUSLDC_SCREEN_UNUSED = 255 + DGUSLCD_SCREEN_POWER_LOSS = 100, + DGUSLCD_SCREEN_PREHEAT = 120, + DGUSLCD_SCREEN_UTILITY = 110, + DGUSLCD_SCREEN_FILAMENT_HEATING = 146, + DGUSLCD_SCREEN_FILAMENT_LOADING = 148, + DGUSLCD_SCREEN_FILAMENT_UNLOADING = 158, + DGUSLCD_SCREEN_SDPRINTTUNE = 170, + DGUSLCD_SCREEN_CONFIRM = 240, + DGUSLCD_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version") + DGUSLCD_SCREEN_WAITING = 251, + DGUSLCD_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen" + DGUSLDC_SCREEN_UNUSED = 255 }; // Display Memory layout used (T5UID) diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp index 8806623b69..73e2f4f6f0 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSScreenHandler.cpp @@ -42,6 +42,8 @@ #if ENABLED(SDSUPPORT) + static ExtUI::FileList filelist; + void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; if (touched_nr > filelist.count()) return; From ffbf7a9141ca886dfc799251ad5405dc0542c2af Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 May 2021 20:06:49 -0500 Subject: [PATCH 089/109] Fix undefined abl_points --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 735fad015e..3bd96ef495 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -97,6 +97,14 @@ public: int abl_probe_index; #endif + #if ENABLED(AUTO_BED_LEVELING_LINEAR) + int abl_points; + #elif ENABLED(AUTO_BED_LEVELING_3POINT) + static constexpr int abl_points = 3; + #elif ABL_USES_GRID + static constexpr int abl_points = GRID_MAX_POINTS; + #endif + #if ABL_USES_GRID xy_int8_t meshCount; @@ -113,14 +121,6 @@ public: 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 From 95a5d63622e26710686ae0ffca5a9326b0c08556 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 May 2021 20:10:16 -0500 Subject: [PATCH 090/109] Air Assist tests --- buildroot/tests/mega2560 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 6701cf573b..b4a3d2b9ac 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -173,7 +173,7 @@ exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" restore_configs 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 AIR_EVACUATION AIR_ASSIST LASER_COOLANT_FLOW_METER MEATPACK_ON_SERIAL_PORT_1 + LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER MEATPACK_ON_SERIAL_PORT_1 exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 12864 LCD | meatpack | SERIAL_PORT_2 " "$3" @@ -183,7 +183,7 @@ exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air As 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 AIR_EVACUATION AIR_ASSIST LASER_COOLANT_FLOW_METER + LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER exec_test $1 $2 "REPRAP MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 44780 LCD " "$3" From 4d544e35e3ed04ee57c5f0242f86551c4e968d0a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 2 May 2021 01:16:57 +0000 Subject: [PATCH 091/109] [cron] Bump distribution date (2021-05-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 74fde2f7ac..2ec701cbe5 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-05-01" + #define STRING_DISTRIBUTION_DATE "2021-05-02" #endif /** From 46eb12da51b50f4fdbd482866e366faee446f3f3 Mon Sep 17 00:00:00 2001 From: vyacheslav-shubin Date: Sun, 2 May 2021 04:28:49 +0300 Subject: [PATCH 092/109] ExtUI event for PID tuning start (#21734) --- Marlin/src/lcd/extui/ui_api.h | 2 +- Marlin/src/module/temperature.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index e6452243fd..5603169626 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -57,7 +57,7 @@ namespace ExtUI { 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, 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 }; + enum result_t : uint8_t { PID_STARTED, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE }; constexpr uint8_t extruderCount = EXTRUDERS; constexpr uint8_t hotendCount = HOTENDS; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 53d6c14d5b..cc7aa6c8e1 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -551,6 +551,8 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL); + TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); + 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)); From 257ae51275f7112fce716cf1e8ebf7f108f32d97 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 May 2021 21:14:58 -0500 Subject: [PATCH 093/109] Use ststm32@~12.1 --- ini/stm32f1.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 94693d65a4..7283adda4b 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -23,7 +23,7 @@ # HAL/STM32 Base Environment values # [common_stm32] -platform = ststm32@~12.0 +platform = ststm32@~12.1 build_flags = ${common.build_flags} -std=gnu++14 -DUSBCON -DUSBD_USE_CDC @@ -36,7 +36,7 @@ src_filter = ${common.default_src_filter} + + Date: Sun, 2 May 2021 03:06:55 -0400 Subject: [PATCH 094/109] Allow disable of POWER_TIMEOUT (#21771) Co-authored-by: Scott Lahteine --- Marlin/src/feature/power.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 2f19dae7a6..fb2f1312e0 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -99,6 +99,10 @@ bool Power::is_power_needed() { return false; } +#ifndef POWER_TIMEOUT + #define POWER_TIMEOUT 0 +#endif + void Power::check() { static millis_t nextPowerCheck = 0; millis_t ms = millis(); @@ -106,7 +110,7 @@ void Power::check() { nextPowerCheck = ms + 2500UL; if (is_power_needed()) power_on(); - else if (!lastPowerOn || ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT))) + else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT)))) power_off(); } } From 78de32e5529fdc140a61fbe9ccca338b4fe0abc0 Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Sun, 2 May 2021 00:09:23 -0700 Subject: [PATCH 095/109] Allow Creality V4 SERVO0 and PROBE pin overrides (#21770) --- Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index 733e24cfac..421e339058 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -58,10 +58,12 @@ // // Servos // -#ifndef HAS_PIN_27_BOARD - #define SERVO0_PIN PB0 // BLTouch OUT -#else - #define SERVO0_PIN PC6 +#ifndef SERVO0_PIN + #ifndef HAS_PIN_27_BOARD + #define SERVO0_PIN PB0 // BLTouch OUT + #else + #define SERVO0_PIN PC6 + #endif #endif // @@ -71,7 +73,9 @@ #define Y_STOP_PIN PA6 #define Z_STOP_PIN PA7 -#define Z_MIN_PROBE_PIN PB1 // BLTouch IN +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB1 // BLTouch IN +#endif // // Filament Runout Sensor From fbc7a3775af380514f5d1da6af9c06a6565f787f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 2 May 2021 03:02:24 -0500 Subject: [PATCH 096/109] SOFT_RESET_VIA_SERIAL sanity-check --- Marlin/src/inc/SanityCheck.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 24ea6ce808..bb4ec75681 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2215,8 +2215,11 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif /** - * Software Reset on Kill option + * Software Reset options */ +#if ENABLED(SOFT_RESET_VIA_SERIAL) && DISABLED(EMERGENCY_PARSER) + #error "EMERGENCY_PARSER is required to activate SOFT_RESET_VIA_SERIAL." +#endif #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 From ae06ee24c52abe373e624315b6fa1dd467d02456 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sun, 2 May 2021 18:06:44 -0300 Subject: [PATCH 097/109] Fix bad call to 'diskIODriver' (#21775) --- Marlin/src/HAL/STM32/msc_sd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp index 20e1ab3cf9..cbfb837875 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -38,7 +38,7 @@ public: return &card.media_usbFlashDrive; #endif #else - return diskIODriver(); + return card.diskIODriver(); #endif } From 30c299fd26af803da9e5b5bb216e80677b9440fe Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 2 May 2021 15:55:20 -0500 Subject: [PATCH 098/109] Fix parser temperature rounding --- Marlin/src/gcode/parser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 8523630098..b3625ec05e 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -371,7 +371,7 @@ public: case TEMPUNIT_K: f -= 273.15f; case TEMPUNIT_F: f = (f - 32) * 0.5555555556f; } - return LROUND(f + 0.5f); + return LROUND(f); } static inline celsius_t value_celsius_diff() { @@ -382,7 +382,7 @@ public: case TEMPUNIT_K: break; case TEMPUNIT_F: f *= 0.5555555556f; } - return LROUND(f + 0.5f); + return LROUND(f); } #else // !TEMPERATURE_UNITS_SUPPORT From cb5e6bfef64ae4bc05db336a5e53a528bb3b7042 Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Sun, 2 May 2021 17:38:55 -0400 Subject: [PATCH 099/109] UBL Mesh Wizard (#21556) Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 2 + Marlin/src/feature/bedlevel/ubl/ubl.cpp | 45 +++++++++++++++++++++++ Marlin/src/gcode/gcode.cpp | 4 ++ Marlin/src/gcode/gcode.h | 4 ++ Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/menu/menu_ubl.cpp | 49 ++++++++++++++++++++++++- buildroot/tests/FYSETC_F6 | 2 +- 7 files changed, 105 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 442f502c3e..7b03cfe68b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1491,6 +1491,8 @@ //#define UBL_Z_RAISE_WHEN_OFF_MESH 2.5 // When the nozzle is off the mesh, this value is used // as the Z-Height correction value. + //#define UBL_MESH_WIZARD // Run several commands in a row to get a complete mesh + #elif ENABLED(MESH_BED_LEVELING) //=========================================================================== diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 164d267ceb..b7a2c380ce 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -35,6 +35,7 @@ unified_bed_leveling ubl; #include "../../../module/planner.h" #include "../../../module/motion.h" #include "../../../module/probe.h" +#include "../../../module/temperature.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" @@ -254,4 +255,48 @@ bool unified_bed_leveling::sanity_check() { return !!error_flag; } +#if ENABLED(UBL_MESH_WIZARD) + + /** + * M1004: UBL Mesh Wizard - One-click mesh creation with or without a probe + */ + void GcodeSuite::M1004() { + + #define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34", "") + #define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R255") + + #if HAS_HOTEND + if (parser.seenval('H')) { // Handle H# parameter to set Hotend temp + const celsius_t hotend_temp = parser.value_int(); // Marlin never sends itself F or K, always C + thermalManager.setTargetHotend(hotend_temp, 0); + thermalManager.wait_for_hotend(false); + } + #endif + + #if HAS_HEATED_BED + if (parser.seenval('B')) { // Handle B# parameter to set Bed temp + const celsius_t bed_temp = parser.value_int(); // Marlin never sends itself F or K, always C + thermalManager.setTargetBed(bed_temp); + thermalManager.wait_for_bed(false); + } + #endif + + process_subcommands_now_P(G28_STR); // Home + process_subcommands_now_P(PSTR(ALIGN_GCODE "\n" // Align multi z axis if available + PROBE_GCODE "\n" // Build mesh with available hardware + "G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice + + if (parser.seenval('S')) { + char umw_gcode[32]; + sprintf_P(umw_gcode, PSTR("G29S%i"), parser.value_int()); + queue.inject(umw_gcode); + } + + process_subcommands_now_P(PSTR("G29A\nG29F10\n" // Set UBL Active & Fade 10 + "M140S0\nM104S0\n" // Turn off heaters + "M500")); // Store settings + } + +#endif // UBL_MESH_WIZARD + #endif // AUTO_BED_LEVELING_UBL diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index bf26fe5d89..c0c5201222 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -987,6 +987,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 1002: M1002(); break; // M1002: [INTERNAL] Tool-change and Relative E Move #endif + #if ENABLED(UBL_MESH_WIZARD) + case 1004: M1004(); break; // M1004: UBL Mesh Wizard + #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 2904d30366..dc0b89e098 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -1079,6 +1079,10 @@ private: static void M1002(); #endif + #if ENABLED(UBL_MESH_WIZARD) + static void M1004(); + #endif + #if ENABLED(MAX7219_GCODE) static void M7219(); #endif diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 5030f82f90..34b2c0bb5b 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -166,6 +166,7 @@ namespace Language_en { PROGMEM Language_Str MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); PROGMEM Language_Str MSG_LCD_TILTING_MESH = _UxGT("Tilting Point"); PROGMEM Language_Str MSG_UBL_MANUAL_MESH = _UxGT("Manually Build Mesh"); + PROGMEM Language_Str MSG_UBL_MESH_WIZARD = _UxGT("UBL Mesh Wizard"); PROGMEM Language_Str MSG_UBL_BC_INSERT = _UxGT("Place Shim & Measure"); PROGMEM Language_Str MSG_UBL_BC_INSERT2 = _UxGT("Measure"); PROGMEM Language_Str MSG_UBL_BC_REMOVE = _UxGT("Remove & Measure Bed"); diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 1ab44856dc..c73be1ef7f 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -37,7 +37,7 @@ #include "../../feature/bedlevel/bedlevel.h" static int16_t ubl_storage_slot = 0, - custom_hotend_temp = 190, + custom_hotend_temp = 150, side_points = 3, ubl_fillin_amount = 5, ubl_height_amount = 1; @@ -603,6 +603,50 @@ void _menu_ubl_tools() { #endif +#if ENABLED(UBL_MESH_WIZARD) + + /** + * UBL Mesh Wizard - One-click mesh creation with or without a probe + */ + void _lcd_ubl_mesh_wizard() { + char ubl_lcd_gcode[30]; + #if HAS_HEATED_BED && HAS_HOTEND + sprintf_P(ubl_lcd_gcode, PSTR("M1004B%iH%iS%i"), custom_bed_temp, custom_hotend_temp, ubl_storage_slot); + #elif HAS_HOTEND + sprintf_P(ubl_lcd_gcode, PSTR("M1004H%iS%i"), custom_hotend_temp, ubl_storage_slot); + #else + sprintf_P(ubl_lcd_gcode, PSTR("M1004S%i"), ubl_storage_slot); + #endif + queue.inject(ubl_lcd_gcode); + } + + void _menu_ubl_mesh_wizard() { + const int16_t total_slots = settings.calc_num_meshes(); + START_MENU(); + BACK_ITEM(MSG_UBL_LEVEL_BED); + + #if HAS_HOTEND + 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); + #endif + + EDIT_ITEM(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, total_slots); + + ACTION_ITEM(MSG_UBL_MESH_WIZARD, _lcd_ubl_mesh_wizard); + + #if ENABLED(G26_MESH_VALIDATION) + SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); + #endif + + ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); + END_MENU(); + } + +#endif + /** * UBL System submenu * @@ -626,6 +670,9 @@ void _lcd_ubl_level_bed() { #if ENABLED(G26_MESH_VALIDATION) SUBMENU(MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step); #endif + #if ENABLED(UBL_MESH_WIZARD) + SUBMENU(MSG_UBL_MESH_WIZARD, _menu_ubl_mesh_wizard); + #endif ACTION_ITEM(MSG_UBL_MESH_EDIT, _ubl_goto_map_screen); SUBMENU(MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh); SUBMENU(MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map); diff --git a/buildroot/tests/FYSETC_F6 b/buildroot/tests/FYSETC_F6 index 3fe59d59a1..9306686af5 100755 --- a/buildroot/tests/FYSETC_F6 +++ b/buildroot/tests/FYSETC_F6 @@ -24,7 +24,7 @@ opt_set MOTHERBOARD BOARD_FYSETC_F6_13 \ L6470_CHAIN_SCK_PIN 53 L6470_CHAIN_MISO_PIN 49 L6470_CHAIN_MOSI_PIN 40 L6470_CHAIN_SS_PIN 42 \ 'ENABLE_RESET_L64XX_CHIPS(V)' NOOP opt_enable RESTORE_LEVELING_AFTER_G28 EEPROM_SETTINGS EEPROM_CHITCHAT \ - Z_PROBE_ALLEN_KEY AUTO_BED_LEVELING_UBL \ + Z_PROBE_ALLEN_KEY AUTO_BED_LEVELING_UBL UBL_MESH_WIZARD \ OLED_PANEL_TINYBOY2 MESH_EDIT_GFX_OVERLAY DELTA_CALIBRATION_MENU exec_test $1 $2 "DELTA, RAMPS, L6470, UBL, Allen Key, EEPROM, OLED_PANEL_TINYBOY2..." "$3" From fb2bfe1cef1daeec13760c29d055b4323e65c25c Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sun, 2 May 2021 19:05:15 -0300 Subject: [PATCH 100/109] Fix bad DELTA probe move (#21781) --- Marlin/src/module/motion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 584e894ae6..7c0f8f404a 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -426,7 +426,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ #endif if (TERN0(IS_KINEMATIC, is_fast)) - TERN(IS_KINEMATIC, NOOP, prepare_line_to_destination()); + TERN(IS_KINEMATIC, prepare_fast_move_to_destination(), NOOP); else prepare_line_to_destination(); From eaa64967b59a12063c6e6cb78ea63bffacaaa1ad Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 3 May 2021 01:04:25 +0000 Subject: [PATCH 101/109] [cron] Bump distribution date (2021-05-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 2ec701cbe5..88ab7540ab 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-05-02" + #define STRING_DISTRIBUTION_DATE "2021-05-03" #endif /** From becdac19ea4559c1e636d55d949a15c50cac7888 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 2 May 2021 21:32:21 -0500 Subject: [PATCH 102/109] Temperature cleanup --- Marlin/src/lcd/tft/touch.cpp | 18 +++--- Marlin/src/module/temperature.cpp | 95 +++++++++++-------------------- Marlin/src/module/temperature.h | 54 +++++++----------- 3 files changed, 61 insertions(+), 106 deletions(-) diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index e8a01e889b..83a7ea78b7 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -184,14 +184,16 @@ void Touch::touch(touch_control_t *control) { int8_t heater; heater = control->data; 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.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.hotend_max_target(heater), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); - #endif - } + #if HAS_HOTEND + if (heater >= 0) { // HotEnd + #if HOTENDS == 1 + 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.hotend_max_target(heater), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); + #endif + } + #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_MAX_TARGET, thermalManager.start_watching_bed); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index cc7aa6c8e1..6a04efc302 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -447,11 +447,11 @@ volatile bool Temperature::raw_temps_ready = false; temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0, sensor_heater_1, sensor_heater_2, sensor_heater_3, sensor_heater_4, sensor_heater_5, sensor_heater_6, sensor_heater_7); #endif -#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED +#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 }; #endif -#ifdef MILLISECONDS_PREHEAT_TIME +#if MILLISECONDS_PREHEAT_TIME > 0 millis_t Temperature::preheat_end_time[HOTENDS] = { 0 }; #endif @@ -472,7 +472,7 @@ volatile bool Temperature::raw_temps_ready = false; #endif #if ENABLED(PROBING_HEATERS_OFF) - bool Temperature::paused; + bool Temperature::paused_for_probing; #endif // public: @@ -1320,10 +1320,10 @@ void Temperature::manage_heater() { #if DISABLED(PIDTEMPBED) if (PENDING(ms, next_bed_check_ms) - && TERN1(PAUSE_CHANGE_REQD, paused == last_pause_state) + && TERN1(PAUSE_CHANGE_REQD, paused_for_probing == last_pause_state) ) break; next_bed_check_ms = ms + BED_CHECK_INTERVAL; - TERN_(PAUSE_CHANGE_REQD, last_pause_state = paused); + TERN_(PAUSE_CHANGE_REQD, last_pause_state = paused_for_probing); #endif TERN_(HEATER_IDLE_HANDLER, heater_idle[IDLE_INDEX_BED].update(ms)); @@ -1958,9 +1958,30 @@ void Temperature::updateTemperaturesFromRawValues() { /** * Initialize the temperature manager + * * The manager is implemented by periodic calls to manage_heater() + * + * - Init (and disable) SPI thermocouples like MAX6675 and MAX31865 + * - Disable RUMBA JTAG to accommodate a thermocouple extension + * - Read-enable thermistors with a read-enable pin + * - Init HEATER and COOLER pins for OUTPUT in OFF state + * - Init the FAN pins as PWM or OUTPUT + * - Init the SPI interface for SPI thermocouples + * - Init ADC according to the HAL + * - Set thermistor pins to analog inputs according to the HAL + * - Start the Temperature ISR timer + * - Init the AUTO FAN pins as PWM or OUTPUT + * - Wait 250ms for temperatures to settle + * - Init temp_range[], used for catching min/maxtemp */ void Temperature::init() { + + TERN_(PROBING_HEATERS_OFF, paused_for_probing = false); + + #if BOTH(PIDTEMP, PID_EXTRUSION_SCALING) + last_e_position = 0; + #endif + // Init (and disable) SPI thermocouples #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS) OUT_WRITE(MAX6675_CS_PIN, HIGH); @@ -2017,10 +2038,6 @@ void Temperature::init() { OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC)); #endif - #if BOTH(PIDTEMP, PID_EXTRUSION_SCALING) - last_e_position = 0; - #endif - #if HAS_HEATER_0 #ifdef BOARD_OPENDRAIN_MOSFETS OUT_WRITE_OD(HEATER_0_PIN, HEATER_0_INVERTING); @@ -2276,55 +2293,8 @@ void Temperature::init() { 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); } -#if WATCH_HOTENDS - /** - * Start Heating Sanity Check for hotends that are below - * their target temperature by a configurable margin. - * This is called when the temperature is set. (M104, M109) - */ - void Temperature::start_watching_hotend(const uint8_t E_NAME) { - const uint8_t ee = HOTEND_INDEX; - watch_hotend[ee].restart(degHotend(ee), degTargetHotend(ee)); - } -#endif - -#if WATCH_BED - /** - * Start Heating Sanity Check for hotends that are below - * their target temperature by a configurable margin. - * This is called when the temperature is set. (M140, M190) - */ - void Temperature::start_watching_bed() { - watch_bed.restart(degBed(), degTargetBed()); - } -#endif - -#if WATCH_CHAMBER - /** - * Start Heating Sanity Check for chamber that is below - * its target temperature by a configurable margin. - * This is called when the temperature is set. (M141, M191) - */ - void Temperature::start_watching_chamber() { - watch_chamber.restart(degChamber(), degTargetChamber()); - } -#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 } }; @@ -2487,8 +2457,8 @@ void Temperature::disable_all_heaters() { #if ENABLED(PROBING_HEATERS_OFF) void Temperature::pause(const bool p) { - if (p != paused) { - paused = p; + if (p != paused_for_probing) { + paused_for_probing = p; if (p) { HOTEND_LOOP() heater_idle[e].expire(); // Timeout immediately TERN_(HAS_HEATED_BED, heater_idle[IDLE_INDEX_BED].expire()); // Timeout immediately @@ -2773,17 +2743,16 @@ void Temperature::readings_ready() { const int8_t tdir = temp_dir[e]; if (tdir) { const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp - const bool heater_on = (temp_hotend[e].target > 0 - || TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount) > 0 - ); if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e); + + const bool heater_on = (temp_hotend[e].target > 0 || TERN0(PIDTEMP, temp_hotend[e].soft_pwm_amount > 0)); if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) { - #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) #endif min_temp_error((heater_id_t)e); } - #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 else consecutive_low_temperature_error[e] = 0; #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 702a3ea04d..148e9eec54 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -462,11 +462,11 @@ class Temperature { static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER; #endif - #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 static uint8_t consecutive_low_temperature_error[HOTENDS]; #endif - #ifdef MILLISECONDS_PREHEAT_TIME + #if MILLISECONDS_PREHEAT_TIME > 0 static millis_t preheat_end_time[HOTENDS]; #endif @@ -475,7 +475,7 @@ class Temperature { #endif #if ENABLED(PROBING_HEATERS_OFF) - static bool paused; + static bool paused_for_probing; #endif public: @@ -610,7 +610,7 @@ class Temperature { /** * Preheating hotends */ - #ifdef MILLISECONDS_PREHEAT_TIME + #if MILLISECONDS_PREHEAT_TIME > 0 static inline bool is_preheating(const uint8_t E_NAME) { return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]); } @@ -653,17 +653,11 @@ class Temperature { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target); } - #if WATCH_HOTENDS - static void start_watching_hotend(const uint8_t e=0); - #else - static inline void start_watching_hotend(const uint8_t=0) {} - #endif - #if HAS_HOTEND static void setTargetHotend(const celsius_t celsius, const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; - #ifdef MILLISECONDS_PREHEAT_TIME + #if MILLISECONDS_PREHEAT_TIME > 0 if (celsius == 0) reset_preheat_time(ee); else if (temp_hotend[ee].target == 0) @@ -702,6 +696,14 @@ class Temperature { return ABS(wholeDegHotend(e) - temp) < (TEMP_HYSTERESIS); } + // Start watching a Hotend to make sure it's really heating up + static inline void start_watching_hotend(const uint8_t E_NAME) { + UNUSED(HOTEND_INDEX); + #if WATCH_HOTENDS + watch_hotend[HOTEND_INDEX].restart(degHotend(HOTEND_INDEX), degTargetHotend(HOTEND_INDEX)); + #endif + } + #endif // HAS_HOTEND #if HAS_HEATED_BED @@ -715,11 +717,8 @@ class Temperature { 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(); - #else - static inline void start_watching_bed() {} - #endif + // Start watching the Bed to make sure it's really heating up + static inline void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } static void setTargetBed(const celsius_t celsius) { TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on()); @@ -752,12 +751,6 @@ class Temperature { static bool wait_for_probe(const celsius_t target_temp, bool no_wait_for_cooling=true); #endif - #if WATCH_PROBE - static void start_watching_probe(); - #else - static inline void start_watching_probe() {} - #endif - #if HAS_TEMP_CHAMBER #if ENABLED(SHOW_TEMP_ADC_VALUES) static inline int16_t rawChamberTemp() { return temp_chamber.raw; } @@ -772,17 +765,13 @@ class Temperature { #endif #endif - #if WATCH_CHAMBER - static void start_watching_chamber(); - #else - static inline void start_watching_chamber() {} - #endif - #if HAS_HEATED_CHAMBER static void setTargetChamber(const celsius_t celsius) { temp_chamber.target = _MIN(celsius, CHAMBER_MAX_TARGET); start_watching_chamber(); } + // Start watching the Chamber to make sure it's really heating up + static inline void start_watching_chamber() { TERN_(WATCH_CHAMBER, watch_chamber.restart(degChamber(), degTargetChamber())); } #endif #if HAS_TEMP_COOLER @@ -799,17 +788,13 @@ class Temperature { #endif #endif - #if WATCH_COOLER - static void start_watching_cooler(); - #else - static inline void start_watching_cooler() {} - #endif - #if HAS_COOLER static inline void setTargetCooler(const celsius_t celsius) { temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET); start_watching_cooler(); } + // Start watching the Cooler to make sure it's really cooling down + static inline void start_watching_cooler() { TERN_(WATCH_COOLER, watch_cooler.restart(degCooler(), degTargetCooler())); } #endif /** @@ -860,7 +845,6 @@ class Temperature { #if ENABLED(PROBING_HEATERS_OFF) static void pause(const bool p); - static inline bool is_paused() { return paused; } #endif #if HEATER_IDLE_HANDLER From 9dd884a324e82c74e8e78c987d490a297bafbdc0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 2 May 2021 21:32:42 -0500 Subject: [PATCH 103/109] Drop early_safe_delay --- Marlin/src/core/utility.cpp | 12 ------------ Marlin/src/core/utility.h | 5 ----- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 8 ++++---- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 385a572029..3d7897f95a 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -35,18 +35,6 @@ 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 0e1c109be1..d774b007b6 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -26,11 +26,6 @@ #include "../core/millis_t.h" 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/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 1fdc291642..1a07b7ab75 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -160,14 +160,14 @@ bool MarlinUI::detected() { return true; } #endif u8g.firstPage(); do { draw_custom_bootscreen(f); } while (u8g.nextPage()); - if (frame_time) early_safe_delay(frame_time); + if (frame_time) safe_delay(frame_time); } #ifndef CUSTOM_BOOTSCREEN_TIMEOUT #define CUSTOM_BOOTSCREEN_TIMEOUT 2500 #endif #if CUSTOM_BOOTSCREEN_TIMEOUT - early_safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); + safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); #endif } #endif // SHOW_CUSTOM_BOOTSCREEN @@ -226,7 +226,7 @@ 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) early_safe_delay(frame_time); + if (frame_time) safe_delay(frame_time); } #endif } @@ -235,7 +235,7 @@ bool MarlinUI::detected() { return true; } void MarlinUI::show_marlin_bootscreen() { for (uint8_t q = bootscreen_pages; q--;) { draw_marlin_bootscreen(q == 0); - if (q) early_safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages); + if (q) safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages); } } From dc187690109b9f66673bb6675c098af0644d40e1 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Sun, 2 May 2021 23:37:54 -0300 Subject: [PATCH 104/109] Prevent watchdog reset in setup() (#21776) Cause `manage_heaters` to only reset the watchdog and return until `setup()` is completed. Co-authored-by: Scott Lahteine --- Marlin/src/inc/Conditionals_adv.h | 5 ----- Marlin/src/module/temperature.cpp | 18 ++---------------- Marlin/src/module/temperature.h | 4 ---- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 735e6464d9..19ab98fed3 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -370,11 +370,6 @@ #endif #endif -// If platform requires early initialization of watchdog to properly boot -#if ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM) - #define EARLY_WATCHDOG 1 -#endif - // Full Touch Screen needs 'tft/xpt2046' #if EITHER(TOUCH_SCREEN, HAS_TFT_LVGL_UI) #define HAS_TFT_XPT2046 1 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 6a04efc302..2f1a54e91d 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -420,10 +420,6 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, // private: -#if EARLY_WATCHDOG - bool Temperature::inited = false; -#endif - volatile bool Temperature::raw_temps_ready = false; #if ENABLED(PID_EXTRUSION_SCALING) @@ -1205,11 +1201,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { * - Update the heated bed PID output value */ void Temperature::manage_heater() { - - #if EARLY_WATCHDOG - // If thermal manager is still not running, make sure to at least reset the watchdog! - if (!inited) return watchdog_refresh(); - #endif + if (marlin_state == MF_INITIALIZING) return watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! #if ENABLED(EMERGENCY_PARSER) if (emergency_parser.killed_by_M112) kill(M112_KILL_STR, nullptr, true); @@ -2015,12 +2007,6 @@ void Temperature::init() { TERN_(TEMP_SENSOR_1_IS_MAX6675, max6675_1.begin()); #endif - #if EARLY_WATCHDOG - // Flag that the thermalManager should be running - if (inited) return; - inited = true; - #endif - #if MB(RUMBA) // Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector #define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495) @@ -2209,7 +2195,7 @@ void Temperature::init() { #endif // Wait for temperature measurement to settle - delay(250); + //delay(250); #if HAS_HOTEND diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 148e9eec54..96ff8b5895 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -419,10 +419,6 @@ class Temperature { private: - #if ENABLED(EARLY_WATCHDOG) - static bool inited; // If temperature controller is running - #endif - static volatile bool raw_temps_ready; #if ENABLED(WATCH_HOTENDS) From 65b1139d93b3080c2eb4f56373bf35fe2945976a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 4 May 2021 00:59:46 +0000 Subject: [PATCH 105/109] [cron] Bump distribution date (2021-05-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 88ab7540ab..5f169f5b05 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-05-03" + #define STRING_DISTRIBUTION_DATE "2021-05-04" #endif /** From 01825d883eac8859547ae92f2b3c01b48b121bec Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 3 May 2021 20:09:21 -0500 Subject: [PATCH 106/109] Apply SBI/CBI/TEST in HAL --- Marlin/src/HAL/LPC1768/main.cpp | 2 +- Marlin/src/HAL/STM32/HAL_MinSerial.cpp | 4 ++-- Marlin/src/HAL/STM32/tft/tft_ltdc.cpp | 25 +++++++++++------------- Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp | 2 +- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/main.cpp b/Marlin/src/HAL/LPC1768/main.cpp index 08fb1a1ed5..ef0dc42c78 100644 --- a/Marlin/src/HAL/LPC1768/main.cpp +++ b/Marlin/src/HAL/LPC1768/main.cpp @@ -117,7 +117,7 @@ void HAL_init() { PinCfg.Pinmode = 2; // no pull-up/pull-down PINSEL_ConfigPin(&PinCfg); // now set CLKOUT_EN bit - LPC_SC->CLKOUTCFG |= (1<<8); + SBI(LPC_SC->CLKOUTCFG, 8); #endif USB_Init(); // USB Initialization diff --git a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp index 823bb6e8f5..7268eed591 100644 --- a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp @@ -71,8 +71,8 @@ static void TXBegin() { volatile uint32_t ICER[32]; }; - NVICMin * nvicBase = (NVICMin*)0xE000E100; - nvicBase->ICER[nvicIndex / 32] |= _BV32(nvicIndex % 32); + NVICMin *nvicBase = (NVICMin*)0xE000E100; + SBI32(nvicBase->ICER[nvicIndex >> 5], nvicIndex & 0x1F); // We NEED memory barriers to ensure Interrupts are actually disabled! // ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the ) diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp index 6039593f46..c1a56101ad 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp @@ -45,7 +45,6 @@ #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; @@ -192,7 +191,7 @@ void LTDC_Config() { hltdc_F.Instance = LTDC; -/* Layer0 Configuration ------------------------------------------------------*/ + /* Layer0 Configuration ------------------------------------------------------*/ /* Windowing configuration */ pLayerCfg.WindowX0 = 0; @@ -289,22 +288,21 @@ void TFT_LTDC::DrawRect(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint uint16_t offline = TFT_WIDTH - (ex - sx); uint32_t addr = (uint32_t)&framebuffer[(TFT_WIDTH * sy) + sx]; - DMA2D->CR &= ~(1 << 0); + CBI(DMA2D->CR, 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; + SBI(DMA2D->CR, 0); uint32_t timeout = 0; - while((DMA2D->ISR & (1<<1)) == 0) - { + while (!TEST(DMA2D->ISR, 1)) { timeout++; - if(timeout>0X1FFFFF)break; + if (timeout > 0x1FFFFF) break; } - DMA2D->IFCR |= 1<<1; + SBI(DMA2D->IFCR, 1); } void TFT_LTDC::DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *colors) { @@ -314,7 +312,7 @@ void TFT_LTDC::DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uin uint16_t offline = TFT_WIDTH - (ex - sx); uint32_t addr = (uint32_t)&framebuffer[(TFT_WIDTH * sy) + sx]; - DMA2D->CR &= ~(1 << 0); + CBI(DMA2D->CR, 0) DMA2D->CR = 0 << 16; DMA2D->FGPFCCR = 0X02; DMA2D->FGOR = 0; @@ -322,15 +320,14 @@ void TFT_LTDC::DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uin DMA2D->FGMAR = (uint32_t)colors; DMA2D->OMAR = addr; DMA2D->NLR = (ey - sy) | ((ex - sx) << 16); - DMA2D->CR |= 1<<0; + SBI(DMA2D->CR, 0); uint32_t timeout = 0; - while((DMA2D->ISR & (1<<1)) == 0) - { + while (!TEST(DMA2D->ISR, 1)) { timeout++; - if(timeout>0X1FFFFF)break; + if (timeout > 0x1FFFFF) break; } - DMA2D->IFCR |= 1<<1; + SBI(DMA2D->IFCR, 1); } void TFT_LTDC::WriteData(uint16_t data) { diff --git a/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp index 2cb75bb1e9..0fc3d014d4 100644 --- a/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp @@ -55,7 +55,7 @@ static void TXBegin() { nvic_irq_disable(dev->irq_num); // Use this if removing libmaple - //NVIC_BASE->ICER[1] |= _BV(irq - 32); + //SBI(NVIC_BASE->ICER[1], irq - 32); // We NEED memory barriers to ensure Interrupts are actually disabled! // ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the ) From dfc906930c9b31ddd4d70e9c0ccf15e369abd188 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 3 May 2021 20:55:05 -0500 Subject: [PATCH 107/109] Pause and PLR refinements - Move `pause_print` argument `unload_length` after `show_lcd` so it's next to `DXC_ARGS`. - Tweak the position and conditions of PLR save in `resume_print`. - Add `Nozzle::park_mode_0_height` accessor to get the raised Z height. - Remove extraneous `recovery.save` from `dwin.cpp`. - Move PLR `info.volumetric...` to `flag`. - Remove some G-code spaces in PLR code - Document `pause.h` function declarations. --- Marlin/src/feature/pause.cpp | 25 +++++++------ Marlin/src/feature/pause.h | 44 ++++++++++++++++++----- Marlin/src/feature/powerloss.cpp | 48 ++++++++++++++----------- Marlin/src/feature/powerloss.h | 6 ++-- Marlin/src/gcode/feature/pause/M125.cpp | 2 +- Marlin/src/gcode/feature/pause/M600.cpp | 2 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 3 -- Marlin/src/libs/nozzle.cpp | 24 ++++++++----- Marlin/src/libs/nozzle.h | 1 + 9 files changed, 99 insertions(+), 56 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 867502712c..93b4a2aa81 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -316,7 +316,7 @@ bool unload_filament(const_float_t unload_length, const bool show_lcd/*=false*/, ); #if !BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER) - constexpr float mix_multiplier = 1.0; + constexpr float mix_multiplier = 1.0f; #endif if (!ensure_safe_temperature(false, mode)) { @@ -371,7 +371,7 @@ bool unload_filament(const_float_t unload_length, const bool show_lcd/*=false*/, */ uint8_t did_pause_print = 0; -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) { +bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool show_lcd/*=false*/, const_float_t unload_length/*=0*/ 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); @@ -394,7 +394,8 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const_float // Pause the print job and timer #if ENABLED(SDSUPPORT) - if (IS_SD_PRINTING()) { + const bool was_sd_printing = IS_SD_PRINTING(); + if (was_sd_printing) { card.pauseSDPrint(); ++did_pause_print; // Indicate SD pause also } @@ -418,7 +419,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const_float unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE); } - // Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos) + // Park the nozzle by doing a Minimum Z Raise followed by an XY Move if (!axes_should_home()) nozzle.park(0, park_point); @@ -630,9 +631,6 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ // Set extruder to saved position planner.set_e_position_mm((destination.e = current_position.e = resume_position.e)); - // Write PLR now to update the z axis value - TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true)); - ui.pause_show_message(PAUSE_MESSAGE_STATUS); #ifdef ACTION_ON_RESUMED @@ -645,8 +643,16 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR)); + // Resume the print job timer if it was running + if (print_job_timer.isPaused()) print_job_timer.start(); + #if ENABLED(SDSUPPORT) - if (did_pause_print) { card.startFileprint(); --did_pause_print; } + if (did_pause_print) { + --did_pause_print; + card.startFileprint(); + // Write PLR now to update the z axis value + TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true)); + } #endif #if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && HAS_FAN @@ -655,9 +661,6 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HAS_FILAMENT_SENSOR, runout.reset()); - // Resume the print job timer if it was running - if (print_job_timer.isPaused()) print_job_timer.start(); - TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); TERN_(HAS_LCD_MENU, ui.return_to_status()); } diff --git a/Marlin/src/feature/pause.h b/Marlin/src/feature/pause.h index facd8d8dee..d2c45e44a5 100644 --- a/Marlin/src/feature/pause.h +++ b/Marlin/src/feature/pause.h @@ -85,19 +85,47 @@ extern uint8_t did_pause_print; #define DXC_SAY #endif -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); +// Pause the print. If unload_length is set, do a Filament Unload +bool pause_print( + const_float_t retract, // (mm) Retraction length + const xyz_pos_t &park_point, // Parking XY Position and Z Raise + const bool show_lcd=false, // Set LCD status messages? + const_float_t unload_length=0 // (mm) Filament Change Unload Length - 0 to skip + DXC_PARAMS // Dual-X-Carriage extruder index +); -void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS); +void wait_for_confirmation( + const bool is_reload=false, // Reload Filament? (otherwise Resume Print) + const int8_t max_beep_count=0 // Beep alert for attention + DXC_PARAMS // Dual-X-Carriage extruder index +); -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); +void resume_print( + const_float_t slow_load_length=0, // (mm) Slow Load Length for finishing move + const_float_t fast_load_length=0, // (mm) Fast Load Length for initial move + const_float_t extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, // (mm) Purge length + const int8_t max_beep_count=0, // Beep alert for attention + const celsius_t targetTemp=0 // (°C) A target temperature for the hotend + DXC_PARAMS // Dual-X-Carriage extruder index +); -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 load_filament( + const_float_t slow_load_length=0, // (mm) Slow Load Length for finishing move + const_float_t fast_load_length=0, // (mm) Fast Load Length for initial move + const_float_t extrude_length=0, // (mm) Purge length + const int8_t max_beep_count=0, // Beep alert for attention + const bool show_lcd=false, // Set LCD status messages? + const bool pause_for_user=false, // Pause for user before returning? + const PauseMode mode=PAUSE_MODE_PAUSE_PRINT // Pause Mode to apply + DXC_PARAMS // Dual-X-Carriage extruder index +); -bool unload_filament(const_float_t unload_length, const bool show_lcd=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT +bool unload_filament( + const_float_t unload_length, // (mm) Filament Unload Length - 0 to skip + const bool show_lcd=false, // Set LCD status messages? + const PauseMode mode=PAUSE_MODE_PAUSE_PRINT // Pause Mode to apply #if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER) - , const_float_t mix_multiplier=1.0 + , const_float_t mix_multiplier=1.0f // Extrusion multiplier (for a Mixing Extruder) #endif ); diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index dd4c78726a..10488af709 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -149,6 +149,8 @@ void PrintJobRecovery::prepare() { */ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/) { + // We don't check IS_SD_PRINTING here so a save may occur during a pause + #if SAVE_INFO_INTERVAL_MS > 0 static millis_t next_save_ms; // = 0 millis_t ms = millis(); @@ -192,7 +194,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/ #endif #if DISABLED(NO_VOLUMETRICS) - info.volumetric_enabled = parser.volumetric_enabled; + info.flag.volumetric_enabled = parser.volumetric_enabled; #if HAS_MULTI_EXTRUDER for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e]; #else @@ -366,13 +368,16 @@ void PrintJobRecovery::resume() { } #endif - // Reset E, raise Z, home XY... + // + // Home the axes that can safely be homed, and + // establish the current position as best we can + // #if Z_HOME_DIR > 0 - // If Z homing goes to max, just reset E and home all + // If Z homing goes to max... gcode.process_subcommands_now_P(PSTR( - "G92.9 E0\n" - "G28R0" + "G92.9 E0\n" // Reset E to 0 + "G28R0" // Home all axes (no raise) )); #else // "G92.9 E0 ..." @@ -391,19 +396,20 @@ void PrintJobRecovery::resume() { #endif - #ifdef POWER_LOSS_ZHOME_POS - // If defined move to a safe Z homing position that avoids the print + #if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS) + // Move to a safe XY position where Z can home while avoiding the print. + // If Z_SAFE_HOMING is enabled, its position must also be outside the print area! constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS; - sprintf_P(cmd, PSTR("G1 X%s Y%s F1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2)); + sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2)); gcode.process_subcommands_now(cmd); #endif - // Ensure that all axes are marked as homed + // Mark all axes as having been homed (no effect on current_position) set_all_homed(); #if ENABLED(POWER_LOSS_RECOVER_ZHOME) - // Now move to ZsavedPos + POWER_LOSS_ZRAISE - sprintf_P(cmd, PSTR("G1 F500 Z%s"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1)); + // Z was homed. Now move Z back up to the saved Z height, plus the POWER_LOSS_ZRAISE. + sprintf_P(cmd, PSTR("G1Z%sF500"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1)); gcode.process_subcommands_now(cmd); #endif @@ -411,16 +417,16 @@ void PrintJobRecovery::resume() { #if DISABLED(NO_VOLUMETRICS) #if HAS_MULTI_EXTRUDER for (int8_t e = 0; e < EXTRUDERS; e++) { - sprintf_P(cmd, PSTR("M200 T%i D%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1)); + sprintf_P(cmd, PSTR("M200T%iD%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1)); gcode.process_subcommands_now(cmd); } - if (!info.volumetric_enabled) { - sprintf_P(cmd, PSTR("M200 T%i D0"), info.active_extruder); + if (!info.flag.volumetric_enabled) { + sprintf_P(cmd, PSTR("M200T%iD0"), info.active_extruder); gcode.process_subcommands_now(cmd); } #else - if (info.volumetric_enabled) { - sprintf_P(cmd, PSTR("M200 D%s"), dtostrf(info.filament_size[0], 1, 3, str_1)); + if (info.flag.volumetric_enabled) { + sprintf_P(cmd, PSTR("M200D%s"), dtostrf(info.filament_size[0], 1, 3, str_1)); gcode.process_subcommands_now(cmd); } #endif @@ -437,13 +443,13 @@ void PrintJobRecovery::resume() { FANS_LOOP(i) { const int f = info.fan_speed[i]; if (f) { - sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f); + sprintf_P(cmd, PSTR("M106P%iS%i"), i, f); gcode.process_subcommands_now(cmd); } } #endif - // Restore retract and hop state + // Restore retract and hop state from an active `G10` command #if ENABLED(FWRETRACT) LOOP_L_N(e, EXTRUDERS) { if (info.retract[e] != 0.0) { @@ -458,7 +464,7 @@ void PrintJobRecovery::resume() { // Restore leveling state before 'G92 Z' to ensure // the Z stepper count corresponds to the native Z. if (info.fade || info.flag.leveling) { - sprintf_P(cmd, PSTR("M420 S%i Z%s"), int(info.flag.leveling), dtostrf(info.fade, 1, 1, str_1)); + sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1)); gcode.process_subcommands_now(cmd); } #endif @@ -468,11 +474,11 @@ void PrintJobRecovery::resume() { #endif // Un-retract if there was a retract at outage - #if POWER_LOSS_RETRACT_LEN + #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0 gcode.process_subcommands_now_P(PSTR("G1 E" STRINGIFY(POWER_LOSS_RETRACT_LEN) " F3000")); #endif - // Additional purge if configured + // Additional purge on resume if configured #if POWER_LOSS_PURGE_LEN sprintf_P(cmd, PSTR("G1 E%d F3000"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN)); gcode.process_subcommands_now(cmd); diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index ad34de6e53..0777466cc1 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -70,7 +70,6 @@ typedef struct { #endif #if DISABLED(NO_VOLUMETRICS) - bool volumetric_enabled; float filament_size[EXTRUDERS]; #endif @@ -116,7 +115,10 @@ typedef struct { bool dryrun:1; // M111 S8 bool allow_cold_extrusion:1; // M302 P1 #if ENABLED(HAS_LEVELING) - bool leveling:1; + bool leveling:1; // M420 S + #endif + #if DISABLED(NO_VOLUMETRICS) + bool volumetric_enabled:1; // M200 S D #endif } flag; diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index e65b48545b..dcd3e99f7a 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -80,7 +80,7 @@ void GcodeSuite::M125() { TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true)); - if (pause_print(retract, park_point, 0, show_lcd)) { + if (pause_print(retract, park_point, show_lcd, 0)) { if (ENABLED(EXTENSIBLE_UI) || !sd_printing || show_lcd) { wait_for_confirmation(false, 0); resume_print(0, 0, -retract, 0); diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 1033025fe3..6cab3ad352 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -149,7 +149,7 @@ void GcodeSuite::M600() { #endif ); - if (pause_print(retract, park_point, unload_length, true DXC_PASS)) { + if (pause_print(retract, park_point, true, unload_length DXC_PASS)) { #if ENABLED(MMU2_MENUS) mmu2_M600(); resume_print(slow_load_length, fast_load_length, 0, beep_count DXC_PASS); diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 9fdf401b57..dc729263db 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -2298,9 +2298,6 @@ void HMI_PauseOrStop() { if (HMI_flag.select_flag) { HMI_flag.pause_action = true; ICON_Continue(); - #if ENABLED(POWER_LOSS_RECOVERY) - if (recovery.enabled) recovery.save(true); - #endif queue.inject_P(PSTR("M25")); } else { diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 6918d2fd80..e277216ab4 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -225,6 +225,18 @@ Nozzle nozzle; #if ENABLED(NOZZLE_PARK_FEATURE) + float Nozzle::park_mode_0_height(const_float_t park_z) { + // Apply a minimum raise, if specified. Use park.z as a minimum height instead. + return _MAX(park_z, // Minimum height over 0 based on input + _MIN(Z_MAX_POS, // Maximum height is fixed + #ifdef NOZZLE_PARK_Z_RAISE_MIN + NOZZLE_PARK_Z_RAISE_MIN + // Minimum raise... + #endif + current_position.z // ...over current position + ) + ); + } + void Nozzle::park(const uint8_t z_action, const xyz_pos_t &park/*=NOZZLE_PARK_POINT*/) { constexpr feedRate_t fr_xy = NOZZLE_PARK_XY_FEEDRATE, fr_z = NOZZLE_PARK_Z_FEEDRATE; @@ -237,15 +249,9 @@ Nozzle nozzle; do_blocking_move_to_z(_MIN(current_position.z + park.z, Z_MAX_POS), fr_z); break; - default: { - // Apply a minimum raise, overriding G27 Z - const float min_raised_z =_MIN(Z_MAX_POS, current_position.z - #ifdef NOZZLE_PARK_Z_RAISE_MIN - + NOZZLE_PARK_Z_RAISE_MIN - #endif - ); - do_blocking_move_to_z(_MAX(park.z, min_raised_z), fr_z); - } break; + default: // Raise by NOZZLE_PARK_Z_RAISE_MIN, use park.z as a minimum height + do_blocking_move_to_z(park_mode_0_height(park.z), fr_z); + break; } do_blocking_move_to_xy( diff --git a/Marlin/src/libs/nozzle.h b/Marlin/src/libs/nozzle.h index d1706f0b31..7bbd0e35c1 100644 --- a/Marlin/src/libs/nozzle.h +++ b/Marlin/src/libs/nozzle.h @@ -83,6 +83,7 @@ class Nozzle { #if ENABLED(NOZZLE_PARK_FEATURE) + static float park_mode_0_height(const_float_t park_z) _Os; static void park(const uint8_t z_action, const xyz_pos_t &park=NOZZLE_PARK_POINT) _Os; #endif From f4f41d01bfe287f9f0addc802b78bdf190f97fbb Mon Sep 17 00:00:00 2001 From: Vert <45634861+Vertabreak@users.noreply.github.com> Date: Mon, 3 May 2021 22:07:57 -0400 Subject: [PATCH 108/109] UMW follow-up (#21791) --- Marlin/src/lcd/menu/menu_ubl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index c73be1ef7f..1171837a57 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -618,6 +618,7 @@ void _menu_ubl_tools() { sprintf_P(ubl_lcd_gcode, PSTR("M1004S%i"), ubl_storage_slot); #endif queue.inject(ubl_lcd_gcode); + ui.return_to_status(); } void _menu_ubl_mesh_wizard() { @@ -626,11 +627,11 @@ void _menu_ubl_tools() { BACK_ITEM(MSG_UBL_LEVEL_BED); #if HAS_HOTEND - EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0)); + EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, HEATER_0_MINTEMP + 20, 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); + EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP + 20, BED_MAX_TARGET); #endif EDIT_ITEM(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, total_slots); From 9405a5e443b78153bf5e2562ed4aaa0be950970b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 4 May 2021 01:47:42 -0500 Subject: [PATCH 109/109] Fix flush_and_request_resend --- Marlin/src/gcode/queue.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index a79909917e..39ec338bbf 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -270,6 +270,7 @@ void GCodeQueue::flush_and_request_resend(const serial_index_t serial_ind) { SERIAL_FLUSH(); SERIAL_ECHOPGM(STR_RESEND); SERIAL_ECHOLN(serial_state[serial_ind.index].last_N + 1); + SERIAL_ECHOLNPGM(STR_OK); } static bool serial_data_available(serial_index_t index) {